File size: 18,313 Bytes
607ee45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
import OAI.RepresentationTheory.RowColumn.Dephasing
import OAI.RepresentationTheory.RowColumn.TensorFilter

namespace OAI

section
noncomputable section
open scoped BigOperators Classical MatrixOrder Matrix.Norms.L2Operator ComplexOrder
namespace RowColumn.MatrixState
variable {I J B : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]

/-- Rectangular coordinate inclusion for an actual injective index map. -/
def indexInclusion (e : J ↪ I) : Matrix I J ℂ := fun i j => if i=e j then 1 else 0

omit [Fintype J] in
lemma indexInclusion_star_mul (e : J ↪ I) : (indexInclusion e).conjTranspose * indexInclusion e=1 := by
  ext i j
  simp only [Matrix.mul_apply,Matrix.conjTranspose_apply,indexInclusion,Matrix.one_apply]
  simp only [apply_ite,star_one,star_zero]
  rw [Finset.sum_eq_single (e i)]
  · simp only [ite_true,one_mul,e.injective.eq_iff]
    split_ifs <;> rfl
  · intro b _ hb
    simp [hb]
  · simp

def extendMatrix (e : J ↪ I) (A : Matrix J J ℂ) : Matrix I I ℂ := indexInclusion e * A * (indexInclusion e).conjTranspose

omit [Fintype I] in
lemma indexInclusion_mul (e : J ↪ I) (A : Matrix J J ℂ) (i j : J) :
    (indexInclusion e * A) (e i) j = A i j := by
  simp [Matrix.mul_apply,indexInclusion,e.injective.eq_iff]

omit [Fintype I] in
lemma extendMatrix_apply (e : J ↪ I) (A : Matrix J J ℂ) (i j : J) :
    extendMatrix e A (e i) (e j)=A i j := by
  simp only [extendMatrix,Matrix.mul_apply,Matrix.conjTranspose_apply,indexInclusion,
    apply_ite,star_one,star_zero,e.injective.eq_iff]
  simp

omit [Fintype I] [DecidableEq J] in
lemma extendMatrix_eq_zero_left (e : J ↪ I) (A : Matrix J J ℂ) (i : I) (hi : i ∉ Set.range e) (j : I) :
    extendMatrix e A i j=0 := by
  have hh : ∀ k, i≠e k := by intro k he; exact hi ⟨k,he.symm⟩
  simp [extendMatrix,Matrix.mul_apply,indexInclusion,hh]

omit [Fintype I] [DecidableEq J] in
lemma extendMatrix_eq_zero_right (e : J ↪ I) (A : Matrix J J ℂ) (i : I) (j : I) (hj : j ∉ Set.range e) :
    extendMatrix e A i j=0 := by
  have hh : ∀ k, j≠e k := by intro k he; exact hj ⟨k,he.symm⟩
  simp [extendMatrix,Matrix.mul_apply,indexInclusion,Matrix.conjTranspose_apply,hh]

omit [DecidableEq J] in
lemma extendMatrix_positive (e : J ↪ I) (A : Matrix J J ℂ) (hA : A.PosSemidef) :
    (extendMatrix e A).PosSemidef := hA.mul_mul_conjTranspose_same _

lemma extendMatrix_trace (e : J ↪ I) (A : Matrix J J ℂ) :
    (extendMatrix e A).trace=A.trace := by
  rw [extendMatrix,Matrix.trace_mul_cycle,indexInclusion_star_mul,one_mul]

variable [Fintype B] [DecidableEq B]
def blockMask (b : I → B) (k : B) : Matrix I I ℂ := Matrix.diagonal (fun i => if b i=k then 1 else 0)
def pinchMatrix (b : I → B) (A : Matrix I I ℂ) : Matrix I I ℂ := ∑ k, blockMask b k * A * blockMask b k

omit [Fintype I] [Fintype B] in
lemma blockMask_hermitian (b : I → B) (k : B) : (blockMask b k).IsHermitian := by
  apply Matrix.isHermitian_diagonal_iff.mpr
  intro i
  split_ifs <;> simp

lemma pinchMatrix_apply (b : I → B) (A : Matrix I I ℂ) (i j : I) :
    pinchMatrix b A i j = if b i=b j then A i j else 0 := by
  simp only [pinchMatrix,Matrix.sum_apply,blockMask,Matrix.diagonal_mul,Matrix.mul_diagonal]
  rw [Finset.sum_eq_single (b i)]
  · simp only [ite_true,one_mul]
    by_cases h : b i=b j
    · simp [h]
    · simp [h,Ne.symm h]
  · intro k _ hk
    rw [ite_eq_right (Ne.symm hk),zero_mul,zero_mul]
  · simp

