A diagrammatic view of differential equations in physics

Presenting systems of differential equations in the form of diagrams has become common in certain parts of physics, especially electromagnetism and computational physics. In this work, we aim to put such use of diagrams on a firm mathematical footing, while also systematizing a broadly applicable framework to reason formally about systems of equations and their solutions. Our main mathematical tools are category-theoretic diagrams, which are well known, and morphisms between diagrams, which have been less appreciated. As an application of the diagrammatic framework, we show how complex, multiphysical systems can be modularly constructed from basic physical principles. A wealth of examples, drawn from electromagnetism, transport phenomena, fluid mechanics, and other fields, is included.


Introduction
Presenting physical quantities and equations between them in the form of diagrams has a long tradition in physics and engineering, especially in those parts, such as electromagnetism, where the exterior calculus is commonly used. To a first approximation, these diagrams are directed graphs where the nodes represent physical quantities, such as fields or densities, and the arrows represent the action of operators on the quantities. The operators are usually differential operators such as the exterior derivative.
The most famous example, evocatively called "Maxwell's house" by Bossavit [11], depicts Maxwell's equations for electric and magnetic fields as a three-dimensional diagram. Two variants of Maxwell's house are reproduced from the literature in Figure 1. In the exterior calculus formulation (Figure 1a), the layout of the diagram is meaningful: (untwisted) time-dependent differential forms, such the electric field 1-form E and magnetic field 2-form B, are placed on the left side, whereas twisted differential forms, such as the charge density 0-form ρ and current density 1-form J, are placed on the right side. Spatial (exterior) derivatives go up or down the page, time derivatives go into or out of the page, and the Hodge star operators transforming between k-forms and twisted (3 − k)-forms go left or right. For comparison, the classical formulation of Maxwell's equations using vector caclulus is shown in Figure 1b, where the spatial layout of the diagram is less meaningful.  Table III], and [46, Figure 8].
Similar diagrams presenting systems of equations in electromagnetics and other branches of physics have been proposed by many authors, including Tonti, Deschamps, and Bossavit [10,11,21,79,80]. Enzo Tonti, in particular, has been an early and consistent advocate for diagrams as a systematic method to describe and classify physical theories. Such diagrams are therefore sometimes called "Tonti diagrams" [10], [30, §7E].
Although it was observed early on that Tonti's diagrams resemble commutative diagrams in algebra [46], this analogy has never been made precise, and indeed the diagrams, as used in practice, seem to involve a certain degree of imprecision. Let us consider in more detail how in the category Vect R of real vector spaces and linear maps. This is a free diagram D : J → Vect R whose shape J := {• ⇒ •} is the free category with two parallel arrows. The diagram does not commute, as the equation is not a tautology.
In the category of sets and functions, a solution to a system of equations presented by a diagram D : J → Set is a choice of elements (x j ∈ D j) j∈J that is compatible with all morphisms in the diagram: In general, the objects of a category do not have elements, so we speak instead of generalized elements when considering solutions for a diagram in an arbitrary category. Recall that, for a category C and an object S ∈ C, a generalized element of shape S in C is simply a morphism x : S → X in C. When C is a concrete category, it is usually possible to choose S so that generalized elements of shape S correspond to elements of the underlying sets. Alternatively, when C is a closed category, it is natural to take S as the unit object of the closed structure. Exemplifying both situations, generalized elements x : 1 → X in Set correspond to elements x ∈ X, and generalized elements v : R → V in Vect R correspond to vectors v ∈ V.
For any fixed category C and object S ∈ C, generalized elements of shape S are objects of the coslice category S /C. The morphisms from x : S → X to y : S → Y in this category are morphisms f : X → Y in C forming a commutative triangle S X Y x y f .
The coslice category S /C will be suggestively denoted El S (C) or, when the dependence on S is clear from context, simply El(C).
Generalizing from diagrams in Set, a solution (or family of solutions) to a system of equations presented by a diagram D in C is a lift of the diagram D to a diagram in El(C). The following definition makes this idea precise. Definition 2.3 (Lifting problem). A lift of a diagram D : J → C through a functor π : E → C is a diagram D : J → E such that π • D = D. Given a diagram D in C and a functor π : E → C, the lifting problem is to find a lift of D through π.
In the present situation, E := El S (C) is a category of generalized elements of C and π := cod : El S (C) → C is the forgetful functor sending a generalized element x : S → X to its codomain X.
To summarize, a diagram in C defines a system of equations involving the objects ("spaces") and morphisms ("operators") of C. Solving the equations is the same as solving the lifting problem with respect to the functor π = cod : El(C) → C.

Example 2.4 (Solving the discrete heat equation). A lift of the diagram (2.2)
in Vect R specifying the discrete heat equation to a diagram in El R (Vect R ) consists of two vectors u, .
u ∈ R N×V such that ∂ n u = .
Thus, we see that lifts of the diagram correspond to single vectors u ∈ R N×V satisfying the discrete heat equation (2.1). In this case, the solutions are easily characterized: once the initial data u(0, −) ∈ R V is given, the solution is determined recursively by u(n + 1, x) = u(n, x) + ∆u(n, x) = 1 µ(x) e∈s −1 (x) u(n, t(e)) µ(e).
Initial value problems are treated formally in Section 4.
We introduce a convention for drawing diagrams that makes the equations presented more transparent and more closely resemble the diagrams in the physics literature. Namely, nodes in the diagrams will be annotated with variables as well as the spaces they inhabit. For example, the discrete heat equation (2.2) is redrawn as (2.4) When presenting a physical theory diagrammatically, we will be deliberately ambiguous about whether the diagram is in C or El(C), just as a classical equation like " f (x) = y" is, without further context, ambiguous about whether x and y are indeterminates waiting to be filled or are specific values satisfying the equation. In the latter kind of diagram, the type-theoretic expression x : X is interpreted as a generalized element x : U → X and an arrow (x : X) f − → (y : Y) as a morphism X f − → Y in C such that x · f = y. For example, we can think of the drawing (2.4) as defining a diagram D : J → Vect R with indexing category J = {u ⇒ . u}, having two objects named "u" and " .
u," and with assignments D(u) = D( . u) = R N×V ; alternatively, the drawing (2.4) can be seen as a diagram in El(Vect R ), involving two specific vectors u and .
u. We emphasize that this visual pun will not create in any ambiguity in the theoretical results, where it will always be clear to which categories the diagrams belong.
Connection with limits. The limit of a diagram D : J → C, when it exists, is a "universal solution" to the given equations. For many choices of category C, including Set and Vect R , the limit comprises all solutions to the equations. One might expect that lifts and limits are related, and that is indeed the case, as we now explain.
Recall that a cone over the diagram D with apex S ∈ C is a natural transformation λ : ∆ S ⇒ D, where ∆ S : J → C is the constant diagram at S . Equivalently, a cone over D is a natural transformation into D whose domain diagram factors through the terminal category 1.
A limit of the diagram D is a cone over D with the universal property of being terminal in the category of cones over D.
The following is immediate from the definitions.
with corners M embeds as a submanifold of an open manifold M of the same dimension, and any smooth function on M extends to a smooth function on an open neighborhood of M in M [58]. More generally, any differential form on M extends to a differential form on an open neighborhood [34]. Physical quantities are taken to be sections of sheaves on the spatial domain M or the space-time domain M × [0, ∞). Loosely speaking, a sheaf on a topological space is a coherent family of quantities defined on open subsets that can be glued together from smaller subsets whenever they agree on the overlaps. In this paper, sheaves will be used more as a convenient language than as a technical tool, and it will suffice to recall the following terminology [82].
Let X be a topological space and let O(X) be the poset of open subsets of X, ordered by inclusion. A presheaf on X is a functor F : O(X) op → Set. Explicitly, a presheaf on X consists of, for each open subset U ⊆ X, a set F (U), whose elements s ∈ F (U) are called sections over U, and a functorial assignment of, for each inclusion V ⊆ U, a function F (U) → F (V), called the restriction map and denoted res U V . The action of the restriction map on a section s ∈ F (U) is abbreviated as s| V := res U V (s). A global section is a section over the open subset X itself. Finally, a sheaf on X is a presheaf F on X satisfying the sheaf condition: if (s i ∈ F (U i )) i∈I , is a family of sections that agree on all pairwise intersections, i.e., such that then there exists a unique section s ∈ F (U) over the union U := i∈I U i such that s| U i = s i for all i ∈ I. The inclusion functor Sh(X) → PSh(X) has a left adjoint (−) : PSh(X) → Sh(X), called sheafification, that freely associates a sheaf to any presheaf. Sheaves can also be defined in categories besides Set. For any category S, an S-valued presheaf on a topological space X is a functor F : O(X) op → S. An S-valued sheaf is such a presheaf that additionally satisfies a sheaf condition abstracting the one above: for any sub-poset P of O(X) that is closed under intersections, the diagram F | P : P op → S has as limit the cone with apex F (U) and legs res U V , V ∈ P, where U := V∈P V. The S-valued presheaves and sheaves on X each form categories, denoted PSh(X, S) and Sh(X, S), respectively. The morphisms in both categories are natural transformations. The most important case for us is that of Vect R -valued sheaves, or sheaves of real vector spaces. The categories of Vect R -valued presheaves and sheaves on a space X are abbreviated as PSh R (X) and Sh R (X). Note that, for an arbitrary category S, the sheafification functor (−) : PSh(X, S) → Sh(X, S) might not exist, but it does for the category S = Vect R . The technical condition that ensures this is the IPC property [40, Definition 3.1.10].
As the term "section" suggests, a principal source of sheaves of vector spaces in differential geometry is sheaves of sections of smooth vector bundles, such as the tangent or cotangent bundles. For the precise relation between sheaves and vector bundles, see [82,Proposition 8.45]. The following sheaves of vector spaces, in which M is a smooth manifold of dimension m, are essential for our purposes: , for 0 ≤ k ≤ m: time-dependent differential k-forms on M (i.e., the k-forms on M × [0, ∞) not involving the 1-form dt) • Ω k M ∈ Sh R (M) and Ω k t,M ∈ Sh R (M × [0, ∞)), for 0 ≤ k ≤ m: twisted (time-independent and time-dependent) differential k-forms on M.
Note that Ω 0 M = C ∞ M , the sheaf of smooth functions on M. When the manifold M is clear from context, we will drop the subscript in the notation.
All of these objects are standard in differential geometry, except perhaps the twisted differential forms, which are better known in physics [11,15]. Unlike an ordinary form, a twisted form changes sign under an orientation-reversing change of coordinates; formally, an (untwisted) k-form is a section of the kth-order exterior bundle Λ k T * M, whereas a twisted k-form [12, §I.7] is a section of the tensor product bundle Here Or(M) is the orientation bundle of M, the real line bundle whose transition functions are given by the sign of the Jacobian determinant of the coordinate transition functions [12,57]. Particularly important are the top-dimensional twisted forms, called densities, which can be integrated over an arbitrary manifold, oriented or not. Physical quantities such as a mass density or charge density are indeed modeled by densities (cf. Figure 1a). Another class of sheaves, the constant sheaves, are useful in working with generalized elements of sheaves. For any object S ∈ S, the constant presheaf on X is the presheaf S X : O(X) op → S with S X (U) := S for all open sets U ⊆ X and all restriction maps equal to the identity on S . In general, the constant presheaf is not a sheaf; the constant sheaf on X is the sheafification S X , which exists in particular when S = Vect R . Proposition 3.1 (Constant sheaves and generalized elements). Let S be a category for which the sheafification functor (−) : PSh(X, S) → Sh(X, S) exists. For any object S ∈ S and any S-valued sheaf F on a space X, the sheaf morphisms S X → F are in natural bijection with generalized elements of F (X) of shape S .
In particular, when F is a sheaf of real vector spaces, the sheaf morphisms R X → F are in natural bijection with global sections of F .
Proof. The sheafification functor is defined to be left adjoint to the inclusion functor Sh(X, S) → PSh(X, S). Thus, sheaf morphisms S X → F are in natural bijection with presheaf morphisms S X → F . The latter are natural transformations α : S X ⇒ F , where naturality implies that, for every open set U ⊆ X, the diagram S commutes. It follows that the natural transformation α is completely determined by its component α X , which is a generalized element of F (X) of shape S .
We use this observation to formulate partial differential equations as lifting problems of diagrams.
where E ∈ Ω 1 t (M) is the electric field as a time-dependent 1-form and B ∈ Ω 2 t (M) is the magnetic field as a time-dependent 2-form. This system of partial differential equations is encoded by the diagram In drawing the diagram, we follow the conventions described in Section 2 and we also abbreviate the sheaf as Ω k t . The object labeled 0 is the zero sheaf on M × [0, ∞), which is the zero object in the category of sheaves of vector spaces.
By Proposition 3.1, a lift of the diagram to a diagram of generalized elements of shape R M×[0,∞) is a solution to the Maxwell-Faraday equations on M for all time t ≥ 0.
The Maxwell-Faraday equations comprise the non-metric half of Maxwell's equations, which make sense on any smooth manifold and are preserved by diffeomorphisms [4]. Most equations of mathematical physics, including the full Maxwell equations, require a metric and so must be defined on a Riemannian or semi-Riemannian manifold. The categorical constructions above carry over directly when the category of smooth manifolds is replaced by the category of Riemannian manifolds (with corners) and isometries, and in the following examples it should be clear from context whether we are working with smooth manifolds or Riemannian manifolds.
In the metric setting, we use the Hodge star operator in a form that is more common certain parts of physics than in mathematics [9,11,15]. Let M be a Riemmanian manifold of dimension m. For each 0 ≤ k ≤ m, the Hodge star is an isomorphism of vector bundles Λ k T * M ∼ − → Λ m−k T * M [65, Definition 7.13]. Thus, the Hodge star induces an isomorphism of sheaves of sections that sends k-forms to twisted (m − k)-forms. There are several reasons to prefer this version of the Hodge star. Unlike the usual Hodge star that sends k-forms to (untwisted) (m − k)-forms, this one does not require the manifold to be oriented and so avoids invoking superfluous structure. More importantly, the distinction between straight and twisted forms is physically meaningful, which becomes especially apparent in computational physics. The Hodge star involving twisted forms permits a direct translation to the discrete exterior calculus [20,36], where straight and twisted forms manifest as "primal" and "dual" forms on a discretized manifold.
Using the metric structure, we now present two of the most famous equations of mathematical physics-the diffusion and wave equations-as diagrams.
Example 3.3 (Diffusion). Consider a substance diffusing on a three-dimensional Riemannian manifold M. Important physical quantities in this system are the concentration of the substance, C ∈ Ω 0 t (M), and the negative of the diffusion flux, φ ∈ Ω 2 t (M). According to Fick's first law [19, §1.2], the negative diffusion flux is proportional to the derivative of the concentration: where the proportionality constant k ∈ C ∞ (M), called the diffusivity, is a property of the material. Applying a conservation of mass principle [19, §1.3], one obtains the diffusion equation which can be neatly expressed by the diagram When the diffusivity k is constant throughout M, the diffusion equation reduces to where δ := −1 • d • is the codifferential and ∆ := δ • d is the Laplace-Beltrami operator. In this special case, the diffusion equation is also called the heat equation (cf. Example 2.2). It can be expressed as a simpler diagram: (3. 2) The notion of a morphism of diagrams, introduced in the next section, will allow us to make precise the relationship between the two diagrams (3.1) and (3.2). They are not isomorphic but, provided that k is constant, they are equivalent in a weaker sense which we will make precise.
where u ∈ Ω 0 t (M) is the displacement, c 2 is a positive constant (the squared wave speed), and ∆ := δ • d is the Laplace-Beltrami operator [81]. Introducing another variable, the velocity v ∈ Ω 0 t (M), the wave equation reduces to a first-order system in time: Expanding the Laplacian into its constituent operators, we can present the wave equation by the diagram Initial and boundary value problems, formulated in the next section, involve not just quantities defined globally on a space-time manifold but also quantities restricted to the manifold's spatial or temporal boundary. In order to express such problems, the underlying geometric objects-smooth manifolds with corners-and the spaces of quantities on them-sheaves of vector spaces-must be assembled into a single category accommodating both kinds of entities. For this, indexed categories and the Grothendieck construction are useful devices.
Given a category J, a J-indexed category is a (pseudo)functor X : J op → Cat, thought of as a family of categories X( j) contravariantly indexed by j ∈ J. The Grothendieck construction assembles the categories X( j), j ∈ J, into a single category X with objects Ob( X) := j∈J Ob X( j). The morphisms in this category can be defined covariantly or contravariantly, depending on the form of the construction [64, §10.5], [76]. We take the covariant Grothendieck construction of X, viewed as a covariant functor from J op to Cat. The resulting category X has, as objects, pairs of objects ( j, x), where j ∈ J and x ∈ X( j), and, as morphisms ( j, x) → (k, y), pairs of morphisms k f − → j in J and  A good setting in which to formulate boundary value problems is the Grothendieck construction of the indexed category Sh M,R := Sh M,Vect R . This category is described explicitly as follows. Two classes of morphisms in Sh M,R will be used routinely. First are the morphisms of form (id U , φ) : (U, F ) → (U, G), where the submanifold U ⊆ M is fixed and φ is a morphism of sheaves; these are abbreviated as φ : F → G. Very often the map φ is a linear differential operator, which are characterized within the class of the sheaf morphisms by the Peetre theorem [45,62]. Second, for any submanifolds V ⊆ U of M, pulling back differential k-forms along the inclusion defines a morphism in Sh M,R , which may be denoted res U V or res V . Time-dependent and twisted differential forms can be restricted similarly.
As before, generalized elements in the category Sh M,R correspond to sections of sheaves: Proof. Inverse images send constant sheaves to constant sheaves [82,Example 3.56]. In particular, the restriction to U of the constant sheaf R M is the constant sheaf R U . The statement now follows from Proposition 3.1.
Consequently, differential equations can be cast as lifting problems for diagrams in this category. Lifting a diagram D : J → Sh M,R to a diagram of generalized elements of shape (M, R M ) amounts to choosing, for each j ∈ J, a section This system of equations should be compared with the simpler one for set-theoretic diagrams in Equation (2.3).

Morphisms of diagrams and boundary value problems
Much of the value of formalizing diagrams in physics becomes apparent only after introducing a notion of morphism between diagrams. It has long been known (even if not widely appreciated) that diagrams in a given category themselves form a category. In fact, they form a category in two different ways, reflecting the duality between limits and colimits. Another category of diagrams, denoted Diag → (C), is defined similarly, except that the morphisms from D : J → C to D : J → C consist of a functor R : J → J in the forward direction together with a natural transformation ρ : There are forgetful functors Diag ← (C) → Cat op and Diag → (C) → Cat, namely the domain functors, that discard all but the indexing category of a diagram.
The two categories of diagrams are motivated by their fundamental connection with limits and colimits.
Proposition 4.2 (Functorality of limits). If C is a complete category, endowed with a choice of limit cone for every diagram, then the operation of taking limits extends to a functor Dually, if C is a cocomplete category, endowed with a choice of colimits, then the operation of taking colimits extends to a functor colim = lim This statement appears already in Eilenberg and Mac Lane's original document about category theory [23, §23], albeit restricted to "inverse limits" and "direct limits" since the terminology surrounding limits and colimits had not yet reached its modern form. We sketch the proof in the case of limits because it is useful in its own right.
Proof. A morphism (R, ρ) : (J, D) → (J , D ) in Diag ← (C) sends cones over D to cones over D , preserving the apex: if λ is a cone over D with apex S ∈ C, then a cone λ over D with apex S is defined by the pasting diagram: (4.1) In particular, the morphism (R, ρ) acts on the limit cone λ over D, having apex lim D, to give a cone λ over D with apex lim D. The universal property of the limit of D then yields a canonical morphism lim D → lim D in C. This construction defines a functor lim : Diag ← (C) → C, whose functorality follows from the universal property.
In view of the connection between lifts and cones (Proposition 2.5), the preceding Proposition 4.2 shows that, of the two categories of diagrams, the category Diag ← (C) should be preferred when interpreting diagrams as systems of equations. Specifically, given an object S ∈ C, Equation (4.1) in the proof shows that a morphism D → D in Diag ← (C) pushes forward any lift of D through π : El S (C) → C to a lift of D through π. In other words, morphisms in Diag ← (C) carry solutions of one system of equations to solutions of another. Morphisms in Diag → (C) generally do not have this property. Thus, when we speak of the "category of diagrams" or a "morphism of diagrams" without qualification, we refer to the category Diag ← (C).
Certain classes of diagram morphisms are worth singling out. A morphism (R, ρ) in Diag → (C) or Diag ← (C) is called strong if the natural transformation ρ is a natural isomorphism and strict if it is an identity. Thus, the strict morphisms in Diag → (C) comprise the slice category Cat/C and the strict morphisms in Diag ← (C) comprise the opposite category (Cat/C) op .
The next several examples illustrate how morphisms of diagrams can be used to formalize relations between physical theories presented diagrammatically.
as a diagram in Sh R (M). The decoupling of the electric and magnetic fields in the static case is visually apparent in the two components of the diagram. Formally, the diagram is a product in the category of diagrams [64, §2.2]. (It is not a coproduct, as one might initially expect, simply because of the contravariance in the forgetful functor Diag ← (C) → Cat op .) If an electric potential φ and a magnetic potential A exist, then the static Maxwell-Faraday equations can be rewritten as the diagram in Sh R (M). The equations dE = 0 and dB = 0 need not be explicitly stated since they are implied by the property d 2 = 0 of the exterior derivative. A morphism from the diagram (4.3) including potentials to the diagram (4.2) excluding them is specified by the following picture.
In drawing the diagram morphism (R, ρ) : (J, D) → (J , D ), the components ρ j , for j ∈ J , of the natural transformation ρ : D • R → D are shown as dashed arrows, while the functor R : J → J between indexing categories is not explicitly shown. The object map of R is determined by the dashed arrows of the transformation components. When the indexing category J is thin, as in this example, the morphism map of R is determined by the object map. For example, the indexing morphism over 0 → Ω 2 maps to the composite morphism over Ω 0 −d − − → Ω 1 −d − − → Ω 2 and the indexing morphism over 0 → Ω 3 maps to the composite morphism over Crucially, the corresponding naturality squares commute due to the fact that d 2 = 0.
It is not a coincidence that the diagram morphism goes from the system with potentials to the system without them, rather than the other way around. The presence of electric and magnetic potentials ensure that dE = 0 and dB = 0, but those equations do not imply that potentials exist. In mathematical jargon, the diagram (4.2) presents a pair of closed forms and the diagram (4.3) presents a pair of exact forms. Exact forms are closed, but whether or not all closed forms are exact depends on the manifold M [4]. Loosely speaking, the diagram morphism goes in the direction of increasing generality.

Example 4.4 (Steady states in diffusion)
. Physical intuition suggests that a diffusing substance should approach a steady-state solution in the long-run limit. Steady states of the diffusion equation can be extracted by a morphism of diagrams. To express this rigorously, the mathematical setup in Example 3.3 must be altered to ensure that the needed limits exist and are well-behaved.
Let M be a three-dimensional Riemannian manifold and let Ω k ∞ = Ω k ∞,M be the sheaf of timedependent k-forms of M that have well-defined limits as t → ∞ and whose time derivatives are uniformly continuous in t. Note that Ω k ∞ is a sheaf on M, not on M × [0, ∞) as usual. Replacing each object Ω k t in diagram (3.1) with Ω k ∞ yields a diagram in Sh R (M) for diffusion under the assumption of steady long-run behavior.
On the other hand, the equation for an equilibrium concentration of the substance is given by the diagram in Sh R (M) and does not involve time at all. When the diffusivity k ∈ C ∞ (M) is constant throughout M, this equation is equivalent to Laplace's equation, ∆C = 0.
A morphism (R, ρ) from the first diagram to the second can be depicted as where, as before, the functor R between indexing categories is implicit. The components of the natural transformation ρ are the limit operators ρ k := lim t→∞ : Ω k ∞ → Ω k or, in one case, the zero map. The naturality squares corresponding to the spatial operators commute because limits in time commute with both derivatives and Hodge stars in space. More subtly, the naturality square corresponding to the time derivative commutes because if C ∈ Ω 0 ∞ , then lim t→∞ ∂ t C = 0, by the uniform continuity assumption and Barbȃlat's lemma [24]. in Cat. The naturality equations are already encoded by the commutative diagrams in K, for each morphism f : j → k in J . Next, recall that the natural transformation ρ : D • R → D is equivalent to a functor ρ : J × 2 → C such that ρ(−, 0) = D • R and ρ(−, 1) = D . This is the classic interpretation of natural transformations as "categorical homotopies." Thus, the collage diagram F : K → C can be defined by the universal property of the pushout: The next example is simpler than the preceding ones but brings out an important feature of diagram morphisms.
Example 4.6 (Variants of the heat equation). We saw in Example 3.3 that the heat equation, or the diffusion equation with constant diffusivity, can be presented by at least two different diagrams, namely (3.1) and (3.2). As expected, there is a strict morphism of diagrams in one direction whose backward map on indexing categories sends the morphism over k∆ to the composite morphism over Lifts of the first diagram can therefore be pushed forward to lifts of the second.
A puzzle now presents itself. The two presentations of the heat equation are evidently equivalent inasmuch as any solution of one gives a solution of the other. However, the diagram morphism above is not an isomorphism. Nor is it a 2-categorical equivalence when the category of diagrams assumes its proper status as a 2-category (see [63] and Remark 6.2). So how is this notion of equivalence accomodated by the diagrammatic formalism? The problem is resolved by recognizing that a special class of diagram morphisms, encompassing the one above, are "weak equivalences" in that they are not necessarily isomorphisms but still establish a one-to-one correspondence between lifts. Weak equivalences of diagrams are studied in Section 9.
Remark 4.7 (Notions of theoretical equivalence). The question of when two physical theories should be considered equivalent is a subtle one that has long been studied by philosophers of science, sometimes even using category-theoretic methods [35]. The discussion above takes for granted that two systems of equations should be considered equivalent when they have interchangeable solutions, but the stronger, more syntactical notion of equivalence supplied by the category of diagrams is also meaningful. As a physical theory, the diffusion equation is derived by combining a phenomenological principle (Fick's first law) with a conservation principle, as recalled in Example 3.3. Textbooks on diffusion, such as Crank's [19], regard Fick's first law as significant enough to be stated on its own, before introducing the diffusion equation. From this perspective, the diagram morphism in Example 4.6 discards information about the derivation of the heat equation and may rightfully be considered a nonequivalence.
Boundary value problems. Another use of diagram morphisms is in formulating boundary value problems. To solve a boundary value problem, one must solve a system of differential equations while simultaneously satisfying a set of side constraints, called the boundary conditions. For our purposes, boundary conditions encompass both the spatial and the temporal boundary of the spacetime domain, and so include initial conditions as a special case. We have seen that solving a system of equations amounts to finding a lift of the diagram presenting the equations (Definition 2.3). Meanwhile, satisfying the boundary conditions requires extending the boundary data to the whole domain. These two problems are combined in the notion of an extension-lifting problem of diagrams.
be a morphism of diagrams in a category C and let D 0 be a lift of the diagram D 0 through a functor π : E → C. The extension-lifting problem associated with this data is to find an extension (R, ρ) : (J, D) → (J 0 , D 0 ) of D 0 along R whose domain D is also a lift of D through π, such that the 2-cells are compatible: When presenting physical theories, the diagram D represents the whole system, the diagram D 0 represents the boundary of the system, and the morphism D → D 0 projects the system onto its boundary. If this seems backward, note that, geometrically, the boundary is included in the space-time domain, but for physical quantities defined on the domain, the inclusion of spaces induces a projection of quantities contravariantly. As before, the lifting is through the projection functor E := El(C) → C associated with a category of generalized elements. Finally, a lift D 0 of D 0 is a choice of boundary data. The extension-lifting problem can then be interpreted as a boundary value problem.
In algebraic topology, it is standard for extension and extension-lifting problems to be strict, meaning that all 2-cells involved must be identities [3,67]. On the other hand, in category theory, a right Kan extension is a "lax" extension, in the sense of Definition 4.8, that satisfies a universal property among all such extensions [68,Chapter 6]. As the examples below show, nontrivial 2-cells are essential for boundary value problems, so we allow extension-lifting problems to be non-strict. Example 4.9 (Discrete Dirichlet problem). Like the classical heat equation (Example 2.2), the classical Dirichlet problem has a discrete analogue on graphs. Let G = (V, E) be a locally finite symmetric weighted graph with no isolated vertices and let ∆ : R Ω → R Ω be the discrete Laplacian on G. For any subset of vertices Ω ⊆ V, define the one-step closure of Ω to be and define the vertex boundary of Ω to be ∂Ω := Ω \ Ω. Given boundary data g ∈ R ∂Ω , the discrete Dirichlet problem is to find u ∈ R Ω such that It can be shown that, if the graph G is connected and Ω is finite with non-empty complement Ω c , then a solution of the problem exists and is unique [29, Theorem 1.38].
As an extension-lifting problem, the discrete Dirichlet problem is defined by the morphism of diagrams in Vect R , whose domain is a cospan and whose codomain is a singleton diagram, together with the lift of the codomain diagram through El R (Vect R ) → Vect R that assigns the boundary data g ∈ R ∂Ω to u b . In the domain diagram, ∆| Ω denotes the restriction of the Laplacian to vertices in Ω, which due to boundary effects depends on vertices in Ω. In the diagram morphism, the sole component of the 2-cell is the restriction map res ∂Ω = res Ω ∂Ω . Solutions of the extension-lifting problem coincide with solutions of the discrete Dirichlet problem.
For smooth boundary value problems, we work in the category of sheaves on submanifolds of the spatial or space-time domain (Definition 3.5).
in the category Sh M×[0,∞),R , together with initial and boundary data corresponding to C 0 : Ω 0 (M) and C b : Ω 0 t (∂M), which would be written in classical notation as for all x ∈ ∂M and t ≥ 0.
We abuse notation slightly in abbreviating the objects (M, Ω k M ) and (M × [0, ∞), Ω k t,M ), for example, as Ω k (M) and Ω k t (M). The two components res t=0 and res ∂M are the restriction maps corresponding to the Subtleties lurk behind this seemingly innocent formulation. The boundary data C 0 and C b are not independent of one another since they both specify the concentration at the intersection of the spatial and temporal boundary. Thus, the extension-lifting has a solution only if the compatibility condition C 0 | ∂M = C b | t=0 is satisfied. This constraint is incorporated by the extension-lifting problem for the morphism of diagrams where a lift of the codomain diagram must satisfy the compatibility condition. The naturality conditions for the diagram morphism are satisfied because the inclusions induce a commuting diagram of restrictions: .
In fact, the condition above is not enough to ensure the existence of a smooth solution near the corner of the space-time domain. For further discussion, see [16] and references therein. We merely note that the diagrammatic formalism can be useful in making assumptions about the boundary data, whatever they may be, clear and explicit. Example 4.11 (Diffusion with Neumann condition). As a variation on the previous example, the diffusion equation with Neumann boundary conditions is the extension-lifting problem for the morphism of diagrams The negative diffusion flux φ is specified at the spatial boundary for all time. For example, this boundary condition describes a closed system with impermeable boundary when the flux through the boundary is fixed to be zero. Compatibility conditions between the initial data C 0 and the boundary data φ b can also be imposed.

Lifting morphisms of diagrams
In this section, we temporarily pause the application-driven development to study how morphisms of diagrams in a category C interact with lifts through a functor π : E → C. The right level of generality for this study takes the functor π to be a discrete opfibration, a concept we now review.
Definition 5.1 (Discrete opfibration). A functor π : E → C is a discrete opfibration if, for every morphism f : x → y in C and every object x ∈ E with π(x) = x, there exists a unique morphism x • x y f f π As the picture suggests, the codomain of the lift f is not given but is part of the existence and uniqueness statement.
Our motivating example of a discrete opfibration is the codomain projection El C → C associated with a category of generalized elements of C.
The relevance of discrete opfibrations to extension-lifting problems of diagrams is strongly suggested by the fact that the former definition can be stated in terms of extension-lifting problems. Conflating objects in a category with diagrams of shape {•} and morphisms with diagrams of shape {0 → 1}, a functor π : E → C is a discrete opfibration exactly when, for every object x ∈ E and every morphism f in C forming a commutative square there exists a unique morphism f in E (indicated by the dashed line) making both triangles commute. These are extension-lifing problems, a strict version of Definition 4.8, involving diagrams of shape Alternatively, discrete opfibrations over C can be seen as actions of the category C in the following way. An action of a category C, also called a C-set or more commonly a copresheaf on C, is a functor X : C → Set. Informally, a C-set X is a family of sets X(c), indexed by c ∈ C, on which the morphisms of C act functorially. Given a C-set X, a discrete opfibration is defined by the projection π X : El(X) → C, where El(X) is the category of elements of X, a special case of the Grothendieck construction (cf. Section 3). The objects of the category El(X) are pairs (c, x), where c ∈ C and x ∈ X(c), and morphisms (c, Conversely, given a discrete opfibration π : E → C, one can construct a C-set X defined on objects by X(c) := π −1 (c). Moreover, the two constructions extend to an equivalence of categories where DOpf(C) is the full subcategory of Cat/C spanned by discrete opfibrations and C-Set is the functor category Set C [75, Proposition 3.9]. Under this correspondence, the discrete opfibrations cod : El S (C) → C associated with generalized elements of some shape S ∈ C correspond to the representable C-sets, i.e., those of the form Hom C (S , −) : C → Set. More general C-sets can also be useful in defining lifting problems. For example, the recourse to sheafification and the constant sheaf in Proposition 3.1 can be avoided by simply taking, for a given manifold M, the Sh(M)-set that sends each sheaf on M to its set of global sections.
Lifting properties of diagrams can be stated more economically using the functorality of the diagram category construction. Namely, a functor Diag ← : Cat → Cat sends each category C to the diagram category Diag ← (C), as in Definition 4.1, and each functor F : C → D to the functor Diag ← (F) : and on diagram morphisms by post-whiskering, sending a morphism (R, ρ) to (R, F * ρ).
Cat → Cat is defined in the same way. In fact, these two endofunctors on Cat extend to strict 2-functors, and even to pseudomonads on Cat [31,43,63], although we will not use this fact here. With these definitions, the previous Definitions 2.3 and 4.8 can be rephrased as: • Given a diagram D in a category C and a functor π : E → C, the lifting problem is to find a diagram D in E such that Diag ← (π)(D) = D.
• Given a morphism of diagrams (R, ρ) : D → D 0 in C and a lift D 0 of D 0 through π, the extensionlifting problem is to find a morphism of diagrams (R, ρ) : We can also succinctly state a generalization of the result (4.1) that diagram morphisms carry lifts of their domain to lifts of their codomain.
Proof. We must show that for any morphism of diagrams (R, ρ) : (J, D) → (J , D ) and any lift D of D through π, there exists a unique morphism (R, ρ) : Since π : E → C is a discrete opfibration, for each j ∈ J , the object DR j ∈ E along with the morphism in C has a unique lift through π to a morphism DR j ρ j − → e j in E. Thus, we must define D : J → E on objects by D j := e j . Next, for every morphism j f − → k in J , the object D j ∈ E along with the morphism in C, which commutes by the naturality of ρ. From the uniqueness of lifts through π, it follows that the codomain of f is D k and also that the square in E commutes. In particular, we can and must define D on morphisms by D f := f . We have shown that the data of the diagram D : J → E and the transformation ρ : D • R → D exist and are unique. The argument already shows that ρ is natural, while the functorality of D follows from the uniqueness of lifts through π.
Given a C-set X, lifts of diagrams and diagram morphisms through the discrete opfibration π X : El(X) → C can also be expressed directly in terms of X. Let 1 = { * } be the terminal set and denote the functor J Moreover, the action on lifts by a diagram morphism (R, ρ) : (J, D) → (J , D ) in Theorem 5.2 takes the form: This equation should be compared with Equation (4.1).
In summary, we have seen, from the perspectives of both discrete opfibrations and category actions, how lifts of diagrams in a category C are pushed forward by morphisms in Diag ← (C). Importantly, morphisms in Diag → (C) generally do not have this property, which is why we regard the category Diag ← (C) as primary in this work. In Section 9, we explore special conditions under which morphisms in Diag → (C) push forward lifts of diagrams.

Diagrams involving cartesian products
The physical theories considered so far, such as the diffusion and wave equations, have been fairly simple. That is no accident. Although the basic vocabulary of category theory-categories, functors, and natural transformations-goes surprisingly far, more structure is needed to express richer physical theories. In this section and the next, we extend the diagrammatic formalism from bare categories to categories with extra structure, beginning with cartesian products, i.e., products in the categorical sense.
The objects of interest will now be cartesian diagrams in a cartesian category. For us, a cartesian category is a category with finite products. Be warned that some authors (notably Johnstone [39]) use "cartesian category" to mean a category having all finite limits. A cartesian functor between cartesian categories C and D is a functor F : C → D that preserves finite products, in the sense that if i∈I x i is a finite product of objects x i ∈ C, i ∈ I, with projections π i : i∈I x i → x i , then the images constitute a product of the objects F(x i ) ∈ D, i ∈ I. Natural transformations between cartesian functors require no extra conditions, as they automatically preserve products. To see this, suppose α : F ⇒ G is a natural transformation between cartesian functors F, G : C → D. Then, in the case of a binary product of x, y ∈ C, we have where the middle equation follows from the naturality of the transformation α applied to the projections π x : x × y → x and π y : x × y → y in C.
The resulting terminology for diagrams is not standard but should be self-explanatory. Similarly, morphisms of cartesian diagrams are defined as in Definition 4.1, replacing "category" with "cartesian category" and "functor" with "cartesian functor." Remark 6.2 (Diagrams, 2-categorically). As this replacement procedure suggests, the present paper's most fundamental definitions involve only formal category theory in that they do not depend on the specifics of categories, functors, and natural transformations, but only on the fact that these form a 2-category. For example, given a 2-category K, the 2-category Diag → (C) of diagrams in C ∈ K can be defined as the lax slice 2-category K C; similarly, the 2-category Diag ← (C) can be defined as the opposite of the colax slice 2-category K C, using Johnstone's notation [38]. Taking K = Cat recovers the classical notion of diagrams, while taking K = Cart, the 2-category of cartesian categories, cartesian functors, and natural transformations, yields the setting of this section. At the expense of introducing mild logical redundancy, we deemphasize the 2-categorical perspective in order to avoid unnecessary formalism. More importantly, the theory in Section 5 does rely on the specifics of the 2-category Cat and so does not extend to other 2-categories without further argument.
Any category of generalized elements of a cartesian category is itself a cartesian category. Given a cartesian category C, the product of generalized elements x i : S → X i , i ∈ I, in El S (C) is the pairing (x i ) i∈I : S → i∈I X i obtained by the universal property of the product in C. The projections π i : (x i ) i∈I → x i in El S (C) are simply the projections π i : i∈I X i → X i in C. Moreover, the codomain projection π := cod : El S (C) → C is clearly a cartesian functor. One can therefore consider lifting problems and extension-lifting problems of cartesian diagrams through the cartesian functor π. The foundational results concerning extension-lifting problems from Section 5 will be verified for cartesian diagrams at the end of this section. For now, we take them for granted in presenting examples of differential equations as lifting problems of cartesian diagrams.
In categories involving vector spaces, (finite) products are typically direct sums of vector spaces, which are also set-theoretic products. In particular, this is the case in the prototypical such category, Example 6.3 (Diffusion with source). Extending Example 3.3, suppose that a substance is diffusing on a three-dimensional Riemannian manifold M that has an external source or sink, which adds or removes substance at an instantaneous rate S ∈ Ω 0 t (M). The system is described by the nonhomogeneous diffusion equation, where, as before, φ = k dC is the negative diffusion flux. Alternatively, the system is presented by the cartesian diagram In this picture, the product on the left side, indicated by dotted lines, is implicitly part of the domain diagram because the diagram is cartesian, even if it would not usually be drawn. The map ι 1 : Ω 0 t → Ω 0 t ⊕ Ω 0 t is the inclusion x → (x, 0) associated with the direct sum. The transformation involved in the diagram morphism is natural, due to equations such as Building on the conventions in Section 2 for drawing diagrams, type-theoretic notation is used to distinguish between those objects in the indexing category of a cartesian diagram that are products and those that merely map to products. Consider the two cartesian diagrams Both diagrams map to the product cone X π X ← − − X×Y π Y − → Y, but their indexing categories are respectively the free cartesian category on two objects and the free cartesian category containing a span, i.e., Thus, the first diagram specifies the product in the indexing category whereas the second does not. When a product is intended, it is advisable to include it in the indexing category since that ensures, for example, that any lift of a cartesian diagram through a functor π will have the intended products, irrespective of the properties of π (but see also Lemma 6.8). Failing to do so can also have subtle but significant consequences for morphisms of the diagram, as the next example shows. 2) that happens to be constant in time. One would expect this to define a morphism of diagrams from the static equations to the dynamic ones. This is indeed the case if the diagrams are taken to be cartesian, with terminal objects specified in the indexing category. Writing ρ k : Ω k → Ω k t to mean the operation that sends k-forms to time-dependent k-forms that are constant in time, there is a morphism of cartesian diagrams in Sh R (M), where the morphism indexing the time derivative ∂ t on the right side is sent to the composite indexing the map Ω 2 ! − → 0 0 − → Ω 2 on the left side. The indexing morphism into the terminal object, indicated by the dotted arrow, would not usually be drawn at all, but it is implicitly contained in the indexing category because this category is cartesian. The corresponding naturality equation says that the time derivative of a time-dependent form that is constant in time is zero. The other naturality equations hold because spatial derivatives commute with the operations ρ k .
This example shows that cartesian diagrams should be preferred to bare diagrams when using product structure, even when doing so in seemingly minor ways.
The use of products to specify sums, as in Example 6.3, is common enough to merit its own abbreviated notation: for any integer n ≥ 0, the cartesian diagram π n + is abbreviated as where it is not necessary to label the projections since addition is commutative. For readers familiar with string diagrams, the notation is deliberately reminiscent of the depiction of commutative monoid objects in symmetric monoidal categories [71, §6], but note the reversal of the arrows corresponding to the projections. With this notation, Maxwell's equations in matter admit the following presentation.
is the electric charge density, and J ∈ Ω 1 t (M) is the current density [4]. As before, the operator δ := −1 • d • is the codifferential. If we assume the existence of an electric potential φ ∈ Ω 0 t (M) and a magnetic potential A ∈ Ω 1 t (M), we can add the two further equations Since d 2 = 0, these latter two equations imply the first half of Maxwell's equations, the Maxwell-Faraday equations (Example 3.2). When studying electromagnetism in a material medium, it is conventional to introduce the electric displacement D ∈ Ω 2 t (M) and magnetic intensity H ∈ Ω 1 t (M), related to the electric and magnetic fields by the constitutive relations where the conductivity σ ∈ C ∞ (M) is another property of the medium, is an equation independent of Maxwell's that is often added.
A cartesian diagram for Maxwell's equations in matter, assuming Ohm's law and the existence of an electric and magnetic potential, is shown in Figure 2. It faithfully encodes all of Equations (6.2) to (6.5). It fulfills the promise of the Introduction to give a rigorous interpretation to Maxwell's house, which was shown in its traditional, informal style in Figure 1. The inconsistency pointed out in the Introduction is avoided through the use of products. Lifting morphisms of cartesian diagrams. To conclude this section, we extend the main lifting result of Section 5 to the cartesian setting. The reader willing to take this result for granted may skip the following without loss of continuity. Theorem 6.6. Suppose that π : E → C is a cartesian discrete opfibration between cartesian categories. Then the functor Diag ← (π) : Diag ← (E) → Diag ← (C) between categories of cartesian diagrams is also a discrete opfibration.
Proof. Suppose (R, ρ) : D → D is a morphism of cartesian diagrams and D is a cartesian diagram lifting D through π. Then, in particular, (R, ρ) is a morphism of (bare) diagrams and D is a diagram lifting D through π. By Theorem 5.2, there exists a unique morphism of diagrams (R, ρ) : D → D lifting (R, ρ). Thus, to prove that Diag ← (π) is a discrete opfibration, we must show that the lift D is necessarily a cartesian diagram. That is a consequence of the following lemma. Lemma 6.7. If D : J → C is a cartesian diagram and D : J → E is a diagram lifting D through a cartesian discrete opfibration π : E → C, then D is also cartesian.
Proof. For any product cone {π i : j → j i } i∈I in J, its image {D(π i ) : D j → D j i } i∈I is a product cone in C and its image {D(π i ) : D j → D j i } i∈I } is a cone in E. Since D = D • π, the latter cone will be a product cone if the functor π reflects products, which is true by the final lemma below. Lemma 6.8. A discrete opfibration (or discrete fibration) between cartesian categories that preserves finite products also reflects finite products.
Proof. In general, a functor F : C → D creates limits for a class of diagrams, and in particular reflects them, whenever (i) C has those limits and F preserves them and (ii) F reflects isomorphisms [68, Exercise 3.3.iv]. Since discrete (op)fibrations reflect isomorphisms, the result follows.

Diagrams involving tensor products
Any physical system modeled by linear partial differential equations can be formalized using cartesian diagrams in a category of vector spaces or sheaves of vector spaces, as in the preceding section. The classical physics of diffusion, waves, and electromagnetism belong to this setting, as does the quantum mechanics of continuous systems, described by Schrödinger's equation. But, of course, many other physical systems exhibit nonlinearity.
Nonlinear physics is accomodated by the diagrammatic formalism in at least two different ways. First, cartesian diagrams can be adapted to nonlinear equations by simply abandoning the category of (sheaves of) vector spaces and linear maps in favor of the category of (sheaves of) sets and functions. One could also consider vector spaces and possibly nonlinear maps as a compromise. In either case, categorical products are given by set-theoretic products. This approach is perfectly viable and, for strongly nonlinear systems like the sine-Gordon equation [70] (which involves the sine of an unknown function) may even be necessary. However, most equations of mathematical physics exhibit more structure than an arbitrary nonlinear system in that, while they may be nonlinear, they are at least multilinear in the unknown functions and their derivatives. In such cases, it is natural to remain in a category with linear maps, using the familiar device of tensor products to reduce multilinearity to linearity.
In this section, we study diagrams involving tensor products. The tensor product of vector spaces is an example of a symmetric monoidal product in a category: a product-like operation on a category that does not necessarily satisfy the universal property of a product or coproduct, yet is still associative, unital, and commutative up to coherent natural isomorphism. So, to be more precise, we study diagrams in symmetric monoidal categories. We assume a working knowledge of symmetric monoidal categories, as can be gleaned from the surveys by Baez and Stay [5], Coecke and Parquette [17], and Selinger [71].
While it may appear that the passage from diagrams with cartesian products to diagrams with monoidal products is shorter than that from bare diagrams to those with cartesian products, the opposite is the case. The projections associated with a cartesian product, together with their universal property, permit cartesian diagrams to be presented in essentially the same style as ordinary diagrams. Although we have been agnostic about the syntax of cartesian diagrams in the logician's strict sense, a syntactical, graph-theoretic description can be given using finite product sketches [83]. Because a generic monoidal product does not have projections, just as a tensor product of vector spaces does not, monoidal diagrams require an entirely different visual and combinatorial mode of presentation. This section therefore marks a more significant departure than the previous one, and certain aspects of the theory will be less fully developed.
The objects of interest are now suitably structured diagrams in a symmetric monoidal category (SMC). Morphisms of symmetric monoidal diagrams are defined similarly to Definition 4.1, replacing "category" with "symmetric monoidal category", "functor" with "symmetric monoidal functor," and "natural transformation" with "monoidal natural transformation." Formally, the 2-categories of symmetric monoidal diagrams are the diagram 2-categories relative to the 2-category SMC, in the sense of Remark 6.2.
Recall that a symmetric monoidal functor (F, Φ, φ) : (C, ⊗ C , I C ) → (D, ⊗ D , I D ) between SMCs consists of a functor F : C → D between the underlying categories, together with a natural family of structure morphisms Φ x,y : F x ⊗ D Fy → F(x ⊗ C y), x, y ∈ C, and φ : I D → F(I C ), subject to certain axioms. In general, a symmetric monoidal functor is lax. When the structure morphisms are all isomorphisms, it is strong; when they are identities, it is strict. In this paper, including in Definition 7.1, symmetric monoidal functors are taken to be strong unless otherwise stated. Moreover, we can and will assume that the shapes of symmetric monoidal diagrams are strict SMCs and that the maps between shapes are strict symmetric monoidal functors. If free categories, which are the shapes of free diagrams, are generated by graphs, then what kind of structure generates free strict SMCs, which are the shapes of free symmetric monoidal diagrams? In an influential paper [56], Meseguer and Montanari established a connection between Petri nets and free strict SMCs, which has been fully clarified only recently through work by Baez et al [7] and independently by Kock [44]. Free strict SMCs are generated by a Petri-net-like structure called Σnets [7], of which a special case are whole-grain Petri nets [44]. We refer to the cited papers for the precise definitions, but idea is simple enough. A net is a kind of directed bipartite graph, with vertices of one type-drawn as ellipses-being the generating objects of the SMC and the vertices of the other type-drawn as rectangles-being the generating morphisms. Input and output arcs between the two types of vertices specify the domain and codomain of the generating morphisms. For example, the free strict SMC generated by objects w, x, y, z and morphisms f : w → x ⊗ y and g : x ⊗ y → z is presented by the net x y w z f g .
To save space and emphasize connections with graph-based diagrams, we adopt the nonstandard convention of drawing morphism generators that have exactly one input and one output as a labeled arrow. Thus, the pictures x y f and x y f both represent the generating morphism f : x → y. In summary, using nets, we can visually present free strict SMCs and thus also free symmetric monoidal diagrams. The category of generalized elements of shape S in an SMC (C, ⊗, I) becomes an SMC itself when S has the additional structure of commutative comonoid object (S , δ, ) in C. Here δ : S → S ⊗ S is the comultiplication and : S → I is the counit. The monoidal product on El S (C) is defined on objects x : S → X and y : S → Y by with monoidal unit : S → I, and on morphisms as in C. Defining the associators, unitors, and braidings of El S (C) by post-composition with the associators, unitors, and braidings of C, it is straightforward to check that the former are well-defined and satisfy the SMC axioms. For example, the braidings are well-defined because the composites are equal by the naturality of the family σ X,Y , X, Y ∈ C, and by the commutativity of the comonoid object. Moreover, the codomain projection π := cod : El S (C) → C is a strict symmetric monoidal functor. Two special cases of this construction are particularly relevant. First, when a category C has finite products, a cartesian monoidal category (C, ×, 1) is defined by making a choice of products for each pair of objects and a choice of terminal object. For any object S ∈ C, there is a unique commutative comonoid object (S , ∆ S , ! S ) with carrier S , in which ∆ S is the diagonal map (id S , id S ) : S → S × S and ! S is the unique map S → 1. The category of generalized elements El S (C) then becomes a cartesian monoidal category itself. Thus, the setting of the previous Section 6 is a special case of this one, apart from the need to make a choice of products in order to obtain a monoidal structure. The cartesian case has enough special features to merit its own treatment, however.
The other case of interest is when the category of generalized elements has shape S = I equal to the monoidal unit of the SMC (C, ⊗, I). The commutative comonoid object (I, δ, ) is given by unitor isomorphisms, with the comultiplication and counit being δ := λ −1 I = ρ −1 I : I − → I ⊗ I and := id I : I − → I.
In this case, the SMC is often a symmetric closed monoidal category, as in the motivating example of (Vect R , ⊗, R), the category of real vector spaces with its tensor product. In the category Sh R (M) of sheaves of vector spaces on a manifold M, the tensor product is defined by taking tensor products of vector spaces locally, for each open subspace of M, followed by sheafification. A final complication is that tensor products and cartesian products/direct sums are often needed in conjunction. The structure of a category with two symmetric monoidal products, where one distributes over the other up to coherent isomorphism, is captured by the notion of a symmetric rig category or symmetric bimonoidal category [37,Chapter 2]. In the following examples, we make free use of both tensor products and cartesian products. This is justified by the theory developed in the final parts of the present section and the previous one, although we omit the details of the bimonoidal structure. For a homogeneous, incompressible fluid, the density is a constant in space and time, ρ ≡ ρ 0 , which we may as well normalize to 1. The Euler equations are then where ∇ is the covariant derivative on the Riemannian manifold. Using the formula L u u = ∇ u u+ 1 2 d u 2 that relates the Lie and covariant derivatives of u with respect to u itself [22], we can rewrite the first equation as This version of the Euler equation is useful when translating to the discrete exterior calculus, which defines a discrete Lie derivative but not a discrete covariant derivative [36]. Boyland Figure 3a shows the incompressible Euler equations as a symmetric monoidal diagram in Sh R (M × [0, ∞)).
where µ, assumed to be constant, is the dynamic viscosity [60,Equation 5]. The extra term µ δdu can be rewritten as δτ, where τ is the stress and τ = µ du is a constitutive equation relating the stress and the gradient of the flow velocity. With this notation, Figure 3b shows the incompressible Navier-Stokes equations as a symmetric monoidal diagram.
Lifting morphisms of monoidal diagrams. Just as discrete opfibrations provide a useful level of generality at which to study the lifting properties of diagram morphisms, monoidal discrete opfibrations, introduced more recently, are useful to study the lifting properties of morphisms of monoidal diagrams. In the remainder of this section, we define monoidal discrete opfibrations, explain their connection with monoidal category actions, and extend the main lifting result of Section 5 to monoidal diagrams. This material may be omitted without loss of continuity.
Definition 7.4 (Monoidal discrete opfibration). A symmetric monoidal discrete opfibration between SMCs is a strict symmetric monoidal functor that is also a discrete opfibration between the underlying categories.
The definition specializes that of a (non-discrete) monoidal opfibration, introduced by Shulman [72, Definition 12.1]. We emphasize that the monoidal functor is required to be strict even when the monoidal categories are not strict, which is atypical for monoidal functors. As a result, a monoidal discrete opfibration π : E → C satisfies the important property that, if f : x → w and g : y → z in E are lifts of f : x → w and g : y → z in C through π, then f ⊗ g is a lift of f ⊗ g through π with domain x ⊗ y, and hence is the unique such lift.
The equivalence between discrete opfibrations over a category C and actions of the category C, recalled in Equation (5.1), extends to monoidal categories. An action of an SMC (C, ⊗, I) is a lax symmetric monoidal functor (X, Φ, φ) : (C, ⊗, I) → (Set, ×, 1), whose structure morphisms Monoidal products on morphisms, as well as associators, unitors, and braidings, are inherited from C. With this definition, the canonical projection π X : El(X) → C is a symmetric monoidal discrete opfibration. Moreover, the category of elements construction extends to an equivalence between symmetric monoidal discrete opfibrations over C and actions of the SMC C. We will not state this equivalence precisely, but it is a special case of the equivalence between monoidal opfibrations and lax monoidal pseudofunctors (C, ⊗, I) → (Cat, ×, 1), established by Moeller and Vasilakopoulou using the monoidal Grothendieck construction [59]. For example, when (S , δ, ) is a commutative comonoid object in an SMC (C, ⊗, I), the representable category action Hom C (S , −) : C → Set becomes an action of (C, ⊗, I) via the structure morphisms and φ( * ) := (S − → I). Taking its category of elements, we recover the symmetric monoidal discrete opfibration cod : El S (C) → C associated with the category of generalized elements of shape S .
The basic lifting result in Theorem 5.2 extends to monoidal diagrams as follows.
Proof. Suppose (R, ρ) : D → D is a morphism of symmetric monoidal diagrams and (D, Φ, φ) is a symmetric monoidal functor lifting (D, Φ, φ) through π. Then, in particular, (R, ρ) is a morphism of diagrams and D is a diagram lifting D through π. By Theorem 5.2, there exists a unique morphism of diagrams (R, ρ) : D → D lifting (R, ρ). Thus, to prove that Diag ← (π) is a discrete opfibration, we must show that there exists a unique structure of a symmetric monoidal functor (D , Φ , φ ) on D that lifts D through π as a symmetric monoidal functor, i.e., such that π • (D , Φ , φ ) = (D , Φ , φ ). We must also show that ρ is a monoidal natural transformation with respect to this structure. The uniqueness is clear, since if the structure morphisms exist, then the composition law for monoidal functors and the strictness of π implies that π(Φ j,k ) = Φ j,k for all j, k ∈ J and also π(Φ ) = φ .
The uniqueness of the structure morphisms Φ j,k and φ then follows from the uniqueness of lifts through π.
We now prove the existence of the structure morphisms. For any j, k ∈ J , since π is strict, in C, respectively. But the latter two morphisms are equal, since ρ : D • R ⇒ D is a monoidal natural transformation, so the former two morphisms are also equal, by the uniqueness of lifts through π. In particular, the codomain of Φ j,k is D ( j ⊗ k), as required. Similary, there is a lift φ : I E → D (I J ) of φ : I C → D (I J ) through π. Thus, we have the data (D , Φ , φ ) of a symmetric monoidal functor. That it is a strong symmetric monoidal functor follows straightforwardly from π being discrete opfibration, and the argument above already shows that ρ is a monoidal natural transformation.

Composition of diagrams and multiphysics
Multiphysics is the study of physical systems that couple together distinct physical phenomena [42]. For example, reaction-diffusion systems combine chemical reactions between different substances with the diffusion of those substances throughout a medium [25,73]. Of course, what counts as a single physics or as multiple physics is largely a matter of perspective, and even systems that are usually considered to involve a single physics, such as a diffusion process, may be derived by combining several distinct physical principles. In this section, as an application of the diagrammatic formalism, we systematize the compositional and hierarchical construction of physical, possibly multiphysical, theories from first principles and experimental laws.
Besides categories of diagrams, the key mathematical tool enabling this formalization are the structured cospans introduced by Baez and Courser [6] as a variant of Fong's decorated cospans [26]. Decorated and structured cospans belong to a now well established tradition of modeling open systems usings spans or cospans [41]. Open systems of a geometrical nature are modeled as cospans, where the legs of a cospan give inclusions of the system's boundaries into the system itself. Composition is by pushout (gluing along boundaries). Dually, open systems consisting of quantitative state variables on a geometrical space are modeled as spans, where the legs of a span give projections of the system's state space onto the state spaces of its boundaries. Composition is by pullback or variants thereof, such as in Baez, Weisbart, and Yassine's study of open systems in Lagrangian and Hamiltonian mechanics [8].
Having seen how diagrams can present physical quantities on geometrical spaces and how diagram morphisms can serve as projections defining boundary value problems, it would be natural to define "open diagrams" in a category C as spans in the diagram category Diag ← (C). For the purposes of this section, however, it suffices to consider spans in (Cat/C) op , the wide subcategory of Diag ← (C) having strict diagram morphisms. Composing open diagrams by pullback then amounts to computing pushouts in the slice category Cat/C and so ultimately in Cat. Although pushouts of categories are generally complicated, pushouts of free categories (the shapes of free diagrams) are simple because they reduce to pushouts of the generating graphs.
To be more precise, we take open diagrams to be structured spans, which are the formal duals of structured cospans [6]. Given a functor R : A → X, an R-structured span is a pair of objects a, b ∈ A together with a span of form Ra ← x → Rb in X. Assuming the categories A and X have finite limits and the functor R is a right adjoint, a hypergraph category is formed by the objects of A and isomorphism classes of R-structured spans, where composition is given by pullback in X [6, Theorem 3.12]. For our applications, fix a category C and consider the discrete diagram functor Disc C : Set/ Ob(C) → Cat/C, which sends an indexed set of objects in C to the discrete diagram with those objects. This functor is left adjoint to the underlying objects functor Ob C : Cat/C → Set/ Ob(C). Consequently, its opposite functor Disc op C : (Set/ Ob(C)) op → (Cat/C) op is a right adjoint. We provisionally define an open diagram in C to be a Disc op C -structured span, or equivalently a span in Diag ← (C) whose legs are strict diagram morphisms and whose feet are discrete diagrams. As one would expect, the two open diagrams above can be composed, using the operations available in a hypergraph category, to form the diffusion equation (3.1). However, experience of the authors and collaborators shows that it is more convenient to employ an alternative syntax for composition that does not artificially insist on dividing the boundary of an open system into exactly two parts [52,53]. We thus mildly generalize the definitions of structured spans and open diagrams as follows. Given a functor R : A → X, an R-structured multispan is a list of objects a 1 , . . . , a n ∈ A, where n ≥ 0, together with a multispan of form x Ra 1 Ra 2 · · · Ra n−1 Ra n in the category X.

Definition 8.2 (Open diagram
). An open diagram in a category C is a Disc op C -structured multispan, or equivalently a multispan in Diag ← (C) whose legs are strict diagram morphisms and whose feet are discrete diagrams.
Although it is not assumed by the theory, the feet of an open diagram will be singleton diagrams (diagrams indexed by the terminal category) in our examples. Open diagrams can then be defined more succinctly by giving the diagram at the apex of the multispan and stating which indexing objects are exposed through the legs of the multispan. Composites of open diagrams can be specified in an appealing visual manner using undirected wiring diagrams (UWDs). Given a category C, there is an operad of typed, undirected wiring diagrams [53,74] with types being discrete diagrams in C. Isomorphism classes of open diagrams in C form an algebra of this operad, where an undirected wiring diagram acts on a list of structured multispans by evaluating a suitable limit, generalizing the composition of structured spans by pullback. The existence of this operad algebra follows from the equivalences between hypergraph categories and cospan algebras [27] and between cospan algebras and algebras of the operad of UWDs   Let v ∈ X t (M) be a fixed time-dependent velocity field for the fluid advecting the substance. If C := C ∈ Ω 3 t is the density corresponding to the 0-form C ∈ Ω 0 t , then the flux of C due to advection is simply ι v C, where ι v : Ω 3 t → Ω 2 t is the interior product with respect to v [1, Definition 6.4.7]. In Euclidean space M = R 3 , using the various isomorphisms between forms and vector fields, this term can be identified with the vector-scalar product vC, which is possibly more familiar. In any case, an advection equation on a three-dimensional Riemannian manifold M is obtained by applying the UWD (8.3) to the open diagram with C and φ exposed, along with the open diagram (8.2) for mass conservation. In traditional notation, the resulting differential equation is where L v denotes the Lie derivative with respect to v, having used Cartan's magic formula Theorem 6.4.8 (iv)]. The equation ∂ t C + L v C = 0 has been called the Lie advection equation [61].
The UWD algebra of open diagrams enables not only modular but also hierarchical construction of physical theories, as illustrated by the following two-level construction of the advection-diffusion equation.  with all of φ 1 , φ 2 , and φ exposed. It may seem excessive to glorify mere addition with the name "superposition" but the addivity of the fluxes does have the physically meaningful interpretation that the two sources of flux are independent of each other. Applying the UWD (8.5) to the superposition diagram as well as to the diffusion and advection flux diagrams (8.1) and (8.4), all now regarded as open cartesian diagrams, we obtain an open cartesian diagram exposing C and φ and encoding the equation for the total negative flux. We can then apply the original UWD (8.3) to this diagram and the mass conservation diagram (8.2) to obtain an open cartesian diagram exposing C and encoding the advectiondiffusion equation. Alternatively, we can operadically compose the original UWD (8.3) with the UWD This equation, compact though it is, already contains substantial physical content, which is formally represented by its hierarchical construction.
Nesting of undirected wiring diagrams may be repeated indefinitely, as hinted at in this section's final example, which involves a three-level hierarchy. We can then proceed as in the previous examples. For instance, applying the new UWD to the diffusion flux diagram (8.1) yields the nonhomogeneous diffusion equation, which was defined directly in Example 6.3. We can also compose with the UWD (8.6) to obtain a more refined UWD for advectiondiffusion with a source or sink.
To incorporate reaction, we introduce a yet higher level of hierarchy via the UWD C : Ω 0 t S : Ω 0 t Transport process Transformation process (8.8) coupling mass transport with reaction or transformation processes. Into the box labeled "transport process" we expect to substitute the UWD (8.7) or any of its concrete applications sketched above. As for the "transformation process" box, a particularly simple choice is the open diagram for a first-order growth or decay, according to the sign of the rate constant β ∈ R. Any additional substances which may be driving this process are left unmodeled. Applying the UWD (8.8) to the appropriate open cartesian diagrams yields the basic example of an advection-diffusion-reaction equation on a Riemannian manifold.

Weak equivalence of diagrams
It is possible for nonisomorphic diagrams to present physical theories that are equivalent in the sense of having interchangeable solutions, as shown by the two different presentations of the heat equation in Example 4.6. In this section, we make a preliminary study of such "weak equivalences" of diagrams: morphisms of diagrams that establish one-to-one correspondences between lifts of their domain and codomain diagrams.
The foundational Theorem 5.2 established that lifts of a diagram D in a category C through a discrete opfibration can be pushed forward along any morphism out of D in the diagram category Diag ← (C). Understanding when morphisms in the dual category Diag → (C) have the same property is essential to characterizing weak equivalence. To state this property precisely, it is helpful to weaken the defining condition of a discrete opfibration (Definition 5.1) so that it does not apply everywhere. Let us say, using a nonstandard but self-explanatory phrase, that a functor π : E → C is a discrete opfibration at a morphism f : x → y in C if, for every object x ∈ E with π(x) = x, there exists a unique morphism f : x → y in E such that π( f ) = f . Thus, a functor into C is a discrete opfibration in the usual sense exactly when it is discrete opfibration at every morphism in C. Definition 9.1 (Pushforward property). Given a category C, a morphism (R, ρ) in the diagram category Diag → (C) has the pushforward property if, for any discrete opfibration π : E → C, the functor Diag → (π) : Diag → (E) → Diag → (C) is a discrete opfibration at (R, ρ). Lemma 9.2 (Closure of pushforward property). Let C be a category.
(i) The class of morphisms in Diag → (C) having the pushforward property forms a wide subcategory of Diag → (C). (ii) For any discrete opfibration π : E → C, the pushforward property is preserved by lifts through Diag → (π).
Sketch of proof. To prove part (i), suppose D − −− → F are composable morphisms in Diag → (C) having the pushforward property. Let π : E → C be a discrete opfibration and D be a lift of D through π. A lift of the composite (T, τ) := (R, ρ) · (S , σ) through Diag → (π) with domain D is obtained by composing the lift (R, ρ) : D → E of (R, ρ) at D with the subsequent lift (S , σ) : E → F of (S , σ) at E. As for uniqueness, any lift (T, τ) of the composite (T, τ) with domain D must factorize as (R, ρ) · (S , σ), as seen by applying the unique lifting property of π to the components of τ. That identities in Diag → (C) have the pushforward property is easy to see, and also follows from stronger results below.
For part (ii), suppose (R, ρ) is a lift through Diag → (π) of a morphism (R, ρ) having the pushforward property. Since the composite of another discrete opfibration µ : F → E with π : E → C is again a discrete opfibration, it straightforward to show that (R, ρ) has the pushforward property using the fact that (R, ρ) does.
A weak equivalence of diagrams is a special kind of diagram morphism having the pushforward property, namely one with an invertible 2-cell. Recall that diagram morphism (R, ρ) is said to be strong if ρ is invertible, and strict if ρ is an identity. It follows from the lemma above that, for any category C, weak equivalences of diagrams in C form a wide subcategory of Diag ← (C), and for any discrete opfibration π : E → C, weak equivalences are preserved by lifts through Diag ← (π).
The property of defining a bijection between lifts, which weak equivalences are expected to exhibit, is captured by the concept of a discrete bifibration. A functor π : E → C is a discrete fibration if its opposite π op : E op → C op is a discrete opfibration; explicitly, π : E → C is a discrete fibration if for every morphism f : x → y in C and every object y ∈ π −1 (y), there exists a unique morphism f : x → y in E such that π( f ) = f . A functor is a discrete bifibration if it is both a discrete fibration and a discrete opfibration. One can similarly define the notion of a functor into C that is a discrete (bi)fibration at some morphism f : x → y in C.
With this terminology, the definition of a weak equivalence is justified by: Proposition 9.4 (Weak equivalences biject lifts). If π : E → C is a discrete obfibration, then the functor Diag ← (π) : Diag ← (E) → Diag ← (C) is a discrete bifibration at any weak equivalence of diagrams in C.
Essentially by definition, diagram morphisms satisfying the pushforward property give a statement dual to Theorem 5.2, and weak equivalences of diagrams establish a bijection between lifts through any discrete opfibration. However, these definitions are of little utility unless they can be verified in concrete situations. To that end, the rest of this section is dedicated to finding sufficient conditions for the pushforward property, and hence for weak equivalences, that can be checked mechanically in particular examples.
Initial functors. A simple criterion, not the most general possible, for a diagram morphism to have the pushforward property is that the functor between indexing categories be initial [54,§IX.3], [67, §8.3]. This important fact, which is a special case of Theorem 9.12 below, will not be immediately apparent from the definition: Definition 9.5 (Initial functor). A functor R : J → J is initial if, for every object j ∈ J , the comma category R/ j is nonempty and connected.
Recall that the comma category R/ j has as objects, the pairs ( j, f ), where j ∈ J and f : R j → j in J , and as morphisms ( j, f ) → (k, g ), the morphisms h : j → k in J making the triangle commute:

R j Rk
j Rh g f . Also, recall that a category is connected whenever any pair of objects can be joined by a finite zig-zag of morphisms.
Example 9.6 (Weak equivalence from initial functor). Recall from Example 4.6 the morphism in between presentations of the heat equation, which is well-defined when k is constant over the manifold M. The diagram morphism is strict and its map between indexing categories is initial, as can be checked directly from the definition. Therefore, by the result to be shown below, the morphism of diagrams is a weak equivalence of diagrams, as anticipated in Example 4.6.
The definition of an initial functor in terms of comma categories is concrete and often easy to check in particular situations, but provides little conceptual insight. Initial functors are motivated by their classical characterization as the functors that preserve limits under change of indexing category. Specifically, for any functor R : J → J and diagram D : J → C, there is a canonical morphism Proposition 9.7 (Initial functors preserve limits). A functor R : J → J is initial if and only if, for any category C and diagram D : J → C, the canonical morphism (9.1) is an isomorphism whenever the limits involved exist. The same statement holds when the category C is specialized to Set.
The proof of this proposition, which is not essential for our purposes, can be found in [ A useful sufficient condition for a functor to be initial is: Lemma 9.8 (Full initial functors). Let R : J → J be a full functor. Then, for R to be initial, it is enough that the comma category R/ j be nonempty and connected for every object j ∈ J not in the essential image of R.
In particular, any full and essentially surjective functor is initial.
Proof. Suppose j ∈ J is in the essential image of R, so that we can find an object k ∈ J and isomorphism m : Rk − → j . The category R/ j is nonempty because it contains the object (k, m). Suppose ( j, f ) is another object of R/ j . Since R is full, the composite is the image under R of some morphism f : j → k in J and hence f : ( j, f ) → (k, m) is a morphism in R/ j . This shows that (k, m) is weakly terminal in R/ j . In particular, the category R/ j is connected. Lemma 9.9 (Closure of initial functors).
(i) Composites of initial functors are initial.
(ii) Equivalences of categories are initial. In particular, the initial functors comprise a wide subcategory of Cat.
Proof. Part (i) is [54,Exercise IX.3.2]. It is also a special case of Lemma 9.14 proved below. Part (ii) follows from from Lemma 9.8, since equivalences of categories are full and essentially surjective.
Relatively initial morphisms of diagrams. The condition that a morphism of diagrams have an initial functor between the indexing categories is stronger than it needs to be, as it does not even make reference to the diagrams themselves or the transformation between them. This defect is remedied by the following definition, which seems to be original. For any j ∈ J , define a category (R, ρ)/ j that has as objects, the pairs ( j, f ), where j ∈ J and f : R j → j in J , and as morphisms ( j, f ) → (k, g ), the morphisms h : j → k in J making the pentagon commute: Composition and identities in (R, ρ)/ j are defined as in J, and so there is a projection functor (R, ρ)/ j → J.
We say that the functor R : J → J is initial relative to ρ or that the diagram morphism (R, ρ) is relatively initial if, for every object j ∈ J , the category (R, ρ)/ j is nonempty and connected.
For any j ∈ J , the category (R, ρ)/ j has the same objects as the comma category R/ j but generally has more morphisms, since if h : j → k is a morphism from ( j, f ) to (k, g ) in R/ j , then the naturality of ρ gives a commuting diagram and hence a morphism from ( j, f ) to (k, g ) in (R, ρ)/ j . Thus, being relatively initial is weaker than being initial, and any extension of an initial functor R : J → J to a morphism (R, ρ) : (J, D) → (J , D ) in Diag → (C) is relatively initial. On the other hand, initiality is formally a special case of relative initiality, since a functor R : J → J is initial if and only R is initial relative to the identity id R , i.e., if and only if the morphism (R, id R ) : (J, R) → (J , id J ) in Diag → (J ) is relatively initial.
between free diagrams, where the map between indexing categories is the obvious inclusion. Because the indexing categories are free, the map between them is not initial, but because the diagrams commute, the diagram morphism is relatively initial. The next theorem, the main result of this section, shows that the two diagrams are weakly equivalent, as one would expect.
Theorem 9.12 (Lifting relatively initial morphisms of diagrams). Any relatively initial morphism of diagrams has the pushforward property.
Consequently, if C is a category and (R, ρ) : D → D is a strong morphism in Diag ← (C) such that the morphism (R, ρ −1 ) : D → D in Diag → (C) is relatively initial, then (R, ρ) is a weak equivalence of diagrams.
Proof. Let (R, ρ) : (J, D) → (J , D ) in Diag → (C) be a relatively initial morphism of diagrams in a category C. We must show that, for any discrete opfibration π : E → C and any lift D of D through π, there exists a unique morphism (R, ρ) : First, we prove that the lifts D and ρ : D ⇒ D • R are unique whenever they exist. Since π : E → C is a discrete opfibration, for each j ∈ J, the object D j ∈ E along with the morphism π(D j) = D j ρ j − → D R j in C has a unique lift through π to a morphism D j ρ j − → e j in E, which must be the j component of ρ. This proves the uniqueness of ρ. The diagram D is determined on objects in the image of R by the equations D R j = e j , j ∈ J. Moreover, once D is defined at an object R j, it is determined on all morphisms in J outgoing from R j (including their codomains), since D must project to D and lifts through π are unique. In particular, since (R, ρ)/ j is nonempty for every j ∈ J , the diagram D is determined everywhere and so is unique if it exists.
It remains to show that both D and and ρ actually exist, the proof of which fully uses the assumption that (R, ρ) is relatively initial.
For any objects j ∈ J and ( j, f ) ∈ (R, ρ)/ j , the object e j ∈ E along with the morphism D R j D f − −− → D j in C has a unique lift through π to a morphism e j f − → • in E. Note that, despite the notation, the lift f depends not only on f : R j → j but also on j. However, if f is in the image of R, say f = R f for f : j → k in J, then the codomain of f is e k . To see this, note that the (possibly ill-formed) square But the latter square commutes, by the naturality of ρ, so the former square must also commute, by the uniqueness of lifts through π. In particular, the codomain of f is e k . With these preliminaries, we can define D on objects. For each j ∈ J , the category (R, ρ)/ j is nonempty, so choose an object ( j, f ). We wish to define D j to be the codomain of f , but first we must check that the codomain depends only on j , not on the choice of ( j, f ) ∈ (R, ρ)/ j . If h : j → k is a morphism in (R, ρ)/ j from ( j, f ) to (k, g ), then letting h = Rh, the diagram where the squiggly arrow indicates that the latter two diagrams are equivalent. Now the last diagram commutes, by definition of morphisms in (R, ρ)/ j , so the first diagram also commutes, by uniqueness of lifts. This implies that cod f is constant on connected components of (R, ρ)/ j . But (R, ρ)/ j is connected by assumption, so cod f is constant on all of (R, ρ)/ j . Thus, we may define D j := cod f . Having defined it on objects, it remains to define the diagram D on morphisms. Given a morphism h : j → k in J , let h be the unique lift of D h through π with domain D j and then define D h := h . We must check that the codomain of h is D k . Taking any object ( j, f ) in (R, ρ)/ j and letting g = f · h , the pair ( j, g ) is an object of (R, ρ)/k , so comparing the lifts D R j Street and Walters established a similar result many years ago [78]. As part of proving that initial functors and discrete opfibrations form the left and right parts of an orthogonal factorization system [66], called the comprehensive factorization, they show that an extension-lifting problem in Cat, where R is an initial functor and π is a discrete opfibration, has a unique solution, indicated by the dashed arrow [78,Theorem 4]. This is the special case of Theorem 9.12 where the transformation ρ is an identity and the functor R is initial.
To close the section, we show that relative initiality has the properties expected of a generalization of initiality. The analogue of Proposition 9.7, that initial functors preserve limits, is: Proposition 9.13 (Relatively initial maps preserve limits). Suppose C is a category and (R, ρ) : D → D is a strong morphism in Diag ← (C) such that (R, ρ −1 ) : D → D in Diag → (C) is relatively initial. Then the pushforward by (R, ρ) of cones over D to cones of D , defined by Equation (4.1), sends limits of D to limits of D .
Proof. First, we show that a relatively initial morphism (R, ρ) : (J, D) → (J , D ) in Diag → (C) pushes forward cones over D to cones over D . Since cones over a diagram are the same as lifts of the diagram through a generalized element projection, this is a special case of Theorem 9.12, but we give a selfcontained proof to make the construction explicit.
Suppose λ is a cone over D with apex x ∈ C. Define a cone λ over D with apex x by choosing, for each j ∈ J , an object ( j, f ) ∈ (R, ρ)/ j and setting To prove that λ is a cone, consider a morphism h : j → k in J and let ( j, f ) and (k, g ) be the objects of (R, ρ)/ j and (R, ρ)/k defining the legs λ j and λ k of λ . By assumption, the category (R, ρ)/k is connected, so we can find a zig-zag of morphisms in (R, ρ)/k connecting ( j, f · h ) and (k, g ), which yields a commutative diagram: x D j D j 1 · · · D j n−1 Dk D R j D R j 1 · · · D R j n−1 D Rk D j D k Thus, using the definition of λ , we obtain the required equation λ j · D h = λ k .
As for the proposition itself, now suppose (R, ρ) : (J, D) → (J , D ) is a strong morphism in Diag ← (C) such that (R, ρ −1 ) in Diag → (C) is relatively initial. In one direction, given a cone λ over D with apex x, a cone λ over D with the same apex x is defined by In the other direction, given a cone λ over D with apex x, the above construction yields a cone λ over D with legs for any choice of ( j , f ) ∈ (R, ρ −1 )/ j. Moreover, when j is in the image of R, we can take j with R j = j and f = id j , so that It is then straightforward to show that these mappings define a bijection between cones over D and D and in fact an isomorphism between the categories of cones over D and D . Since limits are terminal objects in the category of cones, they are preserved by the mappings.
Finally, for completeness, we record the following closure properties. Lemma 9.14 (Closure of relatively initial maps).
(i) Composites of relatively initial morphisms of diagrams are relatively initial.
(ii) Isomorphisms of diagrams are relatively initial. In particular, for any category C, the relatively initial morphisms of diagrams in C form a wide subcategory of Diag → (C).
Proof. Part (ii) follows from Lemma 9.9 (ii), so we need only prove part (i). − −− → (K, F) is a composable sequence of relatively initial morphisms in Diag → (C). We must show that for every k ∈ K, the category (R, ρ)·(S , σ)/k is nonempty and connected.
It is clearly nonempty, since we can choose an object ( j, S j h − → k) in (S , σ)/k and then choose an object (i, Ri g − → j) in (R, ρ)/ j and so obtain an object (i, S Ri S g − − → S j h − → k) in (R, ρ) · (S , σ)/k.
As for connectnedness, consider two objects (i, S Ri h − → k) and (i , S Ri h − → k) in the category (R, ρ) · (S , σ)/k. Since (S , σ)/k is connected, we can find a zig-zag of morphisms connecting (Ri, h) and (Ri , h ) in (S , σ)/k. Without loss of generality, assume that this zig-zag consists of a single morphism g : Ri → Ri in J. Now, since (R, ρ)/Ri is connected, we can find a zig-zag of morphisms connecting (i, g) and (i , id Ri ) in (R, ρ)/Ri , yielding a commutative diagram:

Di
Di 1 · · · D i n− Applying the naturality of the transformation σ to the morphisms g =: g 0 , g 1 , . . . , g n−1 , an equivalent commutative diagram is:

Conclusions and future work
In this paper, we have undertaken to systematize, formalize, and generalize the diagrams employed by Tonti and others to present differential equations in physics. The mathematical foundation is provided by category-theoretic diagrams and morphisms between them, as well as extensions to diagrams involving cartesian products or tensor products. A wide variety of physical systems, from electromagnetism to transport phenomena to fluid mechanics, have been shown to fit into this framework. Morphisms of diagrams, not considered in the physics literature, have been used to formalize relationships between different systems, as well as to modularly construct complex, possibly multiphysical, systems from basic physical principles and experimental laws. On the theoretical side, we have explained how solving systems of equations or boundary value problems amounts to solving lifting or extension-lifting problems of diagrams, and we have studied in some detail how morphisms from both categories of diagrams interact with lifts of diagrams (Theorems 5.2 and 9.12).
It should be noted that Tonti's attempted classification of physical theories, besides its distinctive use of diagrams, involves a rich ontology of concepts in physics. For example, Tonti classifies physical variables into source, configuration, and energy variables [80,Chapter 5] and physical equations into defining, topological, behavior, and phenomenological equations, each with further subclassifications [80,Chapter 6]. No attempt has been made here to formalize these distinctions, and it is an interesting question whether or not this is possible.
Our proposed notion of a weak equivalence of two diagrams, which establishes a one-to-one correspondence between lifts of the diagrams, merits further study. We introduced a generalization of an initial functor, called a relatively initial morphism of diagrams, and showed that it leads to a sufficient condition for weak equivalence, but we have left open whether this is also a necessary condition, or whether our notion of weak equivalence even admits any characterization in terms of concrete, easily verified conditions. Moreover, the term "weak equivalence" is suggestive of methods from homotopy theory such as localization and calculus of fractions [28]. Preliminary investigations suggest that homotopical methods may be applicable to initial or relatively initial morphisms of diagrams. This would aid in understanding quotient categories of diagrams where weak equivalences are formally inverted, a construction not pursued here.
To sidestep the complexities of weak equivalence, one might seek ways of formalizing physical theories or systems of equations that are less sensitive than diagrams to differences of presentation. The category-theoretic approach to logic, pioneered by Lawvere [49], reconstructs logical theories as algebraic objects, making them presentation invariant. It would be worthwhile to understand how physical theories formalized using either category-theoretic diagrams or categorical logic are related.
Finally, although this work has its origins in the partial differential equations of continuum physics, with most examples drawn from that subject, we emphasize that its foundation in category-theoretic diagrams is far more general. In Examples 2.2 and 4.9, difference equations were presented using diagrams in Vect R , requiring only linear algebra, rather than differential geometry. In future work, we intend to explore how probabilistic and statistical models, such as structural equation models, can be presented by diagrams in suitable categories. We hope and expect that many further applications will be found.