arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.26457cs.SEcs.AIcs.CLcs.PL
收藏

Verus-SpecGym: 用于评估规范自动形式化的智能体环境

Verus-SpecGym: An Agentic Environment for Evaluating Specification Autoformalization

CMU(卡内基梅隆大学);Amazon(亚马逊)

Anmol Agarwal, Natalie Neamtu, Pranjal Aggarwal, Seungone Kim, Jannis Limperg, Cedric Flamant, Kanna Shimizu, Bryan Parno, Sean Welleck

AI总结:

提出 Verus-SpecGym 环境与 Verus-SpecBench 基准,通过执行规范机制和对抗性测试评估 LLM 智能体将非正式编程问题转化为形式规范的能力,发现前沿模型可解决 77.8% 的任务但存在遗漏假设等脆弱性。

摘要:

AI 编码智能体越来越多地用于编写真实世界的软件,但确保其输出正确性仍然是一个基本挑战。形式化验证提供了一条有希望的路径:智能体生成代码的同时生成机器检查的证明,保证代码满足形式规范。然而,无法保证形式规范本身与用户意图一致。在这项工作中,我们研究规范自动形式化:LLM 智能体能否将非正式编程问题转化为忠实的形式规范。我们引入了 Verus-SpecBench,一个包含 581 个规范编写任务的基准,这些任务源自针对 Rust 验证器 Verus 的 Codeforces 问题,以及 Verus-SpecGym,一个智能体环境,模型在其中与 Verus、bash 和文件系统交互以开发这些规范。核心挑战在于评估:专家编写的参考规范编写成本高昂,LLM 评判者可能遗漏细微错误。我们通过以下方式解决这一问题:(a) 扩展 Verus 的 exec_spec 机制,使生成的规范可以作为 Rust 代码执行;(b) 针对官方 Codeforces 测试和从 Codeforces "hacks"(即竞争对手编写的用于破解不正确解决方案的边缘情况)中提取的对抗性案例进行测试。在 Verus-SpecBench 上,最强的模型 Gemini 3.1 Pro 解决了 77.8% 的任务,其他前沿模型解决了 51.1-57.8%,而开源模型仅达到 21.5-25.5%。我们对失败模式的分析表明,模型生成的规范可能遗漏重要的输入假设、接受不正确的输出以及拒绝有效的输出。我们还发现,LLM 作为评判者的评估遗漏了我们评估者捕获的 26% 的失败。总体而言,我们的结果表明,规范自动形式化对于前沿智能体来说是可行的,但即使在它们已经能够生成正确代码的问题上仍然脆弱。代码、数据和日志可在 https://github.com/formal-verif-is-cool/verus-spec-gym 获取。

英文摘要:

AI coding agents are increasingly used to write real-world software, but ensuring that their outputs are correct remains a fundamental challenge. Formal verification offers a promising path: an agent generates code together with a machine-checked proof, guaranteeing that the code satisfies a formal specification. However, there is no guarantee that the formal spec itself matches the user's intent. In this work, we study specification autoformalization: whether LLM agents can translate informal programming problems into faithful formal specifications. We introduce Verus-SpecBench, a benchmark of 581 spec-writing tasks derived from Codeforces problems targeting Verus, a verifier for Rust, and Verus-SpecGym, an agentic environment in which models interact with Verus, bash, & the filesystem to develop these specs. The central challenge is evaluation: expert-written reference specs are expensive to write, & LLM judges can miss subtle mistakes. We address this by (a) extending Verus's exec_spec mechanism so that generated specs can be executed as Rust code, & (b) testing them against official Codeforces tests & adversarial cases extracted from Codeforces "hacks", which are edge cases written by competitors to break incorrect solutions. On Verus-SpecBench, the strongest model, Gemini 3.1 Pro, solves 77.8% of tasks, other frontier models solve 51.1--57.8% & OSS models reach only 21.5--25.5%. Our analysis of failure modes shows that model-generated specs can omit important input assumptions, accept incorrect outputs, & reject valid ones. We also find that LLM-as-a-judge evaluation misses 26% of the failures our evaluator catches. Overall, our results suggest that spec autoformalization is within reach for frontier agents but remains brittle even on problems where they can already generate correct code. The code, data, & logs can be found at https://github.com/formal-verif-is-cool/verus-spec-gym

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

↑