paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Assertions for Free: Transferring Invariants from Algorithm to Implementation Proofs (Functional Pearl)

免费的断言:将不变式从算法证明转移到实现证明(函数式珍珠)
ICFP 10(ICFP)2026匹配度 3/10 · 论文属于程序验证/形式化验证,与用户关注的“AI→PL(利用LLM/Agent改进静态分析或形式化验证)”仅有边缘关联,因为该方法完全基于关系Hoare四元组与断言标注,未涉及LLM/Agent、ML/Agentic程序静态分析、浮点程序分析或贝叶斯程序分析等核心方向。引用 0 inbox
Shushu Wu, Chengxi Yang, Xiwei Wu, Qinxiang Cao
crossref: 2026-09-10

AI 速览

一句话:结合关系 Hoare 四元组与抽象程序断言标注,将算法层不变式转移到实现证明,简化验证。

验证复杂算法的真实代码功能正确性通常分为两层:具体代码精化抽象算法描述,以及证明抽象描述正确。但两层在实践中并不清晰分离:例如 KMP 验证中,实现正确性证明常需重新建立算法层已证性质,因为传统两层方法无法转移具体实现所依赖的不变式。本文提出两个简单想法实现干净分离:用关系 Hoare 四元组表达实现正确性,并在抽象程序中加入断言标注以捕获关键不变式。这样算法证明中建立的性质可直接转移到实现证明,无需重证。作者通过 KMP 模式匹配和深度优先搜索等非平凡案例展示,该方法使证明更简单、验证过程更模块化。

问题
真实代码的算法功能正确性验证难以清晰分离算法正确性与实现正确性,实现证明常需重复证明算法层不变式。
方法
将实现正确性表述为关系 Hoare 四元组,并在抽象程序内加入断言标注,以在两层间转移关键不变式。
评估
通过 KMP 模式匹配和深度优先搜索等非平凡案例研究,表明证明更简单且验证更模块化。
原文摘要(Abstract)

Verifying the functional correctness of real-world code with complex algorithms can be decomposed into two layers: verifying that the concrete code refines an abstract algorithmic description, and proving the correctness of the formal description. However, in practice the two layers do not stay cleanly separated. For example, in the verification of the Knuth-Morris-Pratt (KMP) algorithm, the implementation correctness proof often re-establishes algorithm properties that have already been proved, as the concrete implementation relies on invariants that the traditional two-layer method provides no mechanism to transfer. This makes it difficult to clearly separate the concerns of algorithm correctness and implementation correctness. In this pearl, we show how a clean separation can be achieved within the two-layer method by combining two simple ideas: expressing implementation correctness as a relational Hoare quadruple, and introducing assertion annotations into the abstract program to capture key invariants. Properties established in the algorithm proof are thereby transferred directly to the implementation proof, eliminating the need to re-prove them. We demonstrate the effectiveness of this approach through non-trivial case studies, including the Knuth-Morris-Pratt pattern-matching algorithm and the depth-first search algorithm, showing that it leads to simpler proofs and a more modular verification process.

链接与引用

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

BibTeX
@article{WuYWC26,
  title = {Assertions for Free: Transferring Invariants from Algorithm to Implementation Proofs (Functional Pearl)},
  author = {Shushu Wu and Chengxi Yang and Xiwei Wu and Qinxiang Cao},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {ICFP},
  year = {2026},
  doi = {10.1145/3828694}
}