Advanced Mathematics

Category Theory: Functors, Natural Transformations, Monads, and Toposes

Category theory is the mathematics of mathematics. It provides a universal language for describing structures and the maps between them, unifying ideas across algebra, topology, logic, and computer science through the concepts of categories, functors, natural transformations, and adjunctions.

Contents

  1. 1. Categories: Objects, Morphisms, and Axioms
  2. 2. Functors: Covariant, Contravariant, and Endofunctors
  3. 3. Natural Transformations and Equivalence of Categories
  4. 4. Adjoint Functors: Unit, Counit, and Examples
  5. 5. Limits and Colimits
  6. 6. The Yoneda Lemma and Its Consequences
  7. 7. Monads: Kleisli and Eilenberg-Moore Categories
  8. 8. Abelian Categories and Homological Algebra
  9. 9. Toposes and Sheaves
  10. 10. Applications: Functional Programming, Topology, and Logic
  11. 11. Frequently Asked Questions

1. Categories: Objects, Morphisms, and Axioms

A category is the fundamental unit of category theory. It abstracts the idea of mathematical structures and the structure-preserving maps between them, reducing the essential content to objects, arrows, and a composition law. Category theory was invented by Samuel Eilenberg and Saunders Mac Lane in 1945, originally to give a precise meaning to the word 'natural' in mathematics.

The Definition of a Category

A category C consists of:

  • Objects:A collection ob(C) of objects (also called 0-cells or vertices).
  • Morphisms:For each pair of objects A, B, a set hom(A, B) of morphisms (arrows) from A to B. We write f: A to B to say f is a morphism in hom(A, B). The object A is the domain and B is the codomain.
  • Composition:For any three objects A, B, C and morphisms f: A to B and g: B to C, a composed morphism g after f: A to C.
  • Identities:For each object A, a distinguished identity morphism id sub A: A to A.

These data must satisfy two axioms:

  • Associativity:For all composable morphisms f, g, h, the equation h after (g after f) equals (h after g) after f holds.
  • Unit laws:For any f: A to B, we have f after id sub A equals f and id sub B after f equals f.

Core Examples of Categories

Set

Objects are sets. Morphisms are functions. Composition is ordinary function composition. The identity on a set A is the identity function sending each element to itself. This is the archetypal example and the target of most representable functors.

Grp and Ab

Grp has groups as objects and group homomorphisms as morphisms. Ab is the full subcategory of abelian groups. Both are examples of concrete categories -- categories whose objects have underlying sets and morphisms are structure-preserving functions.

Top

Objects are topological spaces. Morphisms are continuous maps. Algebraic topology builds functors from Top (or related categories) to Ab, assigning groups such as homology and homotopy groups to spaces while sending maps to homomorphisms.

A Poset as a Category

Any partially ordered set (P, less-or-equal) is a category: objects are elements of P, and there is exactly one morphism from a to b when a is less than or equal to b, and no morphism otherwise. Composition comes from transitivity and identities from reflexivity.

A Monoid as a Category

A monoid (M, times, e) is precisely a category with one object. The single object is a placeholder; the morphisms are the elements of M; composition is the monoid multiplication. This shows category theory generalizes algebraic structures directly.

The Opposite Category

For any category C, the opposite category C-opposite (also written C to the op) has the same objects but all morphisms reversed: a morphism f: A to B in C becomes a morphism f-opposite: B to A in C-opposite. Duality allows every categorical statement to be dualized for free.

Isomorphisms, Monomorphisms, and Epimorphisms

Categorical notions of injectivity and surjectivity are defined purely through composition, without reference to elements.

  • Isomorphism:A morphism f: A to B is an isomorphism if there exists g: B to A with g after f equal to id sub A and f after g equal to id sub B. In Set, isomorphisms are bijections; in Grp, they are group isomorphisms.
  • Monomorphism:A morphism f: A to B is a monomorphism (monic) if for all h, k: C to A with f after h equal to f after k, we have h equal to k. In Set, monomorphisms are injective functions.
  • Epimorphism:A morphism f: A to B is an epimorphism (epic) if for all h, k: B to C with h after f equal to k after f, we have h equal to k. In Set, epimorphisms are surjective functions. In Rng (rings with unit), the inclusion of the integers into the rationals is epimorphic but not surjective.

2. Functors: Covariant, Contravariant, and Endofunctors

Functors are the morphisms between categories. A functor maps objects to objects and morphisms to morphisms in a way that preserves the categorical structure: identities go to identities and composition is respected. Functors make category theory useful by allowing structures from one mathematical domain to be systematically transported into another.

Covariant Functors

A covariant functor F: C to D assigns:

  • To each object A in C, an object F(A) in D.
  • To each morphism f: A to B in C, a morphism F(f): F(A) to F(B) in D.

Subject to the functoriality axioms:

  • Preservation of identity:F(id sub A) equals id sub F(A) for all objects A.
  • Preservation of composition:F(g after f) equals F(g) after F(f) for all composable f, g.

Examples of Covariant Functors

Forgetful Functor

