Skip to content

Commit ff68c4b

Browse files
committed
chore(LinearAlgebra/Matrix/PosDef): rename Matrix.InnerProductSpace.ofMatrix (#30928)
- Renames `Matrix.NormedAddCommGroup.ofMatrix` to `Matrix.toNormedAddCommGroup` - Removes `Matrix.InnerProductSpace.ofMatrix` and adds `Matrix.toInnerProductSpace` instead. - Removes `Matrix.PosDef.matrixInnerProductSpace` and adds `Matrix.toMatrixInnerProductSpace` instead. - Defines `Matrix.toSeminormedAddCommGroup` and `Matrix.toMatrixSeminormedAddCommGroup`.
1 parent bcdf2b7 commit ff68c4b

File tree

4 files changed

+78
-46
lines changed

4 files changed

+78
-46
lines changed

Mathlib/Analysis/Matrix/LDL.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ variable {S : Matrix n n 𝕜} [Fintype n] (hS : S.PosDef)
4747
applying Gram-Schmidt-Orthogonalization w.r.t. the inner product induced by `Sᵀ` on the standard
4848
basis vectors `Pi.basisFun`. -/
4949
noncomputable def LDL.lowerInv : Matrix n n 𝕜 :=
50-
@gramSchmidt 𝕜 (n → 𝕜) _ (_ :) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
51-
(Pi.basisFun 𝕜 n)
50+
@gramSchmidt 𝕜 (n → 𝕜) _ (Sᵀ.toNormedAddCommGroup hS.transpose)
51+
(Sᵀ.toInnerProductSpace hS.transpose.posSemidef) n _ _ _ (Pi.basisFun 𝕜 n)
5252

5353
theorem LDL.lowerInv_eq_gramSchmidtBasis :
5454
LDL.lowerInv hS =
5555
((Pi.basisFun 𝕜 n).toMatrix
56-
(@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ :) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
57-
(Pi.basisFun 𝕜 n)))ᵀ := by
58-
letI := NormedAddCommGroup.ofMatrix hS.transpose
59-
letI := InnerProductSpace.ofMatrix hS.transpose
56+
(@gramSchmidtBasis 𝕜 (n → 𝕜) _ (Sᵀ.toNormedAddCommGroup hS.transpose)
57+
(Sᵀ.toInnerProductSpace hS.transpose.posSemidef) n _ _ _ (Pi.basisFun 𝕜 n)))ᵀ := by
58+
letI := (Sᵀ.toNormedAddCommGroup hS.transpose)
59+
letI := (Sᵀ.toInnerProductSpace hS.transpose.posSemidef)
6060
ext i j
6161
rw [LDL.lowerInv, Basis.coePiBasisFun.toMatrix_eq_transpose, coe_gramSchmidtBasis]
6262
rfl
@@ -65,13 +65,14 @@ noncomputable instance LDL.invertibleLowerInv : Invertible (LDL.lowerInv hS) :=
6565
rw [LDL.lowerInv_eq_gramSchmidtBasis]
6666
haveI :=
6767
Basis.invertibleToMatrix (Pi.basisFun 𝕜 n)
68-
(@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ :) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
69-
(Pi.basisFun 𝕜 n))
68+
(@gramSchmidtBasis 𝕜 (n → 𝕜) _ (Sᵀ.toNormedAddCommGroup hS.transpose)
69+
(Sᵀ.toInnerProductSpace hS.transpose.posSemidef) n _ _ _ (Pi.basisFun 𝕜 n))
7070
infer_instance
7171

7272
theorem LDL.lowerInv_orthogonal {i j : n} (h₀ : i ≠ j) :
7373
⟪LDL.lowerInv hS i, Sᵀ *ᵥ LDL.lowerInv hS j⟫ₑ = 0 :=
74-
@gramSchmidt_orthogonal 𝕜 _ _ (_ :) (InnerProductSpace.ofMatrix hS.transpose) _ _ _ _ _ _ _ h₀
74+
@gramSchmidt_orthogonal 𝕜 _ _ (Sᵀ.toNormedAddCommGroup hS.transpose)
75+
(Sᵀ.toInnerProductSpace hS.transpose.posSemidef) _ _ _ _ _ _ _ h₀
7576

7677
/-- The entries of the diagonal matrix `D` of the LDL decomposition. -/
7778
noncomputable def LDL.diagEntries : n → 𝕜 := fun i =>
@@ -82,9 +83,8 @@ noncomputable def LDL.diag : Matrix n n 𝕜 :=
8283
Matrix.diagonal (LDL.diagEntries hS)
8384

8485
theorem LDL.lowerInv_triangular {i j : n} (hij : i < j) : LDL.lowerInv hS i j = 0 := by
85-
rw [←
86-
@gramSchmidt_triangular 𝕜 (n → 𝕜) _ (_ :) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
87-
i j hij (Pi.basisFun 𝕜 n),
86+
rw [← @gramSchmidt_triangular 𝕜 (n → 𝕜) _ (Sᵀ.toNormedAddCommGroup hS.transpose)
87+
(Sᵀ.toInnerProductSpace hS.transpose.posSemidef) n _ _ _ i j hij (Pi.basisFun 𝕜 n),
8888
Pi.basisFun_repr, LDL.lowerInv]
8989

9090
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix

Mathlib/Analysis/Matrix/Order.lean

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ This allows us to use more general results from C⋆-algebras, like `CFC.sqrt`.
1919
* `Matrix.instPartialOrder`: the partial order on matrices given by `x ≤ y := (y - x).PosSemidef`.
2020
* `Matrix.PosSemidef.dotProduct_mulVec_zero_iff`: for a positive semi-definite matrix `A`,
2121
we have `x⋆ A x = 0` iff `A x = 0`.
22-
* `Matrix.PosDef.matrixInnerProductSpace`: the inner product on matrices induced by a
23-
positive definite matrix `M`: `⟪x, y⟫ = (y * M * xᴴ).trace`.
22+
* `Matrix.toMatrixInnerProductSpace`: the inner product on matrices induced by a
23+
positive semi-definite matrix `M`: `⟪x, y⟫ = (y * M * xᴴ).trace`.
2424
2525
## Implementation notes
2626
@@ -263,34 +263,52 @@ lemma posDef_iff_eq_conjTranspose_mul_self [DecidableEq n] {A : Matrix n n 𝕜}
263263
@[deprecated (since := "2025-08-07")] alias PosDef.posDef_iff_eq_conjTranspose_mul_self :=
264264
CStarAlgebra.isStrictlyPositive_iff_eq_star_mul_self
265265

266+
/-- The pre-inner product space structure implementation. Only an auxiliary for
267+
`Matrix.toMatrixSeminormedAddCommGroup`, `Matrix.toMatrixNormedAddCommGroup`,
268+
and `Matrix.toMatrixInnerProductSpace`. -/
269+
private abbrev PosSemidef.matrixPreInnerProductSpace {M : Matrix n n 𝕜} (hM : M.PosSemidef) :
270+
PreInnerProductSpace.Core 𝕜 (Matrix n n 𝕜) where
271+
inner x y := (y * M * xᴴ).trace
272+
conj_inner_symm _ _ := by
273+
simp only [mul_assoc, starRingEnd_apply, ← trace_conjTranspose, conjTranspose_mul,
274+
conjTranspose_conjTranspose, hM.isHermitian.eq]
275+
re_inner_nonneg x := RCLike.nonneg_iff.mp (hM.mul_mul_conjTranspose_same x).trace_nonneg |>.1
276+
add_left := by simp [mul_add]
277+
smul_left := by simp
278+
279+
/-- A positive definite matrix `M` induces a norm on `Matrix n n 𝕜`
280+
`‖x‖ = sqrt (x * M * xᴴ).trace`. -/
281+
noncomputable def toMatrixSeminormedAddCommGroup (M : Matrix n n 𝕜) (hM : M.PosSemidef) :
282+
SeminormedAddCommGroup (Matrix n n 𝕜) :=
283+
@InnerProductSpace.Core.toSeminormedAddCommGroup _ _ _ _ _ hM.matrixPreInnerProductSpace
284+
266285
/-- A positive definite matrix `M` induces a norm on `Matrix n n 𝕜`:
267286
`‖x‖ = sqrt (x * M * xᴴ).trace`. -/
268-
noncomputable def PosDef.matrixNormedAddCommGroup {M : Matrix n n 𝕜} (hM : M.PosDef) :
287+
noncomputable def toMatrixNormedAddCommGroup (M : Matrix n n 𝕜) (hM : M.PosDef) :
269288
NormedAddCommGroup (Matrix n n 𝕜) :=
270289
letI : InnerProductSpace.Core 𝕜 (Matrix n n 𝕜) :=
271-
{ inner x y := (y * M * xᴴ).trace
272-
conj_inner_symm _ _ := by
273-
simp only [mul_assoc, starRingEnd_apply, ← trace_conjTranspose, conjTranspose_mul,
274-
conjTranspose_conjTranspose, hM.isHermitian.eq]
275-
re_inner_nonneg x := RCLike.nonneg_iff.mp
276-
(hM.posSemidef.mul_mul_conjTranspose_same x).trace_nonneg |>.1
277-
add_left := by simp [mul_add]
278-
smul_left := by simp
290+
{ __ := hM.posSemidef.matrixPreInnerProductSpace
279291
definite x hx := by
280292
classical
281293
obtain ⟨y, hy, rfl⟩ := CStarAlgebra.isStrictlyPositive_iff_eq_star_mul_self.mp
282294
hM.isStrictlyPositive
295+
simp only at hx
283296
rw [← mul_assoc, ← conjTranspose_conjTranspose x, star_eq_conjTranspose, ← conjTranspose_mul,
284297
conjTranspose_conjTranspose, mul_assoc, trace_conjTranspose_mul_self_eq_zero_iff] at hx
285298
lift y to (Matrix n n 𝕜)ˣ using hy
286299
simpa [← mul_assoc] using congr(y⁻¹ * $hx) }
287300
this.toNormedAddCommGroup
288301

289-
/-- A positive definite matrix `M` induces an inner product on `Matrix n n 𝕜`:
302+
/-- A positive semi-definite matrix `M` induces an inner product on `Matrix n n 𝕜`:
290303
`⟪x, y⟫ = (y * M * xᴴ).trace`. -/
291-
def PosDef.matrixInnerProductSpace {M : Matrix n n 𝕜} (hM : M.PosDef) :
292-
letI : NormedAddCommGroup (Matrix n n 𝕜) := hM.matrixNormedAddCommGroup
304+
def toMatrixInnerProductSpace (M : Matrix n n 𝕜) (hM : M.PosSemidef) :
305+
letI : SeminormedAddCommGroup (Matrix n n 𝕜) := M.toMatrixSeminormedAddCommGroup hM
293306
InnerProductSpace 𝕜 (Matrix n n 𝕜) :=
294307
InnerProductSpace.ofCore _
295308

309+
@[deprecated (since := "2025-11-18")] alias PosDef.matrixNormedAddCommGroup :=
310+
toMatrixNormedAddCommGroup
311+
@[deprecated (since := "2025-11-12")] alias PosDef.matrixInnerProductSpace :=
312+
toMatrixInnerProductSpace
313+
296314
end Matrix

Mathlib/Analysis/Matrix/PosDef.lean

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ This file proves that eigenvalues of positive (semi)definite matrices are (nonne
1313
1414
## Main definitions
1515
16-
* `InnerProductSpace.ofMatrix`: the inner product on `n → 𝕜` induced by a positive definite
17-
matrix `A`, and is given by `⟪x, y⟫ = xᴴMy`.
16+
* `Matrix.toInnerProductSpace`: the pre-inner product space on `n → 𝕜` induced by a
17+
positive semi-definite matrix `M`, and is given by `⟪x, y⟫ = xᴴMy`.
1818
1919
-/
2020

@@ -89,23 +89,39 @@ lemma det_pos [DecidableEq n] (hA : A.PosDef) : 0 < det A := by
8989

9090
end PosDef
9191

92-
/-- A positive definite matrix `A` induces a norm `‖x‖ = sqrt (re xᴴMx)`. -/
93-
noncomputable abbrev NormedAddCommGroup.ofMatrix (hA : A.PosDef) : NormedAddCommGroup (n → 𝕜) :=
92+
/-- The pre-inner product space structure implementation. Only an auxiliary for
93+
`Matrix.toSeminormedAddCommGroup`, `Matrix.toNormedAddCommGroup`,
94+
and `Matrix.toInnerProductSpace`. -/
95+
private def PosSemidef.preInnerProductSpace {M : Matrix n n 𝕜} (hM : M.PosSemidef) :
96+
PreInnerProductSpace.Core 𝕜 (n → 𝕜) where
97+
inner x y := (M *ᵥ y) ⬝ᵥ star x
98+
conj_inner_symm x y := by
99+
rw [dotProduct_comm, star_dotProduct, starRingEnd_apply, star_star,
100+
star_mulVec, dotProduct_comm (M *ᵥ y), dotProduct_mulVec, hM.isHermitian.eq]
101+
re_inner_nonneg x := dotProduct_comm _ (star x) ▸ hM.re_dotProduct_nonneg x
102+
add_left := by simp only [star_add, dotProduct_add, forall_const]
103+
smul_left _ _ _ := by rw [← smul_eq_mul, ← dotProduct_smul, starRingEnd_apply, ← star_smul]
104+
105+
/-- A positive semi-definite matrix `M` induces a norm `‖x‖ = sqrt (re xᴴMx)`. -/
106+
noncomputable abbrev toSeminormedAddCommGroup (M : Matrix n n 𝕜) (hM : M.PosSemidef) :
107+
SeminormedAddCommGroup (n → 𝕜) :=
108+
@InnerProductSpace.Core.toSeminormedAddCommGroup _ _ _ _ _ hM.preInnerProductSpace
109+
110+
/-- A positive definite matrix `M` induces a norm `‖x‖ = sqrt (re xᴴMx)`. -/
111+
noncomputable abbrev toNormedAddCommGroup (M : Matrix n n 𝕜) (hM : M.PosDef) :
112+
NormedAddCommGroup (n → 𝕜) :=
94113
@InnerProductSpace.Core.toNormedAddCommGroup _ _ _ _ _
95-
{ inner x y := (A *ᵥ y) ⬝ᵥ star x
96-
conj_inner_symm x y := by
97-
rw [dotProduct_comm, star_dotProduct, starRingEnd_apply, star_star,
98-
star_mulVec, dotProduct_comm (A *ᵥ y), dotProduct_mulVec, hA.isHermitian.eq]
99-
re_inner_nonneg x := dotProduct_comm _ (star x) ▸ hA.posSemidef.re_dotProduct_nonneg x
100-
definite x (hx : _ ⬝ᵥ _ = 0) := by
101-
by_contra! h
102-
simpa [hx, lt_irrefl, dotProduct_comm] using hA.re_dotProduct_pos h
103-
add_left := by simp only [star_add, dotProduct_add, forall_const]
104-
smul_left _ _ _ := by rw [← smul_eq_mul, ← dotProduct_smul, starRingEnd_apply, ← star_smul] }
105-
106-
/-- A positive definite matrix `A` induces an inner product `⟪x, y⟫ = xᴴMy`. -/
107-
def InnerProductSpace.ofMatrix (hA : A.PosDef) :
108-
@InnerProductSpace 𝕜 (n → 𝕜) _ (NormedAddCommGroup.ofMatrix hA).toSeminormedAddCommGroup :=
114+
{ __ := hM.posSemidef.preInnerProductSpace
115+
definite x (hx : _ ⬝ᵥ _ = 0) := by
116+
by_contra! h
117+
simpa [hx, lt_irrefl, dotProduct_comm] using hM.re_dotProduct_pos h }
118+
119+
/-- A positive semi-definite matrix `M` induces an inner product `⟪x, y⟫ = xᴴMy`. -/
120+
def toInnerProductSpace (M : Matrix n n 𝕜) (hM : M.PosSemidef) :
121+
@InnerProductSpace 𝕜 (n → 𝕜) _ (M.toSeminormedAddCommGroup hM) :=
109122
InnerProductSpace.ofCore _
110123

124+
@[deprecated (since := "2025-10-26")] alias NormedAddCommGroup.ofMatrix := toNormedAddCommGroup
125+
@[deprecated (since := "2025-10-26")] alias InnerProductSpace.ofMatrix := toInnerProductSpace
126+
111127
end Matrix

Mathlib/LinearAlgebra/Matrix/PosDef.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ order on matrices on `ℝ` or `ℂ`.
2424
and `xᴴMx` is nonnegative for all `x`.
2525
* `Matrix.PosDef` : a matrix `M : Matrix n n R` is positive definite if it is Hermitian and `xᴴMx`
2626
is greater than zero for all nonzero `x`.
27-
* `Matrix.InnerProductSpace.ofMatrix`: the inner product on `n → 𝕜` induced by a positive definite
28-
matrix `M`, and is given by `⟪x, y⟫ = xᴴMy`.
2927
3028
## Main results
3129

0 commit comments

Comments
 (0)