arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2601.12845cs.SE
收藏

利用LLMs和测试或acles自动生成形式规范和验证注解

Automatic Generation of Formal Specification and Verification Annotations Using LLMs and Test Oracles

Faculty of Engineering, University of Porto(波尔图大学工程学院);INESC TEC(TEC研究所);INESC-ID(ID研究所)

João Pascoal Faria, Emanuel Trigo, Vinicius Honorato, Rui Abreu

AI总结:

本文利用LLMs和测试或acles自动为Dafny程序生成形式规范和验证注解,实验表明该方法在多数情况下有效,并展示了IDE集成的可行性。

摘要:

最近的验证工具旨在通过自动化大部分验证过程,使形式验证更易于软件工程师使用。然而,为证明常规程序的正确性所需的正式规范和验证构造(前条件、后条件、循环不变式、辅助谓词和函数及证明辅助工具)的注解仍然需要大量的手动工作和专业知识。本文研究了LLMs如何自动为Dafny语言(一种验证感知编程语言)编写的程序生成此类注解,从常规代码及其自然语言规范(在注释中)和测试代码开始。在110个Dafny程序的实验中,结合Claude Opus 4.5和GPT-5.2的多模型方法在最多8次修复迭代内正确生成了98.2%的注解,使用验证器反馈。逻辑回归分析显示,证明辅助注解对当前LLMs的难题贡献不成比例。测试用例中的断言作为静态或acles,自动验证生成的前/后条件。我们还比较了生成的和手动的解决方案,并展示了如何扩展Visual Studio Code以将自动生成整合到IDE中,用户反馈令人鼓舞。

英文摘要:

Recent verification tools aim to make formal verification more accessible to software engineers by automating most of the verification process. However, annotating conventional programs with the formal specification and verification constructs (preconditions, postconditions, loop invariants, auxiliary predicates and functions and proof helpers) required to prove their correctness still demands significant manual effort and expertise. This paper investigates how LLMs can automatically generate such annotations for programs written in Dafny, a verification-aware programming language, starting from conventional code accompanied by natural language specifications (in comments) and test code. In experiments on 110 Dafny programs, a multimodel approach combining Claude Opus 4.5 and GPT-5.2 generated correct annotations for 98.2% of the programs within at most 8 repair iterations, using verifier feedback. A logistic regression analysis shows that proof-helper annotations contribute disproportionately to problem difficulty for current LLMs. Assertions in the test cases served as static oracles to automatically validate the generated pre/postconditions. We also compare generated and manual solutions and present an extension for Visual Studio Code to incorporate automatic generation into the IDE, with encouraging usability feedback.

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

↑