Towards Automatic Transformations of Coq Proof Scripts

Nicolas Magaud
DOI: https://doi.org/10.4204/EPTCS.398.4
2024-01-22
Abstract:Proof assistants like Coq are increasingly popular to help mathematicians carry out proofs of the results they conjecture. However, formal proofs remain highly technical and are especially difficult to reuse. In this paper, we present a framework to carry out a posteriori script transformations. These transformations are meant to be applied as an automated post-processing step, once the proof has been completed. As an example, we present a transformation which takes an arbitrary large proof script and produces an equivalent single-line proof script, which can be executed by Coq in one single step. Other applications, such as fully expanding a proof script (for debugging purposes), removing all named hypotheses, etc. could be developed within this framework. We apply our tool to various Coq proof scripts, including some from the GeoCoq library.
Logic in Computer Science,Symbolic Computation,Software Engineering
What problem does this paper attempt to address?
The focus of this paper is on improving the maintainability and reusability of formal proofs generated by proof assistants like Coq. Despite the increasing popularity of these tools in helping mathematicians verify theorems, formal proofs are still technically challenging and difficult to reuse. Once a proof is completed, the script often remains unchanged and is prone to errors when updated to new versions. To address this issue, the authors propose a post-script transformation framework that aims to serve as an automated post-processing step applied after the proof is completed. As an example, they demonstrate a transformation that compresses complex proof scripts into single-step proof scripts, allowing Coq to execute the equivalent proof in a single step. Furthermore, this framework can also be used for other proof script transformations, such as fully expanding proof scripts (for debugging) or removing all named assumptions. The authors implemented a tool in OCaml that utilizes Emilio Gallego Arias's serapi library to communicate with Coq and perform transformations on Coq proof scripts. Although there are currently some limitations, such as the incomplete method of distinguishing between commands and tactics, and the ongoing development of handling partially structured proof scripts, the tool shows promise in improving automatically generated proof scripts to make them more concise and readable for humans. The paper showcases successful transformation examples of the tool in the Coq standard library and the GeoCoq library, with plans to further expand to other libraries. The authors also plan to develop a reverse transformation that converts single-step proof scripts into detailed (debuggable) proof scripts to facilitate proof porting between different versions of Coq. The ultimate goal is to design new proof script transformations to create more reliable, persistent, and maintainable proof developments.