arXiv:2606.03743cs.AI2026-06

用分阶段流程重构大模型生成的证明,让代码更模块化易读。

Proof-Refactor: Refactoring Generated Formal Proofs into Modular Artifacts

论文配图:Proof-Refactor: Refactoring Generated Formal Proofs into Modular Artifacts
图 1 · 摘自论文原文
  • 分四步重构:提取片段、设计辅助声明、验证组件、修复原证明。
  • 在PutnamBench和Putnam2025上,可读性和结构评分显著优于基线。
  • 不依赖长度指标,更适合提升证明的可维护与复用性,适合形式化数学研究者。

尽管大型语言模型(LLMs)在生成形式化证明方面表现优异,但其输出通常不如成熟形式数学库中的证明那样可读、模块化、可维护和可复用。我们指出,这一差距部分源于大多数证明生成流程中隐含的‘编译优先’目标,导致生成的证明脚本趋于单体或临时性。现有改进方法多依赖显式的可计算优化目标,但实践中最可行且实验验证有效的仍是基于长度的指标,而可读性、模块化、可维护性和可复用性等高层次质量难以转化为可靠的自动度量。为此,我们提出一个受人类证明重构工作流启发的过程引导框架——Proof-Refactor。该框架将证明重构分解为四个阶段:提取候选证明片段、设计辅助声明、形式化证明提取与设计的组件、使用已验证组件修复原证明。在PutnamBench和Putnam2025生成的Lean证明上,Proof-Refactor在人工评估的重构评分上优于强基线模型Claude Code,尤其在签名质量与人类可读性上提升显著。结果表明,过程引导的重构可在不以证明长度为主要目标的前提下,有效改善证明结构。

原文摘要 · Abstract (English)

While Large Language Models (LLMs) have shown strong performance in generating formal proofs, their outputs often remain less readable, modular, maintainable, and reusable than proofs in mature formal mathematics libraries. We argue that this gap stems in part from the compile-first objective implicit in most proof-generation pipelines, which encourages monolithic or ad hoc proof scripts rather than library-quality artifacts. Existing approaches to proof-quality improvement often rely on explicit, computable optimization objectives. In practice, however, the most tractable and experimentally validated objectives are largely length-based, while higher-level qualities such as readability, modularity, maintainability, and reusability are difficult to reduce to reliable automatic metrics. Instead of optimizing proof improvement against a single proxy metric, we take a process-guided approach inspired by human proof-refactoring workflows. We propose an agentic framework $\textbf{Proof-Refactor}$ that decomposes proof refactoring into four phases: extracting candidate proof fragments, designing helper declarations, formally proving the extracted and designed components, and repairing the original proof using the verified components. On generated Lean proofs from PutnamBench and Putnam2025, Proof-Refactor improves rubric-based refactoring scores over a strong Claude Code refactoring baseline, with the largest gains in signature quality and human readability. These results suggest that process-guided refactoring can improve proof structure without treating proof length as the primary objective.

形式化证明代码重构大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。