A cosmology of datatypes : reusability and dependent types

This dissertation defends the idea of a closed dependent type theory whose inductive types are encoded in a universe. Each inductive definition arises by interpreting its description – itself a firstclass citizen in the type theory. Datatype-generic programming thus becomes ordinary programming. This approach is illustrated by several generic programs. We then introduce an elaboration of inductive definitions down to the universe of datatypes. By elaborating an inductive definition – a syntactic artefact – to its code – its type theoretic denotation – we obtain an internalised account of inductive types inside type theory. This is a small step toward bootstrapping, i.e. implementing the inductive fragment in the type theory itself. Building upon this universe of datatypes, ornaments let us treat datatypes as the combination of a structure and a logic: they relate datatypes through their common structure. We set out to rationalise this calculus of structures. We study a categorical model of ornaments, based on Cartesian morphisms of containers. We also illustrate the adequacy of our model by recasting the standard idioms into the categorical mould, and by translating the discovered categorical structures into type theoretic artefacts. Nonetheless, the extreme accuracy of these finely indexed datatypes is a curse for code reuse. Similar functions must be duplicated across similarly structured – but logically incompatible – indexed datatypes. We shall see how code reuse can be achieved by ornamenting functions. We thus capture the relationship between functions such as the addition of natural numbers and the concatenation of lists. We also demonstrate how the implementation of the former informs the implementation of the latter.

[1]  Peter Dybjer,et al.  Internal Type Theory , 1995, TYPES.

[2]  Conor McBride,et al.  Elaborating Inductive Definitions , 2012, ArXiv.

[3]  David Walker,et al.  A Concurrent Logical Framework: The Propositional Fragment , 2003, TYPES.

[4]  Conor McBride Ornamental Algebras, Algebraic Ornaments , 2014 .

[5]  Harald Ruess,et al.  Polytypic Abstraction in Type Theory , 1998 .

[6]  Vincent Siles Investigation on the typing of equality in type systems. (Etude sur le typage de l'égalité dans les systèmes de types) , 2010 .

[7]  Christine C. Paulin Extraction de programmes dans le calcul des constructions , 1989 .

[8]  Alfred North Whitehead,et al.  Principia Mathematica to *56 , 1910 .

[9]  Conor McBride,et al.  Elimination with a Motive , 2000, TYPES.

[10]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

[11]  Andrea Asperti,et al.  A Bi-Directional Refinement Algorithm for the Calculus of (Co)Inductive Constructions , 2012, Log. Methods Comput. Sci..

[12]  Jeremy Gibbons Datatype-Generic Programming , 2006, SSDGP.

[13]  Thierry Coquand,et al.  An Algorithm for Type-Checking Dependent Types , 1996, Sci. Comput. Program..

[14]  Bengt Nordström,et al.  The ALF Proof Editor and Its Proof Engine , 1994, TYPES.

[15]  Thorsten Altenkirch,et al.  Monadic Presentations of Lambda Terms Using Generalized Inductive Types , 1999, CSL.

[16]  Fredrik Lindblad,et al.  A Tool for Automated Theorem Proving in Agda , 2004, TYPES.

[17]  F. Guattari,et al.  A Thousand Plateaus: Capitalism and Schizophrenia , 1980 .

[18]  Thierry Coquand,et al.  A MODULAR TYPE-CHECKING ALGORITHM FOR TYPE THEORY WITH SINGLETON TYPES AND PROOF IRRELEVANCE , 2011 .

[19]  Richard S. Bird,et al.  Algebra of programming , 1997, Prentice Hall International series in computer science.

[20]  Dan Synek,et al.  A Set Constructor for Inductive Sets in Martin-Löf's Type Theory , 1989, Category Theory and Computer Science.

[21]  Pierre-Louis Curien Substitution up to Isomorphism , 1993, Fundam. Informaticae.

[22]  John C. Reynolds,et al.  Polymorphism is not Set-Theoretic , 1984, Semantics of Data Types.

[23]  Andrew M. Pitts,et al.  Polymorphism is Set Theoretic, Constructively , 1987, Category Theory and Computer Science.

[24]  Erik Palmgren,et al.  Wellfounded trees in categories , 2000, Ann. Pure Appl. Log..

[25]  Wouter Swierstra,et al.  A functional specification of effects , 2009 .

[26]  Zhaohui Luo,et al.  Computation and reasoning , 1994 .

[27]  Wim Veldman Review: Per Martin-Lof, H. E. Rose, J. C. Shepherdson, An Intuitionistic Theory of Types: Predicative Part , 1984 .

[28]  C. Paulin-Mohring Définitions Inductives en Théorie des Types , 1996 .

[29]  Simon L. Peyton Jones,et al.  Scrap your boilerplate: a practical design pattern for generic programming , 2003, TLDI '03.

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

[31]  Gordon D. Plotkin,et al.  The category-theoretic solution of recursive domain equations , 1977, 18th Annual Symposium on Foundations of Computer Science (sfcs 1977).

[32]  Michael Shulman,et al.  Framed bicategories and monoidal fibrations , 2007, 0706.1286.

[33]  Ralf Hinze,et al.  Type-indexed data types , 2004, Sci. Comput. Program..

[34]  Simon L. Peyton Jones,et al.  Complete and decidable type inference for GADTs , 2009, ICFP.

[35]  Zhaohui Luo,et al.  Inductive data types: well-ordering types revisited , 1993 .

[36]  Makoto Hamana,et al.  A foundation for GADTs and inductive families: dependent polynomial functor approach , 2011, WGP@ICFP.

[37]  Bruno C. d. S. Oliveira,et al.  Comparing libraries for generic programming in haskell , 2008, Haskell '08.

[38]  Johan Jeuring,et al.  A generic deriving mechanism for Haskell , 2010, Haskell '10.

[39]  Ralph Matthes An induction principle for nested datatypes in intensional type theory , 2009, J. Funct. Program..

[40]  Richard S. Bird,et al.  Nested Datatypes , 1998, MPC.

[41]  Thierry Coquand,et al.  Pattern Matching with Dependent Types , 1992 .

[42]  Martin Hofiiiaiiii The Groupoid Model Refutes Uniqueness of Identity Proofs , 1994 .

[43]  Clément Fumex Induction and coinduction schemes in category theory , 2012 .

[44]  William W. Tait,et al.  Intensional interpretations of functionals of finite type I , 1967, Journal of Symbolic Logic.

[45]  Conor McBride,et al.  Let's See How Things Unfold: Reconciling the Infinite with the Intensional (Extended Abstract) , 2009, CALCO.

[46]  Peter Aczel,et al.  An Introduction to Inductive Definitions , 1977 .

[47]  Harald Ruess,et al.  Polytypic Proof Construction , 1999, TPHOLs.

[48]  Chung-Kil Hur,et al.  Strongly Typed Term Representations in Coq , 2011, Journal of Automated Reasoning.

[49]  Robert Atkey,et al.  Refining Inductive Types , 2012, Log. Methods Comput. Sci..

[50]  Jeremy Gibbons,et al.  Modularising inductive families , 2013 .

[51]  Johan Jeuring,et al.  Generic Views on Data Types , 2006, MPC.

[52]  Judicaël Courant,et al.  Explicit Universes for the Calculus of Constructions , 2002, TPHOLs.

[53]  Peter Morris,et al.  The gentle art of levitation , 2010, ICFP '10.

[54]  Conor McBride,et al.  The view from the left , 2004, Journal of Functional Programming.

[55]  S. Lane Categories for the Working Mathematician , 1971 .

[56]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[57]  R. Seely,et al.  Locally cartesian closed categories and type theory , 1984, Mathematical Proceedings of the Cambridge Philosophical Society.

[58]  Conor McBride,et al.  Inductive Families Need Not Store Their Indices , 2003, TYPES.

[59]  Lennart Augustsson,et al.  Cayenne—a language with dependent types , 1998, ICFP '98.

[60]  Thorsten Altenkirch,et al.  Generic Programming within Dependently Typed Programming , 2002, Generic Programming.

[61]  Jean-Philippe Bernardy,et al.  Realizability and Parametricity in Pure Type Systems , 2011, FoSSaCS.

[62]  Frank Pfenning,et al.  Refinement types for ML , 1991, PLDI '91.

[63]  Johan Jeuring,et al.  Pull-Ups, Push-Downs, and Passing It Around - Exercises in Functional Incrementalization , 2009, IFL.

[64]  Rance Cleaveland,et al.  Implementing mathematics with the Nuprl proof development system , 1986 .

[65]  Robert Harper,et al.  2-Dimensional Directed Type Theory , 2011, MFPS.

[66]  Per Martin-Löf,et al.  Intuitionistic type theory , 1984, Studies in proof theory.

[67]  Robert Harper,et al.  Type Checking with Universes , 1991, Theor. Comput. Sci..

[68]  Healfdene Goguen A typed operational semantics for type theory , 1994 .

[69]  Ralf Hinze,et al.  Memo functions‚ polytypically! , 2000 .

[70]  Leslie Lamport,et al.  How to Write a Proof , 1995 .

[71]  Conor McBride,et al.  A Few Constructions on Constructors , 2004, TYPES.

[72]  E. Wigner The Unreasonable Effectiveness of Mathematics in the Natural Sciences (reprint) , 1960 .

[73]  Per Martin-Löf,et al.  Constructive mathematics and computer programming , 1984 .

[74]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[75]  Ulf Norell Functional generic programming and type theory , 2002 .

[76]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[77]  Juan Chen,et al.  Secure distributed programming with value-dependent types , 2013, J. Funct. Program..

[78]  Matthieu Sozeau Equations: A Dependent Pattern-Matching Compiler , 2010, ITP.

[79]  Martin Hyland,et al.  Wellfounded Trees and Dependent Polynomial Functors , 2003, TYPES.

[80]  Herman Geuvers,et al.  Induction Is Not Derivable in Second Order Dependent Type Theory , 2001, TLCA.

[81]  Steven Awodey,et al.  Inductive Types in Homotopy Type Theory , 2012, 2012 27th Annual IEEE Symposium on Logic in Computer Science.

[82]  Edsko de Vries,et al.  Polytypic properties and proofs in Coq , 2009, WGP '09.

[83]  Thorsten Altenkirch,et al.  Foundations of Software Science and Computation Structures: 6th International Conference, FOSSACS 2003 Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2003 Warsaw, Poland, April 7–11, 2003 Proceedings , 2003, Lecture Notes in Computer Science.

[84]  Conor McBride,et al.  Transporting functions across ornaments , 2012, ICFP '12.

[85]  Peter Dybjer,et al.  The Biequivalence of Locally Cartesian Closed Categories and Martin-Löf Type Theories , 2014, Math. Struct. Comput. Sci..

[86]  Johan Jeuring,et al.  PolyP—a polytypic programming language extension , 1997, POPL '97.

[87]  Magnus Carlsson,et al.  An exercise in dependent types: A well-typed interpreter , 1999 .

[88]  Martin Hofmann,et al.  On the Interpretation of Type Theory in Locally Cartesian Closed Categories , 1994, CSL.

[89]  Benjamin Werner,et al.  Une Théorie des Constructions Inductives , 1994 .

[90]  Gordon D. Plotkin,et al.  Abstract syntax and variable binding , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[91]  M. AdelsonVelskii,et al.  AN ALGORITHM FOR THE ORGANIZATION OF INFORMATION , 1963 .

[92]  E. Van Gestel,et al.  Programming in Martin-Löf's Type Theory: an Introduction : Bengt Nordström, Kent Petersson and Jan M. Smith Intl. Series of Monographs on Computer Science, Vol. 7, Oxford Science Publications, Oxford, 1990, 231 pages , 1991 .

[93]  Peter Morris,et al.  Exploring the Regular Tree Types , 2004, TYPES.

[94]  Erik Palmgren,et al.  On Universes in Type Theory , 2011 .

[95]  James Cheney,et al.  First-Class Phantom Types , 2003 .

[96]  J. Robin B. Cockett,et al.  Shapely Types and Shape Polymorphism , 1994, ESOP.

[97]  Edsko de Vries,et al.  Polytypic programming in COQ , 2008, WGP '08.

[98]  Gordon D. Plotkin,et al.  Algebraic Operations and Generic Effects , 2003, Appl. Categorical Struct..

[99]  Robin Milner,et al.  Definition of standard ML , 1990 .

[100]  Robert Harper,et al.  A type-theoretic interpretation of standard ML , 2000, Proof, Language, and Interaction.

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

[102]  Matthias Puech,et al.  Proofs, Upside Down - A Functional Correspondence between Natural Deduction and the Sequent Calculus , 2013, APLAS.

[103]  Jaakko Järvi,et al.  A comparative study of language support for generic programming , 2003, OOPSLA 2003.

[104]  N. Gambino,et al.  Polynomial functors and polynomial monads , 2009, Mathematical Proceedings of the Cambridge Philosophical Society.

[105]  Simon L. Peyton Jones,et al.  Derivable Type Classes , 2001, Haskell.

[106]  Ralf Hinze,et al.  Comparing Approaches to Generic Programming in Haskell , 2006, SSDGP.

[107]  Nicolas Oury Egalité et filtrage avec types dépendants dans le calcul des constructions inductives , 2006 .

[108]  Conor McBride,et al.  A Categorical Treatment of Ornaments , 2012, 2013 28th Annual ACM/IEEE Symposium on Logic in Computer Science.

[109]  Aarne Ranta,et al.  An Extensible Proof Text Editor , 2000, LPAR.

[110]  Bart Jacobs,et al.  Categorical Logic and Type Theory , 2001, Studies in logic and the foundations of mathematics.

[111]  Guy L. Steele,et al.  Growing a Language , 1999, High. Order Symb. Comput..

[112]  I. Moerdijk,et al.  Sheaves in geometry and logic: a first introduction to topos theory , 1992 .

[113]  Peter Morris,et al.  Indexed Containers , 2009, 2009 24th Annual IEEE Symposium on Logic In Computer Science.

[114]  Peter Dybjer,et al.  A Finite Axiomatization of Inductive-Recursive Definitions , 1999, TLCA.

[115]  P. Martin-Lof,et al.  ON THE MEANINGS OF THE LOGICAL CONSTANTS AND THE JUSTIFICATIONS OF THE LOGICAL LAWS(Logic and the Foundations of Mathematics) , 1986 .

[116]  Conor McBride,et al.  Eliminating Dependent Pattern Matching , 2006, Essays Dedicated to Joseph A. Goguen.

[117]  Johan Jeuring,et al.  Generic programming with fixed points for mutually recursive datatypes , 2009, ICFP.

[118]  Thorsten Altenkirch,et al.  Observational equality, now! , 2007, PLPV.

[119]  Eduardo Giménez,et al.  Codifying Guarded Definitions with Recursive Schemes , 1994, TYPES.

[120]  Karl Crary,et al.  Understanding and evolving the ml module system , 2005 .

[121]  Peter Hancock,et al.  Programming interfaces and basic topology , 2009, Ann. Pure Appl. Log..

[122]  Robin O. Gandy,et al.  On the axiom of extensionality – Part I , 1956, Journal of Symbolic Logic.

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

[124]  Pierre-Yves Strub,et al.  Coq Modulo Theory , 2010, CSL.

[125]  Thorsten Altenkirch,et al.  Epigram reloaded: a standalone typechecker for ETT , 2005, Trends in Functional Programming.

[126]  Richard Garner On the strength of dependent products in the type theory of Martin-Löf , 2009, Ann. Pure Appl. Log..

[127]  Thierry Coquand,et al.  Verifying a Semantic βη-Conversion Test for Martin-Löf Type Theory , 2008 .

[128]  Peter Dybjer,et al.  Indexed induction-recursion , 2006, J. Log. Algebraic Methods Program..

[129]  Wouter Swierstra,et al.  The power of Pi , 2008, ICFP.

[130]  Edsko de Vries,et al.  Formal polytypic programs and proofs , 2010, Journal of Functional Programming.

[131]  Stephanie Weirich,et al.  Arity-generic datatype-generic programming , 2010, PLPV '10.

[132]  Peter Dybjer,et al.  Representing Inductively Defined Sets by Wellorderings in Martin-Löf's Type Theory , 1997, Theor. Comput. Sci..

[133]  Robin Adams Pure type systems with judgemental equality , 2006, J. Funct. Program..

[134]  Peter Morris,et al.  A Universe of Strictly Positive Families , 2009, Int. J. Found. Comput. Sci..

[135]  Ralf Hinze,et al.  Polytypic values possess polykinded types , 2000, Sci. Comput. Program..

[136]  Thorsten Altenkirch Extensional equality in intensional type theory , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[137]  S. Awodey,et al.  Homotopy theoretic models of identity types , 2007, Mathematical Proceedings of the Cambridge Philosophical Society.

[138]  Peter Dybjer,et al.  Inductive families , 2005, Formal Aspects of Computing.

[139]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[140]  J. Lambek A fixpoint theorem for complete categories , 1968 .

[141]  Peter Dybjer,et al.  Universes for Generic Programs and Proofs in Dependent Type Theory , 2003, Nord. J. Comput..

[142]  Peter W. J. Morris,et al.  Constructing Universes for Generic Programming , 2007 .

[143]  Bart Jacobs,et al.  Structural Induction and Coinduction in a Fibrational Setting , 1998, Inf. Comput..