Abstract 1 Introduction

Work on the TILT compiler for Standard ML led us to study a language with singleton kinds: S(A) is the kind of all types provably equivalent to the type A. Singletons are interesting because they provide a very general form of definitions for type variables, allow fine-grained control of type computations, and allow many equational constraints to be expressed within the type system. Internally, TILT represents programs using a predicative variant of Girard's Fω enriched with singleton kinds, dependent product and function kinds (&Sgr; and &Pgr;), and a sub-kinding relation. An important benefit of using a typed language as the representation of programs is that typechecking can detect many common compiler implementation errors. However, the decidability of typechecking for our particular representation is not obvious. In order to typecheck a term, we must be able to determine whether two type constructors are provably equivalent. But in the presence of singleton kinds, the equivalence of type constructors depends both on the typing context in which they are compared and on the kind at which they are compared. In this paper we concentrate on the key issue for decidability of typechecking: determining the equivalence of well-formed type constructors. We define the λ&Pgr;&Sgr;S< calculus, a model of the constructors and kinds of TILT's intermediate language. Inspired by Coquand's result for type theory, we prove decidability of constructor equivalence for λ&Pgr;&Sgr;S≤ by exhibiting a novel — though slightly inefficient — type-directed comparison algorithm. The correctness of this algorithm is proved using an interesting variant of Kripke-style logical relations: unary relations are indexed by a single possible world (in our case, a typing context), but binary relations are indexed by two worlds. Using this result we can then show the correctness of a natural, practical algorithm used by the TILT compiler.

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

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

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

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

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

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

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

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

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

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

[11]  George C. Necula,et al.  Proof-carrying code , 1997, POPL '97.

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

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

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

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

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

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