# Commutative Algebra/The Cayley–Hamilton theorem and Nakayama's lemma
## Determinants within a commutative ring

We shall now derive the notion of a determinant in the setting of a commutative ring.
Definition 7.1 (Determinant):
Let $R$ be a commutative ring, and let $n\in \mathbb {N}$. A determinant is a function $\det :R^{n\times n}\to R$ satisfying the following three axioms:
* $\det I_{n}=1$, where $I_{n}$ is the $n\times n$ identity matrix.
* If $A$ is a matrix such that two adjacent columns are equal, then $\det A=0$.
* For each $j\in \{1,\ldots ,n\}$ we have $\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j}+c\mathbf {b} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})=\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})+c\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {b} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})$, where $\mathbf {a} _{1},\ldots ,\mathbf {a} _{n},\mathbf {b} _{j}$ are columns and $c\in R$.
We shall later see that there exists exactly one determinant.
Theorem 7.2 (Properties of a (the) determinant):
* If $A\in R^{n\times n}$ has a column consisting entirely of zeroes, then $\det A=0$.
* If $A$ is a matrix, and one adds a multiple of one column to an adjacent column, then $\det A$ does not change.
* If two adjacent columns of $A$ are exchanged, then $\det A$ is multiplied by $-1$.
* If any two columns of a matrix $A$ are exchanged, then $\det A$ is multiplied by $-1$.
* If $A$ is a matrix, and one adds a multiple of one column to any other column, then $\det A$ does not change.
* If $A$ is a matrix that has two equal columns, then $\det A=0$.
* Let $\sigma \in S_{n}$ be a permutation, where $S_{n}$ is the $n$-th symmetric group. If $A=(\mathbf {a} _{1},\ldots ,\mathbf {a} _{n})$, then $\det(\mathbf {a} _{\sigma (1)},\ldots ,\mathbf {a} _{\sigma (n)})=\operatorname {sgn} \sigma \det A$.
Proofs:
1. Let $A=(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})$, where the $j$-th column $\mathbf {a} _{j}$ is the zero vector. Then by axiom 3 for the determinant setting $c=-1$,
    $\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})=\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j}-\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})=\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})-\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})=0$.
Alternatively, we may also set $c=1$ and $\mathbf {b} _{j}=\mathbf {a} _{j}=\mathbf {0}$ to obtain
    $\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j}+c\mathbf {b} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})=(1+c)\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})$,
from which the theorem follows by subtracting $\det A$ from both sides.
Those proofs correspond to the proofs for $T0=0$ for a linear map $T$ (in whatever context).
2. If we set $\mathbf {b} _{j}=\mathbf {a} _{j+1}$ or $\mathbf {b} _{j}=\mathbf {a} _{j-1}$ (dependent on whether we add the column left or the column right to the current column), then axiom 3 gives us
    $\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j}+c\mathbf {b} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})=\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})+c\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {b} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})$,
where the latter determinant is zero because we have to adjacent equal columns.
3. Consider the two matrices $A:=(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})$ and $B:=(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j+1},\mathbf {a} _{j},\ldots ,\mathbf {a} _{n})$. By 7.2, 2. and axiom 3 for determinants, we have
    ${\begin{aligned}\det B&=\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j+1}+\mathbf {a} _{j},\mathbf {a} _{j},\ldots ,\mathbf {a} _{n})\\&=\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j+1}+\mathbf {a} _{j},-\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})\\&=\det(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j},-\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})\\&=-\det A\end{aligned}}$.
4. We exchange the $j$-th and $k$-th column by first moving the $j$-th column successively to spot $k$ (using $|j-k|$ swaps) and the $k$-th column, which is now one step closer to the $j$-th spot, to spot $j$ using $|j-k|-1$ swaps. In total, we used an odd number of swaps, and all the other columns are in the same place since they moved once to the right and once to the left. Hence, 4. follows from applying 3. to each swap.
5. Let's say we want to add $c\cdot \mathbf {a} _{k}$ to the $j$-th column. Then we first use 4. to put the $j$-th column adjacent to $\mathbf {a} _{k}$, then use 2. to do the addition without change to the determinant, and then use 4. again to put the $j$-th column back to its place. In total, the only change our determinant has suffered was twice multiplication by $-1$, which cancels even in a general ring.
6. Let's say that the $j$-th column and the $k$-th column are equal, $k\neq j$. Then we subtract column $j$ from column $k$ (or, indeed, the other way round) without change to the determinant, obtain a matrix with a zero column and apply 1.
7. Split $\sigma$ into swaps, use 4. repeatedly and use further that $\operatorname {sgn}$ is a group homomorphism.$\Box$
Note that we have only used axioms 2 & 3 for the preceding proof.
The following lemma will allow us to prove the uniqueness of the determinant, and also the formula $\det(AB)=\det A\det B$.
Lemma 7.3:
Let $A=(a_{i,j})_{1\leq i,j\leq n}$ and $B=(b_{i,j})_{1\leq i,j\leq n}$ be two $n\times n$ matrices with entries in a commutative ring $R$. Then
    $\det(AB)=\det A\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )b_{1,\sigma (1)}\cdots b_{n,\sigma (n)}$.
Proof:
The matrix $AB$ has $k$-th columns $\sum _{\nu =1}^{n}b_{\nu ,k}\mathbf {a} _{\nu }$. Hence, by axiom 3 for determinants and theorem 7.2, 7. and 6., we obtain, denoting $AB=:C=(c_{i,j})_{1\leq i,j\leq n}=(\mathbf {c} _{1},\ldots ,\mathbf {c} _{n})$:
    ${\begin{aligned}\det(AB)&=\sum _{\nu _{1}=1}^{n}b_{\nu _{1},1}\det(\mathbf {a} _{\nu _{1}},\mathbf {c} _{2},\ldots ,\mathbf {c} _{n})\\&=\sum _{\nu _{1}=1}^{n}\sum _{\nu _{2}}^{n}b_{\nu _{1},1}b_{\nu _{2},2}\det(\mathbf {a} _{\nu _{1}},\mathbf {a} _{\nu _{2}},\mathbf {c} _{3},\ldots ,\mathbf {c} _{n})\\&=\cdots =\sum _{\nu _{1},\ldots ,\nu _{n}=1}^{n}b_{\nu _{1},1}\cdots b_{\nu _{n},n}\det(\mathbf {a} _{\nu _{1}},\ldots ,\mathbf {a} _{\nu _{n}})\\&=\det A\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )b_{1,\sigma (1)}\cdots b_{n,\sigma (n)}\end{aligned}}$$\Box$
Theorem 7.4 (Uniqueness of the determinant):
For each commutative ring, there is at most one determinant, and if it exists, it equals
    $\det C=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )c_{1,\sigma (1)}\cdots c_{n,\sigma (n)}$.
Proof:
Let $C\in R^{n\times n}$ be an arbitrary matrix, and set $A=I_{n}$ and $B=C$ in lemma 7.3. Then we obtain by axiom 1 for determinants (the first time we use that axiom)
    $\det C=\det(I_{n}C)=1\cdot \sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )c_{1,\sigma (1)}\cdots c_{n,\sigma (n)}$.$\Box$
Theorem 7.5 (Multiplicativity of the determinant):
If $\det$ is a determinant, then
    $\det(AB)=\det A\det B$.
Proof:
From lemma 7.3 and theorem 7.4 we may infer
    $\det(AB)=\det(A)\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )b_{1,\sigma (1)}\cdots b_{n,\sigma (n)}=\det(A)\det(B)$.$\Box$
Theorem 7.6 (Existence of the determinant):
Let $R$ be a commutative ring. Then
    $\det(A):=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}$
is a determinant.
Proof:
First of all, $I_{n}$ has nonzero entries everywhere except on the diagonal. Hence, if $I_{n}=(a_{i,j})_{1\leq i,j\leq n}$, then $a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}$ vanishes except $\sigma (1)=1,\ldots ,\sigma (n)=n$, i.e. $\sigma$ is the identity. Hence $\det(I_{n})=1$.
Let now $A$ be a matrix whose $j$-th and $j+1$-th columns are equal. The function
    $f:S_{n}\to S_{n},f(\sigma )=k\mapsto {\begin{cases}\sigma (k)&k\notin \{j,j+1\}\\\sigma (j)&k=j+1\\\sigma (j+1)&k=j\end{cases}}$
is bijective, since the inverse is given by $f$ itself. Furthermore, since $f$ amounts to composing $\sigma$ with another swap, it is sign reversing. Hence, we have
    ${\begin{aligned}\det(A)&=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}\\&=\sum _{\operatorname {sgn} \sigma =1}a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}-\sum _{\operatorname {sgn} \sigma =-1}a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}\\&=\sum _{\operatorname {sgn} \sigma =1}a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}-\sum _{\operatorname {sgn} \sigma =1}a_{1,f(\sigma )(1)}\cdots a_{n,f(\sigma )(n)}\end{aligned}}$.
