NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

How Stable Are LLM-Generated Proofs Under Program Refactoring? A Stress Test for Verifiable Code Generation

Aravind Mandiga, Guoming LiarXiv 2026

TL;DR

Machine-checked proofs ensure code correctness, but they are notoriously brittle when the underlying code is refactored. This paper introduces RefactorProof, a benchmark that reveals a surprising trend: specialized LLM provers (like DeepSeek-Prover and Goedel-Prover) actually produce proofs that are significantly more stable under program refactoring than human-written reference proofs, largely due to their reliance on "definitional bridges" rather than explicit syntax unfolding.

What Problem Does This Paper Address?

In formal verification, a proof is a mathematical guarantee that a program satisfies its specification. However, real-world software is rarely static; it undergoes constant refactoring—renaming variables, extracting helper functions, or reordering logic—that preserves behavior but changes the code's structure.

Current benchmarks for verifiable code generation typically evaluate a model's ability to generate a proof for a single, fixed implementation. The authors argue this is insufficient. If a proof breaks every time a developer performs a minor refactoring, the cost of proof maintenance becomes prohibitive. The paper investigates whether LLM-generated proofs are more or less "brittle" than human-written ones when the code changes but the behavior remains identical.

Methods

The authors developed a pipeline called RefactorProof to stress-test proof stability. The process follows these steps:

  1. Refactoring: They take a task from the VERINA benchmark (Implementation $C$, Specification $S$, Proof $P$) and mechanically apply one of five deterministic transformations ($T1$–$T5$) to create a new implementation $C'$.
  2. Equivalence Certification: They use the Lean theorem prover to verify that $C$ and $C'$ are indeed behaviorally equivalent ($\forall x. C(x) = C'(x)$).
  3. Survival Evaluation: They attempt to verify the original, unchanged proof $P$ against the new implementation $C'$ and the original specification $S$.

The transformations are grouped into three classes:

  • Definitional (D): Simple let introductions.
  • Structural (S): Extracting code into private helper functions or branches.
  • Semantic (E): Swapping commutative operands or inverting conditionals.

The core metric is the Proof Survival Rate (PSR): the fraction of certified refactorings where the original proof still verifies without any changes.

Evaluation pipeline and a T2 helper-extraction example

Datasets

  • VERINA: The primary source benchmark containing 189 tasks.
  • RefactorProof: A new benchmark derived from VERINA, consisting of 458 certified variants across 185 tasks.
  • Reference Proofs: 46 human-written proofs provided by the VERINA authors for quality assurance.
  • Model Proofs: Generated using specialized provers (DeepSeek-Prover-V2-7B, Goedel-Prover-V2-8B/32B) and general models (Qwen3-14B/32B).

Key Insights and Ideas

  • The "Definitional Bridge" Advantage: Human-written reference proofs are highly brittle because they often start by explicitly "unfolding" the function definition (using the unfold tactic). If the function structure changes (e.g., a helper is added), the unfold tactic fails. In contrast, specialized LLMs often generate "definitional bridges"—statements like have h : f args = body := rfl—which leverage Lean's internal reduction engine to bridge the gap between the function call and its body, making them much more robust to structural changes.
  • Structural Brittleness: Structural refactorings (like helper extraction) are the most "deadly" for proofs. The PSR for reference proofs on structural changes was a dismal 4.3%, while specialized provers managed 13.3–26.8%.
  • Stability $\neq$ Repair Cost: The authors found that even when a proof "breaks," it is often very easy to fix. A simple one-identifier edit (e.g., adding the new helper name to a simp call) repaired the majority of failures. This suggests that while LLM proofs are more stable, the maintenance effort for broken proofs might be similar across sources.

Key Results

The specialized provers significantly outperformed human reference proofs in terms of stability on matched tasks:

  • DeepSeek-Prover-V2-7B: +15.6 points higher PSR than reference.
  • Goedel-Prover-V2-32B: +18.8 points higher PSR.
  • Goedel-Prover-V2-8B: +20.3 points higher PSR.

As shown in Table 5 (Figure 4), the stylistic difference is stark: reference proofs use unfold 97.8% of the time, whereas specialized provers use simp (a more automated, robust tactic) in roughly 80% of cases.

Table 5: Tactic profile of the fixed reference and specialized-prover proof artifacts.

Table 4 (Figure 5) further breaks down these gains, showing that the advantage holds across both structural and semantic refactoring classes.

Table 4: Matched model versus supplied-reference comparison on identical certified variants. Values are paired PSR differences with task-cluster bootstrap 95% CIs. Overall sensitivity checks remain positive: excluding T1 gives +24.3, +32.9, and +31.3 points for DeepSeek-7B, Goedel-8B, and Goedel-32B; family-balanced aggregation gives +13.7, +18.6, and +17.3 points. PSR columns are rounded independently; ∆PSR is computed from the unrounded task-level values. Appendix A reports full sensitivity results.

Limitations and Future Work

  • Task Complexity: The matched comparisons were performed on a subset of relatively short, non-recursive tasks. It remains to be seen if these stability trends hold for complex, deeply recursive algorithms.
  • Transformation Scope: The study only used five specific types of refactoring. Real-world refactoring often involves algorithmic changes or data representation shifts that were not covered.
  • Benchmark Exposure: Since VERINA is public, the models might have seen these tasks during pre-training, potentially inflating their initial coverage, though the refactored variants were generated specifically for this study.
  • Future Direction: The authors suggest that future verifiable code benchmarks should move beyond "one-time verification" and incorporate stability metrics like PSR to encourage the generation of maintainable formal artifacts.

Summary updated

BibTeX
@misc{mandiga2026how,
  author = {Aravind Mandiga and Guoming Li},
  title = {{How Stable Are LLM-Generated Proofs Under Program Refactoring? A Stress Test for Verifiable Code Generation}},
  year = {2026},
  eprint = {2610.36328},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.36328},
}
Figure