Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox

METAL MEDIA

Compiler-Guided Adaptive Proof Search with Cross-Model Synergy on Context-Dependent Theorem Proving

arXiv:2608.180842026-08-20

Reusing failed AI proof attempts, instead of throwing them away, boosts success on real-world Lean theorem proving

Proving theorems in real Lean 4 projects is hard because proofs depend on project-specific context. This paper builds a search framework that repairs failed proofs using compiler error feedback, while carefully controlling when to keep exploring versus improving the current attempt. Across seven real Lean 4 projects from miniCTX-v2, it raises average pass rate by 12.8 percentage points while cutting LLM calls by 21.9%, compared to pass@k baselines.

METAL MEDIA explanatory visual

Reusing failed AI proof attempts, instead of throwing them away, boosts success on real-world Lean theorem proving

  1. 01Two complementary models generate candidate proofs: a general-purpose reasoning model (generalist) and a Lean-specialized prover (specialist); an LLM judge picks the more promising one as the starting point.
  2. 02The chosen proof is repeatedly revised using compiler error feedback, but each revision is only accepted if the judge decides it's actually better than the current best; otherwise the old version is kept.
  3. 03When repair stalls for several rounds without improvement (a stagnation counter), the system resamples fresh candidates from both models and restarts refinement.
  4. 04On miniCTX-v2's seven projects, within a pass@32 budget the method improved average pass rate by 12.8 percentage points and cut LLM calls by 21.9%, at lower cost ($1.96 vs $2.43 for GPT-5-mini pass@32).
  5. 05Analysis showed about half (50.4%) of proposed repairs get rejected by the judge, and 39.5% of successful proofs came from a preserved earlier state rather than the newest revision, showing that keeping good states matters as much as generating new ones.
An explanatory diagram made by METAL MEDIA, not a figure supplied by the paper's authors.

What they did

  1. Two complementary models generate candidate proofs: a general-purpose reasoning model (generalist) and a Lean-specialized prover (specialist); an LLM judge picks the more promising one as the starting point.
  2. The chosen proof is repeatedly revised using compiler error feedback, but each revision is only accepted if the judge decides it's actually better than the current best; otherwise the old version is kept.
  3. When repair stalls for several rounds without improvement (a stagnation counter), the system resamples fresh candidates from both models and restarts refinement.
  4. On miniCTX-v2's seven projects, within a pass@32 budget the method improved average pass rate by 12.8 percentage points and cut LLM calls by 21.9%, at lower cost ($1.96 vs $2.43 for GPT-5-mini pass@32).
  5. Analysis showed about half (50.4%) of proposed repairs get rejected by the judge, and 39.5% of successful proofs came from a preserved earlier state rather than the newest revision, showing that keeping good states matters as much as generating new ones.
Table 1: Pass rate (%) on miniCTX-v2 across seven projects with Gemini-2.5-flash as the Generalist. Results of full proof generation are pass@16. Our method additionally reports average LLM calls per theorem (gray).
MethodPass rate (%) per projectAvg.
CarlesonConNFFLTFoundationHepLeanMathlibSeymour
Gemini-2.5-Flash44.0028.0035.2952.0038.0040.0072.0044.18
DeepSeek-Prover-V242.0030.0047.0654.0042.0042.0070.0046.72
Ours48.0034.0050.0060.0054.0046.0078.0052.86
avg calls14.8616.4615.0312.2814.9216.128.9814.09
Table 2: Fraction of theorems proved by each component.
ComponentFraction (%)Subtotal (%)
AutoSolve28.3628.36
Init (Generalist)30.34
Init (Specialist)9.4439.78
Resample (Generalist)0.49
Resample (Specialist)1.011.50
Refine (Generalist)18.91
Refine (Specialist)11.4630.37
Table 3: Effect of stagnation threshold N on mathlib-valid.
K/12K/6K/4K/3K/2
Pass Rate (%)48.0056.0060.0054.0060.00
LLM Calls30.2427.1224.4227.6027.76
Table 4: Intra-WP std (same wrong proof, multiple runs) vs. inter-WP std (different wrong proofs) for theorems in the Mathlib valid split.
Intra-WP stdInter-WP std
T11.865.59
T20.802.58
T37.028.66
T40.000.00
T50.080.49
T65.426.54
T71.220.49
T84.064.85
T91.241.00
Avg2.413.36
Table 5: Model selection rate in pairwise comparisons. Each comparison occurs when both GPT5-mini and DeepSeek-prover-v2 produce a candidate proof and the judge selects the better starting point.
Project#ComparisonsGPT5-mini (%)DeepSeek-prover-v2 (%)
ConNF7354.845.2
FLT3278.121.9
HepLean4571.128.9
Foundation4755.344.7
Carleson4953.146.9
Seymour2352.247.8
Mathlib12255.744.3
Total39158.641.4
Table 6: Detailed breakdown of theorems proved by each component on miniCTX-v2 test.
ComponentNumber of theorems proved per projectAvg.
CarlesonConNFFLTFoundationHepLeanMathlibSeymour
AutoSolve07112041058.14
Init (Generalist)16205103258.71
Init (Specialist)41314332.71
Resample (Generalist)00001000.14
Resample (Specialist)00001010.29
Refine (Generalist)55437865.43
Refine (Specialist)27115343.29
Total2722193032274428.71

