---
title: Natural Transformations and Functor Categories
module: Foundations
moduleNumber: 1
lessonNumber: 5
order: 105
summary: >
  A natural transformation is a map between two parallel functors: one
  component arrow per object, subject to a commuting square for every arrow of
  the source. Naturality is verified for the determinant, the double dual, and
  list operations; functors and natural transformations form the functor category
  [C, D]; and vertical and horizontal composition satisfy the Godement interchange
  law.
topics: [Foundations]
sources:
  - book: Leinster
    ref: "§1.3 Natural transformations — definition, examples, functor categories, natural isomorphism"
  - book: Simmons
    ref: "Ch. 3 §3.4 Natural transformations defined; §3.5 Examples of natural transformations"
  - book: Barr & Wells
    ref: "Ch. 4 §4.2–4.3 Natural transformations; §4.4 The Godement calculus of natural transformations"
draft: false
---

[Categories](/category-theory/foundations/what-is-a-category) have maps between
them, the [functors](/category-theory/foundations/functors). Functors in turn
have maps between them, and this second-level notion is the one category theory
was invented for: Eilenberg and Mac Lane introduced categories and functors in
order to say precisely what a _natural_ construction is. A natural
transformation compares two parallel functors $F, G : \mathcal{A} \to
\mathcal{B}$ by giving, for every object of $\mathcal{A}$, an arrow from its
$F$-image to its $G$-image, uniformly in a sense the definition makes exact.

## The definition

To see what the compatibility condition should be, start where no condition is
needed. Let $\mathcal{A}$ be the discrete category with objects
$0, 1, 2, \dots$; functors $F, G : \mathcal{A} \to \mathcal{B}$ are just
sequences $(F_0, F_1, \dots)$ and $(G_0, G_1, \dots)$ of objects of
$\mathcal{B}$, and the reasonable notion of map from $F$ to $G$ is a sequence of
arrows $\alpha_i : F_i \to G_i$. In general $\mathcal{A}$ has arrows too, and
the components must respect them.[^lein-def]

