一句话:扩展 Coq ITree 库,为分层单子解释器提供泛型提升与关系推理框架,消除样板并简化证明。
以解释自由单子操作构造的单子计算,是建模语言语义与效应系统的有力形式化方法;分层语义有望基于单子等式理论提供模块化推理。但层数增加会带来定义单子和解释器的样板与胶水代码,且每层等价关系的关系推理原则也需定义和论证,开销很大。本文显著扩展 Coq 的 interaction trees(ITrees)库:刻画一类可由单子变换器从 ITrees 获得的可解释单子,并支持解释器沿其泛型提升;还提出“单子模关系 R 等价”的关系推理框架,包含 typeclass、实例、新推理原则与 tactic。该工作推广了 ITree 库的现有理论,消除大量样板代码,大幅简化证明。
Monadic computations built by interpreting, or handling , operations of a free monad are a compelling formalism for modeling language semantics and defining the behaviors of effectful systems. The resulting layered semantics offer the promise of modular reasoning principles based on the equational theory of the underlying monads. However, there are a number of obstacles to using such layered interpreters in practice. With more layers comes more boilerplate and glue code needed to define the monads and interpreters involved. That overhead is compounded by the need to define and justify the relational reasoning principles that characterize the equivalences at each layer. This paper addresses these problems by significantly extending the capabilities of the Coq interaction trees (ITrees) library, which supports layered monadic interpreters. We characterize a rich class of interpretable monads ---obtained by applying monad transformers to ITrees---and show how to generically lift interpreters through them. We also introduce a corresponding framework for relational reasoning about "equivalence of monads up to a relation R". This collection of typeclasses, instances, new reasoning principles, and tactics greatly generalizes the existing theory of the ITree library, eliminating large amounts of unwieldy boilerplate code and dramatically simplifying proofs.
@article{paperbot1508,
title = {Formal reasoning about layered monadic interpreters},
author = {Irene Yoon and Yannick Zakowski and Steve Zdancewic},
journal = {Proceedings of the ACM on Programming Languages},
volume = {6},
number = {ICFP},
year = {2022},
doi = {10.1145/3547630}
}