# 6. Interlude on categories and functors

Video (Definition 6.1 to Example 6.6)

###### Definition 6.1.

A category $\mathcal{C}$ consists of

• (a)

A class $\operatorname{obj}(\mathcal{C})$ of mathematical objects (such as groups, rings or metric spaces).

• (b)

For each pair of objects $A,B\in\operatorname{obj}(\mathcal{C})$, a set $\mathcal{C}(A,B)$ of morphisms from $A$ to $B$. We will write $f\colon A\to B$ or $A\xrightarrow{f}B$ to indicate that $f\in\mathcal{C}(A,B)$.

• (c)

For each object $A\in\operatorname{obj}(\mathcal{C})$, a morphism $\operatorname{id}_{A}\in\mathcal{C}(A,A)$ (called the identity morphism).

• (d)

A composition rule for morphisms. This should define, for every pair of morphisms $A\xrightarrow{f}B\xrightarrow{g}C$, a new morphism $g\circ f\colon A\to C$.

These must satisfy the following properties:

• (e)

For every morphism $f\colon A\to B$, we have $f\circ\operatorname{id}_{A}=f=\operatorname{id}_{B}\circ f$.

• (f)

For every triple of morphisms $A\xrightarrow{f}B\xrightarrow{g}C\xrightarrow{h}D$, we have $h\circ(g\circ f)=(h\circ g)\circ f$.

###### Example 6.2.

There is a category $\operatorname{Group}$ of groups. The objects are groups, and the morphisms are group homomorphisms. The identity morphism $\operatorname{id}_{G}$ is just the identity function $G\to G$, which is a group homomorphism by a trivial argument. The composition rule is just ordinary composition of functions. For this to be valid, we need to check that the composite of any two group homomorphisms is another group homomorphism, but this is easy. Properties (e) and (f) are also straightforward.

###### Remark 6.3.
• (a)

Most of our other examples will have the same nature: the objects will be sets with some kind of added structure, and the morphisms will be functions that preserve that structure in some sense. The only point of any real content will be to check that if we compose two structure-preserving maps, then the composite also preserves structure in the same sense.

• (b)

Two examples considered later will be a bit different: the category of topological spaces and homotopy classes of continuous functions, and the category of chain complexes and chain-homotopy classes of chain maps. In these examples we start with a category $\mathcal{C}$ as in (a), and define an equivalence relation on each morphism set $\mathcal{C}(A,B)$, and put $\overline{\mathcal{C}}(A,B)=\mathcal{C}(A,B)/\sim$. We then want to say that we have a new category with the same objects as $\mathcal{C}$ and morphism sets $\overline{\mathcal{C}}(A,B)$. For this to work, we need to check that the equivalence relations are compatible with composition in an appropriate sense. See Definition 9.9 for an example of this.

###### Example 6.4.

Some other algebraic categories:

• (a)

The category $\operatorname{Ab}$ of abelian groups and group homomorphisms. In abelian groups, we will always write the group operation as addition, the identity element as $0$ and the inverse of $a$ as $-a$. Thus, the morphisms from $A$ to $B$ are functions $\alpha\colon A\to B$ satisfying $\alpha(a_{0}+a_{1})=\alpha(a_{0})+\alpha(a_{1})$ for all $a_{0},a_{1}\in A$. (This implies $\alpha(0)=0$ and $\alpha(-a)=-\alpha(a)$, by standard arguments.)

• (b)

The category $\operatorname{Ring}$ of rings and ring homomorphisms.

• (c)

The categories $\operatorname{Vect}_{{\mathbb{Q}}}$, $\operatorname{Vect}_{{\mathbb{R}}}$ and $\operatorname{Vect}_{{\mathbb{C}}}$ of vector spaces over ${\mathbb{Q}}$, ${\mathbb{R}}$ and ${\mathbb{C}}$ respectively. In each case, the morphisms are maps that are linear over the relevant field.

• (d)

Underlying all of these, we have the category $\operatorname{Set}$: the objects are just sets, and the morphisms are just functions.

• (e)

We can also consider subcategories defined by various finiteness conditions. For example, we have the category $\operatorname{FAb}$: the objects are finite abelian groups, and the morphisms are just group homomorphisms between finite abelian groups.

In some sense, the main project of algebraic topology is to compare these algebraic categories with various topological categories.

###### Example 6.5.

