paperbot · PL 论文追踪

全部论文 待读 收藏

P0 Guiding LLM-Based Loop Invariant Synthesis via Feedback on Local Reasoning Errors

通过对局部推理错误的反馈引导基于 LLM 的循环不变式合成
TOPLAS 48(2)2026匹配度 9/10 · 论文将LLM用于循环不变式合成,并通过形式化验证其推理步骤、定位局部逻辑错误来提供反馈,属于“AI→PL:利用LLM/Agent改进静态分析/形式化验证”的核心方向。论文还实现了LORIS工具并在标准与非线性基准上评估,兼具形式化机制和工程实现,与用户画像高度匹配。引用 1 inbox
Tianchi Li, Zhenyu Yan, Junhao Liu, Peng Di, Xin Zhang
crossref: 2026-09-10

AI 速览

一句话:通过形式化验证 LLM 的推理步骤并定位局部逻辑错误,为其循环不变式合成提供建设性反馈,显著提升成功率。

LLM 在“猜测-检查”范式中合成循环不变式时,验证失败往往只返回布尔结果,模型难以定位自身推理中的具体逻辑错误。本文提出一个框架:先让 LLM 针对失败验证条件生成逐步自然语言证明,再用 LLM 将证明步骤翻译成一阶逻辑蕴含式并自动检查;无效蕴含即精确定位推理缺陷,据此构造针对性反馈进行精化。作者实现工具 LORIS,在 460 个 C 程序主基准与 50 个含非线性性质的 C 程序基准上评估,主基准解决 445 个程序,成功率达 93.1%,并在非线性基准上展现稳健性。

问题
LLM 在 guess-and-check 范式下合成循环不变式时,验证失败只给出粗粒度信号,模型无法获知自身推理链中错误的具体位置,导致反复试错效率低。
方法
让 LLM 为失败的验证条件写出逐步自然语言证明,再用 LLM 将其翻译为一阶逻辑蕴含式并自动检查;无效蕴含定位局部推理错误,进而生成针对性反馈以精化候选不变式。
评估
实现工具 LORIS,在 460 个 C 程序主基准和 50 个含非线性性质的 C 程序基准上评估;主基准解决 445 个程序,成功率达 93.1%,在非线性基准上也表现稳健。
原文摘要(Abstract)

We propose a novel framework that provides constructive feedback to an LLM in the “guess-and-check” paradigm by formally verifying its own thinking process and detecting local reasoning errors. We apply this framework to the loop invariant synthesis problem. We prompt the model to produce a step-by-step natural language proof justifying its thinking process for the failed verification condition of its generated loop invariants. Then, we use an LLM to translate the reasoning steps into first-order logic implications, which can be checked automatically. An invalid implication pinpoints the exact logical flaw in the LLM’s thinking process, which we then use to construct targeted feedback for refinement. We have implemented our approach in a tool called LORIS and evaluated it on a main benchmark suite of 460 C programs and an additional benchmark suite of 50 C programs each of which involves non-linear properties. On the main benchmark suite, LORIS solved 445 of the programs and achieved an overall success rate of 93.1%. LORIS also demonstrates robustness on the challenging non-linear benchmark suite.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@article{abs-2605-17914,
  title = {Guiding LLM-Based Loop Invariant Synthesis via Feedback on Local Reasoning Errors},
  author = {Tianchi Li and Zhenyu Yan and Junhao Liu and Peng Di and Xin Zhang},
  journal = {ACM Transactions on Programming Languages and Systems},
  volume = {48},
  number = {2},
  year = {2026},
  doi = {10.1145/3806652}
}