Offline · exact source
Exact Lean source

InfiniteHilbertSchmidt

formalization/Cloning/InfiniteHilbertSchmidt.lean

Source hash: bb28ecf75e2de8cb35d60c195b539456da8c1a1d71abfb336ae04001d1ecedf4

Full source copied without mathematical changes from the snapshot whose input hash matches the passing audit. Select a line number for a stable source pointer.

The declarations belong to the compiled inventory covered by the project’s shared axiom audit. That audit records an aggregate union, without attributing axioms to individual declarations.

Declarations in this module
definition Cloning.InfiniteTraceClass.HilbertSchmidt.IsHilbertSchmidttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.hasSum_norm_sq_apply_eq_adjointtheorem Cloning.InfiniteTraceClass.HilbertSchmidt.summable_norm_sq_adjoint_of_summable_norm_sqtheorem Cloning.InfiniteTraceClass.HilbertSchmidt.hasSum_norm_sq_apply_of_basistheorem Cloning.InfiniteTraceClass.HilbertSchmidt.summable_norm_sq_apply_of_hilbertBasistheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_zerotheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_smultheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_addtheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_subtheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_startheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_mul_left_of_opNorm_le_onetheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_mul_right_of_opNorm_le_onetheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_mul_lefttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isHilbertSchmidt_mul_righttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isTraceClass_star_mul_self_of_isHilbertSchmidttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.isTraceClass_mul_star_of_isHilbertSchmidttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.holder_two_twotheorem Cloning.InfiniteTraceClass.HilbertSchmidt.tsum_mul_le_sqrt_mul_sqrttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.summable_norm_mul_of_square_sumstheorem Cloning.InfiniteTraceClass.HilbertSchmidt.tsum_norm_inner_mul_inner_letheorem Cloning.InfiniteTraceClass.HilbertSchmidt.summable_norm_inner_mul_innertheorem Cloning.InfiniteTraceClass.HilbertSchmidt.summable_diagonal_of_hilbertSchmidttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.summable_matrix_of_hilbertSchmidttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.hasSum_matrix_row_of_hilbertSchmidttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.hasSum_matrix_col_of_hilbertSchmidttheorem Cloning.InfiniteTraceClass.HilbertSchmidt.tsum_diagonal_mul_eq_tsum_diagonal_swaptheorem Cloning.InfiniteTraceClass.HilbertSchmidt.tsum_norm_sq_mul_right_le_of_opNorm_le_onetheorem Cloning.InfiniteTraceClass.HilbertSchmidt.tsum_norm_sq_mul_right_le_of_selfAdjoint
1/-
2Copyright (c) 2026 Tom Ole Diem. All rights reserved.
3Released under Apache 2.0 license as described in PHYSLIB-LICENSE.txt.
4Authors: Tom Ole Diem
5 
6Adapted from Physlib commit f6e446ca99fd83b3a60743a61900cb2acb98f531,
7PhyslibAlpha/ProbabilisticTheory/HilbertSpace/TraceClass/HilbertSchmidt.lean.
8Upstream blob: fbf85edbc753977f3160ccf4d03be194bb636c40.
9Compatibility: Uses the older Holder theorem result pair, qualified map application lemmas, and explicit real exponents.
10-/
11 
12import Cloning.InfiniteTraceClass
13import Mathlib.Analysis.MeanInequalities
14 
15/-!
16 
17# Hilbert–Schmidt operators
18 
19## i. Overview
20 
21A bounded operator `S` is Hilbert–Schmidt when `∑ᵢ ‖S eᵢ‖²` converges for a Hilbert basis `{eᵢ}`.
22Hilbert–Schmidt operators form a two-sided ideal closed under the adjoint, `S⋆S` is trace class for
23Hilbert–Schmidt `S`, and a product of two Hilbert–Schmidt operators has an absolutely summable
24diagonal in every basis, with the diagonal sum symmetric in the two factors.
25 
26## ii. Key results
27 
28- `IsHilbertSchmidt` : a bounded operator is Hilbert–Schmidt.
29- `isHilbertSchmidt_add`, `isHilbertSchmidt_star` : closure under sums and adjoints.
30- `isHilbertSchmidt_mul_left`, `isHilbertSchmidt_mul_right` : the ideal property.
31- `isTraceClass_star_mul_self_of_isHilbertSchmidt` : `S⋆S` is trace class.
32- `summable_diagonal_of_hilbertSchmidt` : the diagonal of a product of two Hilbert–Schmidt operators
33  is absolutely summable.
34- `tsum_diagonal_mul_eq_tsum_diagonal_swap` : the diagonal sums of `R S` and `S R` agree.
35 
36## iii. Table of contents
37 
38- A. Elementary algebraic closure
39- B. Cauchy–Schwarz estimates on Hilbert–Schmidt diagonals
40- C. Quantitative right-multiplication estimate
41 
42-/
43 
44namespace Cloning.InfiniteTraceClass.HilbertSchmidt
45 
46set_option backward.isDefEq.respectTransparency false
47 
48noncomputable section
49 
50open scoped ComplexOrder InnerProductSpace
51 
52variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H]
53 
54 
55/-- A bounded operator is Hilbert–Schmidt when its squared norm sum is summable in one Hilbert
56basis. The basis-independence theorem below shows this existential definition is equivalent to
57using any basis. -/
58def IsHilbertSchmidt (S : H →L[ℂ] H) : Prop :=
59  ∃ (w : Set H) (b : HilbertBasis w ℂ H), Summable (fun i : w => ‖S (b i)‖ ^ 2)
60 
61/-- The Hilbert–Schmidt square sum of `S` in one basis equals the square sum of `S⋆` in a second
62basis. This is the nonnegative double-sum identity; the usual basis-independence statement follows
63by applying it twice. -/
64lemma hasSum_norm_sq_apply_eq_adjoint {S : H →L[ℂ] H}
65    {w w' : Set H} (b : HilbertBasis w ℂ H) (c : HilbertBasis w' ℂ H)
66    (hb : Summable (fun i : w => ‖S (b i)‖ ^ 2)) :
67    HasSum (fun j : w' => ‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2)
68      (∑' i : w, ‖S (b i)‖ ^ 2) := by
69  classical
70  set F : w → w' → ℝ := fun i j => ‖⟪c j, S (b i)⟫_ℂ‖ ^ 2 with hFdef
71  have hFnonneg : 0 ≤ Function.uncurry F := fun _ => sq_nonneg _
72  have hrow : ∀ i : w, HasSum (F i) (‖S (b i)‖ ^ 2) := fun i =>
73    hasSum_norm_sq_inner_basis c (S (b i))
74  have hcol : ∀ j : w', HasSum (fun i : w => F i j)
75      (‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2) := by
76    intro j
77    have e1 : ∀ i : w, ⟪c j, S (b i)⟫_ℂ =
78        ⟪(ContinuousLinearMap.adjoint S) (c j), b i⟫_ℂ := fun i =>
79      (ContinuousLinearMap.adjoint_inner_left S (b i) (c j)).symm
80    have key : (fun i : w => F i j) = fun i : w =>
81        ‖⟪b i, (ContinuousLinearMap.adjoint S) (c j)⟫_ℂ‖ ^ 2 := by
82      funext i
83      show ‖⟪c j, S (b i)⟫_ℂ‖ ^ 2 = _
84      rw [e1 i, ← inner_conj_symm (b i) ((ContinuousLinearMap.adjoint S) (c j)),
85        RCLike.norm_conj]
86    rw [key]
87    exact hasSum_norm_sq_inner_basis b ((ContinuousLinearMap.adjoint S) (c j))
88  have hjoint : Summable (Function.uncurry F) := by
89    rw [summable_prod_of_nonneg hFnonneg]
90    refine ⟨fun i => (hrow i).summable, ?_⟩
91    have heq : (fun i : w => ∑' j : w', F i j) = fun i : w => ‖S (b i)‖ ^ 2 :=
92      funext fun i => (hrow i).tsum_eq
93    show Summable fun i : w => ∑' j : w', F i j
94    rwa [heq]
95  have hswap := hjoint.tsum_comm' (fun i => (hrow i).summable) (fun j => (hcol j).summable)
96  have hLHS : ∑' j : w', ∑' i : w, F i j = ∑' j : w', ‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2 :=
97    tsum_congr fun j => (hcol j).tsum_eq
98  have hRHS : ∑' i : w, ∑' j : w', F i j = ∑' i : w, ‖S (b i)‖ ^ 2 :=
99    tsum_congr fun i => (hrow i).tsum_eq
100  have hEq : ∑' j : w', ‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2 = ∑' i : w, ‖S (b i)‖ ^ 2 := by
101    rw [← hLHS, ← hRHS]; exact hswap
102  set G : w' → w → ℝ := fun j i => F i j with hGdef
103  have hGnonneg : 0 ≤ Function.uncurry G := fun _ => sq_nonneg _
104  have hjointG : Summable (Function.uncurry G) := by
105    have hcomp : Function.uncurry G = Function.uncurry F ∘ (Equiv.prodComm w' w) := by
106      funext p; simp [Function.uncurry, hGdef, Equiv.prodComm]
107    rw [hcomp]
108    exact (Equiv.prodComm w' w).summable_iff.mpr hjoint
109  have hcolSummable : Summable
110      (fun j : w' => ‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2) := by
111    have hpair := (summable_prod_of_nonneg hGnonneg).mp hjointG
112    have h2 : Summable fun j : w' => ∑' i : w, G j i := hpair.2
113    have heq2 : (fun j : w' => ∑' i : w, G j i) = fun j : w' =>
114        ‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2 :=
115      funext fun j => (hcol j).tsum_eq
116    rwa [heq2] at h2
117  rw [← hEq]
118  exact hcolSummable.hasSum
119 
120lemma summable_norm_sq_adjoint_of_summable_norm_sq {S : H →L[ℂ] H}
121    {w : Set H} (b : HilbertBasis w ℂ H)
122    (hb : Summable (fun i : w => ‖S (b i)‖ ^ 2)) :
123    Summable (fun i : w => ‖(ContinuousLinearMap.adjoint S) (b i)‖ ^ 2) :=
124  (hasSum_norm_sq_apply_eq_adjoint b b hb).summable
125 
126lemma hasSum_norm_sq_apply_of_basis {S : H →L[ℂ] H} {w w' : Set H}
127    (b : HilbertBasis w ℂ H) (c : HilbertBasis w' ℂ H)
128    (hb : Summable (fun i : w => ‖S (b i)‖ ^ 2)) :
129    HasSum (fun j : w' => ‖S (c j)‖ ^ 2) (∑' i : w, ‖S (b i)‖ ^ 2) := by
130  have hfirst := hasSum_norm_sq_apply_eq_adjoint b c hb
131  have hstarc : Summable (fun j : w' => ‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2) :=
132    hfirst.summable
133  have hsecond := hasSum_norm_sq_apply_eq_adjoint (S := ContinuousLinearMap.adjoint S) c c hstarc
134  have hsecond' : HasSum (fun j : w' => ‖S (c j)‖ ^ 2)
135      (∑' j : w', ‖(ContinuousLinearMap.adjoint S) (c j)‖ ^ 2) := by
136    simpa only [ContinuousLinearMap.adjoint_adjoint] using hsecond
137  rw [← hfirst.tsum_eq]
138  exact hsecond'
139 
140lemma summable_norm_sq_apply_of_hilbertBasis {S : H →L[ℂ] H}
141    (w : Set H) (b : HilbertBasis w ℂ H) (hS : IsHilbertSchmidt S) :
142    Summable (fun i : w => ‖S (b i)‖ ^ 2) := by
143  rcases hS with ⟨w₀, b₀, hb₀⟩
144  exact (hasSum_norm_sq_apply_of_basis b₀ b hb₀).summable
145 
146/-! ## A. Elementary algebraic closure -/
147 
148lemma isHilbertSchmidt_zero : IsHilbertSchmidt (0 : H →L[ℂ] H) := by
149  obtain ⟨w, b, _⟩ := exists_hilbertBasis ℂ H
150  refine ⟨w, b, ?_⟩
151  simp
152 
153omit [CompleteSpace H] in
154lemma isHilbertSchmidt_smul {S : H →L[ℂ] H} (c : ℂ) (hS : IsHilbertSchmidt S) :
155    IsHilbertSchmidt (c • S) := by
156  rcases hS with ⟨w, b, hb⟩
157  refine ⟨w, b, ?_⟩
158  have hmul := hb.mul_left (‖c‖ ^ 2)
159  apply hmul.congr
160  intro i
161  rw [ContinuousLinearMap.smul_apply, norm_smul]
162  ring
163 
164lemma isHilbertSchmidt_add {R S : H →L[ℂ] H}
165    (hR : IsHilbertSchmidt R) (hS : IsHilbertSchmidt S) :
166    IsHilbertSchmidt (R + S) := by
167  rcases hR with ⟨w, b, hbR⟩
168  have hSb : Summable (fun i : w => ‖S (b i)‖ ^ 2) := summable_norm_sq_apply_of_hilbertBasis w b hS
169  refine ⟨w, b, ?_⟩
170  apply Summable.of_nonneg_of_le (fun i => sq_nonneg _)
171  · intro i
172    have hnorm : ‖R (b i) + S (b i)‖ ≤ ‖R (b i)‖ + ‖S (b i)‖ := norm_add_le _ _
173    have hsq : ‖R (b i) + S (b i)‖ ^ 2 ≤ (‖R (b i)‖ + ‖S (b i)‖) ^ 2 :=
174      (sq_le_sq₀ (norm_nonneg _) (add_nonneg (norm_nonneg _) (norm_nonneg _))).2 hnorm
175    calc
176      ‖(R + S) (b i)‖ ^ 2 = ‖R (b i) + S (b i)‖ ^ 2 := by rfl
177      _ ≤ (‖R (b i)‖ + ‖S (b i)‖) ^ 2 := hsq
178      _ ≤ 2 * ‖R (b i)‖ ^ 2 + 2 * ‖S (b i)‖ ^ 2 := by
179        nlinarith [sq_nonneg (‖R (b i)‖ - ‖S (b i)‖)]
180  · exact (hbR.mul_left 2).add (hSb.mul_left 2)
181 
182lemma isHilbertSchmidt_sub {R S : H →L[ℂ] H}
183    (hR : IsHilbertSchmidt R) (hS : IsHilbertSchmidt S) :
184    IsHilbertSchmidt (R - S) := by
185  simpa [sub_eq_add_neg] using isHilbertSchmidt_add hR (isHilbertSchmidt_smul (-1 : ℂ) hS)
186 
187lemma isHilbertSchmidt_star {S : H →L[ℂ] H} (hS : IsHilbertSchmidt S) :
188    IsHilbertSchmidt (star S) := by
189  rcases hS with ⟨w, b, hb⟩
190  refine ⟨w, b, ?_⟩
191  rw [ContinuousLinearMap.star_eq_adjoint]
192  exact summable_norm_sq_adjoint_of_summable_norm_sq b hb
193 
194omit [CompleteSpace H] in
195lemma isHilbertSchmidt_mul_left_of_opNorm_le_one {U S : H →L[ℂ] H}
196    (hU : ‖U‖ ≤ 1) (hS : IsHilbertSchmidt S) :
197    IsHilbertSchmidt (U * S) := by
198  rcases hS with ⟨w, b, hb⟩
199  refine ⟨w, b, ?_⟩
200  apply Summable.of_nonneg_of_le (fun i => sq_nonneg _) (fun i => ?_) hb
201  have hi : ‖U (S (b i))‖ ≤ ‖S (b i)‖ := by
202    calc
203      ‖U (S (b i))‖ ≤ ‖U‖ * ‖S (b i)‖ := U.le_opNorm _
204      _ ≤ ‖S (b i)‖ := by
205        simpa only [one_mul] using mul_le_mul_of_nonneg_right hU (norm_nonneg (S (b i)))
206  exact (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).2 hi
207 
208lemma isHilbertSchmidt_mul_right_of_opNorm_le_one {S U : H →L[ℂ] H}
209    (hU : ‖U‖ ≤ 1) (hS : IsHilbertSchmidt S) :
210    IsHilbertSchmidt (S * U) := by
211  have hU' : ‖star U‖ ≤ 1 := by simpa using hU
212  have hleft : IsHilbertSchmidt (star U * star S) :=
213    isHilbertSchmidt_mul_left_of_opNorm_le_one hU' (isHilbertSchmidt_star hS)
214  have hdouble : IsHilbertSchmidt (star (star U * star S)) := isHilbertSchmidt_star hleft
215  simpa only [star_mul, star_star] using hdouble
216 
217lemma isHilbertSchmidt_mul_left {U S : H →L[ℂ] H} (hS : IsHilbertSchmidt S) :
218    IsHilbertSchmidt (U * S) := by
219  by_cases hU0 : ‖U‖ = 0
220  · have hzero : U = 0 := norm_eq_zero.mp hU0
221    simpa [hzero] using isHilbertSchmidt_zero (H := H)
222  · let V : H →L[ℂ] H := (‖U‖ : ℂ)⁻¹ • U
223    have hV : ‖V‖ ≤ 1 := by dsimp [V]; simp [norm_smul, norm_inv, hU0]
224    have hVS : IsHilbertSchmidt (V * S) := isHilbertSchmidt_mul_left_of_opNorm_le_one hV hS
225    have hscaled : IsHilbertSchmidt ((‖U‖ : ℂ) • (V * S)) := isHilbertSchmidt_smul (‖U‖ : ℂ) hVS
226    have hVeq : (‖U‖ : ℂ) • V = U := by ext x; simp [V, hU0]
227    rw [show (‖U‖ : ℂ) • (V * S) = ((‖U‖ : ℂ) • V) * S by simp] at hscaled
228    rwa [hVeq] at hscaled
229 
230lemma isHilbertSchmidt_mul_right {S U : H →L[ℂ] H} (hS : IsHilbertSchmidt S) :
231    IsHilbertSchmidt (S * U) := by
232  have hleft : IsHilbertSchmidt (star U * star S) :=
233    isHilbertSchmidt_mul_left (U := star U) (isHilbertSchmidt_star hS)
234  have hdouble : IsHilbertSchmidt (star (star U * star S)) := isHilbertSchmidt_star hleft
235  simpa only [star_mul, star_star] using hdouble
236 
237/-- `S⋆S` is trace class whenever `S` is Hilbert–Schmidt. -/
238lemma isTraceClass_star_mul_self_of_isHilbertSchmidt {S : H →L[ℂ] H}
239    (hS : IsHilbertSchmidt S) : IsTraceClass (star S * S) := by
240  apply isTraceClass_iff.mpr
241  intro w b
242  have hdiag : Summable (fun i : w => ‖S (b i)‖ ^ 2) :=
243    summable_norm_sq_apply_of_hilbertBasis w b hS
244  have hpos : 0 ≤ star S * S := star_mul_self_nonneg S
245  have habs : CFC.abs (star S * S) = star S * S := CFC.abs_of_nonneg _ hpos
246  apply hdiag.congr
247  intro i
248  rw [habs]
249  have hinner : ⟪b i, (star S * S) (b i)⟫_ℂ = ⟪S (b i), S (b i)⟫_ℂ := by
250    rw [ContinuousLinearMap.star_eq_adjoint, ContinuousLinearMap.mul_def,
251      ContinuousLinearMap.comp_apply, ContinuousLinearMap.adjoint_inner_right]
252  rw [hinner, inner_self_eq_norm_sq_to_K]
253  norm_cast
254 
255/-- `S S⋆` is trace class whenever `S` is Hilbert–Schmidt. -/
256lemma isTraceClass_mul_star_of_isHilbertSchmidt {S : H →L[ℂ] H}
257    (hS : IsHilbertSchmidt S) : IsTraceClass (S * star S) := by
258  have hstar : IsHilbertSchmidt (star S) := isHilbertSchmidt_star hS
259  simpa only [star_star] using isTraceClass_star_mul_self_of_isHilbertSchmidt hstar
260 
261/-! ## B. Cauchy–Schwarz estimates on Hilbert–Schmidt diagonals -/
262 
263lemma holder_two_two : (2 : ℝ).HolderConjugate 2 := by
264  rw [Real.holderConjugate_iff]; constructor <;> norm_num
265 
266omit [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] in
267/-- The real `ℓ²` Cauchy–Schwarz estimate, in the tsum form needed for operator diagonal bounds. -/
268lemma tsum_mul_le_sqrt_mul_sqrt {w : Set H} {f g : w → ℝ}
269    (hf : Summable (fun i => f i ^ 2)) (hg : Summable (fun i => g i ^ 2))
270    (hf_nonneg : ∀ i, 0 ≤ f i) (hg_nonneg : ∀ i, 0 ≤ g i) :
271    ∑' i : w, f i * g i ≤ Real.sqrt (∑' i : w, f i ^ 2) * Real.sqrt (∑' i : w, g i ^ 2) := by
272  have h := Real.inner_le_Lp_mul_Lq_tsum_of_nonneg (f := f) (g := g) holder_two_two
273    hf_nonneg hg_nonneg (by convert hf using 1; ext i; norm_num [Real.rpow_natCast])
274    (by convert hg using 1; ext i; norm_num [Real.rpow_natCast])
275  have hf_eq : (∑' i : w, f i ^ (2 : ℝ)) = ∑' i : w, f i ^ 2 :=
276    tsum_congr fun i => Real.rpow_natCast (f i) 2
277  have hg_eq : (∑' i : w, g i ^ (2 : ℝ)) = ∑' i : w, g i ^ 2 :=
278    tsum_congr fun i => Real.rpow_natCast (g i) 2
279  rw [hf_eq, hg_eq] at h
280  rw [← Real.sqrt_eq_rpow, ← Real.sqrt_eq_rpow] at h
281  simpa only [Real.rpow_natCast] using h.2
282 
283omit [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] in
284lemma summable_norm_mul_of_square_sums {w : Set H}
285    (f g : w → ℝ) (hf : Summable (fun i => f i ^ 2)) (hg : Summable (fun i => g i ^ 2))
286    (hf_nonneg : ∀ i, 0 ≤ f i) (hg_nonneg : ∀ i, 0 ≤ g i) :
287    Summable (fun i => f i * g i) := by
288  apply Real.summable_mul_of_Lp_Lq_of_nonneg holder_two_two hf_nonneg hg_nonneg
289  · convert hf using 1; ext i; norm_num [Real.rpow_natCast]
290  · convert hg using 1; ext i; norm_num [Real.rpow_natCast]
291 
292omit [CompleteSpace H] in
293lemma tsum_norm_inner_mul_inner_le {w : Set H} (b : HilbertBasis w ℂ H) (x y : H) :
294    ∑' i : w, ‖⟪x, b i⟫_ℂ‖ * ‖⟪b i, y⟫_ℂ‖ ≤ ‖x‖ * ‖y‖ := by
295  have hx : HasSum (fun i : w => ‖⟪x, b i⟫_ℂ‖ ^ 2) (‖x‖ ^ 2) := by
296    convert hasSum_norm_sq_inner_basis b x using 1
297    funext i
298    rw [← inner_conj_symm x (b i), RCLike.norm_conj]
299  have hy : HasSum (fun i : w => ‖⟪b i, y⟫_ℂ‖ ^ 2) (‖y‖ ^ 2) := hasSum_norm_sq_inner_basis b y
300  have h := Real.inner_le_Lp_mul_Lq_tsum_of_nonneg
301    (f := fun i : w => ‖⟪x, b i⟫_ℂ‖) (g := fun i : w => ‖⟪b i, y⟫_ℂ‖) holder_two_two
302    (fun i => norm_nonneg _) (fun i => norm_nonneg _)
303    (by convert hx.summable using 1; ext i; norm_num [Real.rpow_natCast])
304    (by convert hy.summable using 1; ext i; norm_num [Real.rpow_natCast])
305  have hxs : (∑' i : w, ‖⟪x, b i⟫_ℂ‖ ^ (2 : ℝ)) = ‖x‖ ^ 2 := by
306    convert hx.tsum_eq using 1
307    exact tsum_congr fun i => Real.rpow_natCast ‖⟪x, b i⟫_ℂ‖ 2
308  have hys : (∑' i : w, ‖⟪b i, y⟫_ℂ‖ ^ (2 : ℝ)) = ‖y‖ ^ 2 := by
309    convert hy.tsum_eq using 1
310    exact tsum_congr fun i => Real.rpow_natCast ‖⟪b i, y⟫_ℂ‖ 2
311  calc
312    ∑' i : w, ‖⟪x, b i⟫_ℂ‖ * ‖⟪b i, y⟫_ℂ‖ ≤
313        (∑' i : w, ‖⟪x, b i⟫_ℂ‖ ^ (2 : ℝ)) ^ (1 / (2 : ℝ)) *
314          (∑' i : w, ‖⟪b i, y⟫_ℂ‖ ^ (2 : ℝ)) ^ (1 / (2 : ℝ)) :=
315      h.2
316    _ = ‖x‖ * ‖y‖ := by
317      rw [hxs, hys, ← Real.sqrt_eq_rpow, ← Real.sqrt_eq_rpow, Real.sqrt_sq (norm_nonneg _),
318        Real.sqrt_sq (norm_nonneg _)]
319 
320omit [CompleteSpace H] in
321lemma summable_norm_inner_mul_inner {w : Set H} (b : HilbertBasis w ℂ H) (x y : H) :
322    Summable (fun i : w => ‖⟪x, b i⟫_ℂ‖ * ‖⟪b i, y⟫_ℂ‖) := by
323  apply Real.summable_mul_of_Lp_Lq_of_nonneg holder_two_two
324    (fun i => norm_nonneg _) (fun i => norm_nonneg _)
325  · have hx := (hasSum_norm_sq_inner_basis b x).summable
326    convert hx using 1
327    funext i
328    rw [← inner_conj_symm x (b i), RCLike.norm_conj]
329    exact Real.rpow_natCast ‖⟪b i, x⟫_ℂ‖ 2
330  · have hy := (hasSum_norm_sq_inner_basis b y).summable
331    convert hy using 1; ext i; norm_num [Real.rpow_natCast]
332 
333/-- The diagonal coefficients of a product of two Hilbert–Schmidt operators are absolutely
334summable. -/
335lemma summable_diagonal_of_hilbertSchmidt {R S : H →L[ℂ] H}
336    {w : Set H} (b : HilbertBasis w ℂ H) (hR : IsHilbertSchmidt R) (hS : IsHilbertSchmidt S) :
337    Summable (fun i : w => ⟪b i, (R * S) (b i)⟫_ℂ) := by
338  have hRstar : IsHilbertSchmidt (ContinuousLinearMap.adjoint R) := by
339    rcases hR with ⟨w₀, b₀, hb₀⟩
340    exact ⟨w₀, b₀, summable_norm_sq_adjoint_of_summable_norm_sq b₀ hb₀⟩
341  have hRb : Summable (fun i : w => ‖(ContinuousLinearMap.adjoint R) (b i)‖ ^ 2) :=
342    summable_norm_sq_apply_of_hilbertBasis w b hRstar
343  have hSb : Summable (fun i : w => ‖S (b i)‖ ^ 2) := summable_norm_sq_apply_of_hilbertBasis w b hS
344  have hprod : Summable (fun i : w =>
345      ‖(ContinuousLinearMap.adjoint R) (b i)‖ * ‖S (b i)‖) :=
346    summable_norm_mul_of_square_sums _ _ hRb hSb (fun i => norm_nonneg _) (fun i => norm_nonneg _)
347  apply Summable.of_norm_bounded hprod
348  intro i
349  have hi : ⟪b i, (R * S) (b i)⟫_ℂ = ⟪(ContinuousLinearMap.adjoint R) (b i), S (b i)⟫_ℂ :=
350    (ContinuousLinearMap.adjoint_inner_left R (S (b i)) (b i)).symm
351  rw [hi]
352  simpa only [ContinuousLinearMap.mul_apply] using
353    norm_inner_le_norm ((ContinuousLinearMap.adjoint R) (b i)) (S (b i))
354 
355lemma summable_matrix_of_hilbertSchmidt {R S : H →L[ℂ] H}
356    {w w' : Set H} (b : HilbertBasis w ℂ H) (c : HilbertBasis w' ℂ H)
357    (hR : IsHilbertSchmidt R) (hS : IsHilbertSchmidt S) :
358    Summable (Function.uncurry (fun (i : w) (j : w') =>
359      ⟪(ContinuousLinearMap.adjoint R) (b i), c j⟫_ℂ * ⟪c j, S (b i)⟫_ℂ)) := by
360  have hRstar : IsHilbertSchmidt (ContinuousLinearMap.adjoint R) := by
361    rcases hR with ⟨w₀, b₀, hb₀⟩
362    exact ⟨w₀, b₀, summable_norm_sq_adjoint_of_summable_norm_sq b₀ hb₀⟩
363  have hRb : Summable (fun i : w => ‖(ContinuousLinearMap.adjoint R) (b i)‖ ^ 2) :=
364    summable_norm_sq_apply_of_hilbertBasis w b hRstar
365  have hSb : Summable (fun i : w => ‖S (b i)‖ ^ 2) := summable_norm_sq_apply_of_hilbertBasis w b hS
366  have hprod : Summable (fun i : w =>
367      ‖(ContinuousLinearMap.adjoint R) (b i)‖ * ‖S (b i)‖) :=
368    summable_norm_mul_of_square_sums _ _ hRb hSb (fun i => norm_nonneg _) (fun i => norm_nonneg _)
369  let F : w → w' → ℂ := fun i j => ⟪(ContinuousLinearMap.adjoint R) (b i), c j⟫_ℂ * ⟪c j, S (b i)⟫_ℂ
370  let M : w → w' → ℝ := fun i j => ‖F i j‖
371  have hMrow : ∀ i : w, Summable (M i) := by
372    intro i
373    have h := summable_norm_inner_mul_inner c ((ContinuousLinearMap.adjoint R) (b i)) (S (b i))
374    simpa [M, F, norm_mul] using h
375  have hMrow_bound : ∀ i : w, ∑' j : w', M i j ≤
376      ‖(ContinuousLinearMap.adjoint R) (b i)‖ * ‖S (b i)‖ := by
377    intro i
378    simpa [M, F, norm_mul] using
379      tsum_norm_inner_mul_inner_le c ((ContinuousLinearMap.adjoint R) (b i)) (S (b i))
380  have hMrows : Summable (fun i : w => ∑' j : w', M i j) :=
381    Summable.of_nonneg_of_le (fun i => tsum_nonneg fun j => norm_nonneg _) hMrow_bound hprod
382  have hMnonneg : 0 ≤ Function.uncurry M := fun _ => norm_nonneg _
383  have hM : Summable (Function.uncurry M) := by
384    rw [summable_prod_of_nonneg hMnonneg]; exact ⟨hMrow, hMrows⟩
385  apply Summable.of_norm_bounded hM
386  rintro ⟨i, j⟩
387  exact le_rfl
388 
389lemma hasSum_matrix_row_of_hilbertSchmidt {R S : H →L[ℂ] H}
390    {w w' : Set H} (b : HilbertBasis w ℂ H) (c : HilbertBasis w' ℂ H) (i : w) :
391    HasSum (fun j : w' => ⟪(ContinuousLinearMap.adjoint R) (b i), c j⟫_ℂ * ⟪c j, S (b i)⟫_ℂ)
392      ⟪b i, (R * S) (b i)⟫_ℂ := by
393  have h := c.hasSum_inner_mul_inner ((ContinuousLinearMap.adjoint R) (b i)) (S (b i))
394  have hi : ⟪(ContinuousLinearMap.adjoint R) (b i), S (b i)⟫_ℂ = ⟪b i, (R * S) (b i)⟫_ℂ :=
395    ContinuousLinearMap.adjoint_inner_left R (S (b i)) (b i)
396  rwa [hi] at h
397 
398lemma hasSum_matrix_col_of_hilbertSchmidt {R S : H →L[ℂ] H}
399    {w w' : Set H} (b : HilbertBasis w ℂ H) (c : HilbertBasis w' ℂ H) (j : w') :
400    HasSum (fun i : w => ⟪(ContinuousLinearMap.adjoint R) (b i), c j⟫_ℂ * ⟪c j, S (b i)⟫_ℂ)
401      ⟪c j, (S * R) (c j)⟫_ℂ := by
402  have h := b.hasSum_inner_mul_inner ((ContinuousLinearMap.adjoint S) (c j)) (R (c j))
403  have hR : ∀ i : w, ⟪(ContinuousLinearMap.adjoint R) (b i), c j⟫_ℂ = ⟪b i, R (c j)⟫_ℂ := fun i =>
404    ContinuousLinearMap.adjoint_inner_left R (c j) (b i)
405  have hS : ∀ i : w, ⟪c j, S (b i)⟫_ℂ = ⟪(ContinuousLinearMap.adjoint S) (c j), b i⟫_ℂ := fun i =>
406    (ContinuousLinearMap.adjoint_inner_left S (b i) (c j)).symm
407  have hpoint : (fun i : w => ⟪(ContinuousLinearMap.adjoint R) (b i), c j⟫_ℂ * ⟪c j, S (b i)⟫_ℂ) =
408      (fun i : w => ⟪(ContinuousLinearMap.adjoint S) (c j), b i⟫_ℂ * ⟪b i, R (c j)⟫_ℂ) := by
409    funext i; rw [hR i, hS i, mul_comm]
410  have hSR : ⟪(ContinuousLinearMap.adjoint S) (c j), R (c j)⟫_ℂ = ⟪c j, (S * R) (c j)⟫_ℂ :=
411    ContinuousLinearMap.adjoint_inner_left S (R (c j)) (c j)
412  rw [hpoint, ← hSR]
413  exact h
414 
415/-- For Hilbert–Schmidt `R` and `S`, the diagonal sum of `R S` in one basis equals the diagonal sum
416of `S R` in any other. -/
417lemma tsum_diagonal_mul_eq_tsum_diagonal_swap {R S : H →L[ℂ] H}
418    {w w' : Set H} (b : HilbertBasis w ℂ H) (c : HilbertBasis w' ℂ H)
419    (hR : IsHilbertSchmidt R) (hS : IsHilbertSchmidt S) :
420    (∑' i : w, ⟪b i, (R * S) (b i)⟫_ℂ) = ∑' j : w', ⟪c j, (S * R) (c j)⟫_ℂ := by
421  let F : w → w' → ℂ := fun i j => ⟪(ContinuousLinearMap.adjoint R) (b i), c j⟫_ℂ * ⟪c j, S (b i)⟫_ℂ
422  have hF : Summable (Function.uncurry F) := summable_matrix_of_hilbertSchmidt b c hR hS
423  have hrow : ∀ i : w, HasSum (F i) ⟪b i, (R * S) (b i)⟫_ℂ := fun i =>
424    hasSum_matrix_row_of_hilbertSchmidt b c i
425  have hcol : ∀ j : w', HasSum (fun i : w => F i j) ⟪c j, (S * R) (c j)⟫_ℂ := fun j =>
426    hasSum_matrix_col_of_hilbertSchmidt b c j
427  have hswap := hF.tsum_comm' (fun i => (hrow i).summable) (fun j => (hcol j).summable)
428  calc
429    ∑' i : w, ⟪b i, (R * S) (b i)⟫_ℂ = ∑' i : w, ∑' j : w', F i j :=
430      tsum_congr fun i => (hrow i).tsum_eq.symm
431    _ = ∑' j : w', ∑' i : w, F i j := hswap.symm
432    _ = ∑' j : w', ⟪c j, (S * R) (c j)⟫_ℂ := tsum_congr fun j => (hcol j).tsum_eq
433 
434/-! ## C. Quantitative right-multiplication estimate -/
435 
436/-- **Quantitative right-multiplication-by-a-contraction bound**: for `X` and a contraction `W`,
437the Hilbert–Schmidt square sum of `X * W` never exceeds that of `X` itself, in the same basis. -/
438lemma tsum_norm_sq_mul_right_le_of_opNorm_le_one {X W : H →L[ℂ] H} (hW : ‖W‖ ≤ 1)
439    (hX : IsHilbertSchmidt X) {w : Set H} (b : HilbertBasis w ℂ H) :
440    (∑' i : w, ‖(X * W) (b i)‖ ^ 2) ≤ ∑' i : w, ‖X (b i)‖ ^ 2 := by
441  have hXW : IsHilbertSchmidt (X * W) := isHilbertSchmidt_mul_right hX
442  have hXstar : IsHilbertSchmidt (ContinuousLinearMap.adjoint X) := by
443    rcases hX with ⟨w₀, b₀, hb₀⟩
444    exact ⟨w₀, b₀, summable_norm_sq_adjoint_of_summable_norm_sq b₀ hb₀⟩
445  have hXWb : Summable (fun i : w => ‖(X * W) (b i)‖ ^ 2) :=
446    summable_norm_sq_apply_of_hilbertBasis w b hXW
447  have hXb : Summable (fun i : w => ‖X (b i)‖ ^ 2) := summable_norm_sq_apply_of_hilbertBasis w b hX
448  have hstep1 : (∑' i : w, ‖(X * W) (b i)‖ ^ 2) =
449      ∑' i : w, ‖(ContinuousLinearMap.adjoint (X * W)) (b i)‖ ^ 2 :=
450    (hasSum_norm_sq_apply_eq_adjoint b b hXWb).tsum_eq.symm
451  have hadj : ContinuousLinearMap.adjoint (X * W) =
452      ContinuousLinearMap.adjoint W * ContinuousLinearMap.adjoint X := by
453    show ContinuousLinearMap.adjoint (X ∘L W) = _
454    rw [ContinuousLinearMap.adjoint_comp]; rfl
455  have hstep2 : ∀ i : w,
456      ‖(ContinuousLinearMap.adjoint W * ContinuousLinearMap.adjoint X) (b i)‖ ≤
457        ‖(ContinuousLinearMap.adjoint X) (b i)‖ := by
458    intro i
459    calc
460      ‖(ContinuousLinearMap.adjoint W * ContinuousLinearMap.adjoint X) (b i)‖ =
461          ‖(ContinuousLinearMap.adjoint W) ((ContinuousLinearMap.adjoint X) (b i))‖ := by
462        rw [ContinuousLinearMap.mul_def, ContinuousLinearMap.comp_apply]
463      _ ≤ ‖ContinuousLinearMap.adjoint W‖ * ‖(ContinuousLinearMap.adjoint X) (b i)‖ :=
464        ContinuousLinearMap.le_opNorm _ _
465      _ ≤ ‖(ContinuousLinearMap.adjoint X) (b i)‖ := by
466        have hWadj : ‖ContinuousLinearMap.adjoint W‖ ≤ 1 := by
467          rw [(ContinuousLinearMap.adjoint).norm_map W]; exact hW
468        calc ‖ContinuousLinearMap.adjoint W‖ * ‖(ContinuousLinearMap.adjoint X) (b i)‖ ≤
469            1 * ‖(ContinuousLinearMap.adjoint X) (b i)‖ :=
470              mul_le_mul_of_nonneg_right hWadj (norm_nonneg _)
471          _ = ‖(ContinuousLinearMap.adjoint X) (b i)‖ := one_mul _
472  have hXstarb : Summable (fun i : w => ‖(ContinuousLinearMap.adjoint X) (b i)‖ ^ 2) :=
473    summable_norm_sq_apply_of_hilbertBasis w b hXstar
474  have hcompareSummable : Summable (fun i : w =>
475      ‖(ContinuousLinearMap.adjoint W * ContinuousLinearMap.adjoint X) (b i)‖ ^ 2) :=
476    Summable.of_nonneg_of_le (fun i => sq_nonneg _)
477      (fun i => (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).2 (hstep2 i)) hXstarb
478  have hcompare : (∑' i : w, ‖(ContinuousLinearMap.adjoint W * ContinuousLinearMap.adjoint X)
479      (b i)‖ ^ 2) ≤ ∑' i : w, ‖(ContinuousLinearMap.adjoint X) (b i)‖ ^ 2 :=
480    hcompareSummable.tsum_le_tsum
481      (fun i => (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).2 (hstep2 i)) hXstarb
482  have hstep3 : (∑' i : w, ‖(ContinuousLinearMap.adjoint X) (b i)‖ ^ 2) = ∑' i : w, ‖X (b i)‖ ^ 2 :=
483    (hasSum_norm_sq_apply_eq_adjoint b b hXb).tsum_eq
484  calc
485    (∑' i : w, ‖(X * W) (b i)‖ ^ 2) =
486        ∑' i : w, ‖(ContinuousLinearMap.adjoint (X * W)) (b i)‖ ^ 2 := hstep1
487    _ = ∑' i : w, ‖(ContinuousLinearMap.adjoint W * ContinuousLinearMap.adjoint X) (b i)‖ ^ 2 := by
488      rw [hadj]
489    _ ≤ ∑' i : w, ‖(ContinuousLinearMap.adjoint X) (b i)‖ ^ 2 := hcompare
490    _ = ∑' i : w, ‖X (b i)‖ ^ 2 := hstep3
491 
492/-- Right multiplication by a self-adjoint contraction does not increase the Hilbert–Schmidt sum. -/
493lemma tsum_norm_sq_mul_right_le_of_selfAdjoint {S A : H →L[ℂ] H}
494    (hSself : IsSelfAdjoint S) (hS : IsHilbertSchmidt S)
495    {w w' : Set H} (b : HilbertBasis w ℂ H) (c : HilbertBasis w' ℂ H) :
496    (∑' i : w', ‖(S * A) (c i)‖ ^ 2) ≤ ‖A‖ ^ 2 * (∑' j : w, ‖S (b j)‖ ^ 2) := by
497  let R : H →L[ℂ] H := S * A
498  have hR : IsHilbertSchmidt R := isHilbertSchmidt_mul_right hS
499  have hRc : Summable (fun i : w' => ‖R (c i)‖ ^ 2) :=
500    summable_norm_sq_apply_of_hilbertBasis w' c hR
501  have hEq : HasSum (fun j : w => ‖(ContinuousLinearMap.adjoint R) (b j)‖ ^ 2)
502      (∑' i : w', ‖R (c i)‖ ^ 2) := hasSum_norm_sq_apply_eq_adjoint c b hRc
503  have hAdjSummable : Summable (fun j : w => ‖(ContinuousLinearMap.adjoint R) (b j)‖ ^ 2) :=
504    hEq.summable
505  have hSb : Summable (fun j : w => ‖S (b j)‖ ^ 2) := summable_norm_sq_apply_of_hilbertBasis w b hS
506  have hRstar : ContinuousLinearMap.adjoint R = ContinuousLinearMap.adjoint A * S := by
507    rw [show R = S ∘L A by rfl, ContinuousLinearMap.adjoint_comp]
508    rw [← ContinuousLinearMap.mul_def, (ContinuousLinearMap.star_eq_adjoint S).symm.trans hSself]
509  have hpoint : ∀ j : w, ‖(ContinuousLinearMap.adjoint R) (b j)‖ ^ 2 ≤ ‖A‖ ^ 2 * ‖S (b j)‖ ^ 2 := by
510    intro j
511    rw [hRstar, ContinuousLinearMap.mul_def, ContinuousLinearMap.comp_apply]
512    have hnorm : ‖ContinuousLinearMap.adjoint A‖ = ‖A‖ := (ContinuousLinearMap.adjoint).norm_map A
513    have hle : ‖ContinuousLinearMap.adjoint A (S (b j))‖ ≤ ‖A‖ * ‖S (b j)‖ := by
514      rw [← hnorm]; exact ContinuousLinearMap.le_opNorm _ _
515    calc
516      ‖ContinuousLinearMap.adjoint A (S (b j))‖ ^ 2 ≤ (‖A‖ * ‖S (b j)‖) ^ 2 :=
517        (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (norm_nonneg _) (norm_nonneg _))).2 hle
518      _ = ‖A‖ ^ 2 * ‖S (b j)‖ ^ 2 := by ring
519  have hscaled : Summable (fun j : w => ‖A‖ ^ 2 * ‖S (b j)‖ ^ 2) := hSb.mul_left (‖A‖ ^ 2)
520  have hsum : (∑' j : w, ‖(ContinuousLinearMap.adjoint R) (b j)‖ ^ 2) ≤
521      ∑' j : w, ‖A‖ ^ 2 * ‖S (b j)‖ ^ 2 := hAdjSummable.tsum_le_tsum hpoint hscaled
522  calc
523    ∑' i : w', ‖(S * A) (c i)‖ ^ 2 = ∑' j : w, ‖(ContinuousLinearMap.adjoint R) (b j)‖ ^ 2 :=
524      hEq.tsum_eq.symm
525    _ ≤ ∑' j : w, ‖A‖ ^ 2 * ‖S (b j)‖ ^ 2 := hsum
526    _ = ‖A‖ ^ 2 * (∑' j : w, ‖S (b j)‖ ^ 2) := tsum_mul_left
527 
528 
529end
530 
531 
532end Cloning.InfiniteTraceClass.HilbertSchmidt