betaFeedback

WorksComputer Science

CompCert4Lean: Porting a Verified C Compiler to Lean in Six Weeks with Parallel 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.

Introduction

Lean has made substantial progress as a platform for formalized mathematics and automated theorem proving [18]. Its Mathlib library [30] provides an extensive foundation of reusable mathematical definitions and theorems. AI systems are now using this infrastructure to tackle long-standing open research problems. In October 2026, OpenAI released more than 700 mathematical manuscripts reporting solutions and advances across number theory, geometry, analysis, and theoretical computer science [20]. Among these is a reported proof of the quasi-Riemann hypothesis, a weaker form of the celebrated Riemann hypothesis, accompanied by a Lean formalization [21]. Many other results in the collection also include formal proofs that can be checked mechanically [20]. These advances create an opportunity to bring increasingly capable proof agents and extensive mathematical libraries to the construction, maintenance, and extension of verified software systems.

Despite Lean’s progress, a substantial body of mature program-verification infrastructure remains available only in Rocq [31]. A prominent example is CompCert, an optimizing C compiler with a machine-checked proof of semantic preservation from C to assembly [15, 16]. Its semantics, memory model, and correctness proofs also support Rocq developments in relaxed-memory concurrency [25], separate and compositional compilation [11, 26, 27], C program logics [2], static analysis [9], and verified operating-system kernels [6]. This infrastructure embodies years of proof engineering, yet its definitions and theorems remain tied to Rocq and cannot be imported directly into Lean.

Bringing CompCert and similar infrastructure to Lean would make existing verification work reusable within the Lean ecosystem. Other developments could build on its language semantics, memory model, and correctness theorems without reconstructing those foundations. The growing capability of agents to construct Lean proofs [20] also creates an opportunity to reduce the effort of maintaining and extending verified software. For example, an agent could add a compiler optimization together with the proof needed to preserve the end-to-end correctness theorem. Migration would thus enable new developments to reuse established verification work while making that infrastructure more accessible to current proof agents.

CompCert4Lean. To realize these benefits, we present CompCert4Lean, a Lean port of the CompCert 3.17 compiler core. One author directed the main migration development with parallel LLM coding agents, completing the port in approximately six weeks. The port discharges all 4,908 recorded proof obligations without project-specific axioms and produces executable Linux binaries. The port also pays off immediately. Even though Rocq CompCert is mature, documented, and publicly available, a coding agent under the same budget of 24 active hours produces 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.

Achieving this migration in six weeks required overcoming substantial proof-engineering challenges. Even the first verified version of CompCert consisted of 42,000 lines of Rocq and took about three person-years over five years [15]. In CompCert 3.17, the 154 source modules corresponding to our migration scope contain 149,038 lines of Rocq. Porting this development requires reconstructing executable code, language semantics, theorem statements, and proofs while preserving their relationships. Its proof scripts depend on Rocq’s tactics, libraries such as Flocq [3], and details of its logic. Differences between Rocq and Lean can require new representations and proof strategies, and a change to a shared definition can affect many downstream proofs.

Addressing these challenges with coding agents introduces a further difficulty: agent throughput depends on parallelism, whereas a verified development is a dense web of dependencies among definitions, statements, and proofs. Simply assigning different modules to concurrent agents does not make their work independent. A mistake in a shared definition or theorem statement can become the basis for many agents’ work, spreading into further definitions, interfaces, and proofs. Repairing that mistake later can require changes across multiple units and invalidate substantial proof effort. Naive parallelism can therefore amplify errors as well as accelerate progress. Successful builds and kernel-checked proofs do not eliminate this risk: Lean can check a proof of an incorrectly translated proposition without establishing that it preserves the intended source statement. § 3.3 illustrates this interface risk with an inductive-interface repair.

Our workflow (Figure 2) addresses these challenges by combining dependency-based partitioning with review before large-scale proof reconstruction. We partition the formalization into units with canonical owners and stable shared interfaces, allowing agents to work in parallel once their dependencies are available. For CompCert, this yields 166 units: 154 source components and 12 shared providers. Agents first translate definitions and exact theorem statements, completing necessary supporting proofs and recording the remaining duties as explicit obligations. Independent reviewers then audit the translation against the Rocq source, and review and repair iterate before the baseline is accepted for proof reconstruction. Before large-scale proof reconstruction, the first audit caught 1,091 theorem statements reduced to True, exposing errors that translation-time builds had missed. Partitioning organizes concurrent work around consistent interfaces, while early review reduces the risk that errors in those interfaces and statements propagate into a large body of downstream proofs. Agents then reconstruct proofs against the accepted definitions and statements.

CompCert4Lean migration workflow

Figure 2. CompCert4Lean migration workflow. ①–② Fix scope and resolve risky design choices. ③ Partition the dependency graph into 166 units for independent, parallel definition migration. ④ Review and repair: 11 completed broad definition-review rounds; the first found 1,091 erased theorem statements. ⑤ Rebuild proofs in parallel against frozen statements. ⑥ Human-guided sessions close the remainder. ⑦ Deliver 4,908/4,908 proved obligations and a working toolchain. Purple outlines denote parallel-agent stages; the thin dashed arrow denotes exceptional repair of definition defects missed by auditing and exposed during proof work.

Experimental Results. Our migration produces a verified compiler core comprising 173 Lean modules and discharges all 4,908 recorded proof obligations. Its end-to-end theorem establishes semantic preservation from typed CompCert C abstract syntax to x86-64 assembly abstract syntax. A transitive audit of 75,348 project declarations finds no axioms beyond Lean’s three standard foundational axioms. The executable toolchain passes all 139 applicable CompCert small tests at both O0 and O2, together with 20 correctness executions across six SPEC CPU2026 programs and the two optimization levels. Independent source reviews and differential tests—including identical RTL after all nine stages for 18,807 programs at O2 and bit-identical results on 37.4 million specification-function inputs—complement these proofs by checking the fidelity of the migration; correspondence with Rocq remains supported by this evidence rather than a mechanized equivalence theorem.

We further evaluate whether migration makes the compiler easier for an agent to improve. We give GPT-6-astra an optimization campaign in each environment, using the first 24 active hours in both environments. Relative to original CompCert 3.17, the selected Lean candidate has 11.7% lower generated-program runtime across 29 small-test programs, compared with 2.3% lower for the Rocq candidate. On ten SPEC inputs, the corresponding reductions are 6.9% and 2.2%. These percentages follow the rounded ratios in Table 7; they include differences already present in the starting compilers and do not measure gains relative to each campaign’s own baseline. The SPEC measurements use selected test/train inputs and are not reportable SPEC scores.

ModelSmall-tests runtimeSPEC runtimeCompilation timeNew verified passesSource lines changed
GPT-6-astra0.977 / 0.8830.978 / 0.9311.054 / 2.0540 / 3252 / 2,833
DeepSeek 4.1 Flash0.992 / 0.9500.977 / 0.9111.055 / 1.8660 / 0128 / 136
Kimi K3.10.994 / 0.9770.981 / 0.9851.051 / 2.0010 / 027 / 23

Table 7. Summary of optimization campaigns. Each cell reports Rocq / Lean. O2 time ratios use original CompCert 3.17 as the baseline (= 1; lower is better). Runtime geometric means cover 29 small-tests programs and ten SPEC inputs separately; compilation covers all 39 workloads. Measurement details appear in Appendix § 15.

The Lean improvements include bounded loop duplication, extended inlining, instruction scheduling, and revised allocation heuristics, while preserving the end-to-end correctness theorem and its assumptions. Both selected candidates pass proof checking, correctness tests, and the required compilation-cost checks. The optimization traces also show that the agent produces 106 candidate variants completing full compiler and proof builds in Lean, compared with 40 in Rocq, under broadly comparable recorded token usage. This higher throughput gives the agent more opportunities to evaluate and refine optimizations. These results demonstrate a practical benefit of the migrated infrastructure in the observed campaigns, although one campaign per environment cannot separate the effects of model capability, proof automation, repository structure, and search choices.

Contributions. This paper makes the following contributions:

  • A verified C compiler in Lean. To our knowledge, CompCert4Lean is the first compiler implemented and verified in Lean that covers the full typed CompCert C abstract syntax and its compilation to x86-64 assembly. It supports all 21 configured compiler-pass slots and discharges all 4,908 recorded proof obligations without project-specific axioms. Combined with the CompCert frontend and the system assembler and linker, it produces executable Linux x86-64 binaries (§ 4). Differential testing against CompCert 3.17 yields identical RTL after all nine stages for every compared program (18,807 at O2 and 18,808 at O0) and bit-identical results on 37.4 million specification-function inputs (§ 5.2).

  • A parallel workflow for migrating verified developments to Lean. The workflow combines dependency-based parallelism with semantic review before large-scale proof reconstruction, reducing the risk that translation errors propagate across the development. One expert directed parallel agents to complete the main migration in approximately six weeks; only three of 1,071 human interactions supplied technical direction (§ 4.1); Table 2 reports the migration usage.

Agent roleDistinct sessionsUncached inputCached inputOutputTotal
Interactive / coordinator141316.016,518.533.316,867.8
Built-in subagents5514.9478.81.9495.5
External workers12,2394,874.061,037.9253.066,164.9
Total12,4355,204.978,035.2288.283,528.3

Table 2. Recorded development sessions and LLM token usage through the rc-0.0.1 release snapshot. Token counts are in millions, rounded independently to one decimal place; output includes reasoning tokens. Sessions are deduplicated and include recorded retries and unsuccessful attempts. Usage coverage is incomplete, as described in the text.

  • Evidence that agents optimize the Lean compiler more effectively. Under matched budgets of 24 active hours, GPT-6-astra produces candidates with 11.7% lower generated-program runtime on CompCert4Lean and 2.3% lower on Rocq CompCert across 29 small-tests programs, both relative to original CompCert 3.17, while preserving the end-to-end correctness theorem in both cases (Figure 1, § 5).

CompCert4Lean: verified compiler, LLM migration workflow, and agent optimization chart

Figure 1. CompCert4Lean: LLM-agent migration and verified optimization. ① Full CompCert C-to-x86-64 compilation; all 4,908 proof obligations closed. ② Definitions-first migration across 166 units, large-scale review, then parallel proof reconstruction. ③ With 24 active hours each, GPT-6-astra reduces runtime by 11.7% on Lean versus 2.3% on Rocq across 29 small-tests programs, and 6.9% versus 2.2% across ten SPEC inputs, relative to original CompCert 3.17. Both retain the end-to-end correctness theorem (§ 5).

Overview

CompCert is an optimizing C compiler developed and verified in Rocq [15, 16]. Its verified pipeline consists of passes over a sequence of intermediate representations (IRs), starting from the typed CompCert C abstract syntax tree (AST) and ending at a target assembly AST. Early passes simplify C expressions and control structures through IRs such as Clight and Cminor. Later passes lower the program to register-transfer form (RTL), perform optimizations and register allocation, and generate assembly for the selected backend. Some passes transform programs within the same IR; others translate between IR levels.

Each IR has an operational semantics defining how its programs execute and what behaviors they can exhibit. Each compiler pass comes with a correctness proof relating the input and output programs through a simulation relation. These proofs allow internal steps and program representations to change while preserving the required relationship between observable behaviors. The pass-level results compose into an end-to-end compiler correctness theorem: when compilation succeeds, the generated assembly preserves the source program’s semantics, subject to CompCert’s treatment of undefined behavior.

The IR semantics and pass-level proofs depend on shared foundations, including machine arithmetic [3], global environments, and a common memory model. These foundations connect executable operations to the invariants used throughout the correctness proofs. Migrating such a compiler therefore requires preserving not only its IRs and transformations, but also their semantics, correctness statements, and the shared definitions on which those properties depend.

Migration Scope and Correctness Obligation

We migrate CompCert 3.17’s verified compilation pipeline from the typed CompCert C AST to the x86-64 assembly AST. Our scope includes the shared foundations, IR semantics, all 21 configured compiler-pass slots, and the composed semantic-preservation theorem. The following correctness obligation and verification boundary specify the result that CompCert4Lean must establish.

Correctness obligation. Fix the x86-64 configuration and the compiler’s explicit interface parameters and required certificates. Let compile denote the migrated pipeline. We require:

∀p:Csyntax.program, a:Asm.program, ξ,compile⁡(p)=OK(a)⇒BackwardSim⁡Cξ(p), Aξ(a).(1)\forall p : \mathrm{Csyntax.program},\ a : \mathrm{Asm.program},\ \xi,\quad \operatorname{compile}(p) = \mathrm{OK}(a) \Rightarrow\operatorname{BackwardSim}_{C_{\xi}}(p),\ A_{\xi}(a). \tag*{(1)}

Here CξC_{\xi} and AξA_{\xi} are the source C and target assembly operational semantics under the same external-call interface ξ\xi. Following CompCert, backward simulation ensures that every observable target behavior matches a source behavior, allowing the target to continue with more defined behavior after the source encounters undefined behavior. Consequently, if the source program cannot go wrong, every target behavior is permitted by the source semantics.

Verification boundary and assumptions. CompCert4Lean adopts CompCert 3.17’s verification boundary for the selected x86-64 pipeline, from the typed CompCert C AST to the x86-64 assembly AST. Parsing and elaboration precede this boundary; assembly printing, assembling, and linking follow it and remain outside the compilation theorem’s scope. Provided that the source and target semantics match CompCert’s under the same external-interface assumptions, proving the correctness obligation above in Lean without project-specific axioms establishes the same end-to-end semantic-preservation guarantee. This guarantee does not require correspondence between the intermediate IRs of the two developments. Our migration scope is broader: we also preserve the definitions and correctness statements throughout the selected IR pipeline and reconstruct their proofs in Lean. We assess the fidelity of this migration through independent source-level audits and extensive differential testing against CompCert 3.17. The tests find identical RTL after all nine compilation stages for every compared program (18,807 at O2 and 18,808 at O0) and bit-identical results for 202 executable specification functions over 37.4 million inputs (§ 5.2).

Trusted computing base. Although the migration replaces the entire proof assistant, most of the trusted base stays the same. As in CompCert, the source and target semantics, the external-call interface ξ\xi, and the unverified code that the port reuses from CompCert on either side of the trust boundary, from the preprocessor to the linker, are all in the trusted computing base. The register allocator is not trusted but instead uses a verified validator to check its output (§ 3.6). The CompCert4Lean trusted base differs in three ways. First, the Lean kernel and its standard axioms (propext, Classical.choice, and Quot.sound) replace the Rocq kernel and the axioms that CompCert assumes (proof irrelevance, functional extensionality, excluded middle, and indefinite description). Second, the Lean compiler, the C compiler that compiles its output, and the Lean runtime replace extraction and the OCaml compiler and runtime. Each @[csimp] replacement, which swaps a definition for a faster implementation at compile time, is proved equal to that definition (§ 3.6), so it adds no trust beyond the Lean compiler. Third, the port adds serialization bridges to the reused OCaml front end and printer, which CompCert does not need. The bridge is unverified, but its codecs are generated from the extracted types, and every compilation in our differential testing (§ 5.2) passes through it without error.

Migration Workflow

Figure 2 presents our workflow for migrating CompCert to Lean. It consists of seven stages, grouped into planning, definition migration, proof reconstruction, and executable integration. The workflow enables large-scale parallel work by LLM agents across definition migration, auditing, and proof reconstruction. We outline these stages below.

  • Resolve migration gates. We investigate representation and interface choices whose consequences could affect many downstream tasks. Risk discovery identified 30 issues, which informed feasibility experiments covering shared foundations, compiler services, and a backend slice. Small

executable experiments and checked proofs test these choices before broad translation begins, reducing the risk of costly rework across parallel agents (§ 3.1).

  • Migrate definitions. We partition the development along its dependency graph into 166 units: 154 source components and 12 shared providers. Agents translate definitions, semantics, and exact theorem statements in parallel against stable shared interfaces. They complete necessary supporting proofs but defer most proof obligations, allowing downstream translation to proceed before upstream proofs are complete (§ 3.2).

  • Audit & repair definitions. Independent parallel agents compare the translated definitions and statements with the Rocq source before a large proof effort depends on them. The first audit found 1,091 statements reduced to True, demonstrating why successful builds were insufficient. Repeated review and repair included 11 completed broad definition-review rounds to identify and correct such errors before proof reconstruction (§ 3.3).

  • Reconstruct proofs. Automated parallel agents reconstruct proofs against the accepted definitions and statements, working from an inventory of 4,908 obligations. Bounded attempts and checks of partial results allow the process to retain completed proofs while directing further effort toward unresolved targets. This stage handles proof reconstruction at scale and identifies obligations that require human-guided investigation (§ 3.4).

  • Finalize remaining proofs. Human-guided agent sessions investigate difficult obligations and develop supporting lemmas to unblock dependent proofs, bringing the completed inventory to all 4,908 obligations. If proof work exposes a definition or statement defect, a local repair requires rechecking the affected proofs. This is the exceptional fallback shown in Figure 2, which early auditing aims to minimize (§ 3.5).

  • Integrate, validate, and optimize. We check the completed proofs and their assumptions, then connect the verified core to an executable toolchain that produces running Linux x86-64 binaries. End-to-end tests also exercise components beyond the compilation theorem’s boundary, including parsing, assembly printing, and linking. We improve compiler execution and generated-program performance while preserving the correctness guarantee (§ 3.6).

Approach

We now describe the technical decisions and coordination methods underlying the workflow in Figure 2. We focus on how to establish shared interfaces, audit translated definitions and statements, and reconstruct proofs in parallel, using concrete migration challenges to explain these choices.

Identify and Resolve Migration Gates

Before broad parallel migration, we investigate shared choices that could invalidate downstream translations and proofs if resolved incorrectly. An error in a common representation or interface can spread across agents, making a later correction require widespread rework. Six rounds of risk discovery identified 30 issues, informing five feasibility gates: representations (Gate 1), floating point (Gate 2), memory and injections (Gate 3), validated compiler services and successful execution (Gate 4), and a backend slice through pass interfaces and simulation composition (Gate 5). Executable experiments and checked proofs test these choices before agents build on them. The agents autonomously proposed and implemented the technical solutions to all identified migration gates. Appendix A describes the floating-point and memory/injection gates and reports the effort directly attributed to Gates 1–3.

These investigations illustrate four recurring sources of difficulty in Rocq-to-Lean migration, which can arise together within a gate. Proof-assistant expressiveness gaps require alternative encodings: CompCert’s infinite event traces are coinductive data, whereas Lean 4.33’s coinductive mechanism supports predicates in Prop, not data in Type. Library semantic mismatches require checking observable behavior, including NaN signs and payloads and floating-point rounding, rather than substituting operations with similar names. Missing proof infrastructure can block downstream proofs even when the translated operations have the intended behavior: supporting library lemmas must also be reconstructed. Finally, representation and invariant mismatches arise when a replacement data structure reproduces individual operations but does not support their required relationships; CompCert’s memory proofs depend on permissions, non-overlap, and preservation of memory injections. These sources of difficulty guide what a feasibility experiment must establish, beyond whether its code compiles.

Example: coinductive traces and infinite behavior. The representation gate illustrates how an expressiveness gap becomes a question about downstream semantic proofs. CompCert uses coinduction both for infinite executions, which are propositions, and for infinite event traces, which are data appearing in program behaviors. Lean 4.33’s support for coinductive predicates therefore did not by itself provide a representation for those traces. The gate had to test an alternative encoding together with the semantic arguments that consume it.

We represented an infinite trace as a total function mapping each natural-number position to its event. All observations are total. CompCert also corecursively constructs streams of nonempty finite trace chunks. We represented these as functions from natural numbers to nonempty chunks and flattened them with a cursor that recurses on the requested event position. Nonemptiness ensures that each recursive call consumes an event, allowing the flattened stream to supply any requested observation.

abbrev TraceInf (Event : Type) :=
  Nat → Event
def head (stream : TraceInf Event) :
    Event := stream 0
def tail (stream : TraceInf Event) :
    TraceInf Event :=
  fun index => stream (index + 1)
def cons (event : Event)
    (stream : TraceInf Event) :
    TraceInf Event :=
  | 0 => event
  | index + 1 => stream index

However, an encoding of streams alone would not establish that the behavior proofs could be reconstructed. The checked prototype established finite-prefix and flattening laws, then reconstructed the behavior-existence argument: repeatedly choose a reachable finite execution with a nonempty trace, construct the resulting chunk stream, and prove coinductively that its flattening is the trace of an infinite reactive execution. Infinite-execution predicates remained coinductive in Prop. This argument connected the alternative data representation to the semantic reasoning required by its consumers.

The encoding also exposed a subtler issue: equality. Function extensionality identifies streams with identical observations, whereas Rocq’s equality on coinductive data does not automatically identify bisimilar streams. We retained the source’s named bisimulation relations, proved their correspondence to pointwise observation equality in Lean, and reviewed consumers that used ordinary trace or behavior equality. These checks made the representation change explicit rather than silently assuming that the two notions of equality were interchangeable.

Resolving both the construction and equality questions before broad migration gave agents a shared interface supported by checked semantic proofs, reducing the risk of incompatible downstream encodings. The gate established feasibility for the checked interface and consumers; it did not establish equivalence between the complete Rocq and Lean developments. The later production translation remained subject to its own correspondence audit (§ 3.3).

Migrate Definitions in Parallel

The workflow next migrates definitions in parallel using the translation loop in Algorithm 1 (lines 1–13). We partition the dependency graph into 166 units—154 source components and 12 shared providers—with one canonical owner per declaration and provider, so workers share stable interfaces. Lines 1–2 initialize the baseline and pending units; lines 4–5 launch units whose prerequisites are integrated and whose dependencies have no unresolved blockers. Each assignment uses an isolated checkout of a pinned baseline and reserves disjoint writable files. Agents translate executable definitions, semantic relations, and exact theorem statements, recording most proofs as outstanding obligations while completing supporting proofs required by interfaces. This separation allows downstream translation to proceed before all upstream proofs are complete, without allowing consumers to bypass required proof evidence.

As workers finish, lines 7–13 check and integrate their results, making accepted providers available to dependent units. The integration check (line 9) enforces canonical ownership, intended declaration identities and statement interfaces, restrictions on proof escapes, and build requirements against the current baseline, including changes accepted since the worker started. Rejected candidates retain diagnostics for retry or a blocking report, while unrelated ready work continues. These checks establish that translations can be assembled and used together, but do not establish source correspondence. The audit loop (lines 14–27), described in § 3.3, determines whether the definitions and statements can be accepted as the baseline for proof reconstruction.

Iteratively Audit and Repair Definitions

The workflow next audits and repairs the translated definitions and statements using Algorithm 1’s second loop. Lines 14–18 initialize the audit evidence, fix a snapshot, and extract its proof inventory for independent parallel review. Reviewers compare computational definitions, theorem statements, and relevant consumer interfaces with the Rocq source, including premises, binders, and proof-bearing invariants. At line 19, findings are classified by severity and unresolved critical issues from all rounds are retained in decision.unresolvedCriticalIssues. In our migration, the human did not escalate audit issues. Human involvement included only three technical-direction messages, including one confirmed override, as detailed in § 4.1. The stopping condition at line 20 requires that no unresolved critical issues remain and freezes the reviewed targets for ordinary proof reconstruction; it does not imply complete review coverage or discharge the remaining proofs.

Algorithm 1 Parallel definition migration and iterative correspondence auditing.

Input: pinned source source, contract contract, dependency graph graph.

Output: accepted baseline, obligation inventory, audit evidence and decision; or a blocking report.

  1. base←InitialBaseline⁡(contract)base \leftarrow\operatorname{InitialBaseline}(contract)

  2. pending←Units⁡(graph)pending \leftarrow\operatorname{Units}(graph); running←∅running \leftarrow\varnothing

  3. while pending≠∅pending \ne\varnothing:

  4.     ready←ReadyUnits⁡(pending,graph,base)ready \leftarrow\operatorname{ReadyUnits}(pending, graph, base)

  5.     running←LaunchLeased⁡(ready,base,running)running \leftarrow\operatorname{LaunchLeased}(ready, base, running)

  6.     if running=∅running = \varnothing: return Blocked⁡(base,pending)\operatorname{Blocked}(base, pending)

  7.     results←CollectFinished⁡(running)results \leftarrow\operatorname{CollectFinished}(running)

  8.     for each candidate∈resultscandidate \in results:

  9.         if IntegrationReady⁡(candidate,base,contract)\operatorname{IntegrationReady}(candidate, base, contract):

  10.             base←Integrate⁡(base,candidate)base \leftarrow\operatorname{Integrate}(base, candidate)

  11.             pending←pending∖Units⁡(candidate)pending \leftarrow pending \setminus\operatorname{Units}(candidate)

  12.         else: RecordRetryOrBlock⁡(candidate,pending)\operatorname{RecordRetryOrBlock}(candidate, pending)

  13.     ReleaseFiles⁡(results,running)\operatorname{ReleaseFiles}(results, running)

  14. evidence←∅evidence \leftarrow\varnothing; scope←WholeDevelopment⁡scope \leftarrow\operatorname{WholeDevelopment}

  15. loop:

  16.     snapshot←Snapshot⁡(base)snapshot \leftarrow\operatorname{Snapshot}(base)

  17.     inventory←ExtractObligations⁡(snapshot,source)inventory \leftarrow\operatorname{ExtractObligations}(snapshot, source)

  18.     evidence \leftarrow \operatorname{AuditRound}(snapshot, source, scope, inventory, evidence)

  19.     decision←ReviewFindings⁡(evidence,contract)decision \leftarrow\operatorname{ReviewFindings}(evidence, contract)

  20.     if decision.unresolvedCriticalIssues=∅decision.unresolvedCriticalIssues = \varnothing:

  21.         return (snapshot,inventory,evidence,decision)(snapshot, inventory, evidence, decision)

  22.     if decision.needsOwnerdecision.needsOwner: return AwaitDecision⁡(snapshot,evidence)\operatorname{AwaitDecision}(snapshot, evidence)

  23.     edits←ParallelRepair⁡(snapshot,decision.repairs)edits \leftarrow\operatorname{ParallelRepair}(snapshot, decision.repairs)

  24.     base←IntegrateCheckedRepairs⁡(base,edits)base \leftarrow\operatorname{IntegrateCheckedRepairs}(base, edits)

  25.     changed←ChangedInputs⁡(snapshot,base)changed \leftarrow\operatorname{ChangedInputs}(snapshot, base)

  26.     evidence←InvalidateAffected⁡(evidence,changed)evidence \leftarrow\operatorname{InvalidateAffected}(evidence, changed)

  27.     scope←NextAuditScope⁡(changed,evidence)scope \leftarrow\operatorname{NextAuditScope}(changed, evidence)

Otherwise, questions requiring an expert decision are returned at line 22, and repairs proceed in parallel against a common snapshot with disjoint writable files (lines 23–24). After integration, lines 25–27 invalidate evidence affected by changed definitions or dependencies and select the next review scope. A provider change can invalidate a consumer’s review even when the consumer itself is unchanged. Rechecking affected interfaces and reusing only unchanged evidence allows review and repair to iterate without treating an earlier successful review as permanent acceptance. Appendix B reports how findings evolved across review rounds and records the evidence and limitations of the final acceptance decision.

Example: a lost constructor interface. During our migration campaign, the third proof-inventory review found that SetoidList.InA had been translated directly as ∃y, eqA x y∧y∈xs\exists y,\ eqA\ x\ y \land y \in xs. The Rocq source instead defines the relation inductively with head and tail constructors, then proves InA_alt to characterize it by this existential predicate. In the translation, InA_alt followed immediately by Iff.rf1, but the constructor and induction interfaces were lost. The predicates were logically equivalent; the mismatch concerned the interface available to downstream proofs.

The agents restored the inductive definition and constructors, proved the characterization by induction, and adjusted membership and sortedness proofs in the consuming MSetGenTree unit.

Algorithm 2 Automated proof grinding with partial acceptance and bounded retries.

Input: accepted baseline basebase, exact target inventory inventoryinventory, attempt policy policypolicy.

Output: extended baseline, completed targets, and explicit unfinished targets.

  1. state←InitProofState⁡(base,inventory,policy)state \leftarrow\operatorname{InitProofState}(base, inventory, policy)

  2. running←∅running \leftarrow\emptyset

  3. loop:

  4.     ready←ReadyTargets⁡(state)ready \leftarrow\operatorname{ReadyTargets}(state)

  5.     batches←GroupByOwnerAndFile⁡(ready,policy)batches \leftarrow\operatorname{GroupByOwnerAndFile}(ready, policy)

  6.     running←LaunchLeased⁡(batches,base,running)running \leftarrow\operatorname{LaunchLeased}(batches, base, running)

  7.     if running=∅running = \emptyset:

  8.         return (base,Finished⁡(state),Unfinished⁡(state))(base, \operatorname{Finished}(state), \operatorname{Unfinished}(state))

  9.     result←CollectNext⁡(running)result \leftarrow\operatorname{CollectNext}(running)

  10.     if OperationalFailure⁡(result)\operatorname{OperationalFailure}(result):

  11.         RecordIncidentAndRecover⁡(result,state)\operatorname{RecordIncidentAndRecover}(result, state)

  12.     else:

  13.         RecordDefinitionFindings⁡(result,state)\operatorname{RecordDefinitionFindings}(result, state)

  14.         accepted←∅accepted \leftarrow\emptyset

  15.         extensions←ProofCheckpoints⁡(result)extensions \leftarrow\operatorname{ProofCheckpoints}(result)

  16.         for each extension∈DependencyOrder⁡(extensions)extension \in\operatorname{DependencyOrder}(extensions):

  17.             staged←Apply⁡(base,extension)staged \leftarrow\operatorname{Apply}(base, extension)

  18.             if ValidExtension⁡(staged,base,inventory)\operatorname{ValidExtension}(staged, base, inventory):

  19.                 base←stagedbase \leftarrow staged

  20.                 accepted←accepted∪Targets⁡(extension)accepted \leftarrow accepted \cup\operatorname{Targets}(extension)

  21.             else: RetainRejectedCandidate⁡(extension)\operatorname{RetainRejectedCandidate}(extension)

  22.         MarkFinished⁡(state,accepted)\operatorname{MarkFinished}(state, accepted)

  23.         remaining←Assigned⁡(result)∖acceptedremaining \leftarrow\operatorname{Assigned}(result) \setminus accepted

  24.         ScheduleSingletonOrDefer⁡(state,remaining,result)\operatorname{ScheduleSingletonOrDefer}(state, remaining, result)

  25.     ReleaseFiles⁡(result,running)\operatorname{ReleaseFiles}(result, running)

  26.     Checkpoint⁡(base,state)\operatorname{Checkpoint}(base, state)

Iterative review caught a lost proof interface despite logical equivalence and successful builds; the repair restored the constructors and induction interface needed by downstream proofs.

Reconstruct Proofs in Parallel

Algorithm 2 reconstructs proofs in parallel against the accepted definitions and statements. Lines 1–6 initialize the proof state and assign ready targets whose dependencies are available, whose attempt budgets remain, and which are not already assigned. Workers use isolated baseline revisions and disjoint writable files, adapting source proofs to Lean’s libraries and automation while preserving the frozen targets. Attempts are bounded so that difficult obligations do not prevent progress on other available proofs. Operational failures enter recovery (lines 10–11), while suspected definition mismatches return to review (line 13); neither justifies weakening the target statement.

Lines 15–22 retain checked partial progress: a worker may contribute completed proofs and their required helpers even when other assigned targets remain open. Each addition is checked in dependency order against the current integrated baseline, including proofs accepted while the worker was running. The acceptance check at line 18 requires exact target types, preservation of existing definitions and proofs, a successful build, and only the permitted transitive axioms: propext, Classical.choice, and Quot.sound. Unfinished obligations remain available for further attempts or are deferred when dependencies or budgets prevent progress (lines 23–26); the algorithm returns both completed and unfinished targets when no worker remains (lines 7–8). The human expert can also choose when to stop automatic reconstruction. In our campaign, the expert stopped it with work still queued and 471 obligations remaining, motivating guided investigation of difficult or blocked targets (§ 3.5). Appendix § 12 reports the proof-inventory milestones and the distribution of the remaining obligations.

Batch size balances shared context against the context window available to each agent. At line 5, we group up to four related proof obligations from the same file, allowing a worker to reuse definitions, lemmas, and proof strategies. Larger batches risk exhausting the context window before all targets are addressed; smaller batches repeat shared context and waste agent effort. Four was our practical choice for this trade-off, not an experimentally established optimum. Targets left unfinished by a batch receive subsequent singleton attempts (line 24), allowing focused work without repeatedly carrying the entire batch’s context.

Finalize Proofs through Human-Guided Agent Sessions

The 471 obligations remaining when automatic reconstruction stopped became inputs to human-guided agent sessions. Each session focused on one file, with independent sessions able to proceed in parallel. In this migration, the expert managed context by starting fresh sessions when contexts grew long, decided whether to batch or continue work, permitted longer timeouts, and prompted agents to finish proofs in specific files. The agents supplied proof strategies and constructed proofs and supporting lemmas; the expert did not contribute technical proof solutions. This process completed all 4,908 recorded obligations. § 4.1 analyzes the human interactions throughout the migration. During this stage, only two floating-point-related cases required local repair: a conversion omitted destination normalization, and a theorem omitted its format assumptions. The missing-assumptions case is detailed below; Appendix § 13 gives the conversion counterexample and repair.

A theorem missing its format assumptions. A separate failure concerned the Binary theorem that a canonical value below 2emax2^{emax} satisfies the format’s boundedness test. Its translated statement omitted the source assumptions 0<prec0 < prec and prec<emaxprec < emax. Section-local Lean instances were not retained as parameters because the declaration did not explicitly refer to them. Agents constructed a kernel-checked counterexample with precision 2, maximum exponent 1, mantissa 1, and exponent 0. The value is canonical and satisfies 1<21 < 2, but the boundedness test requires 0≤−10 \le-1 and returns false. This configuration violates the source format assumptions, so it refutes the translated statement rather than the upstream theorem.

This example demonstrates our workflow’s ability to distinguish an incorrectly translated proof target from a difficult proof obligation: the agents constructed a kernel-checked counterexample that justified repairing the statement before resuming proof reconstruction. The repair explicitly bound both assumptions in the statement and reused the corresponding SingleNaN theorem to supply its proof. Together with the conversion repair in Appendix § 13, this case exercises the feedback path in Figure 2: counterexamples justify reopening an accepted definition or proposition through the review procedure in § 3.3, followed by authorized repair and rechecking of affected proofs. A stalled search alone would not justify either change.

Integrate, Validate, and Optimize the Result

With the correctness obligation in § 2.1 discharged, we integrate the verified core into a working C-to-native toolchain.

Integration and validation. We assemble the core with the pinned CompCert frontend and assembly printer, typed interchange formats, concrete compiler services, and the system assembler and linker. A Lean-native register allocator supplies proposals to the existing validator. Together, these components support compilation from C source to native executables. Because components outside the formal boundary still require testing, we validate the integrated toolchain; § 5.1 presents the validation procedures and results.

Register allocation. We preserve CompCert 3.17’s verification boundary: the allocation algorithm is unverified, but its output must pass the verified RTL-to-LTL validator. Correctness therefore depends on successful validation rather than on a proof of the allocation algorithm itself. Builtin expansion requires additional care because its concrete instruction sequences impose operand-placement constraints beyond the abstract builtin semantics. As in CompCert 3.17, our allocator respects these target-specific constraints; we also check compatibility before expansion. This executable check guards the integration with the assembly expander without extending the formal guarantee beyond the assembly abstract syntax described in § 2.1.

Compiler execution-time optimization. The earlier stages prioritize faithful formal definitions and correctness proofs over execution efficiency. The initial implementation compiled some programs too slowly to complete practical validation runs. Straightforward implementations chosen for ease of formalization therefore required substantial execution-time optimization before the compiler was practical to use. Once the toolchain runs, we task agents specifically with reducing the compiler’s own execution time while preserving the logical definitions and existing proofs. Where appropriate, Lean’s @[csimp] mechanism replaces executable implementations using kernel-checked proofs of equality with the logical definitions. For example, interference-graph construction unnecessarily copied an entire adjacency array because an update preceded a read from the old array. Reading both neighbor sets before either update avoids this copy, yet the revised operation is definitionally equal to the original.

Implementation

Using the workflow described in § 3, we implemented CompCert4Lean, a Lean port of CompCert 3.17’s verified compiler core. The migration agents ran in Codex, powered by GPT-5.6 Sol before September 17, 2026, and GPT-6-astra thereafter. Both models used the extra-high reasoning setting (xhigh) by default. Throughout the migration, we maintained a declaration map linking the required Rocq definitions and theorems to their Lean counterparts, recording their ownership and proof obligations. Coverage followed the selected compiler features and their dependencies across executable definitions, theorem statements, and proofs, including shared libraries and generated declarations. Explicit exclusions and reviewed representation changes distinguished intentional differences from missing translations.

Table 1 summarizes the resulting implementation. The migrated core spans 173 Lean modules and 391,963 physical source lines, compared with 149,038 source lines in the corresponding 154 Rocq modules. The Lean count includes comments and blank lines; the core subtotal excludes the added allocator and toolchain integration. The core covers foundations and floating-point arithmetic, language semantics, compiler transformations, and the composed correctness theorem. It discharges all 4,908 recorded obligations, which include theorem proofs and proof-bearing certificates but do not count every supporting lemma. Adding the native register allocator and toolchain integration brings the implementation to 189 Lean files and 396,160 lines. These additional components support a runnable Linux x86-64 compiler, while the formal correctness boundary remains typed CompCert C abstract syntax to x86-64 assembly abstract syntax, as specified in § 2.1.

ComponentLean filesLinesCompleted obligations
Foundations and libraries3464,5571,266
Floating-point development (Flocq)2451,178554
Common semantics and infrastructure1844,081799
Typed-C frontend and proofs1746,383437
Backend transformations and proofs56136,4481,516
x86-64 backend and configuration2147,439324
Pipeline composition and correctness31,87712
Migrated core subtotal173391,9634,908
Native allocator81,603—
Lean toolchain integration72,403—
Build aggregation root1191—
Total189396,1604,908

Table 1. Lean implementation size and proof coverage at the release implementation milestone (801facb). Lines are physical source lines, including comments and blank lines. Counts exclude tests, external dependencies, generated build artifacts, and OCaml/Python integration code. A dash indicates a component outside the original migration proof inventory.

Table 2. Recorded development sessions and LLM token usage through the rc-0.0.1 release snapshot. Token counts are in millions, rounded independently to one decimal place; output includes reasoning tokens. Sessions are deduplicated and include recorded retries and unsuccessful attempts. Usage coverage is incomplete, as described in the text.

Migration cost. Table 2 reports recorded LLM usage by agent role across 12,435 distinct project sessions. Recorded input and output total 83.53 billion tokens; cached input accounts for 93.75% of all input tokens. The accounting ends at the conclusion of the turn that created and locally verified the annotated rc-0.0.1 tag for the September 24 implementation milestone in Table 1. Thirteen interactive/coordinator sessions and 2,989 external-worker sessions lack positive usage counters. The figures describe locally recorded usage with partial coverage of provider billing.

External workers account for approximately 79% of the recorded tokens in Table 2. Most recorded usage therefore went to worker tasks that could run in parallel, reflecting the workflow’s emphasis on decomposing migration work across agents. Recorded usage is also dominated by input tokens. This pattern is consistent with proof migration, where agents consult substantial source and dependency context to construct comparatively short definitions or proofs.

For Table 3, attribution follows recorded task objectives and includes supporting work. Activity dates span the earliest and latest attributed activity markers. Manual user-prompt tokens are counted with o200k_base.

PhaseActivity dates (UTC)Uncached input (M)Cached input (M)Output (M)Total (M)Manual prompts (exact tokens)
1Aug. 11–179.9296.41.6307.92,199
2Aug. 11–16150.58,602.825.88,779.11,721
3Aug. 17–20106.82,041.67.32,155.62,433
4Aug. 20–Sep. 23,239.045,582.6165.148,986.77,260
5Sep. 2–211,642.220,412.082.422,136.612,000
6Sep. 21–2236.8705.03.5745.41,279
7Sep. 22–2419.6394.92.5417.02,673
TotalAll5,204.978,035.2288.283,528.329,565

Table 3. Recorded LLM token usage by migration phase, using the same release snapshot as Table 2. LLM token counts are in millions, rounded independently; output includes reasoning tokens. Manual prompt counts are exact and excluded from Total (M). Activity dates are inclusive UTC dates. The usage-coverage limitations of Table 2 also apply.

Note: Phase 4 dates cover its main activity. Minor local definition fixes were subsequently made to address issues discovered during phase 6.

Table 3 attributes the same recorded usage across the seven workflow phases in Figure 2 by recorded task objectives. Review and repair (phase 4) account for approximately 59% of the recorded tokens in Table 3, with activity spanning August 20 to September 2. However, the last issue whose repair had broad downstream consequences was identified in the third review round; later issues required local fixes. We conservatively completed eleven broad review rounds (Appendix § 11). In retrospect, this suggests that stopping earlier could reduce review cost, although the appropriate stopping point was uncertain at the time. Reducing review also risks cascading repairs during downstream proof reconstruction, when many proofs already depend on the shared definitions. The cost therefore reflects the effort to establish stable definitions before large-scale proof work.

Human Effort

The migration involved 29,565 tokens of human-authored prompts across the six-week development period (Table 3), a modest volume of direct instruction for a development of this scale. One author served as the sole human developer directing the main migration, with agents constructing definitions and proofs. Human interaction focused on setting priorities, reviewing results, and directing subsequent work. In the expert’s experience, parallel workers often ran autonomously for hours between interventions, with human attention concentrated around progress checks and phase or review-round boundaries.

Human involvement was therefore intermittent across the six weeks, rather than continuous implementation work. The workflow allowed the expert to guide many concurrent tasks while agents constructed definitions and proofs. Under one expert’s direction, agents migrated a mature verified compiler embodying an estimated several dozen person-years of accumulated development into Lean in approximately six weeks.

To characterize this involvement, we analyzed all 1,071 substantive human messages exchanged across 211 sessions during the development leading to RC1. Each message counts once, regardless of length; these interaction counts are separate from the prompt-token total above. Figure 3 summarizes the roles of these human contributions.

Pie chart of human messages by role

Figure 3. Human messages by role (N=1,071N = 1{,}071). Areas show exact shares; percentages are rounded.

Workflow organizes work through proof-task assignments, review scheduling, phase transitions, or retry policies. Naming a theorem or asking agents to prove it does not by itself supply technical content. Technical review and discussion engage with that content, for example by asking why a proof fails, examining assumptions, or approving an agent’s proposal,

without introducing a substantive technical proposal. Human technical direction supplies a concrete diagnosis, correction, implementation alternative, or proof strategy. It need not override an agent’s recommendation or be correct. When roles overlap, technical direction takes precedence over review and discussion, which takes precedence over workflow.

Human contributions centered on coordinating parallel work (951 messages, 88.8%) and reviewing or discussing technical content (117 messages, 10.9%), including questions, investigation, and approvals. This active coordination and review accompanied remarkably little human-supplied technical direction: only three messages (0.3%). The three directions comprise a tentative proposition-repair suggestion subsequently corrected by the agent, a conditional fallback to upstream register allocation, and a later change from local prototype repairs toward a CompCert-style allocator. The latter two belong to the same allocator-development episode; Appendix § 16 describes the corpus and classification procedure and gives the context and follow-through for all three cases.

Evaluation

We evaluate CompCert4Lean along three questions. Does the port compile real programs correctly and as efficiently as CompCert (§ 5.1)? Is the port faithful to CompCert, pass by pass (§ 5.2)? And do coding agents improve the compiler further in Lean than in Rocq, while keeping its correctness proof (§ 5.3)?

blackBenchmarks and Release Results

Benchmarks and correctness results. Our benchmark set is exhaustive within the scope defined in § 2.1. It includes (i) all CompCert 3.17 small-tests within that scope and (ii) all SPEC CPU2026 benchmarks written entirely in C that fall within the C subset supported by CompCert. Benchmark membership is determined by these scope and language criteria, independently of measured compiler performance. Every qualifying program is included, ruling out cherry-picking programs for favorable results within these two suites.

For Table 4, LoC counts physical lines in compiled C translation units before preprocessing, including comments, blank lines, and inactive code, but excluding headers and system libraries. The small-tests mean covers its 29 performance programs and is rounded to the nearest line; shared source files count once per program using them. SPEC programs count once across inputs.

BenchmarkDomainLoCCorrectness casesPerformance workloadsO0 passedO2 passed
CompCert small-testsMixed2,909 (avg.)13929139/139139/139
LBMFluid simulation1,016222/22/2
NeutronParticle transport3,832444/44/4
TeaLeafHeat conduction4,284111/11/1
NABMolecular modeling17,776111/11/1
ZstdCompression34,920111/11/1
SQLiteDatabase232,586111/11/1

Table 4. Benchmark coverage and recorded correctness results for CompCert4Lean rc-0.0.1. LoC reports physical source lines: the mean per program for small-tests and the total program span for SPEC. Correctness counts are per optimization profile; pass columns report passed/selected cases.

Table 4 summarizes the benchmark coverage and correctness checks for the CompCert4Lean rc-0.0.1 release on Linux x86-64. The imported CompCert small-tests suite contributes 139 applicable correctness cases, covering language regressions, ABI interoperability, numerical kernels, and applications. We treat all 29 performance workloads as one group. The nine documented correctness exclusions concern other architectures, a frontend-only negative test, the Rocq export group, mixed-struct ABI modes excluded upstream on x86-64, and a test whose expected result depends on non-portable pointer arithmetic. The six qualifying SPEC CPU2026 programs span numerical simulation, molecular modeling, compression, and database processing. They compile unmodified, using serial configurations and the required build flags.

All included correctness cases pass at both O0 and O2; the pinned upstream CompCert 3.17 also passes these checks. The six SPEC programs contribute ten selected test/train inputs, giving 20 CompCert4Lean executions across the two optimization profiles. Correctness uses the supplied expected outputs or workload-specific checks, including SPEC’s output comparators. These execution and integration checks complement the compiler’s semantic-preservation proof. The 139-case small-tests count includes compile-only checks, and its correctness and performance populations overlap. The selected SPEC inputs are not official SPEC performance scores.

Performance results. Table 5 reports generated-program runtime and compiler execution cost with CompCert 3.17 fixed at a baseline of one. Every entry divides the named compiler’s time by the corresponding CompCert time, so lower values are better. The program-runtime columns compare O2 executables produced by CompCert4Lean rc-0.0.1 and GCC 15.2.0 against those produced by CompCert 3.17. The compilation columns compare CompCert4Lean with CompCert at O0 and O2. Compilation covers C-to-object translation, including preprocessing and assembly, while excluding final linking and helper setup. We sum translation-unit times within each program and take geometric means of the per-program ratios for the 29 small-tests workloads. Runtime aggregates are geometric means of per-input ratios, giving each input equal weight. On small-tests, CompCert4Lean closely matches CompCert’s generated-program runtime (ratio 1.004), while GCC achieves 0.796; CompCert4Lean’s compilation ratios are 2.16 at O0 and 2.18 at O2.

BenchmarkInputsProgram runtime (O2) Lean/CompCert ↓Program runtime (O2) GCC/CompCert ↓Compilation time (Lean/CompCert) O0 ↓Compilation time (Lean/CompCert) O2 ↓
CompCert small-tests291.0040.7962.162.18
LBM20.9770.6511.961.61
Neutron40.9880.4571.671.76
TeaLeaf10.9660.6291.521.59
NAB11.0010.6561.711.74
Zstd11.0000.7221.641.70
SQLite11.0010.9901.711.84

Table 5. Recorded release performance, normalized to CompCert 3.17 = 1 in every column. Lower is better: values below one indicate less time than CompCert. Program runtimes use O2; compilation ratios use the indicated optimization profile. The small-tests runtime row aggregates medians over all 29 workloads; SPEC runtime rows aggregate the selected test/train inputs. SPEC runtime and all compilation values are single-run observations, with the measurement qualifications described in the text.

The small-tests runtime measurements use the retained, hash-checked release-validation executables and the retained GCC executables, with one warmup and seven measured executions per compiler. Execution is serial on logical CPU 2 of an AMD Ryzen 9 5900X, and compiler order rotates between rounds. All 29 workloads contribute, including the shortest GCC execution (approximately 9 ms); timings include process startup. The SPEC runtime values use the original quick-profile test/train inputs. SPEC runtime and all compilation values are single-run observations. Small-tests compilation used four concurrent case jobs, whereas SPEC compilation and execution were serial. The LBM reference and GCC observations are from September 23. The other SPEC reference observations are also from September 23, Lean observations are from September 24, and the five additional GCC observations are from October 3. These differences in measurement protocol and date make the compilation and SPEC values provisional; small runtime differences should not be interpreted as statistically established improvements.

Differential Testing against CompCert

The correctness theorem relates CompCert4Lean to its own Lean semantics, not to CompCert’s Rocq development. We therefore compare CompCert4Lean with CompCert 3.17 at three executable levels (Table 6), using 22,062 test records from generated programs, existing test suites, handwritten cases, bug regressions, and optimizer-divergence tests.

LevelComparisonResult
OutputExit status and stdout, O0/O237 discrepancies, explained
IRComplete RTL at nine stages18,807 (O2), 18,808 (O0) identical
Specification202 executable functions37.4 million inputs, bit-identical

Table 6. Differential-testing summary. Results concern the tested inputs; the output discrepancies comprise two undefined-behavior cases and 35 mixed-compiler ABI cases.

Identical IR at every stage. The strongest evidence comes from the intermediate representation. On every one of the 18,807 programs compared at O2 (18,808 at O0), the complete RTL is byte-identical after each of the nine RTL stages, with not a single difference. Equal program output alone would be weaker evidence, because a pass that was translated incorrectly, for example a CSE that misses some redundancies, can still produce correct programs. The IR comparison catches such a pass at its own stage. To confirm that this check can fail, we mutated the Lean passes: every pass mutant we built was detected, always at the stage of the mutated pass (Appendix § 14).

The other two levels agree. The 37 discrepancies come from undefined behavior (2 records) and from structures passed to GCC-compiled callees under CompCert’s own calling convention (35 records); when caller and callee are compiled by the same compiler, these programs agree across CompCert, CompCert4Lean, GCC, and Clang. At the specification level, 202 executable functions give bit-identical results on 37.4 million inputs, even for the floating-point operations that the port defines with Lean’s Float.Model instead of Flocq.

These tests check the compiler, not the Lean semantics or statements; their correspondence with the Rocq source is checked by the source audits in § 3.3. At the IR level, tests also stop before register allocation, and the parser and assembler are shared with CompCert (Appendix § 14).

Optimization Campaigns

The preceding experiments establish that CompCert4Lean produces executable programs and closely follows the original compiler. We next ask whether migration also makes this infrastructure more useful to coding agents. Specifically, can an agent improve generated-program performance while preserving the compiler’s correctness guarantees, and does it achieve better results in Lean than in Rocq? We evaluate this question through optimization campaigns with GPT-6-astra, DeepSeek 4.1 Flash, and Kimi K3.1, using one campaign per model in each environment.

Each campaign starts from a frozen compiler version and asks the agent to improve O2 program performance while retaining correctness and satisfying compilation-time constraints. The agent explores optimization ideas, modifies the compiler, checks its changes, and measures candidate performance. It may revise existing optimization policies or introduce new transformations with the proofs needed to integrate them into the compiler. Table 7 summarizes the selected candidates on 29 small-tests programs and ten SPEC inputs, with times normalized to original CompCert 3.17. It also reports new verified passes and retained source-line changes. The campaigns use a budget of 24 active hours. These are separate searches rather than repeated trials; measurement qualifications therefore matter when interpreting the comparison. The Astra and DeepSeek measurements use different compression and SPASS inputs across environments. We remeasure Kimi on identical inputs with a shared, fresh original-CompCert reference. Appendix § 15 gives the protocols.

New verified passes count distinct transformations integrated into the selected compiler with a new correctness proof, excluding heuristic changes and reuse of existing validators. Astra’s Lean count includes path splitting, loop unrolling, and instruction scheduling; the first two share an implementation and proof family. Source lines changed counts additions plus deletions in the final compiler implementation and proof sources relative to each campaign’s frozen baseline, including OCaml and compiler diagnostics but excluding tests, scripts, documentation, and generated files. Whitespace-only changes are ignored. This measures retained change size, not difficulty.

Optimization results. All three models produce Lean candidates with lower small-tests runtime than their Rocq counterparts; Astra and DeepSeek also achieve lower SPEC runtime (Table 7). For GPT-6-astra, the small-tests ratios are 0.883 in Lean and 0.977 in Rocq, while the SPEC ratios are 0.931 and 0.978. DeepSeek achieves corresponding ratios of 0.950 versus 0.992 on small-tests and 0.911 versus 0.977 on SPEC. Kimi K3.1 achieves small-tests ratios of 0.977 in Lean and 0.994 in Rocq. On SPEC, its ratios are 0.985 and 0.981, respectively; the Lean candidate has a small advantage on small-tests, while the Rocq candidate is slightly faster on SPEC. The Lean candidates retain higher compilation costs: Astra’s compilation-time ratio is 2.054, compared with 1.054 for Rocq, and DeepSeek’s is 1.866, compared with 1.055. Astra also produces 106 variants completing full compiler and proof builds in Lean, compared with 40 in Rocq.

These results illustrate the practical benefit of bringing established verification infrastructure into Lean, while also showing that the benefit depends on how a model uses that infrastructure. Astra provides the clearest example of extending the compiler: its selected Lean version introduces path splitting, loop unrolling, and instruction scheduling, with the first two sharing an implementation and correctness proof. It retains 2,833 changed source lines, compared with 252 in its Rocq version. DeepSeek adds no new standalone verified pass, but improves performance through new inlining-selection and layout heuristics in Lean, retaining 136 changed lines compared with 128 in Rocq. Kimi likewise retains heuristic changes, with 23 changed source lines in Lean and 27 in Rocq, and no new verified pass in either selected compiler. Thus, improvements arise from new verified transformations and better use of existing passes. The advantage supports the value of the migration for agent-driven compiler development, although one campaign per model and environment cannot separate model capability, proof infrastructure, repository layout, and search variability.

GPT-6-astra’s Lean optimization study. Beyond the aggregate results, Astra’s new passes illustrate the scope of autonomous development enabled by the migrated infrastructure. Given the overall objective of improving generated-program performance, Astra independently selected, designed, implemented, proved, and evaluated these optimizations during the campaign of 24 active hours, without further human input. It developed a general RTL code-copying transformation for both acyclic path splitting and loop unrolling. Path splitting keeps execution paths separate at joins so that constant propagation can specialize them. Loop unrolling exposes successive iterations to existing optimizations by copying the loop body and redirecting control flow between them.

These transformations must preserve execution through branches, calls, and returns. Astra constructed a simulation relating each source instruction to its target copies, preserving register and memory contents while tracking corresponding return addresses in the call stack. The proof supports arbitrary routing policies, separating the correctness of the copying machinery from the decisions about which copies execution visits. This design allowed Astra to reuse the same implementation and proof for two distinct optimization passes and integrate both into the compiler’s end-to-end correctness argument.

Astra also independently developed an RTL instruction scheduler that reorders adjacent independent operations and loads before register allocation. A liveness-based heuristic selects exchanges intended to reduce register pressure, while dependency checks ensure that the instructions neither consume each other’s results nor write the same register. Control flow introduces an additional challenge: another edge may enter the second instruction directly. The implementation creates a separate block for the reordered pair while preserving those existing entries, so that reordering does not cause such executions to perform an extra instruction.

The scheduling proof accounts for intermediate states in which the source and target have executed different instructions. Its simulation tracks this partial progress until both reordered instructions have executed; independence preserves their inputs, and updates to distinct registers commute, restoring agreement. Astra integrated the resulting proof into the verified compilation pipeline and evaluated the optimization as part of its search. Together, these cases demonstrate autonomous development of new verified extensions: the agent identified optimization opportunities and carried them through algorithm design, implementation, proof construction, and integration.

Scope and interpretation. The retained changes implement reusable compiler optimizations, although their selection and tuning are informed by the evaluation workloads. Inspection of the Astra and DeepSeek candidates found no added conditions that recognize benchmark names, application identities, source filenames, or benchmark inputs. Instead, the optimizations apply through structural and semantic properties, such as function size, static call count, loop structure, instruction dependencies, and the presence of division operations. Some policies are deliberately narrow: Astra’s additional unrolling of division-containing loops combines several size and control-flow restrictions, while DeepSeek’s inlining thresholds reflect performance and compilation costs observed on the benchmarks. These changes can therefore apply to other programs with the same properties, but their measured benefits are not established improvements on unseen workloads.

Both environments permit workload-informed search under a common optimization objective and constraints. The campaigns demonstrate improvements to generated-program performance and integration of verified extensions under these conditions. They characterize what agents achieved in each environment, without establishing unseen-workload gains or isolating the causes of environment differences. Appendix § 15 details the measurement qualifications.

Related Work

Migrating formal developments between proof assistants. Prior work translates proofs between systems of the same logical family. Obua and Skalberg [19] import HOL4 theories into Isabelle/HOL by replaying primitive inferences, Kaliszyk and Krauss [10] make such LCF-style translation scale to large libraries, and OpenTheory [7] defines a shared exchange format for higher-order logic theories. These approaches rely on a close correspondence between the source and target logics. Within Lean, the community ported Mathlib [30] from Lean 3 to Lean 4 with Mathport [14], a semi-automatic translator followed by extensive manual repair. Proof repair tools such as PUMPKIN PATCH [24] and repair across type equivalences [23] adapt proofs to changes in definitions within one proof assistant. In contrast, Rocq and Lean differ in their libraries, automation, and many representation choices, so a syntactic translation does not carry proofs across. Our workflow instead re-derives the development with LLM agents and uses declaration accounting and independent audits to check that translated definitions and statements still match the source.

Porting Rocq developments to Lean. The closest effort to ours is Iris-Lean [4], which ports the Iris separation-logic framework from Rocq to Lean 4 for similar reasons, such as reusing Mathlib. Starting from a proof-mode prototype [12], the port took several years of work by a large group of contributors; LLM agents entered only late, porting one Iris-based development within a few days. Other work automates parts of the translation. Babel-formal [28] uses proof terms as a pivot to help LLMs translate proof scripts between Lean and Rocq, and Viennot et al. [32] use LLMs to translate the miniF2F theorem statements into Rocq. ITPEval [33] benchmarks LLM translation across Lean, Rocq, Isabelle, and HOL Light, and reports that its strongest evaluated model, GPT-5.5, achieves 5.2% proof-translation pass@1 (36 of 696 directed pairs) on the Formalizing 100 Theorems tier drawn from real libraries. These efforts either port a development by hand over years or translate individual files, statements, and proofs. In contrast, CompCert4Lean migrates a complete verified compiler, including its end-to-end correctness theorem, with parallel LLM agents in about six weeks.

LLMs for theorem proving and verified code. Language models have been applied to formal theorem proving since GPT-f [22]. Subsequent systems guide provers with informal proof sketches [8], generate and repair whole proofs [5], retrieve relevant premises in Lean [35], and train on large synthetic proof corpora [34]. Related work generates code together with specifications and proofs, for example in Dafny [29] and Verus [1]. These systems mostly target single theorems or small programs with fixed statements. CompCert4Lean shows agent-driven migration at the scale of a verified compiler: the workflow audits translated statements and coordinates reconstruction of 4,908 interdependent obligations across parallel agents sharing definitions and interfaces.

Conclusion

CompCert4Lean demonstrates large-scale migration of a verified compiler from Rocq to Lean by one expert directing parallel LLM agents over approximately six weeks. Of 1,071 human interactions, 88.8% concerned workflow and coordination, while only three supplied technical direction. The workflow combined dependency-based parallelism, correspondence audits, and proof reconstruction against stable interfaces.

The optimization campaigns demonstrate a practical benefit of the Lean port: under matched budgets, all three models achieved larger small-tests runtime reductions in Lean while retaining the end-to-end correctness theorem. Agents also integrated new verified extensions into the migrated compiler. Together, these results suggest that agent-assisted migration could make other Rocq-based tools available in Lean with manageable human effort, while opening opportunities to build on and extend their verified infrastructure.

AI Use. AI tools powered the research agents described in § 3 and § 4; the optimization experiments are documented in § 5.3. We also used AI tools to assist with editing the paper. The authors take full responsibility for the paper’s content and the research results presented here.

Data-Availability Statement

The CompCert4Lean source code is publicly available at https://github.com/fanlong/compcert4lean.

References

Investigation Gates

Section 3.1 describes the investigation process and the representation gate (Gate 1). This appendix gives the floating-point and memory/injection cases (Gates 2–3), followed by the directly attributable effort for all three gates.

Gate 2: floating-point values and rounding proofs. A direct substitution of Lean’s logical floating-point type would lose source-visible information. Its model canonicalizes NaNs, while CompCert’s binary32 and binary64 values retain NaN signs and payloads. These bits are observable through conversions and memory. The selected x86 policy also specifies which NaN operand supplies the result and how a signaling NaN is quieted. Agreement on ordinary numerical values would therefore leave part of the compiler’s semantics unspecified.

The gate prototype placed a raw-word interface around the pure numerical model. Schematically, its public carriers were:

structure RawFloat64 where
  bits : UInt64
structure RawFloat32 where
  bits : UInt32

For binary arithmetic, the wrapper first handled NaN operands using CompCert’s x86 selection and quieting rules. Otherwise it invoked the pure numerical model and mapped an invalid-operation NaN to CompCert’s specified default. Negation and absolute value operated directly on the sign bit. This gave an exact representation contract: the wrapper word must equal the source value’s to_bits result, including signed zero and every NaN payload. Native floating-point execution was unnecessary for this theorem-bearing feasibility experiment.

The main challenge was the proof interface. CompCert’s short mul2_add lemma, used in optimization proofs, relies on Flocq to show that adding a value to itself agrees with multiplying it by two. Simplifying the corresponding Lean operations reduced the finite case to missing rounding lemmas. We built a reusable layer interpreting a significand–exponent pair as the exact dyadic value m2em 2^{e} and proved that full rounding preserves the identity

round⁡(2m,e)=round⁡(m,e+1).\operatorname{round}(2m,e) = \operatorname{round}(m,e+1).

Unfolding addition and multiplication then reduced both operations to the same rounded value. A checked negative example prevented an unsound generalization: the internal roundWithAccuracy helper can return different representations for (2,100)(2, 100) and (1,101)(1, 101), despite their equal dyadic values, when its exponent precondition is violated. The proof therefore stated that precondition for the helper and established the unconditional law at the full normalization operation.

Subsequent gate work established independent nearest-even specifications, conversions, square-root correctness, and connections to representative memory and compiler consumers. The final independent audit checked a 134-module Lean dependency graph and obtained exact raw-output agreement with pinned CompCert on 54,789 cases across 26 operation/width families. The numerical proofs and the bit-level tests addressed complementary obligations. The architectural decision was to separate the exact public bit contract from the numerical implementation and its reusable proof bridge; the later production translation remained subject to its own correspondence audit.

Gate 3: memory operations and injection preservation. CompCert’s memory model must support both execution and relations between the memories of different compiler stages. A memory injection maps a source block to a target block and an offset. Matching the results of allocation, loads, and stores does not establish that these operations preserve the full injection relation.

The investigation kernel-checked a counterexample to a deliberately weakened relation that required only agreement of mapped cells. Let two distinct source blocks map to the same target cell:

ι(b1)=ι(b2)=(bt,0).\iota(b_1) = \iota(b_2) = (b_t, 0).

Initially, the two source cells and the target cell all contain zero, so the weakened relation holds. Matching stores of one into b1b_1 and btb_t preserve their correspondence but invalidate the relation for the untouched b2b_2. This small example explains the role of CompCert’s non-overlap requirement: it prevents a target update from interfering with another live source location. The counterexample was an adversarial representation probe, rather than a defect attributed to the source compiler.

We chose a source-shaped functional memory view with explicit contents, current and maximum permissions, and the next-block identifier, together with its well-formedness invariants. A raw finite map was insufficient: arbitrary entries need not respect the current/maximum permission invariant or the next-block boundary. An optimized storage representation would need to preserve these invariants and justify its observations against the functional view. We retained all injection clauses, including non-overlap, pointer representability, validity, and inverse permissions, as well as the source rule allowing an undefined memory value to inject into any target value.

Gate completion required general operation-preservation proofs and real external-call cases, including allocation and copying, over a coherent memory model. The initial zero-length-copy proof established only an interface shape and was insufficient for acceptance. The completed gate combined the stronger proofs with 9,029 differential observations across 20 partitions, including 8,192 deterministic operation sequences. This established that the chosen representation supported the relational reasoning needed by compiler simulations, in addition to reproducing individual operations.

Investigation effort and resulting decisions. Table 8 reports directly attributable effort for these three gates. We include the initial focused coinduction and floating-point studies and the development, integration, retry, and audit workers assigned to each gate. Time is accumulated agent runtime, including tools and waiting within a run; parallel workers contribute separately. The shared 30-risk discovery campaign and shared coordination are excluded, so these figures measure gate-specific work building on existing evidence. In particular, Gate 1’s short run reused the preliminary representation studies, and later behavior/world consumer work remained charged to its recorded Gate 3 assignments. The full phase cost appears in Table 3.

GateAgent hoursUncached input (M)Cached input (M)Output (M)Total (M)
1: Representations1.40.937.70.238.7
2: Floating point107.958.43,473.310.33,542.1
3: Memory/injections20.710.8508.02.7521.5

Table 8. Recorded effort directly attributed to Gates 1–3. Time is accumulated agent-hours, not elapsed calendar time. Token counts are in millions, rounded independently; cached input is included in Total, and output includes reasoning. Worker sessions are deduplicated and recorded unsuccessful attempts are included. Six Gate 2 worker sessions have no positive token counters, so usage is not a complete billing measurement. Shared discovery and coordination are excluded.

Review Across Audit Rounds

Section 3.3 describes the iterative audit and repair procedure. This appendix reports the findings across review rounds and the evidence and limitations of the final acceptance decision.

The first global audit exposed defects that translation-time integration had missed. The build root imported none of the translated modules, so the apparent whole-project build compiled only the root. The audit also found 1,091 theorem or generated-fact propositions reduced to True. We restored build aggregation and reconstructed the propositions before relying on subsequent checks. Other findings included missing transition premises, hidden configuration defaults, and mismatched providers. Source review was complemented by differential probes, downstream consumer examples, successful executions, and negative validator tests. These checks supply different kinds of correspondence evidence; finite tests do not establish universal equivalence between the developments.

Figure 4 shows the number of units with critical findings across successive reviews. Across eleven completed broad definition reviews, the count peaked at 104 and fell to one in the last broad round. A targeted recheck of two repaired units then closed the remaining findings. Subsequent inventory reviews continued to expose missing obligations and interface mismatches. The counts include missing correspondence evidence as well as confirmed defects, and the same issue can appear in more than one round.

Units with critical findings across successive definition and proof-inventory reviews

Figure 4. Units with at least one finding classified as critical in successive definition and proof-inventory reviews. The phases use different severity rules; panel (b) numbers completed inventory reviews consecutively from 1 and uses globally reconciled findings, with its round 3 peak dominated by missing authenticated evidence. The InA annotation marks the round of the case discussed in § 3.3; that finding was classified as major. The first definition review covered 167 reporting units and subsequent reviews covered 166; 8/29a and 8/29b distinguish two reviews completed on August 29. Inventory rounds cover 166 units using fresh reviews and, from round 5, unchanged evidence carried forward. Incomplete rounds and targeted rechecks are omitted. Counts can include findings repeated across rounds.

Acceptance at line 20 of Algorithm 1 is the decision to use the reviewed definitions and statements as fixed targets for ordinary proof work. The inventory records their intended Lean types, source correspondence, responsible declarations, and known proof dependencies. Our accepted inventory contained 4,908 targets, including theorem proofs and proof-bearing certificates; 170 were already complete. The remaining duties become inputs to Algorithm 2. A snapshot taken for one audit round can still be repaired in the next round; the definition freeze for proof work begins only with this acceptance decision.

The returned evidence and decision also delimit what acceptance establishes. In our final obligation-inventory round, 25 units lacked an accepted result, and the expert waived the planned complete-cycle and external final-global gates after a bounded repair and targeted recheck. Those gates were not reported as passed. Acceptance records this engineering judgment and its residual risks; it neither discharges the remaining proofs nor establishes mechanized Rocq–Lean equivalence.

Automated Proof Reconstruction and Proof Progress

Section 3.4 describes automatic proof reconstruction. The following milestones record its progress and the subsequent completion of the remaining obligations.

Automated proof reconstruction and proof progress. Table 9 records these milestones in our migration. At the expert-directed stop, the runner recorded 4,267 new completions in addition to the 170 baseline witnesses: 90.1% of the initially unfinished 4,738 targets had been completed. The remaining 471 included 161 targets in integer foundations, 36 in value-domain reasoning, and 23 in memory, as well as compiler-pass proofs. The residual workload therefore called for investigations across shared foundations and their consumers, rather than only the final assembly of large simulations.

MilestoneCompletedUnfinished
Accepted definition baseline1704,738
Automatic runner stopped4,437471
Later transition to simple status ledger4,732176
Final integrated proof baseline4,9080

Table 9. Checked proof-inventory milestones. Counts include the 170 initially complete targets. Automatic and guided work overlapped; these are cumulative milestones, not results from disjoint phases or equal effort budgets. The automatic runner was stopped by the expert with unfinished work still queued.

We simplify coordination when the remaining workload no longer benefits from the automatic campaign’s machinery. After further guided work had raised completion to 4,732 targets, we replaced the campaign ledger with a manually maintained boolean status ledger for the remaining 176 obligations (Table 9). The earlier inventory and execution history were preserved as references, while integration retained the requirements of ValidExtension in Algorithm 2. The simpler ledger changed how work was assigned and tracked; finished status still required checked integration, and definition repairs still required explicit review. This process completed all 4,908 recorded targets, including the supporting certificates, pass simulations, and composed compiler-correctness result.

Localized Floating-Point Repairs

§ 3.5 presents the missing-format-assumptions repair required during human-guided proof finalization. This appendix gives the counterexample, repair, and subsequent proof checks for the other case, a conversion that omitted destination normalization.

A conversion that lost the value one. Four conversion obligations were false under the migrated implementation. A checked witness starts with single-precision 1.0, whose bit pattern is 1,065,353,216. Widening it produced the double-precision bit pattern 8,388,608, and converting that result to an integer returned zero instead of one. The reverse route also failed: converting integer one directly to single precision produced 1.0, whereas converting through double precision and narrowing produced zero. Agents proved the negations of the four affected propositions in Lean, separating a definition defect from a difficult proof.

Both conversion functions unpacked a source-format finite value and passed it directly to the destination format’s packing operation. Although the mantissa and exponent represented the source value, packing required them to be normalized for the destination format. The authorized repair inserted destination normalization before packing, including round-to-nearest-even for narrowing, while retaining the interfaces and the treatment of NaNs, zeros, and infinities. Rechecking the conversion proofs then established the intended propositions. This case shows why successful proofs of surrounding operations cannot replace checking the representation invariants at a format boundary.

Differential Testing Details

This appendix gives the corpus, comparison procedures, detailed outcomes, and limitations underlying § 5.2. The corpus counts records and distinct source sets, whereas the IR outcome table counts distinct source-and-flags programs; per-file stage pairs and specification inputs are separate units of comparison.

Test corpus. The first two levels share one corpus of 22,062 test records (18,999 distinct source sets) from 18 campaigns (Table 10): random programs (Csmith [36] with its default, feature, floating-point, and large profiles, YARPGen [17], and EMI mutants [13]), existing test suites (the GCC torture tests, the LLVM test suite, and the CompCert test suite), handwritten tests of integer, floating-point, ABI, and control-flow semantics, replays of known CompCert bugs, and programs selected to make the two optimizers diverge. We screen for undefined behavior by also compiling every record with GCC and Clang with UBSan and ASan. A record with a sanitizer report is classified as undefined and is not counted as correspondence evidence; the absence of a report does not establish that a program is free of undefined behavior.

SourceRecordsAgreeUBDiffer
Random (Csmith, YARPGen, EMI)10,2898,9974030
Test suites (GCC, LLVM, CompCert)4,1532,579830
Handwritten (semantics, ABI, control, allocator)2,0691,8971620
Bug replays and divergence mining5,5515,0517815
Total22,06218,52458035

Table 10. Corpus by source and selected final output-level outcomes. “Agree”: the four CompCert and CompCert4Lean executables (O0, O2) give the same exit status and output, with sanitizers clean or their run incomplete; this excludes the 362 records that agree with each other but differ from a reference. “UB”: a sanitizer reports undefined behavior. “Differ”: the outputs of the two compilers differ on a program without a sanitizer report. The displayed outcomes are partial: the remaining 2,923 records are classified in the full outcome table (Table 12).

Output-level comparison. Our first comparison is end to end. One deterministic harness compiles each record with both compilers at O0 and O2, with the same flags, compile deadline (600 s), link mode (non-PIE), and runtime library, runs the four executables on the same input, and compares their exit status and complete standard output. This test covers the complete pipeline, including register allocation and the passes after it. However, equal output is weaker evidence than it appears. Because both compilers run the same passes in the same order, a pass that was translated incorrectly but still preserves semantics, for example a CSE that misses some redundancies, does not change the output.

IR-level comparison. To expose such defects, we also compare the RTL program that each compiler produces after each of its nine RTL stages (RTLgen, Tailcall, Inlining, Renumber, Const-prop, Renumber, CSE, Deadcode, Unusedglob). We stop before register allocation, because CompCert4Lean replaces CompCert’s unverified OCaml allocator with its own allocator, which legitimately chooses different registers. The Lean compiler encodes its RTL as JSON, and the bridge decodes it into CompCert’s own OCaml data type. Both sides are then printed by the same printer, an extended version of CompCert’s PrintRTL that prints every field of the program: all global definitions in order, function signatures, parameters, stack sizes, entry points, every instruction with its full call and builtin signatures, external functions, global variables with their initialization data and flags, prog_public, and prog_main. Every floating-point constant is printed as its exact bit pattern. The printer has no wildcard patterns, and OCaml’s exhaustiveness check confirms that it omits no constructor or field. Equality after stage 0 checks the Lean passes from SimplExpr to RTLgen as one block, and equality after each later stage checks one RTL pass. At O0 only stages 0, 3, and 8 change the program, so O0 checks the front end, Renumber, and Unusedglob; at O2 every pass changes most programs (Table 11).

StagePassMutationAllNon-gen.Detected
0RTLgenbranch heuristic > to >=––55/180
1Tailcall–63.923.9–
2Inliningwrong called-once test67.128.470/180
3Renumberreverse postorder numbering94.085.0179/180
4Constpropno condition strength reduction93.075.027/180
5Renumber(as stage 3)87.662.9–
6CSEa store kills all loads84.250.939/180
7Deadcodenever remove dead stores89.064.643/180
8Unusedglobkeep all definitions66.928.072/180
Field mutants (extended printer, 16 programs, O0 and O2)
stack size, signatures, prog_public, prog_main16/16
global init data, volatile flag, definition order14/16
float constant +1 ulp (180 programs, O2)14/180

Table 11. RTL pass activity and mutation detection at O2. “Changed” reports the percentage of 20,572 records producing RTL in both compilers on which the pass changes the program; duplicates are included. “Non-gen.” uses the 4,812 non-randomly-generated records in that set. “Detected” reports detections out of 180 tested programs. The single Renumber miss is a timeout.

One gap remains: the dumps come from the diagnostic driver of CompCert4Lean, not from the proven driver. To narrow this gap, we proved in Lean that the diagnostic driver with a silent sink is equal to the proven driver transf_c_program (theorem transf_c_program_silent, which depends only on propext, Classical.choice, and Quot.sound).

Sensitivity of the IR check. A check that never reports a difference is convincing only if it can report one. To confirm that it can, we built mutants of the Lean passes and of the RTL fields. Each pass mutant changes only a definition, so no proof had to change. Every tested pass mutant was detected on at least one program, and each detection was at the stage of the mutated pass (Table 11). The detection rate per program is lower for mutants that only weaken an optimization (27, 39, and 43 of 180 programs for Constprop, CSE, and Deadcode), and most detections come from Csmith programs. No Tailcall mutant was tested. The field mutants, which change data that the original PrintRTL does not print, are detected on every program that they change.

Pass mutants in Table 11 were evaluated with the original PrintRTL.

Specification-level comparison. The first two levels exercise the specification only through the programs in the corpus. We therefore also test its executable functions directly. We compared 202 executable functions of the Lean specification with the OCaml code that Rocq extracts from CompCert 3.17: the integer operations of Int, Int64, Byte, and Ptrofs; the operations and conversions of Float and Float32; sem_cast on all 576 pairs of types and the unary, binary, and comparison operations of Cop on non-pointer values; encode_val, decode_val, and proj_bytes of Memdata for all 11 memory chunks; and the 15 functions of Values.Val that the extraction keeps. The inputs were generated with a fixed seed and biased to edge values: NaN payloads, signed zeros, infinities, subnormals, rounding ties, and conversion bounds. Two deliberate perturbations, one on each side, were detected.

Reproducibility. All runs use one script per level and fixed seeds. A full rerun of the output-level test assigns the same outcome to 22,029 of the 22,062 records (99.85%). The 33 changes come from timing near a deadline and from transient ETXTBSY errors in the harness; no program output changed. We did not rerun the 18,875 records that agreed in that run with the final harness. Instead, we reran a stratified sample of 2,000 of them with the final compiler and harness: 1,998 agree, and the other 2 agree after a rerun at lower machine load, since their run time is close to their 30 s deadline.

Results: behavior. Table 12 gives the final outcome of every record. The 35 differences in Table 10 exclude the two undefined-behavior cases included in the 37 discrepancies discussed below. Although the two compilers give different results on 37 records, none remains an unexplained port discrepancy. Two have undefined behavior. One is the replay of CompCert issue #579, which uses the reserved identifier __stringlit_1: CompCert 3.17 silently produces wrong output, whereas CompCert4Lean rejects the program. The other is a GCC test on which ASan reports a stack use after return. The remaining 35 records (20 distinct programs), which have no sanitizer report, pass structures by value to an object file compiled by GCC. Both compilers pass structures with CompCert’s own x86-64 convention, which differs from the System V convention that GCC follows, so the GCC-compiled callee reads its argument from locations that the caller did not write, and the output depends on register and stack contents, which differ because the register allocators differ. When the callee is compiled by the same compiler as the caller, all 20 programs agree across CompCert, CompCert4Lean, GCC, and Clang. There is no record that CompCert rejects and CompCert4Lean accepts, and every timeout and every compile failure other than #579 is the same for both compilers.

OutcomeRecords
Agree, sanitizers clean18,489
Agree, sanitizer run incomplete35
Agree with each other, differ from a reference1362
Undefined behavior reported by a sanitizer2580
Run timeout (1,096 both compilers, 1 GCC only)1,097
Rejected by both compilers1,423
Same failure pattern on both sides (e.g. both reject O0 only)40
Rejected by CompCert4Lean only (#579, undefined behavior)1
Different output, struct passing to GCC code (20 programs)35
Rejected by CompCert only0
Total22,062

Table 12. Final output-level outcome of the 22,062 records. Every compile failure and every run timeout of CompCert or CompCert4Lean, except #579, is the same for both compilers at the same level.

Results: identical IR at every stage. The IR-level test gives a stronger result for the passes up to RTL (Table 13). Of the 20,279 distinct programs (by source and flags), 18,808 at O0 and 18,807 at O2 produce RTL on both sides. The complete RTL is identical at all inline stages for every comparable program, including at O2. The comparison runs per C file, and 1,059 of the compared programs have more than one C file (most have two; the largest has 51). The compared programs thus contain 19,938 C files at O0 and 19,937 at O2, which give 179,442 and 179,433 identical stage pairs, the largest dump several megabytes. Another 59 C files, from the 59 programs that are only partially comparable (Table 13), also have identical RTL at all nine stages (531 stage pairs per level). In total, 359,937 per-file stage pairs are identical and none differs. This total overstates the number of independent pass checks: at O0 six of the nine stages do not change the program (see the IR-level comparison above), so we report the result by program in § 5.2. The remaining outcomes provide no complete pair to compare. This is the result that a faithful translation must give: the passes were translated function by function from the Rocq source, with ports of CompCert’s own maps, sets, and integer arithmetic, so any difference would indicate a translation defect.

OutcomeO0O2
Compared, identical at all nine stages18,80818,807
Compared, different at some stage00
Rejected by both compilers1,4111,411
Contains a precompiled object (C units identical)5858
One C file rejected by both, other file identical11
Rejected by CompCert4Lean only (#579, undefined behavior)11
Compile deadline (300 s) exceeded by both01
Total20,27920,279

Table 13. IR-level differential testing of CompCert4Lean against CompCert 3.17 on 20,279 distinct programs. A program is compared when both compilers produce RTL; its complete RTL after each of the nine stages is then compared byte for byte.

Results: specification. On 37,400,000 inputs, all 202 functions give bit-identical results on both sides. For one group of functions, this agreement was not guaranteed by construction. The port defines floating-point addition, subtraction, multiplication, division, and square root with the IEEE 754 model of the Lean core library (Float.Model), not with the Flocq functions that CompCert uses, and we found no theorem in the port that relates the two. Even so, the two implementations agree on every tested input, including the edge values above. For these operations, the test is the only evidence that the Lean specification agrees with CompCert’s. Float32.sqrt is not in the extracted code and was not tested.

Limitations. Despite these results, the tests have five limits. First, they do not execute the Lean semantics (Csem, Asm) as a whole, and they give no evidence about the proofs; a Csem rule that makes too many programs undefined would not change any test result. Second, the C parser and elaborator, the assembly printer, and the assembler are shared code, so no test can expose a defect that the two compilers share there. Third, register allocation and the passes after it (Allocation, Tunneling, Linearize, CleanupLabels, Stacking, Asmgen) are checked only by the output-level test, on inputs that differ from CompCert’s because the allocators differ; Debugvar is not run. Fourth, the IR comparison of the Lean side passes through the JSON codec and a shared printer, and the silent-sink theorem does not cover the recording sink that writes the dumps; that the kk-th dump is the kk-th intermediate program follows from the code of the driver. Fifth, the corpus rarely exercises switch with jump tables, variadic functions, function pointers, setjmp, and inlining of functions with more than one call site.

Detailed Optimization Campaign Results

Table 14 records the retained optimization checkpoints for both compilers. Each entry is the geometric mean of 39 individual O2 time ratios, comprising 29 small-tests programs and ten SPEC inputs, relative to original CompCert 3.17. For compilation, C-to-object times of a program’s translation units are summed before taking its ratio; the program’s ratio is repeated for each of its SPEC inputs. The CompCert4Lean entries combine the archived release-validation CompCert reference times with the measured times at each Lean checkpoint. The CompCert entries use the original 3.17 measurements paired with each candidate in the Rocq campaign. These are measurements from separate campaigns, not a simultaneous paired cross-compiler run. Moreover, the Lean campaign used a repeated 1 MiB input for the three compression programs and problem.dfg for SPASS, whereas the Rocq campaign used the original license input and small_problem.dfg. The compilation figures exclude linking and helper setup. Values below one indicate less time than original CompCert.

Compiler versionChangeO2 program runtimeO2 compilation time
Original CompCert 3.17Baseline1.0001.000
CompCert 3.17 d324ee55Block layout, spill costs0.9931.011
CompCert 3.17 fed9846fSmall-leaf inlining0.9891.011
CompCert 3.17 2b22ad49Small-wrapper inlining0.9771.054
CompCert4Lean 801facbRelease version1.0002.046
CompCert4Lean 3c06641Campaign baseline0.9821.728
CompCert4Lean e691e83Small-leaf inlining0.9711.800
CompCert4Lean edacc68Four-copy loops0.9351.955
CompCert4Lean 3cad2daWider inlining, if-conversion0.9221.961
CompCert4Lean 7057444Acyclic path splitting0.9211.991
CompCert4Lean d70b047Spill reload reuse0.9161.961
CompCert4Lean 28fba67Division loops, reload cache0.9112.011
CompCert4Lean 8dc9f4eNon-leaf inlining0.9021.945
CompCert4Lean 558a647RTL instruction scheduling0.8972.056
CompCert4Lean 742233eLoop-weighted spill costs0.8952.054

Table 14. GPT-6-astra optimization checkpoints relative to original CompCert 3.17. Each numeric entry is the geometric mean of 39 per-workload O2 time ratios (= 1; lower is better). Within each compiler group and column, the best result is in bold and the second best is underlined; reference rows are not ranked.

Table 14. GPT-6-astra optimization checkpoints relative to original CompCert 3.17. Each numeric entry is the geometric mean of 39 per-workload O2 time ratios (= 1; lower is better). Within each compiler group and column, the best result is in bold and the second best is underlined; reference rows are not ranked.

Table 15 reports the best retained versions of both compilers at O2: CompCert 3.17 2b22ad49 and CompCert4Lean 742233e. Each value is a time ratio to original CompCert 3.17, with smaller values indicating less time. The small-tests row is the geometric mean of 29 individual workload ratios. Each SPEC runtime row is the geometric mean of its selected test and train input ratios; the input column gives the number of cases. Each SPEC compilation ratio covers one compiled program. The separate-campaign and small-tests input qualifications stated for Table 14 also apply here.

BenchmarkInputsO2 program runtimeO2 compilation time
RocqLeanRocqLean
CompCert small-tests290.9770.8831.0432.171
LBM20.9980.9671.0251.371
Neutron41.0020.9641.0581.880
TeaLeaf10.9780.8931.0081.686
NAB10.9820.8981.0631.812
Zstd10.8970.8311.0581.502
SQLite10.9250.9051.5522.466

Table 15. O2 performance of GPT-6-astra’s selected candidates relative to original CompCert 3.17 (= 1; lower is better). Rocq denotes optimized CompCert 3.17 (2b22ad49); Lean denotes optimized CompCert4Lean (742233e).

The optimization traces suggest higher effective search throughput as one explanation for the larger Lean gains. Within the evaluation windows—the first 24 active hours in both environments—GPT-6-astra produces 106 candidate variants in Lean versus 40 in Rocq that complete full compiler and proof builds, a 2.65× difference. We count each development worktree with at least one successful full build once; these counts include related parameter variants and combinations, than only candidates selected for their performance. Recorded model usage is broadly comparable: 453.79 million total tokens for Lean versus 498.12 million for Rocq, including cached input, and 2.51 million versus 2.30 million output tokens, including reasoning. The higher realized throughput gives the agent more opportunities to evaluate, combine, and refine optimization candidates within the available time.

This result suggests greater practical capability of GPT-6-astra for developing compilable optimizations in the Lean environment and offers a plausible mechanism for its larger performance improvements. Completing a full build is an intermediate milestone: both campaigns also contain candidates that pass verification but do not improve measured performance. Moreover, candidate variants can reuse existing proofs, and their number does not measure independent optimization ideas or proof difficulty. With one campaign per environment, the comparison does not isolate language-specific model capability from differences in proof-library support, repository architecture, build infrastructure, or search choices. The evidence therefore supports an advantage in the observed optimization process, while leaving the contributions of these factors unresolved.

DeepSeek 4.1 Flash did not fully follow the campaign prompts. Both runs continued after encountering prior optimization metadata, despite an explicit instruction to stop for review. Their reported performance also used different evaluation procedures: the Lean aggregate omitted one of the 29 small workloads and used a different SPEC profile, while the Rocq report emphasized SPEC test inputs measured with custom sampling. We therefore remeasure every retained revision on the final-candidate lineages using the GPT-6-astra evaluation protocol. Table 16 and Table 17 use the same 29 small workloads and ten SPEC inputs, sampling procedure, normalization, and workload weighting as Table 14 and Table 15. The separate-campaign and small-tests input qualifications stated there still apply. This reevaluation makes the measurements more comparable, but cannot establish that the original optimization searches were independent.

Table 16. DeepSeek 4.1 Flash optimization checkpoints, remeasured with the GPT-6-astra protocol. O2 time ratios use original CompCert 3.17 as the baseline (= 1; lower is better). Each entry is the geometric mean over 39 workloads: 29 small-tests programs and ten SPEC inputs. Within each compiler group and column, bold marks the best value and underlining the second best; ties share a rank and reference rows are not ranked. Dashes indicate unavailable aggregates because the block-layout checkpoint fails SQLite compilation.

Compiler versionChangeO2 program runtimeO2 compilation time
Original CompCert 3.17Baseline1.0001.000
CompCert 3.17 7074c50bSmall-static inlining0.9981.021
CompCert 3.17 5f9087d3Wider small-static inlining0.9911.058
CompCert 3.17 aeb08ee0Called-once size bound0.9901.042
CompCert 3.17 c21ae16aLoop-weighted spill costs0.9901.059
CompCert 3.17 6601adf5Spill-cost divisor refinement0.9881.055
CompCert4Lean 3c06641Campaign baseline0.9681.790
CompCert4Lean 671e092Block layout––
CompCert4Lean b558b5eBlock-layout fuel fix0.9681.821
CompCert4Lean 44fd799Budgeted static-leaf inlining0.9581.784
CompCert4Lean 97940a8Budgeted non-leaf inlining0.9641.808
CompCert4Lean 5137462Called-once size bound0.9621.747
CompCert4Lean 50d2c89Larger inlining budget0.9631.785
CompCert4Lean 004762bPublic-function inlining0.9401.866

Table 16.

Table 17. O2 performance of the best passing DeepSeek 4.1 Flash revisions under the GPT-6-astra evaluation protocol, relative to original CompCert 3.17 (= 1; lower is better). Rocq denotes CompCert 3.17 6601adf5; Lean denotes CompCert4Lean 004762b. Runtime rows are geometric means of per-input median time ratios; each SPEC compilation ratio covers one compiled program. The normalization and small-tests input qualifications of Table 15 also apply here.

BenchmarkInputsO2 program runtimeO2 compilation time
RocqLeanRocqLean
CompCert small-tests290.9920.9501.0441.964
LBM21.0000.9741.0911.293
Neutron41.0030.9021.0121.708
TeaLeaf10.9870.9251.0051.583
NAB10.9930.9651.0281.523
Zstd10.8630.8110.9981.369
SQLite10.9280.8671.7812.495

Table 17.

The DeepSeek search inventory in the first 24 active hours contains 48 successfully built Lean optimization worktrees and 76 named Rocq compiler snapshots (72 distinct binaries); Lean reaches 57 including its later continuation. Baselines and one diagnostic-only Lean worktree are excluded. These counts differ from Astra’s full compiler/proof-build metric: most Lean builds targeted only the compiler, with full builds recorded for two Lean worktrees (three with the continuation), while Rocq reused one development worktree. Compilation sums translation-unit medians, excluding linking. The block-layout checkpoint 671e092 fails SQLite compilation at the block-layout validator.

Table 18 reports repeated measurements of Kimi K3.1’s retained checkpoints. Every row covers all 29 small programs and ten SPEC inputs, using the median of seven wall-time samples after warmup. Compilation sums three-sample median C-to-object times across translation units and repeats each SPEC program’s ratio for its input count. All executions pass their output checks. Compiler order rotates each round on one CPU. Intermediate checkpoints share a freshly measured original-CompCert reference; the selected final revisions use the earlier selected-candidate measurement batch. The Neutron repetitions were paused and resumed with unchanged binaries and inputs, retaining completed samples. Timing noise and the separate measurement batches limit comparisons of small differences between checkpoints.

Compiler versionChangeO2 program runtimeO2 compilation time
Original CompCert 3.17Baseline1.0001.000
CompCert 3.17 180e1bdd24-node multi-call inlining0.9911.041
CompCert 3.17 f5ba998632-node multi-call inlining0.9911.058
CompCert 3.17 b530f8daSmall leaves (selected)0.9901.051
CompCert4Lean 3c06641Campaign baseline1.0041.964
CompCert4Lean 29c6506256-node static leaves0.9942.001
CompCert4Lean 157b44b8-node static non-leaves0.9912.004
CompCert4Lean 4da16e9176-node static leaf budget0.9912.009
CompCert4Lean 2c791a5External single-call leaves0.9922.005
CompCert4Lean 0d5a120Nine-case jump tables0.9892.006
CompCert4Lean 65c4f348-node external non-leaves0.9902.010
CompCert4Lean 33ce3a312-node external non-leaves0.9912.012
CompCert4Lean 681039420-cost if-conversion0.9902.001
CompCert4Lean 93dd165Balanced if-conversion (selected)0.9792.001

Table 18. Repeated O2 measurements of Kimi K3.1’s retained checkpoints, relative to original CompCert 3.17 (= 1; lower is better). Each entry is the geometric mean of 39 per-workload ratios using seven runtime samples and three compilation samples. The selected final rows use the same measurements as Table 19.

The nine-case jump-table threshold is later reverted to seven cases; 65c4f34 and subsequent checkpoints use seven. Restorations and empty measurement commits with identical compiler sources are not separate rows.

Table 19 reports the retained Kimi K3.1 candidates: CompCert 3.17 b530f8da and CompCert4Lean 93dd165. Both extend inlining heuristics; the Lean candidate also adjusts if-conversion costs. They reuse existing correctness proofs and introduce no new verified pass. The completed Rocq crash-gap compensation run retained the same selected implementation.

BenchmarkInputsO2 program runtimeO2 program runtimeO2 compilation timeO2 compilation time
RocqLeanRocqLean
CompCert small-tests290.9940.9771.0312.068
LBM21.0001.0131.0271.356
Neutron40.9991.0031.0041.935
TeaLeaf11.0021.0011.0032.030
NAB11.0000.9991.0821.738
Zstd10.8790.8771.1511.605
SQLite10.9450.9422.1992.708

Table 19. Remeasured O2 performance of Kimi K3.1’s selected candidates, relative to original CompCert 3.17 (= 1; lower is better). Rocq denotes b530f8da; Lean denotes 93dd165. Runtime rows are geometric means of per-input median wall-time ratios. Both compilers use identical inputs and the same freshly measured reference. Each SPEC compilation ratio covers one compiled program.

We remeasure both selected compilers and original CompCert 3.17 on all 29 small programs and ten SPEC inputs. All three compilers use identical sources, inputs, and output checks, including the repeated 1 MiB compression input and problem.dfg for SPASS. Each workload has one warmup and seven wall-time samples on one CPU; compiler order rotates each round. Compilation uses three samples per translation unit. The shared reference is measured in the same rounds, rather than taken from the archived release measurements used for the earlier Lean campaigns. All timed executions pass their output checks. These measurements replace the incomplete campaign records and their different timing metrics.

Compilation sums the three-sample median C-to-object times of each translation unit, excluding linking and helper setup. Repeating each SPEC program’s compilation ratio for its input count gives the 39-workload ratios 1.051 and 2.001 in Table 7. For the selected candidates, omitting any one runtime round changes each small-test, SPEC, or combined aggregate by less than 0.1% relative to the reported value. Omitting one of the three compilation rounds changes the compilation aggregate by up to 4.3%. These checks describe sensitivity to the retained samples; they do not establish confidence intervals. The retained search records contain 33 named Rocq experiments and 101 Lean experimental revisions reaching a passing 139-case O2 suite. Controls and final rechecks are excluded. These counts describe a different milestone from Astra’s full compiler/proof-build counts; they count experiments with suite summaries retained in the inspected inventory.

For Table 7, Astra and DeepSeek SPEC aggregates are reconstructed from rounded per-program ratios, weighted by input count; Kimi uses unrounded input ratios. Compilation is the geometric mean over the same 39 workloads, repeating each SPEC program’s compilation ratio for its inputs.

Recorded Human Interactions

This appendix supports § 4.1 with the scope of the recorded-message analysis and the full classification in Table 20, followed by the three technical-direction cases. We use the finalized version 1.6 classification. Technical direction denotes a supplied technical proposal, not necessarily a correct diagnosis, a successful repair, or an override of an agent recommendation.

FunctionWorkflowTechnical review / discussionHuman technical directionTotal
Information & discussion387700457
Advance plan326390365
Establish/change plan23883249
Total95111731,071

Table 20. Recorded human interactions during migration. Each of 1,071 substantive messages from 211 sessions occupies one cell. Counts are messages, not tokens; row and column totals include all substantive messages.

Corpus and classification. The analysis covers all 1,071 substantive human messages exchanged across 211 sessions during development from August 11 through RC1, the rc-0.0.1 release on September 24, 2026. Excluding 22 acknowledgments and greetings from the 1,093 human messages leaves the 1,071 substantive messages classified here. Machine-generated or replayed content is not counted as human messages. Pre-release compiler validation and execution-time work are included; subsequent optimization experiments, manuscript editing, and maintenance are outside the development scope. Each message has equal weight, regardless of length. An authored request accompanying a copied agent plan counts once without attributing the copied technical ideas to the human.

Three agents classified disjoint batches using a shared codebook and calibration set, followed by additional review and coordinator adjudication. Subsequent owner clarifications and review established the final workflow boundary and the precedence rules below. A file assignment, proof-obligation assignment, or branch/commit instruction alone is workflow, even when the assigned work is technical. Questions about semantics, proof validity, or algorithms are technical review/discussion; a supplied substantive technical alternative is technical direction. The precedence rules place each message in exactly one cell and do not rank expertise or importance. The finalized corpus contains no unresolved primary categories.

Each message is classified by function as well as role. Information and discussion seeks or exchanges information; advancing a plan directs work within an existing plan; establishing or changing a plan sets or revises the plan. Both dimensions are hierarchical and mutually exclusive. For function, establishing or changing a plan takes precedence over advancing it, which takes precedence over information and discussion. For role, human technical direction takes precedence over technical review and discussion, which takes precedence over workflow. A concrete implementation alternative therefore counts as technical direction even when motivated by keeping work moving. Table 20 reports all nine combinations and their totals; Figure 3 aggregates the columns.

The 117 review/discussion messages are not all approvals. Across the 120 messages assigned to either technical role, the records contain 45 explicit approvals and 77 inquiry/discussion/investigation incidences, with four messages in both subcategories; one technical-direction message also contains an inquiry. The three direction messages comprise two contributions and one confirmed override. These overlapping subcounts do not partition the review column.

Tentative proposition repair. During definition review, an agent identified propositions replaced by True and explained that the exact source statements needed to be restored. The human proposed dependency-ordered repair across twelve modules and tentatively suggested replacing the trivial propositions with sorry. The agent corrected this suggestion: workers should reconstruct the exact propositions and leave their proofs absent, rather than admit arbitrary proposition definitions. It then developed the dependency plan, which the human authorized. The finalized classification counts the concrete substitution suggestion as a technical contribution, while dependency scheduling is workflow. This records a tentative proposal corrected by the agent, not an independently supplied human diagnosis or the successful repair strategy.

Conditional allocator fallback. While planning a runnable prototype, the agent recommended reusing and repairing the existing spill allocator. The human added a conditional alternative: switch to CompCert’s allocator if repairing the prototype proved difficult, so that allocation would not block end-to-end testing within the existing verification boundary. This permitted the original prototype-first approach and is classified as a contribution, not an override. The agent supplied the concrete bridge design, a one-attempt, 30-minute repair bound, and a fallback to upstream OCaml allocation whose proposals would pass through the existing Lean validator. The retained completion report states that three smoke tests passed after one local repair and the spill allocator remained the default; it does not report using the fallback.

Change toward a CompCert-style allocator. In a later investigation in the same allocator-development episode, an agent recommended local repairs to builtin-specific placement in the prototype and additional pre-expansion checks. In an explicitly linked follow-up session, the human instead proposed implementing an allocator matching CompCert’s approach and asked about its correctness boundary. This is the one confirmed override in the finalized classification: the record connects the earlier recommendation to the subsequent contrary direction. The agent explained the upstream allocation stages and the existing RTL-to-LTL validator, and the human authorized implementation. The allocation algorithm, bridge details, and validation explanation were supplied by the agent, not by the human’s directional proposal. A later agent report records a Lean-native iterated-register-coalescing allocator with iterative spilling and x86 placement checks, with all 139 applicable tests passing. These are the retained completion reports, not independent rechecks performed by the message analysis; the record establishes a change of approach, not its necessity or superiority.

Interpretation. Classification review provides agent-based consistency checking with owner adjudication. Message shares measure neither human working hours nor reading, offline reasoning, expertise, or causal importance. Even a rare direction may be consequential. The separate prompt-token total in § 4.1 is not the denominator of this analysis.

References

  1. [1]Pranjal Aggarwal, Bryan Parno, and Sean Welleck. 2025. AlphaVerus: Bootstrapping formally verified code generation through self-improving translation and refinement. In Proceedings of the 42nd International Conference on Machine Learning (ICML) (Proceedings of Machine Learning Research, Vol. 267). 587–615.arxiv.org/abs/2412.06176
  2. [2]Andrew W Appel, Robert Dockins, Aquinas Hobor, Lennart Beringer, Josiah Dodds, Gordon Stewart, Sandrine Blazy, and Xavier Leroy. 2014. Program logics for certified compilers. Cambridge University Press, Cambridge.DOI
  3. [3]Sylvie Boldo and Guillaume Melquiond. 2011. Flocq: A unified library for proving floating-point algorithms in Coq. In 2011 IEEE 20th Symposium on Computer Arithmetic. IEEE, 243–252.DOI
  4. [4]Markus de Medeiros, Sergei Stepanenko, Zongyuan Liu, Oliver Soeser, Fernando Leal, Alvin Tang, Max Vistrup, Ralf Jung, Mario Carneiro, Joseph Tassarotti, et al. 2026. Iris in Lean. arXiv preprint arXiv:2609.24252 (2026).
  5. [5]Emily First, Markus N Rabe, Talia Ringer, and Yuriy Brun. 2023. Baldur: Whole-proof generation and repair with large language models. In Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 1229–1241.arxiv.org/abs/2303.04910
  6. [6]Ronghui Gu, Zhong Shao, Hao Chen, Xiongnan Newman Wu, Jieung Kim, Vilhelm Sjöberg, and David Costanzo. 2016. CertiKOS: An extensible architecture for building certified concurrent OS kernels. In 12th USENIX Symposium on Operating Systems Design and Implementation (OSDI 16). 653–669.DOI
  7. [7]Joe Hurd. 2011. The OpenTheory standard theory library. In NASA Formal Methods Symposium. Springer, 177–191.DOI
  8. [8]Albert Q Jiang, Sean Welleck, Jin Peng Zhou, Wenda Li, Jiacheng Liu, Mateja Jamnik, Timothée Lacroix, Yuhuai Wu, and Guillaume Lampe. 2023. Draft, sketch, and prove: Guiding formal theorem provers with informal proofs. In The Eleventh International Conference on Learning Representations (ICLR).
  9. [9]Jacques-Henri Jourdan, Vincent Laporte, Sandrine Blazy, Xavier Leroy, and David Pichardie. 2015. A formally-verified C static analyzer. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 247–259.
  10. [10]Cezary Kalyszak and Alexander Krauss. 2013. Scalable LCF-style proof translation. In International Conference on Interactive Theorem Proving. Springer, 51–66.
  11. [11]Jérémie Koenig and Zhong Shao. 2021. CompCertO: Compiling certified open C components. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation. 1095–1109.DOI
  12. [12]Lars König. 2022. An improved interface for interactive proofs in separation logic. Master’s thesis. Karlsruher Institut für Technologie (KIT). doi:10.5445/IR/1000153230DOI
  13. [13]Vu Le, Mehrdad Afshari, and Edward Jung. 2014. Compiler validation via equivalence modulo inputs. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation. 216–226.
  14. [14]Lean Community. 2023. Mathport: A Tool for Porting Lean 3 Projects to Lean 4. https://github.com/leanprover-community/mathport.
  15. [15]Xavier Leroy. 2009. Formal verification of a realistic compiler. Commun. ACM 52, 7 (2009), 107–115.DOI
  16. [16]Xavier Leroy. 2009. A formally verified compiler back-end. Journal of Automated Reasoning 43, 4 (2009), 363–446.DOI
  17. [17]Vsevolod Livshitskiy, Dmitry Babokin, and John Regehr. 2020. Random testing for C and C++ compilers with YARPGen. Proceedings of the ACM on Programming Languages 4, OOPSLA (2020), 1–25.DOI
  18. [18]Leonardo de Moura and Sebastian Ullrich. 2021. The Lean 4 theorem prover and programming language. In International Conference on Automated Deduction (CADE). Springer, 625–635.DOI
  19. [19]Steven Obua and Sebastian Skalberg. 2006. Importing HOL into Isabelle/HOL. In International Joint Conference on Automated Reasoning. Springer, 298–302.DOI
  20. [20]OpenAI. 2026. Sharing AI Progress in Mathematics. https://openai.com/index/sharing-ai-progress-in-mathematics/. Released October 6, 2026. Manuscript collection and proof artifacts: https://github.com/openai/math. Accessed 2026-11-06.
  21. [21]OpenAI. 2026. The Quasi-Riemann Hypothesis: A Zero-Free Half-Plane Re(s) > 7/8. OpenAI Math Release preprint OAI:The-Quasi-Riemann-Hypothesis-September-30-2026.
  22. [22]Stanislav Polu and Ilya Sutskever. 2020. Generative language modeling for automated theorem proving. arXiv preprint arXiv:2009.03393 (2020).arxiv.org/abs/2009.03393
  23. [23]Talia Ringer, RanDair Porter, Nathaniel Yazdani, John Leo, and Dan Grossman. 2021. Proof repair across type equivalences. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation. 112–127.DOI
  24. [24]Talia Ringer, Nathaniel Yazdani, John Leo, and Dan Grossman. 2018. Adapting proof automation to adapt proofs. In Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs. 115–129.
  25. [25]Jaroslav Ševčík, Viktor Vafeiadis, Francesco Zappa Nardelli, Suresh Jagannathan, and Peter Sewell. 2013. CompCertTSO: A verified compiler for relaxed-memory concurrency. Journal of the ACM (JACM) 60, 3 (2013), 1–50.DOI
  26. [26]Youngju Song, Minki Cho, Dongjoo Kim, Yonghyun Kim, Jeehoon Kang, and Chung-Kil Hur. 2020. CompCertM: CompCert with C-assembly linking and lightweight modular verification. Proceedings of the ACM on Programming Languages 4, POPL (2020), 1–31.DOI
  27. [27]Gordon Stewart, Lennart Beringer, Santiago Cuellar, and Andrew W Appel. 2015. Compositional CompCert. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 275–287.
  28. [28]Théo Stoskopf, Cyril Chen, and Nicolas Tabareau. 2025. Babel-formal: Translation of proofs between Lean and Rocq. In The 5th Workshop on Mathematical Reasoning and AI at NeurIPS 2025.
  29. [29]Chuyue Sun, Ying Sheng, Oded Padon, and Clark Barrett. 2024. Clover: Closed-loop verifiable code generation. In International Symposium on AI Verification. Springer, 134–155.arxiv.org/abs/2310.17807
  30. [30]The mathlib Community. 2020. The Lean Mathematical Library. In Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2020). ACM, New Orleans, LA, USA, 367–381. doi:10.1145/3372885.3373824DOI
  31. [31]The Rocq Development Team. 2025. The Rocq Prover. doi:10.5281/zenodo.15149629DOI
  32. [32]Jules Viennot, Guillaume Baudart, Emilie Jesuis Galleorgias, and Marc Lelarge. 2025. MiniF2F in Rocq: Automatic Translation Between Proof Assistants – A Case Study. arXiv preprint arXiv:2503.04763 (2025).arxiv.org/abs/2503.04763
  33. [33]Jiayi Wu, Robert Joseph George, and Anima Anandkumar. 2026. ITPEval: Benchmarking Formal Translation Across Interactive Theorem Provers. arXiv preprint arXiv:2607.19407 (2026).arxiv.org/abs/2607.19407
  34. [34]Huajian Xin, Daya Guo, Zhihong Shao, Zhizhou Ren, Qihao Zhu, Bo Liu, Chong Ruan, Wenda Li, and Xiaodan Liang. 2024. DeepSeek-Prover: Advancing theorem proving in LLMs through large-scale synthetic data. arXiv preprint arXiv:2405.14333 (2024).arxiv.org/abs/2405.14333
  35. [35]Kaiyu Yang, Aidan Swope, Alex Gu, Rahul Chalamala, Peiyang Song, Shixing Yu, Saad Godil, Ryan J Prenger, and Animashree Anandkumar. 2023. LeanDojo: Theorem proving with retrieval-augmented language models. Advances in Neural Information Processing Systems 36 (2023), 21573–21612.arxiv.org/abs/2306.15626
  36. [36]Xuejun Yang, Yang Chen, Eric Eide, and John Regehr. 2011. Finding and understanding bugs in C compilers. In Proceedings of the 32nd ACM SIGPLAN conference on Programming language design and implementation. 283–294.

Paper details

vlnc:W_wvpnry7r
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

LLM agents

View statement
Looking for related papers…
Contents