Skip to content

Commit b9f14eb

Browse files
chore(LinearAlgebra/Matrix/Reindex): generalize reindexAlgEquiv (#14823)
Co-authored-by: Whysoserioushah <109107491+Whysoserioushah@users.noreply.github.com>
1 parent 63fc395 commit b9f14eb

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

Mathlib/Algebra/Lie/Classical.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ noncomputable def typeBEquivSo' [Invertible (2 : R)] : typeB l R ≃ₗ⁅R⁆ s
337337
apply (skewAdjointMatricesLieSubalgebraEquiv (JB l R) (PB l R) (by infer_instance)).trans
338338
symm
339339
apply
340-
(skewAdjointMatricesLieSubalgebraEquivTranspose (indefiniteDiagonal (Unit ⊕ l) l R)
341-
(Matrix.reindexAlgEquiv _ (Equiv.sumAssoc PUnit l l)) (Matrix.transpose_reindex _ _)).trans
340+
(skewAdjointMatricesLieSubalgebraEquivTranspose (indefiniteDiagonal (Sum Unit l) l R)
341+
(Matrix.reindexAlgEquiv _ _ (Equiv.sumAssoc PUnit l l))
342+
(Matrix.transpose_reindex _ _)).trans
342343
apply LieEquiv.ofEq
343344
ext A
344345
rw [jb_transform, ← val_unitOfInvertible (2 : R), ← Units.smul_def, LieSubalgebra.mem_coe,

Mathlib/LinearAlgebra/Matrix/Basis.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ theorem basis_toMatrix_basisFun_mul (b : Basis ι R (ι → R)) (A : Matrix ι
221221

222222
/-- See also `Basis.toMatrix_reindex` which gives the `simp` normal form of this result. -/
223223
theorem Basis.toMatrix_reindex' [DecidableEq ι] [DecidableEq ι'] (b : Basis ι R M) (v : ι' → M)
224-
(e : ι ≃ ι') : (b.reindex e).toMatrix v = Matrix.reindexAlgEquiv _ e (b.toMatrix (v ∘ e)) := by
224+
(e : ι ≃ ι') : (b.reindex e).toMatrix v =
225+
Matrix.reindexAlgEquiv R R e (b.toMatrix (v ∘ e)) := by
225226
ext
226227
simp only [Basis.toMatrix_apply, Basis.repr_reindex, Matrix.reindexAlgEquiv_apply,
227228
Matrix.reindex_apply, Matrix.submatrix_apply, Function.comp_apply, e.apply_symm_apply,

Mathlib/LinearAlgebra/Matrix/Reindex.lean

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,32 +103,34 @@ end Semiring
103103
section Algebra
104104

105105
variable [CommSemiring R] [Fintype n] [Fintype m] [DecidableEq m] [DecidableEq n]
106+
[Semiring A] [Algebra R A]
106107

107-
/-- For square matrices with coefficients in commutative semirings, the natural map that reindexes
108-
a matrix's rows and columns with equivalent types, `Matrix.reindex`, is an equivalence of algebras.
109-
-/
110-
def reindexAlgEquiv (e : m ≃ n) : Matrix m m R ≃ₐ[R] Matrix n n R :=
111-
{ reindexLinearEquiv R R e e with
108+
/-- For square matrices with coefficients in an algebra over a commutative semiring, the natural
109+
map that reindexes a matrix's rows and columns with equivalent types,
110+
`Matrix.reindex`, is an equivalence of algebras. -/
111+
def reindexAlgEquiv (e : m ≃ n) : Matrix m m A ≃ₐ[R] Matrix n n A :=
112+
{ reindexLinearEquiv A A e e with
112113
toFun := reindex e e
113-
map_mul' := fun a b => (reindexLinearEquiv_mul R R e e e a b).symm
114+
map_mul' := fun a b => (reindexLinearEquiv_mul A A e e e a b).symm
114115
-- Porting note: `submatrix_smul` needed help
115116
commutes' := fun r => by simp [algebraMap, Algebra.toRingHom, submatrix_smul _ 1] }
116117

117118
@[simp]
118-
theorem reindexAlgEquiv_apply (e : m ≃ n) (M : Matrix m m R) :
119-
reindexAlgEquiv R e M = reindex e e M :=
119+
theorem reindexAlgEquiv_apply (e : m ≃ n) (M : Matrix m m A) :
120+
reindexAlgEquiv R A e M = reindex e e M :=
120121
rfl
121122

122123
@[simp]
123-
theorem reindexAlgEquiv_symm (e : m ≃ n) : (reindexAlgEquiv R e).symm = reindexAlgEquiv R e.symm :=
124+
theorem reindexAlgEquiv_symm (e : m ≃ n) : (reindexAlgEquiv R A e).symm =
125+
reindexAlgEquiv R A e.symm :=
124126
rfl
125127

126128
@[simp]
127-
theorem reindexAlgEquiv_refl : reindexAlgEquiv R (Equiv.refl m) = AlgEquiv.refl :=
129+
theorem reindexAlgEquiv_refl : reindexAlgEquiv R A (Equiv.refl m) = AlgEquiv.refl :=
128130
AlgEquiv.ext fun _ => rfl
129131

130-
theorem reindexAlgEquiv_mul (e : m ≃ n) (M : Matrix m m R) (N : Matrix m m R) :
131-
reindexAlgEquiv R e (M * N) = reindexAlgEquiv R e M * reindexAlgEquiv R e N :=
132+
theorem reindexAlgEquiv_mul (e : m ≃ n) (M : Matrix m m A) (N : Matrix m m A) :
133+
reindexAlgEquiv R A e (M * N) = reindexAlgEquiv R A e M * reindexAlgEquiv R A e N :=
132134
_root_.map_mul ..
133135

134136
end Algebra
@@ -145,8 +147,9 @@ theorem det_reindexLinearEquiv_self [CommRing R] [Fintype m] [DecidableEq m] [Fi
145147
146148
For the `simp` version of this lemma, see `det_submatrix_equiv_self`.
147149
-/
148-
theorem det_reindexAlgEquiv [CommRing R] [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n]
149-
(e : m ≃ n) (A : Matrix m m R) : det (reindexAlgEquiv R e A) = det A :=
150+
theorem det_reindexAlgEquiv (B : Type*) [CommRing R] [CommRing B] [Algebra R B] [Fintype m]
151+
[DecidableEq m] [Fintype n] [DecidableEq n] (e : m ≃ n) (A : Matrix m m B) :
152+
det (reindexAlgEquiv R B e A) = det A :=
150153
det_reindex_self e A
151154

152155
end Matrix

Mathlib/LinearAlgebra/Matrix/Transvection.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def reindexEquiv (e : n ≃ p) (t : TransvectionStruct n R) : TransvectionStruct
283283
variable [Fintype n] [Fintype p]
284284

285285
theorem toMatrix_reindexEquiv (e : n ≃ p) (t : TransvectionStruct n R) :
286-
(t.reindexEquiv e).toMatrix = reindexAlgEquiv R e t.toMatrix := by
286+
(t.reindexEquiv e).toMatrix = reindexAlgEquiv R _ e t.toMatrix := by
287287
rcases t with ⟨t_i, t_j, _⟩
288288
ext a b
289289
simp only [reindexEquiv, transvection, mul_boole, Algebra.id.smul_eq_mul, toMatrix_mk,
@@ -292,12 +292,12 @@ theorem toMatrix_reindexEquiv (e : n ≃ p) (t : TransvectionStruct n R) :
292292
simp [ha, hb, hab, ← e.apply_eq_iff_eq_symm_apply, stdBasisMatrix]
293293

294294
theorem toMatrix_reindexEquiv_prod (e : n ≃ p) (L : List (TransvectionStruct n R)) :
295-
(L.map (toMatrix ∘ reindexEquiv e)).prod = reindexAlgEquiv R e (L.map toMatrix).prod := by
295+
(L.map (toMatrix ∘ reindexEquiv e)).prod = reindexAlgEquiv R _ e (L.map toMatrix).prod := by
296296
induction' L with t L IH
297297
· simp
298298
· simp only [toMatrix_reindexEquiv, IH, Function.comp_apply, List.prod_cons,
299299
reindexAlgEquiv_apply, List.map]
300-
exact (reindexAlgEquiv_mul _ _ _ _).symm
300+
exact (reindexAlgEquiv_mul R _ _ _ _).symm
301301

302302
end TransvectionStruct
303303

@@ -616,18 +616,18 @@ theorem reindex_exists_list_transvec_mul_mul_list_transvec_eq_diagonal (M : Matr
616616
(e : p ≃ n)
617617
(H :
618618
∃ (L L' : List (TransvectionStruct n 𝕜)) (D : n → 𝕜),
619-
(L.map toMatrix).prod * Matrix.reindexAlgEquiv 𝕜 e M * (L'.map toMatrix).prod =
619+
(L.map toMatrix).prod * Matrix.reindexAlgEquiv 𝕜 _ e M * (L'.map toMatrix).prod =
620620
diagonal D) :
621621
∃ (L L' : List (TransvectionStruct p 𝕜)) (D : p → 𝕜),
622622
(L.map toMatrix).prod * M * (L'.map toMatrix).prod = diagonal D := by
623623
rcases H with ⟨L₀, L₀', D₀, h₀⟩
624624
refine ⟨L₀.map (reindexEquiv e.symm), L₀'.map (reindexEquiv e.symm), D₀ ∘ e, ?_⟩
625-
have : M = reindexAlgEquiv 𝕜 e.symm (reindexAlgEquiv 𝕜 e M) := by
625+
have : M = reindexAlgEquiv 𝕜 _ e.symm (reindexAlgEquiv 𝕜 _ e M) := by
626626
simp only [Equiv.symm_symm, submatrix_submatrix, reindex_apply, submatrix_id_id,
627627
Equiv.symm_comp_self, reindexAlgEquiv_apply]
628628
rw [this]
629629
simp only [toMatrix_reindexEquiv_prod, List.map_map, reindexAlgEquiv_apply]
630-
simp only [← reindexAlgEquiv_apply, ← reindexAlgEquiv_mul, h₀]
630+
simp only [← reindexAlgEquiv_apply 𝕜, ← reindexAlgEquiv_mul, h₀]
631631
simp only [Equiv.symm_symm, reindex_apply, submatrix_diagonal_equiv, reindexAlgEquiv_apply]
632632

633633
/-- Any matrix can be reduced to diagonal form by elementary operations. Formulated here on `Type 0`

0 commit comments

Comments
 (0)