Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: port LinearAlgebra.FreeModule.Rank (#3377)
This PR also fixes the order of universes in `Cardinal.lift_lift`. Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: ChrisHughes24 <chrishughes24@gmail.com>
- Loading branch information
1 parent
1b5c5dc
commit 2870d41
Showing
4 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/- | ||
Copyright (c) 2021 Riccardo Brasca. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Riccardo Brasca | ||
! This file was ported from Lean 3 source module linear_algebra.free_module.rank | ||
! leanprover-community/mathlib commit 465d4301d8da5945ef1dc1b29fb34c2f2b315ac4 | ||
! Please do not edit these lines, except to modify the commit id | ||
! if you have ported upstream changes. | ||
-/ | ||
import Mathlib.LinearAlgebra.Dimension | ||
|
||
/-! | ||
# Extra results about `Module.rank` | ||
This file contains some extra results not in `LinearAlgebra.Dimension`. | ||
-/ | ||
|
||
|
||
universe u v w | ||
|
||
variable (R : Type u) (M : Type v) (N : Type w) | ||
|
||
open TensorProduct DirectSum BigOperators Cardinal | ||
|
||
open Cardinal | ||
|
||
section Ring | ||
|
||
variable [Ring R] [StrongRankCondition R] | ||
|
||
variable [AddCommGroup M] [Module R M] [Module.Free R M] | ||
|
||
variable [AddCommGroup N] [Module R N] [Module.Free R N] | ||
|
||
open Module.Free | ||
|
||
@[simp] | ||
theorem rank_finsupp (ι : Type w) : | ||
Module.rank R (ι →₀ M) = Cardinal.lift.{v} (#ι) * Cardinal.lift.{w} (Module.rank R M) := by | ||
obtain ⟨⟨_, bs⟩⟩ := Module.Free.exists_basis (R := R) (M := M) | ||
rw [← bs.mk_eq_rank'', ← (Finsupp.basis fun _ : ι => bs).mk_eq_rank'', Cardinal.mk_sigma, | ||
Cardinal.sum_const] | ||
#align rank_finsupp rank_finsupp | ||
|
||
theorem rank_finsupp' (ι : Type v) : Module.rank R (ι →₀ M) = (#ι) * Module.rank R M := by | ||
simp [rank_finsupp] | ||
#align rank_finsupp' rank_finsupp' | ||
|
||
set_option synthInstance.etaExperiment true in -- Porting note: gets around lean4#2074 | ||
/-- The rank of `(ι →₀ R)` is `(# ι).lift`. -/ | ||
@[simp] | ||
theorem rank_finsupp_self (ι : Type w) : Module.rank R (ι →₀ R) = Cardinal.lift.{u} (#ι) := by | ||
simp [rank_finsupp] | ||
#align rank_finsupp_self rank_finsupp_self | ||
|
||
/-- If `R` and `ι` lie in the same universe, the rank of `(ι →₀ R)` is `# ι`. -/ | ||
theorem rank_finsupp_self' {ι : Type u} : Module.rank R (ι →₀ R) = (#ι) := by simp | ||
#align rank_finsupp_self' rank_finsupp_self' | ||
|
||
/-- The rank of the direct sum is the sum of the ranks. -/ | ||
@[simp] | ||
theorem rank_directSum {ι : Type v} (M : ι → Type w) [∀ i : ι, AddCommGroup (M i)] | ||
[∀ i : ι, Module R (M i)] [∀ i : ι, Module.Free R (M i)] : | ||
Module.rank R (⨁ i, M i) = Cardinal.sum fun i => Module.rank R (M i) := by | ||
let B i := chooseBasis R (M i) | ||
let b : Basis _ R (⨁ i, M i) := Dfinsupp.basis fun i => B i | ||
simp [← b.mk_eq_rank'', fun i => (B i).mk_eq_rank''] | ||
#align rank_direct_sum rank_directSum | ||
|
||
/-- If `m` and `n` are `Fintype`, the rank of `m × n` matrices is `(# m).lift * (# n).lift`. -/ | ||
@[simp] | ||
theorem rank_matrix (m : Type v) (n : Type w) [Finite m] [Finite n] : | ||
Module.rank R (Matrix m n R) = | ||
Cardinal.lift.{max v w u, v} (#m) * Cardinal.lift.{max v w u, w} (#n) := by | ||
cases nonempty_fintype m | ||
cases nonempty_fintype n | ||
have h := (Matrix.stdBasis R m n).mk_eq_rank | ||
rw [← lift_lift.{max v w u, max v w}, lift_inj] at h | ||
simpa using h.symm | ||
#align rank_matrix rank_matrix | ||
|
||
/-- If `m` and `n` are `Fintype` that lie in the same universe, the rank of `m × n` matrices is | ||
`(# n * # m).lift`. -/ | ||
@[simp high] | ||
theorem rank_matrix' (m n : Type v) [Finite m] [Finite n] : | ||
Module.rank R (Matrix m n R) = Cardinal.lift.{u} ((#m) * (#n)) := by | ||
rw [rank_matrix, lift_mul, lift_umax.{v, u}] | ||
#align rank_matrix' rank_matrix' | ||
|
||
/-- If `m` and `n` are `Fintype` that lie in the same universe as `R`, the rank of `m × n` matrices | ||
is `# m * # n`. -/ | ||
-- @[simp] -- Porting note: simp can prove this | ||
theorem rank_matrix'' (m n : Type u) [Finite m] [Finite n] : | ||
Module.rank R (Matrix m n R) = (#m) * (#n) := by simp | ||
#align rank_matrix'' rank_matrix'' | ||
|
||
end Ring | ||
|
||
section CommRing | ||
|
||
variable [CommRing R] [StrongRankCondition R] | ||
|
||
variable [AddCommGroup M] [Module R M] [Module.Free R M] | ||
|
||
variable [AddCommGroup N] [Module R N] [Module.Free R N] | ||
|
||
open Module.Free | ||
|
||
/-- The rank of `M ⊗[R] N` is `(Module.rank R M).lift * (Module.rank R N).lift`. -/ | ||
@[simp] | ||
theorem rank_tensorProduct : | ||
Module.rank R (M ⊗[R] N) = | ||
Cardinal.lift.{w, v} (Module.rank R M) * Cardinal.lift.{v, w} (Module.rank R N) := by | ||
obtain ⟨⟨_, bM⟩⟩ := Module.Free.exists_basis (R := R) (M := M) | ||
obtain ⟨⟨_, bN⟩⟩ := Module.Free.exists_basis (R := R) (M := N) | ||
rw [← bM.mk_eq_rank'', ← bN.mk_eq_rank'', ← (bM.tensorProduct bN).mk_eq_rank'', Cardinal.mk_prod] | ||
#align rank_tensor_product rank_tensorProduct | ||
|
||
/-- If `M` and `N` lie in the same universe, the rank of `M ⊗[R] N` is | ||
`(Module.rank R M) * (Module.rank R N)`. -/ | ||
theorem rank_tensor_product' (N : Type v) [AddCommGroup N] [Module R N] [Module.Free R N] : | ||
Module.rank R (M ⊗[R] N) = Module.rank R M * Module.rank R N := by simp | ||
#align rank_tensor_product' rank_tensor_product' | ||
|
||
end CommRing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters