Dependently typed functional programs and their proofs

Research in dependent type theories [M-L71a] has, in the past, concentrated on its use in the presentation of theorems and theorem-proving. This thesis is concerned mainly with the exploitation of the computational aspects of type theory for programming, in a context where the properties of programs may readily be specified and established. In particular, it develops technology for programming with dependent inductive families of datatypes and proving those programs correct. It demonstrates the considerable advantage to be gained by indexing data structures with pertinent characteristic information whose soundness is ensured by typechecking, rather than human effort. Type theory traditionally presents safe and terminating computation on inductive datatypes by means of elimination rules which serve as induction principles and, via their associated reduction behaviour, recursion operators [Dyb91]. In the programming language arena, these appear somewhat cumbersome and give rise to unappealing code, complicated by the inevitable interaction between case analysis on dependent types and equational reasoning on their indices which must appear explicitly in the terms. Thierry Coquand’s proposal [Coq92] to equip type theory directly with the kind of pattern matching notation to which functional programmers have become used over the past three decades [Bur69, McB70] offers a remedy to many of these difficulties. However, the status of pattern matching relative to the traditional elimination rules has until now been in doubt. Pattern matching implies the uniqueness of identity proofs, which Martin Hofmann showed underivable from the conventional definition of equality [Hof95]. This thesis shows that the adoption of this uniqueness as axiomatic is sufficient to make pattern matching admissible. A datatype’s elimination rule allows abstraction only over the whole inductively defined family. In order to support pattern matching, the application of such rules to specific instances of dependent families has been systematised. The underlying analysis extends beyond datatypes to other rules of a similar second order character, suggesting they may have other roles to play in the specification, verification and, perhaps, derivation of programs. The technique developed shifts the specificity from the instantiation of the type’s indices into equational constraints on indices freely chosen, allowing the elimination rule to be applied. Elimination by this means leaves equational hypotheses in the resulting subgoals, which must be solved if further progress is to be made. The first-order unification algorithm for constructor forms in simple types presented in [McB96] has been extended to cover dependent datatypes as well, yielding completely automated solution to a class of problems which can be syntactically defined. The justification and operation of these techniques requires the machine to construct and exploit a standardised collection of auxiliary lemmas for each datatype. This is greatly facilitated by two technical developments of interest in their own right: a more convenient definition of equality, with a relaxed formulation rule allowing elements of different types to be compared, but nonetheless equivalent to the usual equality plus the axiom of uniqueness; a type theory, OLEG, which incorporates incomplete objects, accounting for their ‘holes’ entirely within the typing judgments and, novelly, not requiring any notion of explicit substitution to manage their scopes. A substantial prototype has been implemented, extending the proof assistant LEGO [LP92]. A number of programs are developed by way of example. Chiefly, the increased expressivity of dependent datatypes is shown to capture a standard first-order unification algorithm within the class of structurally recursive programs, removing any need for a termination argument. Furthermore, the use of elimination rules in specifying the components of the program simplifies significantly its correctness proof.

[1]  Philip Wadler,et al.  Views: a way for pattern matching to cohabit with data abstraction , 1987, POPL '87.

[2]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[3]  David J. Pym,et al.  Proofs, search and computation in general logic , 1990 .

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

[5]  Delphine Terrasse,et al.  Encoding Natural Semantics in Coq , 1995, AMAST.

[6]  Lawrence C. Paulson,et al.  Constructing Recursion Operators in Intuitionistic Type Theory , 1986, J. Symb. Comput..

[7]  Martin Strecker,et al.  Interactive and Automated Proof Construction in Type Theory , 1998 .

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

[9]  John McCarthy,et al.  A basis for a mathematical theory of computation, preliminary report , 1899, IRE-AIEE-ACM '61 (Western).

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

[11]  Mathieu Jaume Unification: a Case Study in Transposition of Formal Properties , 1997 .

[12]  Gérard P. Huet,et al.  Constructive category theory , 2000, Proof, Language, and Interaction.

[13]  Zohar Manna,et al.  Deductive Synthesis of the Unification Algorithm , 1981, Sci. Comput. Program..

[14]  D. A. Turner,et al.  Elementary Strong Functional Programming , 1995, FPLE.

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

[16]  Eduardo Giménez,et al.  Structural Recursive Definitions in Type Theory , 1998, ICALP.

[17]  Martin Hofmann,et al.  The groupoid model refutes uniqueness of identity proofs , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[18]  Hugo Herbelin,et al.  The Coq proof assistant : reference manual, version 6.1 , 1997 .

[19]  John McCarthy,et al.  A BASIS FOR A MATHEMATICAL THEORY OF COMPUTATION 1) , 2018 .