Now since the $j$-th and $j+1$-th column of $A$ are identical, $\forall k,l\in \mathbb {N} :a_{k,\sigma (l)}=a_{k,f(\sigma )(l)}$. Hence $\det A=0$.
Linearity follows from the linearity of each summand:
    $\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots (a_{\sigma ^{-1}(j),j}+cb_{\sigma ^{-1}(j),j})\cdots a_{n,\sigma (n)}=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots a_{\sigma ^{-1}(j),j}\cdots a_{n,\sigma (n)}+c\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots b_{\sigma ^{-1}(j),j}\cdots a_{n,\sigma (n)}$.$\Box$
Theorem 7.7:
The determinant of any matrix equals the determinant of the transpose of that matrix.
Proof:
Observe that inversion is a bijection on $S_{n}$ the inverse of which is given by inversion ($(\sigma ^{-1})^{-1}=\sigma$). Further observe that $\operatorname {sgn}(\sigma )=\operatorname {sgn}(\sigma ^{-1})$, since we just apply all the transpositions in reverse order. Hence,
    $\det A=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}=\sum _{\sigma ^{-1}\in S_{n}}\operatorname {sgn}(\sigma ^{-1})a_{1,\sigma ^{-1}(1)}\cdots a_{n,\sigma ^{-1}(n)}=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{\sigma (1),1}\cdots a_{\sigma (n),n}=\det A^{t}$.$\Box$
Theorem 7.8 (column expansion):
Let $A$ be an $n\times n$ matrix over a commutative ring $R$. For $1\leq i,j\leq n$ define $A_{i,j}$ to be the $(n-1)\times (n-1)$ matrix obtained by crossing out the $i$-th row and $j$-th column from $A$. Then for any $k\in \{1,\ldots ,n\}$ we have
    $\det A=\sum _{\nu =1}^{n}(-1)^{\nu +k}a_{\nu ,k}\det A_{\nu ,k}$.
Proof 1:
We prove the theorem from the formula for the determinant given by theorems 7.5 and 7.6.
Let $k\in \{1,\ldots ,n\}$ be fixed. For each $\nu \in \{1,\ldots ,n\}$, we define
    $f:S_{n-1}\to S_{n},f(\sigma ):=m\mapsto {\begin{cases}\nu &m=\nu \\\sigma (m)&m<\nu \wedge \sigma (m)<\nu \\\sigma (m)+1&m<\nu \wedge \sigma (m)\geq \nu \\\sigma (m-1)&m>\nu \wedge \sigma (m)<\nu \\\sigma (m-1)+1&m>\nu \wedge \sigma (m)\geq \nu \end{cases}}$.
Then
    ${\begin{aligned}\sum _{\nu =1}^{n}a_{\nu ,k}\det A_{\nu ,k}&=\sum _{\nu =1}^{n}(-1)^{\nu +k}a_{\nu ,k}\sum _{\sigma \in S_{n-1}}\operatorname {sgn}(\sigma )a_{1,f(\sigma )(1)}\cdots a_{k-1,f(\sigma )(k-1)}a_{k+1,f(\sigma )(k+1)}\cdots a_{n,f(\sigma )(n)}\\&=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}.\end{aligned}}$$\Box$
Proof 2:
We note that all of the above derivations could have been done with rows instead of columns (which amounts to nothing more than exchanging $a_{i,j}$ with $a_{j,i}$ each time), and would have ended up with the same formula for the determinant since
    $\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{1,\sigma (1)}\cdots a_{n,\sigma (n)}=\sum _{\sigma ^{-1}\in S_{n}}\operatorname {sgn}(\sigma ^{-1})a_{1,\sigma ^{-1}(1)}\cdots a_{n,\sigma ^{-1}(n)}=\sum _{\sigma \in S_{n}}\operatorname {sgn}(\sigma )a_{\sigma (1),1}\cdots a_{\sigma (n),n}$
as argued in theorem 7.7.
Hence, we prove that the function $R^{n\times n}\to R$ given by the formula $\sum _{\nu =1}^{n}(-1)^{\nu +k}a_{\nu ,k}\det A_{\nu ,k}$ satisfies 1 - 3 of 7.1 with rows instead of columns, and then apply theorem 7.4 with rows instead of columns.
1.
Set $A=I_{n}$ to obtain
    $\sum _{\nu =1}^{n}a_{\nu ,k}(-1)^{\nu +k}\det A_{\nu ,k}=(-1)^{2k}a_{k,k}\det A_{k,k}=1\cdot 1=1$.
2.
Let $A$ have two equal adjacent rows, the $j$-th and $j+1$-th, say. Then
    $\sum _{\nu =1}^{n}a_{\nu ,k}(-1)^{\nu +k}\det A_{\nu ,k}=(-1)^{j+k}\det A_{j,k}+(-1)^{j+1+k}\det A_{j+1,k}=0$,
since each of the $A_{\nu ,k}$ has two equal adjacent rows except for possibly $\nu =j$ and $\nu =j+1$, which is why, by theorem 7.6, the determinant is zero in all those cases, and further $A_{j,k}=A_{j+1,k}$, since in both we deleted "the same" row.
3.
Define $B:=(b_{i,j})_{1\leq i,j\leq n}:=(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {a} _{j}+c\mathbf {b} _{j}\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})^{t}$, and for each $\nu ,k\in \{1,\ldots ,n\}$ define $C_{\nu ,k}$ as the matrix obtained by crossing out the $\nu$-th row and the $k$-th column from the matrix $C:=(c_{i,j})_{1\leq i,j\leq n}:=(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},\mathbf {b} _{j}\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})^{t}$. Then by theorem 7.6 and axiom 3 for the determinant,
    ${\begin{aligned}\sum _{\nu =1}^{n}b_{\nu ,k}(-1)^{\nu +k}\det B_{\nu ,k}&=\sum _{\nu =1}^{j-1}a_{\nu ,k}(-1)^{\nu +k}(\det A_{\nu ,k}+c\det C_{\nu ,k})+(-1)^{j+k}(a_{j,k}+cb_{j,k})\det A_{j,k}+\sum _{\nu =j+1}^{n}a_{\nu ,k}(-1)^{\nu +k}(\det A_{\nu ,k}+c\det C_{\nu ,k})\\&=\sum _{\nu =1}^{n}a_{\nu ,k}(-1)^{\nu +k}\det A_{\nu ,k}+c\sum _{\nu =1}^{n}c_{\nu ,k}(-1)^{\nu +k}\det C_{\nu ,k}\\&=\det A+c\det C\end{aligned}}$.
Hence follows linearity by rows.$\Box$
For the sake of completeness, we also note the following lemma:
Lemma 7.9:
Let $A$ be an invertible matrix. Then $\det(A)$ is invertible.
Proof:
Indeed, $\det(A)^{-1}=\det(A^{-1})$ due to the multiplicativity of the determinant.$\Box$
The converse is also true and will be proven in the next subsection.

### Exercises

* Exercise 7.1.1: Argue that the determinant, seen as a map from the set of all matrices (where scalars are $1\times 1$-matrices), is idempotent.

## Cramer's rule in the general case

