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

\section{Degrees}
\label{sec:homology_degrees}
\prototype{$z \mapsto z^d$ has degree $d$.}
For any $n > 0$ and map $f \colon S^n \to S^n$, consider
\[ f_\ast \colon \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}

As we mentioned in \Cref{ex:homology_group_sphere}, roughly speaking:
\begin{moral}
	$\deg f$ counts how many times $\img f$ wraps around $S^n$.
\end{moral}
Or, it counts how many ``$S^n$ bags'' that $\img f$ consists of.

\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 \colon 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, 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})$ satisfies the hypothesis of
\Cref{thm:good_pair}, so $H_k(X^n, X^{n-1}) \cong \wt H_k(X^n/X^{n-1})$,
	and $X^n/X^{n-1}$ is a wedge sum of several $n$-spheres.

	For an example, for $n = 2$ (the ``spheres'' are drawn as a balloon-shaped blob here):
	\begin{center}
	\begin{asy}
		pair A=(3, -1);
		path blob=(0, 0){right}..(2, 2)..{down}cycle;
		fill(shift(A)*blob, lightcyan);
		label("$X/A$", A+(-1, 1));
		fill(shift(A)*reflect(origin, (0, 1))*blob, lightgreen);
		dot(A, red, L=Label("$A/A$", align=S));
		label("$\longrightarrow$");
		pair B=(-2.6, 0);
		filldraw(B+(0, 1)--B+(0, -1)--B+(sqrt(3), 0)--cycle, lightcyan, red+1.5);
		label("$X$", B+(-0.5, 0));
		label("$A$", B+(1.2, 0.9), red);
		filldraw(B+(0, 1)--B+(0, -1)--B+(-sqrt(3), 0)--cycle, lightgreen, red+1.5);
	\end{asy}
	\end{center}

	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, surjective head] \ar[d, hook]
		& \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, surjective head]
		& \CX{2} \ar[r, "\partial_2"] \ar[rd, "d_2", blue]
		& H_1(X^1) \ar[r, surjective head] \ar[d, hook]
		& \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, surjective head]
		& \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 blue maps
between the $H_k(X^k, X^{k-1})$ as shown.
\begin{ques}
	Show that the composition of two adjacent blue 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 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}

\section{Digression: why are the homology groups equal?}
\label{sec:homology_group_equal}

There is another intuition that explains it --- roughly speaking,
\[
	H_k(\Cells_\bullet(X))
	= \frac{\text{aligned cycle}}{\text{aligned boundary}}
	= \frac{\text{aligned cycle} \times \text{fuzz}}{\text{aligned boundary} \times \text{fuzz}}
	= \frac{\text{cycle}}{\text{boundary}}
	= H_k(X). \]
Let me explain. Consider a CW-complex $X$ that looks like the following, where $X^1$ is drawn in
red. Each blue region corresponds to a $2$-cell.
\begin{center}
\begin{asy}
	size(5cm);
	for(int i=0; i<4; ++i){
		filldraw(rotate(i*90)*((3, -3)--(3, 3)--(1, 1)--(1, -1)--cycle), lightcyan, lightred+1.5);
		draw(rotate(i*90)*((1, -1)--(3, 3)), lightred+1.5);
	}
	label("$X$", (2.5, -1));
	label("$X^1$", (3, 3), lightred, align=SE);
