Fix, Not Just Resample: Bounded Compiler-Guided Repair in Lean 4
- Source
- arxiv.org
- Author
- Haotian Deng, Chris Farber, Sonal Narasimha, Samskrithi Sivakumar, Yexiang Xue
- Date

Context
When a proposes a proof step in the Lean proof assistant and the step fails, Lean says exactly why. Sampling-based provers such as LeanDojo's ReProver discard that message and propose another step. This paper instead sends the failed tactic, the proof and the error message to a separate repair model that tries to fix the step in place. The search samples K candidate tactics at each step and allows at most R repairs of a failed one, so R of zero is the ordinary sampling baseline. Per the full paper, the step generator is ReProver and the repair model is an existing 4-billion-parameter model from earlier APRIL work, used without extra .
On a 1,990-theorem subset of the LeanDojo benchmark, repair improved the solve rate at every budget tested. With one candidate per step it went from 7.1% to 9.4%, the 32% relative gain the abstract cites; with five candidates it went from 29.9% to 34.0%, the 82 additional theorems in the headline. The payoff is front-loaded: the first repair attempt delivered 84 to 96% of the total gain. On the separate Lean Workbook benchmark, run with a weaker generator that had no premise , two repairs roughly doubled the solve rate on the validation split, from 21.4% to 42.9%, and raised the held-out test split from 19.1% to 31.5%, with no theorem lost that the baseline had solved.
The authors frame the cost as predictable rather than free. Mean time per theorem rose modestly with one candidate, from about 30 to 33 seconds, but at eight candidates it went from about 200 to 486 seconds, and there the second and third repairs added far fewer solves per extra second than the first. When every theorem was given the same time limit, one repair still solved more theorems at nearly every limit tested; the exception was a tight budget of about 50 seconds, where repair's overhead pushed some solves past the deadline. Repair mostly fixes shallow failures, such as a tactic that makes no progress or an apply or rfl that fails, and rarely rescues structural errors like type mismatches. The authors conclude that repair pays most when sampling is constrained.
- Instead of discarding a Lean tactic the compiler rejects, the method feeds the error message to a repair model and fixes that step in place, with at most R repair attempts per step on top of K sampled candidates.
- The authors report up to a 32% relative solve-rate gain over sampling alone and 82 extra theorems on a 1,990-theorem LeanDojo subset, with gains largest when the sampling budget is small. Repair costs extra runtime.
- The first repair attempt captured 84-96% of the total gain, and nearly all of it came from shallow tactic-execution failures rather than structural errors such as type mismatches. On Lean Workbook the approach nearly doubled the solve rate with zero regressions.
- Large language model — A model trained on large amounts of data to process and generate language.
- State — Information describing a system at a particular moment, such as its current text, settings or saved records.
- Training — The process that adjusts a model using examples and a measure of how well it performs.
- Retrieval — Selecting evidence relevant to the current request.
articleCompiler-Guided Adaptive Proof Search with Cross-Model Synergy on Context-Dependent Theorem ProvingZhuo Liu, Ding Yu, Hangfeng He
articleRethinking Automated Program Repair: The Impact of Bug Complexity, Fault Localization, and LLM Cost-efficiencyJunchi Liu, Ali Bigdeli, Roya Daneshi, Atu Ambala, Sudipto Ghosh, Fabio Santos
articleRefine After Generation: Toward Correct and Concise Patches in LLM-based Program RepairWenqiang Luo, Jacky Keung, Xiaoyu Shi, Yicheng Sun, Boyang Yang, Zhou Yang, Haoye Tian