AutoACSL: 通过集成LLM与基于CPG的静态分析来综合ACSL规范
AutoACSL: Synthesizing ACSL Specifications by Integrating LLMs with CPG-Based Static Analysis
AI总结:
提出AutoACSL框架,结合大语言模型与代码属性图语义特征,通过反馈驱动循环自动生成可验证的ACSL规范,在604个程序上达到98%生成成功率和96%完全证明率。
摘要:
为C程序生成形式化规范仍然是形式化验证中的一个挑战,因为它需要手动工作、专业知识和语义精度。尽管大语言模型(LLM)的最新进展为自动化规范综合带来了希望,但当前方法通常缺乏语义深度,并产生不可验证或不完整的契约。为了解决这些限制,我们引入了AutoACSL,这是一个新颖的框架,它将LLM提示与从代码属性图(CPG)中提取的语义特征相结合。AutoACSL执行静态分析以提取关键语义元素,包括算术运算、循环和递归结构以及返回值传播,这些元素被编码为结构化提示。这些提示使LLM不仅能够生成正常行为规范,还能包含防止导致运行时错误的输入的约束。AutoACSL采用反馈驱动的综合循环,其中候选规范使用Frama-C/WP进行验证,并迭代优化,直到验证成功或达到终止条件。在来自不同数据集的604个程序上评估,AutoACSL与Gemini-3配对时实现了98%的规范生成成功率和96%的完全证明率。与仅代码基线相比,AutoACSL在四个LLM(GPT-o4 Mini、GPT-5.2、Grok-4.1和Gemini-3)上将完全证明率提高了24.7%至51.7%,表明将大语言模型与基于CPG的静态分析相结合显著增强了自动ACSL规范综合的生成鲁棒性和验证有效性。
英文摘要:
Generating formal specifications for C programs remains a challenge in formal verification due to the manual effort, expertise, and semantic precision required. While recent advancements in large language models (LLMs) offer promise in automating specification synthesis, current approaches often lack semantic depth and produce unverifiable or incomplete contracts. To address these limitations, we introduce AutoACSL, a novel framework that integrates LLM prompting with semantic features extracted from Code Property Graphs (CPGs). AutoACSL performs static analyses to extract key semantic elements, including arithmetic operations, loop and recursion structures, and return value propagation, which are encoded into structured prompts. These prompts enable the LLM not only to generate normal behavioral specifications but also to include constraints that prevent inputs leading to runtime errors. AutoACSL employs a feedback-driven synthesis loop, where candidate specifications are verified using Frama-C/WP and refined iteratively until verification succeeds or a termination condition is met. Evaluated on 604 programs drawn from diverse datasets, AutoACSL achieves a 98% specification generation success ratio and a 96% full proof ratio when paired with Gemini-3. Compared to a code-only baseline, AutoACSL improves the full proof ratio by 24.7% to 51.7% across four LLMs (GPT-o4 Mini, GPT-5.2, Grok-4.1, and Gemini-3), demonstrating that integrating large language models with CPG-based static analysis substantially enhances both generation robustness and verification effectiveness for automated ACSL specification synthesis.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。