\chapter{Singular cohomology}
Here's one way to motivate this chapter. It turns out that:
\begin{itemize}
	\ii $H_n(\CP^2) \cong H_n(S^2 \vee S^4)$ for every $n$.
	\ii $H_n(\CP^3) \cong H_n(S^2 \times S^4)$ for every $n$.
\end{itemize}
This is unfortunate, because if possible we would like
to be able to tell these spaces apart (as they are
in fact not homotopy equivalent), but the homology groups
cannot tell the difference between them.

In this chapter, we'll define a \emph{cohomology group} $H^n(X)$ and $H^n(Y)$.
In fact, the $H^n$'s are completely determined by the $H_n$'s
by the so-called \emph{universal coefficient theorem}.
However, it turns out that one can take all the cohomology groups and put
them together to form a \emph{cohomology ring} $H^\bullet$.
We will then see that $H^\bullet(X) \not\cong H^\bullet(Y)$ as rings.

\section{Cochain complexes}
\begin{definition}
A \vocab{cochain complex} $A^\bullet$ is algebraically the same as a chain complex, except that the indices increase.
So it is a sequence of abelian groups
\[ \dots \taking{\delta} A^{n-1} \taking\delta A^n \taking\delta A^{n+1} \taking\delta \dots. \]
such that $\delta^2 = 0$.
Notation-wise, we're now using subscripts, and use $\delta$ rather $\partial$.
We define the \vocab{cohomology groups} by
\[ H^n(A^\bullet) = \ker\left( A^n \taking\delta A^{n+1} \right)
	/ \img\left( A^{n-1} \taking\delta A^n \right). \]
\end{definition}

\begin{example}[de Rham cohomology]
	We have already met one example of a cochain complex:
	let $M$ be a smooth manifold and $\Omega^k(M)$ be the
	additive group of $k$-forms on $M$.
	Then we have a cochain complex
	\[ 0 \taking d \Omega^0(M)
		\taking d \Omega^1(M) \taking d \Omega^2(M)
		\taking d \dots. \]
	The resulting cohomology is called \vocab{de Rham cohomology},
	described later.
\end{example}

Aside from de Rham's cochain complex,
\textbf{the most common way to get a cochain complex
is to \emph{dualize} a chain complex.}
Specifically, pick an abelian group $G$;
note that $\Hom(-, G)$ is a contravariant functor,
and thus takes every chain complex
\[ \dots \taking\partial A_{n+1} \taking\partial
	A_n \taking\partial A_{n-1} \taking\partial \dots \]
into a cochain complex: letting $A^n = \Hom(A_n, G)$ we obtain
\[ \dots \taking\delta A^{n-1} \taking\delta
	A^n \taking\delta A^{n+1} \taking\delta \dots. \]
where $\delta(A_n \taking{f} G) = A_{n+1} \taking\partial A \taking{f} G$.

These are the cohomology groups we study most in algebraic topology,
so we give a special notation to them.
\begin{definition}
	Given a chain complex $A_\bullet$ of abelian groups and another group $G$,
	we let \[ H^n(A_\bullet; G) \] denote the cohomology groups
	of the dual cochain complex $A^\bullet$ obtained by applying $\Hom(-,G)$.
	In other words, $H^n(A_\bullet; G) = H^n(A^\bullet)$.
\end{definition}

\section{Cohomology of spaces}
\prototype{$C^0(X;G)$ all functions $X \to G$ while $H^0(X)$ are those functions $X \to G$
constant on path components.}

The case of interest is our usual geometric situation, with $C_\bullet(X)$.
\begin{definition}
	For a space $X$ and abelian group $G$,
	we define $C^\bullet(X;G)$ to be the dual to the
	singular chain complex $C_\bullet(X)$,
	called the \vocab{singular cochain complex} of $X$;
	its elements are called \vocab{cochains}.

	Then we define the \vocab{cohomology groups}
	of the space $X$ as
	\[ H^n(X; G) \defeq H^n(C_\bullet(X); G) = H_n(C^\bullet(X;G)). \]
\end{definition}
\begin{remark}
	Note that if $G$ is also a ring (like $\ZZ$ or $\RR$),
	then $H^n(X; G)$ is not only an abelian group but actually a $G$-module.
\end{remark}

