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


翻译:人工智能编程智能体正越来越多地被用于编写真实世界的软件,但确保其输出的正确性仍是一个根本性挑战。形式化验证提供了一条有前景的路径:智能体生成代码的同时附带机器验证的证明,从而保证代码满足形式化规范。然而,形式化规范本身是否与用户意图一致并无保障。本文研究规范自动形式化问题:即LLM智能体能否将非形式化编程问题转化为忠实的形式化规范。我们引入Verus-SpecBench基准,包含581个源自Codeforces问题的规范编写任务(针对Rust轻量级验证器Verus),以及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获取。

0
下载
关闭预览

相关内容

综述 | Self-Evolving Coding Agents:自进化编程智能体
通用智能体评估的逻辑架构
专知会员服务
23+阅读 · 2月28日
AI 智能体系统:体系架构、应用场景及评估范式
智能体工程(Agent Engineering)
专知会员服务
40+阅读 · 2025年12月31日
设计和构建强大的大语言模型智能体
专知会员服务
56+阅读 · 2024年10月6日
《人工智能安全测评白皮书》,99页pdf
专知
36+阅读 · 2022年2月26日
智能合约的形式化验证方法研究综述
专知
16+阅读 · 2021年5月8日
赛尔笔记 | 条件变分自编码器(CVAE)
AINLP
28+阅读 · 2019年11月8日
PlaNet 简介:用于强化学习的深度规划网络
谷歌开发者
13+阅读 · 2019年3月16日
NLP中自动生产文摘(auto text summarization)
机器学习研究会
14+阅读 · 2017年10月10日
国家自然科学基金
24+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
29+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
21+阅读 · 2013年12月31日
国家自然科学基金
19+阅读 · 2008年12月31日
VIP会员
最新内容
俄罗斯如何拦截乌克兰无人机与巡航导弹
专知会员服务
8+阅读 · 10月15日
《武器-目标分配问题:精确与近似求解算法》
专知会员服务
11+阅读 · 10月15日
综述|谁来改进机器人?迈向物理递归自我改进
专知会员服务
10+阅读 · 10月14日
软件定义无人机蜂群给防空带来全新压力
专知会员服务
10+阅读 · 10月13日
《半自主无人地面战车的互操作性》66页
专知会员服务
14+阅读 · 10月13日
相关VIP内容
综述 | Self-Evolving Coding Agents:自进化编程智能体
通用智能体评估的逻辑架构
专知会员服务
23+阅读 · 2月28日
AI 智能体系统:体系架构、应用场景及评估范式
智能体工程(Agent Engineering)
专知会员服务
40+阅读 · 2025年12月31日
设计和构建强大的大语言模型智能体
专知会员服务
56+阅读 · 2024年10月6日
相关基金
国家自然科学基金
24+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
29+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
21+阅读 · 2013年12月31日
国家自然科学基金
19+阅读 · 2008年12月31日
Top
微信扫码咨询专知VIP会员