This document describes the default SNF algorithm (Storjohann band
reduction), used by smith_normal_form_mod. For the alternative CRT-based fast
path for small moduli, see crt.md.
The algorithm has two main phases:
- Band Reduction: Transforming an arbitrary matrix into an upper bi-diagonal (2-banded) matrix.
- Diagonalization: Transforming the bi-diagonal matrix into the canonical Smith Normal Form.
The algorithm operates over the Principal Ideal Ring
-
The Ring: We operate in
$\mathbb{Z}/N\mathbb{Z}$ . Operations must respect zero divisors. -
Atomic Reduction (
Gcdex): Instead of division, we use the Extended Euclidean Algorithm to compute a unimodular matrix$M$ that eliminates entries. For any$a, b \in R$ :
where
-
Stabilizer (
Stab): When working with zero divisors, we compute a stabilizer$c$ such that$\text{gcd}(a+cb, N) = \text{gcd}(a, b, N)$ [Lemma 1.1].
The core routine for the reduction is Lemma 3.1.
Given a matrix
This routine is used recursively to clear columns or rows within specific sub-blocks of the matrix during the Band Reduction phase.
The goal of this phase is to take an upper
This is achieved using two specific subroutines:
This routine acts on a principal sub-block
-
Transformation:
$B' = B \cdot V$ - Result: The band is locally squeezed, but "fill-in" is created below the band.
This routine chases the fill-in created by Triang down the diagonal to restore the banded structure.
-
Transformation:
$C' = U \cdot C \cdot V$ -
Step 1: Applies a left transform
$U$ (derived via Lemma 3.1) to clear the first column block. -
Step 2: Applies a right transform
$V$ to restore upper-triangularity to the subsequent block.
Once the matrix is upper bi-diagonal, we proceed to the final Smith Normal Form. This involves two steps: reducing the bi-diagonal matrix to a strictly diagonal one, and then fixing the divisibility of the diagonal entries.
This routine eliminates the super-diagonal entries of the 2-banded matrix. It applies a specific sequence of Gcdex, Stab, and Div operations to "chase" non-zero off-diagonal entries off the matrix, resulting in a diagonal matrix
A diagonal matrix is only in Smith Normal Form if the diagonal entries satisfy the divisibility chain
- Recursive Step: The matrix is split into two halves, each is recursively solved.
- Merge Step (Theorem 7.11): The two solved halves are merged using a 5-step process that combines the invariants of the two blocks.
-
Base Case (Lemma 7.10): For a
$2 \times 2$ block, we apply atomic reductions to ensure the divisibility condition holds.