让大模型生成可验证的正式证明,提升代码验证可靠性。
Neural Theorem Proving: Generating and Structuring Proofs for Formal Verification
- 用自然语言描述待验证代码,再由大模型生成正式证明。
- 在miniF2F测试中实现91.7%的证明成功率,验证通过率显著提升。
- 适合研究形式化验证与大模型推理能力的学者参考。
形式化验证软件代码属性是一项重要任务,尤其在大语言模型生成代码的背景下愈发关键。尽管代码专用模型已在Lean4和Isabelle中成功生成代码,但通用定理证明仍面临挑战,是衡量大模型推理能力的重要基准。本文提出一个框架,能够在正式语言中生成完整证明,并集成内置策略与现成自动定理证明器。该框架包含三部分:生成待验证代码的自然语言陈述、利用大模型生成形式化证明,以及基于启发式规则构建最终证明的模块。为训练大模型,采用两阶段微调:先通过SFT使模型生成语法正确的Isabelle代码,再通过强化学习(RL)训练,鼓励生成被定理证明器验证的正确证明。在miniF2F测试基准和Isabelle证明辅助系统上进行验证,并设计了针对AWS S3存储桶访问策略代码的验证用例。此外,基于FVEL\textsubscript{ER}数据集构建了新数据集,供未来训练使用。
原文摘要 · Abstract (English)
Formally verifying properties of software code has been a highly desirable task, especially with the emergence of LLM-generated code. In the same vein, they provide an interesting avenue for the exploration of formal verification and mechanistic interpretability. Since the introduction of code-specific models, despite their successes in generating code in Lean4 and Isabelle, the task of generalized theorem proving still remains far from being fully solved and will be a benchmark for reasoning capability in LLMs. In this work, we introduce a framework that generates whole proofs in a formal language to be used within systems that utilize the power of built-in tactics and off-the-shelf automated theorem provers. Our framework includes 3 components: generating natural language statements of the code to be verified, an LLM that generates formal proofs for the given statement, and a module employing heuristics for building the final proof. To train the LLM, we employ a 2-stage fine-tuning process, where we first use SFT-based training to enable the model to generate syntactically correct Isabelle code and then RL-based training that encourages the model to generate proofs verified by a theorem prover. We validate our framework using the miniF2F-test benchmark and the Isabelle proof assistant and design a use case to verify the correctness of the AWS S3 bucket access policy code. We also curate a dataset based on the FVEL\textsubscript{\textnormal{ER}} dataset for future training tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。