mathlib4 review helperopen PRs by @themathqueen on leanprover-community/mathlib4

← queue

#46289 chore(Matrix): generalize some AlgEquiv stuff now that it's nonunital

delegated t-algebra CI success

+119 −50 · 7 files · 10 commits · head bd6ae2c · updated 3 days ago · Files changed on GitHub

PR description

Now that AlgEquiv is nonunital, we can generalize a lot of things!


Conversation on GitHub 8
github-actions[bot] · comment · 2026-11-20
PR summary bd6ae2c5ed
Import changes for modified files

No significant changes to the import graph

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-|

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ coe_toNonUnitalRingHom + toAddEquiv_mapMatrix + toAddMonoidHom_mapMatrix + toNonUnitalAlgHom_mapMatrix + toNonUnitalRingHom + toRingEquiv_mapMatrix + toRingHom_mapMatrix ++ mapMatrix ++ mapMatrix_comp_mapMatrix ++ mapMatrix_id +++ toNonUnitalRingHom_mapMatrix <details> <summary>You can run this locally as follows</summary>

## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

</details>

The doc-module for scripts/pr_summary/declarations_diff.sh in the undefined repository contains some details about this script.

</details>

<details><summary>

Declarations diff (Lean)

</summary>

✅ Lean-aware diff — post-build, computed from the Lean environment (commit bd6ae2c).

  • +18 new declarations
  • −0 removed declarations
+AlgEquiv.toRingEquiv_mapMatrix
+AlgHom.toNonUnitalAlgHom_mapMatrix
+AlgHom.toRingHom_mapMatrix
+NonUnitalAlgHom.coe_toNonUnitalRingHom
+NonUnitalAlgHom.mapMatrix
+NonUnitalAlgHom.mapMatrix_apply
+NonUnitalAlgHom.mapMatrix_comp_mapMatrix
+NonUnitalAlgHom.mapMatrix_id
+NonUnitalAlgHom.toNonUnitalRingHom
+NonUnitalAlgHom.toNonUnitalRingHom_mapMatrix
+NonUnitalRingHom.mapMatrix
+NonUnitalRingHom.mapMatrix_apply
+NonUnitalRingHom.mapMatrix_comp_mapMatrix
+NonUnitalRingHom.mapMatrix_id
+NonUnitalRingHom.toAddMonoidHom_mapMatrix
+RingEquiv.toAddEquiv_mapMatrix
+RingEquiv.toNonUnitalRingHom_mapMatrix
+RingHom.toNonUnitalRingHom_mapMatrix

</details>


No changes to strong technical debt. No changes to weak technical debt.

Current commit bd6ae2c5ed Reference commit 7ac3ecc3ed

This script lives in the undefined repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
SnirBroshi · comment · 2026-11-20

Oh nice I was just about to do that, thanks! (this code is why I stumbled upon your original PR in the first place :)

themathqueen · comment · 2026-11-20

I think there's a lot more places to generalize stuff now, feel free to go ahead and open PRs. I'll stop with matrices (so just this PR) if you want :)

SnirBroshi · comment · 2026-11-20

Oh no don't let me stop you, I only knew about the matrix equivs

themathqueen · comment · 2026-11-20

!radar

leanprover-radar · comment · 2026-11-20

Benchmark results for cee3cfec10712f4ea628d1ec48bbd5aae7a1fe61 against 66f20c74af93380e30c6f16bad25e5ea77dd19c5 are in. No significant results found. @themathqueen

  • ✅ build//instructions: -796.9M (-0.00%)

Small changes (13✅, 13🟥)

  • 26 hidden
j-loreaux · commented · 2026-12-01

Looks good. I won't force the NonUnital{Ring,Alg}Hom.mapMatrix (+ generalizing RingEquiv.mapMatrix) to be part of this PR, or for this to depend on a PR implementing it, but I would slightly prefer it if you add those here.

bors d+

mathlib-bors[bot] · comment · 2026-12-01