The forgetful functor U: Grp to Set sends each group to its underlying set and each group homomorphism to the same function, now viewed as a function of sets. It forgets the group structure while remembering the underlying data.

Fundamental Group Functor

The fundamental group construction pi sub 1: Top-star to Grp assigns to each pointed topological space its fundamental group and sends each pointed continuous map to a group homomorphism. This is one of the central functors in algebraic topology.

Abelianization Functor

The abelianization functor ab: Grp to Ab sends each group G to its abelianization G modulo the commutator subgroup [G, G], and sends each homomorphism to the induced map on abelianizations. It is left adjoint to the inclusion functor Ab to Grp.

Homology Functors

For each non-negative integer n, the n-th singular homology H sub n: Top to Ab is a functor from topological spaces to abelian groups. A continuous map induces a homomorphism on homology. Homology is homotopy-invariant, meaning homotopic maps induce the same homomorphism.

Contravariant Functors

A contravariant functor G: C to D reverses the direction of all morphisms. It assigns to each morphism f: A to B in C a morphism G(f): G(B) to G(A) in D. Composition is also reversed: G(g after f) equals G(f) after G(g). A contravariant functor from C to D is the same as a covariant functor from C-opposite to D.

Hom Functor hom(-, A)

For a fixed object A, the functor hom(-, A): C-opposite to Set sends each object X to the set hom(X, A) of morphisms from X to A. A morphism f: X to Y is sent to the precomposition map f-star: hom(Y, A) to hom(X, A) defined by f-star(g) equals g after f.

Dual Vector Space

The dual vector space functor (-)star: Vect sub k to Vect sub k sends each vector space V to its dual V-star (the space of linear functionals from V to k) and each linear map T: V to W to the transpose T-star: W-star to V-star. This is a contravariant endofunctor on Vect sub k.

Endofunctors and Bifunctors

An endofunctor on C is a functor from C to itself. Endofunctors are central to the theory of monads. A bifunctor is a functor of two variables: a functor F: C times D to E, where C times D is the product category whose objects are pairs (A, B) and whose morphisms are pairs (f, g). The tensor product on a monoidal category is a bifunctor, as is the Cartesian product in Set.

Full and Faithful Functors

  • Full:F: C to D is full if for every A, B in C and every morphism g: F(A) to F(B) in D, there exists f: A to B in C with F(f) equal to g.
  • Faithful:F is faithful if for all f, g: A to B in C, F(f) equal to F(g) implies f equal to g (injective on hom-sets).
  • Fully faithful:A fully faithful functor is both full and faithful, giving a bijection on every hom-set. Fully faithful functors embed their domain faithfully into the target.

3. Natural Transformations and Equivalence of Categories

Natural transformations are the morphisms between functors. They fill out the three-level structure of category theory: categories, functors, and natural transformations. Mac Lane described the historical progression as: natural transformations were invented to define functors, which were invented to define natural transformations -- but with the formal definition of category needed to make both precise.

Definition of Natural Transformation

Let F, G: C to D be two covariant functors. A natural transformation eta: F implies G assigns to each object A in C a morphism eta sub A: F(A) to G(A) in D, called the component at A, such that for every morphism f: A to B in C, the following naturality square commutes:

G(f) after eta sub A equals eta sub B after F(f)

This square says: it does not matter whether you first apply eta to move from F(A) to G(A) and then apply G(f), or whether you first apply F(f) to move from F(A) to F(B) and then apply eta. Both paths produce the same morphism from F(A) to G(B). This is the precise meaning of naturality.

Motivating Example: Double Dual of a Vector Space

For any finite-dimensional vector space V over a field k, there is a canonical isomorphism from V to its double dual V-double-star. The word canonical here means natural in the technical sense: the collection of these isomorphisms assembles into a natural isomorphism between the identity functor on finite-dimensional vector spaces and the double dual functor. By contrast, a finite-dimensional vector space is also isomorphic to its single dual, but there is no natural isomorphism -- the choice of isomorphism depends on a choice of basis.

Functor Categories and Natural Isomorphism

Given categories C and D, the functors from C to D and the natural transformations between them form a functor category, written D to the C or Fun(C, D). Objects are functors; morphisms are natural transformations; composition of natural transformations is componentwise. Two functors F and G are naturally isomorphic if there is a natural transformation eta: F implies G where every component eta sub A is an isomorphism in D.

Equivalence of Categories

An equivalence of categories between C and D consists of functors F: C to D and G: D to C together with natural isomorphisms eta: id sub C implies G after F and epsilon: F after G implies id sub D. When such an equivalence exists, C and D are said to be equivalent categories, written C is equivalent to D.

Equivalence is the correct notion of sameness for categories. An isomorphism of categories (where eta and epsilon are strict equalities of functors) is too strict: most category-theoretic constructions only produce equivalences, not isomorphisms.

A functor F: C to D is an equivalence of categories if and only if it is fully faithful and essentially surjective (every object of D is isomorphic to F(A) for some A in C). This criterion is the practical way to verify equivalence.

