File: Mathlib/Data/Matrix/Rank.lean

full_name: Matrix.rank
code: /-- The rank of a matrix is the rank of its image. -/
noncomputable def rank (A : Matrix m n R) : ℕ 
goal: ℕ

full_name: Matrix.rank_one
code: @[simp]
theorem rank_one [StrongRankCondition R] [DecidableEq n] :
    rank (1 : Matrix n n R) = Fintype.card n 
goal: Matrix.rank 1 = Fintype.card n

full_name: Matrix.rank_zero
code: @[simp]
theorem rank_zero [Nontrivial R] : rank (0 : Matrix m n R) = 0 
goal: Matrix.rank 0 = 0

full_name: Matrix.rank_le_card_width
code: theorem rank_le_card_width [StrongRankCondition R] (A : Matrix m n R) :
    A.rank ≤ Fintype.card n 
goal: A.rank ≤ Fintype.card n

full_name: Matrix.rank_le_width
code: theorem rank_le_width [StrongRankCondition R] {m n : ℕ} (A : Matrix (Fin m) (Fin n) R) :
    A.rank ≤ n 
goal: A.rank ≤ n

full_name: Matrix.rank_mul_le_left
code: theorem rank_mul_le_left [StrongRankCondition R] (A : Matrix m n R) (B : Matrix n o R) :
    (A * B).rank ≤ A.rank 
goal: (A * B).rank ≤ A.rank

full_name: Matrix.rank_mul_le_right
code: theorem rank_mul_le_right [StrongRankCondition R] (A : Matrix m n R) (B : Matrix n o R) :
    (A * B).rank ≤ B.rank 
goal: (A * B).rank ≤ B.rank

full_name: Matrix.rank_mul_le
code: theorem rank_mul_le [StrongRankCondition R] (A : Matrix m n R) (B : Matrix n o R) :
    (A * B).rank ≤ min A.rank B.rank 
goal: (A * B).rank ≤ min A.rank B.rank

full_name: Matrix.rank_unit
code: theorem rank_unit [StrongRankCondition R] [DecidableEq n] (A : (Matrix n n R)ˣ) :
    (A : Matrix n n R).rank = Fintype.card n 
goal: (↑A).rank = Fintype.card n

full_name: Matrix.rank_of_isUnit
code: theorem rank_of_isUnit [StrongRankCondition R] [DecidableEq n] (A : Matrix n n R) (h : IsUnit A) :
    A.rank = Fintype.card n 
goal: A.rank = Fintype.card n

full_name: Matrix.rank_mul_eq_left_of_isUnit_det
code: /-- Right multiplying by an invertible matrix does not change the rank -/
@[simp]
lemma rank_mul_eq_left_of_isUnit_det [DecidableEq n]
    (A : Matrix n n R) (B : Matrix m n R) (hA : IsUnit A.det) :
    (B * A).rank = B.rank 
goal: (B * A).rank = B.rank

full_name: Matrix.rank_mul_eq_right_of_isUnit_det
code: /-- Left multiplying by an invertible matrix does not change the rank -/
@[simp]
lemma rank_mul_eq_right_of_isUnit_det [Fintype m] [DecidableEq m]
    (A : Matrix m m R) (B : Matrix m n R) (hA : IsUnit A.det) :
    (A * B).rank = B.rank 
goal: (A * B).rank = B.rank

full_name: Matrix.rank_submatrix_le
code: /-- Taking a subset of the rows and permuting the columns reduces the rank. -/
theorem rank_submatrix_le [StrongRankCondition R] [Fintype m] (f : n → m) (e : n ≃ m)
    (A : Matrix m m R) : rank (A.submatrix f e) ≤ rank A 
goal: (A.submatrix f ⇑e).rank ≤ A.rank

full_name: Matrix.rank_reindex
code: theorem rank_reindex [Fintype m] (e₁ e₂ : m ≃ n) (A : Matrix m m R) :
    rank (reindex e₁ e₂ A) = rank A 
goal: ((Matrix.reindex e₁ e₂) A).rank = A.rank

full_name: Matrix.rank_submatrix
code: @[simp]
theorem rank_submatrix [Fintype m] (A : Matrix m m R) (e₁ e₂ : n ≃ m) :
    rank (A.submatrix e₁ e₂) = rank A 
goal: (A.submatrix ⇑e₁ ⇑e₂).rank = A.rank

