Litcius/Paper detail

Verified Extraction from Coq to OCaml

Yannick Forster, Matthieu Sozeau, Nicolas Tabareau

2024Proceedings of the ACM on Programming Languages12 citationsDOIOpen Access PDF

Abstract

One of the central claims of fame of the C oq proof assistant is extraction, i.e., the ability to obtain efficient programs in industrial programming languages such as OC aml , 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 C oq to OC aml , implemented and verified in C oq itself, with a clear correctness theorem and guarantees for safe interoperability. We build our work on the M eta Coq project, which aims at decreasing the TCB of Coq’s kernel by re-implementing it in C oq itself and proving it correct w.r.t. a formal specification of Coq’s type theory in Coq. Since OC aml does not have a formal specification, we make use of the M alfunction project specifying the semantics of the intermediate language of the OC aml compiler. Our work fills some gaps in the literature and highlights important differences between the operational semantics of C oq programs and their extraction. In particular, we focus on the guarantees that can be provided for interoperability with unverified code, and 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. CCS Concepts: • Software and its engineering → Compilers; Functional languages; Formal software verification; • Theory of computation → Type theory.

Topics & Concepts

Computer scienceProgramming languageCorrectnessCompilerFunctional programmingProof assistantHaskellProgram transformationMathematicsGeometryMathematical proofSecurity and Verification in ComputingLogic, programming, and type systemsAdvanced Malware Detection Techniques
Verified Extraction from Coq to OCaml | Litcius