% vim: tw=50
% 07/03/2023 12AM

\noindent
Let $R$ be a Euclidean domain and $\phi : R
\setminus \{0\} \to \ZZ_{\ge 0}$ a Euclidean
function.

\begin{flashcard}[SNF-exists]
\begin{theorem}[Smith Normal-form]
    \cloze{
    An $m \times n$ matrix $A = (a_{ij})$ over a
    \fcemph{Euclidean Domain} $R$ is equivalent to a
    diagonal matrix
    \[
    \begin{pmatrix}
        d_1 & 0 & \cdots & 0 & \cdots & 0 \\
        0 & d_2 & \cdots & 0 & \cdots & 0 \\
        \vdots & \vdots & \ddots & \vdots & \ddots & \vdots & \\
        0 & 0 & \cdots & d_t & \cdots & 0 \\
        \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\
        0 & 0 & \cdots & 0 & \cdots & 0
    \end{pmatrix}
    \]
    where $d_i \neq 0$ and $d_1 \mid d_2 \mid
    \cdots \mid d_t$. The $d_i$ are called
    \emph{invariant factors}. We will show they
    are unique up to associates.}
\end{theorem}
\prompt{
\begin{proof}
\cloze{
    Induct on dimension, where we use an algorithm
    to make the top row and left column all zero
    except for the top left entry, and making sure
    that the top left entry divides all other
    entries in the matrix.
}
\end{proof}
}
\end{flashcard}

\begin{proof}
    If $A = 0$ then done. Otherwise upon swapping
    rows and columns, may assume $a_{11} \neq 0$.
    We will reduce $\phi(a_{11})$ as much as
    possible via the following algorithm.
    \begin{enumerate}[(Step 1)]
        \item If $a_{11} \mid a_{1j}$ for some $j
            \ge 2$, then write $a_{ij} = qa_{11} +
            r$, $q_1 r \in R$, $\phi(r) <
            \phi(a_{11})$. Subtracting $q$ times
            column $1$ from $j$, and swapping
            these columns makes the top left entry
            $r$.
        \item If $a_{11} \nmid a_{i1}$ for some $i
            \ge 2$ then repeat above process with
            row operations.
            \myskip
            Steps 1 and 2 decrease $\phi(a_{11})$, so can
            repeat finitely many times until $a_{11} \mid
            a_{1j}$ for all $j \ge 2$ and $a_{11} \mid
            a_{i1}$ for all $i \ge 2$. Subtracting
            multiples of first row / column from
            others gives
            \[ A =
            \begin{pmatrix}
                a_{11} & 0 & \cdots & 0 \\
                0 & & & \\
                \vdots & & A' & \\
                0 & & &
            \end{pmatrix}
            \]
            where $A'$ is a $(m - 1) \times (n -
            1)$ matrix.
        \item If $a_{11} \nmid a_{ij}$ for some
            $i, j \ge 2$, then add $i$-th row to
            first row, and perform column
            operations as in Step 1 to decrease
            $\phi(a_{11})$. Then restart
            algorithm. Hence after finitely many
            steps we get
            \[ A =
            \begin{pmatrix}
                a_{11} & 0 & \cdots & 0 \\
                0 & & & \\
                \vdots & & A' & \\
                0 & & &
            \end{pmatrix}
            \]
            with $a_{11} = d_1$ say such that $d_1
            \mid a_{ij}$ for all $i, j$.
    \end{enumerate}
    Applying the same method to $A'$ gives the
    result.
\end{proof}

\myskip
For uniqueness of invariant factors -- introduce
minors of $A$.

\begin{definition*}
    A $k \times k$ minor of $A$ is the determinant
    of a $k \times k$ submatrix of $A$ (i.e. a
    matrix formed by deleting $m - k$ rows and $n
    - k$ columns).
\end{definition*}

\begin{flashcard}[fitting-ideal]
\begin{definition*}
    The $k$-th Fitting ideal \cloze{$\Fit_k(A) \normalsub
    R$ is the ideal generated by the $k \times k$
    minors of $A$.}
\end{definition*}
\end{flashcard}

\begin{lemma}
    If $A$ and $B$ are equivalent matrices, then
    $\Fit_k(A) = \Fit_k(B)$ for all $k$.
\end{lemma}

