# The Unapologetic Mathematician

## Spans and Cospans

I was busy all yesterday with my talk at George Washington, so today I’ll make up for it by explaining one of the main tools that went into the talk. Coincidentally, it’s one of my favorite examples of a weak 2-category.

We start by considering a category $\mathcal{C}$ with pullbacks. A span in $\mathcal{C}$ is a diagram of the form $A_1\leftarrow B\rightarrow A_2$. We think of it as going from $A_1$ to $A_2$. It turns out that we can consider these to be the morphisms in a weak 2-category $\mathbf{Span}(\mathcal{C})$, whose objects are just the objects of $\mathcal{C}$.

Now since this is supposed to be a 2-category we need 2-morphisms to go between spans. Given spans $A_1\leftarrow B\rightarrow A_2$ and $A_1\leftarrow B'\rightarrow A_2$ a 2-morphism from the first to the second will be an arrow from $B$ to $B'$ making the triangles on the sides of the following diagram commute: We compose 2-morphisms in the obvious way, stacking these diamond diagrams on top of each other and composing the arrows down the middle.

The composition for 1-morphisms is where it gets interesting. If we have spans $A_1\leftarrow B_1\rightarrow A_2$ and $A_2\leftarrow B_2\rightarrow A_3$ we compose them by overlapping them at $A_2$ and pulling back the square in the middle, as in the following diagram: where the middle square is a pullback. Then the outer arrows form a span $A_1\leftarrow C\rightarrow A_3$.

Notice that this composition is not in general associative. If we have three spans $A_1\leftarrow B_1\rightarrow A_2$, $A_2\leftarrow B_2\rightarrow A_3$, and $A_3\leftarrow B_3\rightarrow A_4$, we could pull back on the left first, then on the right, or the other way around:  But the object $D$ at the top of each diagram is a limit for the $A_1\leftarrow B_1\rightarrow A_2\leftarrow B_2\rightarrow A_3\leftarrow B_3\rightarrow A_4$ along the bottom of the diagram. And thus the two of them must be isomorphic, and the isomorphism must commute with all the arrows from $D$ to an object along the bottom. In particular, it commutes with the arrows from $D$ to $A_1$ and to $A_4$, and thus gives a canonical “associator” 2-morphism. I’ll leave the straightforward-but-tedious verification of the pentagon identity as an exercise.

What is the identity span? It’s just $A\leftarrow A\rightarrow A$, where the arrows are the identity arrows on $A$. When we pull back anything along the identity arrow on $A$, we get the same arrow again. Thus the 2-morphisms we need for the left and right unit are just the identities, and so the triangle identity is trivially true. Thus we have constructed a 2-category $\mathbf{Span}(\mathcal{C})$ from any category with pullbacks.

The concept of a cospan is similar, but the arrows (predictably) run the other way. A cospan in a category $\mathcal{C}$ with pushouts (instead of pullbacks) is a diagram of the form $A_1\rightarrow B\leftarrow A_2$. Everything else goes the same way — 2-morphisms are arrows in the middle making the side triangles commute, and composition of cospans goes by pushing out the obvious square.

Unusual as it is for this weblog, I’d like to make one historical note. Spans and cospans were introduced by Bénabou in the early 1960s. This was first pointed out to me by Eugenia Cheng (of The Catsters) and John Baez (of The n-Category Café) at a conference at Union College two years ago. Until that point I’d been calling cospans “ $\Lambda$-diagrams” because I’d invented them out of whole cloth to solve a problem that I’ll eventually get around to explaining. The name seemed appropriate because I tend to draw them (as I have in the above diagrams) as wedges with the arrows on the sides pointing up into the center, sort of like a capital lambda. They’ve shown up in a number of contexts, but as far as I can tell I’m the first (and so far only) to use them in knot theory like I do. However, Jeff Morton has noted that cobordisms are a sort of cospan, and my use of tangles is analogous to that.