ABSTRACT
We present a verified compiler to an idealized assembly language from a small, untyped functional language with mutable references and exceptions. The compiler is programmed in the Coq proof assistant and has a proof of total correctness with respect to big-step operational semantics for the source and target languages. Compilation is staged and includes standard phases like translation to continuation-passing style and closure conversion, as well as a common subexpression elimination optimization. In this work, our focus has been on discovering and using techniques that make our proofs easy to engineer and maintain. While most programming language work with proof assistants uses very manual proof styles, all of our proofs are implemented as adaptive programs in Coq's tactic language, making it possible to reuse proofs unchanged as new language features are added.
In this paper, we focus especially on phases of compilation that rearrange the structure of syntax with nested variable binders. That aspect has been a key challenge area in past compiler verification projects, with much more effort expended in the statement and proof of binder-related lemmas than is found in standard pencil-and-paper proofs. We show how to exploit the representation technique of parametric higher-order abstract syntax to avoid the need to prove any of the usual lemmas about binder manipulation, often leading to proofs that are actually shorter than their pencil-and-paper analogues. Our strategy is based on a new approach to encoding operational semantics which delegates all concerns about substitution to the meta language, without using features incompatible with general-purpose type theories like Coq's logic.
- Brian Aydemir, Arthur Charguéraud, Benjamin C. Pierce, Randy Pollack, and Stephanie Weirich. Engineering formal metatheory. In Proc. POPL, pages 3--15, 2008. Google ScholarDigital Library
- Nick Benton and Chung-Kil Hur. Biorthogonality, step-indexing and compiler correctness. In Proc. ICFP, pages 97--108, 2009. Google ScholarDigital Library
- Adam Chlipala. A certified type-preserving compiler from lambda calculus to assembly language. In Proc. PLDI, pages 54--65, 2007. Google ScholarDigital Library
- Adam Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In Proc. ICFP, pages 143--156, 2008. Google ScholarDigital Library
- Olivier Danvy and Andrzej Filinski. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science, 2 (4): 361--391, 1992.Google ScholarCross Ref
- Zaynah Dargaye and Xavier Leroy. Mechanized verification of CPS transformations. In Proc. LPAR, pages 211--225, 2007. Google ScholarDigital Library
- Maulik A. Dave. Compiler verification: a bibliography. SIGSOFT Softw. Eng. Notes, 28 (6): 2--2, 2003. Google ScholarDigital Library
- Nicolas G. de Bruijn. Lambda-calculus notation with nameless dummies: a tool for automatic formal manipulation with application to the Church-Rosser theorem. Indag. Math., 34(5): 381--392, 1972.Google ScholarCross Ref
- David Delahaye. A tactic language for the system Coq. In Proc. LPAR, pages 85--95, 2000. Google ScholarDigital Library
- Arthur D. Flatau. A Verified Implementation of an Applicative Language with Dynamic Storage Allocation. PhD thesis, University of Texas at Austin, November 1992. Google ScholarDigital Library
- Louis-Julien Guillemette and Stefan Monnier. A type-preserving compiler in Haskell. In Proc. ICFP, pages 75--86, 2008. Google ScholarDigital Library
- Robert Harper, Furio Honsell, and Gordon Plotkin. A framework for defining logics. J. of the ACM, 40 (1): 143--184, 1993. Google ScholarDigital Library
- Furio Honsell, Marino Miculan, and Ivan Scagnetto. An axiomatic approach to metareasoning on nominal algebras in HOAS. In Proc. ICALP, pages 963--978, 2001. Google ScholarDigital Library
- Xavier Leroy. Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In Proc. POPL, pages 42--54, 2006. Google ScholarDigital Library
- Xavier Leroy and Hervé Grall. Coinductive big-step operational semantics. Inf. Comput., 207 (2): 284--304, 2009. Google ScholarDigital Library
- Yasuhiko Minamide and Koji Okuma. Verifying CPS transformations in Isabelle/HOL. In Proc. MERLIN, pages 1--8, 2003. Google ScholarDigital Library
- J. Strother Moore. A mechanically verified language implementation. J. Automated Reasoning, 5 (4): 461--492, 1989. Google ScholarDigital Library
- G. Morrisett, M. Felleisen, and R. Harper. Abstract models of memory management. In Proc. FPCA, pages 66--77, 1995. Google ScholarDigital Library
- F. Pfenning and C. Elliot. Higher-order abstract syntax. In Proc. PLDI, pages 199--208, 1988. Google ScholarDigital Library
- Frank Pfenning and Carsten Schürmann. System description: Twelf -- a meta-logical framework for deductive systems. In Proc. CADE, pages 202--206, 1999. Google ScholarDigital Library
- Ye Henry Tian. Mechanically verifying correctness of CPS compilation. In Proc. CATS, pages 41--51, 2006. Google ScholarDigital Library
- C. Urban and C. Tasson. Nominal techniques in Isabelle/HOL. In Proc. CADE, pages 38--53, 2005. Google ScholarDigital Library
- Geoffrey Washburn and Stephanie Weirich. Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. J. Funct. Program., 18 (1): 87--140, 2008. Google ScholarDigital Library
- Markus Wenzel. Isar -- a generic interpretative approach to readable formal proof documents. In Proc. TPHOLs, pages 167--184, 1999. Google ScholarDigital Library
Index Terms
- A verified compiler for an impure functional language
Recommendations
A verified compiler for an impure functional language
POPL '10We present a verified compiler to an idealized assembly language from a small, untyped functional language with mutable references and exceptions. The compiler is programmed in the Coq proof assistant and has a proof of total correctness with respect to ...
A certified type-preserving compiler from lambda calculus to assembly language
PLDI '07: Proceedings of the 28th ACM SIGPLAN Conference on Programming Language Design and ImplementationWe present a certified compiler from the simply-typed lambda calculus to assembly language. The compiler is certified in the sense that it comes with a machine-checked proof of semantics preservation, performed with the Coq proof assistant. The compiler ...
A certified type-preserving compiler from lambda calculus to assembly language
Proceedings of the 2007 PLDI conferenceWe present a certified compiler from the simply-typed lambda calculus to assembly language. The compiler is certified in the sense that it comes with a machine-checked proof of semantics preservation, performed with the Coq proof assistant. The compiler ...
Comments