\chapter{Bonus: Cellular homology}
We now introduce cellular homology, which essentially lets us compute
the homology groups of any CW complex we like.

\section{Degrees}
\prototype{$z \mapsto z^d$ has degree $d$.}
For any $n > 0$ and map $f : S^n \to S^n$, consider
\[ f_\ast : \underbrace{H_n(S^n)}_{\cong \ZZ} \to \underbrace{H_n(S^n)}_{\cong \ZZ} \]
which must be multiplication by some constant $d$.
This $d$ is called the \vocab{degree} of $f$, denoted $\deg f$.
\begin{ques}
	Show that $\deg(f \circ g) = \deg(f) \deg(g)$.
\end{ques}

\begin{example}
	[Degree]
	\listhack
	\begin{enumerate}[(a)]
		\ii For $n=1$, the map $z \mapsto z^k$ (viewing $S^1 \subseteq \CC$)
		has degree $k$.
		\ii A reflection map $(x_0, x_1, \dots, x_n) \mapsto (-x_0, x_1, \dots, x_n)$
		has degree $-1$; we won't prove this, but geometrically this should be clear.
		\ii The antipodal map $x \mapsto -x$ has degree $(-1)^{n+1}$
		since it's the composition of $n+1$ reflections as above.
		We denote this map by $-\id$.
	\end{enumerate}
\end{example}

Obviously, if $f$ and $g$ are homotopic, then $\deg f = \deg g$.
In fact, a theorem of Hopf says that this is a classifying invariant:
anytime $\deg f = \deg g$, we have that $f$ and $g$ are homotopic.

One nice application of this:
\begin{theorem}
	[Hairy ball theorem]
	If $n > 0$ is even, then $S^n$ doesn't have a continuous field
	of nonzero tangent vectors.
\end{theorem}
\begin{proof}
	If the vectors are nonzero then WLOG they have norm $1$;
	that is for every $x$ we have an orthogonal unit vector $v(x)$.
	Then we can construct a homotopy map $F : S^n \times [0,1] \to S^n$ by
	\[ (x,t) \mapsto (\cos \pi t)x + (\sin \pi t) v(x). \]
	which gives a homotopy from $\id$ to $-\id$.
	So $\deg(\id) = \deg(-\id)$, which means $1 = (-1)^{n+1}$
	so $n$ must be odd.
\end{proof}
Of course, the one can construct such a vector field whenever $n$ is odd.
For example, when $n=1$ such a vector field is drawn below.
\begin{center}
	\begin{asy}
		size(5cm);
		draw(unitcircle, blue+1);
		label("$S^1$", dir(100), dir(100), blue);
		void arrow(real theta) {
			pair P = dir(theta);
			dot(P);
			pair delta = 0.8*P*dir(90);
			draw( P--(P+delta), EndArrow );
		}
		arrow(0);
		arrow(50);
		arrow(140);
		arrow(210);
		arrow(300);
	\end{asy}
\end{center}


