Abstract

Template-Coq ( https://template-coq.github.io/template-coq ) is a plugin for Coq, originally implemented by Malecha [18], which provides a reifier for Coq terms and global declarations, as represented in the Coq kernel, as well as a denotation command. Initially, it was developed for the purpose of writing functions on Coq’s AST in Gallina. Recently, it was used in the CertiCoq certified compiler project [4], as its front-end language, to derive parametricity properties [3], and to extract Coq terms to a CBV $$\lambda $$ -calculus [13]. 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 Calculus of Inductive Constructions (CIC), 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. We also advocate the use of Template-Coq as a foundation for higher-level tools.

Highlights

  • Meta-programming is the art of writing programs that produce or manipulate programs

  • In the setting of dependent type theory, the expressivity of the language permits to consider the case were the meta and object languages are the same, accounting for well-typedness. This idea has been pursued in the work on inductive-recursive (IR) and quotient inductive-inductive types (QIIT) in Agda to reflect a syntactic model of a dependently-typed language within another one [2,9]

  • This paper proposes to remedy this situation and provides a formal semantics of Coq’s implemented type theory, that can independently be refined and studied

Read more

Summary

Introduction

Meta-programming is the art of writing programs (in a meta-language) that produce or manipulate programs (written in an object language). Other works have taken advantage of the power of dependent types to do meta-programming in a more progressive manner, by first defining the syntax of terms and types; and defining out of it the notions of reduction, conversion and typing derivation [11,26] (the introduction of [11] provides a comprehensive review of related work in this area) This can be seen as a type-theoretic version of the functional programming language designs such as Template Haskell [22] or MetaML [24]. Its use was extended for the needs of the CertiCoq certified compiler project [4], which uses it as its frontend language It was used by Anand and Morissett [3] to formalize a modified parametricity translation, and to extract Coq terms to a CBV λ-calculus [13].

Reification of Coq Terms
Type Checking Coq in Coq
Reification of Coq Commands
Writing Coq Plugins in Coq
A Plugin to Add a Constructor
Parametricity Plugin
Intensional Function Plugin
Related Work and Future Work
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call