Skip to content

Commit 64580bf

Browse files
committed
chore: Address todo in Data/Matrix/Rank.lean (#15191)
This PR addresses a todo in `Data/Matrix/Rank.lean`, generalizing from `LinearOrderedField` to `Field` as suggested by this old Zulip thread: https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/row.20rank.20equals.20column.20rank/near/350462992
1 parent f758d8b commit 64580bf

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

Mathlib/Data/Matrix/Rank.lean

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Mathlib.LinearAlgebra.Determinant
77
import Mathlib.LinearAlgebra.FiniteDimensional
88
import Mathlib.LinearAlgebra.Matrix.Diagonal
99
import Mathlib.LinearAlgebra.Matrix.DotProduct
10+
import Mathlib.LinearAlgebra.Matrix.Dual
1011

1112
/-!
1213
# Rank of matrices
@@ -18,12 +19,6 @@ This definition does not depend on the choice of basis, see `Matrix.rank_eq_finr
1819
1920
* `Matrix.rank`: the rank of a matrix
2021
21-
## TODO
22-
23-
* Do a better job of generalizing over `ℚ`, `ℝ`, and `ℂ` in `Matrix.rank_transpose` and
24-
`Matrix.rank_conjTranspose`. See
25-
[this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/row.20rank.20equals.20column.20rank/near/350462992).
26-
2722
-/
2823

2924

@@ -250,22 +245,22 @@ theorem rank_transpose_mul_self (A : Matrix m n R) : (Aᵀ * A).rank = A.rank :=
250245
· rw [ker_mulVecLin_transpose_mul_self]
251246
· simp only [LinearMap.finrank_range_add_finrank_ker]
252247

253-
/-- TODO: prove this in greater generality. -/
248+
end LinearOrderedField
249+
254250
@[simp]
255-
theorem rank_transpose (A : Matrix m n R) : Aᵀ.rank = A.rank :=
256-
le_antisymm ((rank_transpose_mul_self _).symm.trans_le <| rank_mul_le_left _ _)
257-
((rank_transpose_mul_self _).symm.trans_le <| rank_mul_le_left _ _)
251+
theorem rank_transpose [Field R] [Fintype m] (A : Matrix m n R) : Aᵀ.rank = A.rank := by
252+
classical
253+
rw [Aᵀ.rank_eq_finrank_range_toLin (Pi.basisFun R n).dualBasis (Pi.basisFun R m).dualBasis,
254+
toLin_transpose, ← LinearMap.dualMap_def, LinearMap.finrank_range_dualMap_eq_finrank_range,
255+
toLin_eq_toLin', toLin'_apply', rank]
258256

259257
@[simp]
260-
theorem rank_self_mul_transpose (A : Matrix m n R) : (A * Aᵀ).rank = A.rank := by
258+
theorem rank_self_mul_transpose [LinearOrderedField R] [Fintype m] (A : Matrix m n R) :
259+
(A * Aᵀ).rank = A.rank := by
261260
simpa only [rank_transpose, transpose_transpose] using rank_transpose_mul_self Aᵀ
262261

263-
end LinearOrderedField
264-
265-
/-- The rank of a matrix is the rank of the space spanned by its rows.
266-
267-
TODO: prove this in a generality that works for `ℂ` too, not just `ℚ` and `ℝ`. -/
268-
theorem rank_eq_finrank_span_row [LinearOrderedField R] [Finite m] (A : Matrix m n R) :
262+
/-- The rank of a matrix is the rank of the space spanned by its rows. -/
263+
theorem rank_eq_finrank_span_row [Field R] [Finite m] (A : Matrix m n R) :
269264
A.rank = finrank R (Submodule.span R (Set.range A)) := by
270265
cases nonempty_fintype m
271266
rw [← rank_transpose, rank_eq_finrank_span_cols, transpose_transpose]

0 commit comments

Comments
 (0)