Simply Typed Reverse-Mode AD with Variants: Denotational Correctness via Idempotent Completion
Abstract
Reverse-mode automatic differentiation is commonly given a denotational account in which each source type has a single cotangent type. Variant types obstruct this simply typed representation because the valid cotangent space depends on the branch selected at run time. Existing correctness results therefore use primal-indexed families of cotangent spaces, whose natural internal language is dependently typed. We show that the same dependency can be represented in an ordinary nondependent target. The cotangent fibres of each source type are embedded in a common ambient type, and a primal-indexed idempotent selects the valid fibre. Semantically, this amounts to passing from the constant-family model to its Karoubi completion. For a category and a regular infinite cardinal , we prove that the constant-family inclusion extends to an equivalence precisely when is Cauchy complete and every -small family admits a common retract host. We also construct the resulting coproducts explicitly. Applying this theorem, we obtain a bicartesian closed semantics for reverse-mode automatic differentiation with variants using only ordinary target types, projectors, and backpropagators. Splitting the generated idempotents recovers the established dependent semantics. Thus dependent cotangent families and simply typed ambient cotangents equipped with projectors are equivalent presentations of the same denotational transformation.
Keywords
Cite
@article{arxiv.2607.14453,
title = {Simply Typed Reverse-Mode AD with Variants: Denotational Correctness via Idempotent Completion},
author = {Fernando Lucatelli Nunes and Diogo Simm and Matthijs Vákár},
journal= {arXiv preprint arXiv:2607.14453},
year = {2026}
}
Comments
55 pages