Internalizing representation independence with univalence

In their usual form, representation independence metatheorems provide an external guarantee that two implementations of an abstract interface are interchangeable when they are related by an operation-preserving correspondence. If our programming language is dependently-typed, however, we would like to appeal to such invariance results within the language itself, in order to obtain correctness theorems for complex implementations by transferring them from simpler, related implementations. Recent work in proof assistants has shown that Voevodsky's univalence principle allows transferring theorems between isomorphic types, but many instances of representation independence in programming involve non-isomorphic representations. In this paper, we develop techniques for establishing internal relational representation independence results in dependent type theory, by using higher inductive types to simultaneously quotient two related implementation types by a heterogeneous correspondence between them. The correspondence becomes an isomorphism between the quotiented types, thereby allowing us to obtain an equality of implementations by univalence. We illustrate our techniques by considering applications to matrices, queues, and finite multisets. Our results are all formalized in Cubical Agda, a recent extension of Agda which supports univalence and higher inductive types in a computationally well-behaved way.

[1]  All , 1960 .

[2]  Paul Benacerraf,et al.  Philosophy of mathematics: What numbers could not be , 1965 .

[3]  P. Martin-Löf An Intuitionistic Theory of Types: Predicative Part , 1975 .

[4]  E. Dijkstra On the Role of Scientific Thought , 1982 .

[5]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[6]  Paul Benacerraf,et al.  What the numbers could not be , 1983 .

[7]  D. A. Turner,et al.  Miranda: A Non-Strict Functional language with Polymorphic Types , 1985, FPCA.

[8]  John C. Mitchell,et al.  Representation independence and data abstraction , 1986, POPL '86.

[9]  Donald Sannella,et al.  On Observational Equivalence and Algebraic Specification , 1987, J. Comput. Syst. Sci..

[10]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[11]  Edmund Robinson,et al.  Parametricity as Isomorphism , 1994, Theor. Comput. Sci..

[12]  Xavier Leroy,et al.  Applicative functors and fully transparent higher-order modules , 1995, POPL '95.

[13]  Donald Sannella,et al.  The Definition of Extended ML: A Gentle Introduction , 1997, Theor. Comput. Sci..

[14]  Michael Hedberg,et al.  A coherence theorem for Martin-Löf's type theory , 1998, Journal of Functional Programming.

[15]  Chris Okasaki,et al.  Purely functional data structures , 1998 .

[16]  Nicolas Magaud,et al.  Changing Data Structures in Type Theory: A Study of Natural Numbers , 2000, TYPES.

[17]  Gilles Barthe,et al.  Setoids in type theory , 2003, Journal of Functional Programming.

[18]  Nicolas Magaud Changing Data Representation within the Coq System , 2003, TPHOLs.

[19]  Patrik Jansson,et al.  Proofs for free - Parametricity for dependent types , 2012, J. Funct. Program..

[20]  Nils Anders Danielsson Bag Equivalence via a Proof-Relevant Membership Relation , 2012, ITP.

[21]  Chantal Keller,et al.  Parametricity in an Impredicative Sort , 2012, CSL.

[22]  Chantal Keller,et al.  Parametricity in an Impredicative Sort , 2012, ArXiv.

[23]  E. M. Rijke,et al.  Homotopy type theory , 2012 .

[24]  Tobias Nipkow,et al.  Data Refinement in Isabelle/HOL , 2013, ITP.

[25]  Derek Dreyer,et al.  Internalizing Relational Parametricity in the Extensional Calculus of Constructions , 2013, CSL.

[26]  Edwin Brady,et al.  Idris, a general-purpose dependently typed programming language: Design and implementation , 2013, Journal of Functional Programming.

[27]  Thierry Coquand,et al.  Isomorphism is equality , 2013 .

[28]  Peter Lammich,et al.  Automatic Data Refinement , 2013, ITP.

[29]  P. Aczel,et al.  Homotopy Type Theory: Univalent Foundations of Mathematics , 2013 .

[30]  Cyril Cohen,et al.  Refinements for Free! , 2013, CPP.

[31]  Steve Awodey,et al.  Structuralism, Invariance, and Univalence , 2014 .

[32]  Jacques Carette,et al.  Realms: A Structure for Consolidating Knowledge about Mathematical Theories , 2014, CICM.

[33]  C. Flori,et al.  Homotopy Type Theory : Univalent Foundations of Mathematics , 2014 .

[34]  Vladimir Voevodsky The equivalence axiom and univalent models of type theory. (Talk at CMU on February 4, 2010) , 2014 .

