A verified staged interpreter is a verified compiler

Dependent types and multi-stage programming have both been used, separately, in programming language design and implementation. Each technique has its own advantages --- with dependent types, we can verify aspects of interpreters and compilers such as type safety and stack invariants. Multi-stage programming, on the other hand, can give the implementor access to underlying compiler technology; a staged interpreter is a translator. In this paper, we investigate the combination of these techniques. We implement an interpreter for a simply typed lambda calculus, using dependent types to guarantee correctness properties by construction. We give explicit proofs of these correctness properties, then add staging annotations to generate a translator from the interpreter. In this way, we have constructed a verified compiler from a verified staged interpreter. We illustrate the application of the technique by considering a simple staged interpreter that provides guarantees for some simple resource bound properties, as might be found in a domain specific language for real-time embedded systems.

[1]  Walid Taha,et al.  A Gentle Introduction to Multi-stage Programming , 2003, Domain-Specific Program Generation.

[2]  J. McKinna FUNCTIONAL PEARL A type-correct , stack-safe , provably correct expression compiler in Epigram , 2006 .

[3]  Greg J. Michaelson,et al.  Hume: A Domain-Specific Language for Real-Time Embedded Systems , 2003, GPCE.

[4]  Haskell B. Curry,et al.  Combinatory Logic, Volume I , 1959 .

[5]  Yoshihiko Futamura,et al.  Partial Evaluation of Computation Process--An Approach to a Compiler-Compiler , 1999, High. Order Symb. Comput..

[6]  Edwin Brady,et al.  A Dependently Typed Framework for Static Analysis of Program Execution Costs , 2005, IFL.

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

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

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

[10]  Walid Taha,et al.  Generating Heap-Bounded Programs in a Functional Setting , 2003, EMSOFT.

[11]  Walid Taha,et al.  A methodology for generating verified combinatorial circuits , 2004, EMSOFT '04.

[12]  Emir Pasalic,et al.  The role of type equality in meta-programming , 2004 .

[13]  Walid Taha,et al.  Environment classifiers , 2003, POPL.

[14]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

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

[16]  Walid Taha,et al.  Multi-Stage Programming: Its Theory and Applications , 1999 .

[17]  Walid Taha,et al.  Implicitly Heterogeneous Multi-stage Programming , 2005, GPCE.

[18]  Christine Paulin-Mohring,et al.  The coq proof assistant reference manual , 2000 .

[19]  Conor McBride,et al.  The view from the left , 2004, Journal of Functional Programming.

[20]  Conor McBride,et al.  Dependently typed functional programs and their proofs , 2000 .

[21]  Edwin Brady,et al.  Practical implementation of a dependently typed functional programming language , 2005 .

[22]  Peter Dybjer,et al.  Inductive families , 2005, Formal Aspects of Computing.

[23]  LeroyXavier Formal certification of a compiler back-end or , 2006 .

[24]  William A. Howard,et al.  The formulae-as-types notion of construction , 1969 .

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

[26]  Krzysztof Czarnecki,et al.  DSL Implementation in MetaOCaml, Template Haskell, and C++ , 2003, Domain-Specific Program Generation.

[27]  Robert Harper,et al.  Type Checking with Universes , 1991, Theor. Comput. Sci..

[28]  Ulrich Berger,et al.  An inverse of the evaluation functional for typed lambda -calculus , 1991, [1991] Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science.

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

[30]  Benjamin Grégoire,et al.  A compiled implementation of strong reduction , 2002, ICFP '02.

[31]  Xavier Leroy,et al.  Formal certification of a compiler back - end , 2005 .

[32]  Xavier Leroy,et al.  Formal certification of a compiler back-end or: programming a compiler with a proof assistant , 2006, POPL '06.

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

[34]  Graham Hutton,et al.  Compiling Exceptions Correctly , 2004, MPC.

[35]  Luca Cardelli,et al.  Phase Distinctions in Type Theory , 1988 .