Dependent types in practical programming

We present an approach to enriching the type system of ML with a restricted form of dependent types, where type index objects are drawn from a constraint domain C, leading to the DML(C) language schema. This allows specification and inference of significantly more precise type information, facilitating program error detection and compiler optimization. A major complication resulting from introducing dependent types is that pure type inference for the enriched system is no longer possible, but we show that type-checking a sufficiently annotated program in DML(C) can be reduced to constraint satisfaction in the constraint domain C. We exhibit the unobtrusiveness of our approach through practical examples and prove that DML(C) is conservative over ML. The main contribution of the paper lies in our language design, including the formulation of type-checking rules which makes the approach practical. To our knowledge, no previous type system for a general purpose programming language such as ML has combined dependent types with features including datatype declarations, higher-order functions, general recursions, let-polymorphism, mutable references, and exceptions. In addition, we have finished a prototype implementation of DML(C) for an integer constraint domain C, where constraints are linear inequalities (Xi and Pfenning 1998).

[1]  A. Church,et al.  Some properties of conversion , 1936 .

[2]  Peter Naur Proof of Algorithms by General Snapshots , 1966 .

[3]  George B. Dantzig,et al.  Fourier-Motzkin Elimination and Its Dual , 1973, J. Comb. Theory, Ser. A.

[4]  Karl N. Levitt,et al.  Reasoning about programs , 1973, Artif. Intell..

[5]  Edsger W. Dijkstra,et al.  Guarded commands, nondeterminacy and formal derivation of programs , 1975, Commun. ACM.

[6]  Edsger W. Dijkstra,et al.  A Discipline of Programming , 1976 .

[7]  Norihisa Suzuki,et al.  Implementation of an array bound checker , 1977, POPL.

[8]  Robert E. Shostak,et al.  On the SUP-INF Method for Proving Presburger Formulas , 1977, JACM.

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

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

[11]  S. Feferman Constructive Theories of Functions and Classes , 1979 .

[12]  F. Dick A survey of the project Automath , 1980 .

[13]  de Ng Dick Bruijn,et al.  A survey of the project Automath , 1980 .

[14]  C. A. R. Hoare,et al.  An axiomatic basis for computer programming , 1969, CACM.

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

[16]  J. C. Shepherdson,et al.  Mathematical Logic and Programming Languages , 1985 .

[17]  Thierry Coquand,et al.  Constructions: A Higher Order Proof System for Mechanizing Mathematics , 1985, European Conference on Computer Algebra.

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

[19]  M. F.,et al.  Bibliography , 1985, Experimental Gerontology.

[20]  Dominique Clément,et al.  A simple applicative language: mini-ML , 1986, LFP '86.

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

[22]  Robert L. Constable,et al.  Partial Objects In Constructive Type Theory , 1987, Logic in Computer Science.

[23]  Gilles Kahn,et al.  Natural Semantics , 1987, STACS.

[24]  N. P. Mendler,et al.  Recursive Types and Type Constraints in Second-Order Lambda Calculus , 1987, LICS.

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

[26]  中野 裕,et al.  PX, a computational logic , 1988 .

[27]  Frank Pfenning,et al.  Elf: a language for logic definition and verified metaprogramming , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[28]  Donald Sannella,et al.  Toward Formal Development of ML Programs: Foundations and Methodology (Extended Abstract) , 1989, TAPSOFT, Vol.2.

[29]  John C. Mitchell,et al.  Higher-order modules and the phase distinction , 1989, POPL '90.

[30]  Zhaohui Luo,et al.  ECC, an extended calculus of constructions , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[31]  Frank Pfenning,et al.  Inductively Defined Types in the Calculus of Constructions , 1989, Mathematical Foundations of Programming Semantics.

[32]  Eugenio Moggi,et al.  Computational lambda-calculus and monads , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

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

[34]  Robin Milner,et al.  Commentary on standard ML , 1990 .

[35]  Susumu Hayashi,et al.  An introduction to PX , 1990 .

[36]  Amy P. Felty,et al.  The Coq proof assistant user's guide : version 5.6 , 1990 .

[37]  Richard S. Bird,et al.  A calculus of functions for program derivation , 1990 .

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

[39]  T. Coquand An algorithm for testing conversion in type theory , 1991 .

[40]  M PaulHudakEt,et al.  Report on the programming language haskell: a non-strict , 1992 .

[41]  William Pugh,et al.  Eliminating false data dependences using the Omega test , 1992, PLDI '92.

[42]  Spiro Michaylov,et al.  Design and implementation of practical constraint logic programming systems , 1992 .

