Correct and Complete Type Checking and Certified Erasure for Coq, in Coq - Ecole Normale Supérieure paris-Saclay
Article Dans Une Revue Journal of the ACM (JACM) Année : 2024

Correct and Complete Type Checking and Certified Erasure for Coq, in Coq

Résumé

Coq is built around a well-delimited kernel that performs type checking 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, template polymorphism and η-conversion), which is proven sound and complete in Coq with respect to its formal specification. Note that because of Gödel’s second incompleteness theorem, there is no hope to prove completely the soundness of the specification of Coq inside Coq (in particular strong normalization), but it is possible to prove the correctness and completeness of the implementation assuming soundness 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 meta-programming facilities to work with terms and declarations at the level of the kernel. We verify a relatively efficient type checker based on the specification of the typing relation of the Polymorphic, Cumulative Calculus of Inductive Constructions (PCUIC) at the basis of Coq. It is worth mentioning that during the verification process, we have found a source of incompleteness in Coq’s official type checker, which has then been fixed in Coq 8.14 thanks to our work. In addition to the kernel implementation, another essential feature of Coq is the so-called extraction mechanism: 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 in the future.
Fichier principal
Vignette du fichier
main.pdf (947.31 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-04077552 , version 1 (21-04-2023)
hal-04077552 , version 2 (11-09-2024)
hal-04077552 , version 3 (29-11-2024)

Licence

Identifiants

Citer

Matthieu Sozeau, Yannick Forster, Meven Lennon-Bertrand, Jakob Botsch Nielsen, Nicolas Tabareau, et al.. Correct and Complete Type Checking and Certified Erasure for Coq, in Coq. Journal of the ACM (JACM), 2024, pp.1-76. ⟨https://doi.org/10.1145/3706056⟩. ⟨hal-04077552v3⟩
1219 Consultations
881 Téléchargements

Altmetric

Partager

More