[35]  Enrico Tassi,et al.  A Computer-Algebra-Based Formal Proof of the Irrationality of ζ(3) , 2014, ITP.

[36]  Vladimir Voevodsky,et al.  An experimental library of formalized Mathematics based on the univalent foundations , 2015, Mathematical Structures in Computer Science.

[37]  Jeremy Avigad,et al.  The Lean Theorem Prover (System Description) , 2015, CADE.

[38]  Thierry Coquand,et al.  Cubical Type Theory: A Constructive Interpretation of the Univalence Axiom , 2015, TYPES.

[39]  Thierry Coquand,et al.  A Presheaf Model of Parametric Type Theory , 2015, MFPS.

[40]  Adam Chlipala,et al.  Fiat , 2015, POPL.

[41]  Alvin Cheung,et al.  HoTTSQL: proving query rewrites with univalent SQL semantics , 2016, PLDI.

[42]  Robert Harper,et al.  Homotopical patch theory , 2016, J. Funct. Program..

[43]  Herman Geuvers,et al.  Higher Inductive Types in Programming , 2017, J. Univers. Comput. Sci..

[44]  J. Gregory Morrisett,et al.  Revisiting Parametricity: Inductives and Uniformity of Propositions , 2017, ArXiv.

[45]  Simon Boulier,et al.  The next 700 syntactical models of type theory , 2017, CPP.

[46]  Thierry Coquand,et al.  Notions of Anonymous Existence in Martin-Löf Type Theory , 2016, Log. Methods Comput. Sci..

[47]  Dominique Devriese,et al.  Parametric quantifiers for dependent type theory , 2017, Proc. ACM Program. Lang..

[48]  Karl Crary,et al.  Modules, abstraction, and parametric polymorphism , 2017, POPL.

[49]  Andrej Bauer,et al.  The HoTT library: a formalization of homotopy type theory in Coq , 2016, CPP.

[50]  Ulrik Buchholtz,et al.  Homotopy Type Theory in Lean , 2017, ITP.

[51]  Thierry Coquand,et al.  On Higher Inductive Types in Cubical Type Theory , 2018, LICS.

[52]  Dominique Devriese,et al.  Degrees of Relatedness: A Unified Framework for Parametricity, Irrelevance, Ad Hoc Polymorphism, Intersections, Unions and Algebra in Dependent Type Theory , 2018, LICS.

[53]  Nicolas Tabareau,et al.  Equivalences for free: univalent parametricity for effective transport , 2018, Proc. ACM Program. Lang..

[54]  Herman Geuvers,et al.  Finite sets in homotopy type theory , 2018, CPP.

[55]  Robert Harper,et al.  Cartesian Cubical Computational Type Theory: Constructive Reasoning with Paths and Equalities , 2018, CSL.

[56]  Mart'in Hotzel Escard'o,et al.  Introduction to Univalent Foundations of Mathematics with Agda , 2019, ArXiv.

[57]  Håkon Robbestad Gylterud,et al.  Multisets in type theory , 2016, Mathematical Proceedings of the Cambridge Philosophical Society.

[58]  P. Lumsdaine,et al.  Semantics of higher inductive types , 2017, Mathematical Proceedings of the Cambridge Philosophical Society.

[59]  Robert Harper,et al.  Higher inductive types in cubical computational type theory , 2019, Proc. ACM Program. Lang..

[60]  N. Yazdani,et al.  Ornaments for Proof Reuse in Coq , 2019, ITP.

[61]  Andreas Abel,et al.  Cubical agda: a dependently typed programming language with univalence and higher inductive types , 2019, Journal of Functional Programming.

[62]  Peter LeFanu Lumsdaine,et al.  Displayed Categories , 2017, FSCD.

[63]  Neil Ghani,et al.  Three equivalent ordinal notation systems in cubical Agda , 2019, CPP.

[64]  The law of excluded middle in the simplicial model of type theory , 2020, 2006.13694.

[65]  Dimitris Tsementzis,et al.  A Higher Structure Identity Principle , 2017, LICS.

[66]  PHILIP WADLER,et al.  Leibniz equality is isomorphic to Martin-Löf identity, parametrically , 2020, J. Funct. Program..

[67]  E. Cavallo,et al.  Internal Parametricity for Cubical Type Theory , 2020, CSL.

[68]  Nicolas Tabareau,et al.  The Marriage of Univalence and Parametricity , 2019, J. ACM.

[69]  Thierry Coquand,et al.  Syntax and models of Cartesian cubical type theory , 2021, Mathematical Structures in Computer Science.