Concoqtion: Mixing Indexed Types and Hindley-Milner Type Inference

This paper addresses the question of how to extend OCaml’s Hindley-Milner type system with types indexed by logical propositions and proofs of the Coq theorem prover, thereby providing an expressive and extensible mechanism for ensuringfine-grained program invariants. We propose adopting the approached used by Shao et al. for certified binaries. This approach maintains a phase distinction between the computational and logical languages, thereby limiting effects and non-termination to the computational language, and maintaining the decidability of the type system. The extension subsumes language features such as impredicative first-class (higher-rank) polymorphism and type operators, that are notoriously difficult to integrate with the Hindley-Milner style of type inference that is used in OCaml. We make the observation that these features can be more easily integrated with type inference if the inference algorithm is free to adapt the order in which it solves typing constraints to each program. To this end we define a novel “order-free” type inference algorithm. The key enabling technology is a graph representation of constraints and a constraint solver that performs Hindley-Milner inference with just three graph rewrite rules.

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

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

[3]  Daniel R. Licata,et al.  A Formulation of Dependent ML with Explicit Equality Proofs , 2005 .

[4]  Didier Rémy Simple, partial type-inference for System F based on type-containment , 2005, ICFP '05.

[5]  Luca Cardelli,et al.  The Quest Language and System , 1994 .

[6]  Walid Taha,et al.  Tagless staged interpreters for typed languages , 2002, ICFP '02.

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

[8]  Didier Rémy,et al.  MLF: raising ML to the power of system F , 2003, ACM SIGPLAN Notices.

[9]  Martin Odersky,et al.  Colored local type inference , 2001, POPL '01.

[10]  Thierry Coquand,et al.  Concepts mathématiques et informatiques formalisés dans le calcul des constructions , 1985, Logic Colloquium.

[11]  A. Föhrenbach,et al.  SIMPLE++ , 2000, OR Spectr..

[12]  Cormac Flanagan,et al.  Hybrid type checking , 2006, POPL '06.

[13]  Zhong Shao,et al.  A type system for certi .ed binaries , 2002, Foundations of Intrusion Tolerant Systems, 2003 [Organically Assured and Survivable Information Systems].

[14]  Didier Rémy,et al.  Semi-Explicit First-Class Polymorphism for ML , 1999, Inf. Comput..

[15]  Yann Régis-Gianas,et al.  Stratified type inference for generalized algebraic data types , 2006, POPL '06.

[16]  Martin Odersky,et al.  Putting type annotations to work , 1996, POPL '96.

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

[18]  Tim Sheard,et al.  WHAT IS A PROOF , 2005 .

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

[20]  Pawel Urzyczyn,et al.  Type reconstruction in Fω , 1997, Mathematical Structures in Computer Science.

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

[22]  Gang Chen,et al.  Guarded recursive datatype constructors , 2003, POPL '03.

[23]  VytiniotisDimitrios,et al.  Simple unification-based type inference for GADTs , 2006 .

[24]  Chiyan Chen,et al.  Implementing typeful program transformations , 2003, PEPM '03.

[25]  Simon L. Peyton Jones,et al.  Boxy types: inference for higher-rank types and impredicativity , 2006, ICFP '06.

[26]  Peter J. Stuckey,et al.  Type Inference for Guarded Recursive Data Types , 2005, ArXiv.

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

[28]  James McKinna,et al.  Why dependent types matter , 2006, POPL '06.

[29]  Simon L. Peyton Jones,et al.  Practical type inference for arbitrary-rank types , 2007, Journal of Functional Programming.

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

[31]  Simon L. Peyton Jones,et al.  Simple unification-based type inference for GADTs , 2006, ICFP '06.

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

[33]  Alberto Martelli,et al.  An Efficient Unification Algorithm , 1982, TOPL.

[34]  Frank Pfenning,et al.  Partial polymorphic type inference and higher-order unification , 1988, LISP and Functional Programming.

[35]  Robert E. Tarjan,et al.  Efficiency of a Good But Not Linear Set Union Algorithm , 1972, JACM.

[36]  Chiyan Chen,et al.  Combining programming with theorem proving , 2005, ICFP '05.

[37]  Frank Pfenning,et al.  Dependent types in practical programming , 1999, POPL '99.

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