Lean Refactor: Multi-Objective Controllable Proof Optimization via Agentic Strategy Search
Jialin Lu, Soonho Kong, Rodrigo Stehling, Kaiyu Yang, Zhangyang Wang, Weiran Sun, Wuyang Chen
AI4Math @ ICML 2026
TL;DR. We present Lean Refactor, a plug-and-play retrieval-augmented agentic framework for multi-objective, controllable, and version-robust refactoring of Lean proofs.
Abstract. We present Lean Refactor, a plug-and-play retrieval-augmented agentic framework for multi-objective, controllable, and version-robust refactoring of Lean proofs. LLM-generated proofs are notoriously correct-but-verbose and brittle across library versions, yet existing refactoring works overlook three practical challenges: 1) Lean refactoring is natively multi-objective (proof length, compilation cost, and version compatibility are often in tension); 2) Lean repositories have fragile compatibility, whereas LLM releases are unaware of Lean/Mathlib versions; 3) Training-based pipelines require repeated fine-tuning with each new LLM release, scaling neither with model churn nor with Lean's release cycle. Lean Refactor steers a frozen agentic LLM with retrievals from a curated database of multi-objective refactoring strategies, each densely annotated with metadata such as supported Lean/Mathlib versions and expected compilation-cost reduction. Experiments show over 70% token-level compression on competition benchmarks, over 20% on research repositories, and up to 60% compilation-time reduction, outperforming publicly released results from prior work and Claude Code. Version-filtered retrieval further improves compression on the target Lean version, and refactored miniF2F proofs exhibit stronger zero-shot version transfer to future Lean releases than their unrefactored counterparts. Project website: https://leanrefactor.github.io/.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:49 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
This paper proposes a novel retrieval strategy for improving the performance of LLM agents at Lean proof refactoring. While the reviewers broadly agree that the problem is interesting, they find that the experimental results do not support the efficacy of the technique. First, the reported gains are modest, and the authors do not report standard deviations. Another major issue is that most of the comparisons are not matched on model backbone and budget, and the matched comparisons to Claude Code are limited. Reviewer 3CBB also has a number of additional concerns to be addressed, including tradeoffs between proof size and compile time, version-robustness of the evaluation, and assessing the quality of the strategy bank.
Final justification
The authors have substantially expanded their experimental evaluation, thereby addressing the comments raised by the reviewers. Reviewer 3CBB did not respond; I read through the rebuttal and believe it does a good job addressing the points raised.
Read meta-review
Meta-review
This paper proposes a novel retrieval strategy for improving the performance of LLM agents at Lean proof refactoring. While the reviewers broadly agree that the problem is interesting, they find that the experimental results do not support the efficacy of the technique. First, the reported gains are modest, and the authors do not report standard deviations. Another major issue is that most of the comparisons are not matched on model backbone and budget, and the matched comparisons to Claude Code are limited. Reviewer 3CBB also has a number of additional concerns to be addressed, including tradeoffs between proof size and compile time, version-robustness of the evaluation, and assessing the quality of the strategy bank.
Final justification
The authors have substantially expanded their experimental evaluation, thereby addressing the comments raised by the reviewers. Reviewer 3CBB did not respond; I read through the rebuttal and believe it does a good job addressing the points raised.
2 comments
3. Reviewer 3CBB's additional concerns
- Length/compile-time trade-off:
The full trade-off matrix under both retrieval rules shows reranking achieves the highest heartbeat reduction on all seven benchmarks while staying within 6.6 pp on length, and shows reranking's successful effect on avoiding significant increase in heartbeats after refactoring. Detailed stats and discussion are in Q4 of response to reviewer 3CBB. We further noted that our acceptance rule is a tunable scalarization of a standard multi-objective formulation. New experiments trace two distinct Pareto points showing length/compile-cost trade off and admit longer-but-faster candidates by construction. Detailed discussion is in Q1 of response to reviewer 3CBB.
- Version robustness:
We note that version drift is an ecosystem-level bottleneck of Lean. Lean's release announcements state backward compatibility between versions cannot be promised [1]; Mathlib maintainers document routine breaking changes with no backward compatibility [2]; and Lean repos such as FLT maintain a standing 'Mathlib bump' thread repairing renames and post-bump timeouts after each release [3]. The community moreover lacks any benchmark or infrastructure for evaluating LLM systems under version drift, as research projects pin exact toolchains [2]. Lean Refactor is, to our knowledge, the first refactoring system to treat version compatibility as an explicit objective and to define an evaluation protocol: version-targeted optimization on three toolchains plus a zero-shot transfer audit over ten Mathlib releases. The evidence is predominantly positive: Filtered Retrieval wins 4/6 (version, model) cells across two backbones, and the miniF2F transfer advantage widens at later releases. Detailed discussion is in Q5 of response to reviewer 3CBB
- Strategy bank quality:
A post-hoc audit of 100 sampled strategies by two frontier LLM judges (GPT-5.6-Sol and Opus 4.8) disjoint from the construction pipeline yields 95% and 98% pass rates with 97% inter-judge agreement. No residual strategy duplication detected in top-10 nearest-neighbor checks. This shows the high quality of the strategy bank. Detailed discussion is in Q2 of response to reviewer 3CBB
[1] https://leanprover-community.github.io/blog/posts/first-lean-release/
[2] Baanen et al., "Growing Mathlib: maintenance of a large scale mathematical library" 2025.
[3] https://leanprover-community.github.io/archive/stream/416277-FLT/topic/Mathlib.20bump.html
Finally, we respectfully address the meta-review's initial note that the reviewers think "the experimental results do not support the efficacy of the technique." We hope our new experimental results and clarifications demonstrate that the efficacy is now directly supported: the decisive proof-length margins are 9-20x the run-to-run SD with non-overlapping run ranges, and the cross-version gains similarly exceed run-to-run variation by a wide margin; All matched comparison, including controlled ablations on all seven benchmarks and matched-budget Claude Code runs, shows the effectiveness of Lean Refactor, with each component making a strong contribution to performance; and the multi-objective control, strategy bank quality, and version robustness are each validated by new targeted experiments and clarifications. We will incorporate all new results and clarifications in the camera-ready.
- Rating
- 4/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper introduces Lean Refactor, a retrieval-augmented agentic framework that optimizes Lean proofs with respect to proof complexity, compilation time and version compatibility. The framework first constructs a strategy bank from long-short proof pairs, each annotated with metadata of compilation time and version compatibility. Then, it employs a fine-tuned LLM retriever that chooses strategies based on the input proof fragments. The retrieval process can be conditioned on optimization objectives during inference time. The evaluation shows that LLM Refactor achieves higher reduction ratio in both proof complexity and compilation time, while making the proof compilable under different versions.
Strengths and weaknesses
Strength
- Lean Refactor is effective in simplifying long proofs as shown in the experiments. This can be very helpful for making proofs more readable and accessible for Lean users.
- I like the idea of having a strategy bank, which essentially mimics the design of compilers that have different optimization passes / rewrites. This makes individual strategy amendable for verification to guard their soundness.
- Lean refactor targets cross-version compatibility issues, which I believe is a big concern for today’s LLM-based proof and code generation, as both Mathlib and CSlib are under active development.
Weaknesses
- Motivation on compilation time needs more justification: The proofs are usually compiled once and re-used in other modules, so the relevant question is whether running Lean Refactor plus compiling the optimized proof is cheaper than compiling the original. The experiments also do not report the statistics for scale of re-compilation needed after applying Lean Refactor.
- No comparisons against symbolic techniques. The evaluation does not compare with any symbolic techniques such as rewriting-based optimizations, proof decomposition and parallel compilation. This left the question whether Lean Refactor can bring more benefit than well-known sound techniques unanswered.
- The version-compatibility contribution is not clearly differentiated: given there is an extensive body of work on term rewriting, including the existing Lean infrastructure of
deprecatedTodecorations (lean4/DeprecatedTo), the compatibility issue could be soundly addressed via these mechanical rewrites. Therefore, I found this point of contribution is not clearly differentiating and would like the authors to clarify what are the additional benefits Lean Refactor brings beyond these approaches.
Questions
Besides the above questions:
- Lean Refactor focuses heavily on mathematical proofs. I wonder if similar techniques can be applied to proofs about programs, as there are increasing volumes of work on verified code generation. In these tasks, people may invoke SMT / theory solvers (e.g, CVC5) in the middle of proof scripts. I think under this setting, compilation time is a concern since the solvers may diverge and a manual proof needs to be substituted in.
- Does Lean Refactor consider any global refactor other than local rewrites? Appendices D and M only show examples on mutating / rewriting local tactics, but a global rewrite, e.g., extracting
haves into sub-files and enabling parallel elaboration and compilation, could also potentially yield speed-ups: some global structural rewrites can make the verification task compositional, and compositionality is usually the key to scalability. - While the paper appendix shows the aggregated cost, what approximately is the minimum budget the user has to allocate for Lean Refactor to be effective? What is the per-theorem cost and the cost with respect to the input theorem complexity?
Limitations
yes
Final justification
Major concerns resolved - the author clarified the positioning w.r.t. downstream applications and impact (Mathlib CI); provided additional results on non-math proofs, demonstrating the generality, while minor points such as discussions on related symbolic approaches (Tactic Script Optimisation, CPP'25, Proof Refactoring 2013, Proof Repair 2021) remain. They can be addressed through writing.
Formatting concerns
No particular concern
3 comments
Rebuttal
We thank Reviewer odxM for the time and effort in reviewing our paper, and for recognizing that Lean Refactor is effective at simplifying long proofs to improve readability for Lean users, that the strategy bank is an interesting design that keeps individual strategies amenable to soundness verification, and that our cross-version compatibility focus targets a major concern for Lean projects.
Q1. Importance of compilation time and question about re-compilation after applying Lean Refactor
We thank the reviewer for raising this point. While compiled modules can be reused when valid cached artifacts are available, compilation cost still recurs throughout active Lean development for three structural reasons:
-
Continuous integration. Mathlib continuously monitors build performance: Speedcenter benchmarks per-file compilation time on every master commit and flags regressions of at least 5% [1]. The existence of this infrastructure indicates that recurring compilation cost is an important maintenance concern.
-
File-granularity rebuilding. In batch compilation, Lean rebuilds at the source-file level. Modifying a declaration therefore requires rebuilding its containing file and may invalidate dependent build artifacts, causing expensive proofs to impose recurring costs whenever the module is rebuilt.
-
Fresh and uncached builds. Clean builds, new branches, version upgrades, cache misses, and bisecting historical commits may require modules to be compiled again. Moreover, shared caches must themselves be produced by machines that perform the corresponding builds.
Break-even. Refactoring pays off when N × ΔT > C (N rebuilds, ΔT per-compile saving, C one-time refactoring time cost). With Table 4's savings, break-even is N ≈ 60 rebuilds, easily reached for an active repo.
Re-compilation after applying Lean Refactor: During the optimization process, the agent interacts with the Lean compiler when needing to check correctness of the optimized proof. The average count of compiler calls is 22 per theorem during optimization process. No recompilation is needed after using Lean Refactor.
Finally, some evaluated proofs were supplied by repository maintainers after we contacted them, confirming that proof optimization of length and heartbeat addresses a pain point the community actively cares about.
[1] Baanen et al., "Growing Mathlib: maintenance of a large scale mathematical library" 2025.
Q2. Comparison against symbolic techniques
To our knowledge, no existing symbolic tool performs Lean 4 proof refactoring, and no prior system compares against one, as no such baseline exists.
The techniques named are orthogonal rather than competing: parallel compilation doesn’t change heartbeat, and proof decomposition restructures where work happens without reducing it. Term rewriting (simp lemma sets) is a mechanism for applying a transformation, not for deciding which transformation to apply where.
We are happy to add a comparison if the reviewer can point us to a concrete symbolic Lean proof optimization tool.
Q3. Differentiation from
deprecated-based mechanical rewrites
We address this with three points below:
-
Deprecation aliases cover only one narrow breakage class: renames of declarations that still exist with unchanged statements. They do not cover removed or merged lemmas, changed signatures or implicit-argument structure, typeclass/instance restructurings, or changes in tactic behavior, all of which break proofs with no deprecation to follow. Mathlib also removes aliases after a limited window, so they cannot bridge the multi-version intervals we target.
-
The empirical evidence that mechanical rewrites are insufficient is direct. Despite this infrastructure existing, downstream projects must pin to Mathlib's exact toolchain [1]. Moreover, in Table 9, 54 of 194 original miniF2F proofs fail to compile by v4.29.0, and these failures include tactic-behavior changes with no renamed declaration to rewrite. If
deprecatedTosoundly solved compatibility, neither would occur. -
Our contribution is broader than deprecation rewrites can express.
deprecatedToonly migrates names forward, whereas version-filtered retrieval targets any toolchain, including older ones (Table 5), and can supply toolchain knowledge the backbone LLM lacks.
[1] https://leanprover-community.github.io/archive/stream/270676-lean4/topic/mathlib4.html
Q4. Applicability to proofs about programs
We thank the reviewer for this suggestion and we ran a new experiment on exactly this setting. We evaluate on Strata (strata-org/Strata), an Amazon-backed Lean 4 platform for formalizing programming language semantics and building verification tools, whose pipeline discharges verification conditions via SMT solvers (cvc5, z3), matching the reviewer's described setting. The maintainers, whom we contacted, supplied proofs they wanted optimized. On 40 theorems from 2 files, Lean Refactor achieves a 15.89% average length reduction and a 6.32% average relative heartbeat reduction. These results indicate that our framework works outside of math proofs.
Q5. Does our system do global refactoring of extracting haves into sub-files other than local rewrites?
We would like to make two clarifications:
-
"Local" understates our scope. The planner segments proofs at multiple granularities and can target the entire proof (Section 3.3), and the final rewrites reflect this: across evaluation sets, the median optimized proof has 98% of its proof lines revised or removed, and 42% of optimized proofs share no line with the original, indicating complete rewrites, not local tactic edits. What we deliberately do not do is cross-declaration restructuring such as extracting haves into sub-files: our unit of optimization is the single declaration, which makes every result a drop-in replacement that maintainers can review and accept.
-
Extraction redistributes work; our refactoring removes it. Parallel elaboration of extracted sub-files can reduce wall-clock time but leaves total work unchanged, and our heartbeat metric is invariant to parallelism. In contrast, our rewrites delete the work itself (e.g., 11% heartbeat reduction on FLT and 48% on PutnamBench). The two are therefore complementary: our savings compound with compositional restructuring, which could itself be encoded as strategies over larger scopes, an extension we will note as future work.
Q6. Minimum budget and per-theorem cost
Per-theorem cost with Gemini 3 Flash averages around $0.8, varying with original proof length and style. The minimum effective budget depends on the regime, where competition proofs converge faster, with ~10 api calls already yielding good reduction, while human-written research-level proofs tend to require higher budgets like ~20 - 30.
I thank the authors for their detailed response and clarifications, which address most of my concerns. Most importantly, the response clarifies the paper's position on reducing compilation time: I agree that CI is a real pain point, since each dry run recompiles from scratch. The authors also demonstrate generality by applying LeanRefactor to a non-math codebase (Strata, a formal verification framework in Lean). Finally, the rebuttal addresses my question about local versus global refactoring: LeanRefactor can handle both by baking the relevant rewrites into the strategy bank.
In light of these clarifications and the additional results, I am raising my score to 4. My follow-up comments are below.
1. Importance of compilation time
The pitch toward optimizing for such scenarios is compelling, but this point does not stand out in the Introduction, which focuses primarily on the technical challenges of proof optimization and says little about the downstream impact. The first paragraph, for instance, motivates the work through the difficulty of reading lengthy LLM-generated proofs and compilation. I would recommend giving some space to concrete applications such as Mathlib CI, which requires dry runs that benefit from proof refactoring. This would strengthen the case for tackling the challenge in the first place.
2. Comparison against symbolic techniques
As far as I am aware of, [1] describes a related symbolic approach, and it seems worth discussing, at least qualitatively. Beyond that I cannot point to another symbolic system targeting this task directly, but the basic ingredients for rewrite-based proof optimization have been available for some time (e.g., [2, 3]). I would therefore have been interested to see the comparison against a purely symbolic (super-)optimization baseline.
- [1] Limperg, Jannis. "Tactic Script Optimisation for Aesop." Proceedings of the 14th ACM SIGPLAN International Conference on Certified Programs and Proofs. Association for Computing Machinery, 2025.
- [2] Whiteside, Iain Johnston. Refactoring Proofs. 2013. U of Edinburgh, PhD dissertation. Edinburgh Research Archive
- [3] Tate, Ross, Michael, Stepp, Zachary, Tatlock, Sorin, Lerner. "Equality Saturation: A New Approach to Optimization". Logical Methods in Computer Science Volume 7, Issue 1. (2011).
3. Differentiation from deprecated-based mechanical rewrites
I agree that the built-in mechanism alone is not (yet) sufficient. I view resolving version-compatibility issues as a term-rewriting problem, in which the rewrite rules are indexed by (potentially multiple) version compatibilities. Here it denotes that compiles in but not in , while a semantically equivalent pattern does compile in . Given a target version , one can construct a term-rewriting system that matches the patterns failing on , then instantiates and substitutes . Given that Lean is (hopefully) designed to be back-compatible in terms of expressiveness, there must exist a sequence of rewrite rules that can transform a proof that fails compilation into a compilable artifact in the target version (otherwise we find an expressiveness regression, or the given set of rewrite rules are incomplete, in which case it can be refined based on such feedbacks). The problem can equally be viewed as a form of proof repair [4], which is likewise well studied.
In LeanRefactor, as I understand it, this knowledge is embedded in the Strategies and the model's retrieval capability. I appreciate that the system address the issue via a neuro-symbolic approach, but I find this aspect less interesting than the proof-optimization challenge itself, which is more heuristic, covering a more complex search space.
- [4] Ringer, Talia. Proof Repair. 2021. U of Washington, PhD dissertation.
4. Applicability to proofs about programs
I thank the authors for the additional results on non-math proofs; they look promising.
5. Does our system do global refactoring of extracting haves into sub-files other than local rewrites?
Thanks for the clarification, this point is addressed.
6. Minimum budget and per-theorem cost
Thanks for the additional measurements; they look reasonable.
We sincerely thank reviewer odxM for confirming that our responses and new experiments addressed the main concerns, and for raising the score to 4. We respond to the remaining comments below; all updates will be incorporated into the camera-ready version.
1. Motivating compilation time in the Introduction section.
We agree. We will revise the Introduction to further motivate the problem with concrete downstream applications, in particular Mathlib CI, whose dry runs recompile from scratch and directly benefit from proof refactoring.
2. Symbolic techniques.
We thank the reviewer for the references and will add a qualitative discussion of [1] alongside [2, 3] in the revised related work. [1] is a valuable symbolic pipeline and complementary to ours along two axes: it optimises tactic scripts recorded by Aesop's own proof search (extension to arbitrary or LLM-generated scripts is noted in [1] as future work), and it targets idiomaticity, which is described in [1] as optimising "aesthetics rather than efficiency", whereas our objectives are length, compilation cost, and version robustness on arbitrary Lean 4 proofs. As the reviewer notes, no purely symbolic system currently targets this task directly; we agree that a symbolic optimization baseline would be a valuable comparison once such a comparable system exists, and we will highlight this in the revision.
3. Version compatibility as term rewriting / proof repair.
We appreciate this framing, and we will add the term-rewriting connection, along with the proof repair literature [4], to the camera-ready discussion. We agree that a complete version-indexed rewrite system could potentially address migration. The practical bottleneck lies in constructing such a rule set: acquiring and maintaining complete rules that cover the very wide range of breakage classes, from renamed or merged declarations to changed tactic behavior, as Lean/Mathlib rapidly evolves is itself the critical challenge. Our version-annotated strategy bank can be read as a learned approximation of that rule set: it is acquired automatically rather than curated by hand, and can be expanded upon as new versions are released. To our knowledge, ours is the first system to study cross-version robustness of Lean proofs. We hope this problem formulation, evaluation protocol, and exploration serve as a starting point for the community.
We thank the reviewer again for the constructive engagement!
[1] Limperg, Jannis. "Tactic Script Optimisation for Aesop." Proceedings of the 14th ACM SIGPLAN International Conference on Certified Programs and Proofs. Association for Computing Machinery, 2025.
[2] Whiteside, Iain Johnston. Refactoring Proofs. 2013. U of Edinburgh, PhD dissertation. Edinburgh Research Archive
[3] Tate, Ross, Michael, Stepp, Zachary, Tatlock, Sorin, Lerner. "Equality Saturation: A New Approach to Optimization". Logical Methods in Computer Science Volume 7, Issue 1. (2011).
[4] Ringer, Talia. Proof Repair. 2021. U of Washington, PhD dissertation.
- Rating
- 3/6
- Confidence
- 4/5
- Quality
- 2/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper presents Lean Refactor, a retrieval-augmented agentic framework for optimizing Lean proofs. The system builds a bank of reusable refactoring strategies from long-short proof pairs and annotates these strategies with metadata such as expected compilation-time reduction and Lean/Mathlib version compatibility. At inference time, a frozen LLM uses retrieved strategies inside a planner/refactorer/debugger loop with compiler feedback. The paper evaluates the approach on competition-style Lean benchmarks and several research-level repositories, reporting improvements in proof-length reduction, compile-time reduction under reranking, and some gains in version robustness.
Strengths and weaknesses
Strengths
The paper studies a relevant practical problem: LLM-generated Lean proofs can be correct but verbose, slow to compile, and fragile across Lean/Mathlib versions. The paper’s strongest point is its systems contribution: it combines a strategy bank, retrieval, planning, refactoring, debugging, and compiler validation into a single pipeline. The use of metadata for compilation cost and Lean-version compatibility is also useful, and the evaluation is broader than many Lean-proof papers because it includes both competition benchmarks and research repositories.
The ablations are informative. Removing the planner, removing retrieval, and replacing retrieval with random retrieval all reduce performance, which suggests that the strategy retrieval and planning components are doing useful work. The comparison with Claude Code under a matched Haiku backbone is also a helpful attempt to separate the proposed workflow from a generic coding agent. The paper is generally readable, and the main pipeline is easy to follow.
Weaknesses
My main concern is that the central framing is stronger than what the method and experiments establish. The paper repeatedly presents the method as multi-objective and controllable, but the compile-time objective seems to be implemented mainly through retrieval reranking. The agent loop still appears to accept updates only when the candidate both compiles and shortens the proof. If so, the method is not really optimizing over a length/compile-time trade-off; it is shortening proofs with compile-time-aware strategy selection. This distinction matters because the paper itself emphasizes that shorter proofs can be slower and faster proofs can be longer. A genuine multi-objective method should either expose a Pareto trade-off, support constrained optimization, or allow longer-but-faster candidates when requested.
The version-robustness evidence is also mixed. Version-filtered retrieval improves some settings, but not consistently across all tested Lean versions and backbones. The evaluation is restricted to PutnamBench for cross-version targeting, since research repositories are toolchain-pinned. The zero-shot transfer result is positive on miniF2F, but the paper notes that on PutnamBench the original proofs can remain more compatible than optimized proofs. This weakens the broad version-robustness narrative.
The external comparisons are useful but limited. The comparison to ProofOptimizer is not matched in model, budget, or optimization procedure, and the authors acknowledge that a matched comparison is impossible because ProofOptimizer checkpoints are unavailable. The Claude Code comparison is better controlled, but it is only run on one competition benchmark and one research benchmark. I therefore view the evidence against prior systems and general-purpose agents as suggestive more than conclusive.
Another concern is the strategy bank itself. The bank is central to the method, but it is produced by several automated stages, including LLM-based strategy extraction, LLM-as-judge filtering, and embedding-based deduplication. The paper gives many construction details, but I did not find enough direct validation of strategy quality, metadata correctness, or location grounding. The paper itself does not provide enough direct validation of the strategy bank’s correctness, metadata reliability, and failure modes.
Finally, the reporting relies heavily on averages. This is problematic because the compile-time results already show large outlier behavior, including a setting where cosine-only retrieval doubles compile time on average in relative terms. More distributional information, paired tests, failure rates, and examples would make the empirical claims easier to assess. I would also like to see a more direct evaluation of readability or maintainability; dependency reduction is useful, but it is only a proxy.
Questions
-
In the compile-time-aware setting, can the system accept a proof that is longer but compiles substantially faster? If not, please reframe this as proof shortening with compile-time-aware retrieval, rather than general multi-objective optimization.
-
Please report the length/compile-time trade-off under each retrieval rule. For example, what is the proof-length reduction under compile-time reranking, and what is the compile-time change under length-only retrieval? Distribution plots or paired statistics over the theorem set would be more informative than means alone.
-
Can the authors provide an in-paper or appendix-level audit of the strategy bank, independent of running the released code? Useful quantities would include the fraction of incorrect extracted strategies, incorrect applicability conditions, wrong location grounding, misleading metadata, and near-duplicate strategies after deduplication.
-
Can the Claude Code comparison be expanded to more benchmarks, or can the claim about outperforming generic agents be softened? A matched-budget comparison on all benchmarks, or at least more than one benchmark per regime, would make this part more convincing.
-
For version-aware retrieval, please report type-check success rates, filtered candidate-pool sizes, and representative failure cases for each Lean version. This would help explain why filtering is not consistently beneficial and why original PutnamBench proofs sometimes transfer better than optimized proofs.
Limitations
No. The limitations section mentions the restricted cross-version evaluation and conservative strategy-level metadata aggregation, but it should also discuss the length constraint in the compile-time setting, the limited external comparisons, the lack of manual validation for the strategy bank, the mixed version-transfer findings, and the absence of direct readability evaluation.
Final justification
After considering the rebuttal of the authors, other reviewers, and the AC, I keep my score at 3 (Borderline Reject).
The authors added a weight-controlled length/compile-cost experiment, expanded the matched Claude Code comparison to four benchmarks, reported the full objective trade-off matrix, and provided strategy-bank and version-failure analyses. These additions strengthen the empirical case.
The new scalarization shows that longer-but-faster candidates can be accepted. However, the original main experiments used length-only acceptance, and multi-objective control is demonstrated with only two scalarizations on one benchmark.
Cross-version gains remain mixed and narrowly evaluated. Strategy quality and readability were audited primarily using LLM judges instead of Lean experts. Several compile-cost results also show high theorem-level variance, without paired significance tests and with run-to-run analysis limited to selected settings. The ProofOptimizer comparison remains unmatched.
I give positive weight to the new controlled experiments, but the remaining gaps concern the paper’s central claims. The evidence does not yet clearly establish general and robust multi-objective, version-aware proof optimization.
Formatting concerns
No
4 comments
Rebuttal
We thank Reviewer 3CBB for the time and effort in reviewing our paper, and for recognizing the practical relevance of the problem the paper targets, our system’s contribution and broad evaluation, as well as the informative ablations.
Q1. Whether the acceptance rule admits longer-but-faster proofs, and whether the multi-objective framing is fully supported
We thank the reviewer for this careful reading. We firmly clarify that: 1) our agent loop does not require that a candidate shortens the proof; 2) our multi-objective method can allow longer-but-faster candidates when requested.
We address the concern from the following three perspectives, and will add these discussions and results in our camera ready:
1. Our problem formulation is already multi-objective, following the standard definition. The formulation of our problem is:
where is proof length, is compilation cost, and is the number of incompatible Lean versions.
We respectfully refer the reviewer to the definition in the opening paragraph of the Wikipedia page on multi-objective optimization [1]: "mathematical optimization problems involving more than one objective function to be optimized simultaneously."
Our formulation therefore constitutes a multi-objective optimization problem.
2. The aggregate objective (by which our agent loop accepts updated proofs) in our optimization algorithm is a tunable scalarization
We scalarize the multi-objective (Eqn. 1 above) into an aggregate objective, i.e., a scalar surrogate:
which is one of the canonical, textbook ways to do multi-objective optimization (e.g., §4.7.4 "Scalarization" in “Convex Optimization” (2004) by Boyd & Vandenberghe). This scalarization does not make our problem single-objective. We illustrate the acceptance criterion with the following simplified Python snippet: a candidate proof is accepted iff it improves the best scalarized score (Eqn. 2) achieved so far.
def F_hat(proof):
return w1 * f1(proof) + w2 * f2(proof) + w3 * f3(proof)
# Keep the candidate iff it improves the best scalarized score so far
if verified(candidate) and F_hat(candidate) < best_score:
best_proof, best_score = candidate, F_hat(candidate)
In our current experiments, we carefully chose (, , ) = (1, 0, 0) mainly to enable a consistent and fair comparison with prior length-optimizing work like ProofOptimizer (Gu et al., 2025), as prior works only accept shorter proofs. In the meantime, different settings of (, , ) scalarize into different aggregate objectives, as we will demonstrate below.
3. New experiments: experimenting with different (, ) traces the length/compile-cost trade-off and by construction admits longer-but-faster proofs
We evaluate Lean Refactor w/ Reranking at the two settings of (, ) on PutnamBench:
| (, ) | Avg. Length Reduction (%) | Avg. Heartbeat Reduction (%) |
|---|---|---|
| (1, 0) — length only optimization | 64.29 | 48.92 |
| (0, 1) — compile cost only optimization | 53.78 (longer proofs) | 54.41 (cheaper compiles) |
These experiments demonstrate two points:
- Two distinct Pareto points. Moving the weights from to trades points of length reduction for points of additional heartbeat reduction; each setting is best on its own prioritized objective.
- Longer-but-faster candidates are admitted by construction. Under the agent accepts any candidate that reduces compilation cost, including candidates longer than the original proof. In practice, final proofs still end up shorter than the original version because the original long proofs generated by LLM-based provers are heavily redundant, so their compile-cost optima are also short. This is a property of the benchmark inputs, not a restriction of the method.
4. Constrained optimization is likewise supported. Constrained variants (e.g., "minimize compile cost subject to length <= L", or the reverse) are obtained by a one-line change to the same acceptance condition:
# Example constrained variant: minimize compile time f2 subject to a length threshold f1 <= L
if verified(candidate) and f1(candidate) <= L and f2(candidate) < best_score:
best_proof, best_score = candidate, f2(candidate)
Lastly, we would like to note that Reviewer 1v5H stated, “The framing of Lean refactoring as a problem with several objectives that move independently is well motivated and supported by the paper’s own measurement.” We hope that the clarification above, together with our new weight-controlled experiments, resolves the remaining ambiguity.
[1] https://en.wikipedia.org/wiki/Multi-objective_optimization
Q2. Direct validation of the strategy bank
We thank the reviewer for this suggestion and have conducted a post-hoc audit of the bank.
Strategy correctness audit. We sampled 100 strategies and had two frontier LLMs, GPT-5.6 Sol and Claude Opus 4.8, independently evaluate each strategy's correctness and accuracy. Pass rates are 95/100 (GPT-5.6 Sol) and 98/100 (Claude Opus 4.8), with 97% inter-judge agreement. Importantly, both auditor models are disjoint from the model used to construct the bank, so the audit is independent of the construction pipeline and free of self-preference bias. We chose dual frontier-LLM evaluation to scale the audit and avoid annotator subjectivity; the high agreement rate supports its reliability.
Residual duplication. For each sampled strategy, we retrieved its top-10 nearest neighbors in the bank by cosine similarity and asked both models to judge semantic duplication. Neither judge identified any duplicate, indicating the iterative deduplication pipeline leaves negligible residual redundancy.
Metadata reliability. We emphasize that metadata is not LLM-generated and therefore cannot be misleading: compilation-cost reduction and version compatibility is certified by actually running and compiling every proof under the targeted Lean environment.
Q3. Expanding Claude Code comparison
Following the reviewer's suggestion, we ran the matched-budget, matched-backbone comparison on one additional benchmark per regime: Putnam2025 (competition) and FLT (research-level). Results below use the same three Claude Code tool configurations as Table 3.
| Agent Configuration | Putnam2025 | FLT | |
|---|---|---|---|
| Claude Code (Haiku 4.5) | Lean MCP only | 52.28 | 6.89 |
| + Lean skills | 56.23 | 8.23 | |
| + Lean skills and Strategy retrieval tool | 56.75 | 7.97 | |
| Ours (Haiku 4.5) | Lean Refactor | 61.60 | 10.11 |
The takeaway is consistent with Table 3: Lean Refactor outperforms the strongest Claude Code configuration on both new benchmarks, now covering four benchmarks across both regimes (PutnamBench, Putnam2025, Analysis, FLT).
Q4. Report the length/compile-cost trade-off under each retrieval rule, with statistics beyond means
We computed the full length/compile-cost matrix under both retrieval rules on all seven benchmarks, with more statistics. "No Rerank" = Lean Refactor; "Rerank" = Lean Refactor w/ Reranking. Alongside the mean we report its standard deviation (SD) across theorems, which quantifies how consistently each rule behaves rather than how it performs on average.
↑ = higher is better; bold marks the better rule in each pair. ± is the SD of per-theorem reductions within each dataset (theorem-to-theorem consistency).
| Dataset (n) | Retrieval Rule | Length reduction mean % ↑ | Heartbeat reduction mean % ↑ | Δ Heartbeat reduction (pp) ↑ |
|---|---|---|---|---|
| miniF2F (194) | No Rerank | 88.4 ± 11.6 | −67.7 ± 1473.8 | |
| Rerank | 83.7 ± 18.2 | 46.9 ± 50.8 | +114.6 | |
| PutnamBench (75) | No Rerank | 70.4 ± 27.2 | 46.5 ± 48.5 | |
| Rerank | 64.3 ± 29.9 | 48.9 ± 41.1 | +2.4 | |
| Putnam2025 (66) | No Rerank | 79.3 ± 22.6 | −9.9 ± 294.2 | |
| Rerank | 76.0 ± 20.2 | 1.6 ± 272.2 | +11.5 | |
| FLT (45) | No Rerank | 23.5 ± 26.4 | 3.0 ± 40.0 | |
| Rerank | 18.5 ± 23.4 | 11.3 ± 26.1 | +8.3 | |
| PFR (45) | No Rerank | 20.4 ± 21.3 | 3.1 ± 48.5 | |
| Rerank | 17.5 ± 21.7 | 9.9 ± 19.0 | +6.8 | |
| PhysLean (45) | No Rerank | 27.7 ± 27.5 | −22.0 ± 155.2 | |
| Rerank | 23.1 ± 28.3 | 7.5 ± 26.3 | +29.5 | |
| Analysis (45) | No Rerank | 33.5 ± 29.6 | −14.4 ± 83.0 | |
| Rerank | 26.9 ± 29.1 | 3.2 ± 55.8 | +17.6 |
Direct answers to the two requested numbers.
(i)Proof-length reduction under compile-cost based reranking stays within 6.6 pp of the no rerank retrieval rule on every benchmark.
(ii) Reranking improves compile cost. Under no rerank, mean heartbeat reduction is negative on four of seven benchmarks (i.e. optimized proofs cost more to compile than the originals), while under reranking it is positive on all seven, with improvement ranging from +2.4 to +114.6 pp.
(iii) Reranking improves compile cost more stably. Reranking consistently achieves lower heartbeat reduction SD across theorems within each benchmark. Because the large no-rerank SDs come from proofs whose compile cost explodes, the lower SD means reranking eliminates these large increases in heartbeats.
We will address rest of the questions as comments at a later time
Continued response to reviewer 3CBB’s questions and concerns
Q5. Mixed version-robustness evidence
The evidence is predominantly positive: Filtered Retrieval wins 4 of 6 (version, model) cells(Tab. 5), and the miniF2F transfer advantage widens at later releases. We report exceptions transparently, and ask that they be weighed against two facts:
- Version incompatibility is an ecosystem-level property of Lean, not our setup. Lean cannot promise backward compatibility[1] and Mathlib documents routine breaking changes[2].
- No benchmark exists for evaluating LLM systems under version drift: research projects pin exact toolchains[2], hence cross-version targeting is restricted to self-contained PutnamBench(Sec. 4.3).
Despite the challenges, Lean Refactor is, to our knowledge, the first refactoring system to:
- treat version compatibility as an explicit objective;
- define an evaluation protocol: version-targeted optimization on three toolchains plus zero-shot transfer over Lean releases;
- show promising first results: 4/6 wins across two backbones, direct evidence the bank supplies missing in-weights knowledge (Tab. 5).
Potential causes of the v4.14.0 exceptions (Tab. 5): it is the only tested version inside Gemini 3 Flash's training window, so filtering supplies compatibility knowledge already in-weights and only shrinks the candidate pool. Consistent with this, Filtered still beats No Retrieval (59.54 vs 58.51), and Full Retrieval overtakes both. v4.14.0 also has the smallest compatible strategy pool, reducing retrievable relevant strategies. The PutnamBench transfer gap likely reflects corpus composition(App. G).
We do not claim version robustness is solved; we claim it is now measurable and controllable, and we hope this protocol serves as a community starting point.
[1] https://leanprover-community.github.io/blog/posts/first-lean-release/
[2] Baanen et al., "Growing Mathlib: maintenance of a large scale mathematical library" 2025.
Q6. Unmatched comparison with ProofOptimizer
A fully matched comparison with ProofOptimizer is impossible due to unreleased checkpoint and different inference paradigm (Footnote 3). We therefore evaluate each system under its native configuration.
For matched external comparison, we compared with Claude Code on 4 benchmarks (Tab. 3, Q3); our framework consistently outperforms it with matched backbone and dollar budget.
Q7. Readability and maintainability evidence
Readability. With no rigorous readability metric available and human judgements are subjective, we ran pairwise preference evaluation (original VS our refactored proofs) with two frontier LLM judges on one benchmark per regime:
| Benchmark | GPT-5.6 Sol prefer ours | Opus 4.8 prefer ours | Agreement |
|---|---|---|---|
| Analysis (research) | 80% | 73.3% | 93.3% |
| Putnam2025 (competition) | 90.9% | 87.9% | 90.9% |
Both judges strongly prefer our proofs, with high agreement. Reviewer odxM also noted our simplification "can be very helpful for making proofs more readable".
Maintainability. Given Lean's cross-version fragility, a natural measure is how long a proof survives future releases. We are the first to evaluate this (recompiling refactored proofs against different Lean version). On miniF2F our proofs transfer furthest among all systems and the originals; on PutnamBench the effect is benchmark-dependent, yet we still lead among proof-optimization systems. Reduced dependencies (App. F) also mean fewer breakage points under library churn.
Q8. Type-check rates, pool sizes, failure cases per version
1. Type-check rate Per version: original and optimized proofs under each retrieval setting compiled in tested versions.
| Version | Original | No Retrieval | Filtered Retrieval | Full Retrieval |
|---|---|---|---|---|
| v4.14.0 | 98.7% | 98.7% | 98.7% | 98.7% |
| v4.16.0 | 100% | 100% | 100% | 100% |
| v4.22.0 | 85.3% | 90.7% | 94.7% | 93.3% |
Filtered Retrieval stands out at v4.22.0; other versions stay same across settings.
2. Candidate-pool sizes (version-compatible strategy bank): v4.22.0: 1973; v4.16.0: 1794; v4.14.0: 1688 — shrinking going backward since compatibility sets are conservative intersections (App. B.8).
3. Representative failures fall into two classes: (a) Nominal — renamed/deleted declaration. v4.22.0: putnam_1993_b1 uses div_lt_div_iff, deleted in favor of div_lt_div_iff₀ → unknown identifier; same mechanism at v4.25.0 (Nat.dvd_sub') and v4.27.0 (le_or_lt). (b) Behavioral — automation/normal-form drift, no symbol involved. v4.23.0: in mathd_algebra_275, the stronger norm_num [pow_mul] at h ⊢ closes the goal while processing h, then errors No goals to be solved at ⊢.
Q9. Response to the Limitations comment
Each limitation listed is backed by clarifications and evidence: compile-cost length constraint (Q1), strategy-bank validation (Q2), external comparisons (Q3 Q6), mixed version-transfer findings (Q5), readability evaluation (Q7). We will update paper accordingly in camera ready.
Anticipating Further Discussions
Dear Reviewer 3CBB:
We would like to kindly remind you that the author-reviewer discussion period has started for several days now and will end soon.
We would greatly appreciate it if you could review our responses to your initial comments at your earliest convenience.
This will enable us to address any additional queries or feedback you might have before the discussion period ends.
Should our responses sufficiently address your concerns, we respectfully request that you consider raising the rating of our work.
Thank you very much for your attention, time, and efforts!
Best regards,
Authors of Submission #19023
Anticipating Further Discussions
Dear Reviewer 3CBB:
We would like to kindly remind you again that the author-reviewer discussion will end very soon.
We would greatly appreciate it if you could review our responses to your initial comments. This will enable us to address any additional queries or feedback you might have before the discussion period ends.
Should our responses sufficiently address your concerns, we respectfully request that you consider raising the rating of our work. Thank you very much for your attention, time, and efforts!
Best regards,
Authors of Submission #19023
- Rating
- 4/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 2/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper introduces Lean Refactor, a retrieval augmented agentic system for refactoring Lean 4 proofs along several objectives at once: token length, compilation cost, and compatibility across Lean and Mathlib toolchains. The central idea is to move refactoring knowledge out of model weights and into an external strategy bank. Each strategy is distilled from a pair of a verbose and a concise proof and is annotated with metadata that a frozen model cannot infer on its own, namely an estimated compilation time reduction and a set of toolchain versions under which the transformation still compiles. At inference the user names an objective, and the system reshapes a single retrieval rule over the shared bank: pure cosine similarity for length, a rerank by annotated compile cost for efficiency, and a filter by compatibility set for a target version. A frozen frontier model then drives a planner, refactorer, and debugger loop that proposes, compiles, and repairs candidate proofs. The authors build a corpus of about 200K paired proofs and 9237 deduplicated strategies, train a retrieval encoder on it, and evaluate on three competition suites (miniF2F, PutnamBench, Putnam2025) and four research repositories, reporting length reduction, compilation time and heartbeat reduction, and cross version behavior
Strengths and weaknesses
Strenghts:
- The framing of Lean refactoring as a problem with several objectives that move independently is well motivated and supported by the paper's own measurement. Figure 2 shows a weak correlation between proof length and compilation time (Pearson around 0.12 on PutnamBench and 0.09 on miniF2F), and Appendix gives a concrete case where the shorter proof compiles far slower because a loose bound feeds heavy tactics. This establishes that length is a poor proxy for cost and gives the externalized metadata bank a real job to do rather than a hypothetical one.
- The authors are forthright about the boundaries of their comparisons and about results that cut against the headline. Table 4 openly reports that the length oriented configuration roughly doubles compile time on miniF2F in relative terms, and Appendix explains why relative and absolute heartbeat reductions can disagree in sign. This candor makes the rest of the evidence easier to trust.
- The cleanest result is the objective swap in Section 4.2. Holding the agent, the backbone, and the strategy bank fixed and changing only the retrieval rule, the system moves from optimizing length to optimizing compilation cost, and the reranking variant attains the largest compile time reduction on every competition benchmark. Because nothing but the retrieval criterion changes, this isolates the mechanism the paper is arguing for: the metadata, not the agent architecture alone, is what redirects the system across objectives. The matched budget and matched backbone comparison with Claude Code (Table 3) and the use of GPT OSS 20B, whose knowledge cutoff predates the tested toolchains, strengthen this isolation by separating the bank's contribution from in weights knowledge.
Weaknesses:
- The cross version contribution rests on margins that are small and unquantified for noise. In Table 5, Filtered Retrieval wins on four of six cells by roughly one to two points on a single 75 theorem benchmark, Full Retrieval shows no consistent gain over No Retrieval, and the v4.14.0 row breaks the pattern. Because the backbone samples and no variance is reported here, the separation between filtered and baseline retrieval is not yet established.
- Most headline numbers are single values without error bars, even though the planner, refactorer, and debugger run on a sampling model and the checklist marks statistical significance as addressed. Only Table 4 carries variance, and that is computed over repeated compilations rather than repeated agent runs. Several decisive comparisons, including Lean Refactor versus its ablations on the research repositories in Table 2 and the filtered retrieval margins in Table 5, rest on differences that could lie within sampling noise.
Questions
- Given that the ProofOptimizer comparison is unmatched in backbone and budget by your own account, how should a reader interpret the abstract's claim of outperforming prior work? Would you consider scoping the headline to the matched Claude Code comparison, or adding a bound on the confound, so that the controlled ablations carry the weight rather than the unmatched baseline?
- Can you indicate whether the filtered versus baseline gaps in Table 5 are distinguishable from run to run noise? A clear separation would convert a suggestive pattern into direct evidence for the compatibility set mechanism, which is what the cross version contribution turns on.
- Would you report run to run variance for the length and cross version tables, since the backbone samples and several of the decisive comparisons rest on differences that could lie within sampling noise?
Limitations
yes
Formatting concerns
Paper is formatted well.
3 comments
Rebuttal
We thank Reviewer 1v5H for the careful and constructive review, and for recognizing that our multi-objective framing is well motivated and supported by our own measurement, and that the objective swap is a clean result that can redirect the system across objectives.
Q1. Interpretation of ProofOptimizer comparison
ProofOptimizer's checkpoints are unreleased, and their inference time method is different from ours, so no matched run is possible, which we have openly noted in our paper; the comparison results should be interpreted as end-to-end under each system's own native configuration, on identical source proofs (we reuse their released long proofs). We will therefore revise the abstract to unify previous results as: "outperforming publicly released end-to-end results from prior work and Claude Code".
Q2. Run to run variance for cross version compatibility
Due to budget, we prioritized running additional independent repetitions of the cross-version experiment at v4.22.0 (PutnamBench with Gemini 3 Flash), giving three runs per retrieval setting.
| Retrieval setting | Run 1 | Run 2 | Run 3 | Mean ± std |
|---|---|---|---|---|
| Filtered Retrieval | 57.36 | 57.83 | 57.85 | 57.68 ± 0.28 |
| Full Retrieval | 55.43 | 55.89 | 55.58 | 55.63 ± 0.23 |
| No Retrieval | 55.99 | 55.97 | 56.18 | 56.05 ± 0.12 |
Filtered Retrieval is clearly separated from run-to-run variation in this setting. The within-setting standard deviation is only 0.12–0.28, whereas Filtered Retrieval exceeds No Retrieval by 1.63 and Full Retrieval by 2.05. In contrast, Full Retrieval and No Retrieval remain within the same noise scale. As discussed in Section 4.3, this gap implies that without compatibility filtering, semantically relevant but version-incompatible strategies can introduce stale tactics or removed APIs, consuming the agent’s debugging budget and offsetting the benefit of the additional context.
We will add these three-run means and standard deviations to Table 5 in camera ready.
Q3. Run-to-run variance for the length tables
Due to budget, we prioritized the comparison between results of narrow margin: Lean Refactor and Lean Refactor w/ Random Retrieval under an identical backbone and API budget, giving three runs per setting on representative benchmark: one research repository with a narrow margin (FLT) and one competition benchmark (PutnamBench).
| Benchmark | Method | Run 1 | Run 2 | Run 3 | Mean ± std |
|---|---|---|---|---|---|
| PutnamBench | Lean Refactor | 70.38 | 69.36 | 69.74 | 69.83 ± 0.52 |
| PutnamBench | Lean Refactor w/ Random Retrieval | 59.41 | 60.13 | 59.17 | 59.57 ± 0.50 |
| FLT | Lean Refactor | 23.55 | 23.31 | 23.12 | 23.33 ± 0.22 |
| FLT | Lean Refactor w/ Random Retrieval | 21.47 | 20.99 | 21.28 | 21.25 ± 0.24 |
Lean Refactor is clearly separated from run-to-run variation in both evaluation regimes. The improvement over random retrieval is approximately 20 times the observed standard-deviation scale on PutnamBench and 9 times on FLT. The run ranges also do not overlap: the weakest Lean Refactor run still exceeds the strongest random-retrieval run on both PutnamBench and FLT. This shows that the gains arise from targeted retrieval in Lean Refactor rather than random strategy-bank context.
We will update the Tables accordingly in the camera-ready.
Q4. the compatibility experiment exception for version v4.14.0
Here we address the pattern deviations where in v4.14.0 there is no consistent improvement for filtered retrieval (Table 5). Version v4.14.0 is the only tested version inside Gemini 3 Flash's training window (Fig. 3), so the filter supplies version knowledge this backbone already has. Consistent with this, Filtered Retrieval still beats No Retrieval for Gemini even at v4.14.0 (59.54 vs 58.51); the deviation is Full Retrieval overtaking both, which is exactly what in-window redundancy predicts: when the backbone can natively repair version drift in retrieved strategies, unfiltered retrieval recovers its full semantic advantage and filtering only costs relevance.
More broadly, version incompatibility is an acknowledged ecosystem-level bottleneck of Lean, not an artifact of our setup. Lean's release announcements state backward compatibility between versions cannot be promised [1]; Mathlib maintainers document routine breaking changes with no backward compatibility [2]; and many Lean repos, e.g. FLT, maintains a standing "Mathlib bump" thread repairing renames and post-bump timeouts after each release [3]. The community moreover lacks any benchmark or infrastructure for evaluating LLM systems under version drift, as research projects pin exact toolchains ([2]; our Sec. 6).
Despite these challenges, Lean Refactor is, to our knowledge, the first refactoring system to:
- treat version compatibility as an explicit, controllable objective;
- define a controlled protocol for evaluating it: version-certified retrieval against unfiltered and no-retrieval baselines across three toolchains, plus a zero-shot transfer audit recompiling outputs across ten different Mathlib releases;
- show promising first results: version compatibility gains (Table 5, Q2) and a transfer advantage that widens at later releases (Table 6).
We hope this problem formulation and evaluation protocol serve as a starting point for the community.
[1] https://leanprover-community.github.io/blog/posts/first-lean-release/
[2] Baanen et al., "Growing Mathlib: maintenance of a large scale mathematical library" 2025.
[3] https://leanprover-community.github.io/archive/stream/416277-FLT/topic/Mathlib.20bump.html
Looking forward to discussions
Dear Reviewer 1v5H:
As the author-reviewer discussion period has started for several days now and will end soon, we will appreciate if you could check our response to your review comments soon. This way, if you have further questions and comments, we can still reply before the author-reviewer discussion period ends. If our response resolves your concerns, we kindly ask you to consider raising the rating of our work. Thank you very much for your time and efforts.
Best regards,
Authors of Submission #19023
Looking forward to discussions
Dear Reviewer 1v5H:
As the author-reviewer discussion period is ending very soon, we would greatly appreciate it if you could take a look at our response to your comments. This way, if you have further questions and comments, we can still reply before the author-reviewer discussion period ends. If our response resolves your concerns, we kindly ask you to consider raising the rating of our work. Thank you very much for your time and efforts.
Best regards,
Authors of Submission #19023
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
We thank the Area Chair for the meta-review, and for acknowledging our novel method. Every concern summarized in the meta-review has been addressed in our reviewer responses with new experiments and clarifications; we summarize the key evidence below, with pointers to the detailed responses.
We ran additional independent agent runs per setting for both cross-version and length experiments, covering both research-level and competition style benchmarks, and report standard deviations (SD). Results show that the improvement margin is much higher than the run-to-run SD.
Length: Lean Refactor vs. Random Retrieval under identical backbone and budget. The margin is roughly 20x the run-to-run SD on PutnamBench (69.83 ± 0.52 vs. 59.57 ± 0.50) and 9x on FLT (23.33 ± 0.22 vs. 21.25 ± 0.24); run ranges do not overlap. Detailed discussion is in Q3 of the response to reviewer 1v5H.
Cross-version: at v4.22.0, Filtered Retrieval (57.68 ± 0.28) exceeds No Retrieval (56.05 ± 0.12) by 1.63 pp and Full Retrieval (55.63 ± 0.23) by 2.05 pp, far beyond the within-setting SDs of 0.12-0.28. Detailed discussion is in Q2 of the response to reviewer 1v5H.
On magnitude: with matched backbone and dollar budget experiments with Claude Code, the gains are substantial. Lean Refactor outperforms Claude Code by +16 pp on PutnamBench and +11 pp on Analysis. For heartbeat reduction, reranking brings improvements of +2.4 to +114.6 pp on heartbeat reduction over no reranking.
A matched run with ProofOptimizer is impossible since their checkpoints are unreleased and their inference paradigm differs (we have noted in Footnote 3 in paper). Detailed discussion is in Q1 of the response to reviewer 1v5H.
We ran two additional matched-backbone, matched-dollar-budget comparisons with Claude Code, now covering four benchmarks (PutnamBench, Analysis, Putnam2025, FLT) which include both research level and competition style problems; Lean Refactor consistently outperforms the strongest Claude Code configuration on all four benchmarks. Detailed discussion is in Q3 of the response to reviewer 3CBB
Moreover, all internal ablations (Tables 1-3) are already matched on backbone and API budget, and they cover all seven benchmarks: removing the planner, removing retrieval, or replacing targeted retrieval with random sampling each degrades performance, isolating the effectiveness of every component. As Reviewer 1v5H noted, the cleanest result is the objective-swap experiment, where it holds the agent, backbone, and strategy bank fixed and changes only the retrieval rule, so the metadata mechanism itself is isolated under fully matched conditions.