skip to main content
10.1145/1706299.1706312acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

A verified compiler for an impure functional language

Published:17 January 2010Publication History

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.

References

  1. Brian Aydemir, Arthur Charguéraud, Benjamin C. Pierce, Randy Pollack, and Stephanie Weirich. Engineering formal metatheory. In Proc. POPL, pages 3--15, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Nick Benton and Chung-Kil Hur. Biorthogonality, step-indexing and compiler correctness. In Proc. ICFP, pages 97--108, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Adam Chlipala. A certified type-preserving compiler from lambda calculus to assembly language. In Proc. PLDI, pages 54--65, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Adam Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In Proc. ICFP, pages 143--156, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Olivier Danvy and Andrzej Filinski. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science, 2 (4): 361--391, 1992.Google ScholarGoogle ScholarCross RefCross Ref
  6. Zaynah Dargaye and Xavier Leroy. Mechanized verification of CPS transformations. In Proc. LPAR, pages 211--225, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Maulik A. Dave. Compiler verification: a bibliography. SIGSOFT Softw. Eng. Notes, 28 (6): 2--2, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarCross RefCross Ref
  9. David Delahaye. A tactic language for the system Coq. In Proc. LPAR, pages 85--95, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Arthur D. Flatau. A Verified Implementation of an Applicative Language with Dynamic Storage Allocation. PhD thesis, University of Texas at Austin, November 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Louis-Julien Guillemette and Stefan Monnier. A type-preserving compiler in Haskell. In Proc. ICFP, pages 75--86, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Robert Harper, Furio Honsell, and Gordon Plotkin. A framework for defining logics. J. of the ACM, 40 (1): 143--184, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. Xavier Leroy and Hervé Grall. Coinductive big-step operational semantics. Inf. Comput., 207 (2): 284--304, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Yasuhiko Minamide and Koji Okuma. Verifying CPS transformations in Isabelle/HOL. In Proc. MERLIN, pages 1--8, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Strother Moore. A mechanically verified language implementation. J. Automated Reasoning, 5 (4): 461--492, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. G. Morrisett, M. Felleisen, and R. Harper. Abstract models of memory management. In Proc. FPCA, pages 66--77, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. F. Pfenning and C. Elliot. Higher-order abstract syntax. In Proc. PLDI, pages 199--208, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Frank Pfenning and Carsten Schürmann. System description: Twelf -- a meta-logical framework for deductive systems. In Proc. CADE, pages 202--206, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Ye Henry Tian. Mechanically verifying correctness of CPS compilation. In Proc. CATS, pages 41--51, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. C. Urban and C. Tasson. Nominal techniques in Isabelle/HOL. In Proc. CADE, pages 38--53, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. Markus Wenzel. Isar -- a generic interpretative approach to readable formal proof documents. In Proc. TPHOLs, pages 167--184, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A verified compiler for an impure functional language

              Recommendations

              Comments

              Login options

              Check if you have access through your login credentials or your institution to get full access on this article.

              Sign in
              • Published in

                cover image ACM Conferences
                POPL '10: Proceedings of the 37th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
                January 2010
                520 pages
                ISBN:9781605584799
                DOI:10.1145/1706299
                • cover image ACM SIGPLAN Notices
                  ACM SIGPLAN Notices  Volume 45, Issue 1
                  POPL '10
                  January 2010
                  500 pages
                  ISSN:0362-1340
                  EISSN:1558-1160
                  DOI:10.1145/1707801
                  Issue’s Table of Contents

                Copyright © 2010 ACM

                Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 17 January 2010

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • research-article

                Acceptance Rates

                Overall Acceptance Rate824of4,130submissions,20%

                Upcoming Conference

                POPL '25

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader