Decorated cospans via the Grothendieck construction

Published

May 30, 2022

This post is cross-posted at the Topos Institute blog.

Decorated cospans turn closed systems into open ones, which can be composed along their boundaries to form larger systems (). 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 ().

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 (April 3, 2023): I have incorporated the content of this blog post into a new paper ().

Review of decorated cospans

Given a category A with finite colimits and a lax monoidal functor F:(A,+)(Set,×), the category of F-decorated cospans has:

  • objects, the objects of A;
  • morphisms ab, isomorphism classes of a cospan amb in A together with an element sF(m).

For example, to obtain the category of isomorphism classes of open graphs, made open along vertices, we take the lax monoidal functor F:(FinSet,+)(Set,×) that sends a finite set V to the set F(V) of graphs with vertex set V. Its laxators

F(U)×F(V)F(U+V),U,VFinSet

send a pair of graphs G and H having vertex sets U and V to the coproduct graph G+H with vertex set U+V.

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 A with finite colimits and a lax monoidal functor F:(A,+)(Cat,×), the double category of F-decorated cospans has:

  • objects, the objects of A;
  • arrows, the morphisms of A;
  • proarrows ab, a cospan amb in A together with an object sF(m);
  • cells (amb,s)(cnd,t), a map of cospans in A, which is a commuatative diagram of the form below, together with a morphism ν:F(h)(s)t in F(n).

To get a double category of open graphs, we take the lax monoidal functor F:(FinSet,+)(Cat,×) that sends a finite set V to the category F(V) of graphs with vertex set V, whose morphisms are vertex-preserving graph homomorphisms. A cell—or rather the apex part of a cell—from a graph G with vertex set U to a graph H with vertex set V then consists of a function h:UV together with a vertex-preserving graph homomorphism ν:F(h)(G)H. Together, the two functions h and ν are equivalent to an arbitrary graph homomorphism GH, namely the one with vertex map h and edge map νE.

A modular reconstruction of decorated cospans

Last time, we introduced a Grothendieck construction for double categories, whose input data is a lax double functor DSpan(Cat). To decorate cospans, we apply the construction on the (pseudo) double category D=Csp(A) of cospans in a finitely cocomplete category A. In other words, the input data for generalized decorated cospans is a lax double functor Csp(A)Span(Cat). 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 (A,+)(Cat,×). To do that, we’ll use three simple mappings.

Mapping #1. A monoidal category can be seen as a double category D whose underlying 1-category D0 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 (C,), there is a double category M(C,) with M(C,)0=1, the terminal category, and M(C,)1=C. 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

M:MonCatlaxDblCatlax.

Mapping #2. For any category A with finite colimits, the apex double functor is the lax double functor

Apex:Csp(A)M(A,+)

with Apex0:A!1 the unique map and Apex1:=apex:ACspA the apex functor, where we write Csp:={} for the walking cospan. For composable cospans m:=(axb) and n:=(byc) in A, the laxators

Apex1(m)+Apex1(n)=x+y[ιx,ιy]x+by=Apex1(mn),

as well as unitors 0!a for aA, are given by the universal properties of the colimits.

Mapping #3. For any category C with finite limits, the codiscrete span functor is the double functor

coDisc:M(C,×)Span(C)

with coDisc0:1C picking out the terminal object 1 of C and coDisc1:CCSpan sending each object cC to the codiscrete span 1!c!1. 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 (F,Φ,ϕ):(A,+)(Cat,×), gives rise to data for a Grothendieck construction on the double category of cospans in A. We apply the functor M:MonCatlaxDblCatlax, then precompose with Apex and postcompose with coDisc:

F~:Csp(A)ApexM(A,+)M(F)M(Cat,×)coDiscSpan(Cat).

The resulting lax double functor F~ sends each object aA to the trivial category 1 and sends a cospan amb in A to the span of categories 1!F(m)!1. For composable cospans m=(axb) and n=(byc), the laxator

F~(m)F~(n)F~(mn)

is the image under coDisc of the composite

F(x)×F(y)Φx,yF(x+y)F[ιx,ιy]F(x+by)

in Cat. The unitor of F~ at the object aA is the image under coDisc of

1ϕF(0)F(!)F(a).

The last two formulas are precisely the ones used to compose decorated cospans (; ).

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 Apex:Csp(A)M(A,+) 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.

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 DSpan(Cat), as defined in the previous blog post, in the particular case that D 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 A be a category with finite colimits and let (F~,Γ~,γ~):Csp(A)Span(Cat) be a lax double functor. Define the two functors

F0:=F~0:ACat,F1:=apexF~1:ACspCat

and the two natural transformations

having components λm:=legL(F~1(m)) and ρm:=legR(F~1(m)), where legL,legR:CatSpanCat extract the left and right legs of a span. The components are well-defined because, since F~ is a double functor, ftL(F~1(m))=F~0(ftL(m)) and ftR(F~1(m))=F~0(ftR(m)).

The double category of F-decorated cospans is the Grothendieck construction F, which has underlying categories (F)0=F0 and (F)1=F1. Explicitly, it has:

  • objects, pairs (a,x) with an object aA and a decorating object xF0(a);
  • arrows (a,x)(b,y), pairs (f,ϕ) with a morphism f:ab in A and a decoration morphism ϕ:F0f(x)y in F0(b);
  • proarrows, pairs (m,s) with a cospan m=(aqb) in A and a decorating object sF1(m);
  • cells (m,s)(n,t), pairs (α,ν) with a map α:mn of cospans in A and a decoration morphism ν:F1α(s)t in F1(n).

Sources and targets in F are defined by the functors (ftL,λ) and (ftR,ρ), which respectively send

  • proarrows (m,s), with m=(aqb), to (a,λm(s)) and (b,ρm(s));
  • cells (α,ν):(m,s)(n,t), with α=(f,h,g), to (f,λn(ν)) and (g,ρn(ν)).

A generic cell in the double category of F-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 F. Given composable cospans m=(aqb) and n=(brc), define Γm,n to be the functor

(F1×F0F1)(m,n)=apex(F~1(m)F~1(n))apex(Γ~m,n)apex(F~1(mn))=F1(mn),

whose domain is the pullback in Cat of F1(m)ρmF0(b)λnF1(n). Then composition of decorated cospans is the operation:

(a,x)(m,s)(b,y)(n,t)(c,z)(mn, Γm,n(s,t)).

Furthermore, the external composite of cells (m,s)(α,ν)(n,t) and (o,u)(β,π)(p,v) that satisfy (ftR(α),ρn(ν))=(ftL(β),λp(π)) is (αβ, Γn,p(ν,π)). External identities are defined similarly using the functors γa:=apex(γ~a) for aA.

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 Apex:Csp(A)M(A,+) and the second is discarded by the double functor coDisc:M(Cat,×)Span(Cat).

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.

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 (). A statistical theory consists of a small Markov category with some extra structure, specifying the constituents of a statistical model, plus a distinguished morphism p:θx, 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 i:AX and o:BX is the category (i/o) having

  • objects, a pair of objects aA and bB plus a morphism f:i(a)o(b) in X;
  • morphisms (a,b,f)(a,b,f), a pair of morphisms h:aa in A and k:bb in B inducing a commutative square in X.

In addition, the comma category (i/o) has evident projection functors πA:(i/o)A and πB:(i/o)B.

The comma construction upgrades to a lax double functor, the comma double functor

Comma:Csp(Cat)Span(Cat),

where Comma0:CatCat is the identity functor and Comma1:CatCspCatSpan sends a cospan (AiXoB) to the span (AπA(i/o)πBB) and sends a map of cospans

to the map of spans

where the functor comma(F):(i/o)(i/o) is defined by:

(a,b,i(a)fo(b))(H(a),H(b),i(H(a))=F(i(a))F(f)F(o(b))=o(H(b)))(h,k)(H(h),K(k)).

For composable cospans m=(AiXoB) and n=(BjYpC), the laxator is the feet-preserving map of spans whose apex map is the functor

(i/o)×B(j/p)(ιXi/ιYp)(i(a)fi(b),j(b)gp(c))(ιXi(a)ιXfιXo(b)=ιYj(b)ιYgιYp(c))((h,k),(k,))(h,).

Here ιX:XX+BY and ιY:YX+BY are the coprojections associated with the pushout of categories. Finally, for each category A, the unitor is the feet-preserving map of spans whose apex map is the functor A(idA/idA)A that sends aA to (a,a,ida) and h:aa to (h,h).

The Grothendieck construction Comma is a double category that has:

  • objects, a small category A together with an object aA;
  • arrows (A,a)(A,a), a functor H:AA together with a morphism h:H(a)a in A;
  • proarrows with source (A,a) and target (B,b), a cospan of categories m=(AiXoB) together with a morphism f:i(a)o(b) in X;
  • cells (m,f)(m,f) with source (H,h) and target (K,k), a map of cospans (H,F,K) 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 ().

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 (). In this approach, a dangling-edge graph (called by Kock simply a “graph”) is a diagram of finite sets

where the functions s and t are injective. The elements of N are the nodes or vertices of the graph and the elements of A are the arcs or edges. An edge in the image of s has a source node, which is given by p; otherwise, the edge is incoming. Similarly, an edge in the image of t has a target node, which is given by q; 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 DGraph.

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 V to the category of graphs with vertex set V. Unfortunately, the injectivity condition in dangling-edge graphs causes complications.

Let Arc:FinSetCat be the functor that sends a finite set A to the category of dangling-edge graphs with edge set A. The morphisms in this category are edge-preserving morphisms of dangling-edge graphs, whose I and O components are necessarily injective. For any function f:AA, the functor Arc(f) is defined in terms of the following commutative diagram.

This requires some explanation. Given a dangling-edge graph GArc(A), we construct another dangling-edge graph Arc(f)(G)Arc(A) by taking the epi-mono factorizations of fs and ft, which define I0 and O0 respectively, and then taking N0 to be the colimit of the diagram of finite sets:

I0IpNqOO0.

In effect, we take the edges aA to be incoming or outgoing whenever possible—whenever a is not in the image of fs or ft—and then we quotient the nodes as freely as possible to obtain a morphism GArc(f)(G) in DGraph. The functor Arc(f) also acts on morphisms in Arc(A), the description of which we omit. The functorality of Arc:FinSetCat follows from the uniqueness of epi-mono factorizations and colimits. Actually, since this uniqueness holds only up to unique isomorphism, Arc is a pseudofunctor, but we aren’t going to worry about that.

The functor Arc:FinSetCat has the desirable property that any morphism ϕ:GG of dangling-edge graphs with component f:=ϕA:AA factorizes as

GArc(f)(G)G,

where the latter morphism belongs to Arc(A):

To see this, note that if II0I is the epi-mono factorization of ϕI:II, then post-composing with s gives the epi-mono factorization of sϕI=fs, and similarly for the O component. The function is N0N is then given by the universal property of the colimit N0.

Another complication is that to compose dangling-edge graphs, we must restrict to cospans with monic legs. Given a finitely cocomplete category A with monomorphisms stable under pushout, such as a topos, let Cspm(A) be the double of category of cospans in A whose legs are monic. Its cells are the usual maps of cospans, with no assumption of monicness. Thus, the double category has Cspm(A)0=A and Cspm(A)1=ACspm, where Cspm:={} is the walking cospan with monic legs (formally, a finite limits theory).

With these preliminaries aside, we define a lax double functor

F:Cspm(FinSet)M(Cat,×)

with F0:FinSet!1 the unique map and F1:FinSetCspmCat the following functor. On objects, F1 sends a cospan m=(AiiAoAo) to the category of dangling-edge graphs with edge set A, such that the legs i and o inject into the sets of incoming and outgoing edges, respectively. Importantly, this condition refers to the whole cospan, not just its apex! The category F1(m) is a full subcategory of Arc(A). On morphisms, F1 sends a map of cospans α=(fi,f,fo):mm to the functor F1(α):F1(m)F1(m) given by (co)restriction of Arc(f):Arc(A)Arc(A).

Finally, we define the laxators and unitors of the lax double functor F. Write L:FinSetDGraph for the functor that sends a finite set A to the shrub with edge set A. For composable cospans m=(AiAS) and n=(SBBo) in FinSetCspm, the laxator

Γm,n:F1(m)×F1(n)F1(mn),(G,H)G+L(S)H

takes the pushout in DGraph along the shrub L(S). Conveniently, Kock has already shown that such pushouts in DGraph exist and are computed pointwise (, Proposition 1.5.2). Thus, the dangling-edge graph Γm,n(G,H) has edge set A+SB and other sets given by coproduct. Similarly, the action of Γm,n on cells is by coproduct. For each finite set S, the unitor

γS:1F1(S),L(S)

picks out the corresponding shrub.

The double category of dangling-edge graphs is the Grothendieck construction of the lax double functor Cspm(FinSet)FM(Cat,×)coDiscSpan(Cat). 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 (). 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.

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 (Csp(A),+), the monoidal double category of cospans. I would expect that a lax monoidal functor F:(A,+)(Cat,×) gives rise to a lax monoidal double functor F~:(Csp(A),+)(Span(Cat),×), which would extend the connection to decorated cospans explained here.

References

Baez, John C., Kenny Courser, and Christina Vasilakopoulou. 2022. “Structured Versus Decorated Cospans.” Compositionality 4 (3). DOI:10.32408/compositionality-4-3. arXiv:2101.09363.
Fong, Brendan. 2015. “Decorated Cospans.” Theory and Applications of Categories 30 (33): 1096–1120. http://www.tac.mta.ca/tac/volumes/30/33/30-33abs.html.
Kock, Joachim. 2016. “Graphs, Hypergraphs, and Properads.” Collectanea Mathematica 67 (2): 155–90. DOI:10.1007/s13348-015-0160-0. arXiv:1407.3744.
———. 2022. “Whole-Grain Petri Nets and Processes.” Journal of the ACM 70 (1): 1–58. DOI:10.1145/3559103. arXiv:2005.05108.
Patterson, Evan. 2020. “The Algebra and Machine Representation of Statistical Models.” PhD thesis, Stanford University. arXiv:2006.08945.
———. 2023. “Structured and Decorated Cospans from the Viewpoint of Double Category Theory.” In Applied Category Theory 2023. arXiv:2304.00447.