July 16, 2026
Reverse-mode automatic differentiation can be derived denotationally as a structure-preserving interpretation of program syntax. In the usual simply typed model, each source type has one cotangent type. Variants break this representation because the valid cotangent space depends on the branch selected at run time; established correctness results therefore use primal-indexed families of cotangent spaces, whose direct internal language is dependent.
We show that this dependence can instead be represented in an ordinary nondependent target. The cotangent fibres of each source type are placed inside a common ambient type, and a primal-indexed idempotent selects the valid fibre. For a category \(\mathcal{C}\) and a regular infinite cardinal \(\kappa\), we prove that the constant-family inclusion extends to an equivalence \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr) \simeq \mathsf{Fam}_\kappa(\mathcal{C})\] precisely when \(\mathcal{C}\) is Cauchy complete and every \(\kappa\)-small family admits a common retract host. The same host condition yields explicit coproducts after Karoubi completion.
We use this result to construct a bicartesian closed semantics for reverse-mode AD with variants whose ambient types, projectors, and backpropagators are ordinary nondependent target terms. Splitting the generated idempotents recovers the dependent semantics, and the two interpretations are naturally isomorphic. The ambient backpropagator is consequently the unique map that agrees with the transposed derivative on the valid cotangent fibres and respects their projectors.
Reverse-mode automatic differentiation (AD) transforms a program into one that propagates cotangents backward through its computation. Its efficiency for maps with many inputs and few outputs makes it the standard basis of gradient computation [1]–[3]. A language-level account must make this propagation compositional in substitution, binding, and the source type formers while proving that the transformed program computes the transposed derivative.
Combinatory Homomorphic Automatic Differentiation (CHAD) obtains the transformation from semantics [4]–[6]. Types and programs form a syntactic category, substitution is composition, and the universal property of the syntax extends chosen primal maps and codifferentials to a structure-preserving interpretation. Composition gives the reverse chain rule; products and exponentials generate the corresponding program clauses.
A concrete simply typed model for products and functions is \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\). Its objects \((A,V)\) consist of a set of primal values and one cotangent space, and an arrow \((f,f^*):(A,V)\to(B,W)\) has \(f:A\to B\) and \(f_a^*:W\to V\), with \((gf)^*_a=f_a^*g^*_{f(a)}\). The category is cartesian closed. Variants expose its limitation: at a value of \(A+B\), the valid cotangent is the left or right fibre according to the active branch, and \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\) does not generally have coproducts. Expressive CHAD therefore uses \(\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\), whose fibres vary with the primal value [6]; Paszke and Plotkin use the analogous dependent linear representation for sum types [7]. Executable CHAD uses common carriers [6], while Efficient CHAD develops sparse representations [8]. This leaves open why the simply typed representation presents the dependent semantics and what determines its behaviour outside the valid fibres.
The key observation is that cotangent spaces \(V\) and \(W\) can be represented in \(V\oplus W\) by the projectors \[p_{\mathsf{inl}(a)}(v,w)=(v,0), \qquad p_{\mathsf{inr}(b)}(v,w)=(0,w).\] The dependency is retained as a primal-indexed family of idempotents. Since the Karoubi envelope is the universal category in which idempotents split [9]–[11], this suggests \[\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}}) \simeq \mathsf{Kar}\bigl(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\bigr) \rightsquigarrow \mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}}).\] The equivalence turns projector images into explicit fibres; the semifunctorial passage retains the ordinary carriers and maps but no longer treats their projectors as identities.
We first prove that common retract hosts generate \(\kappa\)-small coproducts in \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\) and characterize when the constant-family inclusion extends to \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\simeq\mathsf{Fam}_\kappa(\mathcal{C})\): precisely when \(\mathcal{C}\) is Cauchy complete and every \(\kappa\)-small family has a common retract host. For \(\mathbf{Vect}^{\mathrm{op}}\), direct sums provide such hosts. We then reproduce the completion inside the ordinary CHAD target. For the freely generated bicartesian closed syntax \(\mathsf{Syn}_{+}\) and ordinary reverse target \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}=\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}^{\mathrm{op}}\), retaining the generated idempotents gives \[\overleftarrow{\mathcal{D}}_{\mathrm{Kar}}:\mathsf{Syn}_{+}\longrightarrow\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow}).\] Its representatives are ordinary nondependent types and terms. At data types the idempotent is \((1,p_\tau)\); at function types cartesian closure projects the entire function–backpropagator package by \(h\mapsto e_\sigma h e_\tau\). Forgetting the distinguished identities gives a composition-preserving semifunctor \(\overleftarrow{\mathcal{D}}_{\mathrm{st}}:\mathsf{Syn}_{+}\rightsquigarrow\mathsf T_{\mathsf{Tar}}^{\leftarrow}\).
Realization by splitting idempotents is naturally isomorphic to dependent CHAD. For a term \(t:\tau\to\sigma\) between the data types of our language, the unique projector-compatible ambient backpropagator is \[\widehat R_t(x)=\iota_{\tau,x}Df(x)^{\mathsf T}\rho_{\sigma,f(x)}.\]
We construct coproducts of completed constant families from common retract hosts and prove the criterion \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\simeq\mathsf{Fam}_\kappa(\mathcal{C})\).
We derive reverse AD with variants as a bicartesian closed interpretation into the completed ordinary target, including explicit variant structure and the higher-order idempotent forced by cartesian closure.
We prove equivalence with dependent CHAD, identify ordinary erasure as a semifunctor, and derive the unique ambient correctness formula. The forward dual is given in the appendix.
2 isolates the obstruction, 3 proves the completion theorem, 4 constructs the simply typed interpretation, and 5 proves correctness. The appendices contain all expanded constructions and proofs.
We begin by recalling the universal formulation of CHAD and the two fibrewise-dual target constructions. This separates the general semantics-driven principle from the specific obstruction introduced by variants: reverse differentiation itself remains compositional, but the constant-cotangent target lacks the coproducts needed to interpret branch-dependent fibres.
Let \(\mathsf{Syn}\) be the cartesian-closed syntactic category freely generated by ground types \(\mathsf{real}^n\) and primitive operations, modulo the \(\beta\eta\)-equations and any declared equations among the primitives. Its universal property is the standard categorical semantics of the simply typed lambda calculus [12], [13]: an interpretation of the generators satisfying those equations extends uniquely to a cartesian-closed functor.
Throughout, a bicartesian closed functor means a functor equipped with coherent comparison isomorphisms for the chosen initial object, terminal object, binary products, binary coproducts, and exponentials. When the source is the freely generated syntax and choices have been fixed, we suppress these comparisons from the notation. No strictness assertion is intended.
The target language is organised by a cartesian category \(\mathsf C_{\mathsf{Tar}}\) of primal types and terms and an indexed category \(\mathsf L_{\mathsf{Tar}}:\mathsf C_{\mathsf{Tar}}^{\mathrm{op}}\longrightarrow\mathbf{Cat}\) of linear types and linear terms. Forward and reverse CHAD use the two fibrewise-dual Grothendieck constructions \[\mathsf T_{\mathsf{Tar}}^{\rightarrow}=\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}, \qquad \mathsf T_{\mathsf{Tar}}^{\leftarrow}=\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}^{\mathrm{op}}.\] An arrow \((f,f^*):(A,V)\to(B,W)\) of \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\) consists of a primal term \(f:A\to B\) and a term \(f^*:A;W\to V\) linear in \(W\); composition is substitution in the primal component and reverse accumulation in the linear component. We import the target hypotheses from basic CHAD: \((\mathsf C_{\mathsf{Tar}},\mathsf L_{\mathsf{Tar}})\) is a categorical model of its target language in the sense of [5]. In particular, the forward and reverse total categories are cartesian closed by [5]. Broader closure criteria are given in [14].
Assigning each primitive operation its primal map and derivative therefore induces a forward functor \(\overrightarrow{\mathcal{D}}:\mathsf{Syn}\to\mathsf T_{\mathsf{Tar}}^{\rightarrow}\), while assigning its primal map and codifferential induces the reverse functor \[\overleftarrow{\mathcal{D}}:\mathsf{Syn}\longrightarrow\mathsf T_{\mathsf{Tar}}^{\leftarrow}.\] The two are fibrewise dual. We develop the reverse target below; every completion argument has the forward analogue obtained by removing the fibrewise opposite.
In the source language considered here, a data type is generated from \(\mathsf{real}^n\), \(1\), and \(0\) by finite products and variants. This is the tuple-and-variant data-type fragment of expressive CHAD. The correctness theorem in 5 is stated for source terms whose domain and codomain are data types of this fragment.
This universal account works without variants because the constant-cotangent target has the cartesian closed structure required by products and functions. Coproducts are different: their tangent or cotangent fibre depends on the branch selected by the primal computation. We now make this obstruction precise in the reverse concrete model.
The concrete constant-cotangent model is \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\). Its terminal object and binary products are \[1=(1,0), \qquad (A,V)\times(B,W)=(A\times B,V\oplus W).\]
The category \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\) is cartesian closed. An exponential may be chosen as \[(A,V)\Rightarrow(B,W) = \left( A\to\bigl(B\times\mathbf{Vect}(W,V)\bigr), \bigoplus_{a\in A}W \right).\]
Proof. This is the constant-cotangent instance of the cartesian-closed reverse target of basic CHAD [4], [5]. The displayed exponential follows by currying the primal map, separating the two biproduct components of the backward map, and applying the universal property of \(\bigoplus_{a\in A}W\). The corresponding explicit evaluation and currying maps are recorded in 14. ◻
The obstruction created by variants is now concrete.
The category \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\) does not have all binary coproducts.
Proof. Suppose, for contradiction, that the coproduct \((K,U) = (1,0) \amalg (1,\mathbb{R})\) exists in \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\).
Evaluating the covariant representable functor \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})((K,U), -)\) on objects of the form \((B,0)\) for an arbitrary set \(B\) yields the natural isomorphisms: \[\mathbf{Set}(K, B) \cong \mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})((K,U),(B,0)) \cong B \times B \cong \mathbf{Set}(2, B).\] By the Yoneda lemma, this naturally forces \(K \cong 2\).
Next, we evaluate the same covariant representable functor against objects of the form \((1,T)\) for an arbitrary \(T \in \mathbf{Vect}\). Since \(K \cong 2\), the universal property of the coproduct provides the following natural bijections: \[\begin{align} \mathbf{Vect}(T,U\oplus U) &\cong \mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})((K,U),(1,T)) \\ &\cong \begin{multlined}[t] \mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})((1,0),(1,T))\\ {}\times\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})((1,\mathbb{R}),(1,T)) \end{multlined}\\ &\cong \mathbf{Vect}(T,0)\times\mathbf{Vect}(T,\mathbb{R}) \cong \mathbf{Vect}(T,\mathbb{R}). \end{align}\] By the Yoneda lemma, it follows that \(U \oplus U \cong \mathbb{R}\). This is impossible: since \(\mathbb{R}\) is one-dimensional, such an isomorphism would imply that \(U\) is finite-dimensional and that \(2\dim(U)=1\). ◻
In \(\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\) the corresponding coproduct is branchwise: \[(A,V_{(-)})+(B,W_{(-)})=(A+B,Z_{(-)}),\] where \(Z_{\mathsf{inl}(a)}=V_a\) and \(Z_{\mathsf{inr}(b)}=W_b\). This is the cotangent semantics of variants in expressive CHAD [6].
The obstruction is therefore not a failure of differentiation, but a mismatch between two free completions: basic CHAD admits only constant families, whereas variants require arbitrary families. The next section shows how common ambient hosts create the missing coproducts and when the resulting completion agrees with the family semantics.
The preceding obstruction compares two semantic universes. Constant families suffice for basic nondependent CHAD, while variants require fibres that vary with the selected primal branch. We now show that a common ambient object already supplies the missing coproducts after idempotents are split. Cauchy completeness then determines when this completed constant-family category agrees with the full family category.
Fix a regular infinite cardinal \(\kappa\). A set is \(\kappa\)-small when its cardinality is less than \(\kappa\). For the unadorned constructions used in the higher-order semantics, we fix Grothendieck universes \(\mathcal{U}\in\mathcal{V}\): sets, families, and vector spaces are \(\mathcal{U}\)-small, and the resulting categories are regarded as \(\mathcal{V}\)-categories. Appendix 9 records the size conventions in full.
For a category \(\mathcal{C}\), the category \(\mathsf{Fam}_\kappa(\mathcal{C})\) has \(\kappa\)-small families \((X_i)_{i\in I}\) as objects. A morphism \[(u,\alpha):(X_i)_{i\in I}\longrightarrow(Y_j)_{j\in J}\] consists of a function \(u:I\to J\) and arrows \(\alpha_i:X_i\to Y_{u(i)}\). The singleton-family embedding \[\eta_{\mathcal{C}}:\mathcal{C}\longrightarrow\mathsf{Fam}_\kappa(\mathcal{C})\] exhibits \(\mathsf{Fam}_\kappa(\mathcal{C})\) as the free completion of \(\mathcal{C}\) under \(\kappa\)-small coproducts [10], [15].
The full subcategory on constant families is \(\mathsf{Copow}_\kappa(\mathcal{C})\). Its objects are pairs \((I,X)\), and it is the free completion of \(\mathcal{C}\) under copowers by \(\kappa\)-small sets. We write \[\iota_{\mathcal{C}}:\mathcal{C}\longrightarrow\mathsf{Copow}_\kappa(\mathcal{C})\] for the singleton embedding and \[J_{\mathcal{C}}:\mathsf{Copow}_\kappa(\mathcal{C})\hookrightarrow\mathsf{Fam}_\kappa(\mathcal{C})\] for the constant-family inclusion.
The Karoubi envelope \(\mathsf{Kar}(\mathcal{A})\) has objects \((A,e)\), where \(e:A\to A\) is idempotent, and arrows \(f:(A,e)\to(B,d)\) satisfying \(f=dfe\). Its identity on \((A,e)\) is \(e\). The canonical embedding \(Q_{\mathcal{A}}:\mathcal{A}\to\mathsf{Kar}(\mathcal{A})\) is the free Cauchy completion: for every Cauchy-complete category \(\mathcal{D}\), restriction induces an equivalence \[[\mathsf{Kar}(\mathcal{A}),\mathcal{D}] \simeq [\mathcal{A},\mathcal{D}].\] See [9]–[11]; the universal properties and our variance conventions are recalled in the appendices.
The three constructions now have distinct roles. The copower completion provides the constant ambient carriers available to nondependent CHAD. The Karoubi envelope separates the subobjects selected by idempotents on those carriers. The family completion presents the resulting fibres directly. We first show that the common-host hypothesis already equips the Karoubi-completed constant-family category with the required coproducts.
Definition 1. A family \((X_i)_{i\in I}\) in \(\mathcal{C}\) admits a common retract host* if there are an object \(P\) and, for each \(i\in I\), arrows \[X_i\xrightarrow{s_i}P\xrightarrow{r_i}X_i\] such that \[r_is_i=1_{X_i}.\]*
A common retract host allows several ambient objects to be represented inside a single carrier. We first isolate this change of carrier.
Lemma 1 (Common-carrier presentation). Let \((E_a)_{a\in A}\) be a family of objects of \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\), where \[E_a=\bigl((I_a,X_a),e_a\bigr), \qquad e_a=(u_a,p^a).\] Suppose that \((X_a)_{a\in A}\) admits a common retract host \[X_a\xrightarrow{s_a}P\xrightarrow{r_a}X_a, \qquad r_as_a=1_{X_a}.\] For each \(a\in A\), define \[\widetilde{p}^a_i=s_ap^a_ir_a\] and \[\widetilde{E}_a = \bigl((I_a,P),\widetilde{e}_a\bigr), \qquad \widetilde{e}_a=(u_a,\widetilde{p}^a).\] Then \(\widetilde{e}_a\) is idempotent, and there is an isomorphism \[E_a\cong\widetilde{E}_a\] in \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\).
Once all objects have the same ambient carrier, their coproduct is obtained by concatenating the index sets and assembling the idempotents blockwise.
Suppose that every \(\kappa\)-small family in \(\mathcal{C}\) admits a common retract host. Then \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr)\] admits \(\kappa\)-small coproducts.
More explicitly, let \((E_a)_{a\in A}\) be a \(\kappa\)-small family of objects, where \[E_a=\bigl((I_a,X_a),(u_a,p^a)\bigr),\] with \[u_a^2=u_a, \qquad p^a_{u_a(i)}p^a_i=p^a_i.\] Choose a common retract host \[X_a\xrightarrow{s_a}P\xrightarrow{r_a}X_a, \qquad r_as_a=1_{X_a},\] for the family \((X_a)_{a\in A}\). Put \[I=\coprod_{a\in A}I_a = \{(a,i)\mid a\in A,\;i\in I_a\},\] and define an endomorphism \(c=(u,c_{(-)})\) of \((I,P)\) by \[u(a,i)=(a,u_a(i)), \qquad c_{(a,i)}=s_ap^a_ir_a.\] Then \(c\) is idempotent, and a coproduct of \((E_a)_{a\in A}\) is \[\coprod_{a\in A}E_a = \bigl((I,P),c\bigr).\] If \[j_a:(I_a,X_a)\longrightarrow(I,P)\] has base map \(i\mapsto(a,i)\) and constant component \(s_a\), then the coproduct injection is \[\iota_a=c\,j_a\,(u_a,p^a).\] Equivalently, \(\iota_a\) has base map \[i\longmapsto(a,u_a(i))\] and component \(s_ap^a_i\) at \(i\).
Proof. By 1, each \(E_a\) is isomorphic to \(\widetilde{E}_a=((I_a,P),\widetilde{e}_a)\), with \(\widetilde{p}^a_i=s_ap^a_ir_a\). The displayed endomorphism \(c\) is the blockwise concatenation of these idempotents, so \(c^2=c\), and the displayed maps \(\iota_a\) are Karoubi arrows.
Given Karoubi arrows \(f_a:E_a\to D\), transport them along \(E_a\cong\widetilde{E}_a\). On the block \(I_a\) of \(I=\coprod_a I_a\), define the base map and components of \([(f_a)]\) to be those of the transported \(f_a\). The sandwich equation holds blockwise, so \([(f_a)]\) is the unique Karoubi arrow with \([(f_a)]\iota_a=f_a\). If \(A=\varnothing\), the common-host condition supplies an object \(P\), and the unique endomorphism of \((\varnothing,P)\) yields an initial Karoubi object. Thus the construction gives all \(\kappa\)-small coproducts. ◻
The common-host hypothesis is used only to replace the ambient objects \(X_a\) by a single carrier \(P\). Once this has been done, the coproduct is formed by concatenating the index sets and assembling the corresponding idempotents blockwise.
A component-by-component verification, including the empty coproduct, is given in [app:common-carrier-details,app:coproduct-details].
A useful sufficient condition is the existence of zero morphisms together with the relevant products or coproducts. Indeed, if \(\mathcal{C}\) has zero morphisms and \(\kappa\)-small coproducts, then the coproduct of any \(\kappa\)-small family is a common retract host: the coproduct injection serves as the section, while the retraction is the morphism that is the identity on the selected summand and zero on every other summand. More generally, we have the following result.
Lemma 2 (Common hosts from products or coproducts). Let \(\mathcal{C}\) be a category with zero morphisms, and let \((X_i)_{i\in I}\) be a family of objects.
If the product \[P=\prod_{j\in I}X_j\] exists, then \(P\) is a common retract host for \((X_i)_{i\in I}\).
If the coproduct \[Q=\coprod_{j\in I}X_j\] exists, then \(Q\) is a common retract host for \((X_i)_{i\in I}\).
Consequently, if \(\mathcal{C}\) has zero morphisms and either \(\kappa\)-small products or \(\kappa\)-small coproducts, then every \(\kappa\)-small family in \(\mathcal{C}\) admits a common retract host. Under either hypothesis, \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr)\] admits \(\kappa\)-small coproducts.
Proof. Suppose first that \(P=\prod_{j\in I}X_j\) exists, with projections \(\pi_j:P\to X_j\). For each \(i\in I\), let \(\delta_i:X_i\to P\) be the unique morphism such that \[\pi_j\delta_i= \begin{cases} 1_{X_i},&j=i,\\ 0_{X_i,X_j},&j\neq i. \end{cases}\] Then \(\pi_i\delta_i=1_{X_i}\), so \(P\) is a common retract host, with section \(\delta_i\) and retraction \(\pi_i\).
Dually, suppose that \(Q=\coprod_{j\in I}X_j\) exists, with injections \(\iota_j:X_j\to Q\). For each \(i\in I\), let \(\rho_i:Q\to X_i\) be the unique morphism determined by \[\rho_i\iota_j= \begin{cases} 1_{X_i},&j=i,\\ 0_{X_j,X_i},&j\neq i. \end{cases}\] Then \(\rho_i\iota_i=1_{X_i}\), so \(Q\) is a common retract host, with section \(\iota_i\) and retraction \(\rho_i\). The final assertion follows from [prop:kar-coprod]. ◻
The preceding proposition supplies the colimit structure required by variants. To identify the resulting category with \(\mathsf{Fam}_\kappa(\mathcal{C})\), one further condition is needed:
Lemma 3 (Cauchy completeness of family categories). The category \(\mathsf{Fam}_\kappa(\mathcal{C})\) is Cauchy complete if and only if \(\mathcal{C}\) is Cauchy complete.
Proof. Assume that \(\mathcal{C}\) is Cauchy complete and let \((u,\alpha)\) be an idempotent on \((X_i)_{i\in I}\). Its base idempotent splits through \(I_0=\operatorname{Fix}(u)\). For \(j\in I_0\), split the idempotent \(\alpha_j\) as \(X_j\xrightarrow{q_j}\overline{X}_j\xrightarrow{m_j}X_j\). The family maps with base functions \(i\mapsto u(i)\) and \(I_0\hookrightarrow I\), and components \(q_{u(i)}\alpha_i\) and \(m_j\), split \((u,\alpha)\).
Conversely, split an idempotent \(e:X\to X\) after regarding it as an idempotent on the singleton family \((X)\). The base equations force the splitting family to be singleton, and its components split \(e\) in \(\mathcal{C}\). ◻
Lemma 4 (Retracts of constant families). A family is a retract in \(\mathsf{Fam}_\kappa(\mathcal{C})\) of a constant family if and only if it has a common retract host in \(\mathcal{C}\).
Proof. If \((X_i)_{i\in I}\) has host \(P\), the maps with base \(1_I\) and components \(s_i\) and \(r_i\) exhibit it as a retract of the constant family \((P)_{i\in I}\). Conversely, suppose that \((X_i)_{i\in I}\) is a retract of \((P)_{j\in J}\), with section \((a,s)\) and retraction \((b,r)\). The equality \((b,r)(a,s)=1\) gives \(ba=1_I\) and \[r_{a(i)}s_i=1_{X_i}.\] Thus \(P\) is a common retract host. ◻
A fully faithful functor \(J:\mathcal{A}\to\mathcal{B}\) is Cauchy dense when every object of \(\mathcal{B}\) is a retract of an object in the image of \(J\). By 4:
Lemma 5. The inclusion \(J_{\mathcal{C}}:\mathsf{Copow}_\kappa(\mathcal{C})\hookrightarrow\mathsf{Fam}_\kappa(\mathcal{C})\) is Cauchy dense if and only if every \(\kappa\)-small family has a common retract host.
This observation links the explicit coproducts of [prop:kar-coprod] with the universal comparison between the two completions.
Theorem 1 (Family-completion criterion). For a category \(\mathcal{C}\), the following are equivalent.
The constant-family inclusion extends to an equivalence \[\label{eq:fundamental-Karequivalence} \mathfrak R: \mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr) \simeq \mathsf{Fam}_\kappa(\mathcal{C}).\qquad{(1)}\]
The category \(\mathcal{C}\) is Cauchy complete and every \(\kappa\)-small family in \(\mathcal{C}\) has a common retract host.
In \(\mathrm{(1)}\), the equivalence is required to restrict, up to natural isomorphism, to \(J_{\mathcal{C}}\). When these conditions hold, \(\mathfrak R\) carries the coproducts of [prop:kar-coprod] to the concatenation coproducts in \(\mathsf{Fam}_\kappa(\mathcal{C})\).
Proof. Assume (2). By 3, \(\mathsf{Fam}_\kappa(\mathcal{C})\) is Cauchy complete, so the fully faithful inclusion \(J_{\mathcal{C}}\) extends along the Karoubi embedding to \(R:\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\to\mathsf{Fam}_\kappa(\mathcal{C})\). By [lem:host,lem:cauchy-dense], the common-host condition is precisely Cauchy density of \(J_{\mathcal{C}}\). Hence \(R\) is fully faithful and essentially surjective.
Conversely, assume (1). Since every Karoubi envelope is Cauchy complete, \(\mathsf{Fam}_\kappa(\mathcal{C})\) is Cauchy complete, and 3 implies that \(\mathcal{C}\) is Cauchy complete. Every \(R(A,e)\) is a retract of \(R(A,1)\cong J_{\mathcal{C}}(A)\); essential surjectivity therefore makes \(J_{\mathcal{C}}\) Cauchy dense. By 5, every \(\kappa\)-small family has a common retract host. Finally, the equivalence carries the coproducts of [prop:kar-coprod] to concatenation coproducts by uniqueness of coproducts. Detailed realization formulas are given in [app:criterion-details,app:realization]. ◻
Corollary 1. Let \(\mathcal{C}\) be a Cauchy-complete category with a zero object. If \(\mathcal{C}\) admits either \(\kappa\)-small products or \(\kappa\)-small coproducts, then the constant-family inclusion extends to an equivalence \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr) \simeq \mathsf{Fam}_\kappa(\mathcal{C}).\]
In particular, there is an equivalence extending the constant-family inclusion \[\mathfrak R: \mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathbf{Vect}^{\mathrm{op}})\bigr) \simeq \mathsf{Fam}_\kappa(\mathbf{Vect}^{\mathrm{op}}).\]
Proof. A zero object supplies zero morphisms. The first assertion therefore follows from [lem:common-hosts-products-coproducts,thm:criterion]. The category \(\mathbf{Vect}^{\mathrm{op}}\) is Cauchy complete and has a zero object together with all small products and coproducts. For the displayed ambient presentation, use the direct sum \(\bigoplus_iV_i\) in \(\mathbf{Vect}\), which is a product in \(\mathbf{Vect}^{\mathrm{op}}\): the coordinate projection in \(\mathbf{Vect}\) represents the section in \(\mathbf{Vect}^{\mathrm{op}}\), and the coordinate injection represents the retraction. ◻
Under this equivalence, a family \((V_i)_{i\in I}\) is represented by the ambient space \(\bigoplus_iV_i\) together with the coordinate projectors \(\iota_i\pi_i\). Conversely, splitting these projectors recovers the original fibres. One could instead use direct-product ambient spaces; the two choices give isomorphic coproduct objects after completion, although their ambient presentations differ. We use direct sums because they provide the sparse, finitely supported presentation relevant to reverse-mode implementations.
The completion theorem identifies the correct semantic target. We next lift that result from concrete families of vector spaces to the syntactic target language of CHAD. The construction proceeds in two stages: first we recover the missing bicartesian structure inside the Karoubi envelope; then the universal property of the source syntax generates the transformation.
We use the ordinary reverse target \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\) of basic CHAD.
We assume that \((\mathsf C_{\mathsf{Tar}},\mathsf L_{\mathsf{Tar}})\) is a categorical model of the basic CHAD target language in the sense of [5]. Thus \(\mathsf L_{\mathsf{Tar}}\) is locally indexed, its fibres have the finite-biproduct and cartesian linear-function structure required by CHAD, and \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\) is cartesian closed by [5]. For variants, the only additional assumption is that \(\mathsf C_{\mathsf{Tar}}\) has finite coproducts.
The remaining operations needed below are consequences of these hypotheses. Finite biproducts in the fibres provide common retract hosts in the reverse fibres. Moreover, cartesian linear-function objects and the coproduct universal property in \(\mathsf C_{\mathsf{Tar}}\) give natural bijections \[\mathsf L_{\mathsf{Tar}}(A+B)(U,P) \cong \mathsf L_{\mathsf{Tar}}(A)(U,P)\times\mathsf L_{\mathsf{Tar}}(B)(U,P),\] so linear maps over \(A+B\) are uniquely determined by their two branch restrictions. The associated branchwise linear case operation, including its \(\beta\)- and \(\eta\)-equations and stability under reindexing, is therefore derived rather than assumed. Appendix 15 gives the full argument.
The following calculations are written in the internal language of \(\mathsf C_{\mathsf{Tar}}\) and its indexed linear calculus. Equivalently, each displayed elementwise equation denotes the corresponding equality of target terms. We call an idempotent \(e=(r,p)\) on a reverse-target object full when it acts on the whole primal/function–backpropagator package, rather than only on a cotangent coordinate.
Let \[E=((A,V),e), \qquad F=((B,W),d),\] where \(e=(r,p)\) and \(d=(s,q)\) are idempotent endomorphisms in \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\). On the ambient object \((A+B,V\oplus W)\), define \(c_{E,F}\) by \[\begin{align} c_{E,F,1}(\mathsf{inl}(a))&=\mathsf{inl}(r(a)), & (c_{E,F})^*_{\mathsf{inl}(a)}(v,w)&=(p_a(v),0),\\ c_{E,F,1}(\mathsf{inr}(b))&=\mathsf{inr}(s(b)), & (c_{E,F})^*_{\mathsf{inr}(b)}(v,w)&=(0,q_b(w)). \end{align}\] For an idempotent in the reverse target, the backward equations are \(p_a\circ p_{r(a)}=p_a\) and \(q_b\circ q_{s(b)}=q_b\). Hence \(c_{E,F}^2=c_{E,F}\) branchwise. Define \[E+F:=((A+B,V\oplus W),c_{E,F}).\] This is the coproduct object in the completed category; no dependent target type former is required.
Under the hypotheses above, \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\) is bicartesian closed. For \(E=((A,V),e)\) and \(F=((B,W),d)\), its chosen structure is \[1=Q_{\mathsf T_{\mathsf{Tar}}^{\leftarrow}}(1_{\mathsf T_{\mathsf{Tar}}^{\leftarrow}}), \quad E\times F=((A\times B,V\oplus W),e\times d), \quad F^E=((B,W)^{(A,V)},\varepsilon_{e,d}),\] where the product projections are \(e\pi_1,d\pi_2\) and \(\varepsilon_{e,d}=\Lambda(d\,\mathrm{ev}(1\times e))\), so \(\varepsilon_{e,d}(h)=dhe\). The initial object is \(((0,0),1)\), and the binary coproduct is \(((A+B,V\oplus W),c_{E,F})\).
Proof. The category \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\) is cartesian closed by the basic CHAD hypotheses, and its Karoubi completion inherits this structure by the standard Karoubi construction, recalled in [prop:kar-ccc-app]. The finite biproduct \(V\oplus W\) is a common retract host for \(V\) and \(W\) in the reverse fibres, and the branchwise decomposition derived above gives \([a,b]^*_{\mathsf{inl}(x)}(u)=(a_x^*(u),0)\) and \([a,b]^*_{\mathsf{inr}(y)}(u)=(0,b_y^*(u))\). The sandwich and injection equations prove existence, while the primal and linear \(\eta\)-equations determine both branches and hence prove uniqueness. The initial object is obtained from the initial object of \(\mathsf C_{\mathsf{Tar}}\) and the zero object in the linear fibres. Appendix 15 contains the component proof and derives all branchwise operations from the stated hypotheses. ◻
Under 1, this coproduct realizes to the branchwise coproduct in \(\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\). It is therefore an ambient presentation of the established dependent variant semantics, not a competing interpretation.
Having reconstructed the missing coproducts in the completed target, the rest of the transformation follows from the source universal property. This is the decisive methodological point: the clauses for variants are not appended to CHAD by hand, but are forced by the same preservation principle as the clauses for products and functions.
Let \(\mathsf{Syn}_{+}\) be the bicartesian closed syntactic category freely generated by the source ground types and primitive operations, modulo the declared equations. Products, variants, and function types are supplied by its chosen bicartesian closed structure.
Theorem 2 (Universal completed reverse interpretation). Every assignment of the source ground types and primitive operations to objects and arrows of \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\) that respects the declared equations extends, relative to the chosen bicartesian closed structures, to a bicartesian closed functor \[\overleftarrow{\mathcal{D}}_{\mathrm{Kar}}:\mathsf{Syn}_{+}\longrightarrow\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow}).\] For the standard primal interpretations and primitive codifferentials, its ambient representatives are ordinary nondependent target types and terms. In particular, the variant clauses are generated by preservation of the completed coproducts rather than postulated as additional syntax-directed rules.
Proof. The substantive input is [prop:bcc]: common ambient hosts and idempotent splitting provide the coproducts that were absent from the ordinary reverse target, while Karoubi completion preserves its cartesian closed structure. Hence \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\) is bicartesian closed. The universal property of the freely generated bicartesian closed category \(\mathsf{Syn}_{+}\) then extends the chosen interpretation of the generators to a bicartesian closed functor \(\overleftarrow{\mathcal{D}}_{\mathrm{Kar}}\). For fixed choices of structure, this extension is determined by its action on the generators; different coherent choices are related by a structure-preserving natural isomorphism.
An object of \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\) is an ordinary target type together with an idempotent ordinary target term, and a morphism is an ordinary target term satisfying the corresponding sandwich equation. Thus the types, primal computations, backpropagators, and idempotents generated by \(\overleftarrow{\mathcal{D}}_{\mathrm{Kar}}\) all belong to the ordinary nondependent target language. Products, variants, abstraction, application, and case analysis are consequently determined by preservation of the chosen bicartesian closed structure. The change from dependent fibres to ambient projectors changes the representation of cotangents, not the universal definition of the CHAD transformation. ◻
Concretely, for every source type \(\tau\) write \[\overleftarrow{\mathcal{D}}_{\mathrm{Kar}}(\tau) = \bigl((\widehat D_1\tau,\widehat D_2\tau),e_\tau\bigr), \qquad e_\tau=(r_\tau,p_\tau),\] where \(e_\tau\) is a full idempotent endomorphism of the ordinary reverse target object. For data types, induction gives \(r_\tau=1\) and the linear component \(p_\tau(x,-)\) is an idempotent cotangent projector. At ground types it is the identity. Products and sums act componentwise; in particular, \[\begin{align} \widehat D_1(\tau+\sigma) &=\widehat D_1\tau+\widehat D_1\sigma,\\ \widehat D_2(\tau+\sigma) &=\widehat D_2\tau\oplus\widehat D_2\sigma,\\ p_{\tau+\sigma}(\mathsf{inl}(x),(v,w)) &=(p_\tau(x,v),0),\\ p_{\tau+\sigma}(\mathsf{inr}(y),(v,w)) &=(0,p_\sigma(y,w)). \end{align}\] At a function type, however, \[e_{\tau\Rightarrow\sigma} = \varepsilon_{e_\tau,e_\sigma},\] the exponential idempotent induced by cartesian closure. Internally it sends an ambient function–backpropagator package \(h\) to \(e_\sigma h e_\tau\); its primal component need not be the identity. The idempotents are generated code, not proof objects. A transformed term is an ordinary primal computation and backpropagator satisfying the full sandwich equation at its source and target. Appendix 14 gives the concrete exponential idempotent explicitly.
The coproduct object, injections, and copairing above determine all four variant constructs—left and right injection, abort, and case analysis—without an ad hoc semantic clause. Appendix 16 gives the resulting injection and case-analysis terms in full. Product and higher-order clauses are those generated by basic CHAD, restricted by the source and target idempotents; we do not duplicate its full macro here.
The fibrewise-dual forward construction and its ambient formula are recorded in Appendix 18.
The Karoubi-valued functor is the primary semantic construction. The ordinary nondependent program is obtained only after a deliberate change of viewpoint in which the ambient carriers and maps are retained but their distinguished idempotents are no longer treated as categorical identities.
A semifunctor preserves objects, arrows, and composition, but need not preserve identities. Hoofman and Moerdijk showed, building on Hayashi and Hoofman, that the theory of semifunctors embeds fully into ordinary functor theory through Karoubi completion [16]–[18]. Forgetting the distinguished status of the idempotent attached to each Karoubi object gives such a map \[\overleftarrow{\mathcal{D}}_{\mathrm{st}}:\mathsf{Syn}_{+}\rightsquigarrow\mathsf T_{\mathsf{Tar}}^{\leftarrow}.\]
For every source arrow \(f:\tau\to\sigma\), \[\overleftarrow{\mathcal{D}}_{\mathrm{st}}(f)=e_\sigma\circ\overleftarrow{\mathcal{D}}_{\mathrm{st}}(f)\circ e_\tau, \qquad \overleftarrow{\mathcal{D}}_{\mathrm{st}}(1_\tau)=e_\tau,\] and \(\overleftarrow{\mathcal{D}}_{\mathrm{st}}(gf)=\overleftarrow{\mathcal{D}}_{\mathrm{st}}(g)\overleftarrow{\mathcal{D}}_{\mathrm{st}}(f)\). At data types \(e_\tau=(1,p_\tau)\), so the backward component of the erased identity is the cotangent projector \(p_\tau\).
Proof. Karoubi arrows satisfy the sandwich equation, their identities are the attached idempotents, and their composition is ambient composition. The data-type claim specializes this observation to \(e_\tau=(1,p_\tau)\). ◻
Equivalently, every semifunctor \(F:\mathcal{X}\rightsquigarrow\mathcal{A}\) determines an ordinary functor \(\mathcal{X}\to\mathsf{Kar}(\mathcal{A})\) by sending \(X\) to \((FX,F1_X)\). This is the concrete form, used here, of the Hoofman–Moerdijk passage from semifunctors to ordinary functors; the appendices prove the correspondence explicitly. Notice that this forgetful passage does not remove projector calls required by the generated program. It forgets only their distinguished categorical role as identities of completed objects.
Structure preservation explains how the algorithm is generated, but it does not by itself identify the linear map computed on the entire ambient carrier. The next section compares the completed semantics with dependent CHAD and derives the exact extension of the mathematical derivative to invalid ambient coordinates.
We now compare the completed target with the concrete dependent model and use the Karoubi equations to determine the ambient backpropagator.
Assume a primal interpretation \(\mathcal{S}:\mathsf C_{\mathsf{Tar}}\to\mathbf{Set}\) and compatible indexed linear interpretations \(\mathcal{L}_A:\mathsf L_{\mathsf{Tar}}(A)\to\mathbf{Vect}^{\mathcal{S} A}\). A linear object \(V\) is sent to the constant family at a vector space \(\mathcal{V} V\), and reindexing is interpreted by substitution. Assume the usual basic-CHAD comparison maps, so the induced reverse-total interpretation preserves the chosen terminal object, products, and exponentials, and assume additionally that finite coproducts, zero objects, biproducts, and linear-function objects are preserved. In particular, \[\begin{align} \mathcal{S}(A+B)&\cong\mathcal{S} A+\mathcal{S} B,\\ \mathcal{V}(V\oplus W)&\cong\mathcal{V} V\oplus\mathcal{V} W,\\ \mathcal{S}(V\multimap W)&\cong\mathbf{Vect}(\mathcal{V} V,\mathcal{V} W). \end{align}\] Ground types have their usual Euclidean interpretations, and primitives use the same primal maps and codifferentials as dependent CHAD. These data induce \[\llbracket-\rrbracket_\mathsf{Tar}:\mathsf T_{\mathsf{Tar}}^{\leftarrow}\longrightarrow\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}}), \qquad \llbracket(A,V)\rrbracket_\mathsf{Tar}=(\mathcal{S} A,\mathcal{V} V),\] with \(\llbracket(f,\ell)\rrbracket_\mathsf{Tar}= (\mathcal{S} f,(\mathcal{L}_A(\ell)_a)_{a\in\mathcal{S} A})\). Karoubi completion followed by realization gives \[\llbracket-\rrbracket_{\mathrm{cpl}}: \mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow}) \xrightarrow{\mathsf{Kar}(\llbracket-\rrbracket_\mathsf{Tar})} \mathsf{Kar}(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})) \xrightarrow{\mathfrak R} \mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}}).\]
The functor \(\llbracket-\rrbracket_{\mathrm{cpl}}\) has canonical bicartesian closed comparison isomorphisms. In particular, for \(E,F\in\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\), \[\llbracket E+F\rrbracket_{\mathrm{cpl}} \cong \llbracket E\rrbracket_{\mathrm{cpl}} + \llbracket F\rrbracket_{\mathrm{cpl}},\] where the right-hand side is the branchwise family coproduct. Under these comparisons, ground types and primitives agree with dependent CHAD.
Proof. The inherited structure is preserved by the assumed concrete comparisons and 8. For coproducts, realization splits the left and right branch projectors of \(c_{E,F}\), yielding precisely the two branchwise image families. The full calculation is in Appendix 17.1. ◻
Let \(\overleftarrow{\mathcal{D}}_{\mathrm{dep}}:\mathsf{Syn}_{+}\to\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\) denote the standard dependent reverse-CHAD interpretation.
Theorem 3 (Comparison with dependent CHAD). There is a coherent bicartesian closed natural isomorphism \[\llbracket-\rrbracket_{\mathrm{cpl}}\overleftarrow{\mathcal{D}}_{\mathrm{Kar}} \cong \overleftarrow{\mathcal{D}}_{\mathrm{dep}}.\] Thus explicit cotangent fibres and ambient carriers equipped with idempotents present the same denotational transformation.
Proof. By [prop:standard-target-compatibility], both sides are bicartesian closed interpretations of \(\mathsf{Syn}_{+}\) agreeing on ground types, primitives, and declared equations. Freeness gives the unique coherent comparison. See Appendix 17.1 for the expanded argument. ◻
Every data type generated from \(\mathsf{real}^n\), \(1\), and \(0\) by finite products and variants is isomorphic, by repeated distributivity, to a finite sum of finite products of Euclidean ground types. The tuple-and-variant correctness theorem of expressive CHAD therefore applies componentwise [6], and correctness transports along these canonical structural isomorphisms.
For a data type \(\tau\) and value \(x\), let \(T^*_\tau(x)\) be the genuine cotangent fibre and \(\widehat T^*_\tau\) its ambient cotangent space. Fix the splitting \[T^*_\tau(x) \xrightarrow{\iota_{\tau,x}} \widehat T^*_\tau \xrightarrow{\rho_{\tau,x}} T^*_\tau(x), \qquad \rho_{\tau,x}\iota_{\tau,x}=1, \quad \iota_{\tau,x}\rho_{\tau,x}=p_{\tau,x}.\] An ambient extension \(h\) of \(k:T^*_\sigma(f(x))\to T^*_\tau(x)\) is projector compatible when \(h=p_{\tau,x}hp_{\sigma,f(x)}\) and \(\rho_{\tau,x}h\iota_{\sigma,f(x)}=k\).
Lemma 6 (Unique projector-compatible extension). The unique projector-compatible extension of \(k\) is \[h=\iota_{\tau,x}k\rho_{\sigma,f(x)}.\]
Proof. The displayed map has the required restriction and sandwich equation. Conversely, \(h=p_\tau hp_\sigma=\iota_\tau(\rho_\tau h\iota_\sigma)\rho_\sigma\). ◻
Theorem 4 (Ambient correctness for reverse CHAD). Let \(t:\tau\to\sigma\) have domain and codomain among the data types generated from \(\mathsf{real}^n\), \(1\), and \(0\) by finite products and variants. Under the usual differentiability and codifferential hypotheses on primitives, the denotation \(f=\llbracket t\rrbracket\) is componentwise differentiable and the backward component of the erased nondependent transformation is \[\widehat R_t(x) = \iota_{\tau,x}Df(x)^{\mathsf T}\rho_{\sigma,f(x)}.\] It is the unique projector-compatible ambient extension of \(Df(x)^{\mathsf T}\).
Proof. Dependent correctness and 3 identify the restriction of the ambient map with \(Df(x)^{\mathsf T}\); the Karoubi sandwich equation and 6 force the displayed formula. The expanded calculation and a branch-sensitive example are in Appendix 17. ◻
In particular, \(\widehat R_{1_\tau}(x)=p_{\tau,x}\), while adjacent retraction–section pairs cancel under composition.
Basic and expressive CHAD provide, respectively, the higher-order semantics-driven transformation and the dependent-family correctness result used here [4]–[6]. Efficient and iterative CHAD study sparse accumulation and partial or iterative computation [8], [19], [20]. For sums, Paszke and Plotkin likewise use dependent linear types selected by the active branch [7]. Our contribution is the denotational equivalence between such fibres and ordinary ambient types with idempotents, including the reconstructed bicartesian closed structure and the uniquely compatible ambient derivative; it is not a new asymptotic AD algorithm.
Other compositional accounts use lenses, reverse derivative categories, continuations, control, or linear negation [21]–[27]. Karoubi completion and semifunctors also occur in denotational and quantum semantics [16]–[18], [28], [29]. Our correctness theorem concerns exactly finite products and variants of Euclidean ground types.
Idempotent completion turns ambient simply typed cotangents into a bicartesian closed model of variants equivalent to the dependent family semantics. Realization recovers dependent CHAD, erasure yields its ordinary semifunctorial program, and the sandwich equations force the unique ambient derivative extension. The forward dual is given in the appendix.
This research was supported by the ERC project FoRECAST. The first author was also supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) through the project Higher-Order Monad-based Programming and Reasoning (HOMBRe), project number 501369690, led by Sergey Goncharov, during his postdoctoral appointment at the School of Computer Science, University of Birmingham. He was further supported by the Fields Institute for Research in Mathematical Sciences through a Fields Research Fellowship in 2023, and by the Centre for Mathematics of the University of Coimbra (CMUC) under the Fundação para a Ciência e a Tecnologia (FCT), through the grants UID/00324/2025 and UID/PRR/00324/2025.
This work is theoretical and does not use or generate research data.
This appendix gives a conceptual map of the construction for readers coming from programming languages, category theory, or automatic differentiation. It omits most universal-property proofs, which begin in 9, and concentrates on what changes—and what does not—when dependent cotangent fibres are presented by ordinary simply typed carriers.
A reverse-mode value has two parts: a primal value and a space in which cotangents for that value live. For a source type without variants, one may use one cotangent space for every primal value. This gives the constant-family model \[\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}}).\] A variant value is different. At \(\mathsf{inl}(a)\) only a left cotangent is valid, while at \(\mathsf{inr}(b)\) only a right cotangent is valid. The intrinsic semantic object is therefore a family \[x\longmapsto T^*_\tau(x),\] represented in \(\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\). The dependence is essential: it expresses which cotangents are meaningful at the current primal value.
The implementation problem is that a direct internal language for such a family uses a cotangent type depending on the primal term. Ordinary implementations, however, prefer one target type for every source type.
Choose one ambient space \(\widehat T^*_\tau\) large enough to contain every fibre \(T^*_\tau(x)\) as a retract. For each primal value \(x\), choose maps \[T^*_\tau(x) \xrightarrow{\iota_{\tau,x}} \widehat T^*_\tau \xrightarrow{\rho_{\tau,x}} T^*_\tau(x), \qquad \rho_{\tau,x}\iota_{\tau,x}=1.\] Their composite \[p_{\tau,x}=\iota_{\tau,x}\rho_{\tau,x}\] is an idempotent on the single ambient type. Its image is the valid cotangent fibre. Thus a dependent family can be presented by two simply typed pieces of data: \[\text{one ambient carrier} \quad+\quad \text{a primal-indexed projector}.\] For a sum, the ambient carrier is a biproduct and the projector selects the active branch: \[\begin{align} p_{\tau+\sigma}(\mathsf{inl}(x),(v,w))&=(p_\tau(x,v),0),\\ p_{\tau+\sigma}(\mathsf{inr}(y),(v,w))&=(0,p_\sigma(y,w)). \end{align}\] Nothing dependent has been approximated or forgotten; its information has moved from the target type into an idempotent target term.
The ordinary constant-family category sees the ambient carrier but treats its identity map as the identity. The semantic fibre, however, behaves as if the projector \(p_x\) were the identity: valid values are fixed by \(p_x\), and valid maps satisfy sandwich equations. The Karoubi envelope makes this viewpoint literal. An object is a pair \((A,e)\) with \(e^2=e\), its identity is \(e\), and an arrow \(h:(A,e)\to(B,d)\) satisfies \[h=dhe.\] Consequently, \[\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}}) \simeq \mathsf{Kar}\bigl(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\bigr)\] expresses that an explicit family of fibres and an ambient carrier with projectors are two presentations of the same semantic object. The relevant completion is \(\mathsf{Kar}(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}}))\), not \(\mathsf{Kar}(\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}}))\): the latter is already equivalent to \(\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\) because the family category is Cauchy complete.
The general theorem isolates the precise hypotheses. The constant-family inclusion extends along idempotent completion to an equivalence with all \(\kappa\)-small families if and only if \(\mathcal{C}\) is Cauchy complete and every such family has a common retract host. For vector spaces, the host is a direct sum and every idempotent splits through its image.
The construction has three compatible levels: \[\begin{array}{ccl} \mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}}) &\simeq& \mathsf{Kar}(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})) \quad\rightsquigarrow\quad \mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\\[2mm] \text{dependent fibres} && \text{ambient carrier + identities} \qquad \text{ambient carrier only.} \end{array}\] The left presentation is best for stating the mathematical semantics and proving logical-relations correctness. The middle presentation is best for preserving products, variants, and higher-order functions: it is an ordinary category in which the projectors are the identities of the represented fibres. The right presentation is the executable simply typed program obtained by forgetting only that distinguished categorical role. The corresponding idempotent calls remain in the code.
This final passage is a semifunctor rather than a functor. Composition is still strict, because composition in the Karoubi envelope is ambient composition. Identities become the generated idempotents: \[\overleftarrow{\mathcal{D}}_{\mathrm{st}}(1_\tau)=e_\tau.\] At data types, \(e_\tau=(1,p_\tau)\), so the primal identity is unchanged while the cotangent identity discards invalid coordinates.
For variants, completion creates the missing coproduct. Its ordinary ambient type is \[(A+B,V\oplus W),\] but its identity is the branch-sensitive idempotent. The coproduct injections and case analysis are obtained by sandwiching the ordinary terms with the source and target idempotents. This is why the resulting clauses satisfy the coproduct equations at the completed level even though the ordinary constant-cotangent category lacks coproducts.
At higher-order types, projecting only the cotangent coordinate is insufficient: an ambient function–backpropagator package may itself fail to respect the represented input and output fibres. Cartesian closure generates the required full idempotent. Internally it sends \[h\longmapsto e_\sigma h e_\tau.\] Its fixed points are precisely the projector-compatible function packages. Restricted evaluation and currying then give the higher-order translation. No separate ad hoc rule is needed.
Let \(h:\widehat T^*_\sigma\to\widehat T^*_\tau\) be an ambient backpropagator. Correctness on the genuine fibres requires \[\rho_{\tau,x}h\iota_{\sigma,f(x)}=Df(x)^{\mathsf T},\] while being a completed arrow requires \[h=p_{\tau,x}hp_{\sigma,f(x)}.\] Substituting \(p=\iota\rho\) leaves no freedom: \[h = \iota_{\tau,x}Df(x)^{\mathsf T}\rho_{\sigma,f(x)}.\] The formula explains the whole program: project the incoming ambient cotangent to the valid output fibre, apply the genuine transposed derivative, and embed the result into the ambient input carrier.
It also explains the apparently asymmetric functorial laws. For an identity, \(Df(x)^{\mathsf T}=1\) and hence \(h=p_{\tau,x}\). For a composite, the middle retraction–section pair cancels: \[\rho_{\sigma,f(x)}\iota_{\sigma,f(x)}=1,\] so the ordinary chain rule yields strict preservation of composition.
The theorem does not prescribe a dense run-time representation. An ambient direct sum is the semantic vector space in which linear accumulation is defined; an implementation may realise it sparsely, use tagged carriers, or apply the accumulation techniques of Efficient CHAD. The completion result supplies the missing semantic invariant: whatever representation is chosen must implement the projectors and the sandwich equations. In this sense, dependent and simply typed reverse AD are not competing algorithms. They are the same semantics-driven transformation viewed through explicit fibres, completed ambient carriers, and executable ordinary terms.
Fix a regular infinite cardinal \(\kappa\). A set is \(\kappa\)-small when its cardinality is less than \(\kappa\). The subscripted constructions \(\mathsf{Fam}_\kappa\) and \(\mathsf{Copow}_\kappa\) use \(\kappa\)-small index sets; regularity ensures that a \(\kappa\)-small coproduct of \(\kappa\)-small sets is again \(\kappa\)-small. These assumptions are all that the completion theorem requires. For the unadorned higher-order semantic categories \(\mathsf{Fam}\) and \(\mathsf{Copow}\), we fix a Grothendieck universe of small sets large enough to contain the relevant function sets and direct sums. Thus the cartesian-closed constructions below are universe-small without imposing an unsupported closure property on an arbitrary regular infinite cardinal. The finite version is obtained by replacing the \(\kappa\)-small doctrine with finite sets throughout. Our conventions for free completions, enriched copowers, and Cauchy completion follow the standard accounts in [9]–[11].
We write \(\mathbf{Vect}\) for real vector spaces and linear maps, \(\mathbf{Vect}^{\mathrm{op}}\) for its opposite, and \(\mathbf{Set}_{*}\) for pointed sets and basepoint-preserving maps. Our section–retraction notation is always internal to the category under discussion. In particular, in \(\mathbf{Vect}^{\mathrm{op}}\) a section is represented by a projection in \(\mathbf{Vect}\), and a retraction by an inclusion in \(\mathbf{Vect}\). For categories \(\mathcal{A}\) and \(\mathcal{D}\), the functor category is denoted \([\mathcal{A},\mathcal{D}]\).
We begin with the two free completions whose difference creates the variant obstruction. Arbitrary families freely add coproducts, while constant families freely add only set-indexed copowers. These constructions are standard instances of free cocompletion [10], [15]; family categories are also the semantic mechanism used for expressive CHAD and arise naturally in familial descent [6], [30]. Making both universal properties explicit fixes the variance and coherence conventions used throughout the later completion argument.
Definition 2 (Family category). The category \(\mathsf{Fam}_\kappa(\mathcal{C})\) has the following data.
An object is a family \((X_i)_{i\in I}\), where \(I\) is \(\kappa\)-small and \(X_i\in\mathcal{C}\).
A morphism \[(u,\alpha):(X_i)_{i\in I}\longrightarrow(Y_j)_{j\in J}\] consists of a function \(u:I\to J\) and arrows \(\alpha_i:X_i\to Y_{u(i)}\).
Identities and composition are \[1_{(X_i)}=(1_I,(1_{X_i})_{i\in I}),\] \[(v,\beta)\circ(u,\alpha) = (vu,(\beta_{u(i)}\circ\alpha_i)_{i\in I}).\]
The singleton-family embedding is \[\eta_\mathcal{C}:\mathcal{C}\longrightarrow\mathsf{Fam}_\kappa(\mathcal{C}), \qquad X\longmapsto(X)_{*\in1}.\]
If \((X_i^a)_{i\in I_a}\) is a \(\kappa\)-small family of objects of \(\mathsf{Fam}_\kappa(\mathcal{C})\) indexed by \(a\in A\), then its coproduct is concatenation: \[\coprod_{a\in A}(X_i^a)_{i\in I_a} = (X_i^a)_{(a,i)\in\coprod_{a\in A}I_a}.\] The injection from the \(a\)-th summand uses the inclusion \(I_a\to\coprod_b I_b\) and identity component arrows.
The following universal property is the standard free completion by families; see, for example, [10] and [15].
Theorem 5 (Free \(\kappa\)-small coproduct completion). Let \(\mathcal{D}\) have chosen \(\kappa\)-small coproducts. Restriction along \(\eta_\mathcal{C}\) induces an equivalence \[\eta_\mathcal{C}^*: \operatorname{Fun}_{\amalg_\kappa} \bigl(\mathsf{Fam}_\kappa(\mathcal{C}),\mathcal{D}\bigr) \simeq \operatorname{Fun}(\mathcal{C},\mathcal{D}),\] where the left-hand side contains the functors preserving the chosen coproducts and all natural transformations between them.
Proof. Given \(F:\mathcal{C}\to\mathcal{D}\), define \[\overline{F}((X_i)_{i\in I}) = \coprod_{i\in I}F(X_i).\] For \((u,\alpha):(X_i)\to(Y_j)\), define \(\overline{F}(u,\alpha)\) by the coproduct universal property: its restriction to the \(i\)-th summand is \[F(X_i) \xrightarrow{F(\alpha_i)} F(Y_{u(i)}) \xrightarrow{\iota_{u(i)}} \coprod_{j\in J}F(Y_j).\] The restrictions of \(\overline{F}(1)\) and of the identity agree on every summand, so they are equal. For composable \((u,\alpha)\) and \((v,\beta)\), the restrictions of \(\overline{F}(v,\beta)\overline{F}(u,\alpha)\) and \(\overline{F}(vu,\beta\alpha)\) to the \(i\)-th summand are both \[F(X_i) \xrightarrow{F(\alpha_i)} F(Y_{u(i)}) \xrightarrow{F(\beta_{u(i)})} F(Z_{v(u(i))}) \xrightarrow{\iota_{v(u(i))}} \coprod_kF(Z_k).\] Hence \(\overline{F}\) is a functor. It preserves the chosen coproducts because concatenating the indexing sets corresponds to reassociating the chosen coproducts in \(\mathcal{D}\).
A natural transformation \(\theta:F\Rightarrow G\) extends to \[\overline{\theta}_{(X_i)}=\coprod_i\theta_{X_i}.\] Naturality follows by checking each coproduct injection. This defines a functor from the right-hand functor category to the left-hand one.
Conversely, let \(H:\mathsf{Fam}_\kappa(\mathcal{C})\to\mathcal{D}\) preserve the chosen coproducts. Every family is canonically a coproduct of singleton families: \[(X_i)_{i\in I} \cong \coprod_{i\in I}\eta_\mathcal{C}(X_i).\] Therefore \[H((X_i)_{i\in I}) \cong \coprod_{i\in I}H(\eta_\mathcal{C} X_i),\] naturally in the family. Thus \(H\) is naturally isomorphic to the extension of \(H\eta_\mathcal{C}\). The same decomposition shows that a natural transformation between coproduct-preserving functors is uniquely determined by its components on singleton families. Restriction and extension are therefore mutually inverse equivalences. ◻
The family construction is the standard free coproduct completion used in the semantics of expressive CHAD [6]; see also the general free-cocompletion accounts in [10], [15] and the use of family categories in familial descent [30].
The constant-family subcategory retains the same morphism calculus but suppresses variation in the fibre object. Its universal property is correspondingly weaker: it freely supplies copowers, rather than arbitrary coproducts.
Definition 3 (Constant-family category). The category \(\mathsf{Copow}_\kappa(\mathcal{C})\) is the full subcategory of \(\mathsf{Fam}_\kappa(\mathcal{C})\) on constant families. An object is written \((I,X)\). A morphism \[(u,\alpha):(I,X)\longrightarrow(J,Y)\] consists of a function \(u:I\to J\) and arrows \(\alpha_i:X\to Y\) for \(i\in I\).
The singleton embedding is \[\iota_\mathcal{C}:\mathcal{C}\longrightarrow\mathsf{Copow}_\kappa(\mathcal{C}), \qquad X\longmapsto(1,X).\] For a \(\kappa\)-small set \(S\), define \[S\cdot(I,X)=(S\times I,X).\] There is a natural bijection \[\mathsf{Copow}_\kappa(\mathcal{C}) \bigl(S\cdot(I,X),(J,Y)\bigr) \cong \mathbf{Set}\Bigl(S,\mathsf{Copow}_\kappa(\mathcal{C})((I,X),(J,Y))\Bigr),\] obtained by currying the base function \(S\times I\to J\) and the \(S\times I\)-indexed component arrows. Thus \(S\cdot(I,X)\) is the copower by \(S\).
The analogous copower completion is standard enriched-category theory; see [10].
Theorem 6 (Free completion under \(\kappa\)-small copowers). Let \(\mathcal{D}\) have chosen copowers by \(\kappa\)-small sets. Restriction along \(\iota_\mathcal{C}\) induces an equivalence \[\iota_\mathcal{C}^*: \operatorname{Fun}_{\odot_\kappa} \bigl(\mathsf{Copow}_\kappa(\mathcal{C}),\mathcal{D}\bigr) \simeq \operatorname{Fun}(\mathcal{C},\mathcal{D}).\]
Proof. Given \(F:\mathcal{C}\to\mathcal{D}\), define \[\overline{F}(I,X)=I\cdot F(X).\] For \((u,\alpha_i):(I,X)\to(J,Y)\), define \(\overline{F}(u,\alpha)\) by copairing, over \(i\in I\), the maps \[F(X) \xrightarrow{F(\alpha_i)} F(Y) \xrightarrow{\iota_{u(i)}} J\cdot F(Y).\] Identity and composition follow by checking the copower injections. The canonical associativity isomorphism \[S\cdot(I\cdot F(X)) \cong (S\times I)\cdot F(X)\] shows that \(\overline{F}\) preserves the chosen copowers.
Conversely, every object \((I,X)\) is the copower \(I\cdot(1,X)\). Hence a copower-preserving functor is naturally isomorphic to the extension of its restriction to singleton objects. Natural transformations are likewise determined by their singleton components. This proves the equivalence. ◻
The two free completions above add different colimit structure. The Karoubi envelope performs a different operation: it adds the retracts already encoded by idempotents. We use the classical universal description of Cauchy completion [9]–[11] and the semifunctorial perspective developed in programming-language semantics by Hayashi, Hoofman, and Hoofman–Moerdijk [16]–[18]. This is precisely the operation that turns an ambient cotangent carrier with projectors into its family of genuine fibres.
Definition 4 (Karoubi envelope). For a category \(\mathcal{A}\), the objects of \(\mathsf{Kar}(\mathcal{A})\) are pairs \((A,e)\) with \(e:A\to A\) idempotent. A morphism \[f:(A,e)\longrightarrow(B,d)\] is an arrow \(f:A\to B\) in \(\mathcal{A}\) satisfying \[f=dfe.\] The identity on \((A,e)\) is \(e\), and composition is inherited from \(\mathcal{A}\).
The condition \(f=dfe\) is equivalent to the pair of equations \(f=fe=df\). The canonical embedding is \[Q_\mathcal{A}:\mathcal{A}\longrightarrow\mathsf{Kar}(\mathcal{A}), \qquad A\longmapsto(A,1_A).\] Every \((A,e)\) is a retract of \(Q_\mathcal{A}(A)\): both the section and the retraction are represented by \(e\), and their composite on \((A,e)\) is \(e\), the identity of that Karoubi object.
A category is Cauchy complete, or idempotent complete, when every idempotent splits. For ordinary categories this is equivalent to admitting all absolute colimits [9]–[11].
The following universal property is the classical description of Cauchy completion by splitting idempotents [9]–[11].
Theorem 7 (Universal property of the Karoubi envelope). If \(\mathcal{D}\) is Cauchy complete, restriction along \(Q_\mathcal{A}\) induces an equivalence \[Q_\mathcal{A}^*: [\mathsf{Kar}(\mathcal{A}),\mathcal{D}] \simeq [\mathcal{A},\mathcal{D}].\]
Proof. Let \(F:\mathcal{A}\to\mathcal{D}\). For every idempotent \(e:A\to A\), choose a splitting \[F(A) \xrightarrow{q_e} \overline{F}(A,e) \xrightarrow{m_e} F(A),\] with \(m_eq_e=F(e)\) and \(q_em_e=1\). Define \[\overline{F}(f)=q_dF(f)m_e\] for \(f:(A,e)\to(B,d)\). The identity of \((A,e)\) is sent to \[q_eF(e)m_e = q_em_eq_em_e =1.\] For composable \(f:(A,e)\to(B,d)\) and \(g:(B,d)\to(C,c)\), \[\begin{align} \overline{F}(g)\overline{F}(f) &=q_cF(g)m_dq_dF(f)m_e\\ &=q_cF(g)F(d)F(f)m_e\\ &=q_cF(gf)m_e\\ &=\overline{F}(gf), \end{align}\] because \(g=gd\) and \(f=df\). Thus \(\overline{F}\) is a functor. On objects \((A,1_A)\) choose the trivial splitting, so \(\overline{F}Q_\mathcal{A}=F\).
If \(\theta:F\Rightarrow G\), define \[\overline{\theta}_{(A,e)}=q_e^G\theta_A m_e^F.\] Naturality follows by inserting the sandwich equations and the naturality of \(\theta\). Conversely, a natural transformation between extensions is determined by its components on \(Q_\mathcal{A}(A)\) because every \((A,e)\) is a retract of such an object. Different choices of splittings produce naturally isomorphic extensions, through the unique isomorphisms commuting with the splitting maps. Hence restriction is an equivalence. ◻
A semifunctor \(F:\mathcal{X}\rightsquigarrow\mathcal{A}\) assigns objects and arrows and preserves composition, but is not required to preserve identities [17], [18]. For every object \(X\), put \(e_X=F(1_X)\). Then \[e_X^2=F(1_X1_X)=e_X,\] and for \(f:X\to Y\), \[F(f)=F(1_Yf1_X)=e_YF(f)e_X.\] Thus \(F(f)\) is a Karoubi arrow \((FX,e_X)\to(FY,e_Y)\).
The correspondence below is the object-and-arrow form of the embedding of semifunctor theory into ordinary functor theory developed by Hayashi, Hoofman, and Hoofman–Moerdijk [16]–[18].
There is a bijective correspondence on object-and-arrow assignments \[\left\{\text{semifunctors }\mathcal{X}\rightsquigarrow\mathcal{A}\right\} \longleftrightarrow \left\{\text{functors }\mathcal{X}\to\mathsf{Kar}(\mathcal{A})\right\}.\] It sends \(F\) to the functor \[\widetilde{F}(X)=(FX,F1_X), \qquad \widetilde{F}(f)=F(f),\] and sends a Karoubi-valued functor to its underlying semifunctor.
Proof. The equations above show that \(\widetilde{F}(f)\) is a valid Karoubi arrow. It preserves identities because the identity of \((FX,F1_X)\) is \(F1_X\), and it preserves composition because \(F\) does. Conversely, forgetting the distinguished idempotents of a Karoubi-valued functor leaves a composition-preserving assignment. The two constructions are inverse. ◻
Taking as transformations the families \(\theta_X:FX\to GX\) satisfying naturality and \[\theta_X=G1_X\,\theta_X\,F1_X\] yields an equivalence of categories between semifunctors with these transformations and ordinary functors into the Karoubi envelope.
This appendix gives a self-contained proof of the categorical result used in 3. The argument has three steps. First, the common-host condition produces explicit \(\kappa\)-small coproducts in the Karoubi envelope of the constant-family category. Second, the same condition is identified with Cauchy density of the constant-family inclusion. Finally, Cauchy density and idempotent completeness yield the equivalence with the full family category. We conclude by recording the concrete passage between explicit families and ambient carriers equipped with idempotents.
Throughout, \(\kappa\) is a regular infinite cardinal and \(\mathcal{C}\) is a category. The category \(\mathsf{Fam}_\kappa(\mathcal{C})\) has \(\kappa\)-small families \((X_i)_{i\in I}\) as objects. A morphism \[(u,\alpha):(X_i)_{i\in I}\longrightarrow(Y_j)_{j\in J}\] consists of a function \(u:I\to J\) and arrows \(\alpha_i:X_i\to Y_{u(i)}\). The full subcategory on the constant families is \(\mathsf{Copow}_\kappa(\mathcal{C})\); its objects are written \((I,X)\). We denote the constant-family inclusion by \[J_{\mathcal{C}}:\mathsf{Copow}_\kappa(\mathcal{C}) \hookrightarrow\mathsf{Fam}_\kappa(\mathcal{C}).\] An object of \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\) is written \[E=((I,X),(u,p)),\] where \(u^2=u\) and \(p_{u(i)}p_i=p_i\) for every \(i\in I\).
Recall that a family \((X_a)_{a\in A}\) has a common retract host if there are an object \(P\) and arrows \[X_a\xrightarrow{s_a}P\xrightarrow{r_a}X_a, \qquad r_as_a=1_{X_a},\] for every \(a\in A\).
Lemma 7 (Changing to a common carrier). Let \[E_a=((I_a,X_a),(u_a,p^a))\] be objects of \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\), and suppose that the objects \(X_a\) have a common retract host \(P\). Put \[\widetilde{p}^a_i=s_ap^a_ir_a, \qquad \widetilde{E}_a=((I_a,P),(u_a,\widetilde{p}^a)).\] Then \((u_a,\widetilde{p}^a)\) is idempotent and \(E_a\cong\widetilde{E}_a\) in \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\).
Proof. Using \(r_as_a=1\) and \(p^a_{u_a(i)}p^a_i=p^a_i\), we obtain \[\widetilde{p}^a_{u_a(i)}\widetilde{p}^a_i = s_ap^a_{u_a(i)}r_as_ap^a_ir_a = s_ap^a_ir_a = \widetilde{p}^a_i.\] Hence \((u_a,\widetilde{p}^a)\) is idempotent. Define \[\alpha_a= \bigl(u_a,(s_ap^a_i)_{i\in I_a}\bigr):E_a\longrightarrow\widetilde{E}_a, \qquad \beta_a= \bigl(u_a,(p^a_ir_a)_{i\in I_a}\bigr): \widetilde{E}_a\longrightarrow E_a.\] The identities \[\widetilde{p}^a_{u_a(i)}s_ap^a_i=s_ap^a_i, \qquad p^a_{u_a(i)}r_a\widetilde{p}^a_i=p^a_ir_a\] show that these are Karoubi arrows. Their composites have base map \(u_a\) and components \[p^a_{u_a(i)}r_as_ap^a_i=p^a_i, \qquad s_ap^a_{u_a(i)}p^a_ir_a=\widetilde{p}^a_i.\] Thus \(\beta_a\alpha_a=(u_a,p^a)\) and \(\alpha_a\beta_a=(u_a,\widetilde{p}^a)\), which are the identities of the two Karoubi objects. ◻
If every \(\kappa\)-small family in \(\mathcal{C}\) admits a common retract host, then \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\) has \(\kappa\)-small coproducts.
More explicitly, let \[E_a=((I_a,X_a),(u_a,p^a)), \qquad a\in A,\] be a \(\kappa\)-small family, and choose a common host \(X_a\xrightarrow{s_a}P\xrightarrow{r_a}X_a\). Put \[I=\coprod_{a\in A}I_a\] and define \(c=(u,c_{(-)})\) on \((I,P)\) by \[u(a,i)=(a,u_a(i)), \qquad c_{(a,i)}=s_ap^a_ir_a.\] Then \(c\) is idempotent and \[\bigl((I,P),c\bigr)\] is a coproduct of the objects \(E_a\). Its \(a\)-th injection has base map \(i\mapsto(a,u_a(i))\) and component \(s_ap^a_i\) at \(i\).
Proof. Regularity of \(\kappa\) ensures that \(I\) is \(\kappa\)-small. By 7, it is enough to construct a coproduct of \[\widetilde{E}_a=((I_a,P),(u_a,\widetilde{p}^a)), \qquad \widetilde{p}^a_i=s_ap^a_ir_a.\] The equations \[u^2(a,i)=(a,u_a^2(i))=u(a,i), \qquad c_{u(a,i)}c_{(a,i)} = \widetilde{p}^a_{u_a(i)}\widetilde{p}^a_i = c_{(a,i)}\] show that \(c\) is idempotent.
For each \(a\), let \[\widetilde{\iota}_a:\widetilde{E}_a\longrightarrow((I,P),c)\] have base map \(i\mapsto(a,u_a(i))\) and component \(\widetilde{p}^a_i\). This is the sandwich of the ordinary block injection by the source and target idempotents, and hence is a Karoubi arrow.
Let \(H=((J,Y),(w,q))\), and suppose that \[f_a=(v_a,\phi^a):\widetilde{E}_a\longrightarrow H\] are Karoubi arrows. Their sandwich equations are equivalent to \[v_au_a=v_a, \qquad \phi^a_{u_a(i)}\widetilde{p}^a_i=\phi^a_i, \qquad wv_a=v_a, \qquad q_{v_a(i)}\phi^a_i=\phi^a_i.\] Define \((v,\phi):((I,P),c)\to H\) blockwise by \[v(a,i)=v_a(i), \qquad \phi_{(a,i)}=\phi^a_i.\] The four displayed equations give \((v,\phi)c=(v,\phi)\) and \((w,q)(v,\phi)=(v,\phi)\), so this is a Karoubi arrow. Moreover, \[(v,\phi)\widetilde{\iota}_a=f_a\] for every \(a\).
For uniqueness, let \(g=(z,\gamma)\) be another such arrow. Since \(g=gc\), \[z(a,i)=z(a,u_a(i)), \qquad \gamma_{(a,i)}= \gamma_{(a,u_a(i))}\widetilde{p}^a_i.\] The equation \(g\widetilde{\iota}_a=f_a\) then forces \(z(a,i)=v_a(i)\) and \(\gamma_{(a,i)}=\phi^a_i\). Thus \(g=(v,\phi)\). Transporting the injections along the isomorphisms of 7 gives the stated component \(s_ap^a_i\).
When \(A=\varnothing\), the common-host condition supplies an object \(P\). The unique endomorphism of \((\varnothing,P)\) is idempotent, and the resulting Karoubi object has a unique arrow to every object. It is therefore initial. ◻
The construction has a simple interpretation. The host condition is used only to place all ambient objects over one carrier \(P\); the coproduct then concatenates the index sets and places the corresponding idempotents on disjoint blocks. Different choices of host may give different ambient representatives, but the resulting coproducts are canonically isomorphic by the universal property.
We first isolate the standard Cauchy-density argument used below.
Lemma 8 (Cauchy-dense extensions). Let \(J:\mathcal{A}\to\mathcal{D}\) be fully faithful and let \(\mathcal{D}\) be Cauchy complete. Let \[\overline{J}:\mathsf{Kar}(\mathcal{A})\longrightarrow\mathcal{D}\] be an extension of \(J\) along the canonical embedding \(Q_{\mathcal{A}}:\mathcal{A}\to\mathsf{Kar}(\mathcal{A})\). Then \(\overline{J}\) is an equivalence if and only if \(J\) is Cauchy dense.
Proof. Choose \(\overline{J}(A,e)\) as a splitting object of \(J(e)\): \[J(A)\xrightarrow{q_e}\overline{J}(A,e) \xrightarrow{m_e}J(A), \qquad m_eq_e=J(e), \quad q_em_e=1.\] For Karoubi objects \((A,e)\) and \((B,d)\), every arrow \(h:\overline{J}(A,e)\to\overline{J}(B,d)\) determines the ambient arrow \(m_dhq_e:J(A)\to J(B)\). By full faithfulness, it is \(J(f)\) for a unique \(f:A\to B\). The splitting equations imply \(f=dfe\), and \(q_dJ(f)m_e=h\). Hence \(\overline{J}\) is fully faithful.
If \(J\) is Cauchy dense, every object of \(\mathcal{D}\) is a retract of some \(J(A)\). The corresponding idempotent on \(J(A)\) is \(J(e)\) for a unique idempotent \(e\) on \(A\), and the retract is isomorphic to \(\overline{J}(A,e)\). Thus \(\overline{J}\) is essentially surjective. Conversely, every \(\overline{J}(A,e)\) is a retract of \(J(A)\); essential surjectivity of \(\overline{J}\) therefore implies Cauchy density of \(J\). ◻
Lemma 9 (Cauchy completeness of family categories). The category \(\mathsf{Fam}_\kappa(\mathcal{C})\) is Cauchy complete if and only if \(\mathcal{C}\) is Cauchy complete.
Proof. Assume first that \(\mathcal{C}\) is Cauchy complete. Let \((u,\alpha)\) be an idempotent on \((X_i)_{i\in I}\). Put \(I_0=\operatorname{Fix}(u)\). For every \(j\in I_0\), choose a splitting \[X_j\xrightarrow{q_j}\overline{X}_j\xrightarrow{m_j}X_j\] of the idempotent \(\alpha_j\). Define \[q:(X_i)_{i\in I}\longrightarrow(\overline{X}_j)_{j\in I_0}\] to have base map \(i\mapsto u(i)\) and component \(q_{u(i)}\alpha_i\), and define \[m:(\overline{X}_j)_{j\in I_0}\longrightarrow(X_i)_{i\in I}\] to have the inclusion \(I_0\hookrightarrow I\) as base map and component \(m_j\). Then \(qm=1\) and \(mq=(u,\alpha)\), so every idempotent splits.
Conversely, let \(e:X\to X\) be idempotent and split the induced idempotent on the singleton family \((X)\) through a family indexed by \(J\). The base map of the composite from that family to itself is constant, whereas the composite is the identity. Hence \(J\) is a singleton, and the component maps split \(e\) in \(\mathcal{C}\). ◻
For every category \(\mathcal{C}\), there is an equivalence \[\mathsf{Kar}\bigl(\mathsf{Fam}_\kappa(\mathcal{C})\bigr) \simeq \mathsf{Fam}_\kappa\bigl(\mathsf{Kar}(\mathcal{C})\bigr)\] whose restriction along \(Q_{\mathsf{Fam}_\kappa(\mathcal{C})}\) is naturally isomorphic to \(\mathsf{Fam}_\kappa(Q_{\mathcal{C}})\).
Proof. The functor \[\mathsf{Fam}_\kappa(Q_{\mathcal{C}}): \mathsf{Fam}_\kappa(\mathcal{C}) \longrightarrow \mathsf{Fam}_\kappa(\mathsf{Kar}(\mathcal{C}))\] is fully faithful. Its codomain is Cauchy complete by 9, since \(\mathsf{Kar}(\mathcal{C})\) is Cauchy complete. It is Cauchy dense because each family of Karoubi objects is, componentwise, a retract of the corresponding family of objects in the image of \(Q_{\mathcal{C}}\). The result now follows from 8. ◻
Lemma 10 (Retracts of constant families). A family \((X_i)_{i\in I}\) is a retract in \(\mathsf{Fam}_\kappa(\mathcal{C})\) of a constant family if and only if it admits a common retract host in \(\mathcal{C}\).
Proof. If \(P\) is a common host, the family maps with base \(1_I\) and components \(s_i\) and \(r_i\) exhibit \((X_i)_{i\in I}\) as a retract of \((P)_{i\in I}\). Conversely, suppose that \((X_i)_{i\in I}\) is a retract of \((P)_{j\in J}\), with section \((a,s)\) and retraction \((b,r)\). From \((b,r)(a,s)=1\) we obtain \(ba=1_I\) and \[r_{a(i)}s_i=1_{X_i}.\] Thus \(P\) is a common retract host. ◻
Since \(J_{\mathcal{C}}\) is fully faithful, the preceding lemma immediately gives \[J_{\mathcal{C}}\text{ is Cauchy dense} \quad\Longleftrightarrow\quad \text{every \kappa-small family in \mathcal{C} has a common host}.\]
Assume (2). By 9, \(\mathsf{Fam}_\kappa(\mathcal{C})\) is Cauchy complete. By 10, the fully faithful inclusion \(J_{\mathcal{C}}\) is Cauchy dense. Its extension along \[Q:\mathsf{Copow}_\kappa(\mathcal{C}) \longrightarrow \mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\] therefore exists by the universal property of the Karoubi envelope and is an equivalence by 8. This gives (1). The existence of \(\kappa\)-small coproducts in the source of \(\mathfrak R\) was proved independently in [prop:kar-coprod].
Conversely, assume (1). The category \(\mathsf{Kar}(\mathsf{Copow}_\kappa(\mathcal{C}))\) is Cauchy complete, so its equivalent category \(\mathsf{Fam}_\kappa(\mathcal{C})\) is Cauchy complete. By 9, \(\mathcal{C}\) is Cauchy complete. Moreover, \(Q\) is Cauchy dense and \(\mathfrak RQ\cong J_{\mathcal{C}}\); hence \(J_{\mathcal{C}}\) is Cauchy dense. By 10, every \(\kappa\)-small family has a common retract host.
It remains to identify the chosen coproducts. For \(i\in\operatorname{Fix}(u_a)\), choose a splitting \[X_a\xrightarrow{q^a_i}X^a_i\xrightarrow{m^a_i}X_a\] of \(p^a_i\). The block idempotent \(s_ap^a_ir_a\) is then split by \[P\xrightarrow{q^a_ir_a}X^a_i \xrightarrow{s_am^a_i}P.\] Thus realization sends the block indexed by \((a,i)\) to \(X^a_i\). The realized component of the injection is \[(q^a_ir_a)(s_ap^a_i)m^a_i = q^a_ip^a_im^a_i = 1_{X^a_i}.\] Hence the realized object is the concatenation of the realized families and the realized injections are the ordinary family coproduct injections.
The equivalence has a useful concrete description. Let \[E=((I,P),(u,p))\] be a completed constant family. For each \(i\in I_0:=\operatorname{Fix}(u)\), choose a splitting \[P\xrightarrow{q_i}P_i\xrightarrow{m_i}P, \qquad m_iq_i=p_i, \quad q_im_i=1.\] Then \[\mathfrak R(E)=(P_i)_{i\in I_0}.\] If \((f,\phi):E\to F\) is a Karoubi arrow, then \(f\) restricts to a function \(\operatorname{Fix}(u)\to\operatorname{Fix}(v)\) and the realized component at \(i\) is \[q^F_{f(i)}\phi_i m^E_i.\] Thus realization replaces each ambient projector by its splitting object and restricts each ambient arrow to the corresponding images.
Conversely, choose for every family \(X=(X_i)_{i\in I}\) a common host \[X_i\xrightarrow{s_i^X}P_X\xrightarrow{r_i^X}X_i.\] Its ambient presentation is \[\mathfrak P(X)= \left( (I,P_X), \bigl(1_I,(s_i^Xr_i^X)_{i\in I}\bigr) \right).\] A family arrow \((f,\alpha):X\to Y\) is represented by \[\mathfrak P(f,\alpha) = \left( f, (s^Y_{f(i)}\alpha_i r_i^X)_{i\in I} \right).\] The retraction equations make these formulas functorial: the middle factors cancel under composition, and the ambient representative of an identity is the corresponding projector.
Under the hypotheses of 1, the formulas above define inverse equivalences up to natural isomorphism \[\mathfrak R: \mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr) \rightleftarrows \mathsf{Fam}_\kappa(\mathcal{C}):\mathfrak P.\] For compatible choices of splittings, \(\mathfrak R\mathfrak P=1\) strictly.
Proof. Choose the splitting of \(s_i^Xr_i^X\) to be \[P_X\xrightarrow{r_i^X}X_i\xrightarrow{s_i^X}P_X.\] Then \(\mathfrak R\mathfrak P\) is the identity on objects and arrows. For \(E=((I,P),(u,p))\), present \(\mathfrak R(E)\) using the same carrier \(P\) and the splittings of the \(p_i\). This gives \[\mathfrak P\mathfrak R(E)= \left((I_0,P),(1_{I_0},(p_i)_{i\in I_0})\right).\] The arrows with base maps \[I\xrightarrow{u}I_0, \qquad I_0\hookrightarrow I,\] and component \(p_i\) in the corresponding block are inverse Karoubi arrows between \(E\) and \(\mathfrak P\mathfrak R(E)\). Naturality follows from the sandwich equation for a Karoubi arrow. Hence \(\mathfrak P\mathfrak R\cong1\). ◻
In the concrete case \(\mathcal{C}=\mathbf{Vect}^{\mathrm{op}}\), a family \((V_i)_{i\in I}\) may be presented on the single ambient vector space \(\bigoplus_iV_i\), with the coordinate projectors selecting the valid fibre. Splitting those projectors recovers the original family. This is the precise sense in which a dependent cotangent family and a simply typed ambient cotangent equipped with primal-indexed projectors are two representations of the same object.
The common-host hypothesis of 1 is often automatic. This appendix records a general sufficient condition and then specializes it to the examples relevant to the paper. The point is that a host need not be a particular coproduct: either a product or a coproduct can serve, provided that zero morphisms are available.
Let \(\mathcal{C}\) be a category with zero morphisms.
If \(\mathcal{C}\) has \(\kappa\)-small products, then every \(\kappa\)-small family in \(\mathcal{C}\) admits a common retract host.
If \(\mathcal{C}\) has \(\kappa\)-small coproducts, then every \(\kappa\)-small family in \(\mathcal{C}\) admits a common retract host.
Consequently, \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr)\] has \(\kappa\)-small coproducts under either hypothesis. If, in addition, \(\mathcal{C}\) is Cauchy complete, then the constant-family inclusion extends to an equivalence \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathcal{C})\bigr) \simeq \mathsf{Fam}_\kappa(\mathcal{C}).\] The same conclusions hold whenever \(\mathcal{C}\) has a zero object, since a zero object induces zero morphisms.
This is the combination of [lem:common-hosts-products-coproducts,prop:kar-coprod,thm:criterion]. For a product host, the section into the \(i\)-th coordinate has identity as its \(i\)-th component and zero as every other component. For a coproduct host, the retraction from the \(i\)-th summand is identity on that summand and zero on all others. Different choices of hosts generally give different ambient presentations, but the resulting coproduct objects in the Karoubi completion are isomorphic by the coproduct universal property.
The categories \(\mathbf{Vect}\) and \(\mathbf{Vect}^{\mathrm{op}}\) are Cauchy complete, have zero objects, and admit all small products and coproducts. Hence \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathbf{Vect})\bigr) \simeq \mathsf{Fam}_\kappa(\mathbf{Vect})\] and \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathbf{Vect}^{\mathrm{op}})\bigr) \simeq \mathsf{Fam}_\kappa(\mathbf{Vect}^{\mathrm{op}}).\]
For a family \((V_i)_{i\in I}\) in \(\mathbf{Vect}^{\mathrm{op}}\), either of the following may be used as a common host.
The direct sum \(P_\oplus=\bigoplus_iV_i\) in \(\mathbf{Vect}\), regarded as a product in \(\mathbf{Vect}^{\mathrm{op}}\). The coordinate projection \(\pi_i:P_\oplus\to V_i\) in \(\mathbf{Vect}\) represents the section \(V_i\to P_\oplus\) in \(\mathbf{Vect}^{\mathrm{op}}\), while the coordinate injection \(\iota_i:V_i\to P_\oplus\) represents the retraction.
The direct product \(P_\Pi=\prod_iV_i\) in \(\mathbf{Vect}\), regarded as a coproduct in \(\mathbf{Vect}^{\mathrm{op}}\). The product projection represents the coproduct injection in \(\mathbf{Vect}^{\mathrm{op}}\), while the one-coordinate map \(\delta_i:V_i\to P_\Pi\) represents its retraction.
For finite families these hosts agree up to the canonical biproduct isomorphism. For infinite families they generally differ. We use direct sums because they give the sparse, finitely supported ambient representation. With this choice, a family arrow whose backward components are \(\alpha_i^*:Y_{f(i)}\to X_i\) is represented on the \(i\)-th block by \[P_Y \xrightarrow{\pi_{f(i)}} Y_{f(i)} \xrightarrow{\alpha_i^*} X_i \xrightarrow{\iota_i} P_X,\] namely by \(\iota_i\alpha_i^*\pi_{f(i)}\).
Let \(R\) be a ring. The categories \(R\text{-}\mathbf{Mod}\) and \((R\text{-}\mathbf{Mod})^{\mathrm{op}}\) are Cauchy complete, have zero objects, and admit all small products and coproducts. Therefore the same two completion equivalences hold for modules. More generally, any Cauchy-complete category with zero morphisms and the required products or coproducts satisfies [prop:standard-hosts-app]. In particular, this applies to Cauchy-complete additive categories whenever the relevant products or coproducts exist; finite biproducts automatically provide hosts for finite families.
The category \(\mathbf{Set}_{*}\) of pointed sets is Cauchy complete, has a zero object, and admits all small products and coproducts. Thus \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathbf{Set}_{*}^{\mathrm{op}})\bigr) \simeq \mathsf{Fam}_\kappa(\mathbf{Set}_{*}^{\mathrm{op}}).\] A convenient host for a family of pointed sets \((X_i,*)\) is the wedge \[P=\bigvee_{i\in I}X_i.\] The inclusion of the \(i\)-th summand has a pointed retraction that is the identity on that summand and collapses every other summand to the basepoint. After passage to the opposite category, these maps give the required section and retraction. For two branches, the wedge has the shape “zero, a left payload, or a right payload”, and the projectors collapse the unselected branch to zero. This explains the carrier shape of a sparse tagged implementation, although pointed sets themselves do not supply the linear accumulation or transposed derivatives required for cotangent semantics.
This appendix gives the bicartesian closed structure explicitly. Expressive CHAD proves that \(\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\) is bicartesian closed and identifies it as the concrete reverse-mode target [6, Sec. 10.2], Corollary 82, and Equation (68). Together with 1, this already gives a bicartesian closed structure on \(\mathsf{Kar}(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}}))\) by transport across realization. The purpose of this appendix is to describe the terminal object, products, the initial object, coproducts, exponentials, evaluation, and currying directly on ambient constant-cotangent objects and to identify their images under realization.
Put \[\mathcal{K}=\mathsf{Kar}(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})), \qquad \mathcal{F}=\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}}).\]
Theorem 8 (Bicartesian closed realization comparison). The realization equivalence \[\mathfrak R:\mathcal{K}\simeq\mathcal{F}\] can be equipped with coherent comparison isomorphisms for the terminal object, binary products, the initial object, arbitrary coproducts, and exponentials. Consequently, it is an equivalence of bicartesian closed categories.
Proof. Existence follows by transporting the standard bicartesian closed structure of \(\mathcal{F}\) across the equivalence. The remainder of this appendix gives the chosen ambient structure and the comparison isomorphisms explicitly and verifies their compatibility with evaluation and currying. ◻
We now give the explicit ambient account.
An object of \(\mathcal{K}\) is written \[E=((A,V),e), \qquad e=(r,p),\] where \(r:A\to A\) and \(p_a:V\to V\) satisfy \[r^2=r, \qquad p_a p_{r(a)}=p_a.\] Let \[F=((B,W),d), \qquad d=(s,q).\] A morphism \(h:E\to F\) is represented by a function \(h_0:A\to B\) and linear maps \(h_a^*:W\to V\) satisfying \[h_0=s h_0 r, \qquad h_a^*=p_a h_{r(a)}^*q_{h_0(r(a))}. \label{eq:kar-arrow-components}\tag{1}\] These are precisely the component equations for \(h=dhe\).
For \(a\in A_0:=\operatorname{Fix}(r)\), \(p_a\) is an idempotent. Write its image splitting as \[V_a^0=\operatorname{im}(p_a), \qquad V_a^0\xrightarrow{\iota_a^E}V\xrightarrow{\rho_a^E}V_a^0,\] with \[\rho_a^E\iota_a^E=1, \qquad \iota_a^E\rho_a^E=p_a.\] Then \[\mathfrak R(E)=(V_a^0)_{a\in A_0}.\] If \(h:E\to F\), the first equation in 1 restricts \(h_0\) to a function \(A_0\to B_0:=\operatorname{Fix}(s)\), and the realized backward map is \[(\mathfrak Rh)_a^* = \rho_a^E h_a^*\iota_{h_0(a)}^F: W_{h_0(a)}^0\longrightarrow V_a^0. \label{eq:realized-arrow-components}\tag{2}\]
Let \((E_a)_{a\in A}\) be a small family of objects in \(\mathcal{K}\), with \[E_a=\bigl((I_a,V_a),(r_a,p^a)\bigr).\] Put \[I=\coprod_{a\in A}I_a, \qquad P=\bigoplus_{a\in A}V_a,\] and write \(\jmath_a:V_a\to P\) and \(\pi_a:P\to V_a\) for the coordinate maps in \(\mathbf{Vect}\). Define \(c=(r,p)\) on \((I,P)\) by \[\begin{align} r(\mathsf{in}_a(i)) &=\mathsf{in}_a(r_a(i)),\\ p_{\mathsf{in}_a(i)} &=\jmath_a p^a_i\pi_a:P\longrightarrow P. \end{align} \label{eq:arbitrary-vect-coproduct}\tag{3}\] Since the reverse-target composition law gives \[(p\circ p)_{\mathsf{in}_a(i)} = p_{\mathsf{in}_a(i)}p_{r(\mathsf{in}_a(i))},\] we have \[\jmath_a p^a_i\pi_a\jmath_a p^a_{r_a(i)}\pi_a = \jmath_a p^a_i p^a_{r_a(i)}\pi_a = \jmath_a p^a_i\pi_a.\] Thus \(c\) is idempotent.
The injection \(\iota_a:E_a\to((I,P),c)\) is \[(\iota_a)_0(i)=\mathsf{in}_a(r_a(i)), \qquad (\iota_a)^*_i=p^a_i\pi_a:P\longrightarrow V_a. \label{eq:arbitrary-vect-injection}\tag{4}\] Let \(H=((J,W),(s,q))\) and let \(h_a:E_a\to H\) be Karoubi arrows. Define \[[h_a]_{a\in A,0}(\mathsf{in}_a(i))=h_{a,0}(i), \qquad [h_a]_{a\in A,\mathsf{in}_a(i)}^* =\jmath_a h_{a,i}^*:W\longrightarrow P. \label{eq:arbitrary-vect-copairing}\tag{5}\] The target compatibility of each \(h_a\) and its source compatibility with \((r_a,p^a)\) imply the sandwich equation for 5 . Its composite with 4 has primal component \[h_{a,0}(r_a(i))=h_{a,0}(i)\] and backward component \[p^a_i\pi_a\jmath_a h^*_{a,r_a(i)} = p^a_i h^*_{a,r_a(i)} = h^*_{a,i}.\] Hence \([h_a]_{a\in A}\iota_a=h_a\). Conversely, if \(k:((I,P),c)\to H\) has these composites, the equation \(k=kc\) restricts its backward map on the \(a\)-th block to the image of \(\jmath_a p^a_i\pi_a\), while \(k\iota_a=h_a\) fixes that restriction as \(\jmath_a h^*_{a,i}\). The direct-sum universal property then forces 5 ; the primal component is forced branchwise as well. Thus \(((I,P),c)\) is the coproduct of the \(E_a\). For \(A=\varnothing\), this gives \(((\varnothing,0),1)\).
As expected, realization sends this object to the concatenated family \[\bigl(\operatorname{im}(p^a_i)\bigr)_{a\in A,\;i\in\operatorname{Fix}(r_a)},\] because the image of \(\jmath_a p^a_i\pi_a\) is canonically isomorphic to \(\operatorname{im}(p^a_i)\). Under these isomorphisms the displayed injections and copairing become the standard family coproduct maps.
The bicartesian closed structure of \(\mathcal{K}\) is the structure used by the program semantics. The initial object of \(\mathcal{K}\) is \[0_{\mathcal{K}}=((\varnothing,0),1).\] There is a unique ambient arrow from it to every object, so it is also initial in the Karoubi envelope.
Let \[E=((A,V),(r,p)), \qquad F=((B,W),(s,q)).\] Their coproduct is \[E+F = \left( (A+B,V\oplus W),c_{E,F} \right), \label{eq:kar-coproduct-concrete}\tag{6}\] where \[\begin{align} (c_{E,F})_0(\mathsf{inl}(a))&=\mathsf{inl}(r(a)), & (c_{E,F})^*_{\mathsf{inl}(a)}(v,w)&=(p_a(v),0),\\ (c_{E,F})_0(\mathsf{inr}(b))&=\mathsf{inr}(s(b)), & (c_{E,F})^*_{\mathsf{inr}(b)}(v,w)&=(0,q_b(w)). \end{align}\] The equations for \(e\) and \(d\) show branchwise that \(c_{E,F}^2=c_{E,F}\).
The injections are \[\iota_E:E\longrightarrow E+F, \qquad \iota_F:F\longrightarrow E+F,\] with \[(\iota_E)_0(a)=\mathsf{inl}(r(a)), \qquad (\iota_E)_a^*(v,w)=p_a(v),\] \[(\iota_F)_0(b)=\mathsf{inr}(s(b)), \qquad (\iota_F)_b^*(v,w)=q_b(w).\] These are precisely the ambient injections sandwiched by the source and coproduct idempotents.
The realization equivalence sends this coproduct to the branchwise family coproduct because \[\operatorname{Fix}((c_{E,F})_0)=\operatorname{Fix}(r)+\operatorname{Fix}(s),\] and the projector images on the left and right branches are respectively \(\operatorname{im}(p_a)\) and \(\operatorname{im}(q_b)\). The realized injections and copairing are the standard family ones.
Let \[E=((A,V),(r,p)), \qquad F=((B,W),(s,q))\] be objects of \(\mathcal{K}\). The terminal object is \[1_{\mathcal{K}}=((1,0),1).\] There is a unique ambient arrow from every object to \((1,0)\), and it satisfies every sandwich equation because its backward component has domain \(0\).
The product is \[E\times F = \left( (A\times B,V\oplus W), (r\times s,p\oplus q) \right), \label{eq:kar-product}\tag{7}\] where \[(r\times s)(a,b)=(r(a),s(b)),\] \[(p\oplus q)_{(a,b)}(v,w)=(p_a(v),q_b(w)).\] Its projections are \[\pi_E:E\times F\longrightarrow E, \qquad \pi_F:E\times F\longrightarrow F,\] with primal components \[(\pi_E)_0(a,b)=r(a), \qquad (\pi_F)_0(a,b)=s(b),\] and backward components \[(\pi_E)^*_{(a,b)}(v)=(p_a(v),0), \qquad (\pi_F)^*_{(a,b)}(w)=(0,q_b(w)).\] They satisfy the sandwich equations directly.
Let \[G=((C,U),(t,\ell))\] and let \(h:G\to E\) and \(k:G\to F\). Define \[\langle h,k\rangle_0(c)=(h_0(c),k_0(c))\] and \[\langle h,k\rangle_c^*(v,w) =h_c^*(v)+k_c^*(w). \label{eq:kar-product-pairing}\tag{8}\] The sandwich equations for \(h\) and \(k\) imply \[\langle h,k\rangle =(e\times d)\langle h,k\rangle(t,\ell),\] so this is a Karoubi arrow. Moreover, \[\pi_E\langle h,k\rangle=h, \qquad \pi_F\langle h,k\rangle=k,\] because target compatibility gives \(h_c^*p_{h_0(c)}=h_c^*\) and \(k_c^*q_{k_0(c)}=k_c^*\).
For uniqueness, suppose \(m:G\to E\times F\) has these two composites. The projection equations force \[m_0(c)=(h_0(c),k_0(c)).\] Writing \(m_c^*:V\oplus W\to U\), the same equations determine its restrictions to the two biproduct summands: \[m_c^*(v,0)=h_c^*(v), \qquad m_c^*(0,w)=k_c^*(w).\] Linearity therefore forces 8 . This proves the product universal property.
As expected, realization preserves this product through the canonical isomorphisms \[\operatorname{Fix}(r\times s)=\operatorname{Fix}(r)\times\operatorname{Fix}(s),\] \[\operatorname{im}(p_a\oplus q_b) \cong \operatorname{im}(p_a)\oplus\operatorname{im}(q_b).\] Under these isomorphisms the realized projections and pairing are the standard family projections and pairing.
We first record the structure to which the ambient formulas will be compared. We recall the structure of \(\mathcal{F}\), see [6]. Let \[X=(V_a)_{a\in A}, \qquad Y=(W_b)_{b\in B}\] be objects of \(\mathcal{F}\). The terminal object and binary product are \[1_{\mathcal{F}}=(0)_{*\in1}, \qquad X\times Y=(V_a\oplus W_b)_{(a,b)\in A\times B}.\] The initial object is the empty family, and the binary coproduct is branchwise: \[0_{\mathcal{F}}=()_{c\in\varnothing}, \qquad X+Y=(Z_c)_{c\in A+B},\] where \[Z_{\mathsf{inl}(a)}=V_a, \qquad Z_{\mathsf{inr}(b)}=W_b.\]
For the exponential, define \[\mathsf H(X,Y)= \left\{ (f,\phi)\;\middle|\; \begin{array}{l} f:A\to B,\\[-1mm] \phi_a:W_{f(a)}\to V_a\text{ linear for all }a\in A \end{array} \right\}.\] For \((f,\phi)\in\mathsf H(X,Y)\), put \[K_{(f,\phi)}=\bigoplus_{a\in A}W_{f(a)}.\] Then \[Y^X= \bigl(K_{(f,\phi)}\bigr)_{(f,\phi)\in\mathsf H(X,Y)}. \label{eq:fam-exponential}\tag{9}\] The evaluation arrow has primal component \[\mathsf{ev}_0((f,\phi),a)=f(a)\] and backward component \[\mathsf{ev}_{((f,\phi),a)}^*(w) = \bigl(\jmath_a(w),\phi_a(w)\bigr): W_{f(a)}\longrightarrow K_{(f,\phi)}\oplus V_a, \label{eq:fam-evaluation}\tag{10}\] where \(\jmath_a\) is the \(a\)-th direct-sum injection.
For completeness, let \(Z=(U_c)_{c\in C}\) and let \(k:Z\times X\to Y\). Write its backward component as \[k_{c,a}^*=\langle k^U_{c,a},k^V_{c,a}\rangle: W_{k_0(c,a)}\longrightarrow U_c\oplus V_a.\] Its transpose sends \(c\) to \[\left( a\longmapsto k_0(c,a), (k^V_{c,a})_{a\in A} \right)\in\mathsf H(X,Y),\] and its backward component \[\bigoplus_{a\in A}W_{k_0(c,a)}\longrightarrow U_c\] has restriction \(k^U_{c,a}\) to the \(a\)-th summand. Evaluation recovers \(k_0\), \(k^U\), and \(k^V\). Hence these operations are mutually inverse and natural, proving the exponential adjunction in \(\mathcal{F}\).
The ambient category \(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})\) is cartesian closed; the following formulas are the concrete constant-cotangent instance of basic higher-order CHAD [4], [5]. Its exponential from \((A,V)\) to \((B,W)\) has primal set \[H= \left\{ (f,\phi)\;\middle|\; f:A\to B, \;\phi_a:W\to V\text{ linear for all }a\in A \right\}\] and cotangent space \[Z=\bigoplus_{a\in A}W.\] Let \(\jmath_a:W\to Z\) be the direct-sum injections. Ambient evaluation has primal component \[\mathsf{ev}_0((f,\phi),a)=f(a)\] and backward component \[\mathsf{ev}_{((f,\phi),a)}^*(w) = (\jmath_a(w),\phi_a(w)): W\longrightarrow Z\oplus V. \label{eq:ambient-evaluation}\tag{11}\] The ordinary currying operation is obtained by decomposing a backward map into its \(Z\)- and \(V\)-components and using the direct-sum universal property.
The standard fact that the Karoubi envelope of a cartesian-closed category is cartesian closed belongs to the classical Karoubi/semifunctor theory [17], [18]; see also the general Cauchy-completion background in [9]. Here we need its concrete form. Define \[\varepsilon_{E,F}:(H,Z)\longrightarrow(H,Z)\] by \[(\varepsilon_{E,F})_0(f,\phi) = \left( s f r, \bigl(p_a\phi_{r(a)}q_{f(r(a))}\bigr)_{a\in A} \right) \label{eq:exponential-idempotent-base}\tag{12}\] and by the unique backward map satisfying \[(\varepsilon_{E,F})^*_{(f,\phi)}\jmath_a = \jmath_{r(a)}q_{f(r(a))} \qquad(a\in A). \label{eq:exponential-idempotent-back}\tag{13}\] This is the transpose of \[(H,Z)\times(A,V) \xrightarrow{1\times e} (H,Z)\times(A,V) \xrightarrow{\mathsf{ev}} (B,W) \xrightarrow{d} (B,W).\] Equivalently, it is the internal operation \[h\longmapsto dhe.\] It is therefore idempotent. Directly, the base calculation uses \(r^2=r\), \(s^2=s\), \(p_ap_{r(a)}=p_a\), and \(q_bq_{s(b)}=q_b\); the backward calculation follows by checking every direct-sum injection in 13 .
The exponential in \(\mathcal{K}\) is \[F^E=((H,Z),\varepsilon_{E,F}). \label{eq:kar-exponential}\tag{14}\] Its evaluation is the restricted ambient evaluation \[\mathsf{ev}_{E,F} = d\,\mathsf{ev}\,(\varepsilon_{E,F}\times e).\] At an ambient point \(((f,\phi),a)\), its primal component is \[s(f(r(a)))\] and its backward component is \[w\longmapsto \left( \jmath_{r(a)}q_{f(r(a))}(w), p_a\phi_{r(a)}q_{f(r(a))}(w) \right). \label{eq:kar-evaluation-explicit}\tag{15}\]
Let \[G=((C,U),t)\] and let \(k:G\times E\to F\) be a Karoubi arrow. Write its ambient backward map as \[k_{c,a}^*=\langle k^U_{c,a},k^V_{c,a}\rangle.\] Its ambient transpose has primal component \[c\longmapsto \left( a\longmapsto k_0(c,a), (k^V_{c,a})_{a\in A} \right)\] and backward component \(Z\to U\) whose restriction to the \(a\)-th summand is \(k^U_{c,a}\). The ambient exponential adjunction transports the sandwich equation exactly as follows: \[k=d\,k\,(t\times e) \quad\Longleftrightarrow\quad \Lambda(k)=\varepsilon_{E,F}\,\Lambda(k)\,t.\] Hence \(\Lambda(k)\) is a Karoubi arrow \(G\to F^E\). Conversely, restricted evaluation uncarries every Karoubi arrow \(G\to F^E\). Since these are the ordinary mutually inverse currying operations, they are natural and satisfy the triangle equations. This proves the exponential universal property.
Put \[A_0=\operatorname{Fix}(r), \qquad B_0=\operatorname{Fix}(s), \qquad V_a^0=\operatorname{im}(p_a), \qquad W_b^0=\operatorname{im}(q_b).\] The base set of \(\mathfrak R(F)^{\mathfrak R(E)}\) consists of pairs \[(g,\bar\phi), \qquad g:A_0\to B_0, \qquad \bar\phi_a:W_{g(a)}^0\to V_a^0.\] There is a bijection \[\Theta: \operatorname{Fix}((\varepsilon_{E,F})_0) \longrightarrow \mathsf H(\mathfrak R(E),\mathfrak R(F)) \label{eq:exponential-base-comparison}\tag{16}\] given by \[\Theta(f,\phi) = \left( f|_{A_0}, (\rho_a^E\phi_a\iota_{f(a)}^F)_{a\in A_0} \right).\] The inverse bijection sends \((g,\bar\phi)\) to \((\widetilde{g},\widetilde{\phi})\), where \[\widetilde{g}(a)=g(r(a)),\] \[\widetilde{\phi}_a = p_a\iota_{r(a)}^E \bar\phi_{r(a)} \rho_{g(r(a))}^F.\] The fixed-point equations in 12 show directly that the two assignments are inverse.
Fix \((f,\phi)\in\operatorname{Fix}((\varepsilon_{E,F})_0)\) and put \[K_{(f,\phi)}^0 = \bigoplus_{a\in A_0}W_{f(a)}^0.\] This is the fibre of the family exponential at \(\Theta(f,\phi)\). Define \[K_{(f,\phi)}^0 \xrightarrow{\iota_{(f,\phi)}^{\Rightarrow}} Z \xrightarrow{\rho_{(f,\phi)}^{\Rightarrow}} K_{(f,\phi)}^0\] by \[\iota_{(f,\phi)}^{\Rightarrow}\jmath_a^0 = \jmath_a\iota_{f(a)}^F \qquad(a\in A_0),\] \[\rho_{(f,\phi)}^{\Rightarrow}\jmath_a = \jmath_{r(a)}^0\rho_{f(r(a))}^F \qquad(a\in A).\] Then \[\rho_{(f,\phi)}^{\Rightarrow} \iota_{(f,\phi)}^{\Rightarrow}=1,\] and \[\iota_{(f,\phi)}^{\Rightarrow} \rho_{(f,\phi)}^{\Rightarrow} =(\varepsilon_{E,F})^*_{(f,\phi)}.\] The second equation follows by evaluating both maps on each \(\jmath_a\) and using 13 . Thus realization of the ambient exponential fibre gives precisely the family exponential fibre.
Under the base bijection and these splittings, realization of 15 is the family evaluation 10 . Indeed, for fixed \((f,\phi)\), fixed \(a\in A_0\), and \(w\in W_{f(a)}^0\), the realized backward map is \[w\longmapsto \left( \jmath_a^0(w), \rho_a^E\phi_a\iota_{f(a)}^F(w) \right).\] The first component is the cotangent contribution to the function object and the second is the realized backward map at \(a\). Since realization identifies evaluation, it also identifies currying by uniqueness of transposes.
We now pass from the constant-family theorem to the ordinary reverse target of basic CHAD. The cartesian-closed part of the argument is already available: basic CHAD proves that the total reverse category is cartesian closed, and Karoubi completion preserves cartesian closure. The only new task is therefore to construct the finite coproducts required by variants.
Let \[\mathsf T_{\mathsf{Tar}}^{\leftarrow}=\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}^{\mathrm{op}}\] be the ordinary reverse target. We assume that \((\mathsf C_{\mathsf{Tar}},\mathsf L_{\mathsf{Tar}})\) is a categorical model of the basic CHAD target language in the sense of [5]. In particular, \(\mathsf L_{\mathsf{Tar}}\) is locally indexed, its fibres have chosen finite biproducts preserved by reindexing, and it supports cartesian linear-function objects. By [5], \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\) is cartesian closed. For variants, we assume only that \(\mathsf C_{\mathsf{Tar}}\) has finite coproducts.
If \(\mathcal{A}\) is cartesian closed, then \(\mathsf{Kar}(\mathcal{A})\) is cartesian closed. For Karoubi objects \((A,e)\) and \((B,d)\), the exponential may be taken to be \[(B,d)^{(A,e)}=(B^A,\varepsilon_{e,d}),\] where \[\varepsilon_{e,d} = \Lambda\bigl(d\circ\mathrm{ev}\circ(1_{B^A}\times e)\bigr), \qquad \varepsilon_{e,d}(h)=dhe.\] The terminal object and products are obtained by applying the corresponding idempotents componentwise.
This is the standard cartesian-closed structure on the Karoubi completion; see [17], [18]. Applying it to \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\) shows that \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\) is already cartesian closed. We now construct its finite coproducts from the structure already present in the basic CHAD target.
Lemma 11 (Common hosts in the reverse fibres). Let \(X\in\mathsf C_{\mathsf{Tar}}\), and let \((V_i)_{i\in I}\) be a finite family of linear objects. Then \((V_i)_{i\in I}\) admits a common retract host in \(\mathsf L_{\mathsf{Tar}}(X)^{\mathrm{op}}\). One may take \[P=\bigoplus_{i\in I}V_i.\] These common-host presentations are preserved by reindexing.
Proof. In \(\mathsf L_{\mathsf{Tar}}(X)\), let \(\iota_i:V_i\to P\) and \(\pi_i:P\to V_i\) be the chosen biproduct injection and projection. Since \(\pi_i\iota_i=1_{V_i}\), the reversed arrows \[V_i\xrightarrow{\pi_i^{\mathrm{op}}}P \xrightarrow{\iota_i^{\mathrm{op}}}V_i\] form a retract presentation in \(\mathsf L_{\mathsf{Tar}}(X)^{\mathrm{op}}\). Local indexedness makes the linear objects independent of the base, and preservation of the chosen biproducts by reindexing makes these presentations stable under substitution. ◻
Lemma 12 (Branchwise decomposition of linear maps). For \(A,B\in\mathsf C_{\mathsf{Tar}}\) and linear objects \(U,P\), restriction along the coproduct injections induces a natural bijection \[\mathsf L_{\mathsf{Tar}}(A+B)(U,P) \cong \mathsf L_{\mathsf{Tar}}(A)(U,P)\times\mathsf L_{\mathsf{Tar}}(B)(U,P).\] Consequently, a linear map over \(A+B\) is uniquely determined by its two branch restrictions. The induced branchwise case operation is stable under reindexing and satisfies the expected \(\beta\)- and \(\eta\)-equations.
Proof. The cartesian linear-function object \(U\multimap P\) represents linear maps in the base variable, giving natural bijections \[\mathsf L_{\mathsf{Tar}}(X)(U,P)\cong\mathsf C_{\mathsf{Tar}}(X,U\multimap P).\] Hence \[\begin{align} \mathsf L_{\mathsf{Tar}}(A+B)(U,P) &\cong\mathsf C_{\mathsf{Tar}}(A+B,U\multimap P)\\ &\cong\mathsf C_{\mathsf{Tar}}(A,U\multimap P) \times\mathsf C_{\mathsf{Tar}}(B,U\multimap P)\\ &\cong\mathsf L_{\mathsf{Tar}}(A)(U,P)\times\mathsf L_{\mathsf{Tar}}(B)(U,P). \end{align}\] Naturality identifies this bijection with restriction along \(\mathsf{inl}\) and \(\mathsf{inr}\). Its inverse is branchwise linear case analysis, and the two inverse equations give the \(\beta\)- and \(\eta\)-equations. ◻
Thus the two pieces of structure that might otherwise appear as additional variant assumptions are already available: the fibrewise biproducts give the common hosts, while the cartesian linear-function objects derive branchwise linear case analysis from finite coproducts in \(\mathsf C_{\mathsf{Tar}}\).
Let \[E=((A,V),e), \qquad F=((B,W),d),\] where \(e=(r,p)\) and \(d=(s,q)\) are idempotent endomorphisms in \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\). Put \(P=V\oplus W\). Define an endomorphism \(c_{E,F}\) of \((A+B,P)\) by \[\begin{align} c_{E,F,1}(\mathsf{inl}(a)) &=\mathsf{inl}(r(a)), & (c_{E,F})^*_{\mathsf{inl}(a)}(v,w) &=(p_a(v),0),\\ c_{E,F,1}(\mathsf{inr}(b)) &=\mathsf{inr}(s(b)), & (c_{E,F})^*_{\mathsf{inr}(b)}(v,w) &=(0,q_b(w)). \end{align}\] The backward component exists uniquely by 12. Since \[r^2=r, \qquad p_a\circ p_{r(a)}=p_a, \qquad s^2=s, \qquad q_b\circ q_{s(b)}=q_b,\] the same branchwise calculation gives \[c_{E,F}^2=c_{E,F}.\] Set \[E+F:=((A+B,V\oplus W),c_{E,F}).\]
Let \[j_E:(A,V)\longrightarrow(A+B,V\oplus W), \qquad j_F:(B,W)\longrightarrow(A+B,V\oplus W)\] be the ambient injections. Their primal components are \(\mathsf{inl}\) and \(\mathsf{inr}\), and their backward components are the corresponding biproduct projections. Define the completed injections by \[\iota_E=c_{E,F}\circ j_E\circ e, \qquad \iota_F=c_{E,F}\circ j_F\circ d.\] Explicitly, \[(\iota_E)_1=\mathsf{inl}\circ r, \qquad (\iota_E)^*_a(v,w)=p_a(v),\] and \[(\iota_F)_1=\mathsf{inr}\circ s, \qquad (\iota_F)^*_b(v,w)=q_b(w).\]
If \(\mathsf C_{\mathsf{Tar}}\) has finite coproducts, then \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\) has finite coproducts. The binary coproduct of \(E\) and \(F\) is the object \(E+F\) above, and the initial object is \[((0,0),1_{(0,0)}),\] where the first \(0\) is initial in \(\mathsf C_{\mathsf{Tar}}\) and the second is the zero linear object.
Proof. Let \(H=((C,U),h)\), and let \(a:E\to H\) and \(b:F\to H\) be Karoubi arrows. Define an ambient arrow \[[a,b]:(A+B,V\oplus W)\longrightarrow(C,U)\] by ordinary primal copairing and by the branch restrictions \[[a,b]^*_{\mathsf{inl}(x)}(u)=(a_x^*(u),0), \qquad [a,b]^*_{\mathsf{inr}(y)}(u)=(0,b_y^*(u)).\] The latter determine a unique linear map by 12.
The equations \(a=h\circ a\circ e\) and \(b=h\circ b\circ d\) imply, branchwise, \[[a,b]=h\circ[a,b]\circ c_{E,F},\] so \([a,b]\) is a Karoubi arrow \(E+F\to H\). The source-compatibility equations \(a=a\circ e\) and \(b=b\circ d\) give \[[a,b]\circ\iota_E=a, \qquad [a,b]\circ\iota_F=b.\] For example, the left backward component reduces to \[p_x\circ a^*_{r(x)}=a_x^*.\]
Conversely, let \(k:E+F\to H\) satisfy \(k\circ\iota_E=a\) and \(k\circ\iota_F=b\). Since \(k=k\circ c_{E,F}\), on the left branch one has \[k_1(\mathsf{inl}(x)) = k_1(\mathsf{inl}(r(x)))\] and \[k^*_{\mathsf{inl}(x)}(u) = \bigl(p_x\pi_Vk^*_{\mathsf{inl}(r(x))}(u),0\bigr),\] where \(\pi_V:V\oplus W\to V\) is the first biproduct projection. The equation \(k\circ\iota_E=a\) then forces \[k_1(\mathsf{inl}(x))=a_1(x), \qquad k^*_{\mathsf{inl}(x)}(u)=(a_x^*(u),0).\] The right branch is symmetric. The primal coproduct \(\eta\)-equation and the linear \(\eta\)-equation of 12 yield \(k=[a,b]\). This proves the binary coproduct universal property.
Finally, from \((0,0)\) to any ambient object there is a unique arrow: its primal component is the unique map from the initial object, and its backward component is the unique linear map into the zero object. Composing this arrow with any target idempotent leaves it unchanged, so it is also the unique arrow from \(((0,0),1_{(0,0)})\) in the Karoubi completion. ◻
Corollary 2 (Bicartesian closure of the completed reverse target). Let \((\mathsf C_{\mathsf{Tar}},\mathsf L_{\mathsf{Tar}})\) be a categorical model of the basic CHAD target language. If \(\mathsf C_{\mathsf{Tar}}\) has finite coproducts, then \[\mathsf{Kar}\left(\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}^{\mathrm{op}}\right)\] is bicartesian closed.
Proof. Cartesian closure follows from [5] and [prop:kar-ccc-app]; finite coproducts follow from [prop:target-coproducts-app]. ◻
Bicartesian closure determines the transformation abstractly, following the semantics-driven methodology of basic and expressive CHAD [4]–[6]. This section unfolds the new data-type clauses into executable nondependent target terms and records the categorical form of the higher-order clauses. The displayed term rules below are for data-type contexts and results, where the primal component of every generated idempotent is the identity. For arbitrary higher-order contexts, structural maps must instead be restricted by the full source and target idempotents. The invariant throughout is the sandwich equation: each generated map restricts to the valid projector image at its source and lands in the valid image at its target. The presentation also separates this semantic derivation from subsequent implementation optimisations such as sparse accumulation and closure conversion [8].
For clarity, we spell out the clauses that are new for variants or modified by the generated projectors. The data types of the present source fragment are \[\tau,\sigma::= \mathsf{real}^n \mid 1 \mid \tau\times\sigma \mid 0 \mid \tau+\sigma.\] For each type, the translation produces a primal type \(\widehat D_1\tau\), an ambient cotangent type \(\widehat D_2\tau\), and a primal-indexed projector \[p_\tau: \widehat D_1\tau; \widehat D_2\tau \multimap \widehat D_2\tau.\] At ground types and the unit type, \[\widehat D_1(\mathsf{real}^n)=\mathsf{real}^n, \qquad \widehat D_2(\mathsf{real}^n)=\mathsf{real}^n, \qquad p_{\mathsf{real}^n}(x,v)=v,\] \[\widehat D_1(1)=1, \qquad \widehat D_2(1)=0, \qquad p_1(*,0)=0.\] For products, \[\begin{align} \widehat D_1(\tau\times\sigma) &=\widehat D_1\tau\times\widehat D_1\sigma,\\ \widehat D_2(\tau\times\sigma) &=\widehat D_2\tau\oplus\widehat D_2\sigma,\\ p_{\tau\times\sigma}((x,y),(v,w)) &=(p_\tau(x,v),p_\sigma(y,w)). \end{align}\] For sums, \[\begin{align} \widehat D_1(\tau+\sigma) &=\widehat D_1\tau+\widehat D_1\sigma,\\ \widehat D_2(\tau+\sigma) &=\widehat D_2\tau\oplus\widehat D_2\sigma,\\ p_{\tau+\sigma}(\mathsf{inl}(x),(v,w)) &=(p_\tau(x,v),0),\\ p_{\tau+\sigma}(\mathsf{inr}(y),(v,w)) &=(0,p_\sigma(y,w)). \end{align}\] The empty type has no primal values, so its projector has no branch to define. For a context \[\Gamma=x_1:\tau_1,\ldots,x_n:\tau_n,\] put \(\widehat D_2\Gamma=\bigoplus_i\widehat D_2\tau_i\) and let \(p_\Gamma(\gamma,-)\) act componentwise at the primal environment \(\gamma\). We write \(\mathsf{one}_i:\widehat D_2\tau_i\multimap\widehat D_2\Gamma\) for the \(i\)-th biproduct injection.
For a judgement \(\Gamma\vdash t:\tau\) in the data-type fragment, the transformation produces \[\widehat D_1\Gamma\vdash \overleftarrow D_\Gamma(t): \widehat D_1\tau \times (\widehat D_2\tau\multimap\widehat D_2\Gamma).\] Write \(0\) and \(+\) for cotangent zero and addition. The standard CHAD clauses are sandwiched by the generated projectors. We display the projector-modified structural clauses and then give the variant clauses in full; primitive clauses not affected by variants are inherited from basic CHAD [5]. The displayed variable clause is valid because all types in \(\Gamma\) are data types. In an arbitrary higher-order context, let \(e_\Gamma\) denote the product idempotent on the translated context. The structural arrow is the full Karoubi restriction \[\overleftarrow{\mathcal{D}}_{\mathrm{st}}(x_i)=e_{\tau_i}\,\pi_i\,e_\Gamma.\] Thus, for a one-variable context, the erased translation of the identity is \(e_\tau\), not the ambient identity. Its data-type specialization is \[\overleftarrow D_\Gamma(x_i) = \left\langle x_i, \lambda\bar x.\mathsf{one}_i(p_{\tau_i}(x_i,\bar x)) \right\rangle,\] \[\overleftarrow D_\Gamma(\langle\rangle) = \langle\langle\rangle,\lambda\bar u.0\rangle,\] \[\begin{align} \overleftarrow D_\Gamma(\langle t,s\rangle) ={}& \mathbf{let}\;\langle x,x^*\rangle=\overleftarrow D_\Gamma(t)\;\mathbf{in}\\ &\mathbf{let}\;\langle y,y^*\rangle=\overleftarrow D_\Gamma(s)\;\mathbf{in}\\ &\left\langle \langle x,y\rangle, \lambda(\bar x,\bar y). x^*(p_\tau(x,\bar x))+y^*(p_\sigma(y,\bar y)) \right\rangle, \end{align}\] \[\begin{align} \overleftarrow D_\Gamma(\pi_1t) ={}& \mathbf{let}\;\langle(x,y),h\rangle=\overleftarrow D_\Gamma(t)\;\mathbf{in}\\ &\left\langle x,\lambda\bar x.h(p_\tau(x,\bar x),0)\right\rangle, \end{align}\] with a symmetric clause for \(\pi_2\).
For a primitive operation, use its chosen codifferential and compose on both sides with the generated projectors. For a let-binding, suppose \[\overleftarrow D_\Gamma(t)=\langle x,x^*\rangle, \qquad \overleftarrow D_{\Gamma,x:\tau}(s)=\langle y,y^*\rangle.\] Then \[\begin{align} &\overleftarrow D_\Gamma(\mathbf{let}\;x=t\;\mathbf{in}\;s)\\ ={}& \mathbf{let}\;\langle x,x^*\rangle=\overleftarrow D_\Gamma(t)\;\mathbf{in}\\ &\mathbf{let}\;\langle y,y^*\rangle=\overleftarrow D_{\Gamma,x:\tau}(s)\;\mathbf{in}\\ &\left\langle y, \lambda\bar y. \mathbf{let}\;\langle\bar\gamma,\bar x\rangle =y^*(p_\sigma(y,\bar y))\;\mathbf{in} p_\Gamma(\gamma,\bar\gamma)+x^*(p_\tau(x,\bar x)) \right\rangle. \end{align}\]
For injections, \[\begin{align} \overleftarrow D_\Gamma(\mathsf{inl}\,t) ={}& \mathbf{let}\;\langle x,x^*\rangle=\overleftarrow D_\Gamma(t)\;\mathbf{in}\\ &\left\langle \mathsf{inl}(x), \lambda(v,w).x^*(p_\tau(x,v)) \right\rangle, \end{align}\] \[\begin{align} \overleftarrow D_\Gamma(\mathsf{inr}\,t) ={}& \mathbf{let}\;\langle y,y^*\rangle=\overleftarrow D_\Gamma(t)\;\mathbf{in}\\ &\left\langle \mathsf{inr}(y), \lambda(v,w).y^*(p_\sigma(y,w)) \right\rangle. \end{align}\] The ignored ambient coordinate is discarded.
For \[c= \mathsf{case}\;t\;\mathsf{of}\; \{\mathsf{inl}(x)\mapsto s \mid \mathsf{inr}(y)\mapsto r\},\] the complete clause is \[\begin{align} \overleftarrow D_\Gamma(c) ={}&\mathbf{let}\;\langle z,z^*\rangle= \overleftarrow D_\Gamma(t)\;\mathbf{in}\\ &\mathsf{case}\;z\;\mathsf{of}\\ &\quad\mathsf{inl}(x)\mapsto \mathbf{let}\;\langle u,u^*\rangle= \overleftarrow D_{\Gamma,x:\tau}(s)\;\mathbf{in}\\ &\qquad\left\langle u,\lambda\bar u. \mathbf{let}\;\langle\bar\gamma,\bar x\rangle= u^*(p_\rho(u,\bar u))\;\mathbf{in}\right.\\[-.2em] &\left. p_\Gamma(\gamma,\bar\gamma)+ z^*\bigl(p_{\tau+\sigma}(\mathsf{inl}(x),(p_\tau(x,\bar x),0))\bigr) \right\rangle,\\ &\quad\mathsf{inr}(y)\mapsto \mathbf{let}\;\langle v,v^*\rangle= \overleftarrow D_{\Gamma,y:\sigma}(r)\;\mathbf{in}\\ &\qquad\left\langle v,\lambda\bar v. \mathbf{let}\;\langle\bar\gamma,\bar y\rangle= v^*(p_\rho(v,\bar v))\;\mathbf{in}\right.\\[-.2em] &\left. p_\Gamma(\gamma,\bar\gamma)+ z^*\bigl(p_{\tau+\sigma}(\mathsf{inr}(y),(0,p_\sigma(y,\bar y)))\bigr) \right\rangle. \end{align}\] The scrutinee is evaluated once, only the selected branch is differentiated, and the branch cotangent is inserted into the ambient biproduct before the scrutinee backpropagator is called. Idempotence simplifies the nested projector to the expected branch insertion. The abort term is the unique map induced by the initial completed object.
Function types use the cartesian closed structure of \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\). If the domain and codomain are represented by full idempotents \(e_\tau\) and \(e_\sigma\), then \[e_{\tau\Rightarrow\sigma}=\varepsilon_{e_\tau,e_\sigma},\] where the exponential idempotent acts internally by \[h\longmapsto e_\sigma h e_\tau.\] The ambient primal and cotangent types are those of basic higher-order CHAD, but the primal component of \(e_{\tau\Rightarrow\sigma}\) generally projects an ambient function–backpropagator package and is not the identity. The concrete base and backward components in the constant-cotangent model are given by 12 and 13 . For arbitrary contexts, every structural arrow is similarly sandwiched by the full context and result idempotents. In particular, abstraction is restricted currying and application is restricted evaluation: \[\operatorname{ev}_{e_\tau,e_\sigma} = e_\sigma\,\operatorname{ev}(\varepsilon_{e_\tau,e_\sigma}\times e_\tau), \qquad \Lambda_{e_\tau,e_\sigma}(f)=\varepsilon_{e_\tau,e_\sigma}\Lambda(f).\] These are the operations described in 15. Hence the higher-order clauses do not reuse the data-type variable rule: they are forced by cartesian closedness and use the full idempotents, as required by [prop:semi].
This appendix supplies the concrete comparison used in [prop:standard-target-compatibility,thm:comparison] and expands the proof of 4.
Recall the concrete-model assumption of 5. The primal functor \(\mathcal{S}:\mathsf C_{\mathsf{Tar}}\to\mathbf{Set}\) and indexed linear functors \(\mathcal{L}_A:\mathsf L_{\mathsf{Tar}}(A)\to\mathbf{Vect}^{\mathcal{S} A}\) induce \[\llbracket-\rrbracket_\mathsf{Tar}:\mathsf T_{\mathsf{Tar}}^{\leftarrow}\longrightarrow\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}}),\] and therefore \[\llbracket-\rrbracket_{\mathrm{cpl}}: \mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow}) \xrightarrow{\mathsf{Kar}(\llbracket-\rrbracket_\mathsf{Tar})} \mathsf{Kar}(\mathsf{Copow}(\mathbf{Vect}^{\mathrm{op}})) \xrightarrow{\mathfrak R} \mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}}).\] The terminal object, products, and exponentials of \(\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\leftarrow})\) are the standard Karoubi restrictions of the corresponding structure of \(\mathsf T_{\mathsf{Tar}}^{\leftarrow}\). They are preserved by the assumed basic-CHAD comparisons and by the explicit realization comparisons of 8. It remains to check the completed coproduct.
Let \[E=((A,V),(r,p)), \qquad F=((B,W),(s,q)).\] In the following calculation, \(r,s\) denote the functions obtained by applying \(\mathcal{S}\), while \(p_a,q_b\) denote the linear maps obtained by applying the corresponding indexed interpretations. The coproduct idempotent \(c_{E,F}\) has fixed primal points \[\mathsf{inl}(a)\quad(a\in\operatorname{Fix}(r)), \qquad \mathsf{inr}(b)\quad(b\in\operatorname{Fix}(s)).\] At a left fixed point its backward component on \(\mathcal{V} V\oplus\mathcal{V} W\) is \((v,w)\mapsto(p_a(v),0)\), whose image is canonically isomorphic to \(\operatorname{im}(p_a)\). At a right fixed point it is \((v,w)\mapsto(0,q_b(w))\), whose image is canonically isomorphic to \(\operatorname{im}(q_b)\). Consequently, \[\llbracket E+F\rrbracket_{\mathrm{cpl}} \cong \llbracket E\rrbracket_{\mathrm{cpl}} + \llbracket F\rrbracket_{\mathrm{cpl}}.\] Under these image isomorphisms the completed injections and copairing become the family injections and branchwise copairing; the empty coproduct becomes the empty family. This proves [prop:standard-target-compatibility].
Let \(\overleftarrow{\mathcal{D}}_{\mathrm{dep}}:\mathsf{Syn}_{+}\to\mathsf{Fam}(\mathbf{Vect}^{\mathrm{op}})\) be dependent CHAD. Both \(\llbracket-\rrbracket_{\mathrm{cpl}}\overleftarrow{\mathcal{D}}_{\mathrm{Kar}}\) and \(\overleftarrow{\mathcal{D}}_{\mathrm{dep}}\) are bicartesian closed interpretations, and by assumption they agree on every ground type and primitive operation. They satisfy the same declared equations, so the universal property of \(\mathsf{Syn}_{+}\) gives the coherent natural isomorphism of 3.
Every data type in the present grammar is isomorphic, by repeated distributivity, to a finite sum of finite products of Euclidean ground types. The dependent correctness theorem applies to that normal form, and naturality with respect to the structural isomorphisms transports the result back to the original type. Thus the realized backward map is the mathematical transposed derivative on the genuine cotangent fibres.
Let \(t:\tau\to\sigma\) have data-type domain and codomain, write \(f=\llbracket t\rrbracket\), and fix the splitting maps \[T^*_\tau(x) \xrightarrow{\iota_{\tau,x}} \widehat T^*_\tau \xrightarrow{\rho_{\tau,x}} T^*_\tau(x), \qquad \rho_{\tau,x}\iota_{\tau,x}=1, \quad \iota_{\tau,x}\rho_{\tau,x}=p_{\tau,x}.\] Let \(h=\widehat R_t(x)\) be the ambient backward map. The comparison with dependent CHAD gives \[\rho_{\tau,x}h\iota_{\sigma,f(x)} = Df(x)^{\mathsf T},\] while the Karoubi equation gives \[h=p_{\tau,x}hp_{\sigma,f(x)}.\] Substituting \(p=\iota\rho\) yields \[\begin{align} h &= \iota_{\tau,x}\rho_{\tau,x} h \iota_{\sigma,f(x)}\rho_{\sigma,f(x)}\\ &= \iota_{\tau,x} Df(x)^{\mathsf T} \rho_{\sigma,f(x)}. \end{align}\] The same calculation proves uniqueness among ambient maps satisfying the restriction and sandwich equations.
For identities, \(h=\iota\rho=p\). For a composite, the adjacent retraction and section cancel because \(\rho\iota=1\). The semifunctor laws are therefore the transport of ordinary derivative functoriality through the retract presentations.
Let \[t:\mathbb{R}+(\mathbb{R}\times\mathbb{R})\to\mathbb{R}, \qquad t(\mathsf{inl}(x))=x^2, \qquad t(\mathsf{inr}(y,z))=yz.\] Choose the ambient cotangent \(\mathbb{R}^3\). The left fibre is split by \[\iota_L(a)=(a,0,0), \qquad \rho_L(a,b,c)=a,\] and the right fibre by \[\iota_R(b,c)=(0,b,c), \qquad \rho_R(a,b,c)=(b,c).\] The associated projectors are \(p_L=\iota_L\rho_L\) and \(p_R=\iota_R\rho_R\).
On the left branch, \[D(x\mapsto x^2)(x)^{\mathsf T}(\bar r)=2x\bar r,\] so \[\widehat R_t(\mathsf{inl}(x))(\bar r) = \iota_L(2x\bar r) =(2x\bar r,0,0).\] On the right branch, \[D((y,z)\mapsto yz)(y,z)^{\mathsf T}(\bar r) =(z\bar r,y\bar r),\] and hence \[\widehat R_t(\mathsf{inr}(y,z))(\bar r) = \iota_R(z\bar r,y\bar r) =(0,z\bar r,y\bar r).\] Thus the ambient result is the mathematical derivative on the active fibre, followed by its inclusion into the common cotangent host.
The paper is phrased in reverse mode because backpropagation is the practically dominant application and because the cotangent interpretation makes the implementation problem especially familiar. Semantically, however, the construction is not specific to reverse mode. From the outset, CHAD presents forward and reverse differentiation through fibrewise-dual total categories [4]–[6]. The present construction therefore applies to forward mode by choosing the Grothendieck construction before, rather than after, taking fibrewise opposites.
Let \[\mathsf T_{\mathsf{Tar}}^{\rightarrow}=\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}\] be the ordinary forward target. Its concrete constant-tangent semantics is \(\mathsf{Copow}(\mathbf{Vect})\), while the dependent semantics is \(\mathsf{Fam}(\mathbf{Vect})\). Since \(\mathbf{Vect}\) is Cauchy complete and direct sums provide common retract hosts, 1 gives \[\mathsf{Kar}\bigl(\mathsf{Copow}_\kappa(\mathbf{Vect})\bigr) \simeq \mathsf{Fam}_\kappa(\mathbf{Vect}).\]
Corollary 3 (Forward-mode completion). Under the corresponding forward-target hypotheses of basic CHAD [5], and assuming that \(\mathsf C_{\mathsf{Tar}}\) has finite coproducts, assigning the chosen primitive derivatives extends, relative to the selected structures, to a bicartesian closed functor \[\overrightarrow{\mathcal{D}}_{\mathrm{Kar}}:\mathsf{Syn}_{+}\longrightarrow\mathsf{Kar}(\mathsf T_{\mathsf{Tar}}^{\rightarrow}).\] Forgetting the distinguished idempotents yields a semifunctor \[\overrightarrow{\mathcal{D}}_{\mathrm{st}}:\mathsf{Syn}_{+}\rightsquigarrow\mathsf T_{\mathsf{Tar}}^{\rightarrow}\] that preserves composition strictly and sends identities to the corresponding full tangent idempotents. At data types, their primal components are identities and their linear components are the tangent projectors.
If \(t:\tau\to\sigma\) has data-type domain and codomain, denotes a map \(f\) differentiable at \(x\), and \[T_\tau(x) \xrightarrow{\iota_{\tau,x}} \widehat T_\tau \xrightarrow{\rho_{\tau,x}} T_\tau(x)\] and \[T_\sigma(f(x)) \xrightarrow{\iota_{\sigma,f(x)}} \widehat T_\sigma \xrightarrow{\rho_{\sigma,f(x)}} T_\sigma(f(x))\] split the generated tangent projectors, then the complete ambient forward derivative is \[\widehat F_t(x) = \iota_{\sigma,f(x)} \circ Df(x) \circ\rho_{\tau,x}.\] It is the unique linear map \(h:\widehat T_\tau\to\widehat T_\sigma\) satisfying \[h=p_{\sigma,f(x)}hp_{\tau,x}, \qquad \rho_{\sigma,f(x)}h\iota_{\tau,x}=Df(x).\]
Proof. Replace the fibrewise-opposite construction \(\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}^{\mathrm{op}}\) by \(\Sigma_{\mathsf C_{\mathsf{Tar}}}\mathsf L_{\mathsf{Tar}}\). At the object level, the completion theorem and the projector presentation of variants use only primal-indexed idempotents together with finite coproducts and biproducts, and hence carry over unchanged. At the arrow level, removing the fibrewise opposite reverses the variance of the linear maps and exchanges the operational roles of the biproduct injections and projections. Under the corresponding forward-target closure assumptions, the universal property of \(\mathsf{Syn}_{+}\) gives the stated bicartesian closed functor; forgetting the distinguished idempotents gives the semifunctor as in [prop:semi].
Under the equivalence \[\mathsf{Kar}\bigl(\mathsf{Copow}(\mathbf{Vect})\bigr) \simeq \mathsf{Fam}(\mathbf{Vect}),\] the restriction of the ambient tangent map to the splitting objects is the ordinary derivative: \[\rho_{\sigma,f(x)}h\iota_{\tau,x}=Df(x).\] Karoubi compatibility gives \(h=p_{\sigma,f(x)}hp_{\tau,x}\). Substituting \[p_{\sigma,f(x)} = \iota_{\sigma,f(x)}\rho_{\sigma,f(x)}, \qquad p_{\tau,x} = \iota_{\tau,x}\rho_{\tau,x}\] yields \[h = \iota_{\sigma,f(x)} Df(x) \rho_{\tau,x}.\] The same calculation proves uniqueness. Thus the forward and reverse transformations are fibrewise-dual presentations of the same completion principle; the transpose appears only in the reverse concrete semantics. ◻