Why it matters

Real-world, project-scale theorem proving is hard because it depends heavily on local context, and this work shows that smarter reuse of failed attempts—not just bigger or retrained models—can improve both accuracy and cost efficiency. The exploration-versus-exploitation search strategy here could generalize to other AI tasks that receive compiler or execution feedback, such as code repair or agentic tool use.

Terms in this paper

  • Lean 4 · A programming language and proof assistant used to write and machine-check formal mathematical proofs
  • pass@k · An evaluation metric counting success if any of k sampled attempts verifies
  • compiler feedback · Error messages from the Lean compiler indicating where and why a proof attempt failed
  • pairwise comparison (LLM judge) · An LLM prompted to compare two candidate proofs and pick the one more likely to succeed
  • stagnation threshold (N) · The number of consecutive rejected refinements after which the system restarts exploration with fresh candidates

Figures we cannot republish

  • Figure 1: Overview of our framework. Exploration (left) generates two diverse candidates via a generalist and a specialist. Exploitation (right) maintains a single current-best proof s∗ and drives it toward verification: each repair produces a proposal, and an LLM judge decides whether to accept it. When refinement stagnates for N consecutive rounds, the system re-enters exploration and draws fresh candidates from both models. The Verification & Feedback layer (bottom) provides structured error feedback, tactic suggestions and verification signals.
  • Figure 2: Empirical refinement results of one theorem with different initial attempts. One theorem, 10 wrong proofs (WP) as starting points (rows), each iteratively refined 5 times (columns) with a 32-iteration budget. Cells show iterations to success; × marks failure. Theorem: Set_EAnnulus_oc_subset_co in carleson. More examples can be found in Figure 8 and Figure 9 in Appendix B.
  • Figure 3: Pass rate (%) vs. LLM calls across seven Lean 4 projects from miniCTX-v2. Gray dashed line is pass@32.
  • Figure 4: LLM cost breakdown under 32 average LLM calls. Specialist DeepSeek-Prover-V2-7B is self-hosted; its cost is estimated at the generalist’s per-token price (higher than the specialist) for a conservative comparison.
  • Figure 5: Pass rate (%) vs. LLM calls on RLMEval-FLT3 with informal proof guidance. Text labels show average calls from the generalist, specialist, and pairwise comparison (Cmp).
  • Figure 6: Ablation study results.
  • (b) Effect of pairwise comparison on call allocation and cost.
  • Figure 7: Pairwise comparison behavior on solved refinement trajectories. (a) Keep-current rate during successful refinement. (b) Final verification from preserved proof states.
  • Figure 8: Refinement heatmap for _isBigO_deriv_ofReal_cpow_const_atTop in the mathlib.
  • Figure 9: Refinement heatmap for eLpNorm_toReal_le in the Carleson.
  • Figure 10: LLM calls breakdown under 32 average LLM calls on miniCTX-v2 test.
  • Figure 11: Pass rate (%) vs. LLM calls on HepLean with GPT5.4-mini as the Generalist and Goedel-Prover-V2-8B as the Specialist.
  • Figure 12: Global refinement keep current rate on solved theorems (294 total steps).
See the figures in the original paper →

Original abstract (English)

Theorem proving in real-world Lean 4 projects is challenging because proofs often depend on project-specific context. While iterative refinement can use compiler errors to repair failed proofs, reusing failed attempts requires careful search control: some proofs provide better starting points than others, and later revisions may degrade a partially correct proof. We propose a compiler-guided proof search framework that balances exploration and exploitation. It explores diverse starting points through dual-model generation and stagnation-triggered resampling, while exploiting promising proof states through current-best refinement guided by compiler-grounded pairwise comparison. Experiments on seven real-world Lean 4 projects from miniCTX-v2 show that our method achieves a better effectiveness--efficiency tradeoff than pass@k baselines. Within the pass@32 budget, our method improves average pass rate by 12.8 percentage points while reducing LLM calls by 21.9%.

Authors · Zhuo Liu, Ding Yu, Hangfeng He

Read on arXiv

Latest papers

All papers →

Latest from METAL MEDIA