lemma pinchMatrix_positive (b : I → B) (A : Matrix I I ℂ) (hA : A.PosSemidef) :
    (pinchMatrix b A).PosSemidef := by
  apply Matrix.nonneg_iff_posSemidef.mp
  apply Finset.sum_nonneg
  intro k _
  have hh := hA.conjTranspose_mul_mul_same (blockMask b k)
  rw [(blockMask_hermitian b k).eq] at hh
  exact hh.nonneg

lemma pinchMatrix_trace (b : I → B) (A : Matrix I I ℂ) : (pinchMatrix b A).trace=A.trace := by
  unfold Matrix.trace Matrix.diag
  simp_rw [pinchMatrix_apply,ite_true]

lemma pinchMatrix_support (b : I → B) (A : Matrix I I ℂ) (i j : I) (h : b i ≠ b j) :
    pinchMatrix b A i j=0 := by rw [pinchMatrix_apply,ite_eq_right h]
end RowColumn.MatrixState

end
end


section

noncomputable section
open scoped BigOperators Classical MatrixOrder Matrix.Norms.L2Operator ComplexOrder
namespace RowColumn.MatrixState
variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]

lemma quadratic_eq_energy (A : Matrix I I ℂ) (x : I → ℂ) :
    quadratic A x = RowColumn.energy (Matrix.toEuclideanLin A) (WithLp.toLp 2 (star x)) := by
  unfold quadratic RowColumn.energy
  apply congrArg Complex.re
  simp only [PiLp.inner_apply, Matrix.toLpLin_apply, RCLike.inner_apply,
    Pi.star_apply, starRingEnd_apply, star_star, Matrix.mulVec, dotProduct]
  apply Finset.sum_congr rfl
  intro i _
  rw [Finset.sum_mul]
  apply Finset.sum_congr rfl
  intro j _
  ring

lemma posSemidef_of_quadratic (A : Matrix I I ℂ) (hA : A.IsHermitian)
    (h : ∀ x, 0 ≤ quadratic A x) : A.PosSemidef := by
  rw [← Matrix.isPositive_toEuclideanLin_iff]
  refine ⟨Matrix.isSymmetric_toEuclideanLin_iff.mpr hA, fun x => ?_⟩
  have hh := h (star (WithLp.ofLp x))
  rw [quadratic_eq_energy] at hh
  rw [inner_re_symm]
  change 0 ≤ (inner ℂ x ((Matrix.toEuclideanLin A) x)).re
  simpa only [star_star, WithLp.toLp_ofLp, RowColumn.energy] using hh

omit [DecidableEq I] in
lemma quadratic_smul (t : ℝ) (A : Matrix I I ℂ) (x : I → ℂ) :
    quadratic (t • A) x = t * quadratic A x := by
  unfold quadratic
  simp only [Matrix.smul_apply, Complex.real_smul, mul_assoc, ← Finset.mul_sum,
    Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero]

omit [DecidableEq I] in
lemma quadratic_sub (A B : Matrix I I ℂ) (x : I → ℂ) :
    quadratic (A-B) x = quadratic A x-quadratic B x := by
  simp [quadratic, sub_mul, Finset.sum_sub_distrib]

omit [DecidableEq I] in
lemma quadratic_sum {D : Type*} [Fintype D] (A : D → Matrix I I ℂ) (x : I → ℂ) :
    quadratic (∑ d, A d) x = ∑ d, quadratic (A d) x := by
  simp only [quadratic, Matrix.sum_apply, Finset.sum_mul, Complex.re_sum]
  conv_lhs => arg 2; ext i; rw [Finset.sum_comm]
  exact Finset.sum_comm

lemma le_of_quadratic_le (A B : Matrix I I ℂ) (hA : A.IsHermitian) (hB : B.IsHermitian)
    (h : ∀ x, quadratic A x ≤ quadratic B x) : A ≤ B := by
  rw [← sub_nonneg, Matrix.nonneg_iff_posSemidef]
  exact posSemidef_of_quadratic (B-A) (hB.sub hA) (fun x => by rw [quadratic_sub]; exact sub_nonneg.mpr (h x))