\begin{example}
	[$C^0(X; G)$, $C^1(X; G)$, and $H^0(X;G)$]
	Let $X$ be a topological space and consider $C^\bullet(X)$.
	\begin{itemize}
		\ii $C_0(X)$ is the free abelian group on $X$,
		and $C^0(X) = \Hom(C_0(X), G)$.
		So a $0$-cochain is a function that
		takes every point of $X$ to an element of $G$.
		\ii $C_1(X)$ is the free abelian group on $1$-simplices in $X$.
		So $C^1(X)$ needs to take every $1$-simplex to an element of $G$.
	\end{itemize}
	Let's now try to understand $\delta : C^0(X) \to C^1(X)$.
	Given a $0$-cochain $\phi \in C^0(X)$,
	i.e.\ a homomorphism $\phi : C^0(X) \to G$,
	what is $\delta\phi : C^1(X) \to G$?
	Answer:
	\[ \delta\phi : [v_0, v_1] \mapsto \phi([v_0]) - \phi([v_1]). \]
	Hence, elements of
	$\ker(C^0 \taking\delta C^1) \cong H^0(X;G)$
	are those cochains
	that are \emph{constant on path-connected components}.
\end{example}
In particular, much like $H_0(X)$, we have \[ H^0(X) \cong G^{\oplus r} \]
if $X$ has $r$ path-connected components (where $r$ is finite\footnote{%
	Something funny happens if $X$ has \emph{infinitely} many path-connected components:
	say $X = \coprod_\alpha X_\alpha$ over an infinite indexing set.
	In this case we have
	$H_0(X) = \bigoplus_\alpha G$ while $H^0(X) = \prod_\alpha G$.
	For homology we get a \emph{direct sum} while
	for cohomology we get a \emph{direct product}.

	These are actually different for infinite indexing sets.
	For general modules $\bigoplus_\alpha M_\alpha$ is \emph{defined} to only allow
	to have \emph{finitely many} nonzero terms.
	(This was never mentioned earlier in the Napkin,
	since I only ever defined $M \oplus N$ and extended it to finite direct sums.)
	No such restriction holds for $\prod_\alpha G_\alpha$ a product of groups.
	This corresponds to the fact that $C_0(X)$ is formal linear sums of $0$-chains
	(which, like all formal sums, are finite)
	from the path-connected components of $G$.
	But a cochain of $C^0(X)$ is a \emph{function}
	from each path-connected component of $X$ to $G$,
	where there is no restriction.
}).

To the best of my knowledge, the higher cohomology groups $H^n(X; G)$
(or even the cochain groups $C^n(X; G) = \Hom(C_n(X), G)$) are harder to describe concretely.

\begin{abuse}
	In this chapter the only cochain complexes
	we will consider are dual complexes as above.
	So, any time we write a chain complex $A^\bullet$ it is implicitly given
	by applying $\Hom(-,G)$ to $A_\bullet$.
\end{abuse}

\section{Cohomology of spaces is functorial}
We now check that the cohomology groups still exhibit the same nice functorial behavior.
First, let's categorize the previous results we had:

\begin{ques}
	Define $\catname{CoCmplx}$
	the category of cochain complexes.
\end{ques}

\begin{exercise}
	Interpret $\Hom(-,G)$ as a contravariant functor
	from \[ \Hom(-,G) : \catname{Cmplx}\op \to \catname{CoCmplx}. \]
	This means in particular that given a chain map $f : A_\bullet \to B_\bullet$,
	we naturally obtain a dual map $f^\vee : B^\bullet \to A^\bullet$.
\end{exercise}

\begin{ques}
	Interpret $H^n : \catname{CoCmplx} \to \catname{Grp}$ as a functor.
	Compose these to get a contravariant functor
	$H^n(-;G) : \catname{Cmplx}\op \to \catname{Grp}$.
\end{ques}

Then in exact analog to our result that $H_n : \catname{hTop} \to \catname{Grp}$ we have:
\begin{theorem}[$H^n (-;G): \catname{hTop}\op \to \catname{Grp}$]
	For every $n$, $H^n(-;G)$ is a contravariant functor
	from $\catname{hTop}\op$ to $\catname{Grp}$.
