Skip to content

Commit 0a8db06

Browse files
committed
refactor: unapply matrix lemmas (#21091)
These are slightly more convenient expressed in terms of vector operations. `ext; simp` can always be used to restore them to the applied versions.
1 parent d7b266a commit 0a8db06

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

β€ŽMathlib/Data/Matrix/Mul.leanβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,12 @@ theorem mulVec_smul [Fintype n] [Monoid R] [NonUnitalNonAssocSemiring S] [Distri
722722

723723
@[simp]
724724
theorem mulVec_single [Fintype n] [DecidableEq n] [NonUnitalNonAssocSemiring R] (M : Matrix m n R)
725-
(j : n) (x : R) : M *α΅₯ Pi.single j x = fun i => M i j * x :=
725+
(j : n) (x : R) : M *α΅₯ Pi.single j x = MulOpposite.op x β€’ Mα΅€ j :=
726726
funext fun _ => dotProduct_single _ _ _
727727

728728
@[simp]
729729
theorem single_vecMul [Fintype m] [DecidableEq m] [NonUnitalNonAssocSemiring R] (M : Matrix m n R)
730-
(i : m) (x : R) : Pi.single i x α΅₯* M = fun j => x * M i j :=
730+
(i : m) (x : R) : Pi.single i x α΅₯* M = x β€’ M i :=
731731
funext fun _ => single_dotProduct _ _ _
732732

733733
theorem mulVec_single_one [Fintype n] [DecidableEq n] [NonAssocSemiring R]
@@ -736,7 +736,7 @@ theorem mulVec_single_one [Fintype n] [DecidableEq n] [NonAssocSemiring R]
736736

737737
theorem single_one_vecMul [Fintype m] [DecidableEq m] [NonAssocSemiring R]
738738
(i : m) (M : Matrix m n R) :
739-
Pi.single i 1 α΅₯* M = M i := by simp
739+
Pi.single i 1 α΅₯* M = M i := by ext; simp
740740

741741
theorem diagonal_mulVec_single [Fintype n] [DecidableEq n] [NonUnitalNonAssocSemiring R] (v : n β†’ R)
742742
(j : n) (x : R) : diagonal v *α΅₯ Pi.single j x = Pi.single j (v j * x) := by
@@ -781,12 +781,14 @@ section NonAssocSemiring
781781

782782
variable [NonAssocSemiring Ξ±]
783783

784-
theorem mulVec_one [Fintype n] (A : Matrix m n Ξ±) : A *α΅₯ 1 = fun i => βˆ‘ j, A i j := by
784+
theorem mulVec_one [Fintype n] (A : Matrix m n Ξ±) : A *α΅₯ 1 = βˆ‘ j, Aα΅€ j := by
785785
ext; simp [mulVec, dotProduct]
786786

787-
theorem vec_one_mul [Fintype m] (A : Matrix m n Ξ±) : 1 α΅₯* A = fun j => βˆ‘ i, A i j := by
787+
theorem one_vecMul [Fintype m] (A : Matrix m n Ξ±) : 1 α΅₯* A = βˆ‘ i, A i := by
788788
ext; simp [vecMul, dotProduct]
789789

790+
@[deprecated (since := "2025-01-26")] alias vec_one_mul := one_vecMul
791+
790792
variable [Fintype m] [Fintype n] [DecidableEq m]
791793

792794
@[simp]

β€ŽMathlib/LinearAlgebra/Matrix/Charpoly/LinearMap.leanβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ theorem PiToModule.fromMatrix_apply [DecidableEq ΞΉ] (A : Matrix ΞΉ ΞΉ R) (w :
3939
theorem PiToModule.fromMatrix_apply_single_one [DecidableEq ΞΉ] (A : Matrix ΞΉ ΞΉ R) (j : ΞΉ) :
4040
PiToModule.fromMatrix R b A (Pi.single j 1) = βˆ‘ i : ΞΉ, A i j β€’ b i := by
4141
rw [PiToModule.fromMatrix_apply, Fintype.linearCombination_apply, Matrix.mulVec_single]
42-
simp_rw [mul_one]
42+
simp_rw [MulOpposite.op_one, one_smul, transpose_apply]
4343

4444
/-- The endomorphisms of `M` acts on `(ΞΉ β†’ R) β†’β‚—[R] M`, and takes the projection
4545
to a `(ΞΉ β†’ R) β†’β‚—[R] M`. -/

β€ŽMathlib/LinearAlgebra/Matrix/Hermitian.leanβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n
279279
Β· intro h
280280
ext i j
281281
simpa only [(Pi.single_star i 1).symm, ← star_mulVec, mul_one, dotProduct_single,
282-
single_vecMul, star_one, one_mul] using h (Pi.single i 1) (Pi.single j 1)
282+
single_one_vecMul, star_one] using h (Pi.single i 1) (Pi.single j 1)
283283

284284
end RCLike
285285

β€ŽMathlib/LinearAlgebra/Matrix/PosDef.leanβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ theorem _root_.Matrix.posDef_diagonal_iff
363363
PosDef (diagonal d) ↔ βˆ€ i, 0 < d i := by
364364
refine ⟨fun h i => ?_, .diagonal⟩
365365
have := h.2 (Pi.single i 1)
366-
simp only [mulVec_single, mul_one, dotProduct_diagonal', Pi.star_apply, Pi.single_eq_same,
367-
star_one, one_mul, Function.ne_iff, Pi.zero_apply] at this
366+
simp_rw [mulVec_single_one, ← Pi.single_star, star_one, single_dotProduct, one_mul,
367+
transpose_apply, diagonal_apply_eq, Function.ne_iff] at this
368368
exact this ⟨i, by simp⟩
369369

370370
protected theorem one [StarOrderedRing R] [DecidableEq n] [NoZeroDivisors R] :

β€ŽMathlib/LinearAlgebra/Matrix/Spectrum.leanβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,19 @@ lemma eigenvectorUnitary_coe {π•œ : Type*} [RCLike π•œ] {n : Type*} [Fintype n
7474
(EuclideanSpace.basisFun n π•œ).toBasis.toMatrix (hA.eigenvectorBasis).toBasis :=
7575
rfl
7676

77+
@[simp]
78+
theorem eigenvectorUnitary_transpose_apply (j : n) :
79+
(eigenvectorUnitary hA)α΅€ j = ⇑(hA.eigenvectorBasis j) :=
80+
rfl
81+
7782
@[simp]
7883
theorem eigenvectorUnitary_apply (i j : n) :
7984
eigenvectorUnitary hA i j = ⇑(hA.eigenvectorBasis j) i :=
8085
rfl
8186

8287
theorem eigenvectorUnitary_mulVec (j : n) :
8388
eigenvectorUnitary hA *α΅₯ Pi.single j 1 = ⇑(hA.eigenvectorBasis j) := by
84-
simp only [mulVec_single, eigenvectorUnitary_apply, mul_one]
89+
simp_rw [mulVec_single_one, eigenvectorUnitary_transpose_apply]
8590

8691
theorem star_eigenvectorUnitary_mulVec (j : n) :
8792
(star (eigenvectorUnitary hA : Matrix n n π•œ)) *α΅₯ ⇑(hA.eigenvectorBasis j) = Pi.single j 1 := by

β€ŽMathlib/LinearAlgebra/Matrix/ToLin.leanβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ variable [Fintype n]
249249
@[simp]
250250
theorem Matrix.mulVecLin_one [DecidableEq n] :
251251
Matrix.mulVecLin (1 : Matrix n n R) = LinearMap.id := by
252-
ext; simp [Matrix.one_apply, Pi.single_apply]
252+
ext; simp [Matrix.one_apply, Pi.single_apply, eq_comm]
253253

254254
@[simp]
255255
theorem Matrix.mulVecLin_mul [Fintype m] (M : Matrix l m R) (N : Matrix m n R) :

0 commit comments

Comments
Β (0)