\end{asy}
\end{center}
Then, look at the following figure.
\begin{center}
\begin{asy}
	size(13cm);

	void drawx(transform t){
		for(int i=0; i<4; ++i){
			filldraw(t*rotate(i*90)*((3, -3)--(3, 3)--(1, 1)--(1, -1)--cycle), lightcyan, lightred+1.5);
			draw(t*rotate(i*90)*((1, -1)--(3, 3)), lightred+1.5);
		}
	}
	transform t=identity;
	void drawarrow(path p){
		draw(t*p, linewidth(1.5), Arrow(size=5));
	}
	drawx(t);
	drawarrow((-3, 3)--(1, 1)--(1, -0.3));
	drawarrow((-1, -1)--(0.7, -1));
	label("$C_1(X^1)$", t*(0, -3), align=S);

	t=shift(8, 0);
	drawx(t);
	drawarrow((-3, 3)--(1, 1));
	path tmp=(-1, -1)--(3, -3);
	pair d=dir(tmp);
	drawarrow((point(tmp, 0.2)){d*dir(20)}..{d*dir(-20)}(point(tmp, 0.8)){-d*dir(20)}..{-d*dir(-20)}cycle);
	label("$Z_1(X^1, X^0)$", t*(0, -3), align=S);

	t=shift(8, 0)*t;
	drawx(t);
	drawarrow((point(tmp, 0.2)){d*dir(20)}..{d*dir(-20)}(point(tmp, 0.8)){-d*dir(20)}..{-d*dir(-20)}cycle);
	label("$B_1(X^1, X^0)$", t*(0, -3), align=S);

	t=shift(8, 0)*t;
	drawx(t);
	drawarrow((-3, 3)--(1, 1));
	label("$\operatorname{Cells}_1(X)$", t*(0, -3), align=S);

	t=shift(-23, -8.5)*t;
	drawx(t);
	drawarrow((-3, 3)--(1, 1)--(1, -1)--(-1, -1)--(-3, -3)--cycle);
	label("$\ker(\operatorname{Cells}_1(X) \to \operatorname{Cells}_0(X))$", t*(0, -3), align=S);

	t=shift(12, 0)*t;
	drawx(t);
	drawarrow((-3, 3)--(1, 1)--(-1, 1)--(-1, -1)--(-3, -3)--cycle);
	label("$\operatorname{im}(\operatorname{Cells}_2(X) \to \operatorname{Cells}_1(X))$", t*(0, -3), align=S);

	t=shift(10, 0)*t;
	drawx(t);
	drawarrow((-1, 1)--(1, 1)--(1, -1)--(-1, -1)--cycle);
	label("$H_1(\operatorname{Cells}_\bullet(X))$", t*(0, -3), align=S);
\end{asy}
\end{center}

