Skip to content

Commit 067bc40

Browse files
MohanadAhmedocfnasheric-wieser
committed
feat: (Mathlib.Data.Matrix.Rank): rank of a matrix unaffected by multiplication with invertible matrices (#6051)
This PR provides two lemmas: - `Matrix.rank_mul_eq_left_of_isUnit_det` in a commutative ring R post multiplication (multiplication from the right) by an invertible matrix does not change the rank of a matrix. With $A$ an invertible matrix: $$\text{rank}(BA) = \text{rank}(B)$$ - `Matrix.rank_mul_eq_right_of_isUnit_det` in a commutative ring R pre-multiplication (multiplication from the left) by an invertible matrix does not change the rank of a matrix. With $A$ an invertible matrix: $$\text{rank}(AB) = \text{rank}(B)$$ Co-authored-by: Mohanad Ahmed <m.a.m.elhassan@gmail.com> Co-authored-by: Oliver Nash <github@olivernash.org> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent e77e8e1 commit 067bc40

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Mathlib/Data/Matrix/Rank.lean

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/-
22
Copyright (c) 2021 Johan Commelin. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Johan Commelin, Eric Wieer
4+
Authors: Johan Commelin, Eric Wieser
55
-/
66
import Mathlib.LinearAlgebra.FreeModule.Finite.Rank
77
import Mathlib.LinearAlgebra.Matrix.ToLin
88
import Mathlib.LinearAlgebra.FiniteDimensional
99
import Mathlib.LinearAlgebra.Matrix.DotProduct
10+
import Mathlib.LinearAlgebra.Determinant
1011
import Mathlib.Data.Complex.Module
1112

1213
#align_import data.matrix.rank from "leanprover-community/mathlib"@"17219820a8aa8abe85adf5dfde19af1dd1bd8ae7"
@@ -101,6 +102,26 @@ theorem rank_of_isUnit [StrongRankCondition R] [DecidableEq n] (A : Matrix n n R
101102
exact rank_unit A
102103
#align matrix.rank_of_is_unit Matrix.rank_of_isUnit
103104

105+
/-- Right multiplying by an invertible matrix does not change the rank -/
106+
lemma rank_mul_eq_left_of_isUnit_det [DecidableEq n]
107+
(A : Matrix n n R) (B : Matrix m n R) (hA : IsUnit A.det) :
108+
(B ⬝ A).rank = B.rank := by
109+
suffices : Function.Surjective A.mulVecLin
110+
· rw [rank, mulVecLin_mul, LinearMap.range_comp_of_range_eq_top _
111+
(LinearMap.range_eq_top.mpr this), ← rank]
112+
intro v
113+
exact ⟨(A⁻¹).mulVecLin v, by simp [mul_nonsing_inv _ hA]⟩
114+
115+
/-- Left multiplying by an invertible matrix does not change the rank -/
116+
lemma rank_mul_eq_right_of_isUnit_det [DecidableEq m]
117+
(A : Matrix m m R) (B : Matrix m n R) (hA : IsUnit A.det) :
118+
(A ⬝ B).rank = B.rank := by
119+
let b : Basis m R (m → R) := Pi.basisFun R m
120+
replace hA : IsUnit (LinearMap.toMatrix b b A.mulVecLin).det := by
121+
convert hA; rw [← LinearEquiv.eq_symm_apply]; rfl
122+
have hAB : mulVecLin (A ⬝ B) = (LinearEquiv.ofIsUnitDet hA).comp (mulVecLin B) := by ext; simp
123+
rw [rank, rank, hAB, LinearMap.range_comp, LinearEquiv.finrank_map_eq]
124+
104125
/-- Taking a subset of the rows and permuting the columns reduces the rank. -/
105126
theorem rank_submatrix_le [StrongRankCondition R] [Fintype m] (f : n → m) (e : n ≃ m)
106127
(A : Matrix m m R) : rank (A.submatrix f e) ≤ rank A := by

0 commit comments

Comments
 (0)