arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.08494cs.LOcs.PL
收藏

通过受保护精化实现几乎必然终止

Almost-Sure Termination by Guarded Refinement

Simon Oddershede Gregersen, Alejandro Aguirre, Philipp G. Haselwarter, Joseph Tassarotti, Lars Birkedal

AI总结:

本文提出Caliper,一种基于受保护递归和概率耦合的高阶分离逻辑,通过证明程序与简单模型间的精化来建立概率程序的几乎必然终止,并在Coq中验证多个示例。

摘要:

几乎必然终止是概率程序的一个重要正确性属性,为此已开发了许多程序逻辑来证明该属性。然而,这些逻辑大多是为使用特定循环语法模式的语言编写的一阶程序而开发的。在本文中,我们考虑具有一般引用的高阶概率程序的几乎必然终止。这种特性组合允许通过多种模式对递归和循环进行编码。因此,我们不是为特定递归模式开发推理规则,而是提出一种基于证明高阶程序与更简单概率模型之间精化的方法,使得精化保留终止行为。通过证明精化,可以通过分析更简单的模型来建立程序的几乎必然终止行为。我们以Caliper的形式呈现这种方法,这是一种用于证明保留终止精化的高阶分离逻辑。Caliper使用概率耦合在程序与模型之间进行关系推理。为了处理高阶程序中发现的递归模式范围,Caliper使用受保护递归,特别是Löb归纳原理。一个技术新颖之处在于,Caliper不需要使用超限步索引或先前关于受保护递归用于保留终止精化的工作中发现的其他技术限制。我们通过证明几个示例的几乎必然终止来展示这种方法的灵活性,包括一阶循环结构、随机列表生成器、treap以及使用高阶存储的Galton-Watson树采样器。所有结果已在Coq证明助手中机械化。

英文摘要:

Almost-sure termination is an important correctness property for probabilistic programs, and a number of program logics have been developed for establishing it. However, these logics have mostly been developed for first-order programs written in languages with specific syntactic patterns for looping. In this paper, we consider almost-sure termination for higher-order probabilistic programs with general references. This combination of features allows for recursion and looping to be encoded through a variety of patterns. Therefore, rather than developing proof rules for reasoning about particular recursion patterns, we instead propose an approach based on proving refinement between a higher-order program and a simpler probabilistic model, in such a way that the refinement preserves termination behavior. By proving a refinement, almost-sure termination behavior of the program can then be established by analyzing the simpler model. We present this approach in the form of Caliper, a higher-order separation logic for proving termination-preserving refinements. Caliper uses probabilistic couplings to carry out relational reasoning between a program and a model. To handle the range of recursion patterns found in higher-order programs, Caliper uses guarded recursion, in particular the principle of Löb induction. A technical novelty is that Caliper does not require the use of transfinite step indexing or other technical restrictions found in prior work on guarded recursion for termination-preservation refinement. We demonstrate the flexibility of this approach by proving almost-sure termination of several examples, including first-order loop constructs, a random list generator, treaps, and a sampler for Galton-Watson trees that uses higher-order store. All the results have been mechanized in the Coq proof assistant.

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

↑