\begin{proof}
    We show that (ER1-3) don't change $\Fit_k(A)$.
    Same proof works for EC1-3.
    \begin{enumerate}[(ER1)]
        \item Add $\lambda$ times $j$-th row to
            $i$-th row, so $A$ becomes $A'$. Let
            $C$ be a $k \times k$ submatrix of $A$
            and $C'$ the corresponding submatrix
            of $A'$.
            \begin{itemize}
                \item If we did not choose the
                    $i$-th row, then $C = C'$ so
                    $\det C = \det C'$.
                \item If we choose both of the
                    rows $i$ and $j$, then $C$ and
                    $C'$ differ by row operation,
                    hence $\det C = \det C'$.
                \item If we chose the $i$-th row
                    but not the $j$-th row, then
                    by expanding along the $i$-th
                    row,
                    \[ \det(C') = \det(C) \pm
                    \lambda \det(D) \]
                    where $D$ is another $R \times
                    R$ submatrix of $A$ (Choose
                    $j$-th row instead of $i$-th
                    row). Thus $\det(C') \in
                    \Fit_k(A)$.
            \end{itemize}
            Hence $\Fit_k(A') \subset \Fit_k(A)$. Since
            (ER1) is reversible we get $\supset$
            as well by same argument, hence
            equality. (ER2) and (ER3) are similar
            but easier.
    \end{enumerate}
\end{proof}

\myskip
Now if $A$ has SNF $\diag(d_1, \ldots, d_t, 0,
\ldots, 0)$, $d_1 \mid d_2 \mid \cdots \mid d_t$,
then $\Fit_k(A) = (d_1 d_2 \cdots d_k) \normalsub
R$, $k = 1, \ldots, t$. Thus the products $d_1
\cdots d_k$ (up to associate) depends only on $A$.

\begin{example*}
    Consider the matrix
    \[ A =
    \begin{pmatrix}
        2 & -1 \\
        1 & 2
    \end{pmatrix}
    \]
    over $\ZZ$.
    \[
    \begin{pmatrix}
        2 & -1 \\
        1 & 2
    \end{pmatrix}
    \stackrel{c_1 \to c_1 + c_2}{\longrightarrow}
    \begin{pmatrix}
        1 & -1 \\
        3 & 2
    \end{pmatrix}
    \stackrel{c_2 \to c_1 + c_2}{\longrightarrow}
    \begin{pmatrix}
        1 & 0 \\
        3 & 5
    \end{pmatrix}
    \stackrel{R_2 \to R_2 - 3R_1}{\longrightarrow}
    \begin{pmatrix}
        1 & 0 \\
        0 & 5
    \end{pmatrix}
    \]
    But also $(d_1) = (2, -1, 1, 2) = (1)$ so $d_1
    = \pm 1$, $(d_1 d_) = (\det A) = (5)$ so $d_2
    = \pm 5$.
\end{example*}

\noindent
We will use SNF to prove the structure theorem.
First some preparation.

\begin{flashcard}[ed-submodule-generated-by-at-most-m-elements]
\begin{lemma}
    $R$ a \cloze{\fcemph{Euclidean Domain}}.
    Any submodule of $R^m$
    is generated by at most $m$ elements.
\end{lemma}

\fcscrap{
\begin{remark*}
    $m = 1$ was Lemma 14.4.
\end{remark*}
}

\begin{proof}
    \cloze{
    Let $N \le R^m$. Consider the ideal
    \[ I = \{r_1 \in R \mid \exists r_2, \ldots,
    r_m \in R, (r_1, \ldots, r_n) \in N\}
    \normalsub R \]
    Since ED implies PID, we have $I = (a)$ for
    some $a \in R$. Choose some $n = (a, a_2,
    \ldots, a_m) \in N$. For $(r_1, \ldots, r_m)
    \in N$, we have $r_1 = ra$ for some $r \in R$,
    so
    \[ (r_1, r_2, \ldots, r_m) - rn = (0, r_2 -
    ra_2, \ldots, r_m - ra_m) \]
    which lies in $N' \defeq N \cap (0 \oplus R^{m
    - 1}) \le R^{m - 1}$, hence $N = Rn + N'$. By
    induction, $N'$ is generated by $n_2, \ldots,
    n_m$, hence $\{n, n_2, \ldots, n_m\}$
    generates $N$.
}
\end{proof}
\end{flashcard}