> **Definition (Natural transformation).** Let
> $F, G : \mathcal{A} \to \mathcal{B}$ be functors. A **natural transformation**
> $\alpha : F \to G$ is a family
> $\left( \alpha_A : F(A) \to G(A) \right)_{A \in \mathcal{A}}$ of arrows in
> $\mathcal{B}$, the **components** of $\alpha$, such that for every arrow
> $f : A \to A'$ in $\mathcal{A}$ the **naturality square** commutes:
>
> $$
> G(f) \circ \alpha_A \;=\; \alpha_{A'} \circ F(f).
> $$

$$
% caption: The naturality square for the component of a transformation $t$ at an
% arrow $f : A \to B$: pushing forward along $F(f)$ then crossing over equals
% crossing over then pushing along $G(f)$.
\begin{tikzpicture}[scale=1.1, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (FA) at (0,1.8) {$F(A)$};
\node (FA2) at (3.2,1.8) {$F(B)$};
\node (GA) at (0,0) {$G(A)$};
\node (GA2) at (3.2,0) {$G(B)$};
\draw[->, acc, thick] (FA) -- (FA2) node[midway, above] {$F(f)$};
\draw[->, acc, thick] (GA) -- (GA2) node[midway, below] {$G(f)$};
\draw[->, black, thick] (FA) -- (GA) node[midway, left] {$t_A$};
\draw[->, black, thick] (FA2) -- (GA2) node[midway, right] {$t_B$};
\end{tikzpicture}
$$

As with categories and functors, the definition is arranged so that each arrow
$f : A \to A'$ of $\mathcal{A}$ yields exactly one arrow $F(A) \to G(A')$ of
$\mathcal{B}$ — the common diagonal of the square.
We write $\alpha : F \Rightarrow G$ when the double arrow is helpful for
distinguishing levels.

The square rules out case-by-case definitions. A family of maps defined by
one formula for some objects and another formula for others will generically
fail the square for arrows crossing between the cases. Naturality is the formal
counterpart of "defined the same way for every object."

## Worked examples

> **Worked example (The determinant is natural).** For each commutative ring $R$,
> the $n \times n$ matrices over $R$ form a multiplicative monoid $M_n(R)$, and
> $R$ itself gives a multiplicative monoid $U(R)$; both assignments are functors
> $\mathbf{CRing} \to \mathbf{Mon}$. The determinant is a family of monoid
> morphisms $\det_R : M_n(R) \to U(R)$, with $\det(XY) = \det X \det Y$ and
> $\det I = 1$. For a ring homomorphism $f : R \to S$, naturality is the equation
> $$
> \det\nolimits_S \circ\, M_n(f) \;=\; U(f) \circ \det\nolimits_R.
> $$
> Both sides compute the determinant of a matrix after or before applying $f$ to
> every entry, and they agree because the determinant is the _same polynomial in
> the entries_ over every ring. One definition for all rings, so naturality
> holds.[^lein-det]

> **Worked example (The double dual).** Let $\mathbf{FDVect}_k$ be
> finite-dimensional vector spaces. Each $V$ has a canonical map
> $\alpha_V : V \to V^{\ast\ast}$ sending $v$ to evaluation at $v$:
> $\alpha_V(v)(\varphi) = \varphi(v)$ for $\varphi \in V^\ast$. The family
> $\alpha$ is a natural transformation from the identity functor to the
> double-dual functor, and each component is an isomorphism. Contrast
> $V \cong V^\ast$: single duals are isomorphic to $V$ too, but only after
> choosing a basis, and no choice makes the family natural. The categorical
> language separates "isomorphic" from "canonically isomorphic," which was the
> original motivation for these definitions.[^lein-dd]

> **Worked example (Natural transformations between $G$-sets).** Regard a monoid
> $G$ as a one-object category, so functors $G \to \mathbf{Set}$ are $G$-sets. A
> natural transformation between two such functors $S, T$ has a single component
> (there is one object), a function $\alpha : S \to T$, and the naturality squares
> (one per element of $G$) say exactly $\alpha(g \cdot s) = g \cdot \alpha(s)$.
> Natural transformations between $G$-sets are the equivariant maps.[^lein-gset]

> **Worked example (Flatten is natural).** The Kleene closure is a functor
> $(-)^\ast : \mathbf{Set} \to \mathbf{Set}$, and applying it twice gives the
> list-of-lists functor. Flattening a list of lists,
> $\mathrm{flatten}_A : A^{\ast\ast} \to A^\ast$, is a natural transformation
> $(-)^{\ast\ast} \Rightarrow (-)^\ast$: naturality says renaming the elements
> commutes with flattening, which holds because flatten never inspects an element.
> Likewise $\mathrm{reduce}_M : F(U(M)) \to M$, which multiplies out a list using
> the operation of the monoid $M$, is natural from $F \circ U$ to
> $1_{\mathbf{Mon}}$. Operations "polymorphic in the element type" are the natural
> transformations; naturality is the mathematical content of the intuition that
> flatten cannot behave differently for integers than for strings.[^bw-lists]

> **Worked example (Reverse is natural, checked on a square).** Reversal is a
> natural transformation $\mathrm{rev} : (-)^\ast \Rightarrow (-)^\ast$, with
> component $\mathrm{rev}_A : A^\ast \to A^\ast$ turning a list end to end. Take
> $f : \{a, b\} \to \{0, 1\}$ with $f(a) = 0$, $f(b) = 1$ and the list
> $\ell = [a, a, b]$. The naturality square
> $\mathrm{rev}_{\{0,1\}} \circ f^\ast = f^\ast \circ \mathrm{rev}_{\{a,b\}}$
> evaluates on $\ell$ as
> $$
> \mathrm{rev}(f^\ast[a, a, b]) = \mathrm{rev}[0, 0, 1] = [1, 0, 0], \qquad
> f^\ast(\mathrm{rev}[a, a, b]) = f^\ast[b, a, a] = [1, 0, 0].
> $$
> The two routes agree because $\mathrm{rev}$ permutes positions while $f^\ast$
> rewrites entries; neither reads the other's data. A definition that reversed
> lists over $\{0, 1\}$ by a different rule would break this square.

## The functor category

Natural transformations compose. Given
$\alpha : F \Rightarrow G$ and $\beta : G \Rightarrow H$ (with
$F, G, H : \mathcal{A} \to \mathcal{B}$), define
$(\beta \circ \alpha)_A = \beta_A \circ \alpha_A$; the two-storey naturality
squares stack into one tall rectangle, which commutes because each storey does.
Each functor $F$ has an identity transformation $1_F$ with components
$1_{F(A)}$.

$$
% caption: Vertical composition stacks naturality squares; the outer rectangle
% commutes because both inner squares do, giving components $u_A$ then $v_A$.
\begin{tikzpicture}[scale=1.1, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (FA) at (0,3.2) {$F(A)$};
\node (FA2) at (3.2,3.2) {$F(B)$};
\node (GA) at (0,1.6) {$G(A)$};
\node (GA2) at (3.2,1.6) {$G(B)$};
\node (HA) at (0,0) {$H(A)$};
\node (HA2) at (3.2,0) {$H(B)$};
\draw[->, acc, thick] (FA) -- (FA2) node[midway, above] {$F(f)$};
\draw[->, acc, thick] (GA) -- (GA2) node[midway, above] {$G(f)$};
\draw[->, acc, thick] (HA) -- (HA2) node[midway, below] {$H(f)$};
\draw[->, black, thick] (FA) -- (GA) node[midway, left] {$u_A$};
\draw[->, black, thick] (FA2) -- (GA2) node[midway, right] {$u_B$};
\draw[->, black, thick] (GA) -- (HA) node[midway, left] {$v_A$};
\draw[->, black, thick] (GA2) -- (HA2) node[midway, right] {$v_B$};
\end{tikzpicture}
$$

> **Definition (Functor category).** For categories $\mathcal{A}$ and
> $\mathcal{B}$, the **functor category** $[\mathcal{A}, \mathcal{B}]$ (also
> written $\mathcal{B}^{\mathcal{A}}$ or
> $\mathrm{Func}(\mathcal{A}, \mathcal{B})$) has functors
> $\mathcal{A} \to \mathcal{B}$ as objects and natural transformations as
> arrows, with vertical composition.[^lein-cat]

The exponent notation is justified on small examples. If $\mathbf{2}$ is the
discrete two-object category, $[\mathbf{2}, \mathcal{B}] \cong \mathcal{B}
\times \mathcal{B}$, a pair of objects and a pair of maps, matching
$\mathcal{B}^{\mathbf{2}}$. If $G$ is a monoid, $[G, \mathbf{Set}]$ is the
category of left $G$-sets and equivariant maps, and
$[G^{\mathrm{op}}, \mathbf{Set}]$ the right $G$-sets. If $A$ and $B$ are ordered
sets, $[A, B]$ is again an ordered set: the monotone maps, compared pointwise
($f \le g$ iff $f(a) \le g(a)$ for all $a$; at most one transformation exists
because all diagrams in a thin category commute).

## Natural isomorphism

Since $[\mathcal{A}, \mathcal{B}]$ is a category, it comes with a notion of
isomorphism automatically.

> **Definition (Natural isomorphism).** A **natural isomorphism** between
> functors $F, G : \mathcal{A} \to \mathcal{B}$ is an isomorphism in
> $[\mathcal{A}, \mathcal{B}]$. We write $F \cong G$, or say
> $F(A) \cong G(A)$ **naturally in** $A$.

> **Lemma (Componentwise test).** A natural transformation
> $\alpha : F \Rightarrow G$ is a natural isomorphism if and only if every
> component $\alpha_A$ is an isomorphism in $\mathcal{B}$.[^lein-natiso]

One direction is immediate. For the other, the inverses $\alpha_A^{-1}$ must be
shown to form a natural family; rearranging the naturality square of $\alpha$
around $f$ does it. The double dual above is the flagship instance: the
canonical $\alpha_V$ are isomorphisms, so
$1_{\mathbf{FDVect}} \cong (-)^{\ast\ast}$ as functors.

$$
% caption: A natural isomorphism is a bridge of parallel component isomorphisms
% $t_{A_i} : F(A_i) \to G(A_i)$, each invertible, between the two images of the
% source category; every square between planks commutes.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (F1) at (0,1.6) {$F(A_1)$};
\node (F2) at (2.6,1.6) {$F(A_2)$};
\node (F3) at (5.2,1.6) {$F(A_3)$};
\node (G1) at (0,0) {$G(A_1)$};
\node (G2) at (2.6,0) {$G(A_2)$};
\node (G3) at (5.2,0) {$G(A_3)$};
\draw[->, acc, thick] (F1) -- (F2);
\draw[->, acc, thick] (F2) -- (F3);
\draw[->, acc, thick] (G1) -- (G2);
\draw[->, acc, thick] (G2) -- (G3);
\draw[<->, black, thick] (F1) -- (G1) node[midway, left] {$t_{A_1}$};
\draw[<->, black, thick] (F2) -- (G2) node[midway, left] {$t_{A_2}$};
\draw[<->, black, thick] (F3) -- (G3) node[midway, left] {$t_{A_3}$};
\end{tikzpicture}
$$

$F(A) \cong G(A)$ for every $A$ _separately_ is strictly weaker than
$F \cong G$. The pointwise statement supplies isomorphisms; naturality demands
they be chosen coherently, and sometimes no coherent choice exists (the single
dual $V^\ast$ again). When the source category is discrete the two notions
collapse (there are no squares to satisfy), which is why the distinction is
invisible until functors enter.

Natural isomorphism also repairs the too-strict notion of sameness for
categories. Isomorphism of categories ($GF = 1$, $FG = 1$ on the nose) almost
never occurs; the correct notion, **equivalence**, asks only
$G \circ F \cong 1_{\mathcal{A}}$ and $F \circ G \cong 1_{\mathcal{B}}$, with
natural isomorphisms in place of equalities.[^bw-equiv] A functor is an
equivalence precisely when it is full, faithful, and essentially surjective —
the classification set up in
[the functors lesson](/category-theory/foundations/functors). Equivalence is the
sense in which "the category of finite sets" and "the category of sets
$\{1, \dots, n\}$" are the same, and in which one-object categories with
invertible arrows _are_ groups.

## Horizontal composition and the Godement calculus

Vertical composition stacks transformations between functors sharing source and
target. There is a second, orthogonal composition when the functors themselves
compose. Given

$$
\mathcal{A}
\underset{G}{\overset{F}{\rightrightarrows}}
\mathcal{B}
\underset{K}{\overset{H}{\rightrightarrows}}
\mathcal{C},
\qquad
\alpha : F \Rightarrow G,
\quad
\beta : H \Rightarrow K,
$$

two hybrid whiskerings are available first:[^bw-godement]

- $\beta F : H \circ F \Rightarrow K \circ F$ with components
  $(\beta F)_A = \beta_{F(A)}$ — sample $\beta$ at image objects; naturality is
  $\beta$'s own naturality at the arrows $F(f)$.
- $H \alpha : H \circ F \Rightarrow H \circ G$ with components
  $(H\alpha)_A = H(\alpha_A)$ — apply $H$ to the components; naturality is $H$
  preserving $\alpha$'s squares.

The two constructions are semantically different (one indexes into $\beta$, the
other transports $\alpha$) yet formally interchangeable, which is why the
notation treats them symmetrically. The **horizontal composite**
$\beta \ast \alpha : H \circ F \Rightarrow K \circ G$ is defined by either route
around the square below, and naturality of $\beta$ makes the routes agree:

$$
(\beta \ast \alpha)_A
\;=\; K(\alpha_A) \circ \beta_{F(A)}
\;=\; \beta_{G(A)} \circ H(\alpha_A).
$$

$$
% caption: Horizontal composition of $a = \alpha$ and $b = \beta$: two
% transformations across consecutive functor pairs compose to one across the
% composites; the square commutes by naturality, and its diagonal is the
% component of the composite at $A$.
\begin{tikzpicture}[scale=1.1, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (HF) at (0,1.9) {$H(F(A))$};
\node (HG) at (3.6,1.9) {$H(G(A))$};
\node (KF) at (0,0) {$K(F(A))$};
\node (KG) at (3.6,0) {$K(G(A))$};
\draw[->, acc, thick] (HF) -- (HG) node[midway, above] {$H(a_A)$};
\draw[->, acc, thick] (KF) -- (KG) node[midway, below] {$K(a_A)$};
\draw[->, black, thick] (HF) -- (KF) node[midway, left] {$b_{F(A)}$};
\draw[->, black, thick] (HG) -- (KG) node[midway, right] {$b_{G(A)}$};
\draw[->, black, thick] (HF) -- (KG);
\end{tikzpicture}
$$

Horizontal composition is associative, and it meshes with vertical composition
through the rule that organizes every calculation involving both:

> **Theorem (Interchange law).** For vertically composable pairs
> $\alpha, \beta$ and $\gamma, \delta$ arranged so that all composites make
> sense,
>
> $$
> (\delta \circ \gamma) \ast (\beta \circ \alpha)
> \;=\;
> (\delta \ast \beta) \circ (\gamma \ast \alpha).
> $$

Composing vertically then horizontally equals composing horizontally then
vertically. Godement codified this together with four bookkeeping rules for
mixing functors and transformations (e.g. $(H \circ G)\alpha = H(G\alpha)$ and
$\gamma(F \circ E) = (\gamma F)E$); all five reduce to the interchange law plus
whiskering-as-horizontal-composition with identities,
$\beta F = \beta \ast 1_F$ and $H\alpha = 1_H \ast \alpha$. The interchange law
is the defining coherence of a _2-category_ (objects, arrows, and arrows
between arrows), of which $\mathbf{CAT}$ is the founding example. We will not
develop 2-categories, but the law itself returns in the
[Godement-style computations with monads](/category-theory/monads-algebras/monads),
where $\mu$ and $\eta$ are natural transformations composed both ways at once.

## Combining categories, functors, and natural transformations

Category, functor, and natural transformation together support the constructions
of later modules:

- **Functor categories.** $[\mathcal{A}^{\mathrm{op}},
  \mathbf{Set}]$, the category of presheaves, is where
  [representable functors](/category-theory/representables-yoneda/representable-functors)
  live; the [Yoneda lemma](/category-theory/representables-yoneda/yoneda-lemma)
  computes its hom-sets out of representables.
- **Natural isomorphism as the right equality.** Statements like
  $\mathcal{D}(F A, B) \cong \mathcal{C}(A, G B)$ "naturally in $A$ and $B$" —
  the definition of an [adjunction](/category-theory/adjunctions/adjunctions) —
  only make sense with natural transformations in hand.
- **Limits in functor categories** are computed componentwise, one naturality
  square at a time, in
  [the limits module](/category-theory/limits-colimits/limits-and-functors).

[^lein-def]: **Leinster**, _Basic Category Theory_, §1.3, Definition 1.3.1 and the discrete-category motivation preceding it — components, the naturality square, and the exactly-one-arrow $F(A) \to G(A')$ bookkeeping of Remarks 1.3.2.
[^lein-det]: **Leinster**, §1.3, Example 1.3.5 — the determinant as a natural transformation $M_n \Rightarrow U$ between functors $\mathbf{CRing} \to \mathbf{Mon}$; naturality as "defined in the same way for all rings."
[^lein-dd]: **Leinster**, §1.3, Example 1.3.14 — the canonical evaluation map $V \to V^{\ast\ast}$ as a natural isomorphism from the identity to the double-dual functor on $\mathbf{FDVect}_k$.
[^lein-gset]: **Leinster**, §1.3, Example 1.3.4 — natural transformations between functors $G \to \mathbf{Set}$ recover the $G$-equivariant maps.
[^bw-lists]: **Barr & Wells**, _Category Theory for Computing Science_, §4.3.8 — flatten as a natural transformation from the list-of-lists functor to the list functor, and reduce from $F \circ U$ to the identity on $\mathbf{Mon}$.
[^lein-cat]: **Leinster**, §1.3, Construction 1.3.6 and Examples 1.3.7–1.3.9 — vertical composition, identity transformations, the functor category $[\mathcal{A}, \mathcal{B}]$, and the computations of $[\mathbf{2}, \mathcal{B}]$, $[G, \mathbf{Set}]$, and $[A, B]$ for ordered sets.
[^lein-natiso]: **Leinster**, §1.3, Definition 1.3.10, Lemma 1.3.11, and Example 1.3.13 — natural isomorphism as isomorphism in the functor category, the componentwise criterion, and the warning that pointwise isomorphism does not imply natural isomorphism.
[^bw-equiv]: **Barr & Wells**, §4.3.4 — a functor is an equivalence with pseudo-inverse $G$ iff $G \circ F$ and $F \circ G$ are naturally isomorphic to the identities.
[^bw-godement]: **Barr & Wells**, §4.4 — the Godement calculus: whiskerings $\beta F$ and $H\alpha$ (Definitions 4.4.2–4.4.3), horizontal composition and its associativity (4.4.4–4.4.6), and the five rules with the interchange law G-1.
