โ† back to index

Limits and Colimits

Bartosz Milewski ยท 2015 ยท Category Theory for Programmers, Ch. 11

Prereqs: ๐Ÿž Ch5 (Products and Coproducts), ๐Ÿž Ch10 (Natural Transformations). 10 min.

A limit is a universal cone over a diagram. Products, terminal objects, and equalizers are all limits. Reverse the arrows and you get colimits: coproducts, initial objects, and coequalizers. One construction, many shapes.

Diagrams and cones

A diagram is a functor D : I โ†’ C from an index category I (the "shape") into a target category C. A cone over that diagram is an apex object c together with morphisms from c to every object in the diagram, such that every triangle commutes. Think of it as a tent pole (c) with ropes (morphisms) to each stake (diagram object), where the ropes respect the connections between stakes.

c d₁ d₂ π₁ π₂ f f ∘ π₁ = π₂
Scheme

Products are limits over discrete diagrams

When the index category has two objects and no morphisms between them (the discrete category 2), a cone is an apex with two projections. The limit is the universal cone: the one through which every other cone factors uniquely. That's the product. The terminal object is the limit over the empty diagram (zero objects, zero morphisms).

c′ c m ! d₁ d₂ π₁ π₂ f every cone factors uniquely through c
Scheme

Equalizers โ€” where two morphisms agree

When the index category has two objects with two parallel morphisms between them (a โ‡‰ b), the limit is an equalizer. It picks out the subobject of a where the two morphisms agree: the set of all x such that f(x) = g(x). The equalizer comes with an embedding eq : E โ†’ a such that f โˆ˜ eq = g โˆ˜ eq.

Scheme

Pullbacks โ€” matching over a shared target

A pullback is the limit over a cospan: two morphisms f : a โ†’ b and g : c โ†’ b pointing at the same object. The pullback is the set of pairs (x, y) from a and c that land on the same element in b: f(x) = g(y). It generalizes the product (a product is a pullback over the terminal object) and the equalizer (an equalizer is a pullback where a = c).

P A B C p₁ p₂ f g f ∘ p₁ = g ∘ p₂
Scheme

Colimits โ€” reverse the arrows

A colimit is a limit in the opposite category. Reverse all the arrows in a cone and you get a cocone: morphisms going from the diagram objects to the apex. The colimit is the universal cocone. Coproducts are colimits over discrete diagrams. Initial objects are colimits over the empty diagram. Pushouts are dual to pullbacks. The coequalizer is dual to the equalizer: it identifies elements that two morphisms map differently.

Scheme

The hom-set definition of limits

There's a cleaner way to state the universal property. A limit Lim D exists when there's a natural isomorphism: C(c, Lim D) โ‰… Nat(ฮ”c, D). The left side is morphisms from c to the limit. The right side is natural transformations from the constant functor at c to the diagram D, which are exactly cones with apex c. This says: morphisms into the limit correspond one-to-one with cones.

Scheme

Notation reference

Blog / Haskell Scheme Meaning
D : I โ†’ C(list of objects and morphisms)Diagram (functor from index category)
ฮ”c(lambda (_) c)Constant functor at c
Cone (apex, ฯ€แตข)(make-cone apex p1 p2)Cone over a diagram
Lim D(product, equalizer, ...)Limit (universal cone)
Equalizer(equalizer f g domain)Limit where f(x) = g(x)
Pullback(pullback f g dom-a dom-c)Limit over a cospan
Colim D(coproduct, coequalizer, ...)Colimit (universal cocone)
C(c, Lim D) โ‰… Nat(ฮ”c, D)(morphism->cone, cone->morphism)Hom-set characterization
Neighbors

Milewski chapters

Paper pages that use limits

Foundations (Wikipedia)

Translation notes

The blog post introduces limits via the constant functor ฮ” and natural transformations, building up from products and terminal objects to equalizers and pullbacks. This page follows the same progression but makes everything executable. The equalizer is computed by filtering a finite domain rather than defining a subobject categorically. The pullback is computed by brute-force enumeration of pairs, which matches the set-theoretic definition but hides the universal property. The coequalizer uses explicit equivalence-class merging, which is the computational content of a quotient. In the blog post, Milewski also covers continuity (functors that preserve limits), which requires representable functors and is deferred to a later chapter.

Ready for the real thing? Read the blog post. Start with the cone construction, then see how the hom-set definition C(c, Lim D) โ‰… Nat(ฮ”c, D) unifies everything.