The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V07. Linear algebra

Mathlib.LinearAlgebra.Dimension.RankNullity

32 declarations and 1 deprecated aliases. Mathlib docs · Source

The rank nullity theorem

In this file we provide the rank nullity theorem as a typeclass, and prove various corollaries of the theorem. The main definition is HasRankNullity.{u} R, which states that

  1. Every R-module M : Type u has a linear independent subset of cardinality Module.rank R M.
  2. rank (M ⧸ N) + rank N = rank M for every R-module M : Type u and every N : Submodule R M.

The following instances are provided in mathlib:

  1. DivisionRing.hasRankNullity for division rings in Mathlib/LinearAlgebra/Dimension/DivisionRing.lean.
  2. IsDomain.hasRankNullity for commutative domains in Mathlib/LinearAlgebra/Dimension/Localization.lean.

TODO: prove the rank-nullity theorem for [Ring R] [IsDomain R] [StrongRankCondition R]. See nonempty_oreSet_of_strongRankCondition for a start.

class HasRankNullity E1 #

(R : Type v) → [inst : Ring R] → Prop

HasRankNullity.{u} is a class of rings satisfying

  1. Every R-module M : Type u has a linear independent subset of cardinality Module.rank R M.
  2. rank (M ⧸ N) + rank N = rank M for every R-module M : Type u and every N : Submodule R M.

Usually such a ring satisfies HasRankNullity.{w} for all universes w, and the universe argument is there because of technical limitations to universe polymorphism.

See DivisionRing.hasRankNullity and IsDomain.hasRankNullity.

ctor HasRankNullity.mk E0 #

∀ {R : Type v} [inst : Ring R],
  (∀ (M : Type u) [inst_1 : AddCommGroup M] [inst_2 : Module R M],
      ∃ s, Cardinal.mk ↑s = Module.rank R M ∧ LinearIndepOn R id s) →
    (∀ {M : Type u} [inst_1 : AddCommGroup M] [inst_2 : Module R M] (N : Submodule R M),
        Module.rank R (M ⧸ N) + Module.rank R ↥N = Module.rank R M) →
      HasRankNullity.{u, v} R

theorem HasRankNullity.exists_set_linearIndependent E1 #

∀ {R : Type v} {inst : Ring R} [self : HasRankNullity.{u, v} R] (M : Type u) [inst_1 : AddCommGroup M]
  [inst_2 : Module R M], ∃ s, Cardinal.mk ↑s = Module.rank R M ∧ LinearIndepOn R id s

theorem HasRankNullity.rank_quotient_add_rank E1 #

∀ {R : Type v} {inst : Ring R} [self : HasRankNullity.{u, v} R] {M : Type u} [inst_1 : AddCommGroup M]
  [inst_2 : Module R M] (N : Submodule R M), Module.rank R (M ⧸ N) + Module.rank R ↥N = Module.rank R M

theorem Submodule.rank_quotient_add_rank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] (N : Submodule R M), Module.rank R (M ⧸ N) + Module.rank R ↥N = Module.rank R M

theorem exists_set_linearIndependent E1 #

∀ (R : Type u_1) (M : Type u) [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R], ∃ s, Cardinal.mk ↑s = Module.rank R M ∧ LinearIndependent (ι := ↑s) R Subtype.val

instance instNontrivial_1 E0 #

∀ {R : Type u_1} [inst : Ring R] [HasRankNullity.{u, u_1} R], Nontrivial R

theorem LinearMap.lift_rank_range_add_rank_ker E1 #

∀ {R : Type u_1} {M : Type u} {M' : Type v} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M']
  [inst_3 : Module R M] [inst_4 : Module R M'] [HasRankNullity.{u, u_1} R] (f : M →ₗ[R] M'),
  Cardinal.lift.{u, v} (Module.rank R ↥f.range) + Cardinal.lift.{v, u} (Module.rank R ↥f.ker) =
    Cardinal.lift.{v, u} (Module.rank R M)

theorem LinearMap.rank_range_add_rank_ker E3 #

∀ {R : Type u_1} {M M₁ : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M₁]
  [inst_3 : Module R M] [inst_4 : Module R M₁] [HasRankNullity.{u, u_1} R] (f : M →ₗ[R] M₁),
  Module.rank R ↥f.range + Module.rank R ↥f.ker = Module.rank R M

The rank-nullity theorem

theorem LinearMap.lift_rank_eq_of_surjective E1 #

