One theorem, two classical classifications
Two classification problems look unrelated.
- Finite abelian groups. Every finite abelian group is a product of cyclic groups, for instance or — but which products are isomorphic? (Answer: , while is not cyclic.)
- Matrices up to similarity. A complex square matrix is similar to a Jordan normal form, unique up to the order of the blocks. Why blocks, and why unique?
Both are the same theorem. An abelian group is a module over the ring ; a vector space with a linear operator is a module over the polynomial ring , where acts as . Both and are principal ideal domains, and the structure theorem for finitely generated modules over a PID says that every such module is a direct sum of cyclic modules , in an essentially unique way. For this is the classification of finitely generated abelian groups; for , the cyclic pieces are exactly the Jordan blocks.
Modules are the language in which much of modern algebra is written: ideals of a ring, representations of groups and quivers, homology groups of spaces, sections of vector bundles. This lesson builds the basic theory — exact sequences, free and projective modules, tensor products — and proves the structure theorem in full. It assumes quotient rings and the isomorphism theorems, PIDs and UFDs and advanced linear algebra.
Vector spaces whose scalars cannot always be divided
A module is a vector space in which the scalars come from a ring instead of a field. Everything that uses only addition and multiplication by scalars survives: submodules, quotients, homomorphisms, kernels, images, direct sums, the isomorphism theorems. Everything that uses division by scalars can fail:
- Bases. In regarded as a -module, is a non-trivial relation, so no non-empty subset is linearly independent: has no basis. Elements killed by non-zero scalars are called torsion, and torsion is the first obstruction to freeness.
- Extending independent sets. In , the set is linearly independent and cannot be enlarged, yet it is not a basis. The set generates minimally, yet contains no basis.
- Complements. The submodule has no complement: is not for any , because any two non-zero submodules of intersect.
So short exact sequences need not split, and the central questions of module theory are about the ways in which they fail to. Free modules (those with a basis) behave like vector spaces; projective modules are the ones that behave well when mapped out of; the tensor product turns bilinear maps into linear ones but can destroy injectivity. Over a PID the damage is controlled: torsion is the only obstruction, and it is completely described by the structure theorem.
Definitions
Throughout, rings have a , and modules are left modules on which acts as the identity. From the section on PIDs onwards, is commutative.
Definition— module, homomorphism, submodule, quotient
A (left) module over a ring is an abelian group with a map , , such that for all and :
Equivalently, a ring homomorphism into the endomorphism ring of the abelian group . A homomorphism (-linear map) is additive with ; they form an abelian group . A submodule is a subgroup closed under the action; for a submodule the quotient is a module with .
Definition— kernel, image, cokernel; exact sequence
For : , and . A sequence is exact at if . A short exact sequence is exact at , and : injective, surjective, , so . It splits if has a section (), equivalently has a retraction; then .
Definition— free module, rank, torsion
A family in is a basis if every is uniquely a finite combination . A module with a basis is free; it is isomorphic to . Universal property: for any module and any elements of there is a unique homomorphism with . For commutative , implies (tensor with for a maximal ideal ), and is the rank. If is a domain, is torsion if for some ; the torsion elements form the torsion submodule , and is torsion-free if .
Definition— projective and injective modules
A module is projective if carries surjections to surjections: for every surjection and every there is with . Dually, is injective if carries injections to surjections: every homomorphism extends along any injection .
Definition— tensor product
Let be commutative and modules. A tensor product is a module with an -bilinear map , , such that every bilinear map factors as for a unique homomorphism . It exists (take the free module on modulo the bilinearity relations) and is unique up to unique isomorphism. Its elements are finite sums , but not every element is a single pure tensor . For we write , .
Definition— principal ideal domain
A commutative domain is a PID if every ideal is for some . Examples: , for a field , the Gaussian integers . A PID is a UFD; any two elements have a gcd , and , so for some (Bézout).
Examples and non-examples
Example— Abelian groups, vector spaces, ideals
A -module is exactly an abelian group ( is forced), and -linear maps are group homomorphisms. A module over a field is a vector space. Every ring is a module over itself; its submodules are its left ideals, and is a module. If is a ring homomorphism, every -module is an -module by restriction of scalars: so -modules are abelian groups killed by .
Example— Modules over k[x] are vector spaces with an operator
A -module is a -vector space together with the linear map ; conversely becomes a -module by . Under this dictionary:
- submodules are -invariant subspaces;
- homomorphisms are linear maps with , and exactly when and are similar;
- the cyclic module , for monic , has basis , in which acts by the companion matrix of .
So classifying finitely generated -modules that are finite-dimensional over means classifying square matrices up to similarity.
Example— Modules without bases
- () is not a free -module: every element is torsion. (Formalised below.)
- is a torsion-free -module that is not free. Any two elements are linearly dependent, since , so a basis would have one element ; but .
- The ideal of is not free: two elements always satisfy , so a basis would be a single generator, and is not principal.
Example— Projective but not free
Let . By the Chinese remainder theorem, as rings, so as -modules with and . Each summand of a free module is projective (Proposition 1 below), but is not free: it has elements, while a non-zero free -module has at least . Over a PID this cannot happen for finitely generated modules (Theorem 2), and the number theorist's viewpoint below describes a deeper example, a non-principal ideal of .
Example— Injective modules
Over a PID, a module is injective exactly when it is divisible ( for all ) — a consequence of Baer's criterion (Baer, 1940): is injective if every homomorphism from an ideal to extends to . So and are injective -modules, while is not (, , does not extend to ). Every module embeds in an injective one; for abelian groups, suffices. Injective modules supply the resolutions used to compute in homological algebra.
Example— Tensor products
- , with basis ; so for vector spaces the tensor product is the familiar one.
- , by right exactness (Theorem 7) applied to .
- : by the previous item it is . So and .
- : . Tensoring can kill a module entirely.
The structure theory
Theorem— Proposition 1 (projective modules)
For a module the following are equivalent:
- is projective;
- every short exact sequence splits;
- is a direct summand of a free module.
In particular, free modules are projective.
Proof
Free modules are projective. Let have basis , surjective and . Choose with and let be the homomorphism with (universal property). Then and agree on the basis, so .
(1 ⇒ 2) Lift along the surjection : there is with .
(2 ⇒ 3) Let be the free module on the set and the surjection sending the basis vector to . The sequence splits, so .
(3 ⇒ 1) Let be free, with inclusion and projection onto . Given and , lift to (free modules are projective) and put ; then .
∎
The functor is always left exact: it sends exact to exact. Projectivity says exactly that it also preserves surjectivity, so is projective iff is exact.
Theorem— Theorem 2 (submodules of free modules over a PID)
Let be a PID and a submodule of . Then is free of rank at most .
Proof
Induction on . For there is nothing to prove. For , is an ideal : if it is free of rank , and otherwise is an isomorphism because is a domain. For , let be the last coordinate, with kernel . Then
is exact. By induction is free of rank at most , and is free of rank at most by the case . A free module is projective, so the sequence splits (Proposition 1) and is free of rank at most .
∎
(The same holds for submodules of free modules of any rank, by a transfinite version of this induction; see Lang, Algebra, III §7. It fails over non-PIDs: , .)
Theorem— Theorem 3 (Smith normal form)
Let be a PID and an matrix over . There are invertible matrices and such that
Proof
Since is a UFD, every non-zero has a length , the number of prime factors counted with multiplicity; units have length , and if but is not an associate of then . Call two matrices equivalent if one is for invertible . We induct on ; the case is trivial.
Among all matrices equivalent to with non-zero entry (there are some: permute a non-zero entry to the corner), choose whose entry has minimal length.
Step 1: divides every entry of the first column and the first row. Suppose . Let , and write , , so that . The matrix has determinant ; applying it to rows and is an invertible row operation that puts in the corner. Since , is a proper divisor of , so , contradicting minimality. Columns are handled by the same argument applied to .
Step 2: clear. Subtracting multiples of row and column gives an equivalent matrix .
Step 3: divides every entry of . If , add row to row : the first row now contains an entry not divisible by , and Step 1 gives a contradiction.
By induction is equivalent to with . Equivalent matrices generate the same ideal of entries (each entry of is a combination of entries of , and conversely), so divides . Put .
∎
Over a Euclidean domain such as or the same steps become an algorithm: divide with remainder instead of using Bézout, and the norm of the corner entry decreases. For a matrix the algorithm is Euclid's algorithm, and the Smith form is . The first experiment below implements it.
Theorem— Theorem 4 (structure theorem for finitely generated modules over a PID)
Let be a PID and a finitely generated -module. Then
with the non-zero non-units (the invariant factors). Equivalently, by the Chinese remainder theorem, with prime and (the elementary divisors ). The rank , the ideals and the multiset of ideals are uniquely determined by .
Proof
Existence. Choose generators and let send . By Theorem 2, is free with a basis of elements; writing them as columns gives an matrix with . If is the Smith form, then and are changes of basis in and , so . Summands with a unit are ; drop them. For the elementary divisors, write ; the ideals are pairwise comaximal, so .
Uniqueness. The torsion submodule is and , so is the rank of the free module , which is well defined. For a prime , the -primary part is the sum of the elementary divisor summands at . For , the quotient is a vector space over the field of dimension
because when , and it is when . These dimensions depend only on , and they determine the multiset of exponents . The invariant factors are recovered from the elementary divisors: is the product of the largest power of each prime, of the next largest, and so on.
∎
Theorem— Corollary 5 (finitely generated abelian groups)
Every finitely generated abelian group is isomorphic to with , for unique . The number of abelian groups of order , up to isomorphism, is , where is the number of partitions of .
Proof
Take . A finite group has , and its elementary divisors at are with , that is, a partition of ; by uniqueness, distinct choices of partitions give non-isomorphic groups.
∎
For example, there are abelian groups of order .
Theorem— Corollary 6 (Jordan normal form)
Let be algebraically closed, a finite-dimensional -vector space and linear. Then has a basis in which is block diagonal with Jordan blocks , and the multiset of blocks is unique. More generally, over any field , has a unique rational canonical form: block diagonal with the companion matrices of its invariant factors , where is the minimal polynomial and the characteristic polynomial.
Proof
is a finitely generated -module, and it is torsion: is finite-dimensional, so are linearly dependent in and some non-zero polynomial kills . Hence by Theorem 4. Over an algebraically closed field the primes of are the . On take the basis , : then and , so acts by the Jordan block (with 's above the diagonal). Uniqueness of the blocks is uniqueness of the elementary divisors, because similar matrices give isomorphic modules. The rational canonical form uses the invariant factor decomposition and the companion matrix basis of . The minimal polynomial generates the annihilator of , which is ; the characteristic polynomial of a companion matrix of is , so that of is .
∎
The proof explains a classical fact: the characteristic polynomial does not determine a matrix up to similarity, but the list of invariant factors does. The two nilpotent matrices with Jordan blocks of sizes and both have characteristic polynomial , but invariant factors and ; the second experiment computes this.
Now tensor products. We use one lemma about .
Theorem— Lemma (exactness can be tested by Hom)
A sequence is exact if and only if for every module the sequence
is exact, where and .
Proof
(⇒) If is surjective then forces . Clearly . If , then vanishes on , so it factors through : .
(⇐) is surjective: the projection satisfies , so . : take ; . : take and the projection ; then , so for some , and every has , that is, .
∎
Theorem— Theorem 7 (tensor–hom adjunction; right exactness)
Let be commutative. For all modules there is an isomorphism, natural in all three variables,
Consequently, if is exact, so is : the functor is right exact. It is not exact in general: is exact, but after the first map becomes the zero map .
Proof
Both sides are the set of bilinear maps : the left by the universal property of , the right because a bilinear map is the same as a linear map from to linear maps . Naturality is a direct check.
For right exactness, fix and write . Since is exact, the lemma (⇒) gives exactness of . By the natural isomorphism, this is the sequence . As this holds for every , the lemma (⇐) gives exactness of .
For the counterexample, via , and .
∎
A module for which is exact is called flat. Free modules are flat (tensoring with is a direct sum of copies of the identity functor), hence so are projective modules (direct summands); is a flat -module that is not projective; is not flat. The derived functors measure the failure of exactness: there, the kernel of the zero map above reappears as . The adjunction also explains right exactness conceptually: is a left adjoint, and left adjoints preserve all colimits, in particular cokernels (see adjunctions).
Explore: modules over ℝ[x] in the plane
A real matrix makes into an -module, with acting by . Its one-dimensional submodules are exactly the invariant lines, which the widget draws dashed (the real eigenvectors). Try the presets and read the module structure off the picture:
- Scaling : two invariant lines, and — a direct sum of two simple modules.
- Shear : a single invariant line. The module is : it has a submodule (the line) with no complementary submodule — indecomposable but not simple, exactly like .
- Rotation by : no invariant line at all, so the module is simple although it has dimension . Over the polynomial factors and the module splits into two lines: the structure theorem depends on which polynomials are prime.
An ℝ[x]-module structure on the plane
The dashed invariant lines are the one-dimensional submodules.
- image of the grid
- image of the unit square
- image of the flag
- before the transformation
- invariant line
The columns of A are the images of e₁ = (1, 0) and e₂ = (0, 1): Ae₁ = (1, 0), Ae₂ = (1, 1)
det A = ad − bc = 1
The unit square (area 1) becomes a parallelogram of area |det A| = 1. Since det A > 0, orientation is preserved.
Invariant lines (real eigenvectors)
λ = 1, v = (1, 0)
Only one invariant line, with eigenvalue 1: there is no second eigenvector direction.
The Smith normal form of a integer matrix is , and the column operations that compute it are the steps of Euclid's algorithm. So : below, each square cut from the rectangle is one column operation.
Smith normal form of a 1 × 2 matrix
Euclid's algorithm as column operations: Z/(36, 15) ≅ Z/3.
36 × 15
Step 1 of 4
A 36 by 15 rectangle. Press “Next step” to cut off the biggest squares that fit.
- …
Modules in Lean and Mathlib
Mathlib's Module R M is exactly the definition above (for a semiring R and an additive commutative monoid M), and exactness of a pair of maps is Function.Exact f g, meaning range f = ker g pointwise. First, the short exact sequence of the counterexample is exact in the middle:
/-- **The short exact sequence `0 → ℤ --2·--> ℤ → ℤ/2 → 0` is exact in the middle**: the image
of multiplication by `2` is exactly the kernel of reduction mod `2`. (Exactness at the ends says
that `2·` is injective and reduction is surjective; both are immediate.) The proof is the
arithmetic fact that an integer reduces to `0` in `ℤ/2` exactly when it is even. -/
theorem int_two_exact :
Function.Exact (fun n : ℤ => 2 * n) (fun n : ℤ => (n : ZMod 2)) := by
intro n
constructor
· intro h
have h2 : (2 : ℤ) ∣ n := (ZMod.intCast_zmod_eq_zero_iff_dvd n 2).mp h
obtain ⟨m, hm⟩ := h2
exact ⟨m, hm.symm⟩
· rintro ⟨m, rfl⟩
push_cast
have : (2 : ZMod 2) = 0 := rfl
rw [this, zero_mul]Next, the first failure of the vector-space analogy, proved from linear independence of a basis:
/-- **`ℤ/2` is a `ℤ`-module with no basis.** Human proof: suppose `b` were a basis. Since
`ℤ/2 ≠ 0` the basis is non-empty; pick a basis vector `b i`. Then `2 • b i = 0` in `ℤ/2`, a
non-trivial linear relation (the coefficient `2 ≠ 0` in `ℤ`), contradicting linear independence.
So modules, unlike vector spaces, can fail to be free: torsion is the obstruction. -/
theorem zmod_two_not_free : ¬ Module.Free ℤ (ZMod 2) := by
intro hfree
let b := Module.Free.chooseBasis ℤ (ZMod 2)
have hne : Nonempty (Module.Free.ChooseBasisIndex ℤ (ZMod 2)) := by
by_contra hempty
rw [not_nonempty_iff] at hempty
have h1 : (1 : ZMod 2) = 0 := by
rw [← b.sum_repr (1 : ZMod 2)]
simp
exact one_ne_zero h1
obtain ⟨i⟩ := hne
have h2 : (2 : ℤ) • b i = 0 := by
have : ∀ x : ZMod 2, (2 : ℤ) • x = 0 := by decide
exact this _
-- a basis vector is never killed by a non-zero scalar
have key : (2 : ℤ) = 0 := by
have hli := b.linearIndependent
rw [LinearIndependent] at hli
have := hli (a₁ := Finsupp.single i 2) (a₂ := 0)
simp only [Finsupp.linearCombination_single, map_zero] at this
have h := this h2
simpa using congrArg (fun f => f i) h
exact two_ne_zero keyThe key step of Proposition 1, proved by the same argument as in the text — choose preimages of the images of basis vectors and extend linearly with Finsupp.linearCombination — followed by Mathlib's versions, "free ⇒ projective" and the lifting property:
/-- **Maps out of a free module lift along surjections.** Let `g : M → N` be surjective and
`f : R^(ι) → N` a homomorphism from the free module on `ι`. For each basis vector `eᵢ`, choose
`mᵢ ∈ M` with `g mᵢ = f eᵢ` (surjectivity); the universal property of the free module gives a
unique `h` with `h eᵢ = mᵢ`, and `g ∘ h = f` because both agree on the basis. This is exactly why
free modules are projective. -/
theorem free_lifting {R : Type*} [Ring R] {ι M N : Type*} [AddCommGroup M] [Module R M]
[AddCommGroup N] [Module R N] (g : M →ₗ[R] N) (hg : Function.Surjective g)
(f : (ι →₀ R) →ₗ[R] N) : ∃ h : (ι →₀ R) →ₗ[R] M, g ∘ₗ h = f := by
choose m hm using fun i : ι => hg (f (Finsupp.single i 1))
refine ⟨Finsupp.linearCombination R m, ?_⟩
ext i
simp [hm]/-- **Free modules are projective.** This is Mathlib's instance `Module.Projective.of_free`,
whose proof is the lifting argument of `free_lifting`. -/
theorem projective_of_free {R P : Type*} [Ring R] [AddCommGroup P] [Module R P]
[Module.Free R P] : Module.Projective R P :=
Module.Projective.of_free/-- **The lifting property of projective modules**: every map from a projective module to the
target of a surjection lifts through it — equivalently, `Hom(P, −)` carries surjections to
surjections. Mathlib: `Module.projective_lifting_property`. -/
theorem projective_lifting {R P M N : Type*} [Ring R] [AddCommGroup P] [Module R P]
[AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] [Module.Projective R P]
(g : M →ₗ[R] N) (f : P →ₗ[R] N) (hg : Function.Surjective g) :
∃ h : P →ₗ[R] M, g ∘ₗ h = f :=
Module.projective_lifting_property g f hgTheorem 2 and the structure theorem (in its elementary-divisor form) with the corollary for abelian groups are in Mathlib:
/-- **Over a PID, submodules of finite free modules are free** (of rank at most the rank of the
ambient module). Mathlib: `Submodule.basisOfPid`, which produces a basis of the submodule indexed
by `Fin n`; the proof is the induction on the rank given in the lesson. -/
theorem submodule_free_pid {R M : Type*} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R]
[AddCommGroup M] [Module R M] {ι : Type*} [Finite ι] (b : Module.Basis ι R M)
(N : Submodule R M) : ∃ n : ℕ, Nonempty (Module.Basis (Fin n) R N) :=
⟨(Submodule.basisOfPid b N).1, ⟨(Submodule.basisOfPid b N).2⟩⟩/-- **Structure theorem for finitely generated modules over a PID** (elementary divisor form):
`M ≅ Rⁿ ⊕ ⨁ᵢ R/(pᵢ^eᵢ)` with each `pᵢ` irreducible (prime). Mathlib:
`Module.equiv_free_prod_directSum`. Grouping the prime powers gives the invariant factor form
`R/(d₁) ⊕ ⋯ ⊕ R/(dₖ)` with `d₁ ∣ ⋯ ∣ dₖ` used in the lesson. -/
theorem structure_theorem {R : Type u} {M : Type v} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R]
[AddCommGroup M] [Module R M] [Module.Finite R M] :
∃ (n : ℕ) (ι : Type u) (_ : Fintype ι) (p : ι → R) (_ : ∀ i, Irreducible (p i)) (e : ι → ℕ),
Nonempty (M ≃ₗ[R] (Fin n →₀ R) × DirectSum ι (fun i => R ⧸ R ∙ p i ^ e i)) :=
Module.equiv_free_prod_directSum R M/-- **Corollary: finitely generated abelian groups.** Taking `R = ℤ`:
`G ≅ ℤⁿ ⊕ ⨁ᵢ ℤ/pᵢ^eᵢ` with the `pᵢ` prime. Mathlib: `AddCommGroup.equiv_free_prod_directSum_zmod`. -/
theorem abelian_groups (G : Type*) [AddCommGroup G] [AddGroup.FG G] :
∃ (n : ℕ) (ι : Type) (_ : Fintype ι) (p : ι → ℕ) (_ : ∀ i, Nat.Prime (p i)) (e : ι → ℕ),
Nonempty (G ≃+ (Fin n →₀ ℤ) × DirectSum ι (fun i => ZMod (p i ^ e i))) :=
AddCommGroup.equiv_free_prod_directSum_zmod GFinally, tensor products: the tensor–hom correspondence, right exactness, and the counterexample to left exactness, proved by computing on the pure tensor and the isomorphism :
/-- **The tensor–hom adjunction** (one variable at a time): bilinear maps `M × N → P`, that is
linear maps `M → Hom(N, P)`, are the same as linear maps `M ⊗ N → P`, naturally. Mathlib:
`TensorProduct.lift.equiv`. -/
noncomputable def tensor_hom (R M N P : Type*) [CommRing R] [AddCommGroup M] [Module R M]
[AddCommGroup N] [Module R N] [AddCommGroup P] [Module R P] :
(M →ₗ[R] N →ₗ[R] P) ≃ₗ[R] (M ⊗[R] N →ₗ[R] P) :=
TensorProduct.lift.equiv (RingHom.id R) M N P/-- **Tensoring is right exact**: if `M → N → P → 0` is exact then so is
`M ⊗ Q → N ⊗ Q → P ⊗ Q → 0`. Mathlib: `rTensor_exact` (exactness in the middle) and
`LinearMap.rTensor_surjective` (at the right). The lesson derives it from the tensor–hom
adjunction. -/
theorem tensor_right_exact {R M N P : Type*} (Q : Type*) [CommRing R] [AddCommGroup M] [Module R M]
[AddCommGroup N] [Module R N] [AddCommGroup P] [Module R P] [AddCommGroup Q] [Module R Q]
{f : M →ₗ[R] N} {g : N →ₗ[R] P} (hfg : Function.Exact f g) (hg : Function.Surjective g) :
Function.Exact (f.rTensor Q) (g.rTensor Q) ∧ Function.Surjective (g.rTensor Q) :=
⟨rTensor_exact Q hfg hg, LinearMap.rTensor_surjective Q hg⟩/-- **…but not exact.** Multiplication by `2` on `ℤ` is injective, yet after tensoring with
`ℤ/2` it becomes the zero map on `ℤ ⊗ ℤ/2 ≅ ℤ/2 ≠ 0`, so it is no longer injective.
Human proof: on a pure tensor, `(2a) ⊗ b = a ⊗ 2b = a ⊗ 0 = 0`; and `1 ⊗ 1 ≠ 0` because
`n ⊗ b ↦ n • b` is a well-defined map `ℤ ⊗ ℤ/2 → ℤ/2` sending it to `1`. -/
theorem tensor_not_left_exact :
Function.Injective (2 • LinearMap.id : ℤ →ₗ[ℤ] ℤ) ∧
¬ Function.Injective ((2 • LinearMap.id : ℤ →ₗ[ℤ] ℤ).rTensor (ZMod 2)) := by
constructor
· intro a b h
have h' : 2 * a = 2 * b := by simpa [two_smul, two_mul] using h
omega
· intro hinj
-- the element `1 ⊗ 1` is sent to `2 ⊗ 1 = 1 ⊗ 2 = 0`
have himg : ((2 • LinearMap.id : ℤ →ₗ[ℤ] ℤ).rTensor (ZMod 2)) ((1 : ℤ) ⊗ₜ (1 : ZMod 2)) = 0 := by
rw [LinearMap.rTensor_tmul]
simp only [LinearMap.smul_apply, LinearMap.id_apply]
rw [TensorProduct.smul_tmul]
have : (2 : ℕ) • (1 : ZMod 2) = 0 := by decide
rw [this, TensorProduct.tmul_zero]
have hzero : (1 : ℤ) ⊗ₜ[ℤ] (1 : ZMod 2) = 0 :=
hinj (himg.trans (map_zero _).symm)
-- but `1 ⊗ 1` maps to `1 ≠ 0` under `ℤ ⊗ ℤ/2 ≅ ℤ/2`
have := congrArg (TensorProduct.lid ℤ (ZMod 2)) hzero
rw [TensorProduct.lid_tmul, map_zero, one_smul] at this
exact one_ne_zero thisWhat is and is not formalised. Proved here: exactness of in the middle, that is not free, the lifting property of free modules, and the failure of left exactness of . From Mathlib: free ⇒ projective, the lifting property, Theorem 2, the structure theorem, the classification of finitely generated abelian groups, the tensor–hom correspondence and right exactness. Not formalised in this module: the Smith normal form proof (Mathlib has Submodule.smithNormalForm for submodules of free modules over a PID), the uniqueness argument of Theorem 4, the lemma testing exactness by , and the Jordan normal form as a corollary.
Smith normal forms, computed
The first experiment implements the Smith normal form over , reads off the abelian group presented by a relation matrix, and checks two theorems on many matrices: the divisibility chain, and the determinantal divisor identity (gcd of the minors). The right-hand side is unchanged by invertible row and column operations, so the identity shows that the depend only on the matrix. It then counts abelian groups of order in two independent ways — chains of invariant factors, and products of partition numbers — confirming Corollary 5 in that range.
"""Smith normal form over the integers: classifying abelian groups by matrices.
A finitely generated abelian group given by generators and relations is
Z^m / (column span of an integer relation matrix A). Row and column operations
over Z (invertible over Z) bring A to diagonal form diag(d1, d2, ...) with
d1 | d2 | ..., and then the group is Z/d1 + Z/d2 + ... + Z^(free rank).
This experiment implements the reduction, checks the divisibility chain and
the determinantal-divisor identity d1 d2 ... dk = gcd of k x k minors (which
proves the d_i do not depend on the choices made), and compares two ways of
counting abelian groups of order n: invariant-factor chains versus products
of partition numbers (elementary divisors). Exact integer arithmetic.
"""
from itertools import combinations
from math import gcd, prod
import random
def smith_diagonal(matrix):
"""Invariant factors d1 | d2 | ... (with zeros last) of an integer matrix."""
a = [list(row) for row in matrix]
m, n = len(a), len(a[0]) if a else 0
diag = []
for t in range(min(m, n)):
entries = [(abs(a[i][j]), i, j) for i in range(t, m)
for j in range(t, n) if a[i][j]]
if not entries:
break
while True:
_, i, j = min(entries)
a[t], a[i] = a[i], a[t]
for row in a:
row[t], row[j] = row[j], row[t]
done = True
for i in range(t + 1, m): # clear column t
q = a[i][t] // a[t][t]
a[i] = [x - q * y for x, y in zip(a[i], a[t])]
done &= a[i][t] == 0
for j in range(t + 1, n): # clear row t
q = a[t][j] // a[t][t]
for row in a:
row[j] -= q * row[t]
done &= a[t][j] == 0
bad = [(i, j) for i in range(t + 1, m) for j in range(t + 1, n)
if a[i][j] % a[t][t]]
if done and bad: # pivot must divide the rest
i = bad[0][0]
a[t] = [x + y for x, y in zip(a[t], a[i])]
done = False
if done:
break
entries = [(abs(a[i][j]), i, j) for i in range(t, m)
for j in range(t, n) if a[i][j]]
diag.append(abs(a[t][t]))
return diag + [0] * (min(m, n) - len(diag))
def cokernel(matrix):
"""(free rank, torsion orders > 1) of Z^m / column span of the matrix."""
m = len(matrix)
diag = smith_diagonal(matrix)
nonzero = [d for d in diag if d]
return m - len(nonzero), [d for d in nonzero if d > 1]
def det(mat):
"""Integer determinant by Laplace expansion (small matrices only)."""
if len(mat) == 1:
return mat[0][0]
return sum((-1) ** j * mat[0][j] * det([r[:j] + r[j + 1:] for r in mat[1:]])
for j in range(len(mat)))
def determinantal_divisor(matrix, k):
"""gcd of all k x k minors of the matrix."""
rows, cols = range(len(matrix)), range(len(matrix[0]))
g = 0
for r in combinations(rows, k):
for c in combinations(cols, k):
g = gcd(g, det([[matrix[i][j] for j in c] for i in r]))
return g
def chain_ok(diag):
"""d1 | d2 | ... among the non-zero entries, zeros only at the end."""
nz = [d for d in diag if d]
tail_zero = all(d == 0 for d in diag[len(nz):])
return tail_zero and all(b % a == 0 for a, b in zip(nz, nz[1:]))
def identity_ok(matrix):
"""d1 ... dk equals the k-th determinantal divisor for every k."""
diag = smith_diagonal(matrix)
return all(prod(diag[:k]) == determinantal_divisor(matrix, k)
for k in range(1, len(diag) + 1))
def partitions(n):
"""Number of partitions of n."""
p = [1] + [0] * n
for part in range(1, n + 1):
for total in range(part, n + 1):
p[total] += p[total - part]
return p[n]
def groups_by_elementary_divisors(n):
"""Abelian groups of order n: product of p(e) over prime powers p^e || n."""
count, q = 1, 2
while n > 1:
e = 0
while n % q == 0:
n, e = n // q, e + 1
count *= partitions(e)
q += 1
return count
def groups_by_invariant_factors(n, prev=1):
"""Chains d1 | d2 | ... | dk with d1 >= 2, prev | d1 and product n."""
if n == 1:
return 1
return sum(groups_by_invariant_factors(n // d, d) for d in range(2, n + 1)
if n % d == 0 and d % prev == 0)
def main():
examples = [("Z^2 / <(2,0), (0,3)>", [[2, 0], [0, 3]]),
("Z^2 / <(4,6), (6,4)>", [[4, 6], [6, 4]]),
("Z^3 / <(2,4,6), (4,8,12)>", [[2, 4], [4, 8], [6, 12]]),
("Z^3 / <(1,1,1), (0,2,4), (0,0,6)>",
[[1, 0, 0], [1, 2, 0], [1, 4, 6]])]
print("Presented abelian groups (relations are the columns):")
for name, mat in examples:
free, tors = cokernel(mat)
parts = [f"Z/{d}" for d in tors] + ["Z"] * free
print(f" {name:34} = {' + '.join(parts) or '0'}")
small = [[[a, b], [c, d]] for a in range(-3, 4) for b in range(-3, 4)
for c in range(-3, 4) for d in range(-3, 4)]
ok2 = sum(chain_ok(smith_diagonal(m)) and identity_ok(m) for m in small)
rng = random.Random(2024)
big = [[[rng.randint(-9, 9) for _ in range(3)] for _ in range(3)]
for _ in range(300)]
ok3 = sum(chain_ok(smith_diagonal(m)) and identity_ok(m) for m in big)
print("Divisibility chain and minor identity d1...dk = gcd of k x k minors:")
print(f" all {len(small)} 2x2 matrices, entries in [-3, 3]: hold for {ok2}")
print(f" 300 random 3x3 matrices, entries in [-9, 9]: hold for {ok3}")
agree = all(groups_by_elementary_divisors(n) == groups_by_invariant_factors(n)
for n in range(1, 101))
print("Abelian groups of order n, two ways, agree for n <= 100:", agree)
print(" n = 8, 16, 72, 64:", [groups_by_elementary_divisors(n)
for n in (8, 16, 72, 64)])
print()
print("Epistemic status: exact integer arithmetic, exhaustive over the "
"finite range\nstated and seeded-random elsewhere. The minor identity "
"shows that the d_i\ndepend only on the matrix, not on the "
"operations chosen. Finite checks are\nevidence; the structure "
"theorem is proved in the lesson for every PID.")
if __name__ == "__main__":
main()The second experiment applies the same theory over : the invariant factors of the module are quotients of gcds of minors of , and their prime-power factors predict the Jordan blocks, which it compares with an independent Jordan form computation.
"""Jordan normal form from the structure theorem over Q[x].
A square matrix A makes Q^n into a Q[x]-module (x acts by A), presented by
the matrix xI - A. Its invariant factors d1 | d2 | ... | dn are quotients of
determinantal divisors: D_k = monic gcd of the k x k minors of xI - A, and
d_k = D_k / D_(k-1). Each power (x - c)^e in the d_k is a Jordan block of
size e for the eigenvalue c. We compute the blocks this way and compare them
with sympy's independent jordan_form; an irreducible factor such as x^2 + 1
shows a module with no Jordan form over Q. Exact symbolic computation.
"""
from itertools import combinations
import sympy as sp
X = sp.Symbol("x")
def invariant_factors(rows):
"""Invariant factors d_1 | ... | d_n of the Q[x]-module Q^n, x acting by A."""
a = sp.Matrix(rows)
n = a.shape[0]
m = X * sp.eye(n) - a
divisors = [sp.Integer(1)]
for k in range(1, n + 1):
g = sp.Integer(0)
for r in combinations(range(n), k):
for c in combinations(range(n), k):
g = sp.gcd(g, m.extract(list(r), list(c)).det())
divisors.append(sp.Poly(g, X).monic().as_expr())
return [sp.factor(sp.cancel(divisors[k] / divisors[k - 1]))
for k in range(1, n + 1)]
def predicted_blocks(factors):
"""Sorted (eigenvalue, size) pairs from linear prime powers; None if a
factor does not split into linear factors over Q."""
blocks = []
for d in factors:
for p, e in sp.factor_list(d, X)[1]:
if sp.degree(p, X) != 1:
return None
blocks.append((sp.solve(p, X)[0], e))
return sorted(blocks)
def sympy_blocks(rows):
"""Sorted (eigenvalue, size) pairs read off sympy's Jordan form."""
_, j = sp.Matrix(rows).jordan_form()
n, blocks, i = j.shape[0], [], 0
while i < n:
size = 1
while i + size < n and j[i + size - 1, i + size] == 1:
size += 1
blocks.append((j[i, i], size))
i += size
return sorted(blocks)
def main():
examples = {
"A (4x4, eigenvalues 1, 2, 4)": [[5, 4, 2, 1], [0, 1, -1, -1],
[-1, -1, 3, 0], [1, 1, -1, 2]],
"N1 (nilpotent)": [[0, 1, 0, 0], [0, 0, 0, 0],
[0, 0, 0, 1], [0, 0, 0, 0]],
"N2 (nilpotent)": [[0, 1, 0, 0], [0, 0, 1, 0],
[0, 0, 0, 0], [0, 0, 0, 0]],
"R (rotation by 90 degrees)": [[0, -1], [1, 0]],
}
for name, rows in examples.items():
factors = invariant_factors(rows)
shown = ", ".join(str(f) for f in factors if f != 1)
print(f"{name}:")
print(f" invariant factors (non-unit): {shown}")
pred = predicted_blocks(factors)
if pred is None:
print(" a factor is irreducible of degree > 1: no Jordan form "
"over Q")
else:
agree = pred == sympy_blocks(rows)
print(f" blocks (eigenvalue, size): {pred}; sympy agrees: {agree}")
print("N1 and N2 have the same characteristic polynomial x**4 but are "
"not similar.")
print()
print("Epistemic status: exact symbolic computation for four matrices; "
"it checks the\nrecipe 'Jordan blocks = prime powers in the "
"invariant factors' on examples.\nThe recipe is a theorem: the "
"structure theorem over the PID Q[x], in the lesson.")
if __name__ == "__main__":
main()Exercises
1. Modules
Warm-upHumanWhich of these -modules are free? (Choose all that apply.)
2. Modules
Warm-upHumanHow many abelian groups of order are there, up to isomorphism?
3. Modules
CoreHumanWhich group is (the quotient by the subgroup generated by these two vectors)?
4. Modules
CoreHumanA linear map on has characteristic polynomial , minimal polynomial , and . What are the sizes of its Jordan blocks?
5. Modules
CoreHumanIn the proof that a submodule over a PID is free, why does the sequence split?
6. Modules
StretchHumanOver which of these rings does some submodule of a free -module (of finite rank) fail to be free? (Choose all that apply.)
7. Modules
CoreHumanHow many elements does have?
8. Modules
CoreFormalWhich Lean statement expresses that tensoring with does not preserve injectivity (as proved in tensor_not_left_exact)?
9. Modules
StretchComputationalWrite invariant_factors(orders): given positive integers , return the invariant factors of as a list with (empty for the zero group). For example , so invariant_factors([4, 6]) == [2, 12].
Common misconceptions
Misconception
"Modules behave like vector spaces." Many familiar facts fail: is a -module with no basis; the independent set does not extend to a basis; the generating set of contains no basis; the submodule has no complement; and over non-noetherian rings a finitely generated module can have submodules that are not finitely generated. What survives is everything that does not divide by scalars.
Misconception
"Tensoring preserves injective maps." It preserves surjections and cokernels (right exactness) but not injections: multiplication by on is injective, and becomes the zero map on . Modules that do preserve injections under tensoring are the flat ones; measures the failure.
Misconception
"Projective means free" and "torsion-free means free". Both are true for finitely generated modules over a PID, and both fail in general: is a projective, non-free -module; is a torsion-free, non-free -module (it is not finitely generated); and a non-principal ideal of a Dedekind domain is a finitely generated, torsion-free, projective module that is not free. Over local rings projective modules are free (Kaplansky), and over polynomial rings finitely generated projective modules are free (Quillen and Suslin, 1976) — deep theorems, not formalities.
Misconception
"The characteristic polynomial determines a matrix up to similarity." It is the product of the invariant factors, and different lists of invariant factors can have the same product: the nilpotent matrices with Jordan blocks and both have characteristic polynomial . The complete invariant is the list .
Viewpoints
Geometry— Projective modules are vector bundles
For a compact Hausdorff space , let be the ring of continuous real functions. The Serre–Swan theorem (Serre 1955 for algebraic varieties, Swan 1962 in this form) says that , sending a vector bundle to its module of continuous sections, is an equivalence between real vector bundles on and finitely generated projective -modules. Free modules correspond to trivial bundles, and "direct summand of a free module" is the statement that every bundle is a summand of a trivial one. On the circle, the Möbius line bundle gives a projective -module that is not free, while because the sum of two Möbius bundles is trivial. In algebraic geometry, finitely generated modules over are coherent sheaves on affine space and projective ones are vector bundles; the Quillen–Suslin theorem says they are all trivial (see vector bundles and algebraic geometry).
Topology— Betti numbers, torsion and barcodes
The integral homology groups of a finite cell complex are finitely generated -modules, and the structure theorem splits each into a free part — the Betti number — and a torsion part, Poincaré's torsion coefficients. The real projective plane has : a loop that is not a boundary, although twice it is. In topological data analysis, a filtration of a space gives homology groups linked by maps, which together form a graded module over ( moves one step along the filtration). Zomorodian and Carlsson (2005) observed that the structure theorem for graded modules over the PID decomposes it into shifted copies and of and : the barcode of features born at time and living forever or for steps. The same decomposition, in quiver language, is the classification of representations of a line in quivers and path algebras.
Number theory— Ideals of number rings: projective but not free
In the ring of integers of a number field — a Dedekind domain, but usually not a PID — every non-zero ideal is a projective module of rank , and is free exactly when it is principal. So the ideal class group measures how far projective modules are from being free. In the ideal is not principal (no element has norm , as has no integer solutions), but ; it is projective and not free. Steinitz (1911) showed that every finitely generated torsion-free -module is isomorphic to for an ideal whose class in is an invariant. Over itself, the structure theorem is the arithmetic statement that relation matrices can be diagonalised, which reduces linear systems of Diophantine equations to congruences (see algebraic number theory).
Category theory— R-Mod as an abelian category; tensor as a left adjoint
is the model abelian category (see abelian categories). Projective objects are those for which is exact; there are enough projectives (free modules surject onto everything) and enough injectives, which makes derived functors possible. The tensor–hom isomorphism says , so tensoring preserves colimits and preserves limits — right and left exactness are shadows of adjointness. The Eilenberg–Watts theorem (1960) says every right exact functor that preserves direct sums is for an -bimodule ; and Morita theory shows that and are equivalent, so the category remembers less than the ring.
History and global context
- Solving systems of linear equations by elimination is ancient: chapter 8 (fangcheng) of the Chinese Nine Chapters on the Mathematical Art (compiled by about the 1st century CE) reduces rectangular arrays of coefficients by column operations. The remainder problem of the Sunzi Suanjing (around the 3rd–5th century) is the earliest known instance of the Chinese remainder theorem, which in module language is for coprime .
- Henry John Stephen Smith (1861) diagonalised integer matrices by invertible row and column operations, in his work on systems of linear Diophantine equations. Karl Weierstrass (1868) introduced elementary divisors of matrix pencils, and Camille Jordan's Traité des substitutions (1870) gave the canonical form now named after him. Leopold Kronecker (1870) proved the decomposition of finite abelian groups, and Ferdinand Georg Frobenius and Ludwig Stickelberger (1879) gave the full structure theorem for finitely generated abelian groups.
- Richard Dedekind introduced the word Modul (for additive subgroups of number fields) and ideals in the 1870s. Emmy Noether and her school in the 1920s made modules over rings the unifying language, and B. L. van der Waerden's Moderne Algebra (1930–31) spread it; the structure theorem over a PID took its modern form there.
- Hassler Whitney (1938) defined tensor products of abelian groups; Reinhold Baer (1940) introduced injective modules; Henri Cartan and Samuel Eilenberg's Homological Algebra (1956) introduced projective modules and made exactness central.
- Jean-Pierre Serre (1955) related projective modules to vector bundles and asked whether projective modules over polynomial rings are free; Daniel Quillen and Andrei Suslin answered yes, independently, in 1976. Richard Swan (1962) proved the topological version of the correspondence.
Further reading
- David S. Dummit and Richard M. Foote, Abstract Algebra (3rd ed., 2004) — Chapters 10–12: modules, tensor products, the structure theorem, rational and Jordan forms.
- Serge Lang, Algebra (revised 3rd ed., 2002) — Chapters III and XVI: modules and tensor products.
- Paolo Aluffi, Algebra: Chapter 0 (2009) — Chapters III, VI and VIII: modules with a categorical outlook, Smith normal form.
- M. F. Atiyah and I. G. Macdonald, Introduction to Commutative Algebra (1969) — Chapter 2: modules, exactness, tensor products, flatness.
- Nathan Jacobson, Basic Algebra I (2nd ed., 1985) — Chapter 3: modules over a PID with full proofs.
- T. Y. Lam, Lectures on Modules and Rings (1999) — projective, injective and flat modules in depth.