full_name: Matrix.rank_eq_finrank_range_toLin
code: theorem rank_eq_finrank_range_toLin [Finite m] [DecidableEq n] {M₁ M₂ : Type*} [AddCommGroup M₁]
    [AddCommGroup M₂] [Module R M₁] [Module R M₂] (A : Matrix m n R) (v₁ : Basis m R M₁)
    (v₂ : Basis n R M₂) : A.rank = finrank R (LinearMap.range (toLin v₂ v₁ A)) 
goal: A.rank = FiniteDimensional.finrank R ↥(LinearMap.range ((Matrix.toLin v₂ v₁) A))

full_name: Matrix.rank_le_card_height
code: theorem rank_le_card_height [Fintype m] [StrongRankCondition R] (A : Matrix m n R) :
    A.rank ≤ Fintype.card m 
goal: A.rank ≤ Fintype.card m

full_name: Matrix.rank_le_height
code: theorem rank_le_height [StrongRankCondition R] {m n : ℕ} (A : Matrix (Fin m) (Fin n) R) :
    A.rank ≤ m 
goal: A.rank ≤ m

full_name: Matrix.rank_eq_finrank_span_cols
code: /-- The rank of a matrix is the rank of the space spanned by its columns. -/
theorem rank_eq_finrank_span_cols (A : Matrix m n R) :
    A.rank = finrank R (Submodule.span R (Set.range Aᵀ)) 
goal: A.rank = FiniteDimensional.finrank R ↥(Submodule.span R (Set.range Aᵀ))

full_name: Matrix.rank_diagonal
code: /-- The rank of a diagnonal matrix is the count of non-zero elements on its main diagonal -/
theorem rank_diagonal [Fintype m] [DecidableEq m] [DecidableEq R] (w : m → R) :
    (diagonal w).rank = Fintype.card {i // (w i) ≠ 0} 
goal: (Matrix.diagonal w).rank = Fintype.card { i // w i ≠ 0 }

full_name: Matrix.ker_mulVecLin_conjTranspose_mul_self
code: theorem ker_mulVecLin_conjTranspose_mul_self (A : Matrix m n R) :
    LinearMap.ker (Aᴴ * A).mulVecLin = LinearMap.ker (mulVecLin A) 
goal: LinearMap.ker (Aᴴ * A).mulVecLin = LinearMap.ker A.mulVecLin

full_name: Matrix.rank_conjTranspose_mul_self
code: theorem rank_conjTranspose_mul_self (A : Matrix m n R) : (Aᴴ * A).rank = A.rank 
goal: (Aᴴ * A).rank = A.rank

full_name: Matrix.rank_conjTranspose
code: /-- TODO: prove this in greater generality. -/
@[simp]
theorem rank_conjTranspose (A : Matrix m n R) : Aᴴ.rank = A.rank 
goal: Aᴴ.rank = A.rank

full_name: Matrix.rank_self_mul_conjTranspose
code: @[simp]
theorem rank_self_mul_conjTranspose (A : Matrix m n R) : (A * Aᴴ).rank = A.rank 
goal: (A * Aᴴ).rank = A.rank

full_name: Matrix.ker_mulVecLin_transpose_mul_self
code: theorem ker_mulVecLin_transpose_mul_self (A : Matrix m n R) :
    LinearMap.ker (Aᵀ * A).mulVecLin = LinearMap.ker (mulVecLin A) 
goal: LinearMap.ker (Aᵀ * A).mulVecLin = LinearMap.ker A.mulVecLin

full_name: Matrix.rank_transpose_mul_self
code: theorem rank_transpose_mul_self (A : Matrix m n R) : (Aᵀ * A).rank = A.rank 
goal: (Aᵀ * A).rank = A.rank

full_name: Matrix.rank_transpose
code: /-- TODO: prove this in greater generality. -/
@[simp]
theorem rank_transpose (A : Matrix m n R) : Aᵀ.rank = A.rank 
goal: Aᵀ.rank = A.rank

full_name: Matrix.rank_self_mul_transpose
code: @[simp]
theorem rank_self_mul_transpose (A : Matrix m n R) : (A * Aᵀ).rank = A.rank 
goal: (A * Aᵀ).rank = A.rank

full_name: Matrix.rank_eq_finrank_span_row
code: /-- The rank of a matrix is the rank of the space spanned by its rows.

TODO: prove this in a generality that works for `ℂ` too, not just `ℚ` and `ℝ`. -/
theorem rank_eq_finrank_span_row [LinearOrderedField R] [Finite m] (A : Matrix m n R) :
    A.rank = finrank R (Submodule.span R (Set.range A)) 
goal: A.rank = FiniteDimensional.finrank R ↥(Submodule.span R (Set.range A))