skip to main content
research-article
Open Access

Propositional equality for gradual dependently typed programming

Published:31 August 2022Publication History
Skip Abstract Section

Abstract

Gradual dependent types can help with the incremental adoption of dependently typed code by providing a principled semantics for imprecise types and proofs, where some parts have been omitted. Current theories of gradual dependent types, though, lack a central feature of type theory: propositional equality. Lennon-Bertrand et al. show that, when the reflexive proof refl is the only closed value of an equality type, a gradual extension of the Calculus of Inductive Constructions (CIC) with propositional equality violates static observational equivalences. Extensionally-equal functions should be indistinguishable at run time, but they can be distinguished using a combination of equality and type imprecision.

This work presents a gradual dependently typed language that supports propositional equality. We avoid the above issues by devising an equality type of which refl is not the only closed inhabitant. Instead, each equality proof is accompanied by a term that is at least as precise as the equated terms, acting as a witness of their plausible equality. These witnesses track partial type information as a program runs, raising errors when that information shows that two equated terms are undeniably inconsistent. Composition of type information is internalized as a construct of the language, and is deferred for function bodies whose evaluation is blocked by variables. We thus ensure that extensionally-equal functions compose without error, thereby preventing contexts from distinguishing them. We describe the challenges of designing consistency and precision relations for this system, along with solutions to these challenges. Finally, we prove important metatheory: type safety, conservative embedding of CIC, weak canonicity, and the gradual guarantees of Siek et al., which ensure that reducing a program’s precision introduces no new static or dynamic errors.

