skip to main content
research-article

The Marriage of Univalence and Parametricity

Authors Info & Claims
Published:15 January 2021Publication History
Skip Abstract Section

Abstract

Reasoning modulo equivalences is natural for everyone, including mathematicians. Unfortunately, in proof assistants based on type theory, which are frequently used to mechanize mathematical results and carry out program verification efforts, equality is appallingly syntactic, and as a result, exploiting equivalences is cumbersome at best. Parametricity and univalence are two major concepts that have been explored in the literature to transport programs and proofs across type equivalences, but they fall short of achieving seamless, automatic transport. This work first clarifies the limitations of these two concepts when considered in isolation and then devises a fruitful marriage between both. The resulting concept, called univalent parametricity, is an extension of parametricity strengthened with univalence that fully realizes programming and proving modulo equivalences. Our approach handles both type and term dependency, as well as type-level computation. In addition to the theory of univalent parametricity, we present a lightweight framework implemented in the Coq proof assistant that allows the user to transparently transfer definitions and theorems for a type to an equivalent one, as if they were equal. For instance, this makes it possible to conveniently switch between an easy-to-reason-about representation and a computationally efficient representation as soon as they are proven equivalent. The combination of parametricity and univalence supports transport à la carte: basic univalent transport, which stems from a type equivalence, can be complemented with additional proofs of equivalences between functions over these types, in order to be able to transport more programs and proofs, as well as to yield more efficient terms. We illustrate the use of univalent parametricity on several examples, including a recent integration of native integers in Coq. This work paves the way to easier-to-use proof assistants by supporting seamless programming and proving modulo equivalences.

