Extensional equivalence and singleton types

We study the &lamda;<sup>ΠΣ<i>S</i></sup><sub>≤</sub> calculus, which contains singleton types <i>S</i>(<i>M</i>) classifying terms of base type provably equivalent to the term <i>M</i>. The system includes dependent types for pairs and functions (Σ and Π) and a subtyping relation induced by regarding singletons as subtypes of the base type. The decidability of type checking for this language is non-obvious, since to type check we must be able to determine equivalence of well-formed terms. But in the presence of singleton types, the provability of an equivalence judgment Γ ⊢ <i>M</i><sub>1</sub> &eqiv;<i>M</i><sub>2</sub> : <i>A</i> can depend both on the typing context Γ and on the particular type <i>A</i> at which <i>M</i><sub>1</sub> and <i>M</i><sub>2</sub> are compared.We show how to prove decidability of term equivalence, hence of type checking, in &lamda;<sup>ΠΣ<i>S</i></sup><sub>≤</sub> by exhibiting a type-directed algorithm for directly computing normal forms. The correctness of normalization is shown using an unusual variant of Kripke logical relations organized around sets; rather than defining a logical equivalence relation, we work directly with (subsets of) the corresponding equivalence classes.We then provide a more efficient algorithm for checking type equivalence without constructing normal forms. We also show that type checking, subtyping, and all other judgments of the system are decidable.The &lamda;<sup>ΠΣ<i>S</i></sup><sub>≤</sub> calculus models type constructors and kinds in the intermediate language used by the TILT compiler for Standard ML to implement the SML module system. The decidability of &lamda;<sup>ΠΣ<i>S</i></sup><sub>≤</sub> term equivalence allows us to show decidability of type checking for TILT's intermediate language. We also obtain a consistency result that allows us to prove type safety for the intermediate language. The algorithms derived here form the core of the type checker used for internal type checking in TILT.

[1]  Zhong Shao Typed cross-module compilation , 1998, ICFP '98.

[2]  Karl Crary A simple proof technique for certain parametricity results , 1999, ICFP '99.

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

[4]  Xavier Leroy,et al.  Applicative functors and fully transparent higher-order modules , 1995, POPL '95.

[5]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[6]  Mark Lillibridge,et al.  A type-theoretic approach to higher-order modules with sharing , 1994, POPL '94.

[7]  Peter Lee,et al.  TIL: a type-directed, optimizing compiler for ML , 2004, SIGP.

[8]  HarperRobert,et al.  Extensional equivalence and singleton types , 2006 .

[9]  Thierry Coquand,et al.  A Logical Framework with Dependently Typed Records , 2003, Fundam. Informaticae.

[10]  Adriana B. Compagnoni,et al.  Typed operational semantics for higher-order subtyping , 2003, Inf. Comput..

[11]  Robert Harper,et al.  Typed closure conversion , 1996, POPL '96.

[12]  R. Harper,et al.  Singleton kinds and singleton types , 2000 .

[13]  Robert Harper,et al.  Abstract 1 Introduction , 2022 .

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

[15]  Frank Pfenning,et al.  On equivalence and canonical forms in the LF type theory , 2001, TOCL.

[16]  Andrew W. Appel,et al.  Lambda-splitting: a higher-order approach to cross-module optimizations , 1997, ICFP '97.

[17]  Andrew Shalit,et al.  The Dylan Reference Manual: The Definitive Guide to the New Object-Oriented Dynamic Language , 1996 .

[18]  P. Cheng,et al.  Implementing the TILT Internal Language , 2000 .

[19]  Karl Crary Sound and complete elimination of singleton kinds , 2007, TOCL.

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

[21]  David Aspinall,et al.  Subtyping with Singleton Types , 1994, CSL.

[22]  David Walker,et al.  From System F to Typed Assembly Language (Extended Version) , 1997 .

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

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

[25]  Healfdene Goguen A syntactic approach to eta equality in type theory , 2005, POPL '05.

[26]  Xavier Leroy,et al.  Manifest types, modules, and separate compilation , 1994, POPL '94.

[27]  Matthias Blume,et al.  Hierarchical modulatory and intermodule optimization , 1998 .

[28]  David Aspinall Subtyping with Power Types , 2000, CSL.

[29]  David Aspinall,et al.  Type systems for modular programs and specifications , 1997 .

[30]  M. Lillibridge Translucent Sums: A Foundation for Higher-Order Module Systems , 1997 .

[31]  Karl Crary Type-Theoretic Methodology for Practical Programming Languages , 1998 .

[32]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[33]  J. Y. Girard,et al.  Interpretation fonctionelle et elimination des coupures dans l'aritmetique d'ordre superieur , 1972 .

[34]  Judicaël Courant Strong Normalization with Singleton Types , 2002, Electron. Notes Theor. Comput. Sci..