Unraveling the iterative CHAD
Nunes, Fernando Lucatelli, Plotkin, Gordon, Vákár, Matthijs
–arXiv.org Artificial Intelligence
Combinatory Homomorphic Automatic Differentiation (CHAD) was originally formulated as a semantics-driven source-to-source transformation for reverse-mode AD of total (terminating) functional programs. In this work, we extend CHAD to encompass programs featuring constructs such as partial (potentially non-terminating) operations, data-dependent conditionals (e.g., real-valued tests), and iteration constructs (i.e. while-loops), while maintaining CHAD's core principle of structure-preserving semantics. A central contribution is the introduction of iteration-extensive indexed categories, which provide a principled integration of iteration into dependently typed programming languages. This integration is achieved by requiring that iteration in the base category lifts to parameterized initial algebras in the indexed category, yielding an op-fibred iterative structure that models while-loops and other iteration constructs in the total category, which corresponds to the category of containers of our dependently typed language. Through the idea of iteration-extensive indexed categories, we extend the CHAD transformation to looping programs as the unique structure-preserving functor in a suitable sense. Specifically, it is the unique iterative Freyd category morphism from the iterative Freyd category corresponding to the source language to the category of containers obtained from the target language, such that each primitive operation is mapped to its (transposed) derivative. We establish the correctness of this extended transformation via the universal property of the syntactic categorical model of the source language, showing that the differentiated programs compute correct reverse-mode derivatives of their originals.
arXiv.org Artificial Intelligence
Aug-15-2025
- Country:
- Europe
- France > Île-de-France
- Netherlands (0.04)
- Portugal > Coimbra
- Coimbra (0.04)
- United Kingdom > England
- Cambridgeshire > Cambridge (0.04)
- Oxfordshire > Oxford (0.04)
- Somerset > Bath (0.04)
- North America > United States
- California
- Monterey County > Pacific Grove (0.04)
- Santa Barbara County > Santa Barbara (0.04)
- New York > New York County
- New York City (0.04)
- California
- Europe
- Genre:
- Research Report (1.00)
- Technology: