Manuscript Offprint
arXiv:2611.05924How to prove equations using diagrams: A categorical and operational semantics for e-graphs
Abstract
E-graphs are a powerful algorithmic technique for automated equational reasoning but have resisted a conceptual understanding independent of issues of presentation and implementation. We propose an operational semantics for e-graphs based on the fundamental category-theoretic concepts of diagrams, limits, and initial functors. We illustrate the formalism through numerous example calculations and establish its soundness and completeness. Technical prerequisites are kept to a minimum in the main text; less standard elements of the mathematical theory are developed in two appendices.
1 Introduction
Mathematical expressions and computer programs are most directly represented as the labeled trees known as terms. However, computer scientists have long found reasons to encode expressions in more general mathematical and data structures. Generalizing from trees to directed acyclic graphs (DAGs), a term DAG enables common subexpressions to be represented by the same vertices, making more efficient use of space [PW78]. Generalizing further to equip a term DAG with an equivalence relation, an equality graph, or e-graph for short, efficiently encodes a family of terms along with an equivalence relation on the terms [Nel80; NO80]. Computing the equivalence relation's congruence closure under term formation then leads to an algorithm to decide quantifier-free formulas in the theory of equality with uninterpreted function symbols. The ideas behind e-graphs, dating back to the late 1970s, received a surge of new attention when their combination with equality saturation [Tat+09] was shown to be a fast and flexible tool for equational reasoning [Wil+21].
Standard expositions, early and recent, emphasize the data structures and algorithms needed to implement e-graphs, such as the union-find [Tar75] and hash-cons data structures and congruence closure algorithms. Data structures and algorithms are indispensable to building practical technology based on e-graphs. Still, they do not exhaust the ways to understand e-graphs. What might be called a “theory of e-graphs”—a mathematical and conceptual understanding of e-graphs, independent of any algorithmic or implementation details—has been elusive. Besides its intrinsic interest, a good theory can be expected to eventually lead to further practical advances.
In this paper, we propose a mathematical semantics for e-graphs. The semantics is, in the first place, a categorical semantics, meaning that category-theoretic concepts—categories, functors, and so forth—are used to give mathematical content to syntactical objects like terms or, in this case, term graphs. Characteristic of categorical semantics is its invariance to presentation: not depending on how the objects in question are presented or implemented. In this spirit, we deliberately avoid proposing a single definition of “e-graph.” Rather, we describe a means of representing equations using category-theoretic diagrams that is conceptually compatible with how e-graphs encode equations, but makes no commitments about presentation.
In addition to being categorical, our semantics is primarily operational. That might seem surprising since categorical semantics are often exclusively denotational, beginning with Lawvere's reconstruction of algebraic theories as categories with finite products [Law63; Cro93; ARV11]. Indeed, we will use algebraic theories qua categories in Section 4. Yet our guiding principle throughout is to analyze not what e-graphs are as objects but what their valid transformations are as morphisms. This is an operational semantics inasmuch as it gives mathematical content to operations performed on e-graphs. The operational aspect, like the denotational one, is invariant: the set of allowed operations is defined "all at once" and without reference to a presentation, rather than being generated by a minimal set of atomic steps as in a small-step operational semantics. Our operational semantics also does not aim at reduction to a final value (or set of values). This is in contrast to many operational semantics for programming languages, but it is in keeping with software systems like egg [Wil+21] and egglog [Zha+23] that are not fixed procedures but allow flexible schedules of rules to be run against an e-graph.
The thesis of this paper is that a categorical and operational semantics for e-graphs can be found in the concept of an initial functor. Consider the term graphs below, which for the moment we take to be labeled graphs.

Both term graphs encode the same two terms, and . The map between them, collapsing both edges labeled on the left to the single edge labeled on the right, is a homomorphism of labeled graphs. It is an example of a congruence reduction, which is, in turn, one type of valid transformation of term graphs, where "valid" means not changing the terms or equations implicit in the graph. It is then natural to ask: what are all the valid transformations? To our knowledge, an elegant answer to this question cannot be given using only the language of graphs and graph homomorphisms. If, instead, we see the map as a functor (between categories freely generated by graphs), we can recognize an example of a known class of functors, the initial functors. As we will explain, initial functors are exactly those that preserve the system of equations encoded by a diagram; in category-theoretic language, restricting the shape of a diagram along an initial functor preserves the diagram's limit, whenever it exists.
The operational semantics for e-graphs thus rests on an analysis of when a functor is guaranteed to maintain, in a suitable sense, the universal property defining a limit. Universal properties are an essential—arguably the essential—idea in category theory. It is for this reason that category theory is the natural language for a theory of e-graphs.
Outline Section 2 lays the groundwork by explaining how to represent systems of equations using category-theoretic diagrams. Section 3 justifies this representation by introducing morphisms between diagrams and singling out the initial ones as those preserving the systems of equations. Rules for, and examples of, calculating with initial morphisms are given. So Sections 2 and 3 concern representation and reasoning, respectively. They are restricted to categories with no extra structure, which in logical terms correspond to algebraic theories with only unary operations. This setting is very limited practically, but it suffices to illustrate the main ideas. Section 4 extends the formalism to categories with finite products, corresponding to the classical setting of algebraic theories (with multiary operations). Finally, Section 5 offers a brief outlook on future directions. Two technical appendices develop the background mathematics.
Background We assume familiarity with the basic concepts of category theory, particularly categories, functors, diagrams, and limits. Further concepts not covered by most textbooks, namely initial functors and comprehensive factorization, are reviewed in Appendix A. As for computer science, readers familiar with term graphs or e-graphs will find connections with those concepts, but no prior knowledge of them is needed to make sense of this paper.
Related work Two groups have recently proposed category-theoretic accounts of e-graphs [BCG25; Tiu+25]. Without going into specifics, both define an “e-hypergraph” to be a labeled hypergraph equipped with extra structure that, directly or indirectly, specifies an equivalence relation. Neither representation allows taking initial functors to be morphisms of e-graphs, the main idea and novelty of this paper.
Motivated by “Tonti diagrams” in computational physics, the author and collaborators have previously used category-theoretic diagrams to represent systems of equations—here, differential equations—and initial functors to formalize weak equivalence of diagrams [Pat+23; Car+24]. The underlying mathematics dates back to the early 1970s, with key results due to Paré [Par73] and Street–Walters [SW73]. The novelty of this work is to recognize the connection between initial functors and the operational aspect of e-graphs.
While diagrams can encode equations in different ways, in this paper a diagram specifies a system of equations through its limit. The limit may or may not exist in the target category C, but the limit always exists when the diagram is interpreted by sets and functions via a functor . A simple first example illustrates these points.
Example 2.1 (An equalizer diagram). Consider a square in some category C:
First of all, what diagram is meant by this picture? In general, we use lowercase letters for objects in the shape J and uppercase letters for objects in the target category So
Explicitly naming the objects in a diagram’s shape is unconventional among category theorists, but doing so makes space for the variables that show up in term graphs.
are objects in J and W, X, Y, Z are objects in C. As for morphisms, we leave the morphisms in the shape nameless and use lowercase letters for morphisms in the target category. So, in this example, C must contain morphisms , , , and .
In the absence of further assumptions, the diagram is not completely determined by its depiction (2.1). The freest, or most general, assumption would take both J and C to be categories freely generated by graphs. The diagram would then be given explicitly as the functor
Whatever the choice of target category C, the diagram represents the system of equations
This system of equations is equivalently but more compactly written as
although that is not the literal reading of the diagram.
The formal meaning of the “system of equations represented by a diagram” comes from the diagram’s limit, which characterizes the system’s solutions by a universal property. The limit can be taken “semantically” or “syntactically.” Working semantically, for any functor , the composite functor is a diagram of sets and functions whose limit is (in canonical bijection with) both (2.2) and (2.3), now interpreted as actual sets. Or, staying in the realm of syntax, we can try to evaluate the limit directly in . If is the free category on a directed square, then the limit does not exist, reflecting that the diagram’s equations do not hold in . On the other hand, if is finitely presented as
then the limit of the diagram exists and its apex is just , reflecting that the diagram's equations are now true in . Later, we will see how to turn this observation into a technique for proving equations in a finitely presented category.
Systematizing the example, a diagram is free if its shape is a free category, i.e., is freely generated by a graph . Note that a diagram being free implies nothing about its target category. The examples in this section and the next will be exclusively of free diagrams. We emphasize, however, that nothing in the theory requires this; in future work, we may consider diagram shapes containing nontrivial isomorphisms as a more faithful model of the equivalence relation in an e-graph.
By the free-forgetful adjunction between graphs and categories, a free diagram in a category C is nothing other than a graph labeled by objects and morphisms in C. The important connection to category theory is not through the data of the diagram itself, but through the notions of limit and, as explained in Section 3, of limit-preserving changes of diagram shape.
This reading of (2.2) and (2.3) abuses notation by conflating the abstract object (“type”) X with the set and the morphism (“operation”) f with the function .
When speaking precisely of a graph, we always mean the category theorist's notion—what a graph theorist might call a “directed multigraph with self-loops.” In Section 4 we use “multigraph” to mean something else.
2.1 Other ways to represent equations with diagrams
It should be noted that this way of representing equations with diagrams subtly differs from others with which the reader may be more familiar.
Remark 2.2 (Comparison with commutative diagrams). Category theorists often use commutative diagrams to assert equations between morphisms. While it is not always carefully defined, this phrase does have a precise meaning: a diagram commutes, or is commutative, if for every pair of morphisms in with the same domain and codomain, their images in are equal.
The senses in which limits and commutativity represent equations through a diagram are not the same. As a small counterexample, consider the free diagrams
in some category where but . Then both diagrams have the same limit, namely X, but the first diagram commutes while the second does not.
Remark 2.3 (Comparison with cyclic term graphs). The graph rewriting community generalizes the notion of term graph from a DAG to an arbitrary graph, regarding it as a system of recursion equations [e.g., AK96, Figure 6]. Cycles are unwound into infinite terms with finitely many distinct subterms, called rational terms [CG98]. Our formalism interprets diagrams differently, with no special treatment of cycles. Each morphism in the diagram's shape introduces an equational constraint between a pair of variables, where in the case of an endomorphism the two variables happen to be the same (see Example 3.5 below).
3 Reasoning with initial morphisms between diagrams
What makes the foregoing representation useful, compared to innumerable other ways of encoding terms and equations in graph-like structures, is that its notion of morphism leads naturally to a way of reasoning about equations.
A morphism of diagrams in a common category , say from to , is a functor making the triangle
commute. In other words, the category of diagrams in C is the slice category Cat/C.
A more flexible definition of morphism between diagrams permits the triangle to be filled by a natural transformation, instead of strictly commuting. However, it turns out [Car+24] that this ostensibly more general starting point leads to the same relation of weak equivalence on diagrams, so we need not consider it here.
An arbitrary morphism of diagrams need not preserve the systems of equations represented by the diagrams, but it does give a canonical comparison in one direction. Assuming the limits in question exist, the restricted family of projections , for , forms a cone over and thus, by the universal property of the limit of , there exists a unique morphism
factoring through the projections of . In general, this comparison map is not invertible.
A functor is initial if, for every diagram in an arbitrary category , the canonical comparison map (3.1) is an isomorphism, whenever the limits exist (either limit existing if the other does). For other, equivalent ways to define an initial functor, see Definition A.1 in Appendix A. We denote an initial functor with a double-headed arrow, , and we extend the terminology to say that a morphism of diagrams is initial if its underlying functor is initial.
Intuitively, the initial morphisms of diagrams are those that preserve the system of equations represented by the domain or codomain diagrams, as the following example illustrates.
Example 3.1 (A congruence reduction). Resuming the example from Remark 2.2, the morphism of diagrams
sending both and in the domain's shape to in the codomain's shape, is initial. To see this, notice that the limit of both diagrams is the equalizer of and , whenever it exists. The intuitive justification is that the systems of equations presented,
and
are equivalent to each other, and also to .
3.1 Weak equivalence of diagrams
Initial functors, and thus also initial morphisms of diagrams, are closed under composition and identities (Proposition A.3), so two diagrams being “related by an initial functor” is a transitive and reflexive relation. It is not symmetric: although every isomorphism of categories—indeed, every equivalence of categories (Proposition A.3)—is an initial functor, there are plenty of initial functors that are not invertible (see Example 3.1). Those are the interesting ones. Yet the relation on diagrams of “representing equivalent systems of equations” should plainly be an equivalence relation; said differently, we want to treat initial morphisms as if they were invertible. This problem is solved by formally inverting the initial morphisms.
A weak equivalence of diagrams will be another name for an initial morphism of diagrams. Two diagrams and in some category are weakly equivalent, denoted , if they can be connected by a zig-zag of weak equivalences.
We say weak equivalence because such morphisms are not equivalences in any familiar 2-category of diagrams. The phrase “weak equivalence” is also deliberately suggestive of homotopy theory. While we will not make serious use of homotopy-theoretic techniques, we note in passing one characteristic property [GZ67, §I.2]: a priori, weakly equivalent diagrams are connected only by a zig-zag of arbitrary finite length, but in fact, a cospan always suffices. To restate this:
Proposition 3.2 (Weak equivalence, cospan form). Two diagrams and are weakly equivalent if and only if there exists a diagram and initial functors and making the triangles commute:
Proof. Follows from the stability of initial functors, and hence of initial morphisms of diagrams, under pushouts (Proposition A.3).
We record this fact only to emphasize that weak equivalence can be defined “all at once,” without recourse to a finite but unbounded iteration. Directly calculating the intermediate diagram does not seem to be computationally feasible.
3.2 Rules of inference
Although initial functors and weak equivalence are invariant notions applicable to diagrams of any size, when calculating it is convenient to have a library of motifs that can be applied mechanically, without having to check initiality at each step. In this section, we record the basic motifs and explain what it means to apply them.
In the motifs that follow, all diagrams are in a fixed but arbitrary category C.
• Operation introduction: for any morphism in C, the diagram morphism
is initial.
• Congruence reduction: for any morphism in C, the diagram morphism
sending both and to y, is initial.
• Equation elimination: for any morphism in C, the diagram morphism
is initial.
- Factorization expansion: for any morphisms and in , the diagram morphism
is initial. Similarly, for any object , the diagram morphism
sending both and to x, is initial.
All of these functors are initial since the limit of every diagram above is simply X.
Each motif gives rise to a rule of inference that can be applied to transform one diagram into another that is weakly equivalent. We will not go so far as to propose a formal system for such derivations, as our focus is rather on mathematical semantics. Still, the justification for our calculations is that initial functors, and thus also initial morphisms of diagrams, are stable under pushout with respect to arbitrary morphisms (Proposition A.3). An example illustrates how to apply rules by computing pushouts.
Example 3.3 (Applying congruence reduction). The initial morphism of diagrams asserted directly in Example 3.1 can be constructed by applying the congruence reduction rule:
To show that two diagrams are weakly equivalent, we are allowed to apply these rules in either direction. In doing so we can derive new rules. Particularly important is equation introduction for equations between morphisms in the target category C. As a representative case, suppose in C. Applying the rules above, there is a zig-zag of weak equivalences
\begin{array}{c}x:X\\\longrightarrow\quad\begin{array}{c}x:X\\g\circ f=koh\\\downarrow\\z:Z\end{array}\quad\longleftarrow\quad\begin{array}{c}x:X\\g\circ f\left(\begin{array}{c}k\\ \end{array}\right)\\z:Z\end{array}\quad\longrightarrow\quad y:Y\begin{array}{c}f\\g\end{array}\begin{array}{c}x:X\\h\\z:Z\end{array}\begin{array}{c}w:W.\\k\end{array}Hence, whenever in C, the two diagrams are weakly equivalent:
It remains to explain how to begin a derivation, assuming nothing of the target category. Suppose we start with a singleton diagram, whose shape is the terminal category, say . The limit of this diagram exists trivially, being itself. Any weakly equivalent diagram will continue to have as its limit. In particular, any parallel paths in such a diagram that originate at the object corresponding to must commute. We use this technique in the calculations that follow. It will become more powerful when we extend to categories with finite products (Section 4), since we can then start with any finite discrete diagram, the shape's generating objects acting as “free variables.”
3.3 Example calculations
We show by example how to prove equations using the calculus of weak equivalence.
Example 3.4 (Pasting commutative squares). The pasting law for commutative squares says that two commutative squares with a common edge can be juxtaposed to produce a commutative rectangle. The notation makes this seem obviously true—that's what makes it good notation—but it still needs a proof. The calculus of weak equivalence makes the proof completely mechanical.
Suppose that the two squares below commute:
Formally, take the target category C to be generated by six objects, called and seven morphisms, called , subject to those two equations.
Begin with the singleton diagram , representing the domain of the equation to be proved. Recognize that we can introduce the first equation at :
Then recognize that we can introduce the second equation at y:
Finally, apply congruence reduction at y:
Since the limit of the original diagram is , the limit of the final, weakly equivalent diagram remains . Consequently the outer paths around the rectangle commute, which was the equation in to be proved:
The next example is adapted from Nelson and Oppen's original work introducing e-graphs [Nel80, §6], [NO80].
Example 3.5 (A monoid presentation). Consider a monoid with an element f satisfying the equations
That is, take the target category to be generated by a single object, say , and an endomorphism, , satisfying those two equations.
Begin with the singleton diagram and introduce both defining equations, noting that since each equation has an identity on one side, they appear as cycles:
We omit the types of the objects and the labels of the arrows, these always being the object and the generating morphism , respectively. We now compute the congruence closure, iteratively applying congruence reduction until that is no longer possible. The first two reductions, at and then at , are:
Applying congruence reduction five more times, at , and , gives the sequence:
The final diagram is the self-loop over f. We have proved the equation
since the limit of the final diagram is that of the original one, namely the unique object . In other words, the monoid presented is the trivial monoid.
3.4 Soundness and completeness
The calculus of weak equivalence is put on a firmer foundation by showing that it is sound and complete for reasoning about systems of equations under any interpretation by sets and functions. In logical jargon, one might say that it is sound and complete for equational reasoning with “uninterpreted function symbols.” Soundness holds essentially by the definition of an initial functor (Definition A.1). Completeness is more involved. Here we state only the result, deferring the proofs to Appendix A and references therein.
Theorem 3.6. Two diagrams and are weakly equivalent if and only if, for every set-valued functor , the limits and are in bijection, naturally in .
Proof. These are two of the four equivalent conditions in Theorem A.10, a more refined result.
We caution that we have not proved the completeness of the specific rules in Section 3.2, though we expect some such result should hold when precisely formulated.
4 The cartesian setting: universal algebra via diagrams
The categorical and operational semantics for e-graphs so far exists in the simplest possible setting, that of categories absent any further properties or structure. In the dictionary of categorical logic, a bare category corresponds to an algebraic theory with only unary function symbols. This is rather restrictive. The classical setting for equational reasoning—universal algebra—is that of algebraic theories, whose categorical counterparts are categories with finite products. Historically, universal algebra was the starting point for both categorical logic [Law63] and e-graphs [Nel80].
In this section, we extend the operational semantics from bare categories to categories with finite products. Surprisingly, this turns out to be, in a sense, trivial: in the definitions and results used in Sections 2 and 3, it is enough to insert the adjective “cartesian” wherever it makes sense. Full justification of this claim is deferred to Appendix B, where initial functors, comprehensive factorization, and limits are shown to interact well with finite products. Here we focus on the operational aspect of calculating with diagrams valued in an algebraic theory.
4.1 Cartesian diagrams and their morphisms
For brevity, we say that a category is cartesian if it has finite products and that a functor is cartesian if it preserves finite products. A diagram in a cartesian category is cartesian if its shape is a cartesian category and the functor is itself cartesian.
Cartesian categories and functors are familiar; cartesian diagrams less so, as limits or colimits are not usually indexed by categories assumed to have products. When taking limits in a cartesian category, there is no harm in making the diagrams cartesian too, because a cone over a cartesian diagram is uniquely determined at a product of objects by its legs at the factors (Lemma B.8). Moreover, any of the diagrams from Sections 2 and 3 can be transported to the cartesian setting without altering its limit (Proposition B.10). But cartesian diagrams are more expressive, allowing diagram shapes to specify multiary operations and diagram morphisms to assign arbitrary terms.
Cartesian diagrams, like ordinary ones, are conveniently generated by combinatorial data. The appropriate data is a multigraph: a set of vertices and a set of multiedges, along with an assignment to each multiedge of a list of vertices, called its source, and a single vertex, its target. In more loaded jargon, a multigraph is a signature, its vertices are sorts, and its multiedges are function symbols. A morphism of multigraphs consists of a pair of functions between the vertex sets and multiedge sets, preserving the source and target assignments. Rearranging the data slightly, the category of multigraphs is seen to be a presheaf topos [Wal89, §1].
We say that a cartesian diagram is free if its shape is a cartesian category freely generated by a multigraph. There are several ways to explicitly construct the free cartesian category on a multigraph [e.g., Wal89, §2], but it is enough to know that a free cartesian diagram corresponds to a multigraph morphism into the underlying multigraph of . The latter is nothing other than a term graph, taking that phrase to mean a labeled multigraph. Moreover, the limit of the free cartesian diagram is completely determined by the term graph (Proposition B.9). As before, all examples of cartesian diagrams in this paper will be free, but freeness is not an assumption of the theory.
The target category may be any cartesian category but is often given by finite presentation. We need not be too precise about how to present a cartesian category. Roughly, a presentation consists of a signature and a set of equations between terms in context over the signature. Adopting the perspective of categorical logic [Law63; Cro93; ARV11], we identify a small cartesian category with an algebraic theory, where the objects and morphisms of the category correspond to the types and operations of the theory, respectively.
A first example is adapted from Nelson and Oppen [Nel80, §6], [NO80]; along with Example 3.5, this covers the two toy examples from the original work on e-graphs.
Example 4.1. Let C be the signature with (i.e., the free cartesian category generated by) a type X and a binary operation . Then the terms and with free variables a:X and b:X, as well as the equation , are encoded by the term graph (i.e., the free cartesian diagram) in C:

Later, we will see how to simplify this diagram using congruence closure.
The notions of morphism from Section 3 extend straightforwardly to the cartesian setting. A morphism of cartesian diagrams is a morphism of diagrams whose underlying functor is cartesian. In other words, the category of cartesian diagrams in a cartesian category C is the slice category Cart/C. A cartesian initial functor is nothing other than a functor that is both cartesian and initial. Similarly, a morphism of cartesian diagrams is initial if its underlying functor is initial. Such morphisms are also called weak equivalences. Two cartesian diagrams are weakly equivalent if they can be connected by a zig-zag of weak equivalences.
This terminology is chosen to make the analogy “graphs : categories :: multigraphs : multicategories” hold.
The nature of this correspondence, a 2-categorical universal property, is the subject of Walters' paper [Wal89].
4.2 Rules of inference
The motifs and rules introduced in Section 3.2 become more general in the cartesian setting, effectively allowing a context comprising a single free variable to be replaced by an arbitrary context, i.e., a finite list of variables.
In the motifs that follow, let C be a cartesian category.
- Operation introduction: for any morphism in , the morphism of cartesian diagrams
is initial.
• Congruence reduction: for any morphism in , the morphism of cartesian diagrams,
sending both and on the left-hand side to on the right-hand side, is initial.
• Equation elimination: for any morphism in , the morphism of cartesian diagrams
is initial.
- Factorization expansion: for any factorization of a morphism in C, the morphism from the cartesian diagram indexed by a single morphism to the cartesian diagram indexed by the shape of the factorization is initial. For example, given morphisms
in C, the morphism of cartesian diagrams

is initial.
To see that the functors above are initial, notice that restricting along each one preserves the limit of any compatibly shaped cartesian diagram. Indeed, by Proposition B.9, each limit is simply the product (where, in the final example, k = 4).
The motifs give rise to rules, applied by taking pushouts. A technical hitch compared to Section 3.2 is that (1-categorical) pushouts of cartesian categories generally do not exist. The simplest fix is to take pushouts in the category of small categories with chosen finite products and strictly product-preserving functors. Within this cocomplete category, initial functors are stable under pushout, a corollary of Theorem B.2.
Example 4.2 (Applying congruence reduction). Returning to Example 4.1, the morphism of cartesian diagrams,

sending both a and c on the left-hand side to a on the right-hand side, is initial. It is an application of congruence reduction. The diagram on the right cannot be reduced further. □
We can again derive new rules, valid in the sense of preserving weak equivalence, by applying the motifs in either direction. Notably, a generalized equation introduction rule can be derived by the same argument as in Section 3.2. Suppose, for example, that morphisms
in a cartesian category C satisfy . Then the rule says that there is a weak equivalence
By Proposition B.1, it suffices to consider cartesian diagrams in the definition of initial functor.
of cartesian diagrams in C:
Finally, the assumption-free starting point for a derivation generalizes from a singleton diagram to a discrete diagram. Recall that a multigraph is discrete if its set of multiedges is empty. A cartesian diagram is discrete if its shape is freely generated by a discrete multigraph. The limit of a cartesian diagram that is finitely generated and discrete, say , always exists, being the product . Any weakly equivalent cartesian diagram will have the same limit, from which equations can be deduced. The next section demonstrates this technique.
4.3 Example calculation: a property of well-behaved lenses
Let C be the algebraic theory of a well-behaved lens. That is, C is the algebraic theory with signature comprising
• sorts ("source") and ("view"),
• operations get: and put: ,
and two axioms:
• PUTGET: .
• GETPUT: .
A very well-behaved or lawful lens satisfies the further axiom:
• PUTPUT: .
The PUTPUT law is independent of the other two. However, a special case of the PUTPUT equation, with , is derivable from the first two laws:
• PUTTWICE: .
We are going to prove this by diagrammatic reasoning. The derivation is fairly trivial, though the fact is noted in the lens literature [FHP15].
Begin with the discrete cartesian diagram . Since the right-hand side of the target equation is , a natural first step is to introduce the put operation:
Recognizing a subterm of the PUTGET law, we introduce that equation at and , then apply congruence reduction of put at and :

(We could have saved a few steps by immediately introducing the PUTGET equation, but we wish to emphasize the mechanizability of such reasoning.) Next, we recognize a subterm of the GETPUT law (replacing with ), so we introduce that equation at :

The final morphism is again a congruence reduction, this time of get at .
The resulting cartesian diagram contains the target equation, though it takes a moment to see that. Since the first and last cartesian diagrams are weakly equivalent, and since the limit of the first diagram is the product , the limit of the last diagram is also . Consequently, in the last diagram, any two parallel morphisms in the shape starting at evaluate to equal morphisms in C. Taking the endpoint and following the cycle at (for fixed ) either zero times or once, we deduce the PUTTWICE law:
5 Outlook
We have seen how the concept of initial functor leads to a method of proving equations by manipulating diagrams. We regard this method as a categorical and operational semantics for e-graphs, as demonstrated by reproducing calculations from the e-graphs literature.
While we have so far treated only the classical setting of e-graphs, a good categorical semantics should suggest generalizations of e-graphs to new or nonstandard settings. We mention two possible directions. First, it seems likely that the extension of initial functors and comprehensive factorization from mere categories to cartesian categories (Appendix B) will extend further to cartesian equipments or, what is closely related, cartesian fibrations. In the dictionary of categorical logic, these categorical structures correspond to enhanced notions of algebraic theory having first-class functions and relations. We thus expect to find a categorical and operational semantics for the recent combination of e-graphs and Datalog in egglog [Zha+23]. Another promising direction is extending to essentially algebraic or generalized algebraic theories, which correspond to categories with all finite limits. As far as we know, e-graph software has not yet been developed for this setting.
Acknowledgments I acknowledge support from the Air Force Office of Scientific Research (AFOSR) Young Investigator Program (YIP) through Award FA9550-23-1-0133. I thank my colleague Tim Hosgood for carefully reading and commenting on the series of blog posts that preceded this paper.
References
[AK96] Zena M. Ariola and Jan Willem Klop. "Equational term graph rewriting". Fundamenta Informaticae 26.3–4 (1996), pp. 207–240. DOI: 10.3233/FI-1996-263401.
[ARV11] Jiří Adámek, Jiří Rosický, and Enrico M. Vitale. Algebraic theories: A categorical introduction to general algebra. Cambridge University Press, 2011. DOI: 10.1017/CB09780511760754.
[BCG25] Roberto Biondo, Davide Castelnovo, and Fabio Gadducci. "EGGs are adhesive!" 11th Conference on Algebra and Coalgebra in Computer Science (CALCO 2025). 2025, 10:1–10:18. DOI: 10.4230/LIPics.CALCO.2025.10. arXiv: 2503.13678.
[BD77] Francis Borceux and Brian J. Day. "On product-preserving Kan extensions". Bulletin of the Australian Mathematical Society 17.2 (1977), pp. 247–255. DOI: 10.1017/S0004972700010455.
[Car+24] Kevin Carlson, James Fairbanks, Tim Hosgood, and Evan Patterson. "The diagrammatic presentation of equations in categories" (2024). arXiv: 2401.09751.
[CG98] Andrea Corradini and Fabio Gadducci. "Rational term rewriting". Foundations of Software Science and Computation Structures (FoSSaCS 1998). Springer, 1998, pp. 156–171. DOI: 10.1007/BFb0053548.
[Cro93] Roy L. Crole. Categories for types. Cambridge University Press, 1993. DOI: 10.1017/CB09781139172707.
[FHP15] Sebastian Fischer, Zhenjiang Hu, and Hugo Pacheco. "A clear picture of lens laws (functional pearl)". Mathematics of Program Construction (MPC 2015). Springer, 2015, pp. 215–223. DOI: 10.1007/978-3-319-19797-5_10.
[GU71] Peter Gabriel and Friedrich Ulmer. Lokal präsentierbare Kategorien. Springer, 1971. DOI: 10.1007/BFb0059396.
[GZ67] Peter Gabriel and Michel Zisman. Calculus of fractions and homotopy theory. Springer, 1967. DOI: 10.1007/978-3-642-85844-4.
[Joy20] André Joyal. Factorisation systems. Joyal's CatLab, revised November 20, 2020. 2020. URL: https://ncatlab.org/joyalscatlab/show/Factorisation+systems.
[KR05] Alexander Kurz and Jiří Rosicky. "Weak factorizations, fractions and homotopies". Applied Categorical Structures 13.2 (2005), pp. 141–160. DOI: 10.1007/s10485-004-6730-z.
[Law63] F. William Lawvere. "Functorial semantics of algebraic theories". Republished in Reprints in Theory and Applications of Categories, No. 5 (2004), pp. 1–121. PhD thesis. Columbia University, 1963. URL: http://www.tac.mta.ca/tac/reprints/articles/5/tr5abs.html.
[Mac98] Saunders Mac Lane. Categories for the working mathematician. 2nd ed. Springer, 1998. DOI: 10.1007/978-1-4757-4721-8.
[Nel80] Greg Nelson. "Techniques for program verification". PhD thesis. Stanford University, 1980.
[NO80] Greg Nelson and Derek C. Oppen. "Fast decision procedures based on congruence closure". Journal of the ACM 27.2 (1980), pp. 356–364. DOI: 10.1145/322186.322198.
[Par73] Robert Paré. "Connected components and colimits". Journal of Pure and Applied Algebra 3.1 (1973), pp. 21–42. DOI: 10.1016/0022-4049(73)90003-0.
[Pat+23] Evan Patterson, Andrew Baas, Timothy Hosgood, and James Fairbanks. "A diagrammatic view of differential equations in physics". Mathematics in Engineering 5.2 (2023), pp. 1–59. DOI: 10.3934/mine.2023036. arXiv: 2204.01843.
[PT22] Paolo Perrone and Walter Tholen. "Kan extensions are partial colimits". Applied Categorical Structures 30.4 (2022), pp. 685–753. DOI: 10.1007/s10485-021-09671-9. arXiv: 2101.04531.
[PW78] Michael S. Paterson and Mark N. Wegman. "Linear unification". Journal of Computer and System Sciences 16.2 (1978), pp. 158–167. DOI: 10.1016/0022-0000(78)90043-0.
[Rie08] Emily Riehl. Factorization systems. Expository notes. 2008. URL: https://emilyriehl.github.io/files/factorization.pdf.
[Rie14] Emily Riehl. Categorical homotopy theory. Cambridge University Press, 2014. DOI: 10.1017/CB09781107261457. URL: https://emilyriehl.github.io/files/cathtpy.pdf.
[Rie16] Emily Riehl. Category theory in context. Dover Publications, 2016. URL: https://emilyriehl.github.io/files/context.pdf.
[SW73] Ross Street and R.F.C. Walters. "The comprehensive factorization of a functor". Bulletin of the American Mathematical Society 79.5 (1973), pp. 936–941. DOI: 10.1090/S0002-9904-1973-13268-9.
[Tar75] Robert Endre Tarjan. "Efficiency of a good but not linear set union algorithm". Journal of the ACM 22.2 (1975), pp. 215–225. DOI: 10.1145/321879.321884.
[Tat+09] Ross Tate, Michael Stepp, Zachary Tatlock, and Sorin Lerner. "Equality saturation: A new approach to optimization". Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2009). 2009, pp. 264–276. DOI: 10.1145/1480881.1480915.
[Tiu+25] Aleksei Tiurin, Chris Barrett, Dan R. Ghica, and Nick Hu. "Equivalence hypergraphs: DPO rewriting for monoidal e-graphs". 40th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS 2025). 2025, pp. 209–222. DOI: 10.1109/LICS65433.2025.00023. arXiv: 2406.15882.
[Wal89] R.F.C. Walters. "The free category with products on a multigraph". Journal of Pure and Applied Algebra 62.2 (1989), pp. 205–210. DOI: 10.1016/0022-4049(89)90152-7.
[Wil+21] Max Willsey et al. "egg: Fast and extensible equality saturation". Proceedings of the ACM on Programming Languages 5.POPL (2021), pp. 1–29. DOI: 10.1145/3434304. arXiv: 2004.03082.
[Zha+23] Yihong Zhang et al. "Better together: Unifying Datalog and equality saturation". Proceedings of the ACM on Programming Languages 7.PLDI (2023), pp. 468–492. DOI: 10.1145/3591239. arXiv: 2304.04332.
A Review of initial functors and comprehensive factorization
A functor preserves limits when, for every diagram , the canonical comparison map
furnished by the universal property of , is an isomorphism, assuming the limits in question exist [Mac98, Exercise V.4.5]. That term is standard, yet there is another, dual sense in which a functor could be said to "preserve limits" that varies the shape of a diagram rather than its target. A functor that does not change the limit of a diagram when the diagram is restricted along it is called initial. In this appendix, which is purely expository, we review initial functors and the factorization system into which they fit. Here and throughout the paper, all categories are assumed to be locally small and shapes of diagrams to be small.
A.1 Initial functors: definition and properties
Initial functors are characterized by the following definition/theorem.
Definition A.1 (Initial functor). A functor between small categories is initial, here denoted , if any of the following equivalent conditions holds:
(i) Restriction preserves limits: for every diagram in an arbitrary category , the canonical comparison map
given by the universal property of , is an isomorphism, each limit existing if the other does;
(ii) Restriction preserves limits of sets: condition (i) holds for , i.e., for every diagram of sets , the canonical comparison is a bijection;
(iii) Commas are connected: for every object , the comma category is nonempty and connected.
Proof of equivalence. The equivalence characterizing an initial functor (or rather its dual) is proved in [Rie14, Lemma 8.3.4]. □
The limit characterization of initiality is useful because one can often see at a glance whether a given functor is initial just by imagining what will happen to a limit of sets. The characterization based on connectedness is useful in being concrete and combinatorial. To spell this out, given a functor and an object , the comma category has
-
as objects, an object together with a morphism in ;
-
as morphisms , morphisms in making the triangle commute:
A category is connected if any two of its objects can be connected by a zig-zag of morphisms, i.e., there is an undirected path between them. In the common case that the categories and are freely and finitely generated, proving initiality—checking that each comma category is nonempty and connected—reduces to a combinatorial problem.
Example A.2 (Initial object as initial functor). Let be an object in a category . The corresponding functor is initial if and only if for every , the discrete category is nonempty and connected, i.e., is an initial object in . This fact explains the term “initial,” which might otherwise appear backwards since initial functors are about limits, not colimits. □
Initial functors are a well-behaved class of functors, closed under many operations.
Proposition A.3 (Closure properties of initial functors). Let and be composable functors.
(i) Composition: If and are initial, then so is .
(ii) Cancellation: If and are initial, then so is .
(iii) Equivalences: Every full and essentially surjective functor—in particular, every equivalence of categories—is initial.
(iv) Pushouts: Initial functors are stable under pushout.
(v) Coproducts: Initial functors are closed under coproducts (in ).
As the next subsection shows, nearly all of these properties follow from the foundational theorem about initial functors: that initial functors form the left class of morphisms in a factorization system on .
A.2 Comprehensive factorization of functors
The comprehensive factorization system, discovered by Street and Walters [SW73], is an orthogonal factorization system on the category of small categories. Its left class of morphisms are the initial functors. Its right class are the discrete opfibrations, whose definition we now recall.
Definition A.4 (Discrete opfibration). A functor is a discrete opfibration, here denoted , if for every morphism in and every object with , there exists a unique morphism in such that :
Note that the codomain of is part of the data required to exist uniquely.
Theorem A.5 (Comprehensive factorization [SW73, Theorems 3 & 4]). Initial functors and discrete opfibrations form the left and right classes, respectively, of an orthogonal factorization system on Cat, the category of small categories and functors.
Using the description of an orthogonal factorization system in terms of unique factorization up to unique isomorphism (see [Joy20, Theorem 3.7] or [Rie08, Lemma 1.8]), the theorem says that any functor admits a factorization

