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:
- 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'$.
- Equivalence Certification: They use the Lean theorem prover to verify that $C$ and $C'$ are indeed behaviorally equivalent ($\forall x. C(x) = C'(x)$).
- 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
letintroductions. - 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.
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
unfoldtactic). If the function structure changes (e.g., a helper is added), theunfoldtactic fails. In contrast, specialized LLMs often generate "definitional bridges"—statements likehave 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
simpcall) 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 4 (Figure 5) further breaks down these gains, showing that the advantage holds across both structural and semantic refactoring classes.
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