\section{Cellular chain complex}
Before starting, we state:
\begin{lemma}
	[CW homology groups]
	Let $X$ be a CW complex. Then
	\begin{align*}
		H_k(X^n, X^{n-1}) &\cong
		\begin{cases}
			\ZZ^{\oplus\text{\#$n$-cells of $X$}} & k = n \\
			0 & \text{otherwise}.
		\end{cases} \\
		\intertext{and}
		H_k(X^n) &\cong
		\begin{cases}
			H_k(X) & k \le n-1 \\
			0 & k \ge n+1.
		\end{cases}
	\end{align*}
\end{lemma}
\begin{proof}
	% I'll prove just the case where $X$ is finite-dimensional as usual.
	The first part is immediate by noting that $(X^n, X^{n-1})$ is a good pair
	and $X^n/X^{n-1}$ is a wedge sum of two spheres.
	For the second part, fix $k$ and note that, as long as $n \le k-1$ or $n \ge k+2$,
	\[
		\underbrace{H_{k+1}(X^n, X^{n-1})}_{=0}
		\to H_k(X^{n-1})
		\to H_k(X^n)
		\to \underbrace{H_{k}(X^n, X^{n-1})}_{=0}.
	\]
	So we have isomorphisms
	\[ H_k(X^{k-1}) \cong H_k(X^{k-2}) \cong \dots \cong H_k(X^0) = 0 \]
	and
	\[ H_k(X^{k+1}) \cong H_k(X^{k+2}) \cong \dots \cong H_k(X). \qedhere \]
\end{proof}

So, we know that the groups $H_k(X^k, X^{k-1})$ are super nice:
they are free abelian with basis given by the cells of $X$.
So, we give them a name:
\begin{definition}
	For a CW complex $X$, we define
	\[ \Cells_k(X) = H_k(X^k, X^{k-1}) \]
	where $\Cells_0(X) = H_0(X^0, \varnothing) = H_0(X^0)$ by convention.
	So $\Cells_k(X)$ is an abelian group with basis given by
	the $k$-cells of $X$.
\end{definition}

Now, using $\Cells_k = H_k(X^k, X^{k-1})$ let's use
our long exact sequence and try to string together maps between these.
Consider the following diagram.

\begin{center}
\newcommand{\CX}[1]{\boxed{\color{blue}\Cells_{#1}(X)}}
\begin{tikzcd}[column sep=tiny]
	& \underbrace{H_3(X^2)}_{=0} \ar[d, "0"] \\
	\CX{4} \ar[r, "\partial_4"] \ar[rd, "d_4", blue]
		& H_3(X^3) \ar[r, two heads] \ar[d, "0"]
		& \underbrace{H_3(X^4)}_{\cong H_3(X)} \ar[r, "0"]
		& \underbrace{H_3(X^4, X^3)}_{= 0} \\
	& \CX{3} \ar[d, "\partial_3"] \ar[rd, "d_3", blue]
		&& \underbrace{H_1(X^0)}_{=0} \ar[d, "0"] \\
	\underbrace{H_2(X^1)}_{=0} \ar[r, "0"]
		& H_2(X^2) \ar[r, hook] \ar[d, two heads]
		& \CX{2} \ar[r, "\partial_2"] \ar[rd, "d_2", blue]
		& H_1(X^1) \ar[r, two heads]
		& \underbrace{H_1(X^2)}_{\cong H_1(X)} \ar[r, "0"]
		& \underbrace{H_1(X^2, X^1)}_{=0} \\
	& \underbrace{H_2(X^3)}_{\cong H_2(X)} \ar[d, "0"]
		&& \CX{1} \ar[d, "\partial_1"] \ar[rd, "d_1", blue] \\
	& \underbrace{H_2(X^3, X^2)}_{=0}
		& \underbrace{H_0(\varnothing)}_{=0} \ar[r, "0"]
		& H_0(X^0) \ar[r, hook] \ar[d, two heads]
		& \CX{0} \ar[r, "\partial_0"]
		& \dots \\
	&&& \underbrace{H_0(X^1)}_{\cong H_0(X)} \ar[d, "0"] \\
	&&& \underbrace{H_0(X^1, X^0)}_{=0}
\end{tikzcd}
\end{center}

The idea is that we have taken all the exact sequences generated by adjacent
skeletons, and strung them together at the groups $H_k(X^k)$,
with half the exact sequences being laid out vertically
and the other half horizontally.

In that case, composition generates a sequence of dotted maps
between the $H_k(X^k, X^{k-1})$ as shown.
\begin{ques}
	Show that the composition of two adjacent dotted arrows is zero.
\end{ques}

So from the diagram above, we can read off a sequence of arrows
\[
	\dots \taking{d_5} \Cells_4(X)  \taking{d_4} \Cells_3(X)
	\taking{d_3} \Cells_2(X) \taking{d_2} \Cells_1(X)
	\taking{d_1} \Cells_0(X) \taking{d_0} 0.
\]
This is a chain complex, called the \vocab{cellular chain complex};
as mentioned before before all the homology groups are free,
but these ones are especially nice because for most reasonable CW complexes,
they are also finitely generated
(unlike the massive $C_\bullet(X)$ that we had earlier).
In other words, the $H_k(X^k, X^{k-1})$ are especially nice ``concrete'' free groups
that one can actually work with.

The other reason we care is that in fact:
\begin{theorem}[Cellular chain complex gives $H_n(X)$]
	\label{thm:cellular_chase}
	The $k$th homology group of the cellular chain complex
	is isomorphic to $H_k(X)$.
\end{theorem}
\begin{proof}
	Follows from the diagram; \Cref{prob:diagram_chase}.
\end{proof}

A nice application of this is to define
the \vocab{Euler characteristic} of a finite CW complex $X$.
Of course we can write
\[ \chi(X) = \sum_n (-1)^n \cdot \#(\text{$n$-cells of $X$}) \]
which generalizes the familiar $V-E+F$ formula.
However, this definition is unsatisfactory because it
depends on the choice of CW complex, while we actually
want $\chi(X)$ to only depend on the space $X$ itself
(and not how it was built). In light of this, we prove that:
\begin{theorem}
	[Euler characteristic via Betti numbers]
	For any finite CW complex $X$ we have
	\[ \chi(X) = \sum_n (-1)^n \rank H_n(X). \]
\end{theorem}
Thus $\chi(X)$ does not depend on the choice of CW decomposition.
The numbers
\[ b_n = \rank H_n(X) \]
are called the \vocab{Betti numbers} of $X$.
In fact, we can use this to define $\chi(X)$ for any reasonable space;
we are happy because in the (frequent) case that $X$ is a CW complex,

\begin{proof}
	We quote the fact that if $0 \to A \to B \to C \to D \to 0$
	is exact then $\rank B + \rank D = \rank A + \rank C$.
	Then for example the row
	\begin{center}
	\begin{tikzcd}
		\underbrace{H_2(X^1)}_{=0} \ar[r, "0"] & H_2(X^2) \ar[r, hook] &
		H_2(X^2, X^1) \ar[r, "\partial_2"] & H_1(X^1) \ar[r, two heads] &
		\underbrace{H_1(X^2)}_{\cong H_1(X)} \ar[r, "0"]
		& \underbrace{H_1(X^2, X^1)}_{=0}
	\end{tikzcd}
	\end{center}
	from the cellular diagram gives
	\[ \#(\text{$2$-cells}) + \rank H_1(X)
		= \rank H_2(X^2) + \rank H_1(X^1). \]
	More generally,
	\[ \#(\text{$k$-cells}) + \rank H_{k-1}(X)
		= \rank H_k(X^k) + \rank H_{k-1}(X^{k-1}) \]
	which holds also for $k=0$ if we drop the $H_{-1}$ terms
	(since $\#\text{$0$-cells} = \rank H_0(X^0)$ is obvious).
	Multiplying this by $(-1)^k$ and summing across $k \ge 0$
	gives the conclusion.
\end{proof}

\begin{example}
	[Examples of Betti numbers]
	\listhack
	\begin{enumerate}[(a)]
		\ii The Betti numbers of $S^n$ are $b_0 = b_n = 1$,
		and zero elsewhere. The Euler characteristic is $1 + (-1)^n$.
		\ii The Betti numbers of a torus $S^1 \times S^1$
		are $b_0 = 1$, $b_1 = 2$, $b_2 = 1$, and zero elsewhere.
		Thus the Euler characteristic is $0$.
		\ii The Betti numbers of $\CP^n$ are $b_0 = b_2 = \dots = b_{2n} = 1$,
		and zero elsewhere. Thus the Euler characteristic is $n+1$.
		\ii The Betti numbers of the Klein bottle
		are $b_0 = 1$, $b_1 = 1$ and zero elsewhere.
		Thus the Euler characteristic is $0$, the same as the sphere
		(also since their CW structures use the same number of cells).
	\end{enumerate}
	One notices that in the ``nice'' spaces $S^n$, $S^1 \times S^1$ and $\CP^n$
	there is a nice symmetry in the Betti numbers, namely $b_k = b_{n-k}$.
	This is true more generally; see Poincar\'e duality and \Cref{prob:betti}.
\end{example}

\section{The cellular boundary formula}
In fact, one can describe explicitly what the maps $d_n$ are.
Recalling that $H_k(X^k, X^{k-1})$ has a basis the $k$-cells of $X$, we obtain:
\begin{theorem}
	[Cellular boundary formula for $k=1$]
	For $k=1$, \[ d_1 : \Cells_1(X) \to \Cells_0(X) \] is just the boundary map.
\end{theorem}
\begin{theorem}
	[Cellular boundary for $k > 1$]
	Let $k > 1$ be a positive integer.
	Let $e^k$ be an $k$-cell, and let $\{e_\beta^{k-1}\}_\beta$
	denote all $(k-1)$-cells of $X$.
	Then \[ d_k : \Cells_k(X) \to \Cells_{k-1}(X) \]
	is given on basis elements by
	\[ d_k(e^k) = \sum_\beta d_\beta e_\beta^{k-1} \]
	where $d_\beta$ is be the degree of the composed map
	\[ S^{k-1} = \partial D_\beta^k \xrightarrow{\text{attach}}
		X^{k-1} \surjto S_\beta^{k-1}. \]
	Here the first arrow is the attaching map for $e^k$
	and the second arrow is the quotient of collapsing
	$X^{k-1} \setminus e^{k-1}_\beta$ to a point.
\end{theorem}
This gives us an algorithm for computing homology groups of a CW complex:
\begin{itemize}
	\ii Construct the cellular chain complex,
	where $\Cells_k(X)$ is $\ZZ^{\oplus \# \text{$k$-cells}}$.
	\ii $d_1 : \Cells_1(X) \to \Cells_0(X)$ is just the boundary map
	(so $d_1(e^1)$ is the difference of the two endpoints).
	\ii For any $k > 1$, we compute $d_k : \Cells_k(X) \to \Cells_{k-1}(X)$
	on basis elements as follows.
	Repeat the following for each $k$-cell $e^k$:
	\begin{itemize}
		\ii For every $k-1$ cell $e^{k-1}_\beta$,
		compute the degree of the boundary of $e^k$ welded onto
		the boundary of $e^{k-1}_\beta$, say $d_\beta$.
		\ii Then $d_k(e^k) = \sum_\beta d_\beta e^{k-1}_\beta$.
	\end{itemize}
	\ii Now we have the maps of the cellular chain complex,
	so we can compute the homologies directly
	(by taking the quotient of the kernel by the image).
\end{itemize}

We can use this for example to compute the homology groups of the torus again,
as well as the Klein bottle and other spaces.

\begin{example}
	[Cellular homology of a torus]
	Consider the torus built from $e^0$, $e^1_a$, $e^1_b$ and $e^2$ as before,
	where $e^2$ is attached via the word $aba\inv b\inv$.
	For example, $X^1$ is
	\begin{center}
		\begin{asy}
			unitsize(0.8cm);
			draw(shift(-1,0)*unitcircle, blue, MidArrow);
			draw(shift(1,0)*rotate(180)*unitcircle, red, MidArrow);
			label("$e^1_a$", 2*dir(180), dir(180), blue);
			label("$e^1_b$", 2*dir(0), dir(0), red);
			dotfactor *= 1.4;
			dot("$e^0$", origin, dir(0));
		\end{asy}
	\end{center}
	The cellular chain complex is
	\begin{center}
	\begin{tikzcd}
		0 \ar[r]
			& \ZZ e^2 \ar[r, "d_2"]
			& \ZZ e^1_a \oplus \ZZ e^1_b \ar[r, "d_1"]
			& \ZZ e^0 \ar[r, "d_0"]
			& 0
	\end{tikzcd}
	\end{center}
	Now apply the cellular boundary formulas:
	\begin{itemize}
		\ii Recall that $d_1$ was the boundary formula.
		We have $d_1(e^1_a) = e_0 - e_0 = 0$ and similarly $d_1(e^1_b) = 0$.
		So $d_1 = 0$.

		\ii For $d_2$, consider the image of the boundary $e^2$ on $e^1_a$.
		Around $X^1$, it wraps once around $e^1_a$, once around $e^1_b$,
		again around $e^1_a$ (in the opposite direction),
		and again around $e^1_b$.
		Once we collapse the entire $e^1_b$ to a point,
		we see that the degree of the map is $0$.
		So $d_2(e^2)$ has no $e^1_a$ coefficient.
		Similarly, it has no $e^1_b$ coefficient, hence $d_2 = 0$.
	\end{itemize}
	Thus \[ d_1=d_2=0. \]
	So at every map in the complex, the kernel of the map
	is the whole space while the image is $\{0\}$.
	So the homology groups are $\ZZ$, $\ZZ^{\oplus 2}$, $\ZZ$.
\end{example}
\begin{example}
	[Cellular homology of the Klein bottle]
	Let $X$ be a Klein bottle.
	Consider cells $e^0$, $e^1_a$, $e^1_b$ and $e^2$ as before,
	but this time $e^2$ is attached via the word $abab\inv$.
	So $d_1$ is still zero, but this time we have
	$d_2(e^2) = 2e^1_a$ instead (why?).
	So our diagram looks like
	\begin{center}
	\begin{tikzcd}[row sep = tiny]
		0 \ar[r, "0"]
			& \ZZ e^2 \ar[r, "d_2"]
			& \ZZ e^1_a \oplus \ZZ e^1_b \ar[r, "d_1"]
			& \ZZ e^0 \ar[r, "d_0"] & 0 \\
		& e^2 \ar[r, mapsto] & 2e^1_a \\
		&& e_1^a \ar[r, mapsto] & 0 && \\
		&& e_1^b \ar[r, mapsto] & 0
	\end{tikzcd}
	\end{center}
	So we get that $H_0(X) \cong \ZZ$,
	but \[ H_1(X) \cong \ZZ \oplus \Zc2 \] this time
	(it is $\ZZ^{\oplus 2}$ modulo a copy of $2\ZZ$).
	Also, $\ker d_2 = 0$, and so now $H_2(X) = 0$.
\end{example}

\section\problemhead
\begin{dproblem}
	Let $n$ be a positive integer.
	Show that
	\[
		H_k(\CP^n) \cong
		\begin{cases}
			\ZZ & k=0,2,4,\dots,2n \\
			0 & \text{otherwise}.
		\end{cases}
	\]
	\begin{hint}
		$\CP^n$ has no cells in adjacent dimensions,
		so all $d_k$ maps must be zero.
	\end{hint}
\end{dproblem}

\begin{problem}
	Show that a non-surjective map $f : S^n \to S^n$ has degree zero.
	\begin{hint}
		The space $S^n - \{x_0\}$ is contractible.
	\end{hint}
\end{problem}

\begin{problem}[Moore spaces]
	\gim
	Let $G_1$, $G_2$, \dots, $G_N$ be a sequence of
	finitely generated abelian groups.
	Construct a space $X$ such that
	\[
		\wt H_n(X)
		\cong
		\begin{cases}
			G_n & 1 \le n \le N \\
			0 & \text{otherwise}.
		\end{cases}
	\]
\end{problem}

\begin{problem}
	\label{prob:diagram_chase}
	Prove \Cref{thm:cellular_chase},
	showing that the homology groups of $X$
	coincide with the homology groups of the cellular chain complex.
	\begin{hint}
		You won't need to refer to any elements.
		Start with \[ H_2(X) \cong H_2(X^3) \cong
			H_2(X^2) / \ker \left[ H_2(X^2) \surjto H_2(X^3) \right], \] say.
		Take note of the marked injective and surjective arrows.
	\end{hint}
	\begin{sol}
		For concreteness, let's just look at the homology at $H_2(X^2, X^1)$
		and show it's isomorphic to $H_2(X)$.
		According to the diagram
		\begin{align*}
			H_2(X) &\cong H_2(X^3) \\
			&\cong H_2(X^2) / \ker \left[ H_2(X^2) \surjto H_2(X^3) \right] \\
			&\cong H_2(X^2) / \img \partial_3 \\
			&\cong \img\left[ H_2(X^2) \injto H_2(X^2, X^1) \right] / \img \partial_3 \\
			&\cong \ker(\partial_2) / \img\partial_3 \\
			&\cong \ker d_2 / \img d_3. \qedhere
		\end{align*}
	\end{sol}
\end{problem}

\begin{dproblem}
	\gim
	Let $n$ be a positive integer. Show that
	\[
		H_k(\RP^n)
		\cong
		\begin{cases}
			\ZZ & \text{if $k=0$ or $k=n\equiv 1 \pmod 2$} \\
			\Zc2 & \text{if $k$ is odd and $0 < k < n$} \\
			0 & \text{otherwise}.
		\end{cases}
	\]
	\begin{hint}
		There is one cell of each dimension.
		Show that the degree of $d_k$ is $\deg(\id)+\deg(-\id)$,
		hence $d_k$ is zero or $\cdot 2$ depending
		on whether $k$ is even or odd.
	\end{hint}
\end{dproblem}
