CompCert4Lean: Porting a Verified C Compiler to Lean in Six Weeks with Parallel Coding Agents
Cong Wang, Zhiyang Chen, Fan Long, Martin Rinard
cs.PL
Nov 16, 2026 · v1
cs.LO
TL;DR
Ports CompCert's verified C compiler and its correctness proofs from Rocq to Lean using parallel LLM coding agents.
Abstract
We present CompCert4Lean, a large-scale port of CompCert 3.17's verified compiler core from Rocq to Lean, completed in approximately six weeks by one expert directing parallel LLM agents. Our migration workflow partitions the development along its dependencies, audits translated definitions and theorem statements before large-scale proof reconstruction, and then reconstructs proofs in parallel against stable interfaces. The resulting compiler covers typed CompCert C through x86-64 assembly, discharges all 4,908 recorded proof obligations without project-specific axioms, and produces executable Linux binaries. The workflow enabled the expert to concentrate on organizing the work rather than supplying technical solutions. Of 1,071 human interactions, 88.8% concerned workflow and coordination, while only three supplied technical direction. Optimization campaigns further demonstrate the benefit of the Lean port for agent-driven verified development. Under matched budgets of 24 active hours, GPT-6-astra produced a Lean candidate with 11.7% lower generated-program runtime across 29 small-tests programs, compared with 2.3% lower for its Rocq candidate, both relative to original CompCert 3.17 and while preserving the end-to-end correctness theorem. These results show that parallel LLM agents can support large-scale migration with limited human technical direction and subsequently improve the migrated compiler while retaining its formal guarantees.
Problem
Much mature program-verification infrastructure, such as the CompCert verified C compiler, exists only in Rocq and cannot be reused directly in the Lean ecosystem. Porting it by hand would take years.
Approach
One expert directed parallel LLM agents (Codex with GPT-5.6 Sol and GPT-6-astra) to migrate CompCert 3.17 from typed CompCert C to x86-64 assembly. The workflow first resolved shared migration gates such as coinductive traces, floating point, and memory injections. It then partitioned the development by dependencies, audited translated definitions and theorem statements, and reconstructed proofs in parallel against stable interfaces. A declaration map tracked correspondence between the Rocq and Lean declarations. Agent-driven optimization campaigns were then run in Lean and in Rocq under matched budgets.
Results
The port covers 173 Lean modules and about 392k lines, discharges all 4,908 proof obligations without project-specific axioms, and produces Linux binaries that pass all selected small-tests and SPEC correctness cases. Of 1,071 human interactions, 88.8% concerned workflow and coordination. With 24 active hours, GPT-6-astra cut small-tests runtime by 11.7% in Lean versus 2.3% in Rocq while preserving the end-to-end correctness theorem.
| Benchmark | Correctness cases | O0 passed | O2 passed |
|---|
| CompCert small-tests | 139 | 139/139 | 139/139 |
| Neutron | 4 | 4/4 | 4/4 |
| Zstd | 1 | 1/1 | 1/1 |
| SQLite | 1 | 1/1 | 1/1 |
Correctness results for CompCert4Lean rc-0.0.1 (passed/selected cases)