Key Examples of Equivalences

  • Skeletal subcategories: Every category is equivalent to its skeleton, in which no two distinct objects are isomorphic.
  • Stone duality: The category of Boolean algebras is equivalent to the opposite of the category of Stone spaces (compact, totally disconnected Hausdorff spaces), via the duality sending a Boolean algebra to its Stone space of ultrafilters.
  • Pontrjagin duality: The category of locally compact abelian groups is self-dual via the Pontrjagin duality functor, which sends a group G to its character group of continuous homomorphisms from G to the circle.

4. Adjoint Functors: Unit, Counit, and Examples

Adjunctions are the most important single concept in category theory. They appear throughout mathematics wherever an optimal solution or best approximation exists. As Saunders Mac Lane wrote, adjoint functors arise everywhere. Almost every interesting functor between significant categories is part of an adjunction.

Definition via Hom-Set Bijection

An adjunction between functors F: C to D (left adjoint) and G: D to C (right adjoint) is a natural bijection:

hom sub D(F(A), B) is naturally isomorphic to hom sub C(A, G(B))

Natural here means natural in both A (varying in C) and B (varying in D). This says: a morphism from the free object F(A) to B corresponds naturally to a morphism from A to the underlying object G(B).

Unit and Counit

An adjunction can equivalently be described by two natural transformations satisfying triangle identities.

  • Unit:eta: id sub C implies G after F. The component eta sub A: A to G(F(A)) is the universal map from A into the right adjoint applied to the left adjoint of A. It expresses the canonical way to embed A into G(F(A)).
  • Counit:epsilon: F after G implies id sub D. The component epsilon sub B: F(G(B)) to B is the canonical evaluation map: it maps the free object on the underlying set of B back to B.
  • Triangle identities:(epsilon sub F(A)) after (F(eta sub A)) equals id sub F(A) and (G(epsilon sub B)) after (eta sub G(B)) equals id sub G(B). These ensure the unit and counit are coherent with each other.

The Free-Forgetful Adjunction

The most important class of adjunctions is free-forgetful pairs. They capture the idea of a free algebraic structure generated by a set, and the underlying set of an algebraic structure.

Free Groups

The free group functor F: Set to Grp is left adjoint to the forgetful functor U: Grp to Set. The free group F(S) on a set S is the group of reduced words in the alphabet S and its formal inverses. The universal property says: every function from S to the underlying set of a group G extends uniquely to a group homomorphism F(S) to G.

Free Modules

The free R-module functor F: Set to R-Mod is left adjoint to the forgetful functor U: R-Mod to Set. The free R-module on S is the direct sum of copies of R indexed by S. Every set function from S to an R-module M extends uniquely to an R-linear map.

Abelianization

The abelianization functor ab: Grp to Ab is left adjoint to the inclusion functor i: Ab to Grp. The abelianization of G is G modulo the commutator subgroup [G, G]. Every homomorphism from G to an abelian group A factors uniquely through the abelianization.

Stone-Cech Compactification

The Stone-Cech compactification functor beta from Tychonoff spaces to compact Hausdorff spaces is left adjoint to the inclusion functor. Every continuous map from X to a compact Hausdorff space K extends uniquely to a continuous map from beta(X) to K.

Adjunctions and Limits

Right adjoints preserve all limits that exist in their domain, and left adjoints preserve all colimits. This fundamental theorem explains why forgetful functors (which are typically right adjoints) preserve limits: the underlying set of a product of groups is the product of their underlying sets. Conversely, free functors (typically left adjoints) preserve colimits.

5. Limits and Colimits

Limits and colimits generalize constructions such as products, intersections, unions, and quotients. They are defined by universal properties: a limit is the most general object receiving maps from a diagram; a colimit is the most general object receiving maps from all objects in a diagram.

Diagrams, Cones, and the Universal Property

A diagram in C of shape J is a functor D: J to C. A cone over D with apex N is a collection of morphisms (pi sub j: N to D(j)) for each object j in J, such that for every morphism f: j to k in J, the equation D(f) after pi sub j equals pi sub k holds. The limit of D is a universal cone: a cone (L, (lambda sub j)) such that every other cone (N, (pi sub j)) factors uniquely through it via a unique morphism from N to L.

The colimit is the dual notion: a universal cocone, an object C with morphisms in sub j: D(j) to C such that every cocone factors uniquely through C.

Products and Coproducts

Products (Limit of Discrete Diagram)

The product of objects A and B is an object A times B with projection morphisms pi sub 1: A times B to A and pi sub 2: A times B to B such that for any object N and morphisms f: N to A and g: N to B, there is a unique morphism (f, g): N to A times B. In Set, the product is the Cartesian product. In Grp, it is the direct product.

Coproducts (Colimit of Discrete Diagram)

The coproduct of A and B is an object A plus B with injection morphisms i sub 1: A to A plus B and i sub 2: B to A plus B satisfying the dual universal property. In Set, the coproduct is the disjoint union. In Ab, it is the direct sum. In Grp, it is the free product.

Equalizers and Coequalizers

Equalizer

The equalizer of two parallel morphisms f, g: A to B is an object E with a morphism e: E to A such that f after e equals g after e, universal with this property. In Set, the equalizer is the subset of A on which f and g agree. In Top, it is this subset with the subspace topology.

