research31 min studyLesson 93 in Mathematics

Categories, functors, and natural transformations

Organize mathematical constructions by identity, composition, and compatibility across every object.

On this page

What you’ll understand

  • Check the identity and composition requirements for a functor.
  • Read the naturality square with correctly typed arrows.
  • Verify the naturality of the double-dual map for finite-dimensional vector spaces.

A useful mathematical construction should behave consistently when its input changes. Taking an underlying set, forming a quotient, or sending a vector space to a related space affects both objects and maps between them. Category theory makes that compatibility explicit. Its first challenge is careful bookkeeping rather than exotic notation: every arrow has a source and a target, composition follows one convention, and a claimed comparison must commute with every permitted map. We will verify such a comparison using elementary linear algebra.

Objects matter together with their arrows

A category has objects, arrows between specified pairs of objects, identity arrows, and associative composition whenever targets and sources match. In the category of sets, arrows are functions; in vector spaces over a fixed field, they are linear maps. Composition g∘f means first f and then g. A picture of connected nodes is not automatically a category: composites and identities must exist and obey the axioms. Conversely an object may carry rich internal data that the category deliberately emphasizes only through a chosen class of structure-preserving maps.

For vector spaces, using arbitrary functions as arrows would produce a different category and destroy statements that rely on linearity. The choice of morphisms is therefore part of the mathematical question. An isomorphism is an arrow with a two-sided inverse inside the category. Even a continuous bijection between topological spaces need not be an isomorphism unless its inverse is also continuous. Keeping the category explicit prevents a familiar word such as equivalent from quietly changing meaning when one moves from algebra to geometry or analysis.

(h∘g)∘f=h∘(g∘f),idB∘f=f=f∘idA(f:A→B)(h\circ g)\circ f=h\circ(g\circ f),\qquad \mathrm{id}_B\circ f=f=f\circ\mathrm{id}_A\quad(f:A\to B)
The category axioms require associativity for composable arrows and an identity at each object. These expressions are meaningful only when all source and target types match.↔ Scroll wide equations horizontally.

A functor transports a whole compositional system

A covariant functor assigns an object F(A) to each object A and an arrow F(f):F(A)→F(B) to each f:A→B. It must preserve identities and composition. Forgetting the vector-space structure gives a functor from vector spaces to sets because a linear map is a function and its composition is the same underlying composition. This construction does not manufacture a preferred basis. Any proposal that chooses arbitrary bases and then claims canonical coordinates must explain how those choices interact with every map rather than only with one convenient example.

Dualization reverses direction: a linear map f:V→W gives a pullback f*:W*→V* by precomposition. It is therefore contravariant, or equivalently a covariant functor into an opposite category. Applying dualization twice restores the original direction. In finite dimension the double dual is isomorphic to the original space, but that does not make every arbitrary isomorphism natural. Naturality identifies a specific compatibility with changing V. Infinite-dimensional algebraic vector spaces still have a canonical injection into their double dual, but it need not be surjective.

F(idA)=idF(A),F(g∘f)=F(g)∘F(f),f∗(ψ)=ψ∘fF(\mathrm{id}_A)=\mathrm{id}_{F(A)},\qquad F(g\circ f)=F(g)\circ F(f),\qquad f^*(\psi)=\psi\circ f
The first two equations define a covariant functor. The final formula defines the dual pullback and reverses the direction of f.↔ Scroll wide equations horizontally.

Naturality compares constructions without hidden choices

A natural transformation η:F⇒G supplies a component η_A:F(A)→G(A) for every object. For every arrow f:A→B, taking the F route and then comparing at B must agree with comparing at A and taking the G route. One successful diagram is insufficient: the statement quantifies over all arrows. Components need not be invertible; when every component is an isomorphism, the transformation is a natural isomorphism. The square thus describes a family of compatible comparisons, rather than an additional operation on one isolated object.

