paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Live Verification in an Interactive Proof Assistant

交互式证明助手中的实时验证
PLDI 8(PLDI)2024匹配度 3/10 · 该论文属于交互式定理证明与程序验证工具,涉及循环不变式和实时验证,但未涉及用户核心关注的 LLM/Agent 与静态分析/形式化验证的交叉,也不涉及浮点程序分析或贝叶斯程序分析。引用 3 inbox
Samuel Gruetter, Viktor Fukala, Adam Chlipala
crossref: 2026-09-10

AI 速览

一句话:在Coq中实现实时验证原型:逐行显示符号状态,并用diff形式表达循环不变式,边写代码边生成机器检查证明。

程序验证通常需要循环不变式,而手工书写繁琐、自动推断又不可靠。本文提出一个在交互式证明助手Coq中实现的实时验证原型:程序员每写一行代码,工具就尝试证明至此不存在未定义行为,并显示该行之后的符号状态摘要;用户可继续写代码,或通过特殊注释提示如何求解侧条件、如何更美观地表示符号状态。对于循环不变式,工具让用户以相对于循环前符号状态的diff来表达,介于全手工书写与全自动推断之间,有望得到更短、更易维护的证明。程序完成后即已获得机器检查的正确性证明;借助针对同一源语言语义验证过的编译器,可保证编译后程序行为与证明中的行为一致。多语言源文件可同时视为Coq或C文件,接受更大可信基时可用GCC编译。

问题
程序验证需要循环不变式,手工书写困难且繁琐,而自动推断又不可靠;现有实时反馈工具往往依赖较大的可信基,且只报告断言是否成立,不展示程序当前的符号状态。
方法
在Coq中实现实时验证原型:逐行检查无未定义行为并显示符号状态摘要,允许用特殊注释提供侧条件求解提示;循环不变式以相对于循环前符号状态的diff形式由用户表达。
评估
通过Coq原型为程序生成机器检查的正确性证明,并借助针对同一源语言语义经验证的编译器保证编译后行为与证明中行为一致;多语言源文件亦可作为C文件由GCC编译。
原文摘要(Abstract)

We present a prototype for a tool that enables programmers to verify their code as they write it in real-time. After each line of code that the programmer writes, the tool tells the programmer whether it was able to prove absence of undefined behavior so far, and it displays a concise representation of the symbolic state of the program right after the added line. The user can then either write the next line of code, or if needed or desired, write a specially marked comment that provides hints on how to solve side conditions or on how to represent the symbolic state more nicely. Once the programmer has finished writing the program, it is already verified with a mathematical correctness proof. Other tools providing real-time feedback already exist, but ours is the first one that only relies on a small trusted proof checker and that provides a concise summary of the symbolic state at the point in the program currently being edited, as opposed to only indicating whether user-stated assertions or postconditions hold. Program verification requires loop invariants, which are hard to find and tedious to spell out. We explore a middle ground in the design space between the two extremes of requiring users to spell out loop invariants manually and attempting to infer loop invariants automatically: Since a loop invariant often looks quite similar to the symbolic state right before the loop, our tool asks the user to express the desired loop invariant as a diff from the symbolic state before the loop, which has the potential to lead to shorter, more maintainable proofs. We prototyped our technique in the interactive proof assistant Coq, so our framework creates machine-checked proofs that the developed functions satisfy their specifications when executed according to the formal semantics of the source language. Using a verified compiler proven against the same source-language semantics, we can ensure that the behavior of the compiled program matches the program’s behavior as represented by the framework during the proof. Additionally, since our polyglot source files can be viewed as Coq or C files at the same time, users willing to accept a larger trusted code base can compile them with GCC.

链接与引用

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

BibTeX
@article{paperbot2501,
  title = {Live Verification in an Interactive Proof Assistant},
  author = {Samuel Gruetter and Viktor Fukala and Adam Chlipala},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {PLDI},
  year = {2024},
  doi = {10.1145/3656439}
}