arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2404.00762cs.SE
收藏

基于静态分析与程序验证的大型语言模型驱动的程序规约合成方法

Enchanting Program Specification Synthesis by Large Language Models using Static Analysis and Program Verification

Cheng Wen, Jialun Cao, Jie Su, Zhiwu Xu, Shengchao Qin, Mengda He, Haokun Li, Shing-Chi Cheung, Cong Tian

AI总结:

本文提出 AutoSpec 方法,结合静态分析、程序验证与大型语言模型,通过程序分解和逐轮验证迭代生成满足性且充分的程序规约,成功验证 79% 的程序,显著优于现有工作。

摘要:

形式化验证为保障软件系统的正确性与可靠性提供了一种严谨且系统化的方法。然而,为完整证明构造规约依赖于领域专业知识且需要大量人力。鉴于这一需求,亟需一种自动化的规约合成方法。现有自动化方法在通用性方面存在局限,即它们要么仅关注数值程序的循环不变式合成,要么针对特定类型的程序或不变量量身定制。涉及多种复杂数据类型(如数组、指针)和代码结构(如嵌套循环、函数调用)的程序通常超出其能力范围。为弥合这一差距,我们提出 AutoSpec,一种面向自动化程序验证的规约合成自动化方法。它克服了现有工作在规约通用性方面的不足,能够合成满足性且充分的规约以支持完整证明。该方法由静态分析和程序验证驱动,并借助大型语言模型(LLMs)增强能力。AutoSpec 通过三种方式应对实际挑战:(1)由静态分析和程序验证驱动 AutoSpec,LLMs 作为生成器生成候选规约;(2)对程序进行分解以引导 LLMs 的注意力;(3)在每一轮交互中对候选规约进行验证,以避免与 LLMs 交互过程中的错误累积。通过这种方式,AutoSpec 能够增量式、迭代地生成满足性且充分的规约。评估结果表明了其有效性和实用性,它优于现有工作,通过自动规约合成成功验证了 79% 的程序,实现了 1.592 倍的显著提升。该方法还可成功应用于验证一个真实的 X509 解析器项目中的程序。

英文摘要:

Formal verification provides a rigorous and systematic approach to ensure the correctness and reliability of software systems. Yet, constructing specifications for the full proof relies on domain expertise and non-trivial manpower. In view of such needs, an automated approach for specification synthesis is desired. While existing automated approaches are limited in their versatility, i.e., they either focus only on synthesizing loop invariants for numerical programs, or are tailored for specific types of programs or invariants. Programs involving multiple complicated data types (e.g., arrays, pointers) and code structures (e.g., nested loops, function calls) are often beyond their capabilities. To help bridge this gap, we present AutoSpec, an automated approach to synthesize specifications for automated program verification. It overcomes the shortcomings of existing work in specification versatility, synthesizing satisfiable and adequate specifications for full proof. It is driven by static analysis and program verification, and is empowered by large language models (LLMs). AutoSpec addresses the practical challenges in three ways: (1) driving \name by static analysis and program verification, LLMs serve as generators to generate candidate specifications, (2) programs are decomposed to direct the attention of LLMs, and (3) candidate specifications are validated in each round to avoid error accumulation during the interaction with LLMs. In this way, AutoSpec can incrementally and iteratively generate satisfiable and adequate specifications. The evaluation shows its effectiveness and usefulness, as it outperforms existing works by successfully verifying 79% of programs through automatic specification synthesis, a significant improvement of 1.592x. It can also be successfully applied to verify the programs in a real-world X509-parser project.

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

↑