用自演化机制让AI自动写出可靠的Rust代码证明
Automated Proof Generation for Rust Code via Self-Evolution
- 构建自演化循环,用符号验证器筛选真假证明
- 生成数万条合成证明,使模型准确率提升至52.52%
- 适合想自动化验证Rust代码的开发者和研究者
确保代码正确性对代码生成至关重要。形式化验证能提供确定性保证,但需大量人工编写证明,亟需自动化。主要障碍是真实证明数据稀缺——可用于训练大语言模型的证明远少于代码片段。本文提出SAFE框架,通过自演化机制克服证明数据不足问题,实现Rust代码的自动化证明生成。SAFE建立数据合成与微调协同的闭环,利用符号验证器区分真伪证明。同时,将大量合成的错误证明用于训练模型的自我调试能力,使其根据验证反馈修正错误。在人类专家设计的基准测试中,SAFE达到52.52%的准确率,显著优于GPT-4o的14.39%。通过数万条合成证明与自调试机制,成功提升开源模型在形式化验证上的能力。
原文摘要 · Abstract (English)
Ensuring correctness is crucial for code generation. Formal verification offers a definitive assurance of correctness, but demands substantial human effort in proof construction and hence raises a pressing need for automation. The primary obstacle lies in the severe lack of data-there is much fewer proofs than code snippets for Large Language Models (LLMs) to train upon. In this paper, we introduce SAFE, a framework that overcomes the lack of human-written proofs to enable automated proof generation of Rust code. SAFE establishes a self-evolving cycle where data synthesis and fine-tuning collaborate to enhance the model capability, leveraging the definitive power of a symbolic verifier in telling correct proofs from incorrect ones. SAFE also re-purposes the large number of synthesized incorrect proofs to train the self-debugging capability of the fine-tuned models, empowering them to fix incorrect proofs based on the verifier's feedback. SAFE demonstrates superior efficiency and precision compared to GPT-4o. Through tens of thousands of synthesized proofs and the self-debugging mechanism, we improve the capability of open-source models, initially unacquainted with formal verification, to automatically write proofs for Rust code. This advancement leads to a significant improvement in performance, achieving a 52.52% accuracy rate in a benchmark crafted by human experts, a significant leap over GPT-4o's performance of 14.39%.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。