Matrix similarity, Jordan blocks, and Jordan matrices
DefinitionHefferonLinAlg_jordanThe vocabulary of Hefferon's Chapter Five, Section IV.2, stated over an arbitrary commutative ring and an arbitrary finite index type so that later work can reuse it: only the theorems need . Similarity is factored out as its own definition ( for some of unit determinant), so statements about similarity alone can be phrased against it. A Jordan block of size with eigenvalue is the matrix carrying down the diagonal and on the subdiagonal; Hefferon places the ones below the diagonal, matching his convention that a nilpotent map carries each string basis vector to the next. A Jordan matrix is assembled from finitely many such blocks: given a block count , sizes and eigenvalues , it is indexed by and is the block diagonal of those blocks. The block data is a Jordan form of when every block is nonempty and, after a reindexing of the coordinates, some change of basis carries to that Jordan matrix; has a Jordan form when such data exists. Nonemptiness is what makes the data an invariant -- without it one could pad any Jordan form with empty blocks carrying arbitrary eigenvalues. Finally jordanBlocks is the multiset of pairs, which is what discards the ordering of the blocks.
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.Matrix.Block
import Mathlib.Data.Complex.Basic
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
namespace HefferonLinAlg
open Matrix
variable {R : Type*}
/-- Two square matrices are **similar** when a change of basis carries one to the
other: `B = P⁻¹ A P` for some `P` with unit determinant. Kept separate from the
Jordan-form vocabulary below so that any statement about matrix similarity — that
it is an equivalence relation, that it preserves the determinant, trace, rank or
characteristic polynomial — can be phrased against it. -/
def IsSimilar [CommRing R] {ι : Type*} [Fintype ι] [DecidableEq ι]
(A B : Matrix ι ι R) : Prop :=
∃ P : Matrix ι ι R, IsUnit P.det ∧ P⁻¹ * A * P = B
/-- The `m × m` **Jordan block** with eigenvalue `lam`: `lam` down the diagonal and
`1` on the subdiagonal. Hefferon puts the ones *below* the diagonal (Five.IV.2),
matching the book's convention that a nilpotent map carries each string basis
vector to the next one. Stated over an arbitrary scalar type so that the same
block is available for real, rational or general-field Jordan theory. -/
def jordanBlock [Zero R] [One R] (m : ℕ) (lam : R) : Matrix (Fin m) (Fin m) R :=
Matrix.of fun i j => if i = j then lam else if (i : ℕ) = (j : ℕ) + 1 then 1 else 0
@[simp] theorem jordanBlock_apply [Zero R] [One R] {m : ℕ} (lam : R) (i j : Fin m) :
jordanBlock m lam i j =
if i = j then lam else if (i : ℕ) = (j : ℕ) + 1 then 1 else 0 :=
rfl
/-- The index type of a Jordan matrix with `k` blocks of sizes `sz`. -/
abbrev jordanIndex {k : ℕ} (sz : Fin k → ℕ) : Type := Σ i : Fin k, Fin (sz i)
/-- The block-diagonal **Jordan matrix** with `k` blocks, the `i`-th of size `sz i`
and eigenvalue `lam i`. -/
def jordanMatrix [Zero R] [One R] {k : ℕ} (sz : Fin k → ℕ) (lam : Fin k → R) :
Matrix (jordanIndex sz) (jordanIndex sz) R :=
Matrix.blockDiagonal' fun i => jordanBlock (sz i) (lam i)
@[simp] theorem jordanMatrix_apply_same [Zero R] [One R] {k : ℕ}
(sz : Fin k → ℕ) (lam : Fin k → R) (i : Fin k) (a b : Fin (sz i)) :
jordanMatrix sz lam ⟨i, a⟩ ⟨i, b⟩ = jordanBlock (sz i) (lam i) a b := by
simp [jordanMatrix, Matrix.blockDiagonal'_apply_eq]
@[simp] theorem jordanMatrix_apply_ne [Zero R] [One R] {k : ℕ}
(sz : Fin k → ℕ) (lam : Fin k → R) {i j : Fin k}
(a : Fin (sz i)) (b : Fin (sz j)) (h : i ≠ j) :
jordanMatrix sz lam ⟨i, a⟩ ⟨j, b⟩ = 0 := by
simp [jordanMatrix, Matrix.blockDiagonal'_apply_ne _ _ _ h]
/-- The block data `(sz, lam)` **is a Jordan form of** `A`: every block is nonempty,
and after reindexing the coordinates by `e`, `A` is similar to the corresponding
block-diagonal Jordan matrix.
Nonemptiness (`0 < sz i`) is what makes the block data an invariant: without it one
could pad any Jordan form with empty blocks carrying arbitrary eigenvalues, and no
uniqueness statement could hold. -/
def IsJordanFormOf [CommRing R] {ι : Type*} [Fintype ι] [DecidableEq ι] {k : ℕ}
(A : Matrix ι ι R) (sz : Fin k → ℕ) (lam : Fin k → R) : Prop :=
(∀ i, 0 < sz i) ∧
∃ e : ι ≃ jordanIndex sz,
IsSimilar A (Matrix.reindex e.symm e.symm (jordanMatrix sz lam))
/-- `A` **has a Jordan form**: it is similar to a block-diagonal Jordan matrix.
Note this says `A` is *similar to* a Jordan matrix, not that `A` is one. -/
def HasJordanForm [CommRing R] {ι : Type*} [Fintype ι] [DecidableEq ι]
(A : Matrix ι ι R) : Prop :=
∃ (k : ℕ) (sz : Fin k → ℕ) (lam : Fin k → R), IsJordanFormOf A sz lam
/-- The multiset of `(block size, eigenvalue)` pairs of a Jordan form. Passing to a
multiset is exactly what discards the ordering of the blocks, which is the sense in
which Jordan form is unique (Hefferon, Five.IV.2, Remark 2.9). -/
def jordanBlocks {k : ℕ} (sz : Fin k → ℕ) (lam : Fin k → R) : Multiset (ℕ × R) :=
(Finset.univ : Finset (Fin k)).val.map fun i => (sz i, lam i)
/-- The dimension of the kernel of `(A - lam)^r`. As `r` grows these dimensions
determine how many Jordan blocks of each size carry the eigenvalue `lam`, so they
are the invariant behind uniqueness of the Jordan form; they are also the standard
way to read block structure off a matrix in practice. -/
noncomputable def kerDim {K : Type*} [Field K] {n : ℕ}
(A : Matrix (Fin n) (Fin n) K) (lam : K) (r : ℕ) : ℕ :=
Module.finrank K (LinearMap.ker (Matrix.toLin' ((A - lam • 1) ^ r)))
end HefferonLinAlg
Read-back
What the Lean code literally says, in plain math · claude-opus-5
Read-back — HefferonLinAlg_jordan.lean
All declarations live in a namespace HefferonLinAlg. Throughout, is an arbitrary type (an implicit parameter of every declaration below except kerDim), and the typeclass assumptions carried by each declaration are stated individually; they differ from declaration to declaration and are not uniform across the bundle.
1. IsSimilar (definition)
Assumptions: is a commutative ring; is an arbitrary type that is a finite type and has decidable equality; are matrices over .
This defines a proposition, " is similar to ", to mean:
Three points of literal content. First, the condition on is that is an invertible element of the ring (i.e. there is with ), not that and not merely that . Second, denotes the total "nonsingular inverse" operation on matrices (adjugate divided by determinant), which returns a junk value — the zero matrix — when the determinant is not invertible; here that junk branch is excluded by the hypothesis, so is a genuine two-sided inverse of . Third, the equation is written in the specific order (the conjugating matrix on the right, its inverse on the left); no symmetry, reflexivity, transitivity, or any other property of this relation is asserted anywhere in this file. Degenerate case: if is empty, there is exactly one matrix and of it is , so the relation holds trivially for the unique .
2. jordanBlock (definition)
Assumptions: carries only a distinguished element and a distinguished element — no ring, group, or even additive structure is assumed. Inputs: a natural number and a scalar .
This defines the matrix indexed by in both coordinates, whose entry is
where is an equation between the underlying natural-number values of the indices. So sits on the diagonal and sits on the subdiagonal (the entries immediately below the diagonal); the superdiagonal entries are . The two cases are tested in that order, but they are mutually exclusive as stated, since and cannot both hold in . Nothing is assumed relating and in ; in particular may be trivial (). Degenerate cases: yields the empty matrix; yields the matrix with no subdiagonal.
3. jordanBlock_apply (theorem, tagged as a simplification lemma)
Assumptions: has a and a ; is a natural number (implicit); ; are indices in .
The claim is that the entry of the matrix of §2 equals if , else if the natural number equals the natural number , else . This restates the defining formula of §2 verbatim and is proved by definitional unfolding; it asserts no new mathematical content.
4. jordanIndex (abbreviation)
Assumptions: none beyond a natural number (implicit) and a function .
This names the index type
the disjoint union (dependent pair type) whose elements are pairs with a block label in and an index in . Its cardinality is . Degenerate cases: if , or if every , this type is empty; blocks with contribute no indices.
5. jordanMatrix (definition)
Assumptions: has a and a ; is a natural number (implicit); assigns a natural-number size to each of the block labels, and assigns an element of to each block label.
This defines the block-diagonal matrix indexed by (§4) whose -th diagonal block is the matrix of §2 and whose off-diagonal blocks are zero:
The eigenvalue function is arbitrary: distinct blocks may carry the same scalar, and no relation among the is imposed. Sizes are arbitrary naturals, including .
6. jordanMatrix_apply_same (theorem, tagged as a simplification lemma)
Assumptions: has a and a ; (implicit), , as above; a block label; indices in .
The claim: the entry of at row and column — i.e. two indices lying in the same block — equals the entry of the single Jordan block .
7. jordanMatrix_apply_ne (theorem, tagged as a simplification lemma)
Assumptions: has a and a ; (implicit), , as above; block labels (implicit); an index in , an index in ; and the explicit hypothesis .
The claim: whenever the row's block label differs from the column's block label, the entry of at row , column is .
8. IsJordanFormOf (definition)
Assumptions: is a commutative ring; is a finite type with decidable equality; is a natural number (implicit); is an matrix over ; and .
This defines the proposition "the block data is a Jordan form of " as the conjunction of:
- Every block is nonempty: for all ; and
- There exists a bijection between the index type of and the disjoint union of block index sets, such that is similar (in the exact sense of §1: there exists over with a unit and equal to the target) to the matrix obtained by transporting along , namely the matrix whose entry is .
Several literal points. The bijection is existentially quantified, so no particular ordering of is fixed; but its mere existence forces , so the proposition is unsatisfiable for any block data whose sizes do not sum to the size of . The similarity is stated in the direction " is similar to the reindexed Jordan matrix", with the conjugator ranging over -indexed matrices with unit determinant. Nothing asserts that the are eigenvalues, roots of the characteristic polynomial, or otherwise related to except through this similarity; nothing asserts uniqueness of ; and no ordering, grouping, or distinctness condition on the blocks is imposed. Degenerate cases: (no blocks) satisfies condition 1 vacuously and is possible exactly when is empty; conversely condition 1 rules out any block of size , so padding with empty blocks is excluded.
9. HasJordanForm (definition)
Assumptions: is a commutative ring; is a finite type with decidable equality; is an matrix over .
This defines the proposition " has a Jordan form" as: there exist a natural number , a size function , and a scalar function such that is a Jordan form of in the sense of §8 — i.e. all , and for some bijection and some matrix over with a unit of , equals the matrix with entries . This is a definition only; no theorem in this file asserts that any matrix has this property, and in particular no existence theorem over or any algebraically closed field is stated.
10. jordanBlocks (definition)
Assumptions: none at all on — no ring, no zero, no one; is a bare type. Inputs: (implicit), , .
This defines the multiset (unordered collection with multiplicities) of pairs
obtained by mapping ) over all block labels. It has exactly elements counted with multiplicity; repeated pairs are kept as repetitions and only the ordering of the blocks is forgotten. This is a construction on arbitrary block data; it is attached to no matrix, and no theorem in this file relates it to IsJordanFormOf, HasJordanForm, or any uniqueness claim.
11. kerDim (definition, noncomputable)
Assumptions: is a field (a fresh type variable, not the used above); is a natural number (implicit); is an matrix over indexed by ; ; .
This defines the natural number
that is: form the matrix (the scalar acting on the identity matrix, i.e. the diagonal matrix with in every diagonal position), raise it to the -th power as a matrix product, view the result as the -linear endomorphism of the coordinate space given by multiplication on the standard basis, and take the -dimension of its kernel as a submodule of .
Literal points: matrix power is the ordinary product, so gives the identity matrix, whose kernel is and hence ; gives the zero space and dimension for every . The value is the rank/dimension function that returns a natural number (returning in the degenerate convention for non-finite-dimensional modules, which does not arise here since is finite-dimensional). No theorem in this file states any property of this quantity — no monotonicity in , no stabilization, no relation to block sizes or to any of the Jordan definitions above.
Scope note
The file contains three theorems (§3, §6, §7); each is an entry-value computation for the matrices defined in §2 and §5, and each is proved by unfolding definitions. Everything else (§1, §2, §4, §5, §8, §9, §10, §11) is a definition or abbreviation. No statement in the file asserts existence, uniqueness, or invariance of Jordan forms, and no statement connects kerDim or jordanBlocks to IsJordanFormOf or HasJordanForm.
Confirmed by the mission captain (proposal self-audit).