References

  1. Thorsten Altenkirch, Conor McBride, and Wouter Swierstra. 2007. Observational Equality, Now!. In Proceedings of the 2007 Workshop on Programming Languages Meets Program Verification (PLPV ’07). ACM, New York, NY, USA. 57–68. isbn:978-1-59593-677-6 https://doi.org/10.1145/1292597.1292608 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Felipe Bañados Schwerter, Alison M. Clark, Khurram A. Jafery, and Ronald Garcia. 2021. Abstracting Gradual Typing Moving Forward: Precise and Space-Efficient. Proc. ACM Program. Lang., 5, POPL (2021), Article 61, Jan., 28 pages. https://doi.org/10.1145/3434342 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Edwin Brady. 2017. Type-driven development with Idris. Manning. isbn:9781617293023 https://www.manning.com/books/type-driven-development-with-idris Google ScholarGoogle Scholar
  4. Pierre-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2016. Partial Type Equivalences for Verified Dependent Interoperability. In Proceedings of the 21st ACM SIGPLAN Conference on Functional Programming (ICFP 2016). ACM Press, Nara, Japan. 298–310. https://doi.org/10.1145/2951913.2951933 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Pierre-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of dependent interoperability. Journal of Functional Programming, 28 (2018), e9. https://doi.org/10.1017/S0956796818000011 Google ScholarGoogle ScholarCross RefCross Ref
  6. Joseph Eremondi, Ronald Garcia, and Éric Tanter. 2022. Propositional Equality for Gradual Dependently Typed Programming (Extended Technical Report). https://doi.org/10.48550/ARXIV.2205.01241 Google ScholarGoogle Scholar
  7. Joseph Eremondi, Éric Tanter, and Ronald Garcia. 2019. Approximate Normalization for Gradual Dependent Types. Proc. ACM Program. Lang., 3, ICFP (2019), Article 88, July, 30 pages. issn:2475-1421 https://doi.org/10.1145/3341692 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for Higher-order Functions. In Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming (ICFP ’02). ACM, New York, NY, USA. 48–59. isbn:1-58113-487-8 https://doi.org/10.1145/581478.581484 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA. 429–442. isbn:978-1-4503-3549-2 https://doi.org/10.1145/2837614.2837670 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Healfdene Goguen, Conor McBride, and James McKinna. 2006. Eliminating Dependent Pattern Matching. Springer Berlin Heidelberg, Berlin, Heidelberg. 521–540. isbn:978-3-540-35464-2 https://doi.org/10.1007/11780274_27 Google ScholarGoogle ScholarCross RefCross Ref
  11. Martin Hofmann and Thomas Streicher. 1998. The groupoid interpretation of type theory. Twenty-five years of constructive type theory (Venice, 1995), 36 (1998), 83–111. https://doi.org/10.1093/oso/9780198501275.003.0008 Google ScholarGoogle ScholarCross RefCross Ref
  12. Koen Jacobs, Amin Timany, and Dominique Devriese. 2021. Fully Abstract from Static to Gradual. Proc. ACM Program. Lang., 5, POPL (2021), Article 7, Jan., 30 pages. https://doi.org/10.1145/3434288 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA. 775–788. isbn:978-1-4503-4660-3 https://doi.org/10.1145/3009837.3009856 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Mark Lemay. 2022. A Dependently Typed Programming Language With Dynamic Equality. Ph. D. Dissertation. Boston University. https://github.com/marklemay/thesis Google ScholarGoogle Scholar
  15. Meven Lennon-Bertrand. 2021. Complete Bidirectional Typing for the Calculus of Inductive Constructions. In 12th International Conference on Interactive Theorem Proving (ITP 2021), Liron Cohen and Cezary Kaliszyk (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 193). Schloss Dagstuhl – Leibniz-Zentrum für Informatik. isbn:978-3-95977-188-7 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ITP.2021.24 Google ScholarGoogle ScholarCross RefCross Ref
  16. Meven Lennon-Bertrand, Kenji Maillard, Nicolas Tabareau, and Éric Tanter. 2022. Gradualizing the Calculus of Inductive Constructions. ACM Trans. Program. Lang. Syst., 44, 2 (2022), Article 7, apr, 82 pages. issn:0164-0925 https://doi.org/10.1145/3495528 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Kenji Maillard, Meven Lennon-Bertrand, Nicolas Tabareau, and Éric Tanter. 2022. A Reasonably Gradual Type Theory. Proc. ACM Program. Lang., 6, ICFP (2022), https://doi.org/10.1145/3547655 Preprint: Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Per Martin-Löf. 1975. About Models for Intuitionistic Type Theories and the Notion of Definitional Equality. In Proceedings of the Third Scandinavian Logic Symposium, Stig Kanger (Ed.) (Studies in Logic and the Foundations of Mathematics, Vol. 82). Elsevier, 81 – 109. issn:0049-237X https://doi.org/10.1016/S0049-237X(08)70727-4 Google ScholarGoogle ScholarCross RefCross Ref
  19. Per Martin-Löf. 1982. Constructive Mathematics and Computer Programming. In Logic, Methodology and Philosophy of Science VI, L. Jonathan Cohen, Jerzy Łoś, Helmut Pfeiffer, and Klaus-Peter Podewski (Eds.) (Studies in Logic and the Foundations of Mathematics, Vol. 104). Elsevier, 153–175. issn:0049-237X https://doi.org/10.1016/S0049-237X(09)70189-2 Google ScholarGoogle ScholarCross RefCross Ref
  20. Conor McBride. 2000. Dependently typed functional programs and their proofs. Ph. D. Dissertation. University of Edinburgh, UK. http://hdl.handle.net/1842/374 Google ScholarGoogle Scholar
  21. Conor McBride. 2002. Elimination with a Motive. In Types for Proofs and Programs, Paul Callaghan, Zhaohui Luo, James McKinna, Robert Pollack, and Robert Pollack (Eds.) (Lecture Notes in Computer Science). Springer, 197–216. isbn:9783540458425 https://doi.org/10.1007/3-540-45842-5_13 Google ScholarGoogle ScholarCross RefCross Ref
  22. Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. Proc. ACM Program. Lang., 2, ICFP (2018), Article 73, July, 30 pages. https://doi.org/10.1145/3236768 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Peter-Michael Osera, Vilhelm Sjöberg, and Steve Zdancewic. 2012. Dependent Interoperability. In Proceedings of the Sixth Workshop on Programming Languages Meets Program Verification (PLPV ’12). ACM, New York, NY, USA. 3–14. isbn:978-1-4503-1125-0 https://doi.org/10.1145/2103776.2103779 Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. 2004. Dynamic Typing with Dependent Types. In Exploring New Frontiers of Theoretical Informatics, Jean-Jacques Levy, Ernst W. Mayr, and John C. Mitchell (Eds.). Springer US, Boston, MA. 437–450. isbn:978-1-4020-8141-5 https://doi.org/10.1007/1-4020-8141-3_34 Google ScholarGoogle ScholarCross RefCross Ref
  25. Loïc Pujet and Nicolas Tabareau. 2022. Observational Equality: Now for Good. Proc. ACM Program. Lang., 6, POPL (2022), Article 32, jan, 27 pages. https://doi.org/10.1145/3498693 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Jeremy Siek, Peter Thiemann, and Philip Wadler. 2015. Blame and Coercion: Together Again for the First Time. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’15). Association for Computing Machinery, New York, NY, USA. 425–435. isbn:9781450334686 https://doi.org/10.1145/2737924.2737968 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Jeremy G. Siek and Tianyu Chen. 2021. Parameterized cast calculi and reusable meta-theory for gradually typed lambda calculi. Journal of Functional Programming, 31 (2021), e30. https://doi.org/10.1017/S0956796821000241 Google ScholarGoogle ScholarCross RefCross Ref
  28. Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop. 81–92. http://scheme2006.cs.uchicago.edu/scheme2006.pdf Google ScholarGoogle Scholar
  29. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages (SNAPL 2015), Thomas Ball, Rastislav Bodik, Shriram Krishnamurthi, Benjamin S. Lerner, and Greg Morrisett (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 32). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 274–293. isbn:978-3-939897-80-4 issn:1868-8969 https://doi.org/10.4230/LIPIcs.SNAPL.2015.274 Google ScholarGoogle ScholarCross RefCross Ref
  30. Jeremy G. Siek and Philip Wadler. 2010. Threesomes, with and Without Blame. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’10). ACM, New York, NY, USA. 365–376. isbn:978-1-60558-479-9 https://doi.org/10.1145/1706299.1706342 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Thomas Streicher. 1993. Investigations into intensional type theory. Ph. D. Dissertation. Ludwig Maximilian Universität. https://www2.mathematik.tu-darmstadt.de/~streicher/HabilStreicher.pdf Habilitation thesis Google ScholarGoogle Scholar
  32. M. Takahashi. 1995. Parallel Reductions in λ -Calculus. Information and Computation, 118, 1 (1995), 120–127. issn:0890-5401 https://doi.org/10.1006/inco.1995.1057 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Éric Tanter and Nicolas Tabareau. 2015. Gradual Certified Programming in Coq. In Proceedings of the 11th Symposium on Dynamic Languages (DLS 2015). ACM, New York, NY, USA. 26–40. isbn:978-1-4503-3690-1 https://doi.org/10.1145/2816707.2816710 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In Proceedings of the 18th European Symposium on Programming Languages and Systems: Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009 (ESOP ’09). Springer-Verlag, Berlin, Heidelberg. 1–16. isbn:9783642005893 https://doi.org/10.1007/978-3-642-00590-9_1 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. A.K. Wright and M. Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation, 115, 1 (1994), 38–94. issn:0890-5401 https://doi.org/10.1006/inco.1994.1093 Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Jakub Zalewski, James McKinna, J. Garrett Morris, and Philip Wadler. 2020. λ dB: Blame tracking at higher fidelity. https://wgt20.irif.fr/wgt20-final98-acmpaginated.pdf First ACM SIGPLAN Workshop on Gradual Typing 2020, WGT 2020 ; Conference date: 19-01-2020 Through 25-01-2020 Google ScholarGoogle Scholar

Index Terms

  1. Propositional equality for gradual dependently typed programming

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image Proceedings of the ACM on Programming Languages
        Proceedings of the ACM on Programming Languages  Volume 6, Issue ICFP
        August 2022
        959 pages
        EISSN:2475-1421
        DOI:10.1145/3554306
        Issue’s Table of Contents

        Copyright © 2022 Owner/Author

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 31 August 2022
        Published in pacmpl Volume 6, Issue ICFP

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!