[43]  Zhaohui Luo,et al.  A Unifying Theory of Dependent Types: The Schematic Approach , 1992, LFCS.

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

[45]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[46]  Amr Sabry,et al.  Reasoning about programs in continuation-passing style , 1992, LFP '92.

[47]  Furio Honsell,et al.  A framework for defining logics , 1993, JACM.

[48]  Xavier Leroy,et al.  Le langage Caml , 1993 .

[49]  Rajiv Gupta,et al.  Optimizing array bound checks using flow analysis , 1993, LOPL.

[50]  Bengt Nordström The alf proof editor , 1993 .

[51]  Peter Lee,et al.  Deferred Compilation: The Automation of Run-Time Code Generation , 1993 .

[52]  Ian A. Mason,et al.  A Variable Typed Logic of E ects , 1993 .

[53]  Frank Pfenning,et al.  On the Undecidability of Partial Polymorphic Type Reconstruction , 1993, Fundam. Informaticae.

[54]  Robert W. Floyd,et al.  Assigning Meanings to Programs , 1993 .

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

[56]  William Pugh,et al.  Experiences with Constraint-based Array Dependence Analysis , 1994, PPCP.

[57]  R. Pollack The Theory of LEGO A Proof Checker for the Extended Calculus of Constructions , 1994 .

[58]  Hiroshi Nakano A Constructive Logic Behind the Catch and Throw Mechanism , 1994, Ann. Pure Appl. Log..

[59]  Michael J. Maher,et al.  Constraint Logic Programming: A Survey , 1994, J. Log. Program..

[60]  Susumu Hayashi Singleton, Union and Intersection Types for Program Extraction , 1994, Inf. Comput..

[61]  Brian N. Bershad,et al.  Extensibility safety and performance in the SPIN operating system , 1995, SOSP.

[62]  Jeremy Buhler The Fox Project: a language-structured approach to networking software , 1995, CROS.

[63]  Greg Morrisett,et al.  Compiling with Types , 1995 .

[64]  Catherine Parent,et al.  Synthesizing Proofs from Programs in the Calculus of Inductive Constructions , 1995, MPC.

[65]  Andrew K. Wright Simple imperative polymorphism , 1995, LISP Symb. Comput..

[66]  Amr Sabry,et al.  Proving the correctness of reactive systems using sized types , 1996, POPL '96.

[67]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[68]  N. Shankar,et al.  Pvs: Combining Speciication, Proof Checking, and Model Checking ? 1 Combining Theorem Proving and Typechecking , 1996 .

[69]  Natarajan Shankar Steps Toward Mechanizing Program Transformations Using PVS , 1996, Sci. Comput. Program..

[70]  Natarajan Shankar,et al.  PVS: Combining Specification, Proof Checking, and Model Checking , 1996, FMCAD.

[71]  C. Barry Jay,et al.  Shape Checking of Array Programs , 1996 .

[72]  Robert Harper,et al.  TIL: a type-directed optimizing compiler for ML , 1996, PLDI '96.

[73]  Peter Lee,et al.  Automatic program specialization for interactive media , 1997 .

[74]  Christoph Zenger,et al.  Indexed Types , 1997, Theoretical Computer Science.

[75]  Frank Pfenning,et al.  Eliminating array bound checking through dependent types , 1998, PLDI.

[76]  George C. Necula,et al.  The design and implementation of a certifying compiler , 1998, PLDI.

[77]  Frank Pfenning,et al.  The Fox Project: Advanced Language Technology for Extensible Systems , 1998 .

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

[79]  Christoph Zenger,et al.  Indizierte Typen , 1998 .

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

[81]  Olivier Danvy Functional Unparsing , 1998, J. Funct. Program..

[82]  Karl Crary,et al.  From system F to typed assembly language , 1999, TOPL.

[83]  Andrew P. Tolmach,et al.  From ML to Ada: Strongly-typed language interoperability via source translation , 1998, Journal of Functional Programming.

[84]  Frank Pfenning,et al.  Automated Theorem Proving in a Simple Meta-Logic for LF , 1998, CADE.

[85]  Christoph Kreitz,et al.  A Proof Environment for the Development of Group Communication Systems , 1998, CADE.

[86]  Hongwei Xi,et al.  Dead Code Elimination through Dependent Types , 1999, PADL.

[87]  Ralf Hinze,et al.  Haskell 98 — A Non−strict‚ Purely Functional Language , 1999 .

[88]  Martin Odersky,et al.  Type Inference with Constrained Types , 1999, Theory Pract. Object Syst..

[89]  Evaluation Contexts , .