[proofplan]
We apply the [Snake Lemma](/theorems/1930) to the short exact sequence of chain complexes $0 \to C_\bullet(A) \xrightarrow{i_\bullet} C_\bullet(X) \xrightarrow{q_\bullet} C_\bullet(X,A) \to 0$, where $i_\bullet$ is the inclusion and $q_\bullet$ is the quotient map. The Snake Lemma produces connecting homomorphisms $\partial: H_n(X,A) \to H_{n-1}(A)$ and the long exact sequence. Exactness at each of the three positions follows from the Snake Lemma applied to the commutative diagram of cycles, boundaries, and homology groups. Naturality of $\partial$ follows from the naturality of the Snake Lemma construction with respect to maps of short exact sequences.
[/proofplan]
[step:Verify that the inclusion and quotient maps form a short exact sequence of chain complexes]
The inclusion $i: A \hookrightarrow X$ induces, for each $n$, an injective homomorphism $i_n: C_n(A) \to C_n(X)$ that sends a singular $n$-simplex $\sigma: \Delta^n \to A$ to the composite $i \circ \sigma: \Delta^n \to X$. This map is injective because distinct singular simplices into $A$ remain distinct as singular simplices into $X$.
Define the quotient chain groups $C_n(X, A) = C_n(X) / i_n(C_n(A))$ and let $q_n: C_n(X) \to C_n(X, A)$ be the quotient map. The sequence
\begin{align*}
0 \to C_n(A) \xrightarrow{i_n} C_n(X) \xrightarrow{q_n} C_n(X, A) \to 0
\end{align*}
is exact at each position: $i_n$ is injective, $q_n$ is surjective by definition, and $\ker(q_n) = i_n(C_n(A)) = \operatorname{im}(i_n)$.
We verify that $i_\bullet$ and $q_\bullet$ are chain maps. For $i_\bullet$: the boundary operator $d_n^A: C_n(A) \to C_{n-1}(A)$ is defined by the same face-map formula as $d_n^X$, so $i_{n-1} \circ d_n^A = d_n^X \circ i_n$. For $q_\bullet$: since $d_n^X$ sends $C_n(A)$ into $C_{n-1}(A)$ (because $d_n^A$ is the restriction of $d_n^X$), the boundary $d_n^X$ descends to a well-defined map $\bar{d}_n: C_n(X,A) \to C_{n-1}(X,A)$ on the quotient, and $q_{n-1} \circ d_n^X = \bar{d}_n \circ q_n$ by construction.
[guided]
The short exact sequence $0 \to C_\bullet(A) \to C_\bullet(X) \to C_\bullet(X,A) \to 0$ is the algebraic input that drives the entire construction. The key point is that this is a short exact sequence of **chain complexes**, not merely of abelian groups: the differentials on all three complexes are compatible. This compatibility is what allows the Snake Lemma to produce connecting homomorphisms that interact correctly with the differentials on each level.
Why is $i_n$ injective? A singular $n$-simplex $\sigma: \Delta^n \to A$ is a continuous map into $A$. The map $i \circ \sigma: \Delta^n \to X$ is a different function (with a larger codomain), and two distinct maps $\sigma_1 \neq \sigma_2$ give distinct composites $i \circ \sigma_1 \neq i \circ \sigma_2$ because $i$ is injective. Since $C_n(A)$ and $C_n(X)$ are free abelian groups on these generators, $i_n$ is injective on generators and hence on the whole group.
Why does $d_n^X$ preserve $C_n(A)$? Because each face of a simplex $\sigma: \Delta^n \to A$ is again a simplex into $A$: the restriction $\sigma|_{[v_0,\ldots,\hat{v}_j,\ldots,v_n]}: \Delta^{n-1} \to A$ has image in $A$ since $\sigma$ maps into $A$.
[/guided]
[/step]
[step:Apply the Snake Lemma to obtain the connecting homomorphism and long exact sequence]
By the [Snake Lemma](/theorems/1930), any short exact sequence of chain complexes
\begin{align*}
0 \to A_\bullet \xrightarrow{i} B_\bullet \xrightarrow{q} C_\bullet \to 0
\end{align*}
yields a long exact sequence in homology:
\begin{align*}
\cdots \to H_n(A_\bullet) \xrightarrow{i_*} H_n(B_\bullet) \xrightarrow{q_*} H_n(C_\bullet) \xrightarrow{\partial} H_{n-1}(A_\bullet) \xrightarrow{i_*} H_{n-1}(B_\bullet) \to \cdots
\end{align*}
Applying this to the short exact sequence $0 \to C_\bullet(A) \xrightarrow{i_\bullet} C_\bullet(X) \xrightarrow{q_\bullet} C_\bullet(X,A) \to 0$ gives the long exact sequence
\begin{align*}
\cdots \to H_n(A) \xrightarrow{i_*} H_n(X) \xrightarrow{q_*} H_n(X, A) \xrightarrow{\partial} H_{n-1}(A) \xrightarrow{i_*} H_{n-1}(X) \to \cdots
\end{align*}
with connecting homomorphism $\partial: H_n(X, A) \to H_{n-1}(A)$.
[guided]
The connecting homomorphism $\partial$ is constructed as follows. Let $[c] \in H_n(X, A)$ be a relative homology class, represented by a chain $c \in C_n(X)$ with $q_n(c) \in \ker(\bar{d}_n)$. The condition $\bar{d}_n(q_n(c)) = 0$ means $q_{n-1}(d_n(c)) = 0$, which by exactness of the short exact sequence means $d_n(c) \in \operatorname{im}(i_{n-1}) = i_{n-1}(C_{n-1}(A))$. So there exists a unique $a \in C_{n-1}(A)$ with $i_{n-1}(a) = d_n(c)$.
We check that $a$ is a cycle: $i_{n-2}(d_{n-1}^A(a)) = d_{n-1}^X(i_{n-1}(a)) = d_{n-1}^X(d_n(c)) = 0$ since $d \circ d = 0$. Since $i_{n-2}$ is injective, $d_{n-1}^A(a) = 0$, so $a \in Z_{n-1}(A)$.
The connecting homomorphism is then $\partial([c]) = [a] \in H_{n-1}(A)$. The Snake Lemma guarantees that this is well-defined (independent of the choice of representative $c$ and the lift) and that the resulting sequence is exact at $H_n(X, A)$, $H_{n-1}(A)$, and $H_{n-1}(X)$.
[/guided]
[/step]
[step:Verify naturality of the long exact sequence with respect to maps of pairs]
Let $f: (X, A) \to (Y, B)$ be a map of pairs, so $f: X \to Y$ is continuous and $f(A) \subseteq B$. Then $f$ induces a morphism of short exact sequences: the diagram
\begin{align*}
\begin{array}{ccccccc}
0 & \to & C_n(A) & \xrightarrow{i_n} & C_n(X) & \xrightarrow{q_n} & C_n(X,A) & \to & 0 \\
& & \downarrow f_\# & & \downarrow f_\# & & \downarrow \bar{f}_\# & & \\
0 & \to & C_n(B) & \xrightarrow{i_n} & C_n(Y) & \xrightarrow{q_n} & C_n(Y,B) & \to & 0
\end{array}
\end{align*}
commutes for each $n$. The left square commutes because $f(A) \subseteq B$ implies $f_\#$ sends $C_n(A)$ into $C_n(B)$. The right square commutes because $\bar{f}_\#$ is the map induced on quotients by $f_\#$.
By the naturality of the Snake Lemma with respect to morphisms of short exact sequences, the induced maps on homology commute with the connecting homomorphism:
\begin{align*}
\partial \circ \bar{f}_* = f_* \circ \partial: H_n(X, A) \to H_{n-1}(B).
\end{align*}
This gives the naturality of the entire long exact sequence.
[/step]