It looks like a lot, so let me explain.
\begin{itemize}
	\ii The first picture depicts a typical element of $C_1(X^1)$ --- that is, a $1$-chain that is
	contained in $X^1$, being the formal sum of two
	maps from $\Delta^1$ to $X^1$, whose image is drawn as black arrows.

	Note that only the image of the maps are depicted, information such as which point of the
	simplex $\Delta^1$ get mapped to which point inside $X^1$ is not shown --- although different
	continuous maps give rise to different elements of $C_1(X^1)$.
	\ii The second picture depicts a typical element of $Z_1(X^1, X^0)$ --- that is, the
	\emph{relative cycles}.

	Although we never formally defined what is a relative cycle or the groups $Z_1(X^1, X^0)$, you
	can guess the definition from the definition of $Z_1(X^1)$ --- it is the subgroup of
	$C_1(X^1, X^0) = C_1(X^1)/C_1(X^0)$ whose boundary vanishes.

	The fact that the loop on the bottom is flattened is just to make it look nicer --- the whole
	thing is contained inside the red skeleton i.e. $X^1$.

	Of course, being an element of the quotient, only a representative element is depicted ---
	the ``modded out'' parts are the chains that are entirely contained inside $X^0$ i.e. some
	vertices.
	\ii The third picture depicts a typical element of $B_1(X^1, X^0)$ i.e. the \emph{relative
	boundaries}.

	This belongs to $\img \left( C_2(X^1, X^0) \taking\partial C_1(X^1, X^0) \right)$ --- in words,
	there is some $2$-chain whose boundary equals the depicted element.
	\ii The fourth picture depicts a typical element of $\Cells_1(X)$ --- that is, ``relative cycles
	mod relative boundaries''.

	Hopefully it is intuitively obvious how this group is isomorphic to the abelian group generated
	by each $1$-cell of $X$.

	We can in fact think of each of these elements as an ``aligned element'' of $C_1(X^1)$
	where all endpoints lie inside a vertex (that is, the boundary of that element is inside $X^0$),
	and for each $1$-cell, a canonical $1$-simplex is chosen to cover that cell (note that different
	simplices with the same image intuitively corresponds to ``reparametrization'' to change the
	speed, and the difference between a simplex and its reparametrization is in fact
	an element of $B_1(X^1, X^0)$ --- try to make this rigorous! Hint: use the prism operator.)

	\ii The fifth picture depicts a typical element of
	\[ \ker \left( \Cells_1(X) \taking\partial \Cells_0(X) \right) \]
	which can be thought of as a ``cellular cycle'', or a $1$-cycle
	(element of $Z_1(X)$) that is ``aligned'', as explained above.

	\ii The sixth picture depicts a typical element of
	\[ \img \left( \Cells_2(X) \taking\partial \Cells_1(X) \right) \]
	which can be thought of as a ``cellular boundary'', or a $1$-boundary
	(element of $B_1(X)$\footnote{This is not an element of $B_1(X^1)$! Think about why.}) that is ``aligned'' in the same sense as above.

	\ii Finally, the last picture is $H_1(\Cells_\bullet(X))$, which is
	\[ H_1(\Cells_\bullet(X)) = \frac{ \ker \left( \Cells_1(X) \taking\partial \Cells_0(X) \right) }{
	\img \left( \Cells_2(X) \taking\partial \Cells_1(X) \right) }. \]
	Or, roughly speaking,
	\[ H_1(\Cells_\bullet(X)) = \frac{\text{aligned cycle}}{\text{aligned boundary}}. \]
\end{itemize}
That is what we mean by $\frac{\text{aligned cycle}}{\text{aligned boundary}} =
\frac{\text{cycle}}{\text{boundary}}$.
With a suitable formalization and arbitrary selection of
canonical simplices,\footnote{Technically we need a so-called $\Delta$-complex structure on $X$, but
we don't define $\Delta$-structure in the Napkin. See \cite{ref:hatcher} for details.} we can
make the argument above rigorous.

What do we mean by ``fuzz''? This part is hopefully obvious, but the point is that an aligned cycle
can be ``moved around'' a bit (with reparametrization, or addition of elements in $B_1(X^1, X^0)$)
while still keep it a cycle (that is, an element of $Z_1(X)$). Similarly for aligned boundaries.

So, the point is --- we can ``cancel'' the common fuzz factor in the numerator and the denominator,
and the result will remain the same.

Refer to \cite{ref:hatcher} for some formal treatment on simplicial approximation.

\section{Application: Euler characteristic via Betti numbers}

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,
the definition coincides with the normal definition of the Euler characteristic.

\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}[column sep=small]
		\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, surjective head] &
		\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 \colon \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 a $k$-cell, and let $\{e_\beta^{k-1}\}_\beta$
	denote all $(k-1)$-cells of $X$.
	Then \[ d_k \colon \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 the degree of the composed map
	\[ S^{k-1} = \partial e^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}

What is the degree doing here? Remember that a basis element $e^k \in \Cells_k(X)$ is just a
$k$-cell, and its boundary should be just the cells that form its boundary.

With the same visualization as above, we can do something like the following.
\begin{center}
\begin{asy}
	filldraw(shift(0, 3)*polygon(3), lightcyan, lightred+1.5);
	draw(dir(-30)--dir(90) , lightred+1.5, Arrow(size=5));
	draw(dir(90)--dir(210) , lightred+1.5, Arrow(size=5), L=Label("$e^1_\beta$", red));
	draw(dir(210)--dir(-30), lightred+1.5, Arrow(size=5));
	draw((0, 2.25)--(0, 1.2), Arrow, L=Label("$d_2$", MidPoint, align=E));
	label("$\in \operatorname{Cells}_2(X)$", (0.9, 3.2), align=E);
	label("$\in \operatorname{Cells}_1(X)$", (0.9, 0.2), align=E);
	label("$e^2$", (0, 3));
\end{asy}
\end{center}
But it's not that easy! Note that in a CW complex, the boundary of a $k$-cell can be fused into
\emph{arbitrary points} in $X^{k-1}$, so an ``edge'' of a $k$-cell need not be a $(k-1)$-cell.

To make matters worse, sometimes there may be a duplicated edge --- in the Klein bottle, each pair
of two opposing edges depicted is actually \emph{the same edge}, possibly in different orientations.
\begin{center}
\begin{asy}
	size(2cm);
	fill(unitsquare, yellow+opacity(0.2));
	pair C = (0,0);
	pair B = (1,0);
	pair A = (1,1);
	pair D = (0,1);
	draw(A--B, red, MidArrow);
	draw(C--B, blue, MidArrow);
	draw(D--C, red, MidArrow);
	draw(A--D, blue, MidArrow);
\end{asy}
\end{center}
In such a case, we need to count the \emph{multiplicity} of each edge --- and this is exactly what
the degree of the map counts!
We will see an explicit example of computing the homology groups of the Klein bottle in just a
moment.

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 \colon \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 \colon \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]
	\label{ex:homology_klein}
	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$.

	Let us sanity check that this makes sense --- that is, there is some cycle that is not a
	boundary, but when doubled it become a boundary.

	Actually, most cycles work.
	\begin{center}
	\begin{asy}
		size(2cm);
		fill(unitsquare, yellow+opacity(0.2));
		pair C = (0,0);
		pair B = (1,0);
		pair A = (1,1);
		pair D = (0,1);
		draw((0, 0.7)--(1, 0.7), MidArrow);
		draw(A--B, red, MidArrow);
		draw(C--B, blue, MidArrow);
		draw(D--C, red, MidArrow);
		draw(A--D, blue, MidArrow);
	\end{asy}
	\end{center}

	If we double up the path, we get something like the following.
	\begin{center}
	\begin{asy}
		size(2cm);
		fill(unitsquare, yellow+opacity(0.2));
		pair C = (0,0);
		pair B = (1,0);
		pair A = (1,1);
		pair D = (0,1);
		draw((0, 0.7){dir(20)}..(1, 0.7), MidArrow);
		draw((0, 0.7){dir(-20)}..(1, 0.7), MidArrow);
		draw(A--B, red, MidArrow);
		draw(C--B, blue, MidArrow);
		draw(D--C, red, MidArrow);
		draw(A--D, blue, MidArrow);
	\end{asy}
	\end{center}

	Here is the important part: since the two blue edges are identified in opposite direction, we
	can pull one of the path across the edge to reverse its direction\dots\ but now the region is in
	fact the boundary of the cyan region! So we're done.
	\begin{center}
	\begin{asy}
		size(2cm);
		fill(unitsquare, yellow+opacity(0.2));
		pair C = (0,0);
		pair B = (1,0);
		pair A = (1,1);
		pair D = (0,1);
		fill(shift(0, 0.3)*scale(1, 0.4)*unitsquare, lightcyan);
		draw((0, 0.7)--(1, 0.7), MidArrow);
		draw((1, 0.3)--(0, 0.3), MidArrow);
		draw(A--B, red, MidArrow);
		draw(C--B, blue, MidArrow);
		draw(D--C, red, MidArrow);
		draw(A--D, blue, MidArrow);
	\end{asy}
	\end{center}

	It remains to convince yourself that the difference of two homotopy equivalent paths is a
	boundary.
\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 \colon 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]
	\onechili
	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}
	\onechili
	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}