We have a category $\operatorname{Metric}$: the objects are metric spaces, and the morphisms are continuous maps. To validate this, we need to know that composites of continuous maps are continuous, which is Proposition 3.24 above, or [MS, page 54]. It is sometimes also useful to consider a slightly different category $\operatorname{Metric}_{1}$: the objects are again metric spaces, but the morphisms are

 $\operatorname{Metric}_{1}(X,Y)=\{f\colon X\to Y\;|\;d(f(x),f(x^{\prime}))\leq d% (x,x^{\prime})\text{ for all }x,x^{\prime}\in X\}.$

It is straightforward to check that if $f\in\operatorname{Metric}_{1}(X,Y)$ and $g\in\operatorname{Metric}_{1}(Y,Z)$ then $g\circ f\in\operatorname{Metric}_{1}(X,Z)$, so this definition does indeed give a category. Lemma 3.5 tells us that $\operatorname{Metric}_{1}(X,Y)\subseteq\operatorname{Metric}(X,Y)$.

###### Example 6.6.

Similarly, there is a category $\operatorname{Top}$ whose objects are topological spaces, and whose morphisms are continuous maps.

We next need to discuss how to compare different categories. The key concept here is as follows:

Video (Definition 6.7 to Example 6.11)

###### Definition 6.7.

Let $\mathcal{C}$ and $\mathcal{D}$ be categories. A functor $F$ from $\mathcal{C}$ to $\mathcal{D}$ consists of

• (a)

A rule giving an object $FA\in\operatorname{obj}(\mathcal{D})$ for every object $A\in\operatorname{obj}(\mathcal{C})$; and

• (b)

A rule giving a morphism $Ff\in\mathcal{D}(FA,FA^{\prime})$ for each morphism $f\in\mathcal{C}(A,A^{\prime})$

such that

• (c)

For each $A\in\operatorname{obj}(\mathcal{C})$, we have $F(\operatorname{id}_{A})=\operatorname{id}_{FA}$

• (d)

For every pair of morphisms $A\xrightarrow{f}A^{\prime}\xrightarrow{f^{\prime}}A^{\prime\prime}$ in $\mathcal{C}$, we have $F(f^{\prime}\circ f)=F(f^{\prime})\circ F(f)\in\mathcal{D}(FA,FA^{\prime\prime})$. In other words, the following diagram should commute:

