Skip to content

Commit 355b074

Browse files
committed
suggestions
1 parent 39b2d08 commit 355b074

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

Mathlib/Analysis/Matrix/Order.lean

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,9 @@ attribute [aesop 20% apply (rule_sets := [CStarAlgebra])] PosSemidef.nonneg
4444
/-- The partial order on matrices given by `A ≤ B := (B - A).PosSemidef`. -/
4545
abbrev instPartialOrder : PartialOrder (Matrix n n 𝕜) where
4646
le_antisymm A B h₁ h₂ := by
47-
have foo := neg_nonneg.mp <| trace_neg (A - B) ▸ neg_sub A B ▸ h₁.trace_nonneg
48-
have : (A - B).trace = 0 := le_antisymm foo h₂.trace_nonneg
49-
classical
50-
simp_rw [h₂.isHermitian.trace_eq_sum_eigenvalues, ← RCLike.ofReal_sum,
51-
RCLike.ofReal_eq_zero, Finset.sum_eq_zero_iff_of_nonneg (s := Finset.univ)
52-
(by simpa using h₂.eigenvalues_nonneg), Finset.mem_univ, true_imp_iff] at this
53-
exact sub_eq_zero.mp <| funext_iff.eq ▸ h₂.isHermitian.eigenvalues_eq_zero_iff.mp <| this
47+
rw [← sub_eq_zero, ← h₂.trace_eq_zero_iff]
48+
have := neg_nonneg.mp <| trace_neg (A - B) ▸ neg_sub A B ▸ h₁.trace_nonneg
49+
exact le_antisymm this h₂.trace_nonneg
5450

5551
scoped[MatrixOrder] attribute [instance] Matrix.instPartialOrder
5652

@@ -110,11 +106,11 @@ lemma sq_sqrt : (CFC.sqrt A) ^ 2 = A := CFC.sq_sqrt A
110106
@[deprecated CFC.sqrt_mul_sqrt_self (since := "2025-09-22")]
111107
lemma sqrt_mul_self : CFC.sqrt A * CFC.sqrt A = A := CFC.sqrt_mul_sqrt_self A
112108

113-
lemma eq_of_sq_eq_sq {B : Matrix n n 𝕜} (hB : PosSemidef B) (hAB : A ^ 2 = B ^ 2) : A = B :=
114-
CFC.sqrt_sq A ▸ CFC.sqrt_unique (sq B ▸ hAB.symm)
115-
109+
@[deprecated CFC.sq_eq_sq_iff (since := "2025-09-24")]
116110
lemma sq_eq_sq_iff {B : Matrix n n 𝕜} (hB : PosSemidef B) : A ^ 2 = B ^ 2 ↔ A = B :=
117-
⟨eq_of_sq_eq_sq hA hB, fun h => h ▸ rfl⟩
111+
CFC.sq_eq_sq_iff A B
112+
113+
@[deprecated (since := "2025-09-24")] alias ⟨eq_of_sq_eq_sq, _⟩ := CFC.sq_eq_sq_iff
118114

119115
@[deprecated CFC.sqrt_sq (since := "2025-09-22")]
120116
lemma sqrt_sq : CFC.sqrt (A ^ 2) = A := CFC.sqrt_sq A

Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/Basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ lemma sqrt_eq_iff (a b : A) (ha : 0 ≤ a := by cfc_tac) (hb : 0 ≤ b := by cfc
277277
lemma sqrt_eq_zero_iff (a : A) (ha : 0 ≤ a := by cfc_tac) : sqrt a = 0 ↔ a = 0 := by
278278
rw [sqrt_eq_iff a _, mul_zero, eq_comm]
279279

280+
lemma mul_self_eq_mul_self_iff (a b : A) (ha : 0 ≤ a := by cfc_tac) (hb : 0 ≤ b := by cfc_tac) :
281+
a * a = b * b ↔ a = b :=
282+
fun h => sqrt_mul_self a ▸ sqrt_unique h.symm, fun h => h ▸ rfl⟩
283+
280284
/-- Note that the hypothesis `0 ≤ a` is necessary because the continuous functional calculi over
281285
`ℝ≥0` (for the left-hand side) and `ℝ` (for the right-hand side) use different predicates (i.e.,
282286
`(0 ≤ ·)` versus `IsSelfAdjoint`). Consequently, if `a` is selfadjoint but not nonnegative, then
@@ -596,6 +600,10 @@ lemma sqrt_sq (a : A) (ha : 0 ≤ a := by cfc_tac) : sqrt (a ^ 2) = a := by
596600
lemma sq_sqrt (a : A) (ha : 0 ≤ a := by cfc_tac) : (sqrt a) ^ 2 = a := by
597601
rw [pow_two, sqrt_mul_sqrt_self (A := A) a]
598602

603+
lemma sq_eq_sq_iff (a b : A) (ha : 0 ≤ a := by cfc_tac) (hb : 0 ≤ b := by cfc_tac) :
604+
a ^ 2 = b ^ 2 ↔ a = b := by
605+
simp_rw [sq, mul_self_eq_mul_self_iff a b]
606+
599607
@[simp]
600608
lemma sqrt_algebraMap {r : ℝ≥0} : sqrt (algebraMap ℝ≥0 A r) = algebraMap ℝ≥0 A (NNReal.sqrt r) := by
601609
rw [sqrt_eq_cfc, cfc_algebraMap]

Mathlib/LinearAlgebra/Matrix/PosDef.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ lemma IsHermitian.posSemidef_iff_eigenvalues_nonneg [DecidableEq n] {A : Matrix
239239
@[deprecated (since := "2025-08-17")] alias ⟨_, IsHermitian.posSemidef_of_eigenvalues_nonneg⟩ :=
240240
IsHermitian.posSemidef_iff_eigenvalues_nonneg
241241

242+
theorem PosSemidef.trace_eq_zero_iff {A : Matrix n n 𝕜} (hA : A.PosSemidef) :
243+
A.trace = 0 ↔ A = 0 := by
244+
refine ⟨fun h => ?_, fun h => h ▸ trace_zero n 𝕜⟩
245+
classical
246+
simp_rw [hA.isHermitian.trace_eq_sum_eigenvalues, ← RCLike.ofReal_sum,
247+
RCLike.ofReal_eq_zero, Finset.sum_eq_zero_iff_of_nonneg (s := Finset.univ)
248+
(by simpa using hA.eigenvalues_nonneg), Finset.mem_univ, true_imp_iff] at h
249+
exact funext_iff.eq ▸ hA.isHermitian.eigenvalues_eq_zero_iff.mp <| h
250+
242251
/-!
243252
## Positive definite matrices
244253
-/

0 commit comments

Comments
 (0)