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

依赖类型理论中单子等式推理的实用形式化

A Practical Formalization of Monadic Equational Reasoning in Dependent-type Theory

Reynald Affeldt, Jacques Garrigue, Takafumi Saikawa

AI总结:

该研究在Coq证明助手中以接口形式形式化单子效应层级与代数定律,分离定律与模型,结合Coq重写能力与引理库实现简洁程序证明,还可用于单子模型形式化及含引用ML子集的等式定律设计。

摘要:

借助单子(monad),人们可以用纯函数式编程语言对计算效应进行等式推理。尽管针对含效应程序的等式推理颇具价值,但它尚未成为主流,部分原因在于大型实例的纸笔证明难以维护。我们在Coq证明助手(Coq proof assistant)中提出了一种基于单子的效应层级形式化方法,让单子等式推理具备实用性。我们的核心思路是将效应层级与代数定律形式化为接口,这与依赖类型理论中代数层级的形式化方式一致。通过该方法,我们清晰地将等式定律与模型分离开来。随后我们可以利用Coq强大的重写能力,构建引理库以实现简洁的程序证明。我们还能借助所得框架利用Coq的数学理论,对单子模型进行形式化。本文中,我们阐释了如何对丰富的效应层级(非确定性、状态、概率等)进行形式化,如何将文献中的单子等式推理实例实现机械化,以及如何将我们的框架应用于含引用的ML子集的等式定律设计。

英文摘要:

One can perform equational reasoning about computational effects with a purely functional programming language thanks to monads. Even though equational reasoning for effectful programs is desirable, it is not yet mainstream. This is partly because it is difficult to maintain pencil-and-paper proofs of large examples. We propose a formalization of a hierarchy of effects using monads in the Coq proof assistant that makes monadic equational reasoning practical. Our main idea is to formalize the hierarchy of effects and algebraic laws as interfaces like it is done when formalizing hierarchy of algebras in dependent type theory. Thanks to this approach, we clearly separate equational laws from models. We can then take advantage of the sophisticated rewriting capabilities of Coq and build libraries of lemmas to achieve concise proofs of programs. We can also use the resulting framework to leverage on Coq's mathematical theories and formalize models of monads. In this article, we explain how we formalize a rich hierarchy of effects (nondeterminism, state, probability, etc.), how we mechanize examples of monadic equational reasoning from the literature, and how we apply our framework to the design of equational laws for a subset of ML with references.

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

↑