The VikiD Truth

Knowledge base / Mathematics / Logic, sets & foundations

algebra

Category Theory

Category theory is abstract, about as abstract as mathematics gets.

It is the study of systems of related objects. The relations between the objects under study are called maps (also arrows or morphisms)

Maps bind Objects together in a relationship.

Often Objects are Represented by Letters and Maps by Arrow, such as:

       f       g
   A  ---> B  -->  C

where we have objects A, B and C, and arrows f & g.

A and B are related through f & B and C are related through g.

Category theory born out of the studies in

Algebraic Topology was formulated precisely in the 1940’s by Samuel Eilenberg & Saunders Mac Lane.

Categories are themselves Objects.

Functors are maps between Categories.

Natural Transformations are maps between Functors.

Often the term Homomorphism is used, I like to think of it as nothing more than meaning a general morphism.

Categories

A category C\mathcal{C} is just three things:

  1. a collection of objects A,B,C,…A, B, C, \dots;
  2. for each pair of objects, a collection of arrows f:A→Bf : A \to B;
  3. a way to compose arrows that line up: given f:A→Bf : A \to B and g:B→Cg : B \to C, there is g∘f:A→Cg \circ f : A \to C.

And only two rules:

That is the whole definition. If it reminds you of groups, good: a group is exactly a category with one object in which every arrow can be undone.

The plain idea

Here is the truth behind the abstraction: category theory says you know a thing by its relationships, not by its insides. Set theory asks “what is this made of?” Category theory asks “how does this connect to everything else?”

It is the difference between describing a person by their DNA and describing them by who they talk to, work with and love. Both are true descriptions. The second one is often more useful.

Why it matters

Mathematics in the 20th century split into many specialised fields, each with its own objects and its own “structure-preserving maps”: functions between sets, homomorphisms between groups, linear maps between vector spaces, continuous maps between spaces. Eilenberg and Mac Lane noticed that the same arguments kept being repeated in each field. Category theory lets you make the argument once, at the level of arrows, and get every special case for free.

It has since leaked out of pure maths:

An everyday analogy: plumbing

Think of objects as pipe fittings and arrows as lengths of pipe. You can join two pipes only if the end of the first matches the start of the second (composition needs matching ends). There is a zero-length connector that changes nothing (the identity). And if you join three pipes, it doesn’t matter which joint you tighten first (associativity). Category theory is the study of what can be built from fittings and pipes, without ever asking what the pipes are made of.

Some examples

CategoryObjectsArrows
Setsetsfunctions
Grpgroupsgroup homomorphisms
Vectvector spaceslinear maps
Toptopological spacescontinuous maps
a preorderelements xxone arrow x→yx \to y whenever x≤yx \le y

The last one is a surprise: any ordering is a category. Composition is just transitivity (if x≤yx \le y and y≤zy \le z then x≤zx \le z), and identity is reflexivity (x≤xx \le x). See Transitivity and Reflexivity: those relation properties are category axioms in disguise.

Functors

A functor F:C→DF : \mathcal{C} \to \mathcal{D} is a map between categories. It sends each object AA to an object F(A)F(A), and each arrow f:A→Bf : A \to B to an arrow F(f):F(A)→F(B)F(f) : F(A) \to F(B), while respecting the structure:

F(g∘f)=F(g)∘F(f),F(1A)=1F(A) F(g \circ f) = F(g) \circ F(f), \qquad F(1_A) = 1_{F(A)}

A worked example: the “list” functor

Let C\mathcal{C} be the category Set. Define L(A)L(A) to be the set of finite lists of elements of AA. Given a function f:A→Bf : A \to B, define L(f)L(f) to apply ff to every entry:

L(f)([a1,a2,a3])=[f(a1),f(a2),f(a3)] L(f)([a_1, a_2, a_3]) = [f(a_1), f(a_2), f(a_3)]

Check the rules with f(x)=x+1f(x) = x + 1 and g(x)=2xg(x) = 2x on whole numbers:

Mapping twice is the same as mapping the composite once. Programmers write this as map g . map f == map (g . f), and compilers use it to fuse two loops into one. That is a categorical law saving real CPU time.

Natural Transformations

A natural transformation η:F⇒G\eta : F \Rightarrow G between two functors F,G:C→DF, G : \mathcal{C} \to \mathcal{D} picks, for each object AA, an arrow ηA:F(A)→G(A)\eta_A : F(A) \to G(A), such that for every f:A→Bf : A \to B this square commutes:

G(f)∘ηA=ηB∘F(f) G(f) \circ \eta_A = \eta_B \circ F(f)
graph LR
  FA["F(A)"] -->|"F(f)"| FB["F(B)"]
  FA -->|"η_A"| GA["G(A)"]
  FB -->|"η_B"| GB["G(B)"]
  GA -->|"G(f)"| GB

Example: “reverse a list” is a natural transformation from LL to LL. Reversing and then adding one to every entry gives the same answer as adding one and then reversing. It works uniformly, without peeking at what the entries are. Mac Lane said category theory was invented precisely to define this word “natural”.

Common misconceptions

How it connects

The truth revealed: stop staring at the thing. Look at its arrows.

Further Reading

Last edited · 8 revisions

Tags: #Math