Coequalizer

The coequalizer of f, g: A to B is an object Q with a morphism q: B to Q such that q after f equals q after g, universal with this property. In Set, the coequalizer is the quotient of B by the equivalence relation generated by f(a) tilde g(a) for all a in A.

Pullbacks and Pushouts

Pullback

The pullback of f: A to C and g: B to C is an object P with morphisms p sub 1: P to A and p sub 2: P to B such that f after p sub 1 equals g after p sub 2, universal with this property. In Set, the pullback is the set of pairs (a, b) in A times B with f(a) equal to g(b). Pullbacks generalize fiber products and preimages.

Pushout

The pushout of f: C to A and g: C to B is the colimit of the span. In Set, it is the disjoint union of A and B modulo identifying f(c) with g(c) for all c in C. Pushouts appear in the Seifert-van Kampen theorem: the fundamental group of X union Y (over Z) is the pushout of the fundamental groups of X and Y over the fundamental group of Z.

Terminal and Initial Objects

  • Terminal object:An object 1 in C such that for every object A, there is exactly one morphism from A to 1. Terminal objects are limits of the empty diagram. In Set, the terminal object is any singleton. In Grp, it is the trivial group.
  • Initial object:An object 0 in C such that for every object A, there is exactly one morphism from 0 to A. Initial objects are colimits of the empty diagram. In Set, the initial object is the empty set. In Grp, it is the trivial group (which is both initial and terminal, making it a zero object).

6. The Yoneda Lemma and Its Consequences

The Yoneda lemma is arguably the most important theorem in category theory. It says that an object is completely determined by the morphisms mapping into it (or out of it) from all other objects. It provides the foundation for representable functors, adjunctions, and the modern approach to algebraic geometry via functors of points.

Representable Functors

For each object A in a locally small category C, the hom-functor hom(A, -): C to Set sends each object X to the set hom(A, X) of morphisms from A to X, and each morphism f: X to Y to the postcomposition map f-star: hom(A, X) to hom(A, Y). A functor F: C to Set is representable if it is naturally isomorphic to hom(A, -) for some object A, called a representing object.

Statement of the Yoneda Lemma

Yoneda Lemma:

For any locally small category C, any object A in C, and any functor F: C to Set, there is a bijection:

Nat(hom(A, -), F) is in bijection with F(A)

natural in both A and F. The bijection sends a natural transformation eta: hom(A, -) implies F to the element eta sub A(id sub A) in F(A) -- the image of the identity morphism on A under the component at A.

Conversely, given an element x in F(A), the natural transformation eta with eta sub X(f) equal to F(f)(x) for every f: A to X is the unique natural transformation corresponding to x.

The Yoneda Embedding

Applying the Yoneda lemma to F equal to hom(B, -) shows that natural transformations from hom(A, -) to hom(B, -) correspond exactly to morphisms from B to A. This means the Yoneda embedding:

y: C-opposite to Fun(C, Set) sending A to hom(A, -)

is fully faithful: it gives a bijection on every hom-set. This means C embeds into its presheaf category in a way that completely preserves morphisms. Every object A is completely determined by the functor hom(A, -) representing it. This is the categorical version of the principle that an object is characterized by its relations to all other objects.

Applications of the Yoneda Lemma

Uniqueness of Representing Objects

If hom(A, -) is naturally isomorphic to hom(B, -), then A is isomorphic to B. This shows that representing objects of a functor are unique up to unique isomorphism -- the universal property determines the object uniquely.

Adjunctions via Representability

An adjunction F left adjoint to G can be defined as a natural isomorphism hom sub D(F(-), -) is naturally isomorphic to hom sub C(-, G(-)). This expresses that hom sub D(F(A), B) is represented in A by hom sub C(A, G(B)), unifying representability and adjunctions.

Algebraic Geometry: Functor of Points

In modern algebraic geometry, a scheme X is identified with the functor it represents: for each commutative ring R, the set X(R) of R-points is hom(Spec R, X). The Yoneda lemma guarantees X is determined by all its sets of R-points, and morphisms of schemes are natural transformations between these functors.

Presheaves and Sheaves

A presheaf on a category C is simply a functor C-opposite to Set. The Yoneda embedding embeds C into its category of presheaves. Sheaves are presheaves satisfying a gluing condition with respect to a Grothendieck topology on C, and form the basis of sheaf cohomology and topos theory.

7. Monads: Kleisli and Eilenberg-Moore Categories

Monads are a formalization of the idea of algebraic structure that can be composed. Every adjunction gives rise to a monad, and monads provide a way to describe algebraic theories (groups, rings, modules) in categorical terms. They are also the central abstraction for managing effects in functional programming.

Definition of a Monad

A monad on a category C is a triple (T, eta, mu) where:

  • T: C to Cis an endofunctor, called the underlying functor of the monad.
  • eta: id sub C implies Tis the unit natural transformation with components eta sub A: A to T(A).
  • mu: T after T implies Tis the multiplication natural transformation with components mu sub A: T(T(A)) to T(A).

These must satisfy:

  • Associativity:mu after T(mu) equals mu after mu(T) as natural transformations from T-cubed to T.
  • Unit laws:mu after T(eta) equals id sub T and mu after eta(T) equals id sub T.

Examples of Monads

The List Monad (on Set)

T(A) is the set of finite lists of elements of A. The unit eta sub A sends each element a to the singleton list [a]. The multiplication mu sub A flattens a list of lists into a single list. This is the free monoid monad, corresponding to the free-forgetful adjunction between Set and Mon (monoids).

The Power Set Monad

T(A) is the power set of A (the set of all subsets). The unit eta sub A sends a to the singleton set containing a. The multiplication mu sub A sends a set of sets to their union. This monad encodes non-determinism and corresponds to the free-forgetful adjunction for complete join-semilattices.

The Maybe (Option) Monad

T(A) equals A plus a distinguished element Nothing (the disjoint union with a one-element set). The unit embeds A via the Just injection. The multiplication collapses Just(Just(a)) to Just(a) and anything involving Nothing to Nothing. This encodes partiality or failure.

The Free Algebra Monad

For any algebraic theory (groups, rings, lattices), the composition U after F of the free functor F and forgetful functor U is a monad on Set. The unit embeds generators and the multiplication reduces a free algebra on a free algebra by evaluating the outer free structure.

The Kleisli Category

The Kleisli category C sub T of a monad (T, eta, mu) has the same objects as C. A morphism from A to B in C sub T is a morphism from A to T(B) in C. These are called Kleisli arrows. Composition of f: A to T(B) and g: B to T(C) in C sub T is the composite:

A to T(B) via T(g) to T(T(C)) via mu sub C to T(C)

The identity on A in C sub T is eta sub A: A to T(A). Kleisli categories are the natural setting for effectful computation: a Kleisli arrow from A to B is a computation that takes input of type A and produces an output of type B, possibly with effects described by T. In Haskell, Kleisli arrows are functions of type a to M b for a monad M.

The Eilenberg-Moore Category

The Eilenberg-Moore category of a monad T has T-algebras as objects. A T-algebra is a pair (A, alpha) where A is an object of C and alpha: T(A) to A is a morphism in C (the structure map) satisfying:

  • alpha after eta sub A equals id sub A (the unit law: embedding and then evaluating is the identity).
  • alpha after mu sub A equals alpha after T(alpha) (the associativity law: double application and then evaluation equals applying T to the evaluation and then evaluating).

A morphism of T-algebras f: (A, alpha) to (B, beta) is a morphism f: A to B in C compatible with the structure maps: f after alpha equals beta after T(f). For the list monad on Set, T-algebras are exactly monoids. For the free group monad, T-algebras are exactly groups. This is how monads encode algebraic theories.

Monadic Adjunctions

Every adjunction F: C to D left adjoint to G: D to C gives a monad T equal to G after F on C. Conversely, every monad T on C arises from adjunctions in (typically many) ways. The Kleisli category gives the initial such adjunction (the smallest category for which the monad arises). The Eilenberg-Moore category gives the terminal such adjunction (the largest). For the list monad, the Kleisli category is the category of sets and multivalued functions; the Eilenberg-Moore category is the category of monoids.

8. Abelian Categories and Homological Algebra

Abelian categories are the natural setting for homological algebra. They axiomatize the categorical properties of the category of abelian groups and the category of modules over a ring, capturing just enough structure to define kernels, cokernels, and exact sequences in full generality.

Definition of an Abelian Category

An abelian category A satisfies:

  • Ab-enriched:Every hom-set hom(A, B) is an abelian group, and composition is bilinear with respect to this structure.
  • Zero object:There is an object 0 that is both initial and terminal (a zero object).
  • Biproducts:Every pair of objects has a biproduct: an object A direct sum B that is simultaneously a product and coproduct.
  • Kernels and cokernels:Every morphism has both a kernel (the limit of the pair with the zero morphism) and a cokernel (the dual colimit).
  • Monos are kernels, epis are cokernels:Every monomorphism is the kernel of some morphism, and every epimorphism is the cokernel of some morphism.

Exact Sequences

A sequence of morphisms in an abelian category is exact at an object B if the image of the incoming morphism equals the kernel of the outgoing morphism. Exactness captures the idea that what goes in is exactly what comes out.

Short Exact Sequences

A short exact sequence 0 to A to B to C to 0 encodes B as an extension of C by A: A is a subobject of B and C is the quotient B over A. The sequence splits if B is isomorphic to A direct sum C. Not every short exact sequence splits: the failure to split is measured by the Ext group Ext(C, A).

Long Exact Sequences

Applying a half-exact functor (such as Hom or tensor product) to a short exact sequence produces a long exact sequence involving derived functors (Ext or Tor). For cohomology theories, a short exact sequence of coefficient groups yields a long exact sequence of cohomology groups connecting different dimensions.

The Snake Lemma and Five Lemma

Snake Lemma:

Given a commutative diagram with exact rows and vertical morphisms f: A to A-prime, g: B to B-prime, h: C to C-prime, there is an exact sequence connecting the kernels to the cokernels:

ker(f) to ker(g) to ker(h) via delta to coker(f) to coker(g) to coker(h)

The connecting homomorphism delta is the snake that winds through the diagram. The snake lemma is used to extract long exact sequences from short exact sequences of chain complexes.

Five Lemma:

In a commutative diagram with exact rows and five vertical morphisms, if four of them are isomorphisms (or satisfy injectivity and surjectivity conditions), the fifth is an isomorphism. This is one of the main tools for comparing different exact sequences.

Derived Functors and Homological Dimensions

Given a left exact functor F: A to B between abelian categories, its right derived functors R to the n F measure the failure of F to be exact. They are computed using injective resolutions: replace A by an injective resolution, apply F to get a cochain complex, and take cohomology. The functor Ext to the n(-, B) is the n-th right derived functor of hom(-, B), and Tor sub n(-, B) is the n-th left derived functor of tensor product with B. Projective dimension and injective dimension of modules are measured by where the corresponding derived functors vanish.

9. Toposes and Sheaves

Toposes (or topoi) are categories that behave like the category of sets, but can encode geometric, logical, or algebraic information. They were introduced by Grothendieck to handle sheaves in algebraic geometry and were axiomatized by Lawvere and Tierney into the elementary topos, a foundation for constructive mathematics and intuitionistic logic.

Grothendieck Topology and Sites

A Grothendieck topology on a category C assigns to each object U a collection of covering sieves -- distinguished collections of morphisms into U that are declared to cover U, generalizing open covers in topology. A site is a category equipped with a Grothendieck topology. Standard examples include:

  • Zariski site:On the category of schemes, covers are open immersions. Sheaves on the Zariski site are the classical sheaves of algebraic geometry.
  • Etale site:Covers are etale morphisms (algebraic analogs of local homeomorphisms). Etale cohomology built from sheaves on the etale site was used by Deligne to prove the Weil conjectures.
  • Canonical topology:On any category, one can take the canonical topology where covering families are jointly epimorphic families.

Sheaves and the Sheaf Condition

A presheaf F on a site (C, J) is a functor F: C-opposite to Set. F is a sheaf if it satisfies the gluing axiom with respect to the topology J: for every covering sieve, every compatible family of local sections has a unique global section. Sheaves on a site form a category called the sheaf topos, which is a Grothendieck topos. The category Sh(X) of sheaves of sets on a topological space X (with the usual open cover topology) is the prototypical example.

Elementary Toposes and the Subobject Classifier

An elementary topos is a category E satisfying:

  • E has all finite limits.
  • E has exponential objects: for any objects A, B there is an object A to the B with a natural bijection between hom(C times B, A) and hom(C, A to the B).
  • E has a subobject classifier: an object Omega with a morphism true: 1 to Omega such that for every monomorphism m: A to X, there is a unique morphism chi sub m: X to Omega (the characteristic morphism) with m equal to the pullback of true along chi sub m.

In Set, Omega is the two-element set with elements true and false, and chi sub A sends each element to true if it lies in A and to false otherwise -- this is the characteristic function. In a sheaf topos Sh(X), Omega is the sheaf of open sets: for each open U, Omega(U) is the set of open subsets of U.

Internal Logic of a Topos

Every topos has an internal logic that is intuitionistic (also called constructive) rather than classical. In a topos, the law of excluded middle (every proposition is either true or false) and the axiom of choice do not hold in general. The subobject classifier Omega plays the role of the set of truth values, which in a general topos may have more than two elements. This connection between toposes and logic, developed by Lawvere and Tierney, gives a categorical foundation for constructive mathematics and provides models for intuitionistic set theory.

Connection to Forcing in Set Theory

Grothendieck's sheaf toposes provide a categorical account of forcing in set theory: a generic extension of the universe of sets can be modeled as the internal logic of a sheaf topos over a poset (the forcing poset). This connects category theory, logic, and the independence results of Cohen and others.

10. Applications: Functional Programming, Topology, and Logic

Category Theory in Functional Programming

Haskell is the programming language most directly influenced by category theory. The type system of Haskell can be modeled as a category Hask where types are objects and pure functions are morphisms. Several Haskell typeclasses correspond exactly to categorical structures.

Functor Typeclass

The Haskell Functor typeclass requires an fmap function with type (a to b) to f a to f b. A lawful Functor instance must satisfy fmap id equals id (preservation of identity) and fmap (g after f) equals fmap g after fmap f (preservation of composition). These are exactly the functor axioms for an endofunctor on Hask.

Monad Typeclass

The Haskell Monad typeclass has return :: a to m a (the unit eta) and the bind operator m a to (a to m b) to m b. The bind operation encodes Kleisli composition. The three monad laws (left identity, right identity, associativity) are the categorical monad axioms expressed in terms of Kleisli composition.

Applicative Functors

The Applicative typeclass, between Functor and Monad in the Haskell hierarchy, corresponds to a lax monoidal functor: a functor equipped with morphisms from the monoidal unit to F(unit) and from F(A) tensor F(B) to F(A tensor B), satisfying coherence conditions. Applicatives model independent effects; Monads model sequentially dependent effects.