References

  1. Thorsten Altenkirch and Ambrus Kaposi. 2015. Towards a cubical type theory without an interval. In 21st International Conference on Types for Proofs and Programs (TYPES’15), Tarmo Uustalu (Ed.), Vol. 69. LIPICS.Google ScholarGoogle Scholar
  2. Thorsten Altenkirch, Conor McBride, and Wouter Swierstra. 2007. Observational equality, now! In Proceedings of the Workshop on Programming Languages meets Program Verification (PLPV’07). 57--68.Google ScholarGoogle Scholar
  3. Abhishek Anand and Greg Morrisett. 2017. Revisiting parametricity: Inductives and uniformity of propositions. CoRR abs/1705.01163 (2017).Google ScholarGoogle Scholar
  4. Carlo Angiuli, Kuen-Bang Hou, and Robert Harper. 2018. Cartesian cubical computational type theory: Constructive reasoning with paths and equalities. In 27th EACSL Annual Conference on Computer Science Logic (CSL’18). 6:1--6:17.Google ScholarGoogle Scholar
  5. Robert Atkey, Neil Ghani, and Patricia Johann. 2014. A relationally parametric model of dependent type theory. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’14). Association for Computing Machinery, New York, NY, 503--515.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Andrej Bauer, Jason Gross, Peter LeFanu Lumsdaine, Michael Shulman, Matthieu Sozeau, and Bas Spitters. 2017. The HoTT library: A formalization of homotopy type theory in Coq. In Proceedings of the 6th ACM SIGPLAN Conference on Certified Programs and Proofs (CPP’17). ACM, New York, NY, 164--172.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Jean-Philippe Bernardy, Thierry Coquand, and Guilhem Moulin. 2015. A presheaf model of parametric type theory. Electronic Notes in Theoretical Computer Science 319 (2015), 67--82.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Jean-Philippe Bernardy, Patrik Jansson, and Ross Paterson. 2012. Proofs for free: Parametricity for dependent types. Journal of Functional Programming 22, 2 (March 2012), 107--152.Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Simon Boulier, Pierre-Marie Pédrot, and Nicolas Tabareau. 2017. The next 700 syntactical models of type theory. In Certified Programs and Proofs (CPP’17). 182--194.Google ScholarGoogle Scholar
  10. Evan Cavallo and Robert Harper. 2020. Internal parametricity for Cubical Type Theory. In 28th EACSL Annual Conference on Computer Science Logic (CSL'20). 13:1--13:17 pages.Google ScholarGoogle Scholar
  11. Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mörtberg. 2015. Cubical Type Theory: A constructive interpretation of the univalence axiom. In Proceedings of the 21st International Conference on Types for Proofs and Programs (TYPES'15). 5:1--5:34 pages.Google ScholarGoogle Scholar
  12. Cyril Cohen, Maxime Dénès, and Anders Mörtberg. 2013. Refinements for free! In Proceedings of the International Conference on Certified Programming and Proofs (CPP’13) (Lecture Notes in Computer Science), G. Gonthier and M. Norrish (Eds.), Vol. 8307. Springer-Verlag, 147--162.Google ScholarGoogle Scholar
  13. Coq Development Team. 2020. The Coq Proof Assistant. https://doi.org/10.5281/zenodo.1003420.Google ScholarGoogle Scholar
  14. Thierry Coquand and Gérard Huet. 1988. The calculus of constructions. Information and Computation 76, 2--3 (Feb. 1988), 95--120.Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Pierre-Évariste Dagand and Conor McBride. 2014. Transporting functions across ornaments. Journal of Functional Programming 24, 2--3 (2014), 316--383.Google ScholarGoogle ScholarCross RefCross Ref
  16. Nicola Gambino and Martin Hyland. 2004. Wellfounded trees and dependent polynomial functors. In Proceedings of Types for Proofs and Programs (TYPES’03) (Lecture Notes in Computer Science), Vol. 3085. Springer-Verlag, 210--225.Google ScholarGoogle ScholarCross RefCross Ref
  17. Healfdene Goguen, Conor McBride, and James McKinna. 2006. Eliminating Dependent Pattern Matching. Springer Berlin Heidelberg, Berlin,521--540.Google ScholarGoogle Scholar
  18. Florian Haftmann, Alexander Krauss, Ondřej Kunčar, and Tobias Nipkow. 2013. Data refinement in Isabelle/HOL. In Proceedings of the 4th International Conference on Interactive Theorem Proving (ITP’13) (Lecture Notes in Computer Science), S. Blazy, C. Paulin-Mohring, and D. Pichardie (Eds.), Vol. 7998. Springer-Verlag, 100--115.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Michael Hedberg. 1998. A coherence theorem for Martin-Löf’s type theory. Journal of Functional Programming 8, 4 (July 1998), 413--436.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Brian Huffman and Ondřej Kunčar. 2013. Lifting and transfer: A modular design for quotients in Isabelle/HOL. In Proceedings of the 3rd International Conference on Certified Programs and Proofs (CPP’13). Springer-Verlag, Melbourne, Australia, 131--146.Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Chris Kapulkin and Peter LeFanu Lumsdaine. 2018. Homotopical inverse diagrams in categories with attributes. arXiv preprint arXiv:1808.01816 (2018).Google ScholarGoogle Scholar
  22. Neelakantan R. Krishnaswami and Derek Dreyer. 2013. Internalizing relational parametricity in the extensional calculus of constructions. In Proceedings of the Conference for Computer Science Logic (CSL’13). 432--451.Google ScholarGoogle Scholar
  23. Peter Lammich. 2013. Automatic data refinement. In Proceedings of the 4th international conference on interactive theorem proving (ITP’13) (Lecture Notes in Computer Science), S. Blazy, C. Paulin-Mohring, and D. Pichardie (Eds.), Vol. 7998. Springer-Verlag, 84--99.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Nicolas Magaud. 2003. Changing data representation within the Coq system. In International Conference on Theorem Proving in Higher Order Logics (TPHOLs’03) (Lecture Notes in Computer Science), D. Basin and B. Wolff (Eds.), Vol. 2758. Springer-Verlag.Google ScholarGoogle ScholarCross RefCross Ref
  25. Nicolas Magaud and Yves Bertot. 2000. Changing data structures in type theory: A study of natural numbers. In International Workshop on Types for Proofs and Programs (TYPES’00) (Lecture Notes in Computer Science), P. Callaghan, Z. Luo, J. McKinna, and R. Pollack (Eds.), Vol. 2277. Springer-Verlag, 181--196.Google ScholarGoogle Scholar
  26. Per Martin-Löf. 1975. An intuitionistic theory of types: Predicative part. In Logic Colloquium’73, H. E. Rose and J. C. Shepherdson (Eds.). Studies in Logic and the Foundations of Mathematics, Vol. 80. Elsevier, 73--118.Google ScholarGoogle Scholar
  27. Ulf Norell. 2009. Dependently typed programming in Agda. In Proceedings of the 4th International Workshop on Types in Language Design and Implementation (TLDI’09). ACM, 1--2.Google ScholarGoogle ScholarCross RefCross Ref
  28. Andreas Nuyts, Andrea Vezzosi, and Dominique Devriese. 2017. Parametric quantifiers for dependent type theory. Proceedings of the ACM on Programming Languages 1, ICFP, Article Article 32 (Aug. 2017), 29 pages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Christine Paulin-Mohring. 2015. Introduction to the calculus of inductive constructions. In All About Proofs, Proofs for All, Bruno Woltzenlogel Paleo and David Delahaye (Eds.). Studies in Logic (Mathematical Logic and Foundations), Vol. 55.Google ScholarGoogle Scholar
  30. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. 2006. Simple unification-based type inference for GADTs. In Proceedings of the 11th ACM SIGPLAN Conference on Functional Programming (ICFP’06). ACM Press, Portland, Oregon, 50--61.Google ScholarGoogle Scholar
  31. John C. Reynolds. 1983. Types, abstraction and parametric polymorphism. In IFIP Congress. 513--523.Google ScholarGoogle Scholar
  32. Talia Ringer, Nathaniel Yazdani, John Leo, and Dan Grossman. 2019. Ornaments for proof reuse in Coq. In 10th International Conference on Interactive Theorem Proving (ITP’19) (Leibniz International Proceedings in Informatics (LIPIcs)), John Harrison, John O’Leary, and Andrew Tolmach (Eds.), Vol. 141. Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, 26:1--26:19.Google ScholarGoogle Scholar
  33. Edmund Robinson. 1994. Parametricity as isomorphism. Theoretical Computer Science 136, 1 (1994), 163--181.Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Michael Shulman. 2015. Univalence for inverse diagrams and homotopy canonicity. Mathematical Structures in Computer Science 25, 5 (2015), 1203--1277.Google ScholarGoogle ScholarCross RefCross Ref
  35. Matthieu Sozeau, Abhishek Anand, Simon Boulier, Cyril Cohen, Yannick Forster, Fabian Kunze, Gregory Malecha, Nicolas Tabareau, and Théo Winterhalter. 2020a. Coq Coq correct! Verification of type checking and erasure for Coq, in Coq. Proceedings of the ACM on Programming Languages 4, POPL (Jan. 2020), 8:1--8:28.Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Matthieu Sozeau, Abhishek Anand, Simon Boulier, Cyril Cohen, Yannick Forster, Fabian Kunze, Gregory Malecha, Nicolas Tabareau, and Théo Winterhalter. 2020b. The MetaCoq project. Journal of Automated Reasoning 64 (Feb. 2020), 947--999.Google ScholarGoogle ScholarCross RefCross Ref
  37. Nicolas Tabareau, Éric Tanter, and Matthieu Sozeau. 2018. Equivalences for free: Univalent parametricity for effective transport. Proceedings of the ACM on Programming Languages 2, ICFP (Sept. 2018), 92:1--92:29.Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Univalent Foundations Program. 2013. Homotopy Type Theory: Univalent Foundations of Mathematics. Institute for Advanced Study.Google ScholarGoogle Scholar
  39. Andrea Vezzosi, Anders Mörtberg, and Andreas Abel. 2019. Cubical Agda: A dependently typed programming language with univalence and higher inductive types. Proceedings of the ACM on Programming Languages 3, ICFP (Aug. 2019), 87:1--87:29.Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Vladimir Voevodsky. 2010. The Equivalence Axiom and Univalent Models of Type Theory. arXiv:1402.5556.Google ScholarGoogle Scholar
  41. Philip Wadler. 1989. Theorems for free! In Functional Programming Languages and Computer Architecture. ACM Press, 347--359.Google ScholarGoogle Scholar
  42. Theo Zimmermann and Hugo Herbelin. 2015. Automatic and Transparent Transfer of Theorems along Isomorphisms in the Coq Proof Assistant. arXiv:1505.05028v4.Google ScholarGoogle Scholar

Index Terms

  1. The Marriage of Univalence and Parametricity

        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 Journal of the ACM
          Journal of the ACM  Volume 68, Issue 1
          February 2021
          215 pages
          ISSN:0004-5411
          EISSN:1557-735X
          DOI:10.1145/3437069
          Issue’s Table of Contents

          Copyright © 2021 Owner/Author

          This work is licensed under a Creative Commons Attribution International 4.0 License.

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 15 January 2021
          • Accepted: 1 October 2020
          • Revised: 1 May 2020
          • Received: 1 August 2019
          Published in jacm Volume 68, Issue 1

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article
          • Research
          • Refereed

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        HTML Format

        View this article in HTML Format .

        View HTML Format