paperbot · PL 论文追踪

全部论文 待读 收藏

P2 CHAD: Combinatory Homomorphic Automatic Differentiation

CHAD:组合子同态自动微分
TOPLAS 44(3)2022匹配度 3/10 · 论文提出一种可证明正确的自动微分源到源变换,属于程序语言理论与编译优化,与用户关注的静态分析、LLM/Agent 以及浮点/贝叶斯程序分析交叉较少;虽涉及形式化验证,但未直接面向 ML 系统或 Agentic 程序中的静态分析,也无 LLM 相关。引用 13 inbox
Matthijs Vákár, Tom Smeding
crossref: 2026-09-10

AI 速览

一句话:提出 CHAD,一种纯函数式、类型保持且可证明正确的前向/反向自动微分源到源变换方法。

论文提出 CHAD,一种面向具有丰富特性编程语言的纯函数式、可证明正确的前向与反向自动微分方法。它将 AD 实现为保持类型的源代码变换,生成纯函数式代码,并且被刻画为 Elliott 一阶函数式语言 AD 定义在更丰富语言上的唯一同态扩展。正确性由组合式逻辑关系证明:语法导数的语义等于原程序语义的通常微积分导数。CHAD 的优雅表述使用线性类型,但实际变换可在缺少线性类型的标准函数式语言中实现,并用模块系统的抽象类型模拟线性类型以保证类型安全。论文以操作静态大小数组的高阶语言为例详细说明,并讨论推广到其他函数式语言特性及累积交换幺半群的动态程序分析。

问题
如何为具有丰富特性的编程语言提供组合、类型保持且可证明正确的前向与反向自动微分,并保持其同态性?
方法
将 AD 定义为源代码到源代码的变换,作为 Elliott 一阶 AD 定义的唯一同态扩展;用线性类型给出优雅表述,并通过组合式逻辑关系证明其语义正确性,还说明可用抽象类型在普通函数式语言中模拟线性类型。
评估
在一个操作静态大小数组的高阶语言上详细实例化该方法,论证其可推广到其他函数式特性,并讨论其在交换幺半群累积数据类动态程序分析中的扩展。
原文摘要(Abstract)

We introduce Combinatory Homomorphic Automatic Differentiation (CHAD), a principled, pure, provably correct define-then-run method for performing forward and reverse mode automatic differentiation (AD) on programming languages with expressive features. It implements AD as a compositional, type-respecting source-code transformation that generates purely functional code. This code transformation is principled in the sense that it is the unique homomorphic (structure preserving) extension to expressive languages of Elliott’s well-known and unambiguous definitions of AD for a first-order functional language. Correctness of the method follows by a (compositional) logical relations argument that shows that the semantics of the syntactic derivative is the usual calculus derivative of the semantics of the original program. In their most elegant formulation, the transformations generate code with linear types. However, the code transformations can be implemented in a standard functional language lacking linear types: While the correctness proof requires tracking of linearity, the actual transformations do not. In fact, even in a standard functional language, we can get all of the type-safety that linear types give us: We can implement all linear types used to type the transformations as abstract types by using a basic module system. In this article, we detail the method when applied to a simple higher-order language for manipulating statically sized arrays. However, we explain how the methodology applies, more generally, to functional languages with other expressive features. Finally, we discuss how the scope of CHAD extends beyond applications in AD to other dynamic program analyses that accumulate data in a commutative monoid.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1606,
  title = {CHAD: Combinatory Homomorphic Automatic Differentiation},
  author = {Matthijs Vákár and Tom Smeding},
  journal = {ACM Transactions on Programming Languages and Systems},
  volume = {44},
  number = {3},
  year = {2022},
  doi = {10.1145/3527634}
}