Parametric Polymorphism as Naturality

A polymorphic Haskell function of type forall a. F(a) to G(a) is a natural transformation from functor F to functor G. The parametricity theorem (free theorems) states that any such function satisfies the naturality condition automatically, because it cannot inspect the type variable a.

Applications to Algebraic Topology

Algebraic topology is perhaps the original application area of category theory. The assignment of algebraic invariants to topological spaces is functorial, and many key theorems are most naturally expressed in categorical language.

Eilenberg-Steenrod Axioms

Homology theories are characterized categorically by the Eilenberg-Steenrod axioms: functoriality, homotopy invariance, the long exact sequence of a pair, excision, and the dimension axiom (fixing the homology of a point). These axioms uniquely characterize ordinary singular homology on finite CW complexes.

Seifert-van Kampen and Pushouts

The Seifert-van Kampen theorem states that the fundamental group functor pi sub 1 sends pushouts of sufficiently connected spaces to pushouts of groups (amalgamated free products). This is a statement about the preservation of colimits, reflecting that pi sub 1 is a left adjoint in a suitable sense.

Sheaf Cohomology

Sheaf cohomology H to the n(X, F) is the right derived functor of the global sections functor Gamma: Sh(X) to Ab. It generalizes singular cohomology (for constant sheaves) and provides the correct cohomology theory for coherent sheaves in algebraic geometry, underlying proofs of the Riemann-Roch theorem and the Weil conjectures.

Higher Category Theory

Modern algebraic topology uses infinity-categories, where in addition to objects and morphisms, there are 2-morphisms between morphisms, 3-morphisms between those, and so on. The homotopy hypothesis states that infinity-groupoids (where all morphisms at all levels are invertible) are equivalent to homotopy types of topological spaces.

Applications to Mathematical Logic

The connection between category theory and logic runs deep, from Lawvere's categorical logic to the Curry-Howard-Lambek correspondence that equates proofs, programs, and morphisms in a cartesian closed category.

  • Curry-Howard-Lambek:Types correspond to propositions, programs (proofs) correspond to morphisms, and type constructors (product, function space, coproduct) correspond to logical connectives (conjunction, implication, disjunction). A cartesian closed category models intuitionistic propositional logic.
  • Hyperdoctrines:Lawvere's hyperdoctrines give a categorical semantics for first-order logic, with quantifiers as adjoints to substitution functors: universal quantification is the right adjoint and existential quantification is the left adjoint.
  • Categorical set theory:Lawvere's Elementary Theory of the Category of Sets (ETCS) axiomatizes set theory in categorical terms, replacing the membership-based axioms of ZFC with properties of functions and the category of sets. It is equiconsistent with bounded Zermelo-Fraenkel set theory.

Related Topics

11. Frequently Asked Questions

What is a category and what are its axioms?

A category consists of a collection of objects and, for each ordered pair of objects A and B, a set of morphisms (arrows) from A to B. Three laws must hold. Composition: for morphisms f from A to B and g from B to C, there is a composed morphism g after f from A to C. Identity: for every object A there is an identity morphism id sub A from A to A such that composing any morphism with the identity on either side returns the original morphism. Associativity: for any composable triple f, g, h, the equation h after (g after f) equals (h after g) after f holds. Examples include Set (sets and functions), Grp (groups and homomorphisms), Top (spaces and continuous maps), and any poset viewed as a category with a morphism from a to b whenever a is less than or equal to b.

What is the difference between a covariant and contravariant functor?

A covariant functor F from C to D sends a morphism f: A to B in C to a morphism F(f): F(A) to F(B) in D, going in the same direction. A contravariant functor G from C to D reverses arrows: it sends f: A to B to G(f): G(B) to G(A), and reverses the order of composition, so G(g after f) equals G(f) after G(g). A contravariant functor from C to D is the same as a covariant functor from the opposite category C-opposite to D. The hom-functor hom(-, A) and the dual vector space functor are standard examples of contravariant functors. Covariant functors arise when structure maps are pushed forward; contravariant functors arise when structure maps are pulled back.

What is a natural transformation and when are two functors naturally isomorphic?

A natural transformation eta from functor F to functor G (both from C to D) assigns to each object A in C a morphism eta sub A: F(A) to G(A) in D, such that for every morphism f: A to B in C, the square G(f) after eta sub A equals eta sub B after F(f) commutes. The naturality square says: the two paths from F(A) to G(B) -- through eta and then G(f), or through F(f) and then eta -- are equal. This is the precise meaning of canonical. Two functors are naturally isomorphic if there is a natural transformation between them whose every component eta sub A is an isomorphism. The canonical isomorphism from a finite-dimensional vector space to its double dual is the classic example: it is natural in the vector space, while an isomorphism to the single dual requires a choice of basis and is not natural.

What is the Yoneda lemma and why is it important?

The Yoneda lemma states that for any locally small category C, object A in C, and functor F: C to Set, the set of natural transformations from the representable functor hom(A, -) to F is in natural bijection with F(A). The bijection sends a natural transformation eta to the element eta sub A(id sub A) in F(A). A key consequence is the Yoneda embedding: the functor sending each object A to hom(A, -) is fully faithful, so an object is completely determined by all the morphisms mapping out of it. The lemma underlies representable functors, universal properties, adjunctions, and the functor-of-points approach in algebraic geometry where a scheme X is identified with the functor sending each ring R to the set of R-points of X.

What is an adjunction between two functors?

Functors F: C to D (left adjoint) and G: D to C (right adjoint) form an adjunction when there is a natural bijection hom sub D(F(A), B) is isomorphic to hom sub C(A, G(B)) for all A in C and B in D. Equivalently, an adjunction is given by a unit eta: id sub C implies G after F and a counit epsilon: F after G implies id sub D satisfying the triangle identities. The prototypical example is the free-forgetful adjunction: the free group functor from Set to Grp is left adjoint to the forgetful functor. A morphism from a free group on set S to a group G corresponds naturally to a function from the set S to the underlying set of G. Right adjoints preserve limits and left adjoints preserve colimits. Adjunctions appear throughout mathematics wherever an optimal approximation or universal construction exists.

What are limits and colimits in category theory?

A limit of a diagram D: J to C is an object L with a universal cone over D: morphisms from L to each object in the diagram, compatible with diagram morphisms, such that any other cone factors uniquely through L. Colimits are the dual: a universal object receiving maps from every object in the diagram. Products are limits of discrete diagrams; coproducts are colimits. Equalizers limit parallel pairs; coequalizers are their duals. Pullbacks are limits of cospans; pushouts are colimits of spans. The terminal object is the limit of the empty diagram. In Set, limits are sets of compatible tuples and colimits are quotients of disjoint unions. Right adjoints preserve limits and left adjoints preserve colimits -- this single theorem explains why forgetful functors preserve products and free functors preserve coproducts.

What is a monad and how does it relate to the Kleisli and Eilenberg-Moore categories?

A monad on C is a triple (T, eta, mu): an endofunctor T, a unit eta: id implies T, and a multiplication mu: T squared implies T, satisfying associativity and unit laws analogous to those of a monoid. The Kleisli category has the same objects as C but morphisms from A to B are morphisms A to T(B) in C, composed via mu. This models effectful computation: a Kleisli arrow is a computation producing a T-shaped effect. The Eilenberg-Moore category has T-algebras as objects: pairs (A, alpha) where alpha: T(A) to A satisfies unit and associativity laws. For the list monad, T-algebras are exactly monoids. Every monad arises from adjunctions; the Kleisli category gives the initial such adjunction and the Eilenberg-Moore category gives the terminal one.

What is an abelian category and why are exact sequences important?

An abelian category is an Ab-enriched category with a zero object, biproducts, and in which every morphism has a kernel and cokernel, with every monomorphism being a kernel and every epimorphism being a cokernel. Key examples are Ab (abelian groups), R-Mod (R-modules), and sheaves of abelian groups. A sequence is exact at B if the image of the incoming map equals the kernel of the outgoing map. Short exact sequences 0 to A to B to C to 0 encode B as an extension of C by A. Long exact sequences arise from applying half-exact functors to short exact sequences, with the failure of exactness measured by derived functors Ext and Tor. The snake lemma constructs connecting homomorphisms between kernels and cokernels, and the five lemma deduces isomorphisms from surrounding isomorphisms in a commutative diagram.

What is a Grothendieck topos and what is a subobject classifier?

A Grothendieck topos is a category equivalent to the category of sheaves on a site (a category with a Grothendieck topology specifying what counts as a cover). An elementary topos is a category with finite limits, exponential objects, and a subobject classifier: an object Omega with a morphism true: 1 to Omega such that every monomorphism A to X corresponds uniquely to a characteristic morphism X to Omega. In Set, Omega is the set of truth values true and false and the characteristic morphism is the indicator function of a subset. In a sheaf topos, Omega is the sheaf of open sets. Toposes have an internal intuitionistic logic and sheaf toposes model forcing in set theory, connecting categorical logic with independence results in foundations of mathematics.

How does category theory apply to functional programming?

Category theory provides the mathematical underpinning of several core abstractions in functional programming. In Haskell, the category Hask has types as objects and pure functions as morphisms. The Functor typeclass corresponds to an endofunctor: fmap maps functions to functions and must satisfy the functor laws. The Monad typeclass corresponds to a monad: return is the unit eta and the bind operator encodes Kleisli composition. Monad laws (left identity, right identity, associativity) are the categorical monad axioms. The Applicative typeclass corresponds to a lax monoidal functor, modeling independent effects. Parametrically polymorphic functions are natural transformations, and the parametricity theorem (free theorems) says they automatically satisfy naturality. This connection lets programmers reason about code correctness using categorical theorems without inspecting implementation details.

NailTheTest

Ready to Master Category Theory?

Practice with targeted problem sets covering functors, natural transformations, adjunctions, the Yoneda lemma, and monads. Build deep intuition with worked examples and instant feedback.