Theorem 7.10 (Cramer's rule, solution of linear equations):
Let $R$ be a commutative ring, let $A=(a_{i,j})_{1\leq i,j\leq n}$ be a matrix with entries in $R$ and let $\mathbf {b} =(b_{1},\ldots ,b_{n})^{t}$ be a vector. If $A$ is invertible, the unique solution to $Ax=\mathbf {b}$ is given by
    $x_{j}={\frac {\det A_{j}}{\det A}}$,
where $A_{j}$ is obtained by replacing the $j$-th column of $A$ by $\mathbf {b}$.
Proof 1:
Let $j\in \{1,\ldots ,n\}$ be arbitrary but fixed. The determinant of $A$ is linear in the first column, and hence constitutes a linear map in the first column $L_{j}:R^{n}\to R$ mapping any vector to the determinant of $A$ with the $j$-th column replaced by that vector. If $\mathbf {a} _{j}$ is the $j-$-th column of $A$, $L_{j}(\mathbf {a} _{j})=\det(A)$. Furthermore, if we insert a different column $\mathbf {a} _{k}$ into $L_{j}$, we obtain zero, since we obtain the determinant of a matrix where the column $\mathbf {a} _{k}$ appears twice. We now consider the system of equations
    ${\begin{cases}a_{1,1}x_{1}+\cdots +a_{1,n}x_{n}&=b_{1}\\&\vdots \\a_{n,1}x_{1}+\cdots +a_{n,n}x_{n}&=b_{n},\end{cases}}$
where $(x_{1},\ldots ,x_{n})^{T}$ is the unique solution of the system $Ax=b$, which exists since it is given by $A^{-1}b$ since $A$ is invertible. Since $L_{j}$ is linear, we find an $1\times n$ matrix $(c_{1},\ldots ,c_{n})$ such that for all $\mathbf {v} \in R^{n}$
    $(c_{1},\ldots ,c_{n})\cdot \mathbf {v} =L_{j}(\mathbf {v} )$;
in fact, due to theorem 7.8, $c_{k}=(-1)^{j+k}\det(A_{j,k})$. We now add up the lines of the linear equation system above in the following way: We take $c_{1}$ times the first row, add $c_{2}$ times the second row and so on. Due to our considerations, this yields the result
    $\det(A)x_{j}=L_{j}(\mathbf {b} )$.
Due to lemma 7.9, $\det(A)$ is invertible. Hence, we get
    $x_{j}=(\det(A))^{-1}L_{j}(\mathbf {b} )=(\det(A))^{-1}\det(A_{j})$
and hence the theorem.$\Box$
Proof 2:
For all $j\in \{1,\ldots ,n\}$, we define the matrix
    $X_{j}:={\begin{pmatrix}1&0&\cdots &0&x_{1}&0&\cdots &&0\\0&1&\cdots &0&x_{2}&0&\cdots &&0\\\vdots &&\ddots &&\vdots &&&&\vdots \\\vdots &&&&\vdots &\ddots &&&\vdots \\0&&\cdots &0&x_{n}&0&\cdots &1&0\\0&&\cdots &0&x_{n}&0&\cdots &0&1\end{pmatrix}};$
this matrix shall represent a unit matrix, where the $j$-th column is replaced by the vector $(x_{1},\ldots ,x_{n})^{\mathbf {T} }$. By expanding the $j$-th column, we find that the determinant of this matrix is given by $\det(X_{j})=x_{j}$.
We now note that if $A=(\mathbf {a} _{1},\ldots ,\mathbf {a} _{n})$, then $X_{j}=A^{-1}(\mathbf {a} _{1},\ldots ,\mathbf {a} _{j-1},A\mathbf {b} ,\mathbf {a} _{j+1},\ldots ,\mathbf {a} _{n})=A^{-1}A_{j}$. Hence
    $x_{j}=\det(A^{-1}A_{j})=\det(A^{-1})\det(A_{j})=\det(A)^{-1}\det(A_{j})$,
where the last equality follows as in lemma 7.9.$\Box$
Theorem 7.11 (Cramer's rule, matrix inversion):
Let $A$ be an $n\times n$ matrix with entries in a ring $R$. We recall that the cofactor matrix $\operatorname {Cof} A$ of $A$ is the matrix with $(i,j)$-th entry
    $(-1)^{i+j}\det(A_{i,j})$,
where $A_{i,j}$ is obtained from $A$ by crossing out the $i$-th row and $j-$-th column. We further recall that the adjugate matrix $\operatorname {adj} (A)$ was given by
    $\operatorname {adj} (A):=\operatorname {Cof} (A)^{\mathsf {T}}$.
With this definition, we have
    $\operatorname {adj} (A)A=\det(A)I_{n}$.
In particular, if $\det(A)$ is a unit within $R$, then $A$ is invertible and
    $A^{-1}={\frac {1}{\det(A)}}\operatorname {adj} (A)$.
Proof:
For $j\in \{1,\ldots ,n\}$, we set $\mathbf {b} _{j}:=e_{j}=(0,\ldots ,0,1,0,\ldots ,0)^{T}$, where the zero is at the $j$-th place. Further, we set $L_{j}$ to be the linear function from proof 1 of theorem 7.10, and $M_{j}$ its matrix. Then $\operatorname {adj} (A)$ is given by
    $\operatorname {adj} (A)={\begin{pmatrix}-M_{1}-\\\vdots \\-M_{n}-\end{pmatrix}}$
due to theorem 7.8. Hence,
    $\operatorname {adj} (A)A={\begin{pmatrix}-M_{1}A-\\\vdots \\-M_{n}A-\end{pmatrix}}={\begin{pmatrix}\det(A)&0&\cdots &\cdots &0\\0&\det(A)&&0&\vdots \\\vdots &&\ddots &&\vdots \\\vdots &0&&\det(A)&0\\0&\cdots &\cdots &0&\det(A)\end{pmatrix}},$
where we used the properties of $L_{j}$ established in proof 1 of theorem 7.10.$\Box$

## The theorems

Now we may finally apply the machinery we have set up to prove the following two fundamental theorems.
Theorem 7.12 (the Cayley–Hamilton theorem):
Let $M$ be a finitely generated $R$-module, let $\phi :M\to M$ be a module morphism and let $I\leq R$ be an Ideal of $R$ such that $\phi (M)\subseteq IM$. Then there exist $n\in \mathbb {N}$ and $a_{n-1},\ldots ,a_{1},a_{0}\in I$ such that
    $\phi ^{n}+a_{n-1}\phi ^{n-1}+\cdots +a_{1}\phi +a_{0}=0$;
this equation is to be read as
    $\forall m\in M:\phi ^{n}(m)+a_{n-1}\phi ^{n-1}(m)+\cdots +a_{1}\phi (m)+a_{0}m=0$,
where $\phi ^{n}(m)$ means applying $\phi$ to $m$ $n$ times.
Note that the polynomial in $\phi$ is monic, that is, the leading coefficient is $1$, the unit of the ring in question.
Proof: Assume that $\{m_{1},\ldots ,m_{n}\}$ is a generating set for $M$. Since $\phi (M)\subseteq IM$, we may write
    $\phi (m_{j})=\sum _{k=1}^{n}b_{j,k}x_{k},~j\in \{1,\ldots ,n\}$ (*),
where $b_{k}\in I$ for each $k$. We now define a new commutative ring as follows:
    ${\tilde {R}}:=\{\phi ^{k}|k\in \mathbb {N} \}\cup R$,
where we regard each element $r$ of $R$ as the endomorphism $m\mapsto rm$ on $M$. That is, ${\tilde {R}}$ is a subring of the endomorphism ring of $M$ (that is, multiplication is given by composition). Since $\phi$ is $R$-linear, ${\tilde {R}}$ is commutative.
Now to every $n\times n$ matrix $A$ with entries in ${\tilde {R}}$ we may associate a function
    $A:M^{n}\to M^{n},A\left((x_{1},\ldots ,x_{n})^{T}\right):=\left(\sum _{k=1}^{n}a_{1,k}(x_{1}),\ldots ,\sum _{k=1}^{n}a_{1,k}(x_{1})\right)$.
By exploiting the linearities of all functions involved, it is easy to see that for another $n\times n$ matrix with entries in ${\tilde {R}}$ called $B$, the associated function of $AB$ equals the composition of the associated functions of $A$ and $B$; that is, $(AB)(x)=A(B(x))$.
Now with this in mind, we may rewrite the system (*) as follows:
    $A(x)=0$,
where $A$ has $j,k$-th entry $\delta _{j,k}\phi -b_{j,k}\in {\tilde {R}}$. Now define $B:=\operatorname {adj} (A)$. From Cramer's rule (theorem 7.11) we obtain that
    $BA=I_{n}\det(A)$,
which is why
    $(\det Ax_{1},\ldots ,\det Ax_{n})^{t}=(BA)(x)=B(A(x))=B(0)=\mathbf {0}$, the zero vector.
Hence, $\det A\in {\tilde {R}}$ is the zero mapping, since it sends all generators to zero. Now further, as can be seen e.g. from the representation given in theorem 7.4, it has the form
    $\phi ^{n}+a_{n-1}\phi ^{n-1}+\cdots +a_{1}\phi +a_{0}$
for suitable $a_{n-1},\ldots ,a_{0}\in I$.$\Box$
Theorem 7.13 (Nakayama's lemma):
Let $R$ be a ring, $M$ a finitely generated $R$-module and $I\leq R$ an ideal such that $IM=M$. Then there exists an $x\equiv 1\mod I$ such that $xM=0$.
Proof:
Choose $\phi =\operatorname {Id_{M}}$ in theorem 7.12 to obtain for $m\in M$ that
    $\phi ^{n}(m)+a_{n-1}\phi ^{n-1}(m)+\cdots +a_{1}\phi (m)+a_{0}m=(1+a_{n-1}+\cdots +a_{0})m=0$
for suitable $a_{n-1},\ldots ,a_{0}\in I$, since the identity is idempotent.$\Box$