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