# Homology and Euler Characteristic
Homology is a generalization of the Euler characteristic. In order to understand what that means and how it works, we must first define the $\textit{Betti numbers}$. If $X$ is a topological space that has a finite triangulation, then it has finitely many nonzero homology groups; furthermore, each homology group is a finitely generated abelian group, and hence of the form ==$H_i(X) \cong \mathbb{Z}^k \times \prod_{j=1}^{m} \left(\mathbb{Z}/p^{e_j}_j \mathbb{Z}\right)$.== We define the $i^{th}$ $\textit{Betti number}$ $h_i(X)$ to be $k$, the number of copies of $\mathbb{Z}$, also known as the $rank$ of a finitely generated abelian group.
$\textbf{Theorem}$
The Euler characteristic is the alternating sum of the Betti numbers, i.e.,
\begin{equation}
\chi(X) = \sum_{i=0}^{\infty} (-1)^i h_i(X).
\end{equation}Note that this is actually a $finite$ sum because all but finitely many of the Betti numbers are zero.
$\textbf{Proof:}$
Recall that the Euler characteristic is the alternating sum of the number of faces of dimension $i$. Now, it is not true that the number of faces of dimension $i$ is equal to the $i$th Betti number, only that their alternating sums are equal. (They couldn't possibly be equal in general because the number of faces depends on the choice of triangulation, and we have stated that the homology does not depend on the choice of triangulation.)
But note that the number of faces of dimension $i$ is the rank of $C_i(X)$. So we have to show that
\begin{equation}
\sum_{i=0}^{\infty} (-1)^i \operatorname{rank} C_i(X) = \sum_{i=0}^{\infty} (-1)^i \operatorname{rank} H_i(X).
\end{equation}
To do this, observe that $\operatorname{rank} H_i(X) = \operatorname{rank} Z_i(X) - \operatorname{rank} B_i(X)$; each new relation decreases the number of "free" generators by one. Also, recall the isomorphism theorem for groups: if $f: G \to H$ is a homomorphism of groups, then $G/\operatorname{ker}(f) \cong \operatorname{im}(f)$. This implies that if $G$ is a finitely generated abelian group, then
\begin{equation}
\operatorname{rank} G = \operatorname{rank} \operatorname{im}(f) + \operatorname{rank} \operatorname{ker}(f).
\end{equation}
Now we're ready to go! By the above, using the boundary maps, we have
\begin{equation}
\operatorname{rank} C_i(X) = \operatorname{rank} B_{i-1}(X) + \operatorname{rank} Z_i(X).
\end{equation}
So
\begin{align}
\chi(X) & = \sum_{i=0}^{\infty} (-1)^i \operatorname{rank} C_i(X) \\
& = \sum_{i=0}^{\infty} (-1)^i (\operatorname{rank} B_{i-1}(X) + \operatorname{rank} Z_i(X)) \\
& = \sum_{i=0}^{\infty} (-1)^i (\operatorname{rank} Z_i(X) - \operatorname{rank} B_i(X)) \\
& = \sum_{i=0}^{\infty} (-1)^i \operatorname{rank} H_i(X),
\end{align}
which is what we wanted to show!
# Homology and Orientability
Let $S$ be a compact, connected surface (without boundary). The homology detects the orientability of $S$ in the following way. Note that $H_2(T) \cong \mathbb{Z}$, whereas $H_2(K) = 0$. In general, the 2-dimensional homology of $S$ is $\mathbb{Z}$ if $S$ is orientable, and it's 0 if $S$ is nonorientable. More generally, if $X$ is a compact, connected $n$-dimensional manifold (without boundary), then $H_n(X) \cong \mathbb{Z}$ if $X$ is orientable, and $H_n(X) = 0$ if $X$ is nonorientable. We'll only prove this for surfaces since we'll work in terms of ID spaces.
$\textbf{Definition}$
An identification space (or ID space) is a polygon in $\mathbb{R}^2$ along with instructions for gluing edges together.
Let's first suppose that $S$ is orientable, and that we have an ID space for $S$, which is a polygon with edges identified in pairs.==Because $S$ is orientable, the edges are Type I edges, i.e., as we traverse the boundary of the ID space polygon, the two instances of that edge appear with opposite orientations.==
Now, split the ID space for $S$ up into triangles so that we have a triangulation of $S$, into triangles $T_1, T_2, \ldots, T_r$. We orient each triangle $T_i$ in the counterclockwise orientation. Then a 2-chain $c$ is a sum $\sum_{i=1}^{r} a_i T_i$, where each $a_i \in \mathbb{Z}$. What does it mean for $c$ to be a 2-cycle? Take two triangles that share an edge in the interior of the polygon, say $T_i$ and $T_j$, which share edge $e$. ==These are the only two triangles containing that edge==, so they are the only contributors to $e$ in $\partial_2(c)$. Thus $\partial_2(a_i T_i + a_j T_j)$ must have a coefficient of 0 for $e$. The contribution from $a_i T_i$ is $a_i$, whereas the contribution from $a_j T_j$ is $-a_j$ (or the signs may both be swapped). Thus we find that a necessary condition for $c$ to be a 2-cycle is that $a_i = a_j$. Because we can apply this argument to an arbitrary interior edge, we find that all the $a_i$'s must be equal, i.e., it must be the case that $c = \sum_{i=1}^{r} a T_i$ for some $a \in \mathbb{Z}$.
But is such a $c$ actually a cycle? The only thing that can go wrong is that the boundary edges of the polygon might not cancel. However, ==since $S$ is assumed to be orientable, each boundary edge appears once with a positive orientation and once with a negative orientation.== Thus chains of the form $\sum_{i=1}^{r} a T_i$ are indeed cycles, and they are the only cycles in $S$. If $a \neq 0$, then they are not boundaries, because $C_3(S) = 0$. Thus we find that $H_2(S) = \langle \sum_{i=1}^{r} T_i \rangle \cong \mathbb{Z}$.
$\textbf{Definition}$
Let $S$ be an orientable, compact, connected surface divided into triangles $T_1, \ldots, T_r$ as above. Then the cycle $\sum_{i=1}^{r} T_i$ is called a $\textit{fundamental class}$ of $S$.
Thus, a fundamental class generates $H_2(S)$. Note that we could have reflected our ID space polygon, which would flip the orientation of all the triangles and thus multiply the fundamental class by $-1$. This means that there are two possible choices for a fundamental class of $S$.
Now, what happens if $S$ is nonorientable? As before, we find that a necessary condition for $c$ being a cycle is that it has the form $c = \sum_{i=1}^{r} a T_i$. However, now we run into a problem with the boundary. Since $S$ is nonorientable, ==there is some edge $e$ on the boundary that is oriented in the same way both times.== Thus, the contribution of $e$ to $\partial_2(c)$ is $\pm 2a$. In particular, $c \notin Z_2(S)$ unless $a = 0$. Thus $Z_2(S) = 0$, so $H_2(S) = 0$ as well.
# Smith Normal Form
It seems as though computing homology is easy and completely mechanical—so that the process is something that one could program a computer to do. But there is one step that is still difficult. Once we have computed $Z_i(X)$ and $B_i(X)$, we obtain some presentation for $H_i(X)$, but we would like to be able to identify it in a more convenient form. If $X$ has a finite triangulation, then $H_i(X)$ is a finitely generated abelian group, and we know what all the finitely generated abelian groups look like.
But when we see a group like
\begin{equation}
\langle a_1, a_2, a_3, a_4 \mid 5a_1 - 2a_2 + 3a_4, 3a_1 + 2a_2 + 2a_3, 4a_3 - 2a_4, 9a_2 + 6a_3 \rangle,
\end{equation}how do we write that nicely, in the form $\mathbb{Z}^k \times (\text{finite group})$?
Fortunately, there is a fairly simple algorithm for doing this. It will be convenient to write out the relations as a matrix. Each relation gets a row, and each generator gets a column, and the coefficients go in the matrix. Hence the matrix we get from the presentation is
\begin{bmatrix}
5 & -2 & 0 & 3 \\
3 & 2 & 2 & 0 \\
0 & 0 & -2 & 4 \\
9 & 6 & 0 & 0 \\
\end{bmatrix}.
The goal is to find better generators and relations, ones that make it more obvious what the group structure is.
So, how do we find other generators? If $a_1$ and $a_2$ generate an abelian group, then $a_1$ and $a_1 + a_2$ generate it just as well, as do $a_1$ and $5a_1 + a_2$. More generally, if $a_1$ and $a_2$ are two of the generators for an abelian group (and there may be others), then $a_1$ and $ca_1 + a_2$, for any integer $c$, together with the remaining generators, also generate the same group.
What happens to the matrix when we modify the generators in this way? Replacing $a_2$ with $ca_1 + a_2$ means we add $c$ times the $a_1$ column to the $a_2$ column. For example, in the matrix above, replacing $a_2$ by $2a_1 + a_2$ would turn the matrix into
\begin{bmatrix}
5 & 8 & 0 & 3 \\
3 & 8 & 2 & 0 \\
0 & 0 & -2 & 4 \\
9 & 6 & 0 & 0 \\
\end{bmatrix}.
Also allowable is switching the order of the generators, which amounts to switching the order of the columns.
Similarly, we can modify the relations: if $r_1$ and $r_2$ are two relations, then $cr_1 + r_2$ is also a relation, and we can replace $r_2$ with $cr_1 + r_2$ in the list of relations. Thus we can do the same operations to the rows as we can to the columns. Using these row and column operations, we can convert the matrix to one that is in a particularly nice form, called the Smith normal form.
$\textbf{Definition}$
A matrix $A = (a_{ij})_{1 \leq i \leq m, 1 \leq j \leq n}$ is said to be in Smith normal form if, for some $k \leq \min(m, n)$, the first $k$ diagonal entries are nonzero, with $a_{ii}$ dividing $a_{i+1, i+1}$, and all other entries are 0.
Thus, a matrix in Smith normal form looks like this:
\begin{bmatrix}
a_{11} & 0 & \cdots & \cdots & \cdots & 0 & \cdots & 0 \\
0 & a_{22} & \cdots & \cdots & \cdots & 0 & \cdots & 0 \\
\vdots & \vdots & \ddots & & \vdots & \vdots & & \vdots \\
0 & 0 & \cdots & a_{kk} & \cdots & 0 & \cdots & 0 \\
\end{bmatrix}
with all other omitted entries being 0.
It turns out that we can put any integer matrix into Smith normal form; this fact is equivalent to the classification of finitely generated abelian groups, and in fact, this is the idea behind the standard proof of that classification theorem. (We didn’t quite prove it properly.) The details of how to get a matrix into Smith normal form are slightly outside the scope of this book (see [Mun84, Section 11] for a proof). This process involves some elementary number theory (in particular, the Euclidean algorithm), but the idea is as follows. If there is some nonzero entry in the matrix, then let $g$ be the gcd of all the entries in the matrix. Using the Euclidean algorithm repeatedly, it is possible to perform row and column operations so that $a_{11} = g$. Then, everything else in the first row and column is a multiple of $g$, so we can add multiples of the first row or column to the others—so as to make all the other entries in the first row and first column 0. Now, if there are any nonzero entries left in the matrix other than $a_{11}$, do the same process to the matrix obtained by deleting the first row and column, making $a_{22}$ into the gcd of all the rest of the elements, and so forth.
Once we have a matrix in Smith normal form, it is easy to read off the group structure so as to fit it into the classification. Let us say that the columns correspond to generators $g_1, \ldots, g_n$. If the $i$th column is all 0’s, then $g_i$ contributes a factor of $\mathbb{Z}$ to the group. If there is a nonzero entry in column $i$ (hence the entry $a_{ii}$), then $g_i$ contributes a factor of $\mathbb{Z}/a_{ii}\mathbb{Z}$ to the group.
Why? Let us look at the $i$th row. Once the matrix is in Smith normal form, there is at most one nonzero entry in that row; if all the entries in row $i$ are 0, then that corresponds to the relation $0 = 0$, which we already knew. But if there is a nonzero entry $a_{ii}$, then the relation is $a_{ii}e_i = 0$, giving us a factor of $\mathbb{Z}/a_{ii}\mathbb{Z}$.
In the case of the matrix above, the Smith normal form is
\begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 336 \\
\end{bmatrix}
meaning that the corresponding group is isomorphic to $\mathbb{Z}/336\mathbb{Z}$.
# The Induced Map on Homology
Recall that, given two topological spaces $X$ and $Y$, base points $x \in X$ and $y \in Y$, and a continuous function $f: X \to Y$ with $f(x) = y$, there is a homomorphism $f_*: \pi_1(X, x) \to \pi_1(Y, y)$. This is the induced homomorphism.
Similarly, in the case of homology, we also have an induced homomorphism—at least sometimes. Let us think about how to mimic the construction of the induced homomorphism on fundamental groups, in the case of homology. Remember that, given a loop $\gamma$ in $X$ based at $x$, we set $f_*(\left[\gamma\right]) = [f \circ \gamma]$. The analogous construction in the case of homology, which would give us maps $f_*: H_n(X) \to H_n(Y)$ for each $n$, would be to pick an $n$-chain $\sum_{i=0}^{r} a_i T_i$ and define $f_*$ on chains by
\begin{equation}
f_*\left(\sum_{i=0}^{r} a_i T_i\right) = \sum_{i=0}^{r} a_i f(T_i),
\end{equation}
where $f(T_i)$ is the image of the simplex $T_i$ under $f$. That would be a map of chains, so a homomorphism $f_*: C_n(X) \to C_n(Y)$. The grand goal would be to show that, when we restrict $f_*$ to $Z_n(X)$ and $B_n(X)$, we have $f_*(Z_n(X)) \leq Z_n(Y)$ and $f_*(B_n(X)) \leq B_n(Y)$.
But there is a problem: if $T_i$ is a simplex of $X$, then we have no guarantee that $f(T_i)$ is a simplex of $Y$; it might just be some fairly arbitrary subset of $Y$ with no nice properties. In order for everything to work out, we need to ensure that the image of every simplex of $X$ is a simplex of $Y$.
$\textbf{Definition}$
Let $X$ and $Y$ be simplicial complexes, and $f: X \to Y$ a continuous function. We say that $f$ is a $\textit{simplicial map}$ if the image of every simplex of $X$ is a simplex of $Y$.
Most maps are not simplicial, but for simplicial maps, the idea above for constructing an induced homomorphism on homology works perfectly.
$\textbf{Proposition}$
Suppose $f: X \to Y$ is a simplicial map. Then, for each $n$,
\begin{equation}
f_*(Z_n(X)) \leq Z_n(Y) \quad \text{and} \quad f_*(B_n(X)) \leq B_n(Y).
\end{equation}
$\textbf{Proof:}$
We show first that, for any $n$-simplex $T$ of $X$, $\partial_n \circ f_*(T) = f_* \circ \partial_n(T)$. Suppose that $T = [v_0, \ldots, v_n]$ and that $f_*(T) = [w_0, \ldots, w_n]$, with $w_i = f(v_i)$. Then, we have
\begin{align*}
\partial_n \circ f_*(T) &= \partial_n([w_0, \ldots, w_n]) \\
&= \sum_{i=0}^{n} (-1)^i [w_0, \ldots, w_{i-1}, w_{i+1}, \ldots, w_n] \\
&= \sum_{i=0}^{n} (-1)^i f([v_0, \ldots, v_{i-1}, v_{i+1}, \ldots, v_n]) \\
&= f_* \left(\sum_{i=0}^{n} (-1)^i [v_0, \ldots, v_{i-1}, v_{i+1}, \ldots, v_n]\right) \\
&= f_* \circ \partial_n(T),
\end{align*}
as desired.
Now, suppose that $c = \sum_{i=0}^{r} a_i T_i \in Z_n(X)$, so that $\partial_n(c) = 0$. Then
\begin{equation}
0 = f_* \circ \partial_n(c) = \partial_n \circ f_*(c),
\end{equation}
so $f_*(c) \in Z_n(Y)$. Similarly, if $c = \partial_n(d) \in B_n(X)$, then
\begin{equation}
f_*(c) = f_* \circ \partial_n(d) = \partial_n \circ f_*(d),
\end{equation}
so $f_*(c) \in B_n(Y)$.
$\textbf{Remark}$
It may be the case that $f(v_i) = f(v_j)$ for some $i \neq j$, so that $f_*(T)$ is a lower-dimensional simplex. It is okay if a vertex appears multiple times in $f_*(T)$; this means that we treat $f_*(T)$ formally as an $n$-dimensional simplex; nothing in our definitions ever has to "know" that $f_*(T)$ is secretly lower-dimensional.
It is immediate from the definition that $f_*$ is a homomorphism.
Now we are ready to define the induced homomorphism on homology. Let $f: X \to Y$ be a simplicial map, let $c \in Z_n(X)$, and let $[c] = c + B_n(X)$ be its class in homology. Then we define $f_*: H_n(X) \to H_n(Y)$ by setting $f_*([c]) = [f_*(c)]$.
Let us verify that $f_*$ is well-defined. Suppose $[c] = [c']$. Then $c - c' = d$ for some $d \in B_n(X)$. We have $f_*(c) - f_*(c') = f_*(d) \in f_*(B_n(X)) \leq B_n(Y)$. Thus, $[f_*(c)] = [f_*(c')]$, so $f_*: H_n(X) \to H_n(Y)$ is indeed well-defined.
The induced homomorphism on homology satisfies all the same basic properties as does the induced homomorphism on fundamental groups. For example:
1.If $f: X \to Y$ and $g: Y \to Z$ are simplicial maps, then $(g \circ f)_* = g_* \circ f_*$.
2.If $f: X \to Y$ is a homotopy equivalence, then $f_*$ is an isomorphism.
# Exact Sequences
Although it is possible to compute homology directly from the definition, it is not always much fun to do so—computing the homology for a genus-$g$ surface would require a lot of simplices and matrix manipulations! We were able to compute the fundamental group for an arbitrary surface using the Seifert–Van Kampen Theorem, breaking it up into smaller regions and splicing together their fundamental groups. In particular, we were able to express $\pi_1(A \cup B)$ in terms of $\pi_1(A)$, $\pi_1(B)$, $\pi_1(A \cap B)$, and some information about how they all fit together. It would be nice if we could do that for homology as well.
In fact, we can relate the homology of $A \cup B$ to the homologies of $A$, $B$, and $A \cap B$, but the relation is a bit more complicated than in the case of fundamental groups. In particular, we relate $H_n(A \cup B)$ not just to $H_n(A)$, $H_n(B)$, and $H_n(A \cap B)$, but to all the homologies of these spaces, as well as to all the other homology of $A \cup B$.
Before we can state this connection, known as the Mayer–Vietoris sequence, we need to introduce the notion of an $\textit{exact sequence}$.
Recall chain complexes from the last chapter: these are sequences
\begin{equation}
\cdots \rightarrow A_{n+1} \xrightarrow{f_{n+1}} A_n \xrightarrow{f_n} A_{n-1} \rightarrow \cdots
\end{equation}
of abelian groups and maps between them such that composing any two consecutive maps gives the zero map, i.e. $f_n \circ f_{n+1} = 0$ for any $n$. This means that $\text{im}(f_{n+1}) \leq \text{ker}(f_n)$.
$\textbf{Definition}$
A sequence
\begin{equation}
\cdots \rightarrow A_{n+1} \xrightarrow{f_{n+1}} A_n \xrightarrow{f_n} A_{n-1} \rightarrow \cdots
\end{equation}
of abelian groups and maps is said to be exact at $A_n$ if $\text{im}(f_{n+1}) = \text{ker}(f_n)$. It is said to be exact if it is exact at all $A_n$.
It is sometimes the case that a sequence does not go on forever, or perhaps it only goes on forever in one direction. In this case, we say it is exact if it is exact at all positions other than the end or ends of the sequence.
It is useful to distinguish between two types of exact sequences: short ones and long ones.
$\textbf{Definition}$
An exact sequence of the form
\begin{equation}
0 \rightarrow A' \rightarrow A \rightarrow A'' \rightarrow 0
\end{equation}is said to be a $\textit{short exact sequence}$.
Naturally, we thus call a sequence with more than three (potentially) nonzero terms a $\textit{long exact sequence}$.
$\textbf{Example}$
If $A$ and $B$ are any two abelian groups, then we have a short exact sequence
\begin{equation}
0 \rightarrow A \xrightarrow{f} A \times B \xrightarrow{g} B \rightarrow 0,
\end{equation}where $f$ is defined by $f(a) = (a, 0)$ and $g$ is defined by $g(a, b) = b$. Let us check
that this is exact at $A$. The image of the map $0 \rightarrow A$ is just $0$. The kernel of $f$ is $0$,
because if $a \neq 0$, then $(a, 0) \neq (0, 0) \in A \times B$. Now let us check exactness at $B$.
The kernel of $B \rightarrow 0$ is all of $B$: everything gets mapped to $0$. The image of $g$ is
also all of $B$ because, for any $b \in B$, $g(0, b) = b$. Finally, let us check exactness at
$A \times B$. The image of $f$ is $\{(a, 0)\}$, and this is also the kernel of $g$. Hence the sequence
is exact at each position. Short exact sequences of the form given in Example are known as $\textit{split exact sequences}$.
Note that exactness at $A'$ means that $A' \rightarrow A$ is injective, and exactness at $A''$ means that $A \rightarrow A''$ is surjective.
$\textbf{Example}$
If $m$ and $n$ are any positive integers, consider the sequence
\begin{equation}
0 \rightarrow \mathbb{Z}/m\mathbb{Z} \rightarrow \mathbb{Z}/mn\mathbb{Z} \rightarrow \mathbb{Z}/n\mathbb{Z} \rightarrow 0,
\end{equation}where the maps $\mathbb{Z}/m\mathbb{Z} \rightarrow \mathbb{Z}/mn\mathbb{Z}$ and $\mathbb{Z}/mn\mathbb{Z} \rightarrow \mathbb{Z}/n\mathbb{Z}$ are given by $a + m\mathbb{Z} \mapsto an + mn\mathbb{Z}$ and $b + mn\mathbb{Z} \mapsto b + n\mathbb{Z}$, respectively. This sequence is a short exact sequence. If $m$ and $n$ are relatively prime, then this sequence is a split exact sequence by the Chinese Remainder Theorem, but otherwise, it is not. For example, if $p$ is prime, the sequence
\begin{equation}
0 \rightarrow \mathbb{Z}/p\mathbb{Z} \rightarrow \mathbb{Z}/p^2\mathbb{Z} \rightarrow \mathbb{Z}/p\mathbb{Z} \rightarrow 0
\end{equation}is exact but not split exact.
In fact, we can, in some sense, classify all short exact sequences: If $A$ and $B$ are two abelian groups with $A \leq B$, then
\begin{equation}
0 \rightarrow A \rightarrow B \rightarrow B/A \rightarrow 0
\end{equation}is an exact sequence, and any exact sequence can be expressed in this way.
# The Mayer–Vietoris Sequence
Suppose $X$ is a topological space (implicitly with a triangulation), and $A$ and $B$ are subspaces with $A \cup B = X$. Furthermore, assume that $A$ and $B$ are each unions of simplices in $X$.
$\textbf{Proposition 14.3}$
For any $n$, we have a short exact sequence
\begin{equation}
0 \to C_n(A \cap B) \xrightarrow{\alpha} C_n(A) \times C_n(B) \xrightarrow{\beta} C_n(A \cup B) \to 0
\end{equation}of abelian groups. Here $\alpha$ is given by inclusion: an $n$-chain $c$ of $A \cap B$ is also an $n$-chain of $A$ and an $n$-chain of $B$, so we define $\alpha(c) = (c, c)$. Similarly, an $n$-chain of $A$ is an $n$-chain of $A \cup B$, and similarly for $B$. We define $\beta(c, d) = c - d$.
$\textbf{Remark}$
The minus sign in the definition of $\beta$ is necessary to make this sequence exact!
$\textbf{Proof}$
It is clear that $\alpha$ is injective, so this sequence is exact at $C_n(A \cap B)$. Now, let $N = \sum_{i=1}^{r} a_i T_i$ be an $n$-chain of $A \cup B$. Let us suppose that $T_1, ..., T_k$ are in $A$ and $T_{k+1}, ..., T_r$ are in $B$. (Each simplex must be in either $A$ or $B$; some of them may be in both, so let us—arbitrarily—group them with $A$.) Let $c = \sum_{i=1}^{k} a_i T_i$ and $d = \sum_{i=k+1}^{r} a_i T_i$. Then $c \in C_n(A)$ and $d \in C_n(B)$, and $N = c + d = \beta(c, -d)$. Thus $\beta$ is surjective.
Finally, we must show that $\text{im} \, \alpha = \text{ker} \, \beta$. We have
\begin{equation}
\text{im} \, \alpha = \text{ker} \, \beta = \{(c, c) : c \in C_n(A \cap B)\}.
\end{equation}Thus the sequence is also exact at $C_n(A) \times C_n(B).$
A general phenomenon in mathematics is that a short exact sequence of chains induces a long exact sequence in homology. In this case, the resulting long exact sequence is the Mayer--Vietoris sequence.
$\textbf{Theorem(Mayer–Vietoris)}$
Let $X = A \cup B$, where $X$, $A$, and $B$ are equipped with triangulations. Then there is a long exact sequence.

of homology groups.
It is possible to prove—for once and for all—that short exact sequences at the level of chains give rise to long exact sequences in homology. We will think in terms of homology of topological spaces, but nothing in the proof depends on that. We’ll leave certain aspects of the proof for Problems 3–5.
$\textbf{Proof}$
The first step in the proof is to define the maps $\alpha_*, \beta_*, \text{and} \, \partial_*$. The first two are straightforward: they are the induced maps in homology coming from the maps $\alpha$ and $\beta$ of Proposition 14.3. The map $\partial_*$ is more complicated: for each $n$, we wish to construct a homomorphism $\partial_* : H_n(A \cup B) \to H_{n-1}(A \cap B)$. Observe the following diagram of abelian groups:

This diagram $commutes$. This means that if we pick either square of the diagram and start from the top left corner and then take the horizontal arrow followed by the vertical arrow, we get the same result as we do if we first take the vertical one then the horizontal one.

commutes if and only if $\theta \circ \phi(w) = \rho \circ \psi(w)$ for all $w \in W$.
In order to construct $\partial_* : H_n(A \cup B) \to H_{n-1}(A \cap B)$, we first attempt to construct a homomorphism $\delta : Z_n(A \cup B) \to Z_{n-1}(A \cap B)$ in an interesting way. We will fail. But we will fail in exactly the way we need to get a homomorphism on homology! Our attempt is as follows:
(1) Pick $x \in Z_n(A \cup B)$; this means that $\partial^{(3)}(x) = 0$.
(2) We saw earlier that $\beta_n$ is surjective, so we can find some $y \in C_n(A) \times C_n(B)$ so that $\beta_n(y) = x$. (There may be many choices for $y$; pick one at random.)
(3) Now, look at $z = \partial^{(2)}(y)$. Because the right square of (14.2) commutes, we have $\partial^{(3)} \circ \beta_n(y) = \beta_{n-1} \circ \partial^{(2)}(y) = 0$, so $\beta_{n-1}(z) = 0$.
(4) The bottom row of (14.2) is exact and $\beta_{n-1}(z) = 0$, so there is some $w \in C_{n-1}(A \cap B)$ so that $\alpha_{n-1}(w) = z$.
(5) We wish to set $\delta(x) = w$.
We now check that $w \in Z_{n-1}(A \cap B)$. Observe that $z \in Z_{n-1}(A) \times Z_{n-1}(B)$. (In fact, $z \in B_{n-1}(A) \times B_{n-1}(B)$, which is stronger, but we will not need this at the moment.) Consider the commutative square

Because $\partial^{(2)}(z) = \partial^{(2)} \circ \alpha_{n-1}(w) = 0$, we also have $\alpha_{n-2} \circ \partial^{(1)}(w) = 0$; by Proposition 14.3, $\alpha_{n-2}$ is injective, so $\partial^{(1)}(w) = 0$, so $w \in Z_{n-1}(A \cap B)$.
So, it appears that we have made a map $\delta : Z_n(A \cup B) \to Z_{n-1}(A \cap B)$. However, this is just an illusion. The problem is that it is not well-defined: we had many choices for $y$, and we just chose one at random. In fact, there is generally no systematic way of picking $y$ so as to make $\delta$ into a homomorphism. (We can make a function, but it will not have the homomorphism property.)
Nonetheless, all is not lost: Imagine we have two elements $y$ and $y'$ in $C_n(A) \times C_n(B)$ with $\beta_n(y) = \beta_n(y')$. Construct $z'$ and $w'$ similarly to the way we constructed $z$ and $w$ before. Since $\beta_n(y) = \beta_n(y') = x$, we have $\beta_n(y - y') = 0$, which means by Proposition 14.3 that $y - y' \in \text{im}(\alpha_n)$, say $y - y' = \alpha_n(v)$. Then $\partial^{(1)}(v) = w - w'$.
By definition, this means that $w - w' \in B_{n-1}(A \cap B)$. As a result, although $\delta$ didn't give us a well-defined map from $Z_n(A \cup B)$ to $Z_{n-1}(A \cap B)$, it did give us a well-defined map to $Z_{n-1}(A \cap B)$ up to a boundary - which is exactly the same as a map to $H_{n-1}(A \cap B)$. Thus we have a well-defined map $\delta : Z_n(A \cup B) \to H_{n-1}(A \cap B)$. One can now check that $\delta$ is in fact a homomorphism,as you will do in Problem 3.
In fact, $\delta$ induces a well-defined map $\partial_* : H_n(A \cup B) \to H_{n-1}(A \cap B)$. In order to verify that, we have to check that if $x$ and $x'$ in $Z_n(A \cup B)$ differ by a boundary, then $\delta(x) = \delta(x')$; equivalently, $\delta(x - x') = 0$. We leave this for you to do in Problem 4.
Now that we have constructed the homomorphisms, we have to show that the sequence is exact. We need to show that the sequence is exact at $H_n(A \cap B)$, $H_n(A) \times H_n(B)$, and at $H_n(A \cup B)$. We prove exactness at $H_n(A) \times H_n(B)$ below and leave the other two for exercises. $\textbf{Warning}$: Diagram chases can be enjoyable to work out on your own, but they are never fun to read. Try it on your own first!
We start with exactness at $H_n(A) \times H_n(B)$. First, $\text{im}(\alpha_*) \leq \text{ker}(\beta_*)$, because this is true at the level of chains: if $x \in Z_n(A \cap B)$, then we have $[\beta \circ \alpha(x)] = \beta_* \circ \alpha_*([x])$, and the left side is zero by Proposition 14.3. For the other direction, suppose that $y \in Z_n(A) \times Z_n(B)$ and that $\beta_*([y]) = 0$. Then $\beta_n(y) \in B_n(A \cup B)$, so that $\beta_n(y) = \partial^3(z)$ for some $z \in C_{n+1}(A \cup B)$. Because $\beta_{n+1}$ is surjective, there is some $w \in C_{n+1}(A) \times C_{n+1}(B)$ so that $\beta_{n+1}(w) = z$. Now, $\beta_n(y - \partial^2(w)) = 0$, so $y - \partial^2(w) = \alpha_n(v)$ for some $v \in C_n(A \cap B)$. Now, $\alpha_{n-1} \circ \partial^1(v) = \partial^2 \circ \alpha_n(v) = 0$, and since $\alpha_{n-1}$ is injective, $\partial^1(v) = 0$, so $v \in Z_1(A \cap B)$. Finally, $\alpha_*([v]) = [y - \partial^2(w)] = [y]$, so $[y] \in \text{im}(\alpha_*)$, as desired.
The arguments for exactness at $H_n(A \cap B)$ and $H_n(A \cup B)$ are similar diagram chases. We leave them for Problem 5.
$\textbf{Problems}$
(3) Show that $\delta : Z_n(A \cup B) \to H_{n-1}(A \cap B)$, constructed in the proof of the Mayer–Vietoris sequence, is a homomorphism.
(4) Show that if $w \in B_n(A \cup B)$, then $\delta(w) = 0$, where $\delta$ is as in the proof of the Mayer–Vietoris sequence.
(5) In the proof of the Mayer–Vietoris sequence, prove that the sequence is exact at $H_n(A \cap B)$ and $H_n(A \cup B)$.
# Homology of Orientable Surfaces
Okay, so now that we have the theorem, it’s time to learn how to use it! We will use it to compute the homology of an orientable surface of genus $g$. In order to do this, we first compute the homology of a once-punctured surface of genus $g$ (or, up to homotopy equivalence, a surface of genus $g$ with a small open disk removed). This will turn out to be easier, based on the following observation: we saw earlier that a punctured torus is homotopy equivalent to a wedge sum of two circles. More generally, a once-punctured surface of genus $g$ is homotopy equivalent to a wedge sum of $2g$ circles. We will take advantage of the following fact that we did not prove (and whose proof is beyond the scope of this book): If two spaces are homotopy equivalent, then they have the same homology groups. So, we prove the following by induction using the Mayer–Vietoris sequence.
$\textbf{Proposition}$
Let $Y_r$ denote a wedge sum of $r$ circles. Then
\begin{equation}
H_n(Y_r) =
\begin{cases}
\mathbb{Z} & \text{if } n = 0, \\
\mathbb{Z}^r & \text{if } n = 1, \\
0 & \text{if } n \geq 2.
\end{cases}
\end{equation}
$\textbf{Proof}$
When $r = 1$, the statement is true, so suppose $r \geq 2$ and work by induction. In the Mayer–Vietoris sequence, let $A$ denote a wedge of $r - 1$ of the circles and let $B$ denote the remaining circle, so that $A \cap B$ is a point and $A \cup B = Y_r$. Because $A$ and $B$ have dimension $1$, all homology in dimension $\geq 2$ is zero. Thus, plugging in
the values we know (and recalling that $H_0(Y_r) = \mathbb{Z}$ since $Y_r$ is connected), we have
an exact sequence
\begin{equation}
0 \rightarrow \mathbb{Z}^{r-1} \times \mathbb{Z} \rightarrow H_1(Y_r) \rightarrow \mathbb{Z} \rightarrow \mathbb{Z} \times \mathbb{Z} \rightarrow \mathbb{Z} \rightarrow 0.
\end{equation}
Let us first think about the $H_0$ part of the sequence
\begin{equation}
\mathbb{Z} \rightarrow \mathbb{Z} \times \mathbb{Z} \rightarrow \mathbb{Z} \rightarrow 0.
\end{equation}
The map $\mathbb{Z} \times \mathbb{Z} \rightarrow \mathbb{Z}$ is surjective, and its kernel is the subgroup of the form $(n, n)$.But that is exactly the image of the map $\mathbb{Z} \rightarrow \mathbb{Z} \times \mathbb{Z}$, and this is injective. Thus
the map $H_1(A \cup B) \rightarrow H_0(A \cap B)$ is the zero map (its image is the kernel of the
map $\mathbb{Z} \rightarrow \mathbb{Z} \times \mathbb{Z}$, which is zero), so the map $H_1(A) \times H_1(B) \rightarrow H_1(A \cup B)$ must be surjective. It is also injective because $H_1(A \cap B) = 0$, so it is an isomorphism.
Since we already know that $H_1(A) \cong \mathbb{Z}^{r-1}$ and $H_1(B) \cong \mathbb{Z}$, we have $H_1(A \cup B) =
H_1(Y_r) \cong \mathbb{Z}^r$.
Now we have everything we need to compute the homology of surfaces of genus $g$.
$\textbf{Theorem}$
Let $X_g$ be a surface of genus $g$. Then
\begin{equation}
H_n(X_g) \cong
\begin{cases}
\mathbb{Z} & \text{if } n = 0, 2, \\
\mathbb{Z}^{2g} & \text{if } n = 1, \\
0 & \text{if } n \geq 3.
\end{cases}
\end{equation}
$\textbf{Proof}$
Let $A$ be $X_g$ with a point removed, and let $B$ be a small neighborhood of the deleted point. Then $A \cap B$ is an annulus, which is homotopy equivalent to a circle. So, we know the homology groups of $A$, $B$, and $A \cap B$. Plugging in everything we know into the Mayer–Vietoris sequence, we have (starting with $0$ for $H^2(A) \times H^2(B)$)
\begin{equation}
0 \to H^2(X_g) \to \mathbb{Z} \to \mathbb{Z}^{2g} \to H^1(X_g) \to 0,
\end{equation}where we end with a $0$ because the map $H^1(X_g) \to H^0(A \cap B)$ is the zero map, as in Proposition above The map $H^2(X_g) \to H^1(A \cap B) \cong \mathbb{Z}$ is injective, and there are only two groups with injective maps to $\mathbb{Z}$: these are $0$ and $\mathbb{Z}$ itself. So, which is it?
We actually already know the answer to this: we had saw that the second homology group of a compact connected orientable surface is isomorphic to $\mathbb{Z}$. Thus $H^2(X_g) \cong \mathbb{Z}$.
Now, to compute $H^1(X_g)$, we note that the homomorphism $H^1(A) \times H^1(B) \to H^1(X_g)$ is surjective, and that $H^1(A) \cong \mathbb{Z}^{2g}$. Furthermore, we can use exactness to compute the rank of $H^1(X_g)$: in any exact sequence of finitely generated abelian groups starting and ending with $0$’s, the alternating sum of the ranks is equal to $0$. (The argument is very similar to the one we used to show that the Euler characteristic is the alternating sum of the ranks of the homology groups.) This shows that the rank of $H^1(X_g)$ is $2g$, and the only abelian group of rank $2g$ for which there is a surjection from $\mathbb{Z}^{2g}$ is $\mathbb{Z}^{2g}$ itself. This completes the proof.