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

交互树:在Coq中表示递归和不纯程序

Interaction Trees: Representing Recursive and Impure Programs in Coq

Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, Steve Zdancewic

摘要:

“交互树”(ITrees)是一种通用的数据结构,用于表示与其环境交互的递归程序的行为。作为“自由单子”的共归纳变体,ITree是由未解释的事件及其延续构建的。它们支持从“事件处理程序”组合构造解释器,事件处理程序通过将事件的语义定义为一元操作来赋予事件意义。ITrees的表达能力足以代表不纯的和潜在的非终止的,相互递归的计算,同时承认一个丰富的等价方程理论弱互模拟。与其他方法(如关系指定的操作语义)相比,ITree可通过代码提取执行,使其适合于调试、测试和实现服从形式化验证的软件工件。我们已经实现了ITrees和他们的相关理论作为一个Coq库,机械化经典域和范畴理论的结果,程序语义,迭代,一元结构,和方程推理。虽然库的内部严重依赖于共归纳证明,但接口隐藏了这些细节,以便客户可以使用和推理ITrees,而无需明确使用Coq的共归纳策略。为了展示我们理论的实用性,我们证明了编译器从简单的命令式源语言到类似汇编的目标(其含义以基于ITree的指称语义给出)的终止敏感正确性。与以前的结果使用操作技术,我们的互模拟证明如下直接通过控制流图的组合子的方程理论的结构归纳和初等重写。

英文摘要:

"Interaction trees" (ITrees) are a general-purpose data structure for representing the behaviors of recursive programs that interact with their environments. A coinductive variant of "free monads," ITrees are built out of uninterpreted events and their continuations. They support compositional construction of interpreters from "event handlers", which give meaning to events by defining their semantics as monadic actions. ITrees are expressive enough to represent impure and potentially nonterminating, mutually recursive computations, while admitting a rich equational theory of equivalence up to weak bisimulation. In contrast to other approaches such as relationally specified operational semantics, ITrees are executable via code extraction, making them suitable for debugging, testing, and implementing software artifacts that are amenable to formal verification. We have implemented ITrees and their associated theory as a Coq library, mechanizing classic domain- and category-theoretic results about program semantics, iteration, monadic structures, and equational reasoning. Although the internals of the library rely heavily on coinductive proofs, the interface hides these details so that clients can use and reason about ITrees without explicit use of Coq's coinduction tactics. To showcase the utility of our theory, we prove the termination-sensitive correctness of a compiler from a simple imperative source language to an assembly-like target whose meanings are given in an ITree-based denotational semantics. Unlike previous results using operational techniques, our bisimulation proof follows straightforwardly by structural induction and elementary rewriting via an equational theory of combinators for control-flow graphs.

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

↑