Decorated cospans via the Grothendieck construction
Building on the double Grothendieck construction introduced last time, we explain how decorated cospans are instance of the Grothendieck construction. This perspective suggests a natural generalization of decorated cospans, which we illustrate through several examples.
Decorated cospans turn closed systems into open ones, which can be composed along their boundaries to form larger systems (Fong 2015). Continuous dynamical systems and a variety of combinatorial systems, such as graphs, Petri nets, and stock and flow diagrams, have all been made into open systems using this method. In addition, decorated cospans are thought to be more general than their simpler cousin, structured cospans (Baez, Courser, and Vasilakopoulou 2022).
Despite this versatility, decorated cospans do not encompass all categories with morphisms that could reasonably be called “cospans with decorations.” The standard example of decorated cospans are open graphs, made open by exposing vertices via a cospan of vertex sets. Yet the other kind of open graphs—those allowing “dangling edges,” where the incoming edges define the domain and the outgoing edges the codomain—are not decorated cospans, even though they can also be described as cospans, now of edge sets, plus some extra data. We know that because decorated cospan categories are “undirected” (more accurately, they are hypergraph categories), whereas the category of graphs with dangling edges has a definite directionality. In this post, we’ll explain how to generalize decorated cospans to include this and other interesting examples.
To do that, we’ll use the Grothendieck construction for double categories introduced in our previous blog post. It would be helpful to read that post before this one, but it’s not strictly necessary since we’ll review the specific case of the construction that we need. We’ll also start with a brief review of decorated cospans. For much more about decorated cospans, see the papers cited above or the several blog posts written over the years by John Baez at the n-Category Cafe.
Update (03 April 2023): I have incorporated the content of this blog post into a new paper (Patterson 2023).
1 Review of decorated cospans
Given a category with finite colimits and a lax monoidal functor , the category of -decorated cospans has:
- objects, the objects of ;
- morphisms , isomorphism classes of a cospan in together with an element .
For example, to obtain the category of isomorphism classes of open graphs, made open along vertices, we take the lax monoidal functor that sends a finite set to the set of graphs with vertex set . Its laxators send a pair of graphs and having vertex sets and to the coproduct graph with vertex set .
The original version of decorated cospans forgets about any morphisms which may have already existed between the original (closed) systems. In the case of open graphs, these morphisms are graph homomorphisms. Their absence is often a problem! To recover them, we need a more refined version of decorated cospans, furnishing not just a category but a double category.
Given a category with finite colimits and a lax monoidal functor , the double category of -decorated cospans has:
- objects, the objects of ;
- arrows, the morphisms of ;
- proarrows , a cospan in together with an object ;
- cells , a map of cospans in , which is a commuatative diagram of the form below, together with a morphism in .
To get a double category of open graphs, we take the lax monoidal functor that sends a finite set to the category of graphs with vertex set , whose morphisms are vertex-preserving graph homomorphisms. A cell—or rather the apex part of a cell—from a graph with vertex set to a graph with vertex set then consists of a function together with a vertex-preserving graph homomorphism . Together, the two functions and are equivalent to an arbitrary graph homomorphism , namely the one with vertex map and edge map .
2 A modular reconstruction of decorated cospans
Last time, we introduced a Grothendieck construction for double categories, whose input data is a lax double functor . To decorate cospans, we apply the construction on the (pseudo) double category of cospans in a finitely cocomplete category . In other words, the input data for generalized decorated cospans is a lax double functor . We will describe the Grothendieck construction of such a double functor in the next section. First, let’s see how this data generalizes the usual data for decorated cospans, a lax monoidal functor . To do that, we’ll use three simple mappings.
Mapping #1. A monoidal category can be seen as a double category whose underlying 1-category is trivial. This fact is a variation on the possibly more familar one that a monoidal category is a bicategory with one object. More precisely, for any monoidal category , there is a double category with , the terminal category, and . External composition and identities are given by the monoidal product and unit. A lax monoidal functor can also be viewed as a lax double functor, so altogether we obtain a functor
Mapping #2. For any category with finite colimits, the apex double functor is the lax double functor with the unique map and the apex functor, where we write for the walking cospan. For composable cospans and in , the laxators as well as unitors for , are given by the universal properties of the colimits.
Mapping #3. For any category with finite limits, the codiscrete span functor is the double functor with picking out the terminal object of and sending each object to the codiscrete span . This double functor is pseudo, and can be made strict by a suitable choice of limits.
It is now clear how the usual data for decorated cospans, a lax monoidal functor , gives rise to data for a Grothendieck construction on the double category of cospans in . We apply the functor , then precompose with and postcompose with : The resulting lax double functor sends each object to the trivial category and sends a cospan in to the span of categories . For composable cospans and , the laxator is the image under of the composite in . The unitor of at the object is the image under of The last two formulas are precisely the ones used to compose decorated cospans (Fong 2015), (Baez, Courser, and Vasilakopoulou 2022).
This observation clears up a puzzle that had always slightly bothered me about decorated cospans: where does the composition law come from? Why does it involve two operations, instead of just one? Well, the answer is that the construction itself involves a composite! Specifically, it is precomposition with the lax double functor that gives the distinctive composition law for decorated cospans. Using this modular reconstruction of decorated cospans, we can start with various kinds of lax monoidal or double functors, but ultimately reduce them all to data for a Grothendieck construction on the double category of cospans.
3 Double Grothendieck construction on cospans
We now apply the double Grothendieck construction to decorate double categories of cospans. Abstractly speaking, this is no more than taking the Grothendieck construction of a lax double functor , as defined in the previous blog post, in the particular case that is a double category of cospans. For the sake of clarity and concreteness, we are going to spell that out in some detail. Further technical details can found in the previous post.
Let be a category with finite colimits and let be a lax double functor. Define the two functors and the two natural transformations
having components and , where extract the left and right legs of a span. The components are well-defined because, since is a double functor, and .
The double category of -decorated cospans is the Grothendieck construction , which has underlying categories and . Explicitly, it has:
- objects, pairs with an object and a decorating object ;
- arrows , pairs with a morphism in and a decoration morphism in ;
- proarrows, pairs with a cospan in and a decorating object ;
- cells , pairs with a map of cospans in and a decoration morphism in .
Sources and targets in are defined by the functors and , which respectively send
- proarrows , with , to and ;
- cells , with , to and .
A generic cell in the double category of -decorated cospans can be depicted as:
The laxators and unitors of the lax double functor are used to define the external composition and identities in . Given composable cospans and , define to be the functor whose domain is the pullback in of . Then composition of decorated cospans is the operation: Furthermore, the external composite of cells and that satisfy is . External identities are defined similarly using the functors for .
In case it got lost in the morass of notation, let us summarize the two key ways that this version of decorated cospans generalizes the existing one. First, and most importantly, the decorations allowed for a given cospan can depend on the whole cospan, not just on its apex. Second, the feet of the cospans (the objects of the double category) get their own decorations, which can be extracted from the cospan decorations by the transformations and . For two decorated cospans to be composable, not only must the feet of the cospans be compatible, so must be the decorations on the feet. In the langauge of the previous section, the first increase in generality is discarded by the lax double functor and the second is discarded by the double functor .
4 Examples
Any existing example of decorated cospans gives an example of the new formalism via the reductions above. So let’s see a few examples that actually need the extra generality afforded by the double Grothendieck construction.
4.1 The comma construction
In synthetic treatments of statistics and machine learning, a natural thing to consider is a small category, regarded as a theory in the sense of categorical logic, that is equipped with a distinguished morphism. Especially motivating to me are the statistical theories studied in my PhD thesis (Patterson 2020). A statistical theory consists of a small Markov category with some extra structure, specifying the constituents of a statistical model, plus a distinguished morphism , specifying its sampling distribution. My thesis viewed theories as objects and focused on morphisms of theories, which formally capture relationships between different theories. But statistical theories can also be viewed as themselves a kind of morphism, which can be composed to create hierarchical or multi-level statistical models. So, from the perspective of double categories, statistical theories should be understood not merely as objects in a category but as proarrows in a double category. A structurally similar story applies to neural networks in machine learning, where the distinguished morphism now plays the role of the prediction function.
Using comma categories and decorated cospans, we construct a double category whose proarrows consist of a cospan of categories together with a morphism in the apex category, such that its domain and codomain are images of objects in the left and right feet. Actually, to address my motivating examples in statistics or machine learning, we would need to use comma objects in a 2-category of categories with extra structure. For simplicity, we’ll just work with bare categories here.
Recall that the comma category of two functors and is the category having
- objects, a pair of objects and plus a morphism in ;
- morphisms , a pair of morphisms in and in inducing a commutative square in .
In addition, the comma category has evident projection functors and .
The comma construction upgrades to a lax double functor, the comma double functor where is the identity functor and sends a cospan to the span and sends a map of cospans
to the map of spans
where the functor is defined by:
For composable cospans and , the laxator is the feet-preserving map of spans whose apex map is the functor Here and are the coprojections associated with the pushout of categories. Finally, for each category , the unitor is the feet-preserving map of spans whose apex map is the functor that sends to and to .
The Grothendieck construction is a double category that has:
- objects, a small category together with an object ;
- arrows , a functor together with a morphism in ;
- proarrows with source and target , a cospan of categories together with a morphism in ;
- cells with source and target , a map of cospans as depicted above such that the following square commutes:
External composition is given by pushout of categories, followed by composition in the quotient category.
When transplanted to the setting of Markov categories, such a cell is a refinement of what I have called a lax morphism of statistical theories (Patterson 2020, sec. 3.5).
4.2 Graphs with dangling edges
Directed graphs with dangling edges are an intuitively simple concept that is surprisingly resistant to clean mathematical treatment. One elegant approach, suited to the combinatorics of properads, has been developed by Joachim Kock (Kock 2016). In this approach, a dangling-edge graph (called by Kock simply a “graph”) is a diagram of finite sets
where the functions and are injective. The elements of are the nodes or vertices of the graph and the elements of are the arcs or edges. An edge in the image of has a source node, which is given by ; otherwise, the edge is incoming. Similarly, an edge in the image of has a target node, which is given by ; otherwise, the edge is outgoing. An edge that is incoming or outgoing (or both) is called dangling, and an edge that is incoming and outgoing is called passing. A dangling-edge graph that has no nodes, and which therefore has only passing edges, is called a shrub.
Dangling-edge graphs are evidently a subset of the objects of a copresheaf category. A morphism of dangling-edge graphs is a morphism in this copresheaf category, i.e., a commutative diagram:
The category of dangling-edge graphs is denoted .
We are going to construct a double category whose objects are finite sets, regarded as shrubs, and whose proarrows are dangling-edge graphs with specified incoming and outgoing edges. Composition of proarrows will glue outgoing edges of the first graph to incoming edges of the second graph. To do this construction, we’ll need the edge-analogue of the functor that sends a finite set to the category of graphs with vertex set . Unfortunately, the injectivity condition in dangling-edge graphs causes complications.
Let be the functor that sends a finite set to the category of dangling-edge graphs with edge set . The morphisms in this category are edge-preserving morphisms of dangling-edge graphs, whose and components are necessarily injective. For any function , the functor is defined in terms of the following commutative diagram.
This requires some explanation. Given a dangling-edge graph , we construct another dangling-edge graph by taking the epi-mono factorizations of and , which define and respectively, and then taking to be the colimit of the diagram of finite sets: In effect, we take the edges to be incoming or outgoing whenever possible—whenever is not in the image of or —and then we quotient the nodes as freely as possible to obtain a morphism in . The functor also acts on morphisms in , the description of which we omit. The functorality of follows from the uniqueness of epi-mono factorizations and colimits. Actually, since this uniqueness holds only up to unique isomorphism, is a pseudofunctor, but we aren’t going to worry about that.
The functor has the desirable property that any morphism of dangling-edge graphs with component factorizes as where the latter morphism belongs to :
To see this, note that if is the epi-mono factorization of , then post-composing with gives the epi-mono factorization of , and similarly for the component. The function is is then given by the universal property of the colimit .
Another complication is that to compose dangling-edge graphs, we must restrict to cospans with monic legs. Given a finitely cocomplete category with monomorphisms stable under pushout, such as a topos, let be the double of category of cospans in whose legs are monic. Its cells are the usual maps of cospans, with no assumption of monicness. Thus, the double category has and , where is the walking cospan with monic legs (formally, a finite limits theory).
With these preliminaries aside, we define a lax double functor with the unique map and the following functor. On objects, sends a cospan to the category of dangling-edge graphs with edge set , such that the legs and inject into the sets of incoming and outgoing edges, respectively. Importantly, this condition refers to the whole cospan, not just its apex! The category is a full subcategory of . On morphisms, sends a map of cospans to the functor given by (co)restriction of .
Finally, we define the laxators and unitors of the lax double functor . Write for the functor that sends a finite set to the shrub with edge set . For composable cospans and in , the laxator takes the pushout in along the shrub . Conveniently, Kock has already shown that such pushouts in exist and are computed pointwise (Kock 2016, Proposition 1.5.2). Thus, the dangling-edge graph has edge set and other sets given by coproduct. Similarly, the action of on cells is by coproduct. For each finite set , the unitor picks out the corresponding shrub.
The double category of dangling-edge graphs is the Grothendieck construction of the lax double functor . The proarrows are dangling-edge graphs with chosen incoming and outgoing edges, and the cells are arbitrary morphisms of dangling-edge graphs together with compatible maps of the incoming and outgoing edges.
If the injectivity constraint in dangling-edge graphs is dropped, one obtains a structure isomorphic to whole-grain Petri nets (Kock 2022). A double category of whole-grain Petri nets with chosen incoming and outgoing transitions can be constructed similarly to that of dangling-edge graphs. In fact, the construction is much simpler because we can work in a copresheaf category.
5 Discussion
As noted in the previous post, there is a logical gap between our double Grothendieck construction, which assumes the double category is strict, and its application to decorated cospans, using the pseudo double category of cospans. This discrepancy could be resolved by strictifying or, better, by appropriate use of 2-categorical ideas.
Both of our examples should be not only double categories but monoidal double categories, with monoidal product derived from the coproduct. The principled way to address this would be to derive the Grothendieck construction for monoidal double categories, as hinted at last time, and apply it to , the monoidal double category of cospans. I would expect that a lax monoidal functor gives rise to a lax monoidal double functor , which would extend the connection to decorated cospans explained here.