definition example theorem proof
A cospan in a Category from to is a Diagram — a Cocone under the discrete diagram (DaoFP: a Natural Transformation for ). The universal cospan is the Coproduct.
Sources: Kittenlab Lecture 15 (“Cospans”: , identity, equivalence, well-definedness); 7 Sketches §6.2.5 (Definition 6.22, Examples 6.23–6.24, Exercises 6.25–6.27: as a Symmetric Monoidal Category and Hypergraph Category), §6.4 (decorated cospans); DaoFP §9.4 (“Cospans as natural transformations”, “Functoriality of cospans”).
The cospan category (Kittenlab Lecture 15)
Let have pushouts. has objects the objects of and morphisms the cospans; the composite of and is , by pushout. The identity on is .
The subtlety. Composing with the identity gives , which is only isomorphic to — “showing two objects are equal is almost always the wrong thing to do, but here objects serve as morphisms, which must be equal on the nose”. Two fixes: pass to a bicategory (morphisms between cospans), or — Kittenlab’s route — define morphisms as equivalence classes of cospans, where and are equivalent if there is an Isomorphism commuting with the legs.
Proposition (well-definedness). Given equivalent cospans (via ) and (via ), there is an isomorphism compatible with all legs. Proof. The two pushout spans are functors from ; the given isomorphisms and assemble into a Natural Isomorphism (naturality is exactly the commuting of the legs). Then , and representing objects of isomorphic functors are isomorphic (“that’s Yoneda, baby!”). Tracing the construction shows the legs commute. “Our first big serious proof in category theory: when in doubt, go back to definitions.”
Uses
- Undirected wiring diagrams: a cospan in drawn as boxes with ports joined through junctions (two styles of picture, Kittenlab Fig. “uwd”). Open graphs: a graph with input/output maps — a cospan of finite sets with a decoration; composing them is gluing along shared vertices.
- is a Hypergraph Category (7 Sketches Example 6.61), the prototype: every object carries a Frobenius Monoid given by the cospans etc.; decorated cospans and structured cospans add data (circuit components) on the apex. The Operad of cospans “designs” wiring diagrams (§6.5).
- DaoFP: the set of cospans over is functorial in , and defines the sum. Dual: Span.
Docs: FinSets · Limits & colimits · Free diagrams — Kittenlab Lecture 15
using Catlab
# cospans of finite sets; composition by pushout
c1 = Cospan(FinFunction([1, 2], 3), FinFunction([2, 3], 3)) # X=2 → A=3 ← Y=2
c2 = Cospan(FinFunction([1, 1], 2), FinFunction([2], 2)) # Y=2 → B=2 ← Z=1
po = pushout(right(c1), left(c2)) # glue A and B along Y
c12 = Cospan(compose(left(c1), legs(po)[1]), compose(right(c2), legs(po)[2])) # X → A +_Y B ← Z
apex(c12) # FinSet(3)
id_cospan(X) = Cospan(id(X), id(X))
# Catlab computes one specific pushout; the result is well defined up to isomorphism#check CategoryTheory.Limits.cospan -- cospan f g : WalkingCospan ⥤ C
-- Mathlib has spans/cospans as diagrams; the (bi)category of cospans is not built indata Cospan a x y = Cospan (x -> a) (y -> a) -- with apex a
-- composition needs pushouts of the apices (see Pushout / Colimit); identity is Cospan id id
idCospan :: Cospan x x x
idCospan = Cospan id id