lemma quadratic_pinch {B : Type*} [Fintype B] [DecidableEq B]
    (b : I → B) (A : Matrix I I ℂ) (x : I → ℂ) :
    quadratic (pinchMatrix b A) x = ∑ z : B, quadratic A (fun i => if b i=z then x i else 0) := by
  simp only [quadratic, pinchMatrix_apply, Complex.re_sum]
  conv_rhs => rw [Finset.sum_comm]; arg 2; ext i; rw [Finset.sum_comm]
  apply Finset.sum_congr rfl
  intro i _
  apply Finset.sum_congr rfl
  intro j _
  rw [Finset.sum_eq_single (b i)]
  · by_cases h : b i=b j
    · simp [h]
    · simp [h, Ne.symm h]
  · intro z _ hz
    simp [Ne.symm hz]
  · simp

end RowColumn.MatrixState

namespace RowColumn.Signed
open RowColumn.MatrixState CubeShuffle.Specht
variable {S C L : Type*} [Fintype S] [DecidableEq S] [Fintype C] [DecidableEq C]
  [Fintype L] [DecidableEq L] {odd : C → Prop} [DecidablePred odd] {k : ℕ}

/-- Matrix in the actual orthonormal word basis, with no change of representation. -/
def intertwinerMatrix (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) :
    Matrix (Words (S := S) odd k) (Words (S := S) odd k) ℂ :=
  (Matrix.toEuclideanCLM (𝕜 := ℂ)).symm T.toLinearMap.toContinuousLinearMap

omit [Fintype L] [DecidableEq L] in
lemma intertwinerMatrix_apply (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (w v : Words (S := S) odd k) :
    intertwinerMatrix line T w v=T (wordVector v) w := by
  rw [← matrix_wordVector odd k (intertwinerMatrix line T) w v]
  simp only [intertwinerMatrix, StarAlgEquiv.apply_symm_apply]
  rfl

omit [Fintype L] [DecidableEq L] in
lemma intertwinerMatrix_positive (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (hT : T.toLinearMap.IsPositive) :
    (intertwinerMatrix line T).PosSemidef := by
  rw [← toEuclideanCLM_positive_iff]
  rw [intertwinerMatrix, StarAlgEquiv.apply_symm_apply,
    ← ContinuousLinearMap.isPositive_toLinearMap_iff]
  exact hT

omit [DecidableEq S] [Fintype C] [DecidableEq C] in
lemma parityPattern_eq_iff (w v : Words (S := S) odd k) :
    parityPattern w=parityPattern v ↔ ∀ i, odd (w.1 i) ↔ odd (v.1 i) := by
  simp [parityPattern, funext_iff]

omit [Fintype L] [DecidableEq L] in
lemma pinch_intertwiner_invariant (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (g : lineGroup line)
    (w v : Words (S := S) odd k) :
    pinchMatrix parityPattern (intertwinerMatrix line T) (actWord g.1 w) (actWord g.1 v) =
      pinchMatrix parityPattern (intertwinerMatrix line T) w v := by
  have hp : parityPattern (actWord g.1 w)=parityPattern (actWord g.1 v) ↔ parityPattern w=parityPattern v := by
    simp only [parityPattern_eq_iff, actWord_apply]
    constructor
    · intro h i; simpa using h (g.1 i)
    · intro h i; exact h _
  simp only [pinchMatrix_apply, hp]
  by_cases h : parityPattern w=parityPattern v
  · simp only [h, ite_true, intertwinerMatrix_apply]
    have hr := commuting_coefficient_relation line T g w v
    rw [oddPerm_parity_congr g.1 w v (parityPattern_eq_iff w v |>.mp h)] at hr
    have hs := congrArg (fun z => permSign (oddPerm g.1 v)*z) hr
    simpa only [← mul_assoc, permSign_sq, one_mul] using hs
  · simp only [h, ite_false]

omit [DecidableEq L] in
lemma intertwiner_le_pinch (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (hT : T.toLinearMap.IsPositive) :
    intertwinerMatrix line T ≤
      (((Fintype.card S+1)^(Fintype.card L*Fintype.card C^2) : ℕ) : ℝ) •
        pinchMatrix parityPattern (intertwinerMatrix line T) := by
  have hM := intertwinerMatrix_positive line T hT
  apply le_of_quadratic_le _ _ hM.isHermitian
    ((pinchMatrix_positive parityPattern _ hM).smul (by positivity : (0 : ℝ) ≤ _)).isHermitian
  intro x
  rw [quadratic_smul, quadratic_pinch]
  simp only [quadratic_eq_energy]
  have he : Matrix.toEuclideanLin (intertwinerMatrix line T)=T.toLinearMap := by
    exact congrArg ContinuousLinearMap.toLinearMap ((Matrix.toEuclideanCLM (𝕜 := ℂ)).apply_symm_apply T.toLinearMap.toContinuousLinearMap)
  rw [he]
  convert line_signed_parity_dephasing line T hT (WithLp.toLp 2 (star x)) using 1
  congr 1
  apply Finset.sum_congr rfl
  intro b _
  congr 1
  ext w
  simp only [parityMask, WithLp.ofLp_toLp, Pi.star_apply]
  split_ifs <;> simp

end RowColumn.Signed

end
end


section

noncomputable section
open scoped BigOperators Classical MatrixOrder Matrix.Norms.L2Operator ComplexOrder
namespace RowColumn.MatrixState
variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]

omit [Fintype I] in
lemma extendMatrix_equiv (e : J ↪ I) (p : Equiv.Perm I) (q : Equiv.Perm J)
    (he : ∀ j, p (e j)=e (q j)) (A : Matrix J J ℂ)
    (hA : ∀ i j, A (q i) (q j)=A i j) (i j : I) :
    extendMatrix e A (p i) (p j)=extendMatrix e A i j := by
  have hh (x : I) (hx : x ∉ Set.range e) : p x ∉ Set.range e := by
    rintro ⟨k,hk⟩
    apply hx
    refine ⟨q.symm k, p.injective ?_⟩
    rw [he, Equiv.apply_symm_apply, hk]
  by_cases hi : i ∈ Set.range e
  · obtain ⟨i,rfl⟩ := hi
    by_cases hj : j ∈ Set.range e
    · obtain ⟨j,rfl⟩ := hj
      rw [he, he, extendMatrix_apply, extendMatrix_apply, hA]
    · rw [extendMatrix_eq_zero_right e A _ _ (hh j hj), extendMatrix_eq_zero_right e A _ _ hj]
  · rw [extendMatrix_eq_zero_left e A _ (hh i hi), extendMatrix_eq_zero_left e A _ hi]

omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in
lemma submatrix_mono (A B : Matrix I I ℂ) (h : A ≤ B) (e : J → I) :
    A.submatrix e e ≤ B.submatrix e e := by
  rw [← sub_nonneg, Matrix.nonneg_iff_posSemidef] at h ⊢
  exact h.submatrix e

end RowColumn.MatrixState

namespace RowColumn.Signed
open RowColumn.MatrixState RowColumn.Postselection RowColumn.WordOrbits
variable {S C L : Type*} [Fintype S] [DecidableEq S] [Fintype C] [DecidableEq C]
  [Fintype L] [DecidableEq L] (odd : C → Prop) [DecidablePred odd] (k : ℕ)

def wordInclusion : Words (S := S) odd k ↪ (S → C) := ⟨Subtype.val, Subtype.val_injective⟩

def extendedPinch (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) : Matrix (S → C) (S → C) ℂ :=
  extendMatrix (wordInclusion odd k) (pinchMatrix parityPattern (intertwinerMatrix line T))

omit [Fintype L] [DecidableEq L] in
lemma extendedPinch_positive (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (hT : T.toLinearMap.IsPositive) :
    (extendedPinch odd k line T).PosSemidef :=
  extendMatrix_positive _ _ (pinchMatrix_positive _ _ (intertwinerMatrix_positive line T hT))

omit [Fintype L] [DecidableEq L] in
lemma extendedPinch_trace (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) :
    (extendedPinch odd k line T).trace = (intertwinerMatrix line T).trace := by
  rw [extendedPinch, extendMatrix_trace, pinchMatrix_trace]

omit [Fintype L] [DecidableEq L] in
lemma extendedPinch_invariant (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (p : Equiv.Perm S)
    (hp : ∀ i, line (p i)=line i) (w v : S → C) :
    extendedPinch odd k line T (w ∘ p) (v ∘ p)=extendedPinch odd k line T w v := by
  let g : lineGroup line := ⟨p⁻¹, (lineGroup line).inv_mem hp⟩
  apply extendMatrix_equiv (wordInclusion odd k) (reindexWord p) (wordsEquiv g.1)
  · intro j
    ext i
    change j.1 (p i) = j.1 ((p⁻¹)⁻¹ i)
    rw [inv_inv]
  · exact pinch_intertwiner_invariant line T g

omit [Fintype L] [DecidableEq L] in
lemma extendedPinch_support (line : S → L)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (w v : S → C)
    (h : ¬ ∀ i, odd (w i) ↔ odd (v i)) : extendedPinch odd k line T w v=0 := by
  by_cases hw : w ∈ Set.range (wordInclusion (S := S) odd k)
  · obtain ⟨w,rfl⟩ := hw
    by_cases hv : v ∈ Set.range (wordInclusion (S := S) odd k)
    · obtain ⟨v,rfl⟩ := hv
      rw [extendedPinch, extendMatrix_apply]
      apply pinchMatrix_support
      exact fun he => h ((parityPattern_eq_iff w v).mp he)
    · exact extendMatrix_eq_zero_right _ _ _ _ hv
  · exact extendMatrix_eq_zero_left _ _ _ hw _

/-- Finite positive even product-state majorant of the true signed line
commutant. Both parity bandwidth and the local-state normalization are retained. -/
theorem signed_line_postselection (line : S → L) (a₀ : S → C × C)
    (hn : 0 < Fintype.card S)
    (T : Representation.IntertwiningMap (lineRepresentation (odd := odd) (k := k) line)
      (lineRepresentation (odd := odd) (k := k) line)) (hT : T.toLinearMap.IsPositive) :
    intertwinerMatrix line T ≤
      ((((Fintype.card S+1)^(Fintype.card L*Fintype.card C^2) : ℕ) : ℝ) *
        (intertwinerMatrix line T).trace.re *
        (((Fintype.card S+1)^(Fintype.card (L × (C × C))) : ℕ) /
          (Fintype.card (Phases (L × (C × C)) (Fintype.card S)) : ℝ))) •
      (∑ q : Types (S := S) (A := L × (C × C)),
        ∑ θ : Phases (L × (C × C)) (Fintype.card S),
          sectorTensor odd k (fun i => lineState line a₀ odd q θ (line i))) := by
  let A := extendedPinch odd k line T
  let B := ∑ q : Types (S := S) (A := L × (C × C)),
    ∑ θ : Phases (L × (C × C)) (Fintype.card S),
      tensorMatrix (fun i : S => lineState line a₀ odd q θ (line i))
  let t : ℝ := (intertwinerMatrix line T).trace.re *
    (((Fintype.card S+1)^(Fintype.card (L × (C × C))) : ℕ) /
      (Fintype.card (Phases (L × (C × C)) (Fintype.card S)) : ℝ))
  have hA : A.PosSemidef := extendedPinch_positive odd k line T hT
  have ht : 0 ≤ t := mul_nonneg (by
    have hh := (intertwinerMatrix_positive line T hT).trace_nonneg
    exact hh.1) (by positivity)
  have hB : B.PosSemidef := by
    apply Matrix.nonneg_iff_posSemidef.mp
    apply Finset.sum_nonneg
    intro q _
    apply Finset.sum_nonneg
    intro θ _
    exact (tensorMatrix_posSemidef _ (fun i => lineState_positive line a₀ odd q θ (line i))).nonneg
  have hab : A ≤ t • B := by
    apply le_of_quadratic_le _ _ hA.isHermitian (hB.smul ht).isHermitian
    intro x
    simp only [quadratic_smul, B, quadratic_sum]
    have hh := positive_line_postselection line a₀ hn odd A hA
      (extendedPinch_invariant odd k line T) (extendedPinch_support odd k line T) x
    simpa only [A, extendedPinch_trace, t, mul_assoc] using hh
  have hsub := submatrix_mono A (t • B) hab (Subtype.val : Words (S := S) odd k → S → C)
  have hleft : A.submatrix Subtype.val Subtype.val=pinchMatrix parityPattern (intertwinerMatrix line T) := by
    ext w v
    exact extendMatrix_apply (wordInclusion odd k) _ w v
  rw [hleft] at hsub
  have hs := smul_le_smul_of_nonneg_left hsub
    (by positivity : (0 : ℝ) ≤ (((Fintype.card S+1)^(Fintype.card L*Fintype.card C^2) : ℕ) : ℝ))
  apply (intertwiner_le_pinch line T hT).trans
  convert hs using 1
  ext w v
  simp only [Matrix.smul_apply, Matrix.submatrix_apply, Matrix.sum_apply, B, t,
    sectorTensor, smul_smul, mul_assoc]

end RowColumn.Signed

end
end

end OAI