arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2311.03739cs.FLcs.AI
收藏

利用大型语言模型在 Rust 中自动合成证明

Leveraging Large Language Models for Automated Proof Synthesis in Rust

Columbia University(哥伦比亚大学);Microsoft Research(微软研究院)

Jianan Yao, Ziqiao Zhou, Weiteng Chen, Weidong Cui

AI总结:

本文提出结合大型语言模型和静态分析,为基于 Rust 的 Verus 形式化验证框架自动合成不变量和断言等证明结构,通过分解任务并迭代查询 GPT-4,显著降低了编写证明代码的人力成本。

摘要:

形式化验证可以可证明地保证关键系统软件的正确性,但高昂的证明负担长期以来阻碍了其广泛采用。最近,大型语言模型(LLMs)在代码分析和合成方面取得了成功。在本文中,我们提出了一种结合 LLMs 和静态分析的方法,为一个名为 Verus 的基于 Rust 的形式化验证框架合成不变量、断言和其他证明结构。在少样本设置下,LLMs 在生成后置条件和循环不变量方面表现出令人印象深刻的逻辑能力,尤其是在分析短代码片段时。然而,LLMs 缺乏保留和传播上下文信息的能力,而这正是传统静态分析的优势。基于这些观察,我们开发了一个基于 OpenAI 的 GPT-4 模型的原型。我们的原型将验证任务分解为多个较小的任务,迭代地查询 GPT-4,并将其输出与轻量级静态分析相结合。我们在自动化循环中由开发人员参与,对 20 个向量操作程序评估了该原型。结果表明,它显著减少了编写入门级证明代码所需的人力。

英文摘要:

Formal verification can provably guarantee the correctness of critical system software, but the high proof burden has long hindered its wide adoption. Recently, Large Language Models (LLMs) have shown success in code analysis and synthesis. In this paper, we present a combination of LLMs and static analysis to synthesize invariants, assertions, and other proof structures for a Rust-based formal verification framework called Verus. In a few-shot setting, LLMs demonstrate impressive logical ability in generating postconditions and loop invariants, especially when analyzing short code snippets. However, LLMs lack the ability to retain and propagate context information, a strength of traditional static analysis. Based on these observations, we developed a prototype based on OpenAI's GPT-4 model. Our prototype decomposes the verification task into multiple smaller ones, iteratively queries GPT-4, and combines its output with lightweight static analysis. We evaluated the prototype with a developer in the automation loop on 20 vector-manipulating programs. The results demonstrate that it significantly reduces human effort in writing entry-level proof code.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