Specification synthesis, the task of automatically inferring formal specifications from program implementations and natural language, is important for refactoring, transpilation, optimization, and verification, yet remains an open challenge for large C++ repositories. Existing LLM-based approaches fail to simultaneously scale to such repositories, produce specifications expressive enough to capture systems-code features such as dynamic memory and heap-allocated data structures, and systematically validate those specifications to rule out incorrect candidates. We present Spec-Agent, an agentic system for synthesizing expressive, well-validated specifications across large C++ codebases. Spec-Agent targets a ladder of specification languages: propositional logic, first-order logic, propositional separation logic, and first-order separation logic. For each function, Spec-Agent uses static analysis and runtime heap tracing to select the appropriate target specification language, generalizes existing functional tests into fuzz harnesses, and iteratively refines LLM-generated candidates via counterexample-guided feedback. We evaluate Spec-Agent on open source C++ codebases comprising millions of lines of code. Spec-Agent synthesizes valid specifications for 85% of target functions, with no false positives observed under fuzzing and expert validation, outperforming Claude Code Opus 4.6 at 10x lower token cost.


翻译:规范合成——即从程序实现和自然语言中自动推断形式化规范的任务——对于重构、转译、优化和验证至关重要,然而在大型C++代码仓库中仍是一个开放性挑战。现有基于大语言模型的方法无法同时满足以下需求:扩展到此类代码仓库、生成足以描述系统代码特征(如动态内存和堆分配数据结构)的表达性规范、以及系统化验证这些规范以剔除错误候选。我们提出Spec-Agent,一个面向大型C++代码库、用于合成表达性强且经过充分验证的规范的智能体系统。Spec-Agent针对一系列规范语言:命题逻辑、一阶逻辑、命题分离逻辑和一阶分离逻辑。对于每个函数,Spec-Agent通过静态分析和运行时堆追踪选择合适的规范语言目标,将现有功能测试泛化为模糊测试工具,并通过反例引导的反馈迭代优化LLM生成的候选规范。我们在包含数百万行代码的开源C++代码库上评估了Spec-Agent。Spec-Agent为85%的目标函数合成了有效规范,在模糊测试和专家验证下未观察到误报,性能优于Claude Code Opus 4.6的同时将代币消耗降低了10倍。

0
下载
关闭预览

相关内容

智能体技能综合综述:分类、技术与应用
专知会员服务
35+阅读 · 5月11日
《大语言模型的数据合成与增强综述》
专知会员服务
44+阅读 · 2024年10月19日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
智能合约的形式化验证方法研究综述
专知
16+阅读 · 2021年5月8日
一文了解成分句法分析
人工智能头条
15+阅读 · 2019年4月24日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
Arxiv
0+阅读 · 5月20日
VIP会员
最新内容
《无人机脆弱性利用:网络空间力量的新域》
专知会员服务
2+阅读 · 8月1日
美空军如何将人工智能从战场部署至后方机关
专知会员服务
11+阅读 · 7月31日
《史诗怒火行动:多域前瞻评估》49页报告
专知会员服务
7+阅读 · 7月31日
《英国防部:未来空战系统数字化战略》33页
专知会员服务
5+阅读 · 7月31日
《面向自主飞行网络的智能体人工智能架构》
专知会员服务
7+阅读 · 7月31日
“史诗怒火”行动:现代多域作战的重要节点
专知会员服务
8+阅读 · 7月30日
《下一代无线网络中的多无人机通信资源管理》
相关VIP内容
智能体技能综合综述:分类、技术与应用
专知会员服务
35+阅读 · 5月11日
《大语言模型的数据合成与增强综述》
专知会员服务
44+阅读 · 2024年10月19日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
Top
微信扫码咨询专知VIP会员