:v: themathqueen can now approve this pull request until 2026-12-15 21:39 UTC (in 2 weeks). To approve and merge, reply with bors r+. More detailed instructions are available here.

:warning: This delegation only covers changes within Archive/**, Counterexamples/**, docs/**, DownstreamTest/**, Mathlib/**, MathlibTest/**, Wanted/**, widget/**, Archive.lean, Counterexamples.lean, docs.lean, Mathlib.lean, Wanted.lean; an author commit touching anything else will revoke it. Bors also revokes it if a later push changes too many files for it to check the full list — even if it stays within scope.

Mathlib/Algebra/Algebra/NonUnitalHom.lean +5 −0

theorem inr_apply (x : B) : inr R A B x = (0, x) :=
432end Prod
def toNonUnitalRingHom newL434–435
434/-- Interpret a non-unital algebra morphism as a non-unital ring morphism. -/
435def toNonUnitalRingHom (f : A →ₛₙₐ[φ] B) : A →ₙ+* B := NonUnitalRingHomClass.toNonUnitalRingHom f
lemma coe_toNonUnitalRingHom newL437–437
437@[simp] lemma coe_toNonUnitalRingHom (f : A →ₛₙₐ[φ] B) : ⇑f.toNonUnitalRingHom = f := rfl
439end NonUnitalAlgHom
441/-! ### Interaction with `AlgHom` -/

Mathlib/Analysis/CStarAlgebra/CStarMatrix.lean +4 −3

instance instRing [Fintype n] [DecidableEq n] [Ring A] : Ring (CStarMatrix n n A
367 inferInstanceAs <| Ring (Matrix n n A)
def ofMatrixRingEquiv changedL369–373
369/-- `ofMatrix` bundled as a ring equivalence. -/
−def ofMatrixRingEquiv [Fintype n] [Semiring A] :
370def ofMatrixRingEquiv [Fintype n] [AddCommMonoid A] [Mul A] :
j-loreaux · 2026-12-01

This seems a bit spurious (i.e., not particularly useful to go weaker the NonUnitalNonAssocSemiring A). But given that everything is fine is terms of benchmarking, I guess I don't really care.

371 Matrix n n A ≃+* CStarMatrix n n A :=
372 { ofMatrix with
373 map_mul' := fun _ _ => rfl
instance instAlgebra [Fintype n] [DecidableEq n] [CommSemiring R] [Semiring A] [
380 Algebra R (CStarMatrix n n A) := inferInstanceAs <| Algebra R (Matrix n n A)
def ofMatrixStarAlgEquiv changedL382–387
382/-- `ofMatrix` bundled as a star algebra equivalence. -/
−def ofMatrixStarAlgEquiv [Fintype n] [SMul ℂ A] [Semiring A] [StarRing A] :
383def ofMatrixStarAlgEquiv [Fintype n] [SMul ℂ A] [NonUnitalNonAssocSemiring A] [StarRing A] :
384 Matrix n n A ≃⋆ₐ[ℂ] CStarMatrix n n A :=
385 { ofMatrixRingEquiv with
386 map_star' := fun _ => rfl
387 map_smul' := fun _ _ => rfl }
lemma ofMatrix_eq_ofMatrixStarAlgEquiv changedL389–392
−lemma ofMatrix_eq_ofMatrixStarAlgEquiv [Fintype n] [SMul ℂ A] [Semiring A] [StarRing A] :
389lemma ofMatrix_eq_ofMatrixStarAlgEquiv [Fintype n] [SMul ℂ A] [NonUnitalNonAssocSemiring A]
390 [StarRing A] :
391 (ofMatrix : Matrix n n A → CStarMatrix n n A)
392 = (ofMatrixStarAlgEquiv : Matrix n n A → CStarMatrix n n A) := rfl

Mathlib/Data/Matrix/Basic.lean +93 −29

lemma entryLinearMap_comp_mapMatrix (f : α ≃ₛₗ[σᵣₛ] β) (i : m) (j :
603end LinearEquiv
605namespace NonUnitalRingHom
606variable [Fintype m]
607 [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalNonAssocSemiring γ]
def mapMatrix newL609–614
609/-- The `NonUnitalRingHom` between spaces of square matrices induced by a `NonUnitalRingHom`
610between their coefficients. This is `Matrix.map` as a `NonUnitalRingHom`. -/
611@[simps] def mapMatrix (f : α →ₙ+* β) : Matrix m m α →ₙ+* Matrix m m β where
612 __ := f.toAddMonoidHom.mapMatrix
613 toFun M := M.map f
614 map_mul' _ _ := Matrix.map_mul
theorem mapMatrix_id newL616–616
616@[simp] theorem mapMatrix_id : (NonUnitalRingHom.id α).mapMatrix = .id (Matrix m m α) := rfl
theorem mapMatrix_comp_mapMatrix newL618–619
618@[simp] theorem mapMatrix_comp_mapMatrix (f : β →ₙ+* γ) (g : α →ₙ+* β) :
619 f.mapMatrix.comp g.mapMatrix = ((f.comp g).mapMatrix : Matrix m m α →ₙ+* _) := rfl
theorem toAddMonoidHom_mapMatrix newL621–622
621@[simp] theorem toAddMonoidHom_mapMatrix (f : α →ₙ+* β) :
622 f.mapMatrix (m := m).toAddMonoidHom = f.toAddMonoidHom.mapMatrix := rfl
624end NonUnitalRingHom
626namespace RingHom
628variable [Fintype m] [DecidableEq m]
variable [NonAssocSemiring α] [NonAssocSemiring β] [NonAssocSemiring γ]
632coefficients. This is `Matrix.map` as a `RingHom`. -/
def mapMatrix changedL633–637
633@[simps]
634def mapMatrix (f : α →+* β) : Matrix m m α →+* Matrix m m β :=
− { f.toAddMonoidHom.mapMatrix with
635 { f.toNonUnitalRingHom.mapMatrix with
636 toFun := fun M => M.map f
− map_one' := by simp
− map_mul' := fun _ _ => Matrix.map_mul }
637 map_one' := by simp }
639@[simp]
640theorem mapMatrix_id : (RingHom.id α).mapMatrix = RingHom.id (Matrix m m α) :=
protected lemma _root_.Matrix.map_pow {α β : Type*} [Semiring α] [Semiring β
649 (M : Matrix m m α) (f : α →+* β) (a : ℕ) : (M ^ a).map f = (M.map f) ^ a :=
650 f.mapMatrix.map_pow M a
lemma toNonUnitalRingHom_mapMatrix newL652–653
652@[simp] lemma toNonUnitalRingHom_mapMatrix (f : α →+* β) :
653 f.mapMatrix (m := m).toNonUnitalRingHom = f.toNonUnitalRingHom.mapMatrix := rfl
655end RingHom
657namespace RingEquiv
−variable [Fintype m] [DecidableEq m]
−variable [NonAssocSemiring α] [NonAssocSemiring β] [NonAssocSemiring γ]
659variable [Fintype m]
660variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalNonAssocSemiring γ]
def mapMatrix changedL662–669
662/-- The `RingEquiv` between spaces of square matrices induced by a `RingEquiv` between their
663coefficients. This is `Matrix.map` as a `RingEquiv`. -/
664@[simps apply]
665def mapMatrix (f : α ≃+* β) : Matrix m m α ≃+* Matrix m m β :=
− { f.toRingHom.mapMatrix,
666 { f.toNonUnitalRingHom.mapMatrix,
667 f.toAddEquiv.mapMatrix with
668 toFun := fun M => M.map f
669 invFun := fun M => M.map f.symm }
theorem mapMatrix_trans (f : α ≃+* β) (g : β ≃+* γ) :
681 f.mapMatrix.trans g.mapMatrix = ((f.trans g).mapMatrix : Matrix m m α ≃+* _) :=
682 rfl
theorem toAddEquiv_mapMatrix newL684–685
684@[simp] theorem toAddEquiv_mapMatrix (f : α ≃+* β) :
685 (f.mapMatrix (m := m) : Matrix m m α ≃+ _) = f.toAddEquiv.mapMatrix := rfl
theorem toNonUnitalRingHom_mapMatrix newL687–688
687@[simp] theorem toNonUnitalRingHom_mapMatrix (f : α ≃+* β) :
688 f.mapMatrix (m := m).toNonUnitalRingHom = f.toNonUnitalRingHom.mapMatrix := rfl
690open MulOpposite in
691/-- For any ring `α`, we have ring isomorphism `Matₙₓₙ(αᵒᵖ) ≅ (Matₙₓₙ(α))ᵒᵖ` given by transpose.
theorem MulOpposite.isStablyFiniteRing_iff (α) [MulOne α] [AddCommMonoid α] :
714 .of_injective f (map_injective (op_injective.comp op_injective))⟩
715 mpr _ := inferInstance
717namespace NonUnitalAlgHom
718variable [Fintype m] [Monoid R] [Monoid S] {φ : R →* S} {T : Type*} [Monoid T] {ψ : S →* T}
719 [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalNonAssocSemiring γ]
720 [DistribMulAction R α] [DistribMulAction S β] [DistribMulAction T γ]
721 {χ : R →* T} [φ.CompTriple ψ χ]
def mapMatrix newL723–728
723/-- The `NonUnitalAlgHom` between spaces of square matrices induced by a `NonUnitalAlgHom`
724between their coefficients. This is `Matrix.map` as a `NonUnitalAlgHom`. -/
themathqueen · 2026-11-20

RingEquiv.mapMatrix should probably be generalized to nonunital too?

j-loreaux · 2026-12-01

Yes, but for that (to do it properly) we need the aforementioned NonUnitalRingHom.mapMatrix.

I'm starting to lean to just doing it in this PR.

We're also missing NonUnitalAlgHom.mapMatrix.

themathqueen · 2026-12-02

I didn't change the definition here, because f.toNonUnitalAlgHom would require more hypotheses on R.

725@[simps apply] def mapMatrix (f : α →ₛₙₐ[φ] β) : Matrix m m α →ₛₙₐ[φ] Matrix m m β :=
726 { f.toNonUnitalRingHom.mapMatrix with
727 toFun M := M.map f
728 map_smul' r := Matrix.map_smulₛₗ f _ r (map_smulₛₗ f _) }
theorem mapMatrix_id newL730–730
730@[simp] theorem mapMatrix_id : (NonUnitalAlgHom.id R α).mapMatrix = .id R (Matrix m m α) := rfl
theorem mapMatrix_comp_mapMatrix newL732–733
732@[simp] theorem mapMatrix_comp_mapMatrix (f : β →ₛₙₐ[ψ] γ) (g : α →ₛₙₐ[φ] β) :
733 f.mapMatrix.comp g.mapMatrix = ((f.comp g).mapMatrix : Matrix m m α →ₛₙₐ[χ] _) := rfl
theorem toNonUnitalRingHom_mapMatrix newL735–736
735@[simp] theorem toNonUnitalRingHom_mapMatrix (f : α →ₛₙₐ[φ] β) :
736 f.mapMatrix (m := m).toNonUnitalRingHom = f.toNonUnitalRingHom.mapMatrix := rfl
738end NonUnitalAlgHom
740namespace AlgHom
742variable [Fintype m] [DecidableEq m]
theorem mapMatrix_comp (f : β →ₐ[R] γ) (g : α →ₐ[R] β) :
760 f.mapMatrix.comp g.mapMatrix = ((f.comp g).mapMatrix : Matrix m m α →ₐ[R] _) :=
761 rfl
lemma toRingHom_mapMatrix newL763–764
763@[simp] lemma toRingHom_mapMatrix (f : α →ₐ[R] β) :
764 (f.mapMatrix (m := m) : _ →+* Matrix m m β) = f.toRingHom.mapMatrix := rfl
lemma toNonUnitalAlgHom_mapMatrix newL766–767
766@[simp] lemma toNonUnitalAlgHom_mapMatrix (f : α →ₐ[R] β) :
767 (f.mapMatrix (m := m) : _ →ₙₐ[R] Matrix m m β) = f.toNonUnitalAlgHom.mapMatrix := rfl
769end AlgHom
771namespace AlgEquiv
−variable [Fintype m] [DecidableEq m]
−variable [CommSemiring R] [Semiring α] [Semiring β] [Semiring γ]
−variable [Algebra R α] [Algebra R β] [Algebra R γ]
773variable [Fintype m]
774variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalNonAssocSemiring γ]
775variable [SMul R α] [SMul R β] [SMul R γ]
def mapMatrix changedL777–784
777/-- The `AlgEquiv` between spaces of square matrices induced by an `AlgEquiv` between their
778coefficients. This is `Matrix.map` as an `AlgEquiv`. -/
779@[simps apply]
780def mapMatrix (f : α ≃ₐ[R] β) : Matrix m m α ≃ₐ[R] Matrix m m β :=
− { f.toAlgHom.mapMatrix,
− f.toRingEquiv.mapMatrix with
− toFun := fun M => M.map f
− invFun := fun M => M.map f.symm }
781 { f.toRingEquiv.mapMatrix with
782 toFun M := M.map f
783 invFun M := M.map f.symm
784 map_smul' _ _ := by ext; simp }
786@[simp]
787theorem mapMatrix_refl : AlgEquiv.refl.mapMatrix = (AlgEquiv.refl : Matrix m m α ≃ₐ[R] _) :=
theorem mapMatrix_trans (f : α ≃ₐ[R] β) (g : β ≃ₐ[R] γ) :
797 f.mapMatrix.trans g.mapMatrix = ((f.trans g).mapMatrix : Matrix m m α ≃ₐ[R] _) :=
798 rfl
lemma toRingEquiv_mapMatrix newL800–801
800@[simp] lemma toRingEquiv_mapMatrix (f : α ≃ₐ[R] β) :
801 f.mapMatrix (m := m).toRingEquiv = f.toRingEquiv.mapMatrix := rfl
def mopMatrix changedL803–811
803/-- For any algebra `α` over a ring `R`, we have an `R`-algebra isomorphism
804`Matₙₓₙ(αᵒᵖ) ≅ (Matₙₓₙ(R))ᵒᵖ` given by transpose.
806See also `Matrix.transposeAlgEquiv` for a version that doesn't take the opposite of `α`,
807given that its multiplication is commutative. -/
−@[simps!] def mopMatrix : Matrix m m αᵐᵒᵖ ≃ₐ[R] (Matrix m m α)ᵐᵒᵖ where
808@[simps!] def mopMatrix {α : Type*} [AddCommMonoid α] [Mul α] [SMul R α] :
809 Matrix m m αᵐᵒᵖ ≃ₐ[R] (Matrix m m α)ᵐᵒᵖ where
810 __ := RingEquiv.mopMatrix
811 map_smul' _ _ := MulOpposite.unop_injective <| by ext; simp
variable [Fintype n]
938@[simp] theorem toAddEquiv_prodRingEquiv [AddCommMonoid α] [AddCommMonoid β] [Mul α] [Mul β] :
939 prodRingEquiv n α β = prodAddEquiv n n α β := rfl
−variable [CommSemiring R] [DecidableEq n]
−
def prodAlgEquiv changedL941–946
941/-- `prodEquiv` as an `AlgEquiv`. -/
−@[simps!] def prodAlgEquiv [Semiring α] [Algebra R α] [Semiring β] [Algebra R β] :
942@[simps!] def prodAlgEquiv [AddCommMonoid α] [AddCommMonoid β] [Mul α] [Mul β]
943 [SMul R α] [SMul R β] :
944 Matrix n n (α × β) ≃ₐ[R] Matrix n n α × Matrix n n β where
945 __ := prodRingEquiv n α β
− __ := AlgHom.mk' (prodRingEquiv n α β).toRingHom fun _ _ ↦ rfl
946 map_smul' _ _ := by ext <;> simp
theorem toRingEquiv_prodAlgEquiv changedL948–950
−@[simp] theorem toRingEquiv_prodAlgEquiv [Semiring α] [Algebra R α] [Semiring β] [Algebra R β] :
948@[simp] theorem toRingEquiv_prodAlgEquiv [AddCommMonoid α] [AddCommMonoid β] [Mul α] [Mul β]
949 [SMul R α] [SMul R β] :
950 prodAlgEquiv n R α β = prodRingEquiv n α β := rfl
theorem toLinearEquiv_prodAlgEquiv changedL952–954
−@[simp] theorem toLinearEquiv_prodAlgEquiv [Semiring α] [Algebra R α]
− [Semiring β] [Algebra R β] :
952@[simp] theorem toLinearEquiv_prodAlgEquiv [Semiring R] [NonUnitalNonAssocSemiring α]
953 [NonUnitalNonAssocSemiring β] [Module R α] [Module R β] :
954 prodAlgEquiv n R α β = prodLinearEquiv n n R α β := rfl
956end Prod
This is available in bundled forms as:
1001 (piRingEquiv (n := n) (ι := ι) (β := β) :
1002 Matrix n n (Π i, β i) ≃+ Π i, Matrix n n (β i)) = piAddEquiv := rfl
−variable (R) [CommSemiring R] [Π i, Semiring (β i)] [Π i, Algebra R (β i)]
− [Fintype n] [DecidableEq n]
1004variable (R) [Fintype n]
def piAlgEquiv changedL1006–1010
1006/-- `piEquiv` as an `AlgEquiv`. -/
−@[simps!] def piAlgEquiv : Matrix n n (Π i, β i) ≃ₐ[R] Π i, Matrix n n (β i) where
1007@[simps!] def piAlgEquiv [Π i, AddCommMonoid (β i)] [Π i, Mul (β i)] [Π i, SMul R (β i)] :
1008 Matrix n n (Π i, β i) ≃ₐ[R] Π i, Matrix n n (β i) where
1009 __ := piRingEquiv
− map_smul' := map_smul (AlgHom.mk' (piRingEquiv (β := β) (n := n)).toRingHom fun _ _ ↦ rfl)
1010 map_smul' _ _ := by ext; simp
theorem toRingEquiv_piAlgEquiv changedL1012–1015
−@[simp] theorem toRingEquiv_piAlgEquiv :
1012@[simp] theorem toRingEquiv_piAlgEquiv [Π i, AddCommMonoid (β i)] [Π i, Mul (β i)]
1013 [Π i, SMul R (β i)] :
1014 (piAlgEquiv (n := n) R (ι := ι) (β := β) :
1015 Matrix n n (Π i, β i) ≃+* Π i, Matrix n n (β i)) = piRingEquiv := rfl
theorem toLinearEquiv_piAlgEquiv changedL1017–1020
−@[simp] theorem toLinearEquiv_piAlgEquiv :
1017@[simp] theorem toLinearEquiv_piAlgEquiv [Semiring R] [Π i, NonUnitalNonAssocSemiring (β i)]
1018 [Π i, Module R (β i)] :
1019 (piAlgEquiv (n := n) R (ι := ι) (β := β) :
1020 Matrix n n (Π i, β i) ≃ₗ[R] Π i, Matrix n n (β i)) = piLinearEquiv R := rfl
variable (R m α)
1104See also `AlgEquiv.mopMatrix` for a version that doesn't require `α` to have commutative
1105multiplication, by taking its opposite. -/
def transposeAlgEquiv changedL1106–1110
1106@[simps!]
−def transposeAlgEquiv [CommSemiring R] [CommSemiring α] [Fintype m] [Algebra R α] :
1107def transposeAlgEquiv [CommMagma α] [AddCommMonoid α] [Fintype m] [SMul R α] :
1108 Matrix m m α ≃ₐ[R] (Matrix m m α)ᵐᵒᵖ where
1109 __ := transposeRingEquiv m α
1110 map_smul' := by simp
theorem toRingEquiv_transposeAlgEquiv changedL1112–1114
1112@[simp]
−theorem toRingEquiv_transposeAlgEquiv [CommSemiring R] [CommSemiring α] [Fintype m] [Algebra R α] :
1113theorem toRingEquiv_transposeAlgEquiv [CommMagma α] [AddCommMonoid α] [Fintype m] [SMul R α] :
1114 transposeAlgEquiv m R α = transposeRingEquiv m α := rfl
1116end Transpose

Mathlib/Data/Matrix/Composition.lean +4 −3

end LinearMap
177section Algebra
−variable (K : Type*) [CommSemiring K] [Semiring R] [Fintype I] [Fintype J] [Algebra K R]
179variable (K : Type*) [AddCommMonoid R] [Mul R] [Fintype I] [Fintype J] [SMul K R]
181/-- `Matrix.comp` as `AlgEquiv` -/
182def compAlgEquiv : Matrix I I (Matrix J J R) ≃ₐ[K] Matrix (I × J) (I × J) R where
theorem compAlgEquiv_symm_apply (M : Matrix (I × J) (I × J) R) :
192 (compAlgEquiv I J R K).symm M = (comp I I J J R).symm M := rfl
theorem isUnit_comp_iff changedL194–197
194@[simp]
−theorem isUnit_comp_iff [DecidableEq I] [DecidableEq J]
195theorem isUnit_comp_iff {R : Type*} [Semiring R] [DecidableEq I] [DecidableEq J]
196 {M : Matrix I I (Matrix J J R)} : IsUnit (comp _ _ _ _ _ M) ↔ IsUnit M :=
197 isUnit_map_iff (compAlgEquiv _ _ _ ℕ) M
theorem isUnit_comp_symm_iff changedL199–203
199@[simp]
−theorem isUnit_comp_symm_iff [DecidableEq I] [DecidableEq J] {M : Matrix (I × J) (I × J) R} :
200theorem isUnit_comp_symm_iff {R : Type*} [Semiring R]
201 [DecidableEq I] [DecidableEq J] {M : Matrix (I × J) (I × J) R} :
202 IsUnit (comp _ _ _ _ _ |>.symm M) ↔ IsUnit M :=
203 isUnit_map_iff (compAlgEquiv _ _ _ ℕ).symm M

Mathlib/LinearAlgebra/Matrix/ConjTranspose.lean +4 −5

theorem conjTranspose_list_prod [Semiring α] [StarRing α] [Fintype m] [Decidab
468variable (n α) in
def conjTransposeAlgEquiv changedL469–475
469/-- `Matrix.conjTranspose` as a `StarAlgEquiv` to the opposite ring -/
470@[simps!]
−def conjTransposeAlgEquiv [Fintype n] [CommSemiring R] [StarRing R] [TrivialStar R] [Semiring α]
− [StarRing α] [Algebra R α] [StarModule R α] : Matrix n n α ≃⋆ₐ[R] (Matrix n n α)ᵐᵒᵖ where
471def conjTransposeAlgEquiv [Fintype n] [Star R] [TrivialStar R] [NonUnitalNonAssocSemiring α]
472 [StarRing α] [SMul R α] [StarModule R α] :
473 Matrix n n α ≃⋆ₐ[R] (Matrix n n α)ᵐᵒᵖ where
474 __ := conjTransposeRingEquiv n α
− map_smul' r M := by
− change conjTransposeRingEquiv n α (r • M) = r • conjTransposeRingEquiv n α M
− simp
475 map_smul' r M := by simp
477end Matrix

Mathlib/LinearAlgebra/Matrix/Reindex.lean +8 −9

end Semiring
203section Algebra
−variable [CommSemiring R] [Fintype n] [Fintype m] [Fintype o] [Semiring A] [Algebra R A]
205variable [Fintype n] [Fintype m] [AddCommMonoid A] [Mul A] [SMul R A]
207/-- For square matrices with coefficients in an algebra over a commutative semiring, the natural
208map that reindexes a matrix's rows and columns with equivalent types,
theorem toRingEquiv_reindexAlgEquiv (e : m ≃ n) : reindexAlgEquiv R A e = rein
229 rfl
theorem toLinearEquiv_reindexAlgEquiv changedL231–235
231@[simp]
−theorem toLinearEquiv_reindexAlgEquiv (e : m ≃ n) :
232theorem toLinearEquiv_reindexAlgEquiv {A : Type*} [Semiring R] [NonUnitalNonAssocSemiring A]
233 [Module R A] (e : m ≃ n) :
234 reindexAlgEquiv R A e = reindexLinearEquiv R A e e :=
235 rfl
theorem reindexAlgEquiv_refl : reindexAlgEquiv R A (Equiv.refl m) = AlgEquiv.ref
251 rfl
theorem reindexAlgEquiv_trans_reindexAlgEquiv changedL253–256
253@[simp]
−theorem reindexAlgEquiv_trans_reindexAlgEquiv (e : m ≃ n) (e' : n ≃ o) :
254theorem reindexAlgEquiv_trans_reindexAlgEquiv [Fintype o] (e : m ≃ n) (e' : n ≃ o) :
255 .trans (reindexAlgEquiv R A e) (reindexAlgEquiv R A e') = reindexAlgEquiv R A (.trans e e') :=
256 rfl
end Algebra
265section StarAlgebra
−variable [Semiring R] [Fintype n] [Fintype m] [Fintype o] [NonUnitalNonAssocSemiring A] [Module R A]
− [Star A]
267variable [Fintype n] [Fintype m] [Fintype o] [AddCommMonoid A] [Mul A] [SMul R A] [Star A]
def reindexStarAlgEquiv changedL269–276
269/-- For square matrices with coefficients in a (non-unital, non-associative) semiring `A` with a
270star operation and an `R`-module structure, the natural map that reindexes a matrix's rows and
271columns with equivalent types, `Matrix.reindex`, is an equivalence of ⋆-algebras. -/
272def reindexStarAlgEquiv (e : m ≃ n) : Matrix m m A ≃⋆ₐ[R] Matrix n n A where
− __ := reindexRingEquiv A e
− __ := reindexLinearEquiv R A e e
273 __ := reindexAlgEquiv R A e
274 map_star' _ := rfl
276@[simp]
theorem reindexStarAlgEquiv_trans_reindexStarAlgEquiv (e : m ≃ n) (e' : n ≃
311end StarAlgebra
theorem toAlgEquiv_reindexStarAlgEquiv changedL313–317
313@[simp]
−theorem toAlgEquiv_reindexStarAlgEquiv [CommSemiring R] [Fintype m] [Fintype n] [Semiring A]
− [Algebra R A] [Star A] (e : m ≃ n) :
314theorem toAlgEquiv_reindexStarAlgEquiv [Semiring R] [Fintype m] [Fintype n]
315 [NonUnitalNonAssocSemiring A] [Module R A] [Star A] (e : m ≃ n) :
316 (reindexStarAlgEquiv R A e).toAlgEquiv = reindexAlgEquiv R A e :=
317 rfl

Mathlib/LinearAlgebra/Matrix/Unique.lean +1 −1

def uniqueRingEquiv [NonUnitalNonAssocSemiring A] : Matrix m m A ≃+* A where
def uniqueAlgEquiv changedL58–62
58/-- `M₁(A)` is equivalent to `A` as an `R`-algebra. -/
59@[simps!]
−def uniqueAlgEquiv [Semiring A] [CommSemiring R] [Algebra R A] : Matrix m m A ≃ₐ[R] A where
60def uniqueAlgEquiv [NonUnitalNonAssocSemiring A] [SMul R A] : Matrix m m A ≃ₐ[R] A where
61 __ := uniqueRingEquiv
62 map_smul' r := by aesop
0/39 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.