We will sometimes write $f_{*}$ (or $f_{\#}$ or $f_{\bullet}$ or some similar notation) instead of $Ff$.

###### Example 6.8.

For every topological space $X\in\operatorname{obj}(\operatorname{Top})$, we have a set $\pi_{0}(X)\in\operatorname{obj}(\operatorname{Set})$, as in Definition 5.10. For every continuous map $f\in\operatorname{Top}(X,Y)$, we have a function $f_{*}=\pi_{0}(f)\in\operatorname{Set}(\pi_{0}(X),\pi_{0}(Y))$, as in Proposition 5.20. The same proposition proves conditions (c) and (d) in Definition 6.7, so we have a functor $\pi_{0}\colon\operatorname{Top}\to\operatorname{Set}$.

###### Example 6.9.

For any metric space $X$, we let $TX$ denote the same set regarded as a topological space using the metric topology. If $f\in\operatorname{Metric}(X,Y)$ then $f$ is just a continuous map from $X$ to $Y$ and so can also be regarded as an element of $\operatorname{Top}(TX,TY)$. We define $Tf=f$. This gives a functor $T\colon\operatorname{Metric}\to\operatorname{Top}$.

###### Example 6.10.

For any set $X$, we have another set $PX=X\times{\mathbb{Z}}$. We would like to make this construction into a functor $P\colon\operatorname{Set}\to\operatorname{Set}$. Given a morphism $f\in\operatorname{Set}(X,Y)$ (i.e. a function $f\colon X\to Y$), we need to define a corresponding function $Pf\colon PX\to PY$, or in other words $Pf\colon X\times{\mathbb{Z}}\to Y\times{\mathbb{Z}}$. Thus, given a function $f\colon X\to Y$, a point $x\in X$ and a number $n\in{\mathbb{Z}}$, we need to define a point $(Pf)(x,n)\in Y\times{\mathbb{Z}}$. This must have the form $(Pf)(x,n)=(y,m)$ for some $y\in Y$ and $m\in{\mathbb{Z}}$. The only element of $Y$ that we can produce from these ingredients is $f(x)$, so we need to take $y=f(x)$. We must have $P(\operatorname{id}_{X})=\operatorname{id}\colon X\times{\mathbb{Z}}\to X% \times{\mathbb{Z}}$, so in the case $f=\operatorname{id}_{X}$ we need to take $m=n$, so the simplest thing is to take $m=n$ in all cases. We therefore arrive at the definition $(Pf)(x,n)=(f(x),n)$, or in other words $Pf=f\times\operatorname{id}_{{\mathbb{Z}}}\colon X\times{\mathbb{Z}}\to Y% \times{\mathbb{Z}}$. This gives

 $P(\operatorname{id}_{X})(x,n)=(\operatorname{id}_{X}(x),n)=(x,n)=\operatorname% {id}_{PX}(x,n).$

Also, if we have functions $X\xrightarrow{f}Y\xrightarrow{g}Z$, then

 $P(g)(P(f)(x,n))=P(g)(f(x),n)=(g(f(x)),n)=((g\circ f)(x),n)=P(g\circ f)(x,n).$

Thus, we have $P(\operatorname{id}_{X})=\operatorname{id}_{PX}$ and $P(g\circ f)=P(g)\circ P(f)$. We have therefore succeeded in defining a functor.

###### Example 6.11.

For any abelian group $A$ we note that the subset $DA=\{2a\;|\;a\in A\}$ is a subgroup of $A$. If $\alpha\colon A\to B$ is a homomorphism, then $\alpha(2a)=2\alpha(a)$ for all $a\in A$, so $\alpha(DA)\leq DB$, so we have a function $D\alpha=\alpha|_{DA}\colon DA\to DB$, which is again a homomorphism. It is easy to see that $D(\operatorname{id}_{A})=\operatorname{id}_{DA}$ and $D(\beta\circ\alpha)=(D\beta)\circ(D\alpha)$, so we have defined a functor $D\colon\operatorname{Ab}\to\operatorname{Ab}$. This satisfies $D({\mathbb{Z}}/2)=0$ and $D({\mathbb{Z}}/3)={\mathbb{Z}}/3$, for example. We can also define $QA=A/DA$. Given a coset $a+DA\in QA$, we would like to define $(Q\alpha)(a+DA)=\alpha(a)+DB\in QB$. This is well-defined, because if $a+DA=a^{\prime}+DA$ then $a^{\prime}-a\in DA$, so $\alpha(a^{\prime})-\alpha(a)=\alpha(a^{\prime}-a)\in\alpha(DA)\leq DB$, so $\alpha(a^{\prime})+DB=\alpha(a)+DB$. One can check that this gives a homomorphism $Q\alpha\colon QA\to QB$, and that $Q(\operatorname{id}_{A})=\operatorname{id}_{QA}$ and $Q(\beta\circ\alpha)=(Q\beta)\circ(Q\alpha)$. Thus, we have defined another functor $Q\colon\operatorname{Ab}\to\operatorname{Ab}$. This satisfies $Q({\mathbb{Z}}/2)\simeq{\mathbb{Z}}/2$ and $Q({\mathbb{Z}}/3)=0$, for example.

Video (Definition 6.12 to Corollary 6.18)

###### Definition 6.12.

Let $\mathcal{C}$ be a category, and let $f\colon X\to Y$ be a morphism in $\mathcal{C}$. An inverse for $f$ is a morphism $g\colon Y\to X$ such that $g\circ f=\operatorname{id}_{X}$ and $f\circ g=\operatorname{id}_{Y}$. We say that $f$ is an isomorphism if it has an inverse. We say that $X$ and $Y$ are isomorphic if there exists an isomorphism from $X$ to $Y$. We will usually write $X\simeq Y$ to indicate that $X$ and $Y$ are isomorphic.

###### Lemma 6.13.

If $f$ has an inverse, then it is unique.

###### Proof.

Let $g_{1}$ and $g_{2}$ be inverses for $f$. Then

 $g_{1}=g_{1}\circ\operatorname{id}_{Y}=g_{1}\circ(f\circ g_{2})=(g_{1}\circ f)% \circ g_{2}=\operatorname{id}_{X}\circ g_{2}=g_{2}.$

Because of the lemma, we can write $f^{-1}$ for the inverse of $f$ without creating any ambiguity.

###### Example 6.14.

In the category $\operatorname{Group}$, the isomorphisms are just group isomorphisms as usually defined in abstract algebra. In the category $\operatorname{Set}$, the isomorphisms are just bijections. In the categories $\operatorname{Metric}$ and $\operatorname{Top}$, the isomorphisms are homeomorphisms.

###### Proposition 6.15.
• (a)

For every object $X\in\mathcal{C}$, the identity morphism $\operatorname{id}_{X}$ is an isomorphism.

• (b)

If $f\colon X\to Y$ is an isomorphism, then so is $f^{-1}\colon Y\to X$.

• (c)

If $f\colon X\to Y$ and $g\colon Y\to Z$ are isomorphisms, then so is $g\circ f\colon X\to Z$.

###### Proof.
• (a)

$\operatorname{id}_{X}$ is an inverse for itself.

• (b)

$f$ is an inverse for $f^{-1}$.

• (c)

$f^{-1}\circ g^{-1}$ is an inverse for $g\circ f$.

###### Corollary 6.16.

Let $X$, $Y$ and $Z$ be objects in a category $\mathcal{C}$.

• (a)

$X\simeq X$

• (b)

If $X\simeq Y$ then $Y\simeq X$

• (c)

If $X\simeq Y$ and $Y\simeq Z$ then $X\simeq Z$.

###### Proof.

Immediate from the proposition. ∎

###### Proposition 6.17.

Let $F\colon\mathcal{C}\to\mathcal{D}$ be a functor, and let $f\colon X\to Y$ be an isomorphism in $\mathcal{C}$. Then the morphism $Ff\colon FX\to FY$ is an isomorphism in $\mathcal{D}$, with inverse $F(f^{-1})$.

###### Proof.

By the definition of an inverse, we have $f^{-1}\circ f=\operatorname{id}_{X}$ and $f\circ f^{-1}=\operatorname{id}_{Y}$. Using the functor axioms we obtain

 $\displaystyle F(f^{-1})\circ Ff$ $\displaystyle=F(f^{-1}\circ f)=F(\operatorname{id}_{X})=\operatorname{id}_{FX}$ $\displaystyle Ff\circ F(f^{-1})$ $\displaystyle=F(f\circ f^{-1})=F(\operatorname{id}_{Y})=\operatorname{id}_{FY}.$

These prove that $F(f^{-1})$ is an inverse for $Ff$, as required. ∎

###### Corollary 6.18.

Let $F\colon\mathcal{C}\to\mathcal{D}$ be a functor, and let $X$ and $Y$ be objects of $\mathcal{C}$. If $X\simeq Y$ in $\mathcal{C}$, then $FX\simeq FY$ in $\mathcal{D}$.

###### Proof.

Immediate from the proposition. ∎

Video (Definition 6.19 to Proposition 6.26)

We will also need a weaker concept, which is only half as good as being isomorphic.

###### Definition 6.19.

Let $X$ and $Y$ be objects in a category $\mathcal{C}$. We say that $X$ is a retract of $Y$ if there exist morphisms $X\xrightarrow{f}Y\xrightarrow{g}X$ with $g\circ f=\operatorname{id}_{X}$. (We make no assumption about $f\circ g$.) Any pair $(f,g)$ with this property will be called a retraction pair for $(X,Y)$.

###### Example 6.20.

Let $G$ and $H$ be groups. We can define homomorphisms

 $G\xrightarrow{j}G\times H\xrightarrow{q}G$

by $j(g)=(g,1)$ and $q(g,h)=g$. These satisfy $q\circ j=\operatorname{id}_{G}$, so $G$ is a retract of $G\times H$ in $\operatorname{Group}$.

###### Example 6.21.

We can define continuous maps $S^{2}\xrightarrow{f}{\mathbb{R}}^{3}\setminus\{0\}\xrightarrow{g}S^{2}$ by $f(u)=u$ and $g(v)=v/\|v\|$. These satisfy $g\circ f=\operatorname{id}_{S^{2}}$, so $S^{2}$ is a retract of ${\mathbb{R}}^{3}\setminus\{0\}$ in $\operatorname{Top}$.

###### Example 6.22.

Let $X$ and $Y$ be nonempty finite sets with $|X|\leq|Y|$. We claim that $X$ is a retract of $Y$ in the category $\operatorname{Set}$. Indeed, we can list the elements as $X=\{x_{1},\dotsc,x_{n}\}$ and $Y=\{y_{1},\dotsc,y_{m}\}$ with $1\leq n\leq m$. We can then define $f\colon X\to Y$ by $f(x_{i})=y_{i}$. In the opposite direction, we define $g\colon Y\to X$ by

 $g(y_{i})=\begin{cases}x_{i}&\text{ if }1\leq i\leq n\\ x_{n}&\text{ if }n

We then have $g\circ f=\operatorname{id}_{X}$, as required.

We will mostly be interested in cases where we can prove that $X$ is not a retract of $Y$. The main tool for this is as follows:

###### Proposition 6.23.

Let $\mathcal{C}$ be a category in which the objects are sets with extra structure, and the morphisms are the functions that preserve that structure. (This covers all the examples that we have discussed so far.) Let $(f,g)$ be a retraction pair in $\mathcal{C}$. Then $f$ is injective, and $g$ is surjective.

###### Proof.

We can ignore the structure-preserving properties of $f$ and $g$; we just need to know that we have functions $f\colon X\to Y$ and $g\colon Y\to X$ satisfying $g(f(x))=x$ for all $x\in X$. In particular, this shows that $x$ can be written as $g(y)$ for some $y$ (namely $y=f(x)$), so $g$ is surjective. Now suppose we have $x,x^{\prime}\in X$ with $f(x)=f(x^{\prime})$. By applying $g$ to both sides we obtain $g(f(x))=g(f(x^{\prime}))$, but $g(f(x))=x$ and $g(f(x^{\prime}))=x^{\prime}$ so we get $x=x^{\prime}$. This proves that $f$ is injective. ∎

###### Corollary 6.24.

Let $G$ and $H$ be groups.

• (a)

If $G$ is nonabelian and $H$ is abelian, then $G$ is not a retract of $H$.

• (b)

If $G$ is infinite and $H$ is finite, then $G$ is not a retract of $H$.

• (c)

If $G\simeq{\mathbb{Z}}/2$ and $H\simeq{\mathbb{Z}}$, then $G$ is not a retract of $H$.

###### Proof.

Suppose that $G\xrightarrow{j}H\xrightarrow{q}G$ is a retraction pair. Then $j$ is injective, so $G$ is isomorphic to $j(G)$, which is a subgroup of $H$. By the contrapositive, if $G$ is not isomorphic to any subgroup of $H$, then $G$ cannot be a retract of $H$. In case (a), every subgroup of $H$ is abelian, so $G$ cannot be isomorphic to any subgroup of $H$. In case (b), every subgroup of $H$ is finite, so $G$ cannot be isomorphic to any subgroup of $H$. In case (c), the group $G$ contains an element of order precisely two, but all elements of ${\mathbb{Z}}$ have order $1$ or $\infty$, so again $G$ cannot be isomorphic to any subgroup of $H$. ∎

###### Proposition 6.25.

Let $F\colon\mathcal{C}\to\mathcal{D}$ be a functor, and let $X$ and $Y$ be objects of $\mathcal{C}$. If $X$ is a retract of $Y$ in $\mathcal{C}$, then $FX$ is a retract of $FY$ in $\mathcal{D}$. Thus, by the contrapositive, if $FX$ is not a retract of $FY$, then $X$ cannot be a retract of $Y$.

###### Proof.

If $X$ is a retract of $Y$, then we can choose a retraction pair $X\xrightarrow{f}Y\xrightarrow{g}X$ with $g\circ f=\operatorname{id}_{X}$. This gives maps $FX\xrightarrow{Ff}FY\xrightarrow{Fg}FX$ with $Fg\circ Ff=F(g\circ f)=F(\operatorname{id}_{X})=\operatorname{id}_{FX}$, proving that $FX$ is a retract of $FY$. ∎

As a basic example of how this can be used, we have the following:

###### Proposition 6.26.

Let $X$ and $Y$ be topological spaces such that $|\pi_{0}(Y)|$ is finite and $|\pi_{0}(X)|>|\pi_{0}(Y)|$. Then $X$ is not a retract of $Y$.

###### Proof.

If $X$ was a retract of $Y$, then $\pi_{0}(X)$ would be a retract of $\pi_{0}(Y)$, so in particular, we would have an injective function $f_{*}\colon\pi_{0}(X)\to\pi_{0}(Y)$. This is impossible because $|\pi_{0}(X)|>|\pi_{0}(Y)|$. ∎