TL;DR for operators

When an automated checker rejects an AI-generated step, generating another candidate is not the only response. The error message may contain enough information to correct the rejected step.

A study of compiler-guided repair in Lean 41 finds that:

  • Repair increases completed proofs. With up to three repairs, theorem-solving coverage improves by 2.3–4.1 percentage points across four initial candidate budgets on 1,990 LeanDojo theorems.
  • The first repair does most of the work. One correction attempt captures 84–96% of the cumulative net gain achieved with three.
  • Higher coverage comes with latency. At the largest candidate budget, three repairs increase mean runtime from 200.5 to 485.7 seconds. Matched-runtime comparisons generally favor one repair, but tight deadlines can reverse the advantage.
  • Failure type matters. One repair corrects 14.6% of no-progress/simplification failures but only 1.8% of type mismatches.

For teams building systems that generate machine-checkable outputs, the practical hypothesis is to try one targeted correction when diagnostics are actionable, then measure whether additional repair is preferable to regeneration or broader replanning.

A failed step can carry information worth keeping

An AI system generates a candidate, submits it to a checker, and receives a rejection. The straightforward response is to discard the candidate and request another. That approach makes sense when the rejection provides little information, but it may waste a promising partial solution when the checker identifies a specific error.

The distinction matters when each additional generation or correction consumes time and computational resources. A system might complete more tasks by correcting some failures, yet miss deadlines because its correction process is too expensive.

Fix, Not Just Resample: Bounded Compiler-Guided Repair in Lean 4 examines this allocation problem in automated mathematical proof search. The research asks whether compiler diagnostics can recover rejected proof steps efficiently enough to improve completed proofs, rather than simply increasing the number of generated alternatives.

Lean 4 checks formal mathematical proofs. A neural theorem prover generates tactics: individual proof steps that either advance the current proof state or fail with diagnostic information.

In the evaluated system, a ReProver-style generator proposes $K$ candidate tactics at each state. The conventional search discards unsuccessful candidates and continues exploring other possibilities.

The modified search introduces a correction operation. When a tactic fails, a pretrained 4-billion-parameter repair model receives three inputs: the current proof state, the rejected tactic, and the verbatim Lean compiler diagnostic. It proposes corrected Lean code, which is executed from the original failing state. Accepted corrections create new successor states for the continuing best-first search.

The parameter $R$ limits the number of sequential repairs for each original candidate. Consequently, tactic evaluations per expanded state satisfy:

$$ N_{\mathrm{tactic\ attempts\ per\ state}}\leq K(1+R) $$

This is a bound on tactic evaluations, not an equal-cost compute budget: invoking the repair model can be substantially more expensive than generating an initial tactic.

The integration requires no additional training, although the repair model itself was previously trained. The experiments use deterministic beam search for generation and greedy repair decoding, rather than stochastic sampling.

The architectural change is that a rejected candidate can lead to a new search state through diagnosis-conditioned correction, without restarting the entire proof.

Most of the improvement comes from one correction

The primary experiment evaluates 1,990 common LeanDojo theorems, testing $K\in{1,3,5,8}$ and $R\in{0,1,2,3}$. Here, $R=0$ means generation without repair.

The study reports Pass@1: the percentage of theorems completed in one configured proof-search run within its resource limits. It does not measure the correctness of a single tactic.

At $K=5$, no repair solves 29.9% of theorems. One repair increases coverage to 33.5%, while three reach 34.0%. The three-repair configuration gains 83 proofs unavailable to the baseline but loses one baseline success, yielding 82 net additional solves.

The diminishing returns become especially clear at $K=8$.

Repair depth at $K=8$ Pass@1 Net additional proofs Mean runtime
$R=0$ 34.8% 0 200.5 s
$R=1$ 38.7% +77 367.3 s
$R=3$ 38.8% +80 485.7 s

Source: Section 6, Table 1. Net recovery subtracts previously successful baseline proofs lost under repair. Each row uses the same 1,990 theorems.

One repair delivers 77 net additional proofs; allowing two further repairs increases that total by only three. Across all four candidate budgets, the first attempt accounts for approximately 84–96% of the cumulative three-repair benefit.

The result favors evaluating shallow repair before allocating substantial compute to deeper correction. It does not make a second repair universally unproductive: at $K=1$, adding the second attempt recovers seven additional net proofs.

The paired theorem-level improvements for one repair are statistically significant across all tested $K$ values, with reported exact McNemar $p$-values below $10^{-11}$. Those tests establish reliable differences in the evaluated configurations, not an optimal retry policy for every deployment.

This also extends the issue raised in Cognaptus’s earlier discussion, Skeletons in the Proof Closet: a stalled search may benefit from information that changes the next candidate, rather than another proposal drawn from the same generator.

