The MetaCoq Project

The MetaCoq project aims to provide a certified meta-programming environment in Coq. It builds on Template-Coq, a plugin for Coq originally implemented by Malecha (Extensible proof engineering in intensional type theory, Harvard University, http://gmalecha.github.io/publication/2015/02/01/extensible-proof-engineering-in-intensional-type-theory.html, 2014), which provided a reifier for Coq terms and global declarations, as represented in the Coq kernel, as well as a denotation command. Recently, it was used in the CertiCoq certified compiler project (Anand et al., in: CoqPL, Paris, France, http://conf.researchr.org/event/CoqPL-2017/main-certicoq-a-verified-compiler-for-coq, 2017), as its front-end language, to derive parametricity properties (Anand and Morrisett, in: CoqPL’18, Los Angeles, CA, USA, 2018). However, the syntax lacked semantics, be it typing semantics or operational semantics, which should reflect, as formal specifications in Coq, the semantics of Coq ’s type theory itself. The tool was also rather bare bones, providing only rudimentary quoting and unquoting commands. We generalize it to handle the entire polymorphic calculus of cumulative inductive constructions, as implemented by Coq, including the kernel’s declaration structures for definitions and inductives, and implement a monad for general manipulation of Coq ’s logical environment. We demonstrate how this setup allows Coq users to define many kinds of general purpose plugins, whose correctness can be readily proved in the system itself, and that can be run efficiently after extraction. We give a few examples of implemented plugins, including a parametricity translation and a certified extraction to call-by-value λ\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\lambda $$\end{document}-calculus. We also advocate the use of MetaCoq as a foundation for higher-level tools.

[1]  B. Russell Mathematical Logic as Based on the Theory of Types , 1908 .

[2]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[3]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[4]  Ronald L. Rivest,et al.  Introduction to Algorithms , 1990 .

[5]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[6]  Torben Æ. Mogensen Efficient self-interpretation in lambda calculus , 1992, Journal of Functional Programming.

[7]  Walid Taha,et al.  Multi-stage programming with explicit annotations , 1997, PEPM.

[8]  Simon Peyton Jones,et al.  Template meta-programming for Haskell , 2002, ACM SIGPLAN Notices.

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

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

[11]  S. Feferman,et al.  Typical Ambiguity: Trying to Have Your Cake and Eat it too , 2003 .

[12]  Godehard Link Typical Ambiguity: Trying to Have Your Cake and Eat It Too , 2004 .

[13]  Pierre Letouzey,et al.  Programmation fonctionnelle certifiée : L'extraction de programmes dans l'assistant Coq. (Certified functional programming : Program extraction within Coq proof assistant) , 2004 .

[14]  Hugo Herbelin Type inference with algebraic universes in the Calculus of Inductive Constructions , 2005 .

[15]  Matthieu Sozeau Program-ing finger trees in Coq , 2007, ICFP '07.

[16]  Sven-Bodo Scholz,et al.  Implementation and Application of Functional Languages , 2009, Lecture Notes in Computer Science.

[17]  James Chapman,et al.  Type Theory Should Eat Itself , 2008, LFMTP@LICS.

[18]  Benjamin Grégoire,et al.  Extending Coq with Imperative Features and Its Application to SAT Verification , 2010, ITP.

[19]  Benjamin Grégoire,et al.  Full Reduction at Full Throttle , 2011, CPP.

[20]  Patrik Jansson,et al.  Proofs for free - Parametricity for dependent types , 2012, J. Funct. Program..

[21]  Chantal Keller,et al.  Parametricity in an Impredicative Sort , 2012, ArXiv.

[22]  Ross P Aterson Proofs for free Parametricity for dependent types JEAN -P HILIPPE B ERNARDY and P ATRIK J ANSSON , 2012 .

[23]  Wouter Swierstra,et al.  Engineering Proof by Reflection in Agda , 2012, IFL.

[24]  Hugo Herbelin,et al.  The Rooster and the Syntactic Bracket , 2013, TYPES.

[25]  Dominique Devriese,et al.  Typed syntactic meta-programming , 2013, ICFP.

[26]  Jan Martin Jansen Programming in the λ-Calculus: From Church to Scott and Back , 2013, The Beauty of Functional Code.

[27]  Marc Lasson Canonicity of Weak ω-groupoid Laws Using Parametricity Theory , 2014, MFPS.

[28]  T. Sheard Template Metaprogramming for Haskell , 2014 .

[29]  Viktor Vafeiadis,et al.  Mtac: A monad for typed tactic programming in Coq , 2015, J. Funct. Program..

[30]  Gregory Malecha,et al.  Extensible proof engineering in intensional type theory , 2015 .

[31]  Thorsten Altenkirch,et al.  Type theory in type theory using quotient inductive types , 2016, POPL.

[32]  Stephan Merz,et al.  Interactive Theorem Proving , 2016, Lecture Notes in Computer Science.

[33]  Gregory Malecha,et al.  Extensible and Efficient Automation Through Reflective Tactics , 2016, ESOP.

[34]  Y. Forster,et al.  Verified Extraction from Coq to a Lambda-Calculus , 2016 .

[35]  Matthew Z. Weaver,et al.  CertiCoq : A verified compiler for Coq , 2016 .

[36]  Nicolas Tabareau,et al.  The Definitional Side of the Forcing , 2016, 2016 31st Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[37]  Elaborator reflection: extending Idris in Idris , 2016, ICFP.

[38]  Nicolas Tabareau,et al.  An effectful way to eliminate addiction to dependence , 2017, 2017 32nd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[39]  J. Gregory Morrisett,et al.  Revisiting Parametricity: Inductives and Uniformity of Propositions , 2017, ArXiv.

[40]  Matthieu Sozeau,et al.  A comprehensible guide to a new unifier for CIC including universe polymorphism and overloading* , 2017, Journal of Functional Programming.

[41]  Simon Boulier,et al.  The next 700 syntactical models of type theory , 2017, CPP.

[42]  Jeremy Avigad,et al.  A metaprogramming framework for formal verification , 2017, Proc. ACM Program. Lang..

[43]  Gert Smolka,et al.  Weak Call-by-Value Lambda Calculus as a Model of Computation in Coq , 2017, ITP.

[44]  Matthieu Sozeau,et al.  Reification of shallow-embedded DSLs in Coq with automated verification , 2018 .

[45]  Andreas Abel,et al.  Decidability of conversion for type theory in type theory , 2017, Proc. ACM Program. Lang..

[46]  Gert Smolka,et al.  Formal Small-step Verification of a Call-by-value Lambda Calculus Machine , 2018, APLAS.

[47]  Matthieu Sozeau,et al.  Cumulative Inductive Types In Coq , 2018, FSCD.

[48]  Adam Chlipala,et al.  Reification by Parametricity - Fast Setup for Proof by Reflection, in Two Lines of Ltac , 2018, ITP.

[49]  Jacques Carette,et al.  HOL Light QE , 2018, ITP.

[50]  Simon Boulier,et al.  Towards Certified Meta-Programming with Typed Template-Coq , 2018, ITP.

[51]  Derek Dreyer,et al.  Mtac2: typed tactics for backward reasoning in Coq , 2018, Proc. ACM Program. Lang..

[52]  Jeremy Avigad Interactive Theorem Proving , 2018, Lecture Notes in Computer Science.

[53]  Dan Grossman,et al.  Œuf: minimizing the Coq extraction TCB , 2018, CPP.

[54]  Matthieu Sozeau,et al.  Equations reloaded: high-level dependently-typed functional programming and proving in Coq , 2019, Proc. ACM Program. Lang..

[55]  Yannick Forster,et al.  A certifying extraction with time bounds from Coq to call-by-value $λ$-calculus , 2019, ArXiv.

[56]  Bas Spitters,et al.  Towards a Smart Contract Verification Framework in Coq , 2019, ArXiv.

[57]  Yannick Forster,et al.  A Certifying Extraction with Time Bounds from Coq to Call-By-Value Lambda Calculus , 2019, ITP.

[58]  Nicolas Tabareau,et al.  Eliminating reflection from type theory , 2019, CPP.