Bertus: Implementing Observational Equality

The marriage between programming and logic has been a fertile one. In particular, since the definition of the simply typed λ-calculus, a number of type systems have been devised with increasing expressive power. Among this systems, Intuitionistic Type Theory (ITT) has been a popular framework for theorem provers and programming languages. However, reasoning about equality has always been a tricky business in ITT and related theories. In this thesis we shall explain why this is the case, and present Observational Type Theory (OTT), a solution to some of the problems with equality. To bring OTT closer to the current practice of interactive theorem provers, we describe Bertus, a system featuring OTT in a setting more close to the one found in widely used provers such as Agda and Coq. Most notably, we feature user defined inductive and record types and a cumulative, implicit type hierarchy. Having implemented part of Bertus as a Haskell program, we describe some of the implementation issues faced. Acknowledgements I would like to thank Steffen van Bakel, my supervisor, who was brave enough to believe in my project and who provided support and invaluable advice. I would also like to thank the Haskell and Agda community on IRC, which guided me through the strange world of types; and in particular Andrea Vezzosi and James Deikun, with whom I entertained countless insightful discussions over the past year. Andrea suggested Observational Type Theory as a topic of study: this thesis would not exist without him. Before them, Tony Field introduced me to Haskell, unknowingly filling most of my free time from that time on. Finally, most of the work stems from the research of Conor McBride, who answered many of my doubts through these months. I also owe him the colours.

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

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

[3]  Dale Miller,et al.  Unification Under a Mixed Prefix , 1992, J. Symb. Comput..

[4]  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 .

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

[6]  P. Dybjer Inductive sets and families in Martin-Lo¨f's type theory and their set-theoretic semantics , 1991 .

[7]  Peter Dybjer,et al.  A general formulation of simultaneous inductive-recursive definitions in type theory , 2000, Journal of Symbolic Logic.

[8]  GERARD P. HUET,et al.  The Undecidability of Unification in Third Order Logic , 1973, Inf. Control..

[9]  Simon L. Peyton Jones,et al.  System F with type equality coercions , 2007, TLDI '07.

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

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

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

[13]  Richard S. Bird,et al.  de Bruijn notation as a nested datatype , 1999, Journal of Functional Programming.

[14]  Lawrence C. Paulson,et al.  Isabelle: The Next 700 Theorem Provers , 2000, ArXiv.

[15]  Fritz Henglein,et al.  Type inference with polymorphic recursion , 1993, TOPL.

[16]  Conor McBride,et al.  A tutorial implementation of dynamic pattern unification A dependently typed programming language implementation pearl , 2012 .

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

[18]  Miran Lipovača,et al.  Learn You a Haskell for Great Good! , 2009 .

[19]  Graham Hutton,et al.  Programming in Haskell , 2007 .

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

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

[22]  Christian Queinnec Lisp in small pieces , 1994 .

[23]  Stephanie Weirich,et al.  Binders unbound , 2011, ICFP.

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

[25]  Venanzio Capretta,et al.  General recursion via coinductive types , 2005, Log. Methods Comput. Sci..

[26]  Conor McBride,et al.  Dependently typed functional programs and their proofs , 2000 .

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

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

[29]  Thierry Coquand,et al.  Normalization by Evaluation for Martin-Lof Type Theory with Typed Equality Judgements , 2007, 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007).

[30]  Thierry Coquand,et al.  The Calculus of Constructions , 1988, Inf. Comput..

[31]  Hendrik Pieter Barendregt,et al.  Introduction to generalized type systems , 1991, Journal of Functional Programming.

[32]  J. C. Reynolds An Introduction to the Polymorphic Lambda Calculus , 1994 .

[33]  Conor McBride,et al.  Epigram: Practical Programming with Dependent Types , 2004, Advanced Functional Programming.

[34]  Conor McBride,et al.  A Tutorial Implementation of a Dependently Typed Lambda Calculus , 2010, Fundam. Informaticae.

[35]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[36]  A. Church An Unsolvable Problem of Elementary Number Theory , 1936 .

[37]  Eduardo Giménez,et al.  Un calcul de constructions infinies et son application a la verification de systemes communicants , 1996 .

[38]  John Launchbury,et al.  Structuring depth-first search algorithms in Haskell , 1995, POPL '95.

[39]  Nils Anders Danielsson Operational semantics using the partiality monad , 2012, ICFP '12.

[40]  Simon L. Peyton Jones,et al.  Associated types with class , 2005, POPL '05.

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

[42]  Simon Marlow,et al.  Haskell 2010 Language Report , 2010 .

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

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

[45]  Antonius J. C. Hurkens A Simplification of Girard's Paradox , 1995, TLCA.

[46]  Christine Paulin-Mohring,et al.  The Coq Proof Assistant A Tutorial , 2005 .

[47]  de Ng Dick Bruijn Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem , 1972 .

[48]  H B Curry,et al.  Functionality in Combinatory Logic. , 1934, Proceedings of the National Academy of Sciences of the United States of America.

[49]  de Ng Dick Bruijn,et al.  Telescopic Mappings in Typed Lambda Calculus , 1991, Inf. Comput..

[50]  Simon Thompson,et al.  Type theory and functional programming , 1991, International computer science series.

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