For a vector v, evaluation defines j_V(v) in V** by j_V(v)(φ)=φ(v). No basis appears. The identity f**∘j_V=j_W∘f follows by applying both sides to an arbitrary covector on W, making this an excellent first naturality proof. In finite dimension each j_V is invertible. In the lab, a single sigmoid computation graph makes order of operations inspectable; it neither represents an entire category nor checks naturality. The lesson's proof comes from following typed linear maps and testing their evaluations, not from the graph's visual arrows.

G(f)∘ηA=ηB∘F(f),jV(v)(φ)=φ(v),f∗∗∘jV=jW∘fG(f)\circ\eta_A=\eta_B\circ F(f),\qquad j_V(v)(\varphi)=\varphi(v),\qquad f^{**}\circ j_V=j_W\circ f
The first equation is naturality for every f:A→B. The latter two give the canonical natural map from a vector space to its algebraic double dual.↔ Scroll wide equations horizontally.

A naturality square evaluated numerically

Take f:R→R2f:\mathbb R\to\mathbb R^2, f(t)=(2t,3t), v=4, and ψ(x,y)=5x−y. Compare the two double-dual routes at ψ.

  1. The direct route sends v=4 to f(v)=(8,12), then evaluates ψ: ψ(8,12)=40−12=28. Thus j_W(f(v))(ψ)=28.

  2. The pullback is the covector f*(ψ) on the real line, with f*(ψ)(t)=ψ(2t,3t)=10t−3t=7t.

  3. The other route evaluates j_V(4) on f*(ψ), giving 7×4=28. By the definition of f**, this equals (f**j_V(4))(ψ).

  4. For a general ψ(x,y)=ax+by and arbitrary v, both routes give (2a+3b)v. That final symbolic identity establishes compatibility beyond the one numerical check.

The result

Both routes give 28 in the test, and the general evaluation identity proves the square commutes for this map.

Explore the model

Interactive lab

Interactive lab · network

Follow a composition in a small graph

Set weight w=0 and predict whether changing input x can affect the output; then vary both controls and follow wx, the fixed bias −0.5, and the sigmoid output σ(wx−0.5). This is an explicit composition of scalar operations. It is not a category, a double-dual computation, or a test of naturality over all maps.

Follow a composition in a small graphOne inspectable sigmoid unit, σ(wx − 0.5). Playback traces the computation graph. There is no training, attention mechanism or hidden deep network. Current readings: Product · wx: 1.2; Logit · wx − 0.5: 0.7; Sigmoid output: 0.6682. All parameters are adjustable with the labeled controls below.One input. One weight. One sigmoid.x1.20× w1.20+ b0.70σ0.668output0.668w = 1.00b = −0.50σ(z) = 1 / (1 + exp(−z))
Computation graphSignal trace
Product · wx
1.2
Logit · wx − 0.5
0.7
Sigmoid output
0.6682
t = 0 s

One inspectable sigmoid unit, σ(wx − 0.5). Playback traces the computation graph. There is no training, attention mechanism or hidden deep network. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA diagram becomes mathematics when its arrows are typed and its claimed equal routes are verified.

Check your understanding

What does naturality of η:F⇒G require for f:A→B?

Try it yourself

Let V=R², W=R, f(x,y)=x−2y, v=(3,1), and ψ(t)=4t. Evaluate j_W(f(v))(ψ) and j_V(v)(f*(ψ)).

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Compute f(v) first, then compute the pulled-back covector on a general (x,y).

Compare with the solution

f(v)=1, so the first route gives ψ(1)=4. The pullback is f*(ψ)(x,y)=4x−8y, which at (3,1) gives 12−8=4. The matching value is a concrete instance of the basis-free evaluation identity.

Take it with you

  • A category specifies permitted maps as well as objects.
  • Functors preserve identity and composition; dualization reverses direction.
  • Naturality requires compatibility across every map, and canonical double-dual evaluation supplies a concrete example.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.