[20]  Rod M. Burstall,et al.  Explicit Environments , 1999, Fundam. Informaticae.

[21]  M. Hofmann Extensional concepts in intensional type theory , 1995 .

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

[23]  James Hook,et al.  Substitution: A Formal Methods Case Study Using Monads and Transformations , 1994, Sci. Comput. Program..

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

[25]  David J. Pym,et al.  A Unification Algorithm for the lambda-Pi-Calculus , 1992, Int. J. Found. Comput. Sci..

[26]  Christine Paulin-Mohring,et al.  Inductive Definitions in the system Coq - Rules and Properties , 1993, TLCA.

[27]  John Darlington,et al.  A Transformation System for Developing Recursive Programs , 1977, J. ACM.

[28]  Zhaohui Luo,et al.  Computation and reasoning - a type theory for computer science , 1994, International series of monographs on computer science.

[29]  Masako Takahashi,et al.  Parallel reductions in λ-calculus (revised version) , 1992 .

[30]  G. Gentzen Untersuchungen über das logische Schließen. I , 1935 .

[31]  D. Prawitz Natural Deduction: A Proof-Theoretical Study , 1965 .

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

[33]  Bengt Nordström Terminating general recursion , 1988, BIT Comput. Sci. Sect..

[34]  R. M. BURSTALL Inductively Defined Functions in Functional Programming Languages , 1987, J. Comput. Syst. Sci..

[35]  Konrad Slind,et al.  Function Definition in Higher-Order Logic , 1996, TPHOLs.

[36]  J. Rouyer Développement de l'algorithme d'unification dans le calcul des constructions avec types inductifs , 1992 .

[37]  César A. Muñoz,et al.  Dependent Types with Explicit Substitutiuons: A Meta-theoretical development , 1996, TYPES.

[38]  Martin David Coen,et al.  Interactive program derivation , 1992 .

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

[40]  Thierry Coquand,et al.  Inductively defined types , 1988, Conference on Computer Logic.

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

[42]  Lawrence C. Paulson,et al.  Logic and computation - interactive proof with Cambridge LCF , 1987, Cambridge tracts in theoretical computer science.

[43]  Lennart Augustsson,et al.  Compiling Pattern Matching , 1985, FPCA.

[44]  Gérard P. Huet,et al.  A Unification Algorithm for Typed lambda-Calculus , 1975, Theor. Comput. Sci..

[45]  Lena Magnusson,et al.  The implementation of ALF : a proof editor based on Martin-Löf's monomorphic type theory with explicit substitution , 1994 .

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

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

[48]  John C. Shepherdson,et al.  Unfold/fold transformations of logic programs , 1992, Mathematical Structures in Computer Science.

[49]  Frederick Valentine McBride Computer aided manipulation of symbols , 1970 .

[50]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[51]  Dale Miller,et al.  A Logic Programming Language with Lambda-Abstraction, Function Variables, and Simple Unification , 1991, J. Log. Comput..

[52]  Marianne Simonot,et al.  Automatizing Termination Proofs of Recursively Defined Functions , 1994, Theor. Comput. Sci..

[53]  Erik Poll,et al.  Pure Type Systems with Definitions , 1994, LFCS.

[54]  Conor McBride,et al.  Inverting Inductively Defined Relations in LEGO , 1996, TYPES.

[55]  Robert Harper,et al.  Type Checking, Universe Polymorphism, and Typical Ambiguity in the Calculus of Constructions (Draft) , 1989, TAPSOFT, Vol.2.

[56]  Cristina Cornes,et al.  Conception d'un langage de haut niveau de representation de preuves : recurrence par filtrage de motifs unification en presence de types inductifs primitifs synthese de lemmes d'inversion , 1997 .

[57]  J. A. Robinson,et al.  A Machine-Oriented Logic Based on the Resolution Principle , 1965, JACM.

[58]  Keith L. Clark,et al.  Negation as Failure , 1987, Logic and Data Bases.

[59]  E Erik Poll A programming logic based on type theory , 1994 .

[60]  P. Martin-Löf Hauptsatz for the Intuitionistic Theory of Iterated Inductive Definitions , 1971 .

[61]  John McCarthy,et al.  Correctness of a compiler for arithmetic expressions , 1966 .

[62]  Donald Sannella,et al.  The definition of Extended ML , 1994 .

[63]  Rod M. Burstall,et al.  HOPE: An experimental applicative language , 1980, LISP Conference.

[64]  E. Manes Algebraic Theories in a Category , 1976 .

[65]  Randy B. Pollack,et al.  Incremental Changes in LEGO , 1994 .

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

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

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

[69]  Rod M. Burstall,et al.  Proving Properties of Programs by Structural Induction , 1969, Comput. J..

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