Canonical: https://knowlpedia.com/algebra-homological/snake-lemma/

# Snake lemma

From a commutative diagram with exact rows, produces an exact sequence of kernels and cokernels with a canonical connecting map.

**Snake lemma**: Let \(R\) be a ring, and suppose a commutative diagram of \(R\)-modules has [exact](https://knowlpedia.com/algebra-modules/exact-sequence-modules/) rows
```tikz-cd
0 \arrow[r] & A' \arrow[r, "i"] \arrow[d, "f'"] & A \arrow[r, "p"] \arrow[d, "f"] & A'' \arrow[r] \arrow[d, "f''"] & 0 \\
0 \arrow[r] & B' \arrow[r, "j"] & B \arrow[r, "q"] & B'' \arrow[r] & 0
```
Then there is a homomorphism \(\delta:\ker(f'')\to\operatorname{coker}(f')\), the **connecting homomorphism**, such that the sequence
\[
0 \to \ker(f') \to \ker(f) \to \ker(f'') \xrightarrow{\ \delta\ } \operatorname{coker}(f') \to \operatorname{coker}(f) \to \operatorname{coker}(f'') \to 0
\]
is exact. The maps other than \(\delta\) are induced by \(i,p,j,q\), and \(\operatorname{coker}(f')=B'/\operatorname{im}(f')\) is the [cokernel](https://knowlpedia.com/algebra-modules/cokernel-module/).

The name comes from the picture: the kernels sit above the rows, the cokernels below, and \(\delta\) snakes from \(\ker(f'')\) down to \(\operatorname{coker}(f')\):

```tikz-cd
\begin{tikzcd}
0 \arrow[r] & \ker f' \arrow[r] \arrow[d] & \ker f \arrow[r] \arrow[d] & \ker f'' \arrow[d]
  \arrow[dddll, "\delta" description, rounded corners,
    to path={ -- ([xshift=2ex]\tikztostart.east)
      |- ($(\tikztostart)!0.5!(\tikztotarget)$) [near end]\tikztonodes
      -| ([xshift=-2ex]\tikztotarget.west)
      -- (\tikztotarget)}] & \\
0 \arrow[r] & A' \arrow[r, "i"] \arrow[d, "f'" near start] & A \arrow[r, "p"] \arrow[d, "f" near start] & A'' \arrow[r] \arrow[d, "f''" near start] & 0 \\[1.2em]
0 \arrow[r] & B' \arrow[r, "j"] \arrow[d] & B \arrow[r, "q"] \arrow[d] & B'' \arrow[r] \arrow[d] & 0 \\
& \operatorname{coker} f' \arrow[r] & \operatorname{coker} f \arrow[r] & \operatorname{coker} f'' \arrow[r] & 0
\end{tikzcd}
```

The same statement holds in any [abelian category](https://knowlpedia.com/algebra-category-theory/abelian-category/), with [kernels](https://knowlpedia.com/algebra-category-theory/kernel-categorical/) and [cokernels](https://knowlpedia.com/algebra-category-theory/cokernel-categorical/) taken in the categorical sense.

## Construction of the connecting homomorphism

Given \(x\in \ker(f'')\subseteq A''\):
1. pick \(a\in A\) with \(p(a)=x\);
2. since \(f''(x)=0\), commutativity implies \(q(f(a))=0\), hence \(f(a)\in \operatorname{im}(j)\);
3. choose \(b'\in B'\) with \(j(b')=f(a)\);
4. define \(\delta(x)\) to be the class of \(b'\) in \(\operatorname{coker}(f')=B'/\operatorname{im}(f')\).

A standard diagram chase shows this is well-defined (independent of choices) and gives exactness.

The map \(\delta\) is natural in the diagram, and it is the prototype for the [connecting homomorphism](https://knowlpedia.com/algebra-homological/connecting-homomorphism-lemma/) appearing in long exact sequences.

## Examples

1. **Induced map on quotients: the “kernel–cokernel” exact sequence.**
   Let \(g:M\to M'\) be an \(R\)-linear map, and let \(N\subseteq M\), \(N'\subseteq M'\) satisfy \(g(N)\subseteq N'\). Consider the commutative diagram with exact rows:
   \[
   \begin{array}{ccccccccc}
   0 &\to& N &\to& M &\to& M/N &\to& 0\\
    & & \downarrow g|_N & & \downarrow g & & \downarrow \overline g & & \\
   0 &\to& N' &\to& M' &\to& M'/N' &\to& 0
   \end{array}
   \]
   The snake lemma produces the exact sequence
   \[
   0\to \ker(g|_N)\to \ker(g)\to \ker(\overline g)\xrightarrow{\delta}
   \operatorname{coker}(g|_N)\to \operatorname{coker}(g)\to \operatorname{coker}(\overline g)\to 0,
   \]
   which cleanly measures how kernels/cokernels change when passing to quotients.

2. **Boundary map in homology from a short exact sequence of complexes.**
   Given a degreewise short exact sequence of [chain complexes](https://knowlpedia.com/algebra-homological/chain-complex/)
   \[
   0\to C'_\bullet \to C_\bullet \to C''_\bullet \to 0,
   \]
   one applies the snake lemma to the diagram of cycles and boundaries in each degree to construct the connecting map
   \[
   \partial: H_n(C''_\bullet)\longrightarrow H_{n-1}(C'_\bullet),
   \]
   yielding the usual long exact sequence in [homology](https://knowlpedia.com/algebra-homological/homology-module/). (This is the chain-complex analogue of [long exact sequences from derived functors](https://knowlpedia.com/algebra-homological/long-exact-sequence-derived/).)

3. **Computing a boundary map concretely (multiplication on a quotient).**
   Fix integers \(m,n\) and consider the diagram
   \[
   \begin{array}{ccccccccc}
   0&\to& \mathbb Z &\xrightarrow{\cdot m}& \mathbb Z &\to& \mathbb Z/m &\to& 0\\
    && \downarrow \cdot n && \downarrow \cdot n && \downarrow \cdot n &&\\
   0&\to& \mathbb Z &\xrightarrow{\cdot m}& \mathbb Z &\to& \mathbb Z/m &\to& 0
   \end{array}
   \]
   The connecting map \(\delta:\ker(\cdot n:\mathbb Z/m\to \mathbb Z/m)\to \operatorname{coker}(\cdot n:\mathbb Z\to \mathbb Z)\cong \mathbb Z/n\)
   sends a class \(\overline{x}\in\mathbb Z/m\) with \(nx\in m\mathbb Z\) to the class of \(\frac{nx}{m}\) in \(\mathbb Z/n\). This is a concrete instance of how \(\delta\) encodes the failure of lifting across the diagram.
