Change Actions: Models of Generalised Differentiation

Cai et al. have recently proposed change structures as a semantic framework for incremental computation. We generalise change structures to arbitrary cartesian categories and propose the notion of change action model as a categorical model for (higher-order) generalised differentiation. Change action models naturally arise from many geometric and computational settings, such as (generalised) cartesian differential categories, group models of discrete calculus, and Kleene algebra of regular expressions. We show how to build canonical change action models on arbitrary cartesian categories, reminiscent of the F\`aa di Bruno construction.


Introduction
Incremental computation is the process of incrementally updating the output of some given function as the input is gradually changed, without recomputing the entire function from scratch. Recently, Cai et al. [Cai et al., 2014] introduced the notion of change structure to give a semantic account of incremental computation. Change structures have subsequently been generalised to change actions [Alvarez-Picallo et al., 2019], and proposed as a model for automatic differentiation [Kelly et al., 2016]. These developments raise a number of questions about the structure of change actions themselves and how they relate to more traditional notions of differentiation. A change action A = (|A|, ∆A, ⊕ A , + A , 0) is a set |A| equipped with a monoid (∆A, + A , 0 A ) acting on it, via action ⊕ A : |A| × ∆A → |A|. For example, every monoid (S, +, 0) gives rise to a (so-called monoidal) change action (S, S, +, +, 0). Given change actions A and B, consider functions f : |A| → |B|. A derivative of f is a function ∂f : |A| × ∆A → ∆B such that for all a ∈ |A|, δa ∈ ∆A, f (a ⊕ A δa) = f (a) ⊕ B ∂f (a, δa). Change actions and differentiable functions (i.e. functions that have a regular derivative) organise themselves into categories (and indeed 2-categories) with finite (co)products, whereby morphisms are composed via the chain rule.
The definition of change actions (and derivatives of functions) makes no use of properties of Set beyond the existence of products. We develop the theory of change actions on arbitrary cartesian categories and study their properties. A first contribution is the notion of a change action model, which is defined to be a coalgebra for a certain (copointed) endofunctor CAct on the category Cat × of (small) cartesian categories. The functor CAct sends a category C to the category CAct(C) of (internal) change actions and differential maps on C.
There is a natural, extrinsic, notion of higher-order derivative in change action models. In such a model α : C → CAct(C), a C-object A is associated (via α) with a change action, the carrier object of whose monoid is in turn associated with a change action, and so on ad infinitum. We construct a "canonical" change action model, CAct ω (C), that internalises such ω-sequences that exhibit higher-order differentiation. Objects of CAct ω (C) are ωsequences of "contiguously compatible" change actions; and morphisms are corresponding ω-sequences of differential maps, each map being the canonical (via α) derivative of the preceding in the ω-sequence. We show that CAct ω (C) is the final CAct-coalgebra (relativised to change action models on C). The category CAct ω (C) may be viewed as a kind of Faà di Bruno construction [Cruttwell, 2017;Cockett and Seely, 2011] in the more general setting of change action models.
Change action models capture many versions of differentiation that arise in mathematics and computer science. We illustrate their generality via three examples. The first, (generalised) cartesian differential categories (GCDC) [Blute et al., 2009;Cruttwell, 2017], are themselves an axiomatisation of the essential properties of the derivative. We show that a GCDC C-which by definition associates every object A with a monoid L(A) = (L 0 (A), + A , 0 A )-gives rise to change action models in various non-trivial ways. First there is a canonical change action model mapping each object A to the trivial action of L(A) on itself. A second arises from interpreting the identity Id : A × L 0 (A) → A × L 0 (A) as defining an action of L(A) on A in the Kleisli category of the tangent bundle monad.
Secondly we show how discrete differentiation in both the calculus of finite differences [Jordan, 1965] and Boolean differential calculus [Steinbach and Posthoff, 2017;Thayse, 1981] can be modelled using the full subcategory Grp Set of Set whose objects are groups. Our unifying formulation generalises these discrete calculi to arbitrary groups, and gives an account of the chain rule in these settings.
Our third example is differentiation of regular expressions. Recall that Kleene algebra K is the algebra of regular expressions. Thanks to Taylor's Theorem [Hopkins and Kozen, 1999], every polynomial over a commutative K, viewed as an endofunction on K qua (monoidal) change action, has a regular derivative. We show that the algebra of polynomials over a commutative Kleene algebra is a change action model. Interestingly the derivatives are not additive in the second (i.e. vectorial) argument, thus violating GCDC axiom [CD.2].
Outline. In Section 2 we present the basic definitions of change actions and differential maps, and show how they can be organised into categories. The theory of change action is extended to arbitrary cartesian categories C in Section 3: we introduce the category CAct(C) of internal change actions on C. In Section 4 we present change action models, and properties of the tangent bundle functors. In Section 5 we illustrate the unifying power of change action models via three examples. In Section 6, we study the category CAct ω (C) of ω-change actions and ω-differential maps. Missing proofs are provided in the Appendix.

Change actions
A change action is a tuple A = (|A|, ∆A, ⊕ A , + A , 0 A ) where |A| and ∆A are sets, (∆A, + A , 0 A ) is a monoid, and ⊕ A : |A| × ∆A → |A| is an action of the monoid on |A|. We omit the subscript from ⊕ A , + A and 0 A whenever we can.
Remark 2.1. Change actions are closely related to the notion of change structures introduced in [Cai et al., 2014] but differ from the latter in not being dependently typed or assuming the existence of an ⊖ operator. On the other hand, change actions require the change set ∆A to have a monoid structure compatible with the map ⊕, hence neither notion is strictly a generalisation of the other. Whenever one has a change structure, however, one can easily obtain a change action by considering the free monoid generated by its change set.
Definition 2.2 (Derivative condition). Let A and B be change actions. A function f : |A| → |B| is differentiable if there is a function ∂f : |A|× ∆A → ∆B satisfying f (a⊕ A δa) = f (a) ⊕ B ∂f (a, δa), for all a ∈ |A|, δa ∈ ∆A. We call ∂f a derivative for f , and write f : A → B whenever f is differentiable. Proof. Unpacking the definition, we have (g•f )(a)⊕ C ∂(g•f )(a, δa) = g(f (a))⊕ C ∂g(f (a), ∂f (a, δa)) = g(f (a) ⊕ B ∂f (a, δa)) = g(f (a ⊕ A δa)), as desired. 2.2. Two categories of change actions. The study of change actions can be undertaken in two ways: one can consider functions that are differentiable (without choosing a derivative); alternatively, the derivative itself can be considered part of the morphism. The former leads to the category CAct − , whose objects are change actions and morphisms are the differentiable maps. The category CAct − was the category we originally proposed [Alvarez-Picallo et al., 2019]. It is well-behaved, possessing limits, colimits, and exponentials, which is a trivial corollary of the following result: Theorem 2.8. The category CAct − of change actions and differentiable morphisms is equivalent to PreOrd, the category of preorders and monotone maps.

Proof. See Appendix A
The actual structure of the limits and colimits in CAct − is, however, not so satisfactory. One can, for example, obtain the product of two change actions A and B by taking their product in PreOrd and turning it into a change action, but the corresponding monoid action map ⊕ is not, in general, easily expressible, even if those for A and B are. Derivatives of morphisms in CAct − can also be hard to obtain, as exhibiting f as a morphism in CAct − merely proves it is differentiable but gives no clue as to how a derivative might be constructed.
A more constructive approach is to consider morphism as a function together with a choice of a derivative for it.
Definition 2.9. Given change actions A and B, a differential map f : A → B is a pair (|f |, ∂f ) where |f | : |A| → |B| is a function, and ∂f : |A| × ∆A → ∆B is a regular derivative for |f |.
Finite products and coproducts exist in CAct (see Theorems 3.1 and 3.4 for a more general statement). Whether limits and colimits exist in CAct beyond products and coproducts is open.
Remark 2.10. If one thinks of changes (i.e. elements of ∆A) as morphisms between elements of |A|, then regularity resembles functoriality. This intuition is explored in Appendix F, where we show that categories of change actions organise themselves into 2-categories.

Adjunctions with Set.
There is an obvious forgetful functor F : CAct → Set that maps every change action A to its underlying set |A| and every differential map f : A → B to the function on the underlying sets |f | : |A| → |B|.
Given a change action A on a set |A|, the structure of the change action defines a preorder ≤ on |A| where a ≤ b whenever there exists some δa such that a ⊕ δa = b (indeed, one can think of change actions as particular presentations of preorders). Then we can define a quotient functor Q : CAct → Set that maps the change action A to the set |A|/∼, where ∼ is the transitive and symmetric closure of ≤; and the action on morphisms Finally, there is a functor D : Set → CAct that maps every set A to the discrete change action (A, 1, Id, !, !) (where 1 denotes the terminal object in Set and ! the universal morphism). This functor D sends every function f to the differential map (f, !).
In what follows we will make use of the fact that F • D = Q • D = Id Set .
Lemma 2.11. The forgetful functor F is right-adjoint to the functor D, with the unit and counit given by: Lemma 2.12. The functor D is right adjoint to the quotient functor Q, with unit and counit given by: where [Id A ] is the map that sends an element a in A to the equivalence class [a] of a modulo ∼ ≤ . Note that η is well-defined since whenever a ⊕ δa = b it is the case that [a] = [b].
In what follows we assume the Axiom of Choice. This is equivalent to the assumption that every set is the underlying set of some group. We will suppose a map G that sends each set A to a group G A whose underlying set is A.
Definition 2.13. The functor G : Set → CAct maps every object to the monoidal change action (G A , G A , +, +, 0), and every function f : A → B to the differential map (f, A straightforward consequence of this definition is that G is full and faithful.
Lemma 2.14. The functor G is a right adjoint to the forgetful functor F.
Proof. If one uses the hom-set isomorphism definition of adjunction, it follows trivially from the fact that every function into a change action of the form G(A) has one and only one derivative.
Remark 2.15. In a nutshell, this means there is a sequence of four adjunctions where Q preserves finite products and D, G are full and faithful. This is precisely the setting of Lawvere's notion of differential cohesion [nLab authors, 2018] (with the exception that CAct is not a topos), which has been proposed to unify many settings for higher differential geometry.
It is a topic of ongoing research to put this fact in the context of the recent advances in differential cohesive type theory [Gross et al., 2018;Shulman, 2018] (the internal language of a topos with differential cohesion), which have recently been used to give a constructive formalization of Brouwer's fixed point theorem [Shulman, 2018].

Change actions on arbitrary categories
The definition of change actions makes no use of any properties of Set beyond the existence of products. Indeed, change actions can be characterised as just a kind of multi-sorted algebra, which is definable in any category with products.
3.1. The category CAct(C). Consider the category Cat × of (small) cartesian categories (i.e. categories with chosen finite products) and product-preserving functors. We can define an endofunctor CAct : Cat × → Cat × sending a category C to the category of (internal) change actions on C.
The objects of CAct(C) are tuples A = (|A|, ∆A, ⊕ A , + A , 0 A ) where |A| and ∆A are (arbitrary) objects in C, (∆A, + A , 0 A ) is a monoid object in C, and ⊕ A : |A| × ∆A → |A| is a C-morphism such that the following diagrams-specifying monoid action-commute (omitting the obvious structural morphisms): Given objects A, B in CAct(C), the morphisms of CAct(A, B) are pairs f = (|f |, ∂f ) where |f | : |A| → |B| and ∂f : |A| × ∆A → ∆B are morphisms in C, such that the following diagrams commute: The first diagram states the derivative condition: |f |(x ⊕ A δx) = |f |(x) ⊕ B ∂f (x, δx). The other two assert a diagrammatic version of the regularity of ∂f . The chain rule can then be expressed naturally by pasting two instances of the previous diagram: Now, given a product-preserving functor F : C → D, there is a corresponding functor CAct(F) : CAct(C) → CAct(D) given by: We can embed C fully and faithfully into CAct(C) via the functor η C which sends an object A of C to the "trivial" change action A ⋆ = (A, ⊤, π 1 , !, !) and every morphism f : A → B of C to the morphism (f, !). As before, this functor extends to a natural transformation from the identity functor to CAct.
Additionally, there is an obvious forgetful functor ε C : CAct(C) → C, which defines the components of a natural transformation ε from the functor CAct to the identity endofunctor Id.
3.2. Products and coproducts in CAct(C). We have defined CAct as an endofunctor on cartesian categories. This is well-defined: if C has all finite (co)products, so does CAct(C). Let A = (|A|, ∆A, ⊕ A , + A , 0 A ) and B = (|B|, ∆B, ⊕ B , + B , 0 B ) be change actions on C. We present their product and coproducts as follows.

Proof. See Appendix B
Theorem 3.2. The change action ⊤ = (⊤, ⊤, π 1 , π 1 , Id ⊤ ) is the terminal object in CAct(C), where ⊤ is the terminal object of C. Furthermore, if A is a change action every point |f | : ⊤ → |A| in C is differentiable, with (unique) derivative 0 A .

Proof. See Appendix B
Whenever we have a differential map f : A × B → C between change actions, we can compute its derivative ∂f by adding together its "partial" derivatives: 2 .

Proof. See Appendix B
3.3. Change actions as Lawvere theories. According to their definition, change actions seem nothing more than multi-sorted algebras. This is perhaps misleading in that it suggests that differential maps should correspond to algebra homomorphisms, which is in fact false: a homomorphism of change actions A, B would be a pair (u, v) where |u| : |A| → |B| is a function and v : ∆A → ∆B is a monoid homomorphism such that u(a ⊕ δa) = u(a) ⊕ v(δa). That is to say, a homomorphism of change actions as algebras is precisely a homomorphism of monoid actions.
There is a sense, however, in which differential maps are exactly algebra homomorphisms. To make this precise, we require a few new definitions.
Definition 3.5. The ∆-theory T ∆ is the free Cartesian category generated by objects X, ∆X and morphisms ⊕ : X × ∆X → X + : ∆X × ∆X → ∆X 0 : 1 → ∆X subject to the equations: A ∆-algebra on a Cartesian category C is a product-preserving functor from T ∆ into C.
Remark 3.6. Every ∆-algebra F : T ∆ → C corresponds to a change action on C given by: Conversely, every change action on C induces a ∆-algebra. However, ∆-algebra homomorphisms do not correspond to differentiable morphisms, hence the category of ∆-algebras and ∆-algebra homomorphisms is not equivalent to the category CAct of change actions.
Definition 3.7. The T-theory T T is the free Cartesian category generated by objects X, TX and morphisms ⊕ : TX → X Π : TX → X A T-algebra on a Cartesian category C is a product-preserving functor from T T into C. A homomorphism of T-algebras F, G is a natural transformation φ : F → G.
Lemma 3.8. Consider the product-preserving functor T : T T → T ∆ defined by: Every ∆-algebra F corresponds then to a T-algebra F • T. Furthermore, given ∆-algebras F, G, there is a one-to-one correspondence between T-algebra homomorphisms φ : F • T → G • T and pairs (f, f ′ ) of a differentiable function f and its derivative f ′ between the underlying change actions F, G.

Proof. See Appendix B
These definitions exhibit ∆-algebras and T-algebras as multi-sorted Lawvere algebras. Differential morphisms between ∆-algebras are precisely Lawvere homomorphisms when the corresponding ∆-algebras are regarded as T-algebras.
The parallel between ∆-algebras and T-algebras is strikingly similar to the connection between (generalized) Cartesian differential categories and categories with tangent structure that was outlined in [Cockett and Cruttwell, 2014].
3.4. Stable derivatives and additivity. We do not require derivatives to be additive in their second argument; indeed in many cases they are not. Under some simple conditions, however, (regular) derivatives can be shown to be additive. Definition 3.9. Given a (internal) change action A and arbitrary objects |B|, |C| in a cartesian category C, a morphism u : |A| × |B| → |C| is stable whenever the following diagram commutes: If one thinks of ∆A as the object of "infinitesimal" transformations on |A|, then the preceding definition says that a morphism u : |A|×|B| → |C| is stable whenever infinitesimal changes on the input A do not affect its output.
It is straightforward to see that the category Stab(C) of change actions and differential maps with stable derivatives is a subcategory of CAct(C).

Higher-order derivatives: the extrinsic view
In this section we study categories in which every object is equipped with a change action, and every morphism specifies a corresponding differential map. This provides a simple way of characterising categories which are models of higher-order differentiation purely in terms of change actions. 4.1. Change action models. Recall that a copointed endofunctor is a pair (F, σ) where the endofunctor F : C → C is equipped with a natural transformation σ : F Definition 4.1. We call a coalgebra α : C → CAct(C) of the copointed endofunctor (CAct, ε) a change action model (on C).
Given an object A of C, the coalgebra α specifies a (internal) change action α(A) = (A, ∆A, ⊕ A , + A , 0 A ) in CAct(C). (We abuse notation and write ∆A for the carrier object of the monoid specified in α(A); similarly for + A , ⊕ A , and 0 A .) Given a morphism f : second derivative for f . Iterating this process, we obtain an n-th derivative ∂ n f for every C-morphism f . Thus change action models offer a setting for reasoning about higher-order differentiation.
4.2. Tangent bundles in change action models. In differential geometry the tangent bundle functor, which maps every manifold to its tangent bundle, is an important construction. There is an endofunctor on change action models reminiscent of the tangent bundle functor, with analogous properties.
The tangent bundle functor T preserves products up to isomorphism, i.e. for all objects A, B of C, we have T(A × B) ∼ = TA × TB and T1 ∼ = 1. In particular, φ A,B := π 11 , π 12 , π 21 , π 22 : TA × TB → T(A × B) is an isomorphism. Consequently, given maps f : A → B and g : A → C, then, up to the previous isomorphism, T f, g = Tf , Tg .
A consequence of the structure of products in CAct(C) is that the map ⊕ A×B inherits the pointwise structure in the following sense: It will often be convenient to operate directly on the functor T, rather than on the underlying derivatives. For these, the following results are useful: Lemma 4.4. The following families of morphisms are natural transformations: π 1 , ⊕ A : T(A) → A, z := Id, 0 : A → T(A), l := π 1 , 0 , π 2 , 0 : T(A) → T 2 (A). Additionally, the triple (T, z, T⊕) defines a monad on C.

Proof. See Appendix C
A particularly interesting class of change action models are those that are also cartesian closed. Surprisingly, this has as an immediate consequence that differentiation is itself internal to the category.

Proof. See Appendix C
Under some conditions, we can classify the structure of the exponentials in (CAct, ε)coalgebras. This requires the existence of an infinitesimal object. 4 Definition 4.6. If C is cartesian closed, an infinitesimal object D is an object of C such that the tangent bundle functor T is represented by the covariant Hom-functor D ⇒ (·), i.e. there is a natural isomorphism φ : (D ⇒ (·)) .

− → T.
Lemma 4.7. Whenever there is an infinitesimal object in C, the tangent bundle T(A ⇒ B) is naturally isomorphic to A ⇒ TB.
We would like the tangent bundle functor to preserve the exponential structure; in particular we would expect a result of the form ∂ (λy.t) ∂x = λy. ∂ t ∂x , which is true in differential λ-calculus [Ehrhard and Regnier, 2003]. Unfortunately it seems impossible to prove in general that this equation holds, although weaker results are available. If the tangent bundle functor is representable, however, additional structure is preserved.
Theorem 4.8. The isomorphism between the functors T(A ⇒ (·)) and A ⇒ T(·) respects the structure of T, in the sense that the following diagram commutes: The concept "infinitesimal object" is borrowed from synthetic differential geometry [Kock, 2006]. However, there is nothing intrinsically "infinitesimal" about these objects here.
Proof. See Appendix C 5. Examples of change action models 5.1. Generalised cartesian differential categories. Generalised cartesian differential categories (GCDC) [Cruttwell, 2017]-a recent generalisation of cartesian differential categories [Blute et al., 2009]-are models of differential calculi. We show that change action models generalise GCDC in that GCDCs give rise to change action models in three 5 different (non-trivial) ways. In this subsection let C be a GCDC (we assume familiarity with the definitions and notations in [Cruttwell, 2017]).
1. The Flat Model. Define the functor α : Theorem 5.1. The functor α is a change action model.
Proof. See Appendix D 2. The Kleisli Model. GCDCs admit a tangent bundle functor, defined analogously to the standard notion in differential geometry. Let f : A → B be a C-morphism. Define the tangent bundle functor T : C → C as: TA := A × L 0 (A), and Tf : Thus we can define the Kleisli category of this functor by C T which has geometric significance as a category of generalised vector fields. We define the functor α T : Lemma 5.2. α T is a change action model.

Proof. See Appendix D
Remark 5.3. The converse is not true: in general the existence of a change action model on C does not imply that C satisfies the GCDC axioms. However, if one requires, additionally, (∆A, + A , 0 A ) to be commutative, with ∆(∆A) = ∆A and ⊕ ∆A = + A for all objects A, and some technical conditions (stability and uniqueness of derivatives), then it can be shown that C is indeed a GCDC. 5.2. Difference calculus and Boolean differential calculus. Consider the full subcategory Grp Set of Set whose objects are all the groups 6 . This is a cartesian closed category which can be endowed with the structure of a (CAct, ε)-coalgebra α in a straightforward way.
This result is interesting. In the calculus of finite differences [Jordan, 1965], the discrete derivative (or discrete difference operator ) of a function f : Finite difference calculus [Gleich, 2005;Jordan, 1965] has found applications in combinatorics and numerical computation. Our formulation via change action model over Grp Set has several advantages. First it justifies the chain rule, which seems new. Secondly, it generalises the calculus to arbitrary groups. To illustrate this, consider the Boolean differential calculus [Steinbach and Posthoff, 2017;Thayse, 1981], a theory that applies methods from calculus to the space B n of vectors of elements of some Boolean algebra B.
Definition 5.5. Given a Boolean algebra B and function f : Lemma 5.6. The Boolean derivative of f : B n → B m coincides with its derivative qua morphism in Grp Set : ∂f ∂x i (u 1 , . . . , u n ) = ∂f ((u 1 , . . . , u n ), ⊤ i ). Proof. See Appendix D.0.1 5.3. Polynomials over commutative Kleene algebras. The algebra of polynomials over a commutative Kleene algebra [Hopkins and Kozen, 1999;Kleene, 1956] (see [Lombardy and Sakarovitch, 2004;Esparza et al., 2010] for work of a similar vein) is a change action model. Recall that Kleene algebra is the algebra of regular expressions [Brzozowski, 1964;Conway, 1971]. Formally a Kleene algebra K is a tuple (K, +, ·, ⋆ , 0, 1) such that (K, +, ·, 0, 1) is an idempotent semiring under + satisfying, for all a, b, c ∈ K: Henceforth fix a commutative Kleene algebra K. Define the algebra of polynomials K[x] as the free extension of the algebra K with elements x = x 1 , . . . , x n . We write p(a) for the value of p(x) evaluated at x → a. Polynomials, viewed as functions, are closed under composition: when p ∈ K[x], q 1 , . . . , q n ∈ K[y] are polynomials, so is the composite p(q 1 (y), . . . , q n (y)). Given to mean the result of evaluating the polynomial ∂ p ∂x i (x) at x → e. Theorem 5.7 (Taylor's formula [Hopkins and Kozen, 1999] . The category of finite powers of K, K × , has all natural numbers n as objects. The mor- Composition of morphisms is the usual composition of polynomials.
Lemma 5.8. The category K × is a cartesian category, endowed with a change action model α : Remark 5.9. Interestingly derivatives are not additive in the second argument. Take p(x) = x 2 . Then ∂p(a, b + c) > ∂p(a, b) + ∂p(a, c). It follows that K[x] cannot be modelled by GCDC (because of axiom [CD.2]).
6. ω-change actions and ω-differential maps A change action model α : C → CAct(C) is a category that supports higher-order differentials: each C-object A is associated with an ω-sequence of change actions-α(A), α(∆A), α(∆ 2 A), . . .in which every change action is compatible with the neighbouring change actions. We introduce ω-change actions as a means of constructing change action models "freely": given a cartesian category C, the objects of the category CAct ω (C) are all ω-sequences of "contiguously compatible" change actions.
Proof. See Appendix E Proposition 6.6. Composition of pre-ω-differential maps is associative: given pre-ω-differential Proof. See Appendix E Definition 6.7. Given pre-ω-differential maps is an ω-sequence of C-objects, and for each j ≥ 0, ⊕ A j and + A j are ω-sequences, satisfying Definition 6.9. Given pre-ω-change actions A and B (using the preceding notation), a pre-ω-differential map [ We say that a pre-ω-change action A is an ω-change action if, for each i ≥ 0, ⊕ A i and + A i are ω-differential maps.
Remark 6.10. It is important to sequence the definitions appropriately. Notice that we only define ω-differential maps once there is a notion of pre-ω-change action, but pre-ωchange actions need pre-ω-differential maps to make sense of the monoidal sum + j and action ⊕ j . The reason for requiring each ⊕ A i and + A i in an ω-change object i ]) to be ω-differential is so that A is internally a change action in CAct ω (C) (see Def. 6.15).
Lemma 6.11. Let f : A → B and g : B → C be ω-differential maps. Qua pre-ω-differential maps, their composite [ it follows that composition of ω-differential maps is associative.
Proof. See Appendix E Lemma 6.12. For any ω-change action A, the pre-ω-differential map Id : [A i ] → [A i ] is ω-differential. Hence Id := Id : A → A satisfies the identity laws.
• CAct ω (C) is the category whose objects are the ω-change actions over C and whose morphisms are the ω-differential maps.
is the functor mapping the ω-change action ( Theorem 6.16. The category CAct ω (C) is cartesian, with product given in Def. 6.13. Moreover if C is closed and has countable limits, CAct ω (C) is cartesian closed.
Theorem 6.18 (Relativised final coalgebra). Let C be a change action model. The canonical change action model γ : CAct ω (C) → CAct(CAct ω (C)) is a relativised 8 final coalgebra of (CAct, ε). I.e. for all change action models on C, α : C → CAct(C), there is a unique coalgebra homomorphism α ω : C → CAct ω (C), as witnessed by the commuting diagram: Proof. We first exhibit the functor α ω : C → CAct ω (C). Take a C-morphism f : A → B. We define the ω-differential map α ω (f ) : is the ω-change action determined by A under iterative actions of α. I.e. for each i ≥ 0: A i := ∆ i A (by abuse of notation, we write ∆A ′ to mean the carrier object of the monoid of the internal change action α(A ′ ), for any C-object A ′ ); The ω-sequence f := [f i ] is defined by induction: f 0 := f ; assume f n : (D A) n → B n is defined and suppose α(f n ) = (f n , ∂f n ) then define f n+1 := ∂f n .
Intuitively any change action model on C is always a "subset" of the change action model on CAct ω (C).
Theorem 6.19. The category CAct ω (C) is the limit in Cat × of the diagram D CAct(C) CAct(CAct(C)) CAct(CAct(CAct(C))) . . . Our work is also closely related to Cockett, Seely and Cruttwell's work on cartesian differential categories [Blute et al., 2009[Blute et al., , 2010Cockett and Cruttwell, 2014] and Cruttwell's more recent work on generalised cartesian differential categories [Cruttwell, 2017]. Both cartesian differential categories and change action models aim to provide a setting for differentiation, and the construction of ω-change actions resembles the Faà di Bruno construction [Cruttwell, 2017;Cockett and Seely, 2011] (especially its recent reformulation by Lemay 9 [Lemay, 2018]) which, given an arbitrary category C, builds a cofree cartesian differential category for it). The main differences between these two settings lie in the specific axioms required (change action models are significantly weaker: see Remark 5.3) and the approach taken to define derivatives.
This last point is of particular interest: cartesian differential categories assume there is a notion of differentiation in place that satisfies certain coherence conditions, whereas change actions give an algebraic definition of what it means for a function to have a derivative in terms of the change action structure. In this sense, the derivative condition is close to the Kock-Lawvere axiom from synthetic differential geometry [Kock, 2006;Lavendhomme, 2013], which has provided much of the driving intuition behind this work, and making this connection precise is the subject of ongoing research.
In a different direction, the nice interplay between derivatives, products and exponentials in closed change action models (see Theorem 4.8) suggests that there should be a reasonable calculus for change action models. It would be interesting to formulate such a calculus and explore its connections to the differential λ-calculus [Ehrhard and Regnier, 2003]. This could also lead to practical applications to languages for incremental computation, or even higher-order automatic differentiation [Kelly et al., 2016].
In conclusion, change actions and change action models constitute a new setting for reasoning about differentiation that is able to unify "discrete" and "continuous" models, as well as higher-order functions. Change actions are remarkably well-behaved and show tantalising connections with geometry and 2-categories. We believe that most ad hoc notions of derivatives found in disparate subjects can be elegantly integrated into the framework of change action models. We therefore expect any further work in this area to have the potential of benfitting these notions of derivatives.
Appendix A. Supplementary materials for Section 2 Proposition A.1. Whenever f : A → B is differentiable and has a unique derivative ∂f , this derivative is regular.
Remark A.2. One may wonder whether every differentiable function admits a regular derivative: the answer is no. Consider the change actions: Proof.
Proof. Consider an arbitrary change action A = (|A|, ∆A, ⊕, +, 0). Its structure as a change action induces a natural preorder on the base set |A|.
Definition A.5 (Reachability preorder). For a, b ∈ |A|, we define a ⊑ b iff there is a δa ∈ ∆A such that a ⊕ δa = b. Then ⊑ defines a preorder on |A|.
The intuitive significance of the reachability preorder induced by A is that it contains all the information about differentiability of functions from or into A. This is made precise in the following result: Lemma A.6. A function f : |A| → |B| is differentiable as a function from A to B iff it is monotone with respect to the reachability preorders on A, B.
Proof. Let f be a differentiable function, with ∂f an arbitrary derivative, and suppose a ⊑ A a ′ . Hence there is some δa such that a ⊕ δa = a ′ . Then, by the derivative property, Conversely, suppose f is monotone, and pick arbitrary a ∈ A, δa ∈ ∆A. Since a ⊑ A a ⊕ δa and f is monotone, we have f (a) ⊑ B f (a ⊕ δa) and therefore there exists a δb ∈ ∆B such that f (a) ⊕ δb = f (a ⊕ δa). We define ∂f (a, ∆a) to be precisely such a change δb (note that the process of arbitrarily picking a δb for every pair a, δa makes use, in general, of the Axiom of Choice).
The correspondence between a change action and its reachability preorder gives rise to a (full and faithful) functor Reach : CAct → PreOrd that acts as the identity on morphisms.
Conversely, any preorder ≤ on some set |A| induces a change action where |A| ⊥ is the set |A| extended with a bottom element ⊥, and ⊔ denotes the least upper bound according to the preorder ≤. Note that the reachability preorder of the change action A ≤ is precisely ≤. This defines another full and faithful functor Act : PreOrd → CAct that is the identity on morphisms.
It remains to check that there are natural isomorphisms U : Act • Reach → Id CAct and V : Reach • Act → Id PreOrd . But these are trivial: it suffices to set U A = Id A and V (|A|,≤) = Id (|A|,≤) . Hence Act, Reach establish an equivalence of categories between PreOrd and CAct.
Adjunctions with Set.
Lemma A.7. The forgetful functor F is right-adjoint to the functor D, with the unit and counit given by: Supplementary materials for Section 3 The category CAct(C).
Theorem B.1. The functor CAct preserves all products.
Proof. Consider an I-indexed product of categories i∈I C i . An object A of CAct( i∈I C i ) is a change action (|A|, ∆A, ⊕ A , + A , 0 A ) where: satisfying the relevant conditions ((∆A, + A , 0 A ) is a monoid, ⊕ A is an action). But this entails that, for every i, the triple (∆A i , + i , 0 i ) defines a monoid in C i , and ⊕ i is an action of this monid on A i . Hence we obtain an I-indexed family A i of change actions in CAct(C i ) respectively. Conversely, given any such family, we can always construct the corresponding change action in CAct( i∈I C i ). A similar argument applies to differential maps: every differential map f : A → B in CAct( i∈I C i ) corresponds to a family of differential maps f i : A i → B i in CAct(C i ) and vice versa. Hence the functor CAct preserves all products.
Proof. Given any pair of differential maps f 1 : We check that, indeed, the relevant diagram commutes since: The universal property of the coproduct in C entails that if h = (|h|, ∂h) is such that the universal property of the coproduct also shows that necessarily ∂h = ∂f .
Change actions as Lawvere theories.
Lemma B.6. Consider the product-preserving functor T : T T → T ∆ defined by: Every ∆-algebra F corresponds then to a T-algebra F • T. Furthermore, given ∆-algebras F, G, there is a one-to-one correspondence between T-algebra homomorphisms φ : F • T → G • T and pairs (f, f ′ ) of a differentiable function f and its derivative f ′ between the underlying change actions F, G.
Proof. Consider a natural transformation φ : F • T → G • T, and define Then, by naturality of φ, it follows that: Hence φ TX = f • π 1 , f ′ . Additionally, we also have: which states precisely that f ′ is a derivative for f .

Stable derivatives and linearity.
Lemma B.7. Let f = (|f |, ∂f ) be a differential map in CAct(C). If ∂f is stable, then it is additive in its second argument 10 , i.e. the following diagram commutes: Proof. Since ∂f is regular, the following diagram commutes: But since ∂f is stable, we have ∂f • (⊕ × Id) = ∂f • (π 1 × Id), and substituting in the previous diagram gives the desired result.

Appendix C. Supplementary materials for Section 4
Tangent bundles in change action models.
Proof. First, we verify that ⊕ • Tz = ⊕ • z. This is easy to do since (omitting some obvious isomorphisms): The equation ⊕ • T⊕ = ⊕ • ⊕ is merely an instance of the naturality of ⊕ and thus it is satisfied trivially.
Commutativity of the above diagram then can be shown by equational reasoning in the internal logic of the CCC C: Supplementary materials for Section 5 Generalised cartesian differential categories.
Theorem 5.1. The functor α is a change action model.
Proof. We need to check that α is well-defined and a right-inverse to the forgetful functor.
First, note that α(f ) trivially satisfies the derivative property: Furthermore, by the axiom [CD.2] of generalised cartesian differential categories, we have: Proof. First, since T preserves products (up to isomorphism), it follows that C T is cartesian, with the product of objects A, B in C T being precisely the product A × B in C. For brevity, we write π i • π j as π ij .
It is immediate that α T is functorial and preserves products, and it is trivially a section of the forgetful functor.
We need to prove that α T (A) is a change action internal to the category C T . First note that since (L 0 (A), We need to check that Id A×L 0 (A) is a monoid action. First, note that (η • g) ⋆ f = Tg • f . Then: That Id A×L 0 (A) respects the associativity of η • + A follows by a similar argument.
We write in detail the proof that the derivative condition holds. In particular, what we seek to prove is . Then, given that ⊕ = Id, and noting that µ • Tf • η = f , we obtain: Conversely: Since + is commutative (by the definition of a generalised cartesian differential category), both expresions are equal and so the derivative condition holds.
Regularity is a straightforward consequence of the additivity of derivatives in generalised cartesian differential categories. D.0.1. The Eilenberg-Moore model. Definition D.3. Given a category C and a monad (T, η, µ), a T-algebra is a pair (A, ν) where A is an object in C and ν : TA → A is a C-morphism such that: Both of the previous change action models are in fact categories of algebras for the tangent bundle monad T on a generalised cartesian differential category C (the flat model considers algebras of the form (A, π 1 ), whereas the Kleisli category for T can be understood as the category of freely generated T-algebras). This is a consequence of the following result: it is a T-algebra morphism between (A, ν A ) and (B, ν B ) if and only if Tf is a differential morphism between the corresponding change actions.
Proof. For the first part, it suffices to check that ν A is a monoid action.
First, note that the monad unit ε A is precisely the map Id For the second part, note that the monoid addition can be written in terms of the monad multiplication as follows: µ • π 1 , π 12 , π 22 , 0 A = (Id × + A ) • π 11 , π 21 , π 12 • π 1 , π 12 , π 22 , 0 A = (Id × + A ) • π 1 , π 12 , π 22 Then because ν A is a T-algebra homomorphism, we have: Now consider a C-morphism f : A → B. Its derivative D [f ] satisfies regularity trivially, since in every generalised cartesian differential category derivatives are additive in their second argument. Then the property that f is a T-algebra morphism between (A, ν A ) and (B, ν B ) states that ν B • Tf = f • ν A , which is equivalent to stating that (f, D [f ]) is a differential morphism between the corresponding change actions.
One might be tempted to generalise this result in the "obvious" direction and try to construct a change action model directly on the Eilenberg-Moore category C T . This is, however, not possible: while an algebra on some object A does define a change action, it does not give any information on what should be the change action structure on ∆A.
Instead, consider the obvious projection functor π : C T → C. Now let σ : C → C T be a section of π, i.e. π • σ = Id. For every object A of C, the section σ picks a particular T-algebra σ(A) = (A, ν A ). Similarly, σ maps every morphism f : A → B in C onto a T-algebra homomorphism.
An immediate corollary of Theorem D.4 is that any section of π that maps objects of C to "well-behaved" T-algebras defines a model structure on C.
Lemma D.5. Let σ : C → C T be a section of π : C T → C such that for every object A of C, the corresponding algebra (A, ν A ) satisfies D [ν A ] • f, g, 0 A = g. Then there is a change action model α : C → CAct(C) defined by: The flat model described in Section 5.1 is an immediate corollary of this, as it is the change action model obtained from picking the section that maps every object A to the T-algebra π 2 : A × L 0 (A) → A.
Groups, calculus of differences, and Boolean differential calculus.
(2) Pilling's Normal Form Theorem [Pilling, 1973;Hopkins and Kozen, 1999]: every (regular) expression is equivalent to a sum y 1 + · · · + y n where each y i is a product of atomic symbols and expressions of the form (a 1 · · · a k ) ⋆ , where the a i are atomic symbols. For , viewed as a function from change action (K, K, +, +, 0) to itself. For a, b ∈ K, we have That this defines a derivative of p(x) is an immediate consequence of Theorem 5.7. We need to prove that the derivative is regular. Trivially ∂p(a, 0) = 0. It remains to prove: for u, a, b ∈ K ∂ p ∂x which we argue by structural induction, presenting the cases of p = q ⋆ and p = q r explicitly. Let p = q ⋆ . Thanks to Pilling's Normal Form Theorem, WLOG we assume q = 2) using the shorthand θ = u + a + b.
A typical element that matches LHS(D.2) has shape satisfying l ≥ 0, i ′ + j ′ + k ′ = n + 1, i + j + k = n. It suffices to consider two cases: l = 0 and l = 1, for if l > 1 and (u i ′ a j ′ b k ′ c) (u i a j b k c) a matches RHS(D.2) then so does (u i ′ a j ′ b k ′ c) l (u i a j b k c) a.
• Now suppose l = 0. If k = 0 then Ξ matches the first summand of RHS(D.2); otherwise note that Ξ = (u i a j+1 b k−1 c) b matches the second summand of RHS(D.2). • Next suppose l = 1. If k = k ′ = 0 then Ξ matches the first summand of RHS(D.2); Applying the product rule of partial derivatives, equation (D.1) is equivalent to L = R where using the shorthand θ = u + a + b as before. Similar to the preceding case, clearly R ≤ L.
To show L ≤ R, it suffices to show: We consider the first; the same reasoning applies to the second. As before, thanks to Pilling's Normal Form Theorem, we may assume that r(x) = (x m+1 c) ⋆ and q(x) = (x n+1 d) ⋆ . Then By considering a typical element Ξ that matches the preceding expression, and using the same reasoning as the preceding case, we can then show that Ξ matches R, as desired.
Proof. We use lexicographical induction on (n, j). The base case is straightforward. Our induction hypothesis is as desired. The third equality uses the fact: for j ≥ 0, π 2 , which is proved by a straightforward induction on j. The base case is trivial. For the inductive case: Proposition E.3. Composition of pre-ω-differential maps is associative: given pre-ω-differential Proof. For convenience and to save space, we write p n [f i ] as f n . Next we first prove a couple of useful technical lemmas.
First observe that for each n ≥ 0, and for each 0 ≤ j ≤ n, there exists a morphism: ] This leads to the following.
Lemma E.4. For all n ≥ 0 and 1 ≤ j ≤ n, Proof. A stronger induction principle is needed. We claim: for all n, i ≥ 0 and j ≤ n We prove by lexicographical induction on (n, j, i). The base case, which is ∀i ≥ 0 . f i • π i 1 = π 1 • f (1,i) , holds trivially. For the inductive case: The second equality appeals to the fact: for i, j ≥ 0, n > i + j + 1 which is easily proved by induction.
Lemma E.5. For all n ≥ 0 and 0 ≤ j ≤ n, Proof. We prove by lexicographical induction on (n, j). The base case is straightforward. For the inductive case: The second equality appeals to the induction hypothesis. The third equality uses Lemma E.4 for the first component, and the induction hypothesis for the second.
We are now ready to prove the associativity of composition, which boils down to: for all n ≥ 0, which is a special case of Lemma E.5.
Lemma E.6. Whenever f : A → B is an ω-differential map, then so is D n [f i ] for all n ≥ 0.
Proof. Since f i+1 is always a regular derivative for f i , it suffices to show that f i+1 • π i+1 1 is a regular derivative for f i • π i 1 . We abuse the notation and write ∂f to denote some arbitrary derivative of f . Then we show by induction on i that π i 1 • π 2 is a regular derivative of π i 1 . The base case is trivial. Then, by applying properties of the product of change actions (e.g. that the derivative of π i is π i • π 2 ), we obtain: • π 2 is a derivative of π i+1 1 . By the induction hypothesis, π i 1 • π 2 is a regular derivative for π i 1 , and since we have obtained a derivative for π i+1 1 by applying the chain rule to a composition of functions with regular derivatives, the resulting derivative is also regular.
The desired result then follows from applying the chain rule again: is a derivative for f i • π i 1 , and since regularity is preserved under applications of the chain rule, it is also a regular derivative.
Lemma E.7. Let f : A → B and g : B → C be ω-differential maps. Qua pre-ω-differential maps, their composite [ it follows that composition of ω-differential maps is associative.
Proof. As in the previous proof, we write ∂f for an arbitrary derivative of f . By the previous lemma, the map D j [f i ] is ω-differential and, in particular, Then, by applying the chain rule in the definition of composition, we obtain: Lemma E.8. For any ω-change action A, the pre-ω-differential map Id : [A i ] → [A i ] is ω-differential. Hence Id := Id : A → A satisfies the identity laws.
Proof. We show: for any ω-differential maps f : A → B and g : B → A, f • Id = f and Id • g = g.
p 1 Id is trivially a derivative for p 0 Id. Furthermore, since π 2 is an ω-differential map, we have p i+2 Id is a derivative for p i+1 Id, therefore Id is ω-differential.
Proof. First we prove that the map π 1 : A × B → A is ω-differential. For this we need to check that p i+1 π 1 is a regular derivative for p i π 1 as a map from the change action D( A× B, i) to the change action ∆( A, i).
The key insight is that Verifying the derivative property then boils down to applying the structure of products of change actions.
Consider the map π 1 • π (i) 2 from the carrier |D( A, i) × D( B, i)| into |∆( A, i)|. This is in fact the composition of i + 1 differentiable maps, and hence we can apply the chain rule to compute a regular derivative for it in terms of the (regular) derivatives for π 1 , π 2 , which we know are π 21 , π 22 respectively. We abuse the notation and write ∂f to denote some arbitrary derivative of f . Then we show by induction on i that π 1 • π (i+1) 2 is a derivative for π 1 • π (i) 2 . The base case is trivial. For the inductive case: Hence π 1 is an ω-differential map; similarly for π 2 . A similar argument also shows that f , g is ω-differential whenever f and g are.
We then check that π 1 • f , g = f . For this, the following auxiliary lemma will be of use: Lemma E.10. For any pre-ω-differential map [f i ], for all j, k ≥ 0, Proof. We proceed by induction on j. For the case j = 0 we have π For the inductive case: The desired equation follows as a trivial corollary. Indeed, for any i Theorem 6.16. The category CAct ω (C) is cartesian, with product given in Def. 6.13. Moreover if C is closed and has countable limits, CAct ω (C) is cartesian closed.
Proof. Consider ω-change actions A, B, C and let f : A → B, g : A → C be ω-differential maps. Lemma 6.14 already shows that π 1 • f , g = f , and similarly for π 2 . It remains to establish uniqueness.
Suppose there is an ω-differential map h : A → B × C satisfying Then, for every i, applying Lemma E.10 we obtain Applying a similar reasoning to g i , and by the universal property of f i , g i in C, we obtain that h i = f i , g i = p i f , g and hence h = f , g . Therefore, A × B is the categorical product in CAct ω (C).
We can construct a terminal ω-change action ⊤ by picking the terminal object of C at every level. This uniquely determines the entire structure of ⊤, since the only possible choice for every morphism is the universal morphism ! in C.
We now sketch a proof that CAct ω (C) has exponentials, provided that C is cartesian closed and has all countable limits. First, consider ω-sequences of C-objects [A i ] and [B i ]. Since C has all countable products, one can construct the infinite product Intuitively, this object of C represents the pre-ω-differential maps between [A i ] and [B i ].
If A, B are ω-change actions on the ω-sequences where the second element is the derivative of the first (i.e. of differential maps) by taking the limit of the following diagram: We can further restrict the space to only regular derivatives by taking the limit of a similar diagram, requiring that ∂f (a, 0) = 0 ∂f (a, δa + δb) = ∂f (a, δa) + ∂f (a + δa, δb).
Pasting all these diagrams together, we can define the space of ω-differential maps between A and B as a limit object | A ⇒ B| internal to C.
The ω-sequence [| A ⇒ Π i B|] is then a pre-ω-change action that forms the basis for the exponential A ⇒ B in CAct ω (C). The structure morphisms, ⊕, + and 0, are obtaining by lifting the structure morphisms in Π i B pointwise.

Proof. Given an object
CAct ω (C), the canonical coalgebra γ : CAct ω (C) → CAct(CAct ω (C)) maps the ω-change action to itself. That A is a internal change action of CAct ω (C) follows at once from the definition of ω-change action: ∆ A = Π A and p n (D( A × Π A)) = p n+1 (D A); and ⊕ 0 : A × ∆ A → A and + 0 : ∆ A × ∆ A → ∆ A are ω-differential. The functor γ maps an ω-differential map f : A → B to the differential map γ( f ) := ( f , ∂ f ) where ∂ f : A × ∆ A → ∆ B is just the ω-differential map Π f .
To prove the universal property, consider a category D and functors ε ′ i : D → CAct i (C) making the diagram commute. Then there is a unique functor [ε ′ i ] : D → CAct ω (C) satisfying ε ′ i = ε i • [ε ′ i ]. To construct it, first consider an object U of D. We define the ω-sequence [U i ] by: U 0 := |ε ′ 1 (U )| U j+1 := ∆ j+1 ε ′ j+1 (U ) Note that, for every j, ε ′ j+1 (U ) is a change action on CAct j+1 (C) and, therefore, ∆ j ε ′ j+1 (U ) is a change action in CAct(C). In particular, ⊕ ∆ j ε ′ j+1 is an action of U j+1 on U j . Hence we define the pre-ω-differential map ⊕ U j as follows: and similarly for + U j , 0 U j . Then the action of [ε ′ i ] on an object U of D can be defined as: Note that this is indeed an ω-change action, since the maps ⊕ U j , + U j are ω-differential and satisfy the required equations by construction.
Regularity follows from functoriality of F, and the derivative property is a direct consequence of the fact that F is well-typed.
Lemma F.1. The category CAct embeds fully and faithfully into the 2-category Cat of (small) categories and functors.
Given differential maps f, g : A → B, a natural transformation U : f · − → g maps every object a : |A| to a change U (a) : ∆B such that the following diagram commutes: In particular, this means natural transformations are a subset of the set |A| → ∆B, which can be read as generalized vector fields (mapping the space A to ∆B rather than ∆A).
Remark F.2. Consider a natural transformation from functor Cat(f ) into Cat(g). This is, first and foremost, a map that assigns to every element a ∈ |A| a change δa ∈ ∆A. This is precisely the space of functional changes ∆(A ⇒ B) in CAct ω (see Sec. 6) and, in general, in any change action model (see Sec. 4) equipped with an infinitesimal object.
More generally, the category CAct(C) of change actions on an arbitrary base cartesian category C can be regarded as a 2-category. Indeed, given change actions A, B we define the category of differential maps Diff (A, B) as follows: • The objects of Diff (A, B) are differential maps f : A → B.
• The morphisms between f, g are C-morphisms U : |A| → ∆B such that the following diagrams (in C) commute: Furthermore, composition of differential maps can be lifted to a functor on the corresponding categories. More precisely, let A, B, C be change actions. Define the functor Comp : Diff (A, B) × Diff (B, C) → Diff (A, C) as follows: • If (f, g) is an object in Diff (A, B) × Diff (B, C), then Comp(f, g) is just the composition of differential maps, i.e.