Lune

POPL2020Top-tier venue

Coq Coq correct! verification of type checking and erasure for Coq, in Coq

Matthieu Sozeau, Simon Boulier, Yannick Forster, Nicolas Tabareau, Théo Winterhalter

Abstract

Coq is built around a well-delimited kernel that perfoms typechecking for definitions in a variant of the Calculus of Inductive Constructions (CIC). Although the metatheory of CIC is very stable and reliable, the correctness of its implementation in Coq is less clear. Indeed, implementing an efficient type checker for CIC is a rather complex task, and many parts of the code rely on implicit invariants which can easily be broken by further evolution of the code. Therefore, on average, one critical bug has been found every year in Coq. This paper presents the first implementation of a type checker for the kernel of Coq (without the module system and template polymorphism), which is proven correct in Coq with respect to its formal specification and axiomatisation of part of its metatheory. Note that because of Gödel's incompleteness theorem, there is no hope to prove completely the correctness of the specification of Coq inside Coq (in particular strong normalisation or canonicity), but it is possible to prove the correctness of the implementation assuming the correctness of the specification, thus moving from a trusted code base (TCB) to a trusted theory base (TTB) paradigm. Our work is based on the MetaCoq project which provides metaprogramming facilities to work with terms and declarations at the level of this kernel. Our type checker is based on the specification of the typing relation of the Polymorphic, Cumulative Calculus of Inductive Constructions (PCUIC) at the basis of Coq and the verification of a relatively efficient and sound type-checker for it. In addition to the kernel implementation, an essential feature of Coq is the so-called extraction: the production of executable code in functional languages from Coq definitions. We present a verified version of this subtle type-and-proof erasure step, therefore enabling the verified extraction of a safe type-checker for Coq.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

9 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • All Your Base Are Belong to Us: Sort Polymorphism for Proof Assistants cites The taming of the rew: a type theory with computational assumptions
  • All Your Base Are Belong to Us: Sort Polymorphism for Proof Assistants cites Verified Extraction from Coq to OCaml
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers9

  1. The taming of the rew: a type theory with computational assumptionsJesper Cockx, Nicolas Tabareau, Théo WinterhalterPOPL 2021 · 24 citations
  2. End-to-End Mechanized Proof of a JIT-Accelerated eBPF Virtual Machine for IoTShenghao Yuan, Frédéric Besson, Jean-Pierre TalpinCAV 2024 · 18 citations
  3. Verified Extraction from Coq to OCamlYannick Forster, Matthieu Sozeau, Nicolas TabareauPLDI 2024 · 13 citations
  4. Mechanizing Refinement TypesMichael Borkowski, Niki Vazou, Ranjit JhalaPOPL 2024 · 7 citations
  5. All Your Base Are Belong to Us: Sort Polymorphism for Proof AssistantsJosselin Poiret, Gaëtan Gilbert, Kenji Maillard, Pierre-Marie Pédrot et al.POPL 2025 · 6 citations

Related papers

  1. Type Inference LogicsDenis Carnier, François Pottier, Steven KeuchelOOPSLA 2024 · 3 citations
  2. Computing correctly with inductive relationsZoe Paraskevopoulou, Aaron Eline, Leonidas LampropoulosPLDI 2022 · 16 citations
  3. Nested Inductive Types: Justified and Usable Nested Inductive Types in Lean and RocqThomas Lamiaux, Yannick Forster, Matthieu Sozeau, Nicolas TabareauPLDI 2026
  4. Pyrosome: Verified Compilation for Modular MetatheoryDustin Jamner, Gabriel Kammer, Ritam Nag, Adam ChlipalaOOPSLA 2025
  5. Extensible Metatheory Mechanization via Family PolymorphismEnde Jin, Nada Amin, Yizhou ZhangPLDI 2023 · 10 citations
Dusk over the sea between two cliffs drawn in fine vertical lines