Verified Extraction from Coq to OCaml
Yannick Forster, Matthieu Sozeau, Nicolas Tabareau
摘要
One of the central claims of fame of the Coq proof assistant is extraction, i.e., the ability to obtain efficient programs in industrial programming languages such as OCaml, Haskell, or Scheme from programs written in Coq's expressive dependent type theory. Extraction is of great practical usefulness, used crucially e.g., in the CompCert project. However, for such executables obtained by extraction, the extraction process is part of the trusted code base (TCB), as are Coq's kernel and the compiler used to compile the extracted code. The extraction process contains intricate semantic transformation of programs that rely on subtle operational features of both the source and target language. Its code has also evolved since the last theoretical exposition in the seminal PhD thesis of Pierre Letouzey. Furthermore, while the exact correctness statements for the execution of extracted code are described clearly in academic literature, the interoperability with unverified code has never been investigated formally, and yet is used in virtually every project relying on extraction.
In this paper, we describe the development of a novel extraction pipeline from Coq to OCaml, implemented and verified in Coq itself, with a clear correctness theorem and guarantees for safe interoperability.
We build our work on the MetaCoq project, which aims at decreasing the TCB of Coq's kernel by reimplementing it in Coq itself and proving it correct w.r.t. a formal specification of Coq's type theory in Coq. Since OCaml does not have a formal specification, we make use of the Malfunction project specifying the semantics of the intermediate language of the OCaml compiler.
Our work fills some gaps in the literature and highlights important differences between the operational semantics of Coq programs and their extracted variants. In particular, we focus on the guarantees that can be provided for interoperability with unverified code, identify guarantees that are infeasible to provide, and raise interesting open question regarding semantic guarantees that could be provided. As central result, we prove that extracted programs of first-order data type are correct and can safely interoperate, whereas for higher-order programs already simple interoperations can lead to incorrect behaviour and even outright segfaults.
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了每一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
引用它的顶会 Paper3
- All Your Base Are Belong to Us: Sort Polymorphism for Proof AssistantsJosselin Poiret, Gaëtan Gilbert, Kenji Maillard, Pierre-Marie Pédrot 等POPL 2025 · 被引用 6 次
- Syntactic Effectful Realizability in Higher-Order LogicLiron Cohen, Ariel Grunfeld, Dominik Kirst, Étienne MiqueyLICS 2025
- Definitional Proof Irrelevance Made AccessibleThiago Felicissimo, Yann Leray, Loïc Pujet, Nicolas Tabareau 等LICS 2026
它引用的顶会 Paper2
- Coq Coq correct! verification of type checking and erasure for Coq, in CoqMatthieu Sozeau, Simon Boulier, Yannick Forster, Nicolas Tabareau 等POPL 2020 · 被引用 67 次
- Relational compilation for performance-critical applications: extensible proof-producing translation of functional models into low-level codeClément Pit-Claudel, Jade Philipoom, Dustin Jamner, Andres Erbsen 等PLDI 2022 · 被引用 26 次
相关 Paper
- Formally Verified Native Code Generation in an Effectful JIT: Turning the CompCert Backend into a Formally Verified JIT CompilerAurèle Barrière, Sandrine Blazy, David PichardiePOPL 2023 · 被引用 27 次
- Certified Compilers à la CarteOghenevwogaga Ebresafe, Ian Zhao, Ende Jin, Arthur Bright 等PLDI 2025 · 被引用 2 次
- Machine-checked ZKP for NP relations: Formally Verified Security Proofs and Implementations of MPC-in-the-HeadJosé Bacelar Almeida, Manuel Barbosa, Manuel L. Correia, Karim Eldefrawy 等CCS 2021 · 被引用 1 次
- Type Inference LogicsDenis Carnier, François Pottier, Steven KeuchelOOPSLA 2024 · 被引用 3 次
- Fully Verified Instruction SchedulingZiteng Yang, Jun Shirako, Vivek SarkarOOPSLA 2024 · 被引用 1 次
