一句话:提出 Hefty 代数,用语法重载为高阶代数效应建立模块化精化语义,并在 Agda 中形式化。
代数效应与处理器支持模块化编程,但高阶操作(以计算为参数)会破坏模块性:它们虽可编码为代数效应,却通常无法封装在接口中,实现精化时需改动程序与证明。本文提出 Hefty 代数,一个通过语法重载刻画高阶效应语义的形式框架,定义从高阶效应树到原始代数效应的模块化精化,并发展模块化高阶效应理论与推理原则。作者展示该框架可覆盖文献中多种已知高阶效应,并在 Agda 中形式化全部贡献。
Abstract Algebraic effects and handlers is an increasingly popular paradigm for programming with effects. A key benefit is modularity: programs with effects are defined against an interface of operations, allowing the implementation of effects to be defined and refined without changing or recompiling programs. The behavior of effects is specified using equational theories, with equational proofs inheriting the same modularity. However, higher-order operations (that take computations as arguments) break this modularity: while they can often be encoded in terms of algebraic effects, this typically breaks modularity as operations defined this way are not encapsulated in an interface, inducing changes to programs and proofs upon refinement of the implementation. In this paper, we show that syntactic overloading is a viable solution to this modularity problem by defining hefty algebras : a formal framework that captures an overloading-based semantics of higher-order effects by defining modular elaborations from higher-order effect trees into primitive algebraic effects. We demonstrate how this approach scales to define a wide range of known higher-order effects from the literature and develop modular higher-order effect theories and modular reasoning principles that build on and extend the state of the art in modular algebraic effect theories. We formalize our contributions in Agda.