More completed proofs do not mean faster execution

The coverage comparison alone cannot establish repair’s computational efficiency because configurations with additional repair attempts generally run longer.

At $K=8$, mean runtime increases from 200.5 seconds without repair to 367.3 seconds with one repair and 485.7 seconds with three. The last configuration takes approximately 2.4 times as long as its no-repair baseline.

The study therefore also measures completed-proof coverage under matched per-theorem wall-clock budgets (Section 6, Figure 4). With $K=8$, one repair leads by approximately 0.6 percentage points at a 100-second budget and 2.8 points at 600 seconds.

This matched-runtime comparison supports a genuine coverage advantage for repair over much of the measured range, rather than merely rewarding a configuration for consuming more compute. However, very tight budgets, including a reported region around 50 seconds, can favor generation without repair.

Repair can also displace proofs the baseline would have completed before the timeout. At $K=8$, one repair recovers 83 previously unsolved theorems but loses six baseline successes.

An inference policy therefore needs to account for recovered successes, lost successes, and deadline performance together. The preferred configuration depends on the permitted response time, not solely on its eventual solving rate.

Compiler errors differ sharply in repairability

The failure-category analysis explains why targeted repair has limits.

In the $K=8$, $R=1$ experiment, the system attempts to repair 89,634 rejected generator tactics. It converts 5,543 into valid successor states, an overall 6.2% tactic-level correction rate.

The rates vary considerably by compiler error:

Compiler failure category Successful corrections
No progress / simplification 14.6%
Apply / exact failed 13.2%
Reflexivity failed 11.0%
Unknown identifier 5.4%
Type mismatch 1.8%
Unsolved goals / timeout 0.8%

Source: Section 6.2, Table 4. Percentages describe rejected tactics successfully corrected by one attempt, not completed theorem proofs.

Errors involving local tactic execution are substantially more amenable to repair than failures suggesting deeper structural problems. A compiler diagnostic can help identify a faulty operation, but it does not necessarily supply the missing mathematical strategy.

The 6.2% figure also should not be mistaken for theorem-level accuracy. Correcting a tactic may advance the search without completing the theorem.

The separate Lean Workbook evaluation provides a generalization check rather than another error-category experiment. With a retrieval-free generator and $K=5$, validation Pass@1 rises from 21.4% without repair to 42.9% with two repairs. On 89 held-out test theorems, it increases from 19.1% to 31.5%. Neither split shows baseline-proof regressions.

These results strengthen the evidence that the benefit is not confined to the primary LeanDojo configuration, although the second benchmark is smaller and evaluates only one initial candidate budget.

What an operator can test, and what remains unproven

Cognaptus inference: For teams developing AI coding assistants or machine-verifiable generation pipelines, the study suggests testing a diagnostic-aware correction policy rather than uniformly retrying failed outputs.

Where a checker returns precise, localized errors, a system could route likely execution-level failures to one bounded repair attempt. Structural failures, repeated unsuccessful corrections, or approaching deadlines could instead trigger fresh generation or broader replanning. This is an application hypothesis, not an evaluated policy from the paper.

Such a test should compare identical tasks and fixed wall-clock limits while recording completed tasks, recovered successes, regressions, repair rates by error category, and latency. An aggregate success rate alone would conceal whether correction improves task coverage at an acceptable cost.

Several boundaries remain material. The main study uses one tactic generator, one pretrained repair model, deterministic decoding, and a particular hardware configuration. Its error distribution and runtime trade-offs may not persist with different models or workloads. It also evaluates Lean 4 proofs, not general software debugging, other proof assistants, or production business agents.

The evidence supports local correction when a formal checker supplies actionable feedback. It does not establish that every rejected AI output is economically worth repairing.

The operational conclusion: budget correction, then measure it

The paper’s strongest finding is not simply that failed proof steps can be repaired. It shows that incorporating compiler feedback into an ongoing search recovers additional completed proofs, with most of the measured benefit arriving from the first correction attempt.

The corresponding design question for a verifier-backed AI system is how to allocate a limited inference budget among another candidate, a targeted fix, and a broader restart.

A single bounded repair is a defensible starting configuration to benchmark. Whether it belongs in production depends on the distribution of errors, the cost of the repair model, the resulting task coverage, and the deadlines the system must meet.


Cognaptus: Automate the Present, Incubate the Future.


  1. Haotian Deng and Chris Farber and Sonal Narasimha and Samskrithi Sivakumar and Yexiang Xue (2026). Fix, Not Just Resample: Bounded Compiler-Guided Repair in Lean 4. arXiv:2610.26942. https://arxiv.org/abs/2610.26942 ↩︎