∀ {R : Type u_1} {M : Type u} {M' : Type v} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M']
  [inst_3 : Module R M] [inst_4 : Module R M'] [HasRankNullity.{u, u_1} R] {f : M →ₗ[R] M'},
  Function.Surjective ⇑f →
    Cardinal.lift.{v, u} (Module.rank R M) =
      Cardinal.lift.{u, v} (Module.rank R M') + Cardinal.lift.{v, u} (Module.rank R ↥f.ker)

theorem LinearMap.rank_eq_of_surjective E1 #

∀ {R : Type u_1} {M M₁ : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M₁]
  [inst_3 : Module R M] [inst_4 : Module R M₁] [HasRankNullity.{u, u_1} R] {f : M →ₗ[R] M₁},
  Function.Surjective ⇑f → Module.rank R M = Module.rank R M₁ + Module.rank R ↥f.ker

theorem LinearMap.lift_rank_map_add_rank_inf_ker E1 #

∀ {R : Type u_1} {M : Type u} {M' : Type v} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M']
  [inst_3 : Module R M] [inst_4 : Module R M'] [HasRankNullity.{u, u_1} R] (f : M →ₗ[R] M') (p : Submodule R M),
  Cardinal.lift.{u, v} (Module.rank R ↥(Submodule.map f p)) + Cardinal.lift.{v, u} (Module.rank R ↥(p ⊓ f.ker)) =
    Cardinal.lift.{v, u} (Module.rank R ↥p)

theorem LinearMap.rank_map_add_rank_inf_ker E1 #

∀ {R : Type u_1} {M M₁ : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M₁]
  [inst_3 : Module R M] [inst_4 : Module R M₁] [HasRankNullity.{u, u_1} R] (f : M →ₗ[R] M₁) (p : Submodule R M),
  Module.rank R ↥(Submodule.map f p) + Module.rank R ↥(p ⊓ f.ker) = Module.rank R ↥p

theorem LinearMap.lift_rank_comap E1 #

∀ {R : Type u_1} {M : Type u} {M' : Type v} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M']
  [inst_3 : Module R M] [inst_4 : Module R M'] [HasRankNullity.{u, u_1} R] (f : M →ₗ[R] M') (p : Submodule R M'),
  Cardinal.lift.{v, u} (Module.rank R ↥(Submodule.comap f p)) =
    Cardinal.lift.{u, v} (Module.rank R ↥(f.range ⊓ p)) + Cardinal.lift.{v, u} (Module.rank R ↥f.ker)

theorem LinearMap.rank_comap E1 #

∀ {R : Type u_1} {M M₁ : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M₁]
  [inst_3 : Module R M] [inst_4 : Module R M₁] [HasRankNullity.{u, u_1} R] (f : M →ₗ[R] M₁) (p : Submodule R M₁),
  Module.rank R ↥(Submodule.comap f p) = Module.rank R ↥(f.range ⊓ p) + Module.rank R ↥f.ker

theorem LinearMap.lift_rank_comap_le E1 #

∀ {R : Type u_1} {M : Type u} {M' : Type v} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M']
  [inst_3 : Module R M] [inst_4 : Module R M'] [HasRankNullity.{u, u_1} R] {f : M →ₗ[R] M'} (p : Submodule R M'),
  Cardinal.lift.{v, u} (Module.rank R ↥(Submodule.comap f p)) ≤
    Cardinal.lift.{u, v} (Module.rank R ↥p) + Cardinal.lift.{v, u} (Module.rank R ↥f.ker)

theorem LinearMap.rank_quot_submodule_map_eq E0 #

∀ {R : Type u_1} {M : Type u} {M' : Type v} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M']
  [inst_3 : Module R M] [inst_4 : Module R M'] [HasRankNullity.{v, u_1} R] {f : M →ₗ[R] M'} (p : Submodule R M),
  Module.rank R (M' ⧸ Submodule.map f p) =
    Module.rank R (M' ⧸ f.range) + Module.rank R (↥f.range ⧸ Submodule.map f.rangeRestrict p)

theorem LinearMap.lift_rank_quot_map_le E1 #

∀ {R : Type u_1} {M : Type u} {M' : Type v} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : AddCommGroup M']
  [inst_3 : Module R M] [inst_4 : Module R M'] [HasRankNullity.{v, u_1} R] {f : M →ₗ[R] M'} (p : Submodule R M),
  Cardinal.lift.{u, v} (Module.rank R (M' ⧸ Submodule.map f p)) ≤
    Cardinal.lift.{u, v} (Module.rank R (M' ⧸ f.range)) + Cardinal.lift.{v, u} (Module.rank R (M ⧸ p))

theorem exists_linearIndepOn_of_lt_rank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] {s : Set M},
  LinearIndepOn R id s → ∃ t, s ⊆ t ∧ Cardinal.mk ↑t = Module.rank R M ∧ LinearIndepOn R id t

theorem exists_linearIndependent_cons_of_lt_rank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] {n : ℕ} {v : Fin n → M},
  LinearIndependent R v → ↑n < Module.rank R M → ∃ x, LinearIndependent R (Fin.cons x v)

Given a family of n linearly independent vectors in a space of dimension > n, one may extend the family by another vector while retaining linear independence.

theorem exists_linearIndependent_snoc_of_lt_rank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] {n : ℕ} {v : Fin n → M},
  LinearIndependent R v → ↑n < Module.rank R M → ∃ x, LinearIndependent R (Fin.snoc v x)

Given a family of n linearly independent vectors in a space of dimension > n, one may extend the family by another vector while retaining linear independence.

theorem exists_linearIndependent_pair_of_one_lt_rank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [IsDomain R] [StrongRankCondition R] [Module.IsTorsionFree R M],
  1 < Module.rank R M → ∀ {x : M}, x ≠ 0 → ∃ y, LinearIndependent R ![x, y]

Given a nonzero vector in a space of dimension > 1, one may find another vector linearly independent of the first one.

theorem Submodule.exists_smul_notMem_of_rank_lt E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] {N : Submodule R M},
  Module.rank R ↥N < Module.rank R M → ∃ m, ∀ (r : R), r ≠ 0 → r • m ∉ N

theorem Submodule.rank_sup_add_rank_inf_eq E0 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] (s t : Submodule R M),
  Module.rank R ↥(s ⊔ t) + Module.rank R ↥(s ⊓ t) = Module.rank R ↥s + Module.rank R ↥t

theorem Submodule.rank_add_le_rank_add_rank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] (s t : Submodule R M), Module.rank R ↥(s ⊔ t) ≤ Module.rank R ↥s + Module.rank R ↥t

theorem exists_linearIndependent_snoc_of_lt_finrank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] {n : ℕ} {v : Fin n → M},
  LinearIndependent R v → n < Module.finrank R M → ∃ x, LinearIndependent R (Fin.snoc v x)

Given a family of n linearly independent vectors in a finite-dimensional space of dimension > n, one may extend the family by another vector while retaining linear independence.

theorem exists_linearIndependent_cons_of_lt_finrank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] {n : ℕ} {v : Fin n → M},
  LinearIndependent R v → n < Module.finrank R M → ∃ x, LinearIndependent R (Fin.cons x v)

Given a family of n linearly independent vectors in a finite-dimensional space of dimension > n, one may extend the family by another vector while retaining linear independence.

theorem exists_linearIndependent_pair_of_one_lt_finrank E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] [IsDomain R] [Module.IsTorsionFree R M],
  1 < Module.finrank R M → ∀ {x : M}, x ≠ 0 → ∃ y, LinearIndependent R ![x, y]