as an initial functor followed by a discrete opfibration, and such a factorization is unique in the sense that any other factorization is related by a unique isomorphism making both triangles commute:

Later, we will explain how to actually construct the comprehensive factorization. Its existence already has many consequences, starting with:
Proof of Proposition A.3. Nearly all of the stated closure properties of initial functors follow from closure properties of the left class in an orthogonal factorization system, applied to the comprehensive factorization system (Theorem A.5). Specifically, the cancellation property is [Joy20, Proposition 2.2] or [Rie08, Lemma 1.13], and closure under colimits is [Rie08, Theorem 1.17]. The only property not covered by generalities about factorization systems is that full and essentially surjective functors are initial, proved in [Pat+23, Lemma 9.8].
The comprehensive factorization extends from categories to diagrams in a fixed category.
Corollary A.6 (Comprehensive factorization for diagrams). Let be any category. The slice category , or category of diagrams in , has an orthogonal factorization system whose left and right classes are the morphisms underlain by initial functors and discrete opfibrations, respectively.
Proof. This follows from Theorem A.5 and the fact that orthogonal factorization systems pass to slices (and coslices) [Joy20, §1].
Initial functors can also serve as weak equivalences in the sense of homotopy theory. Though not used directly in the main text, the result is worth recording since it too follows from the comprehensive factorization.
Corollary A.7 (Calculi of fractions). As a class of weak equivalences in Cat, the initial functors admit a calculus of left fractions in the sense of Gabriel–Zisman [GZ67, §I.2].
For any category C, the same is true of the morphisms in Cat/C underlain by initial functors.
Proof. The two statements follow from Theorem A.5 and Corollary A.6, combined with the fact that the left class in an orthogonal factorization system admits a calculus of left fractions [KR05, Example 2.4].
That initial morphisms between diagrams admit a calculus of left fractions was first proved in [Par73, §3, p. 32]. The main idea behind that paper is the subject of the next subsection.
A.3 The image copresheaf of a diagram
The two seminal early works on initial functors, both published in 1973, are by Street and Walters [SW73], on the comprehensive factorization of a functor, and by Paré [Par73], on the image copresheaf generated by a diagram.⁸ Their connection, reviewed in this subsection, lies in how the image copresheaf is used to construct the comprehensive factorization, analogously to how the image of a function is used to construct the epi-mono factorization.
Many different diagrams in a category can have the same limit. The image copresheaf captures all of the functorial limit properties of a diagram while forgetting the accidental properties of its shape [cf. Par73, §0].
Definition A.8 (Image copresheaf). The image copresheaf of a diagram is the copresheaf on C defined by
where is the comma category construction and is the connected components functor.
So, on objects, for each . The similarity with the comma characterization of an initial functor (Definition A.1) is striking. To be more precise, a functor is initial if and only if is naturally isomorphic to 1, the terminal copresheaf on .
Like the notion of initial functor, the image copresheaf admits several characterizations:
Theorem A.9 (Guises of image copresheaf). Let be a diagram. Then the following copresheaves on are naturally isomorphic:
(i) ;
(ii) the colimit of representables , where is the (contravariant) Yoneda embedding of ;
⁸The name “image copresheaf” is borrowed from the more recent exposition [PT22, §3].
(iii) the left Kan extension , where 1 is the terminal copresheaf on J;
(iv) a representing object for the representable functor
Proof. The isomorphisms among (i)–(iii) are (the dual of) [Par73, Theorem 2.1 and Corollary 2.8].
We prove that (iii) and (iv) are isomorphic. Given a functor , we have
Hence, the functor is represented by (which, by the Yoneda lemma, is unique up to isomorphism).
The fundamental theorem about the image copresheaf is that it classifies diagrams with the same functorial limit properties, which is reinterpreted in Section 3.4 as a soundness and completeness result for equational reasoning with diagrams.
Theorem A.10 (Isomorphism of image copresheaves). Let and be diagrams in a category . The following are equivalent:
(i) the copresheaves and are naturally isomorphic;
(ii) the diagrams and are weakly equivalent (Section 3.1), i.e., they can be connected by a zig-zag in with each morphism underlain by an initial functor;
(iii) for every category D and functor , the limits and are isomorphic, each existing if the other does;
(iv) for every set-valued functor , the limits and are in bijection, naturally in .
Proof. We have been careless about size issues, but in fact the theorem is true regardless of whether C and D are required to be small categories or range over all locally small categories. In the case of small categories, the equivalence of (i) and (iii) is [Par73, Theorem 3.2], while the equivalence with (ii) is implicit in [Par73, end of §3]. In the case of locally small categories, the equivalence of (i)–(iii) appears verbatim as [PT22, Proposition 3.9].
As for the equivalence of (i) and (iv), we have if and only if , by Theorem A.9 and the Yoneda lemma.
Finally, we recall how the image copresheaf appears in the construction of the comprehensive factorization of a functor.
Construction A.11 (Comprehensive factorization [SW73]). Let be a functor out of a small category . The image copresheaf of is the copresheaf on , the left Kan extension of the terminal copresheaf on along . By the universal property of its category of elements as a comma category, , there exists a unique functor factorizing as
and equating the 2-cells:
In this factorization, is a discrete opfibration, and Street and Walters show that is initial. So is the comprehensive factorization of .
B Cartesian initial functors
In Section 4, we consider diagrams, limits, and initial functors in the setting of categories with finite products. This appendix shows that the well-established theory of these concepts for ordinary categories, reviewed in Appendix A, extends smoothly to cartesian categories. Although we cannot locate a few of the statements directly in the literature, this material should be considered essentially known.
B.1 Initial functors between cartesian categories
For initial functors between cartesian categories, the defining characterizations involving limits (Definition A.1) still hold when confined to cartesian diagrams:
Proposition B.1. Let be a functor between cartesian categories. The following are equivalent:
(i) R is initial;
(ii) for every cartesian diagram in a cartesian category , the canonical comparison is an isomorphism, each limit existing if the other does;
(iii) for every cartesian diagram , the canonical comparison is a bijection.
Proof. That (i) implies (ii) and (ii) implies (iii) is immediate. We prove that (iii) implies (i). The equivalence of (i) and (ii) can also be deduced, in dual form, from the “relative theory” in [Par73, §§5–6].
Let denote the full subcategory of spanned by the cartesian functors. Then condition (iii) furnishes a natural isomorphism between functors . Now, the terminal copresheaf on is trivially cartesian, and the image copresheaf is cartesian by Corollary B.7, proved below. Thus, and 1 are representing objects for and , respectively, using the representation in Theorem A.9. Apply the Yoneda lemma to conclude that and hence that is initial.
Thus, in defining a cartesian initial functor to be simply a functor that is both cartesian and initial, we need not worry about which adjective comes first.
B.2 Comprehensive factorization of cartesian functors
The foundational theorem about initial functors is the existence of the comprehensive factorization system [SW73], an orthogonal factorization system on having initial functors and discrete opfibrations as its left and right classes (Theorem A.5). Perhaps surprisingly, the comprehensive factorization works just as well for cartesian functors as it does for ordinary functors. The precise statement is:
Theorem B.2 (Cartesian comprehensive factorization). The comprehensive factorization system on restricts to an orthogonal factorization system on , the category of small categories with finite products and finite-product-preserving functors.
Moreover, this factorization system on lifts to an orthogonal factorization system on , the category of small categories with chosen finite products and functors strictly preserving the chosen products.
We do not know of a source for this theorem in the literature, though we suspect that it is folklore since it follows straightforwardly from other, well-documented facts. In any case, the purpose of this subsection is to present a self-contained proof. To do so, we show that the explicit construction of the comprehensive factorization (Construction A.11), when applied to a cartesian functor, is a factorization in which the intermediate category and both functors are automatically cartesian, without further assumptions.
The analysis of the right class—discrete opfibrations—is simpler, so we start there. Recall that discrete opfibrations correspond to copresheaves via the elements construction [Rie16, §2.4]. A simple result says that the elements construction preserves cartesianness.
Lemma B.3 (Products in elements construction). Let be a cartesian set-valued functor on a cartesian category . Then the category of elements, , is cartesian, and its canonical projection, the discrete opfibration , both preserves and reflects finite products.
Proof. The product of objects in is given, in its first component, by the product in , and, in its second component, by pairing:
Product projections in are simply the product projections in . The canonical projection clearly preserves finite products, and it also reflects them since a tuple is uniquely determined by its components (or, apply [Pat+23, Lemma 6.8]).
Since the comprehensive factorization of a functor involves a left Kan extension, we ask how left Kan extensions interact with finite products. The crucial concept in answering this question is siftedness [GU71]—or rather its dual, cosiftedness, characterized by the following definition/theorem.
Definition B.4 (Cosiftedness). A small category J is cosifted if any of the following equivalent conditions holds:
(i) in Set, colimits of shape J^{op} commute with finite products;
(ii) J is nonempty and the diagonal functor is initial;
(iii) J is nonempty and for any objects , the category of spans in J with feet and is nonempty and connected.
A cosifted colimit is a colimit whose shape is a cosifted category.
Proof of equivalence. The (dual of the) equivalence between (i) and (ii) originates in [GU71]; see also [ARV11, Theorem 2.15]. The equivalence between (ii) and (iii) follows from the defining characterization of an initial functor (Definition A.1).
Lemma B.5. A small category with finite products is cosifted.
Proof. Suppose J has finite products. Then J is nonempty, having a terminal object, and for any objects , the category has a terminal object—the product cone , by the universal property of the product—so is in particular nonempty and connected.
The surprising fact is that the left Kan extension of a cartesian set-valued functor along any functor (not necessarily cartesian) is again cartesian. This result seems to first appear in the literature as [BD77, Theorem 1.5 and Example 3.1], in the more general setting of enriched categories. We give a direct and elementary proof.
Theorem B.6 (Product-preserving Kan extensions). Let be a small cartesian category, and let be a cartesian set-valued functor. For any functor into a cartesian category , the left Kan extension is cartesian.
Proof. Decomposing as a canonical colimit of representables, the left Kan extension of has the formula:
Because the representables preserve finite products, will preserve finite products when is cosifted. But that is the case by Lemmas B.3 and B.5.
The following corollary also appears, in dual and slightly weaker form, as [Par73, Proposition 6.5].
Corollary B.7. Let be a diagram whose shape and target are both cartesian categories. Then the image copresheaf of is cartesian.
Proof. Since , the terminal copresheaf on J is cartesian. Thus, by Theorem B.6, so is .
We now have all the ingredients needed to prove that the comprehensive factorization on Cat restricts to Cart, the category of small cartesian categories and cartesian functors.
Proof of Theorem B.2. Let be a functor out of a small category , and adopt the notation of Construction A.11. If and are cartesian, then so is by Corollary B.7; hence, so are and by Lemma B.3. Moreover, if is itself cartesian, then so is , since the composite preserves finite products and, by Lemma B.3, reflects them.
Thus, when a functor belongs to Cart, the factorization in Cat restricts to Cart. Any morphism between factorizations also preserves finite products, since cartesian discrete opfibrations reflect them [Pat+23, Lemma 6.8]. This proves the first part of the theorem, using the characterization of a factorization system in terms of unique factorization up to unique isomorphism [Joy20, Theorem 3.7].
Now suppose that belongs to , the category of small categories with chosen finite products. There is a unique choice of finite products in the elements construction making the projection strictly preserve products. Since also strictly preserves products, must do so too, as its product comparisons lie over identities in , hence must be identities by the discrete opfibration property. Similarly, any morphism between such factorizations must strictly preserve products. Thus the orthogonal factorization system lifts through the forgetful functor .
B.3 Limits of cartesian diagrams
In Section 4, we take limits of diagrams whose shapes themselves have finite products, a not-too-common situation in category theory. This subsection shows that such limits are innocuous provided the diagram itself preserves finite products.
We say that a diagram is cartesian if its shape and target have finite products and if it, as a functor, preserves finite products. A first observation about cartesian diagrams is:
Lemma B.8 (Cones over a cartesian diagram). A cone over a cartesian diagram is uniquely determined at a product of objects by its legs at each factor.
Proof. Let be a cone over a cartesian diagram . For any finite list of objects in , pairing the naturality triangles at each projection gives a commuting triangle
in which the comparison map is an isomorphism since preserves finite products.
The next two propositions show that cartesian diagrams freely generated by two different means have the expected cones, hence the expected limits.
Proposition B.9 (Cones over a free cartesian diagram). Let be a free cartesian diagram, with shape freely generated by a multigraph . Then any family of morphisms in indexed by vertices of , making the square commute
for every multiedge in , extends uniquely to a cone over .
Moreover, this bijective correspondence with cones over is natural in the apex .
For the next proposition, let denote the free completion of a category under finite products, given explicitly by the contravariant family construction [e.g., ARV11, Remark 1.15].
Proposition B.10 (Limit indexed by a free product completion). Let be a diagram in a cartesian category , and let be its essentially unique extension to a cartesian diagram:
Then cones over and are in bijection, naturally in the apex; in particular, , each limit existing if the other does.
Both propositions can be proved by inspecting explicit constructions of the free completions. We take a more abstract approach that uses their universal properties instead.
To do so, we must change our perspective on cones, viewing them not as natural transformations but as functors solving a lifting problem. Fix a diagram . For any object in , let be the codomain functor out of the coslice category under . Then cones with apex over correspond exactly with lifts of through the codomain functor:
This perspective is taken consistently in [Pat+23, esp. §2].
As preparation, we restate and reprove the first lemma [cf. Pat+23, Lemma 6.7].
Lemma B.11 (Lemma B.8, for lifts). When is a cartesian diagram, the lifting problem (B.1) is the same whether it is taken in the category or .
Proof. Let be an object of . Since is cartesian, so is the representable ; hence, by Lemma B.3, the canonical projection —which is simply —reflects finite products. Since preserves finite products, it follows that any lift of through (in the category ) also preserves finite products.
To see the idea of the proof of Proposition B.9, imagine there were a free-forgetful adjunction between multigraphs and cartesian categories. Let the cartesian diagram and the multigraph morphism correspond under the adjunction. Then naturality of the hom-set bijections [Rie16, Lemma 4.1.3] implies that lifts of and lifts of correspond bijectively:
But lifts of correspond to cones over (noting that lifts in Cat and Cart are the same, by Lemma B.11), and lifts of correspond to the -indexed families in the proposition statement. So the first part of Proposition B.9 would be proved.
The problem with this argument is that there is not, in fact, a (1-categorical) adjunction between multigraphs and cartesian categories. The actual proof uses the 2-categorical universal property discovered by Walters [Wal89], interesting in its own right.
Proof of Proposition B.9. To state a 2-categorical universal property for the free cartesian category, Walters [Wal89] constructs the 2-category of multigraphs internal to and a forgetful 2-function . Viewing an ordinary multigraph as a discrete object in , there is a multigraph morphism , pre-composition with which induces an equivalence of hom-categories:
This is the better part of a biadjunction. In any case, for each object c of C, we obtain a commuting square
in which the top and bottom functors are equivalences.
Since cod is a discrete opfibration, post-composing with it gives a functor that is itself a discrete opfibration, for any category J. Moreover, since cod is cartesian, the post-composition functor is also a discrete opfibration, for any cartesian category J. These two facts are special cases of [Pat+23, Theorems 5.2 and 6.6], respectively. Post-composition with can also be shown to be a discrete opfibration.
So, in the commuting square, the left and right functors are discrete opfibrations and the top and bottom functors are equivalences. In this situation, the top functor restricts to a bijection on fibers; here, that means that if a cartesian diagram and a multigraph morphism correspond under the bottom equivalence, then the top equivalence puts their lifts, hence also their cones, in bijection. Moreover, the bijection is natural with respect to changes of total space given by pre-composing with a morphism in .
Proof of Proposition B.10. The proof is similar to that of Proposition B.9.
Let be the free-forgetful biadjunction between categories and categories with finite products. For any category and cartesian category , pre-composition with the unit of the biadjunction, , gives an equivalence of hom-categories
Then, for each object c of C, there is a commuting square of functors
in which the top and bottom are equivalences and the left and right are discrete opfibrations [Pat+23, Theorems 5.2 and 6.6]. The rest of the proof follows the previous one.