arXiv:2507.15822cs.SEcs.AI2025-07被引 5

用形式化验证测试大模型能否真正修复代码漏洞,结果出人意料。

Do AI models help produce verified bug fixes?

  • 分两组程序员对比:一组用大模型,一组不用,均通过形式验证工具确认修复正确性。
  • 大模型组修复成功率未显著提升,且错误修复比例更高,反超预期。
  • 揭示了程序员使用大模型的7种模式,给出高效使用的实操建议。

在软件工程中,大型语言模型(LLM)有望显著提升自动程序修复(APR)的效果。但这一预期是否真实?如何验证修复是否真正有效?若程序员可使用LLM,他们实际如何结合自身能力?为此,我们利用一个程序证明环境,对两组随机分配的程序员展开研究:一组可使用LLM,另一组不可用,所有修复均通过形式化证明工具验证。研究采用目标-查询-度量(Goal-Query-Metric)框架,涵盖一般研究问题、具体可答要素和量化指标。尽管样本量有限,结果为界定AI与LLM在生成有保证正确性的代码修复中的角色迈出第一步。结果令人意外:使用大模型并未带来预期优势,甚至错误修复率更高。贡献包括:可复用的实验方法论;基于全会话记录的细粒度程序员行为分析;识别出7类大模型使用模式;以及优化调试与自动修复的实用建议。

原文摘要 · Abstract (English)

Among areas of software engineering where AI techniques -- particularly, Large Language Models -- seem poised to yield dramatic improvements, an attractive candidate is Automatic Program Repair (APR), the production of satisfactory corrections to software bugs. Does this expectation materialize in practice? How do we find out, making sure that proposed corrections actually work? If programmers have access to LLMs, how do they actually use them to complement their own skills? To answer these questions, we took advantage of the availability of a program-proving environment, which formally determines the correctness of proposed fixes, to conduct a study of program debugging with two randomly assigned groups of programmers, one with access to LLMs and the other without, both validating their answers through the proof tools. The methodology relied on a division into general research questions (Goals in the Goal-Query-Metric approach), specific elements admitting specific answers (Queries), and measurements supporting these answers (Metrics). While applied so far to a limited sample size, the results are a first step towards delineating a proper role for AI and LLMs in providing guaranteed-correct fixes to program bugs. These results caused surprise as compared to what one might expect from the use of AI for debugging and APR. The contributions also include: a detailed methodology for experiments in the use of LLMs for debugging, which other projects can reuse; a fine-grain analysis of programmer behavior, made possible by the use of full-session recording; a definition of patterns of use of LLMs, with 7 distinct categories; and validated advice for getting the best of LLMs for debugging and Automatic Program Repair.

自动修复大模型形式验证

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。