\end{theorem}
\begin{proof}
	The idea is to leverage the work we already did in constructing
	the prism operator earlier.
	First, we construct the entire sequence of functors
	from $\catname{Top}\op \to \catname{Grp}$:
	\begin{center}
	\begin{tikzcd}
		\catname{Top}\op \ar[rr, "C_\bullet"]
			&& \catname{Cmplx}\op \ar[rr, "\Hom(-;G)"]
			&& \catname{CoCmplx} \ar[rr, "H^n"]
			&& \catname{Grp} \\
		X \ar[dd, "f"', near start]
			&& C_\bullet(X) \ar[dd, "f_\sharp"', near start]
			&& C^\bullet(X;G)
			&& H^n(X;G) \\
			\quad \ar[rr, mapsto] &&
			\quad \ar[rr, mapsto] &&
			\quad \ar[rr, mapsto] &&
			\quad \\
		Y
			&& C_\bullet(Y)
			&& C^\bullet(Y;G) \ar[uu, "f_\sharp"', near start]
			&& H^n(Y;G). \ar[uu, "f^\ast"', near start]
	\end{tikzcd}
	\end{center}
	Here $f^\sharp = (f_\sharp)^\vee$, and $f^\ast$
	is the resulting induced map on homology groups of the cochain complex.

	So as before all we have to show is that $f \simeq g$,
	then $f^\ast = g^\ast$.
	Recall now that there is a prism operator such that
	$f_\sharp - g_\sharp = P \partial + \partial P$.
	If we apply the entire functor $\Hom(-;G)$ we get that
	$f^\sharp - g^\sharp = \delta P^\vee + P^\vee \delta$
	where $P^\vee : C^{n+1}(Y;G) \to C^n(X;G)$.
	So $f^\sharp$ and $g^\sharp$ are chain homotopic thus $f^\ast = g^\ast$.
\end{proof}


\section{Universal coefficient theorem}
We now wish to show that the cohomology groups are determined up to isomorphism
by the homology groups: given $H_n(A_\bullet)$, we can extract $H^n(A_\bullet; G)$.
This is achieved by the \emph{universal coefficient theorem}.
\begin{theorem}
	[Universal coefficient theorem]
	Let $A_\bullet$ be a chain complex of \emph{free} abelian groups,
	and let $G$ be another abelian group.
	Then there is a natural short exact sequence
	\[
		0 \to \Ext(H_{n-1}(A_\bullet), G) \to H^n(A_\bullet; G)
		\taking{h} \Hom(H_n(A_\bullet), G) \to 0. \]
	In addition, this exact sequence is \emph{split}
	so in particular
	\[ H^n(C_\bullet; G) \cong \Ext(H_{n-1}(A_\bullet, G))
		\oplus \Hom(H_n(A_\bullet), G). \]
\end{theorem}
Fortunately, in our case of interest, $A_\bullet$ is $C_\bullet(X)$
which is by definition free.

There are two things we need to explain, what the map $h$ is and the map $\Ext$ is.

It's not too hard to guess how \[ h : H^n(A_\bullet; G) \to \Hom(H_n(A_\bullet), G) \] is defined.
An element of $H^n(A_\bullet;G)$ is represented by a function which sends a cycle
in $A_n$ to an element of $G$.
The content of the theorem is to show that $h$ is surjective with kernel $\Ext(H_{n-1}(A_\bullet), G)$.

What about $\Ext$?
It turns out that $\Ext(-,G)$ is the so-called \vocab{Ext functor}, defined as follows.
Let $H$ be an abelian group, and consider a \vocab{free resolution} of $H$,
by which we mean an exact sequence
\[ \dots \taking{f_2} F_1 \taking{f_1} F_0 \taking{f_0} H \to 0 \]
with each $F_i$ free.
Then we can apply $\Hom(-,G)$ to get a cochain complex
\[ \dots \xleftarrow{f_2^\vee} \Hom(F_1, G) \xleftarrow{f_1^\vee}
	\Hom(F_0, G) \xleftarrow{f_0^\vee} \Hom(H,G) \leftarrow 0. \]
but \emph{this cochain complex need not be exact}
(in categorical terms, $\Hom(-,G)$ does not preserve exactness).
We define \[ \Ext(H,G) \defeq \ker(f_2^\vee) / \img(f_1^\vee) \]
and it's a theorem that this doesn't depend on the choice of the free resolution.
There's a lot of homological algebra that goes into this,
which I won't take the time to discuss;
but the upshot of the little bit that I did include is that the $\Ext$
functor is very easy to compute in practice, since
you can pick any free resolution you want and compute the above.

%By ``natural'', we mean that if $f : A_\bullet \to B_\bullet$ is a chain map,
%then we obtain a commutative diagram
%\begin{diagram}
%	0 & \rTo & \Ext(H_{n-1}(A_\bullet), G) & \rTo
%		& H^n(A_\bullet;G) & \rTo & \Hom(H_n(A_\bullet), G) & \rTo & 0 \\
%	& & \uTo^{ \Ext(f_\ast, G) } & & \uTo^{f^\ast} & & \uTo^{\Hom(f_\ast, G)} & & \\
%	0 & \rTo & \Ext(H_{n-1}(B_\bullet), G) & \rTo
%		& H^n(A_\bullet;G) & \rTo & \Hom(H_n(B_\bullet), G) & \rTo & 0 \\
%\end{diagram}
%where $f_\ast$ is the induced arrow $H_n(A_\bullet) \to H_n(B_\bullet)$.

\begin{lemma}
	[Computing the $\Ext$ functor]
	For any abelian groups $G$, $H$, $H'$ we have
	\begin{enumerate}[(a)]
		\ii $\Ext(H \oplus H', G) = \Ext(H, G) \oplus \Ext(H', G)$.
		\ii $\Ext(H,G) = 0$ for $H$ free, and
		\ii $\Ext(\Zc n, G) = G / nG$.
	\end{enumerate}
\end{lemma}
\begin{proof}
	For (a), note that if $\dots \to F_1 \to F_0 \to H \to 0$
	and $\dots \to F_1' \to F_0' \to F_0' \to H' \to 0$ are free resolutions,
	then so is $F_1 \oplus F_1' \to F_0 \oplus F_0' \to H \oplus H' \to 0$.

	For (b), note that $0 \to H \to H \to 0$ is a free resolution.

	Part (c) follows by taking the free resolution
	\[ 0 \to \ZZ \taking{\times n} \ZZ \to \Zc n \to 0 \]
	and applying $\Hom(-,G)$ to it.
	\begin{ques}
		Finish the proof of (c) from here. \qedhere
	\end{ques}
\end{proof}

\begin{ques}
	Some $\Ext$ practice: compute
	$\Ext(\ZZ^{\oplus 2015}, G)$ and $\Ext(\Zc{30}, \Zc 4)$.
\end{ques}

\section{Example computation of cohomology groups}
\prototype{Possibly $H^n(S^m)$.}

The universal coefficient theorem gives us a direct way to compute
any cohomology groups, provided we know the homology ones.

\begin{example}
	[Cohomolgy groups of $S^m$]
	It is straightforward to compute $H^n(S^m)$ now:
	all the $\Ext$ terms vanish since $H_n(S^m)$ is always free,
	and hence we obtain that
	\[ H^n(S^m) \cong \Hom(H_n(S^m), G) \cong
		\begin{cases}
			G & n=m, n=0 \\
			0 & \text{otherwise}.
		\end{cases}
	\]
%	By UCT for reduced groups, we also have
%	\[ \wt H^n(S^m) \cong \Hom(\wt H_n(S^m), G) \cong
%		\begin{cases}
%			G & n=m \\
%			0 & \text{otherwise}.
%		\end{cases}
%	\]
%	since $\Hom(\ZZ, G)$.
\end{example}

\begin{example}
	[Cohomolgy groups of torus]
	This example has no nonzero $\Ext$ terms either,
	since this time $H^n(S^1 \times S^1)$ is always free.
	So we obtain
	\[ H^n(S^1 \times S^1) \cong \Hom(H_n(S^1 \times S^1), G). \]
	Since $H_n(S^1 \times S^1)$ is $\ZZ$, $\ZZ^{\oplus 2}$, $\ZZ$
	in dimensions $n=1,2,1$ we derive that
	\[
		H^n(S^1 \times S^1)
		\cong
		\begin{cases}
			G & n = 0,2 \\
			G^{\oplus 2} & n = 1.
		\end{cases}
	\]
\end{example}

From these examples one might notice that:
\begin{lemma}
	[$0$th homology groups are just duals]
	For $n = 0$ and $n = 1$, we have
	\[ H^n(X;G) \cong \Hom(H_n(X), G). \]
\end{lemma}
\begin{proof}
	It's already been shown for $n=0$.
	For $n=1$, notice that $H_0(X)$ is free,
	so the $\Ext$ term vanishes.
\end{proof}

\begin{example}
	[Cohomolgy groups of Klein bottle]
	This example will actually have $\Ext$ term.
	Recall that if $K$ is a Klein Bottle then its homology groups are
	$\ZZ$ in dimension $n=0$ and $\ZZ \oplus \Zc 2$ in $n=1$, and $0$ elsewhere.

	For $n=0$, we again just have $H^0(K;G) \cong \Hom(\ZZ, G) \cong G$.
	For $n=1$, the $\Ext$ term is $\Ext(H_0(K), G) \cong \Ext(\ZZ, G) = 0$
	so \[ H^1(K;G) \cong \Hom(\ZZ \oplus \Zc2, G) \cong G \oplus \Hom(\Zc2, G). \]
	We have that $\Hom(\Zc2,G)$ is the subgroup
	of elements of order $2$ in $G$ (and $0 \in G$).

	But for $n=2$, we have our first interesting $\Ext$ group:
	the exact sequence is
	\[ 0 \to \Ext(\ZZ \oplus \Zc 2, G) \to H^2(X;G) \to \underbrace{H_2(X)}_{=0} \to 0. \]
	Thus, we have
	\[ H^2(X;G) \cong \left( \Ext(\ZZ,G) \oplus \Ext(\Zc2,G) \right) \oplus 0
		\cong G/2G. \]
	All the higher groups vanish.
	In summary:
	\[
		H^n(X;G) \cong
		\begin{cases}
			G & n = 0 \\
			G \oplus \Hom(\Zc2, G) & n = 1 \\
			G/2G & n = 2 \\
			0 & n \ge 3.
		\end{cases}
	\]
\end{example}


\section{Relative cohomology groups}
One can also define relative cohomology groups in the obvious way:
dualize the chain complex
\[ \dots \taking\partial C_1(X,A) \taking\partial C_0(X,A) \to 0 \]
to obtain a cochain complex
\[
	\dots \xleftarrow\delta C^1(X,A;G) \xleftarrow\delta C^0(X,A;G)
	\leftarrow 0.
\]
We can take the cohomology groups ofthis.
\begin{definition}
	The groups thus obtained are the \vocab{relative cohomology groups}
	are denoted $H^n(X,A;G)$.
\end{definition}

In addition, we can define reduced cohomology groups as well.
One way to do it is to take the augmented singular chain complex
\[ \dots \taking\partial C_1(X) \taking\partial C_0(X) \taking\eps \ZZ \to 0 \]
and dualize it to obtain
\[
	\dots \xleftarrow\delta C^1(X;G) \xleftarrow\delta C^0(X;G)
	\xleftarrow{\eps^\vee} \underbrace{\Hom(\ZZ, G)}_{\cong G}
	\leftarrow 0.
\]
Since the $\ZZ$ we add is also free,
the universal coefficient theorem still applies.
So this will give us reduced cohomology groups.

However, since we already defined the relative cohomology groups,
it is easiest to simply define:
\begin{definition}
	The \vocab{reduced cohomology groups} of a nonempty space $X$,
	denoted $\wt H^n(X; G)$,
	are defined to be $H^n(X, \{\ast\} ; G)$
	for some point $\ast \in X$.
\end{definition}


\section\problemhead
\begin{sproblem}
	[Wedge product cohomology]
	For any $G$ and $n$ we have
	\[
		\wt H^n(X \vee Y; G)
		\cong
		\wt H^n(X; G) \oplus \wt H^n(Y; G).
	\]
\end{sproblem}

\begin{dproblem}
	Prove that for a field $F$ of characteristic zero and a space $X$
	with finitely generated homology groups:
	\[ H^k(X, F) \cong \left( H_k(X) \right)^\vee.  \]
	Thus over fields cohomology is the dual of homology.
\end{dproblem}

\begin{problem}[$\Zc2$-cohomology of $\RP^n$]
	Prove that
	\[
		H^m(\RP^n, \Zc2)
		\cong
		\begin{cases}
			\ZZ & \text{$m=0$, or $m$ is odd and $m=n$} \\
			\Zc2 & \text{$0 < m < n$ and $m$ is odd} \\
			0 & \text{otherwise}.
		\end{cases}
	\]
\end{problem}
