arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.13802cs.PLcs.LO
收藏

Coq 中的 While 循环

While Loops in Coq

David Nowak, Vlad Rusu

AI总结:

本文提出在 Coq 浅层嵌入的命令式语言中引入 while 循环的方法,通过一种可定义可能不终止递归函数的通用技术解决 Coq 对终止证明的要求,并以链表程序验证其有效性。

摘要:

While 循环几乎存在于所有命令式编程语言中。它们在实际应用中很重要(可执行事先未知次数的迭代),在理论上也很重要(可实现图灵完备性)。本文提出一种方法,将 while 循环纳入浅层嵌入 Coq 证明助手中的命令式语言。主要困难在于证明 while 循环的终止性并非易事,在非终止情况下甚至不可能,而 Coq 只接受带有终止证明的程序。我们的解决方案基于一种新的通用方法,用于在 Coq 中定义可能不终止的递归函数。我们通过证明一个链表程序的终止性和部分正确性来说明该方法。

英文摘要:

While loops are present in virtually all imperative programming languages. They are important both for practical reasons (performing a number of iterations not known in advance) and theoretical reasons (achieving Turing completeness). In this paper we propose an approach for incorporating while loops in an imperative language shallowly embedded in the Coq proof assistant. The main difficulty is that proving the termination of while loops is nontrivial, or impossible in the case of non-termination, whereas Coq only accepts programs endowed with termination proofs. Our solution is based on a new, general method for defining possibly non-terminating recursive functions in Coq. We illustrate the approach by proving termination and partial correctness of a program on linked lists.

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

↑