Given a nonzero vector in a finite-dimensional space of dimension > 1, one may find another vector linearly independent of the first one.

theorem Submodule.finrank_quotient_add_finrank E3 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] [Module.Finite R M] (N : Submodule R M),
  Module.finrank R (M ⧸ N) + Module.finrank R ↥N = Module.finrank R M

Rank-nullity theorem using finrank.

theorem Submodule.finrank_quotient E1 #

∀ {R : Type u_2} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_2} R] [StrongRankCondition R] [Module.Finite R M] {S : Type u_1} [inst_6 : Ring S]
  [inst_7 : SMul R S] [inst_8 : Module S M] [inst_9 : IsScalarTower R S M] (N : Submodule S M),
  Module.finrank R (M ⧸ N) = Module.finrank R M - Module.finrank R ↥N

Rank-nullity theorem using finrank and subtraction.

theorem Submodule.disjoint_ker_of_finrank_le E1 #

∀ {R : Type u_2} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_2} R] [StrongRankCondition R] [IsDomain R] [Module.IsTorsionFree R M] {N : Type u_1}
  [inst_7 : AddCommGroup N] [inst_8 : Module R N] {L : Submodule R M} [Module.Finite R ↥L] (f : M →ₗ[R] N),
  Module.finrank R ↥L ≤ Module.finrank R ↥(Submodule.map f L) → Disjoint L f.ker

theorem Submodule.exists_of_finrank_lt E1 #

∀ {R : Type u_1} {M : Type u} [inst : Ring R] [inst_1 : AddCommGroup M] [inst_2 : Module R M]
  [HasRankNullity.{u, u_1} R] [StrongRankCondition R] [Module.Finite R M] (N : Submodule R M),
  Module.finrank R ↥N < Module.finrank R M → ∃ m, ∀ (r : R), r ≠ 0 → r • m ∉ N

Deprecated aliases

NameNew nameSince
nontrivial_of_hasRankNullity2026-10-08