introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
19.4 kB
import OAI.RepresentationTheory.RowColumn.TensorFilter
import OAI.RepresentationTheory.RowColumn.HookIsometry
namespace OAI
section
noncomputable section
open scoped BigOperators Classical
namespace RowColumn.Postselection
open WordOrbits
variable {S L A : Type*} [Fintype S] [DecidableEq S] [Fintype L] [DecidableEq L]
[Fintype A] [DecidableEq A]
def allocationPerm (line b : S β†’ L) (hb : counts b = counts line) : Equiv.Perm S :=
(same_counts_permutation line b hb.symm).choose
omit [DecidableEq S] [Fintype L] in
lemma allocationPerm_spec (line b : S β†’ L) (hb : counts b = counts line) (i : S) :
b (allocationPerm line b hb i) = line i :=
(same_counts_permutation line b hb.symm).choose_spec i
omit [DecidableEq S] [Fintype A] in
lemma counts_precomp (w : S β†’ A) (p : Equiv.Perm S) : counts (w ∘ p) = counts w := by
funext c
apply Fin.ext
exact Fintype.card_congr
{ toFun := fun i => ⟨p i.1,i.2⟩
invFun := fun i => ⟨p.symm i.1,by simpa using i.2⟩
left_inv := by intro i; apply Subtype.ext; simp
right_inv := by intro i; apply Subtype.ext; simp }
def symExtension (line : S β†’ L) (v : (S β†’ A) β†’ β„‚) (w : S β†’ L Γ— A) : β„‚ :=
if hb : counts (fun i => (w i).1) = counts line then
v (fun i => (w (allocationPerm line _ hb i)).2) else 0
omit [Fintype A] [DecidableEq A] in
omit [DecidableEq S] in
lemma symExtension_on_line (line : S β†’ L) (v : (S β†’ A) β†’ β„‚)
(hv : βˆ€ p : Equiv.Perm S, (βˆ€ i, line (p i) = line i) β†’ βˆ€ w, v (w ∘ p) = v w)
(w : S β†’ A) : symExtension line v (fun i => (line i,w i)) = v w := by
simp only [symExtension]
exact hv (allocationPerm line line rfl) (allocationPerm_spec line line rfl) w
omit [Fintype A] [DecidableEq A] in
omit [DecidableEq S] in
lemma symExtension_invariant (line : S β†’ L) (v : (S β†’ A) β†’ β„‚)
(hv : βˆ€ p : Equiv.Perm S, (βˆ€ i, line (p i) = line i) β†’ βˆ€ w, v (w ∘ p) = v w)
(p : Equiv.Perm S) (w : S β†’ L Γ— A) : symExtension line v (w ∘ p) = symExtension line v w := by
have hc : counts (fun i => (w (p i)).1) = counts (fun i => (w i).1) := counts_precomp (fun i => (w i).1) p
by_cases hb : counts (fun i => (w i).1) = counts line
Β· have hb' : counts (fun i => (w (p i)).1) = counts line := hc.trans hb
simp only [symExtension, Function.comp_apply, dite_eq_left hb, dite_eq_left hb']
let e := allocationPerm line (fun i => (w i).1) hb
let e' := allocationPerm line (fun i => (w (p i)).1) hb'
let q : Equiv.Perm S := e'.trans (p.trans e.symm)
have hq (i : S) : line (q i) = line i := by
rw [← allocationPerm_spec line (fun i => (w i).1) hb (q i)]
change (w (e (e.symm (p (e' i))))).1 = line i
rw [Equiv.apply_symm_apply]
exact allocationPerm_spec line (fun i => (w (p i)).1) hb' i
have hh := hv q hq (fun i => (w (e i)).2)
change v (fun i => (w (p (e' i))).2) = v (fun i => (w (e i)).2)
convert hh using 1
congr 1
ext i
simp only [q, Equiv.trans_apply, Function.comp_apply, Equiv.apply_symm_apply]
Β· have hb' : Β¬ counts (fun i => (w (p i)).1) = counts line := fun hh => hb (hc.symm.trans hh)
simp only [symExtension, Function.comp_apply, dite_eq_right hb, dite_eq_right hb']
omit [Fintype A] in
omit [DecidableEq S] in
lemma symExtension_counts (line : S β†’ L) (v : (S β†’ A) β†’ β„‚)
(hv : βˆ€ p : Equiv.Perm S, (βˆ€ i, line (p i) = line i) β†’ βˆ€ w, v (w ∘ p) = v w)
(w z : S β†’ L Γ— A) (he : counts w = counts z) : symExtension line v w = symExtension line v z := by
obtain ⟨p,hp⟩ := same_counts_permutation w z he
have hh : z ∘ p = w := funext hp
rw [← hh]
exact symExtension_invariant line v hv p z
abbrev Allocations (line : S β†’ L) := {b : S β†’ L // counts b = counts line}
def labelWordEquiv : (S β†’ L Γ— A) ≃ (S β†’ L) Γ— (S β†’ A) where
toFun w := (fun i => (w i).1, fun i => (w i).2)
invFun w i := (w.1 i,w.2 i)
left_inv := by intro w; rfl
right_inv := by intro w; rfl
def precompWordEquiv (p : Equiv.Perm S) : Equiv.Perm (S β†’ A) where
toFun w := w ∘ p
invFun w := w ∘ p.symm
left_inv := by intro w; ext i; simp
right_inv := by intro w; ext i; simp
omit [DecidableEq A] in
lemma symExtension_norm (line : S β†’ L) (v : (S β†’ A) β†’ β„‚) :
(βˆ‘ w : S β†’ L Γ— A, Complex.normSq (symExtension line v w)) =
(Fintype.card (Allocations line) : ℝ) * βˆ‘ w : S β†’ A, Complex.normSq (v w) := by
rw [← (labelWordEquiv (S := S) (L := L) (A := A)).symm.sum_comp,
Fintype.sum_prod_type]
change (βˆ‘ b : S β†’ L, βˆ‘ w : S β†’ A, Complex.normSq
(if hb : counts b=counts line then v (w ∘ allocationPerm line b hb) else 0)) = _
have he (b : S β†’ L) : (βˆ‘ w : S β†’ A, Complex.normSq
(if hb : counts b=counts line then v (w ∘ allocationPerm line b hb) else 0)) =
if counts b=counts line then βˆ‘ w : S β†’ A, Complex.normSq (v w) else 0 := by
split_ifs with hb
Β· exact Equiv.sum_comp (precompWordEquiv (A := A) (allocationPerm line b hb)) (fun w => Complex.normSq (v w))
Β· simp
simp_rw [he]
simp [Finset.sum_ite, Fintype.card_subtype, Allocations]
def labelTest (line : S β†’ L) (x : (S β†’ A) β†’ β„‚) (w : S β†’ L Γ— A) : β„‚ :=
if (fun i => (w i).1)=line then x (fun i => (w i).2) else 0
omit [DecidableEq A] in
lemma labeled_pair (line : S β†’ L) (x : (S β†’ A) β†’ β„‚) (f : (S β†’ L Γ— A) β†’ β„‚) :
(βˆ‘ w, f w * labelTest line x w) = βˆ‘ w : S β†’ A, f (fun i => (line i,w i)) * x w := by
rw [← (labelWordEquiv (S := S) (L := L) (A := A)).symm.sum_comp,
Fintype.sum_prod_type]
change (βˆ‘ b : S β†’ L, βˆ‘ w : S β†’ A, f (fun i => (b i,w i)) *
(if b=line then x w else 0)) = _
simp only [mul_ite, mul_zero, Finset.sum_ite_irrel, Finset.sum_const_zero]
simp
lemma allocation_probability (line : S β†’ L) (r : L β†’ ℝ)
(hr : βˆ€ l, 0 ≀ r l) (hs : βˆ‘ l, r l ≀ 1) :
(Fintype.card (Allocations line) : ℝ) * (∏ i, r (line i)) ≀ 1 := by
have he (b : S β†’ L) (hb : counts b=counts line) :
(∏ i, r (b i)) = ∏ i, r (line i) := by
rw [prod_by_counts, prod_by_counts, hb]
have hh : (βˆ‘ b : S β†’ L, if counts b=counts line then ∏ i, r (line i) else 0) ≀
βˆ‘ b : S β†’ L, ∏ i, r (b i) := by
apply Finset.sum_le_sum
intro b _
split_ifs with hb
Β· exact le_of_eq (he b hb).symm
Β· exact Finset.prod_nonneg (fun _ _ => hr _)
have hl : (βˆ‘ b : S β†’ L, if counts b=counts line then ∏ i, r (line i) else 0) =
(Fintype.card (Allocations line) : ℝ) * (∏ i, r (line i)) := by
simp [Finset.sum_ite, Fintype.card_subtype, Allocations]
rw [hl, ← Fintype.prod_sum] at hh
exact hh.trans (Finset.prod_le_oneβ‚€ (fun _ _ => Finset.sum_nonneg (fun l _ => hr l)) (fun _ _ => hs))
def lineMass (z : L Γ— A β†’ β„‚) (l : L) : ℝ := βˆ‘ a, Complex.normSq (z (l,a))
def normalizedLine (z : L Γ— A β†’ β„‚) (l : L) (a : A) : β„‚ :=
(Real.sqrt (lineMass z l) : β„‚)⁻¹ * z (l,a)
omit [Fintype L] [DecidableEq L] [DecidableEq A] in
lemma lineMass_nonneg (z : L Γ— A β†’ β„‚) (l : L) : 0 ≀ lineMass z l :=
Finset.sum_nonneg (fun _ _ => Complex.normSq_nonneg _)
omit [Fintype L] [DecidableEq L] [DecidableEq A] in
lemma lineMass_zero (z : L Γ— A β†’ β„‚) (l : L) (h : lineMass z l=0) (a : A) : z (l,a)=0 := by
apply Complex.normSq_eq_zero.mp
have hh : Complex.normSq (z (l,a)) ≀ lineMass z l :=
Finset.single_le_sum (fun b _ => Complex.normSq_nonneg (z (l,b))) (Finset.mem_univ a)
exact le_antisymm (h β–Έ hh) (Complex.normSq_nonneg _)
omit [Fintype L] [DecidableEq L] [DecidableEq A] in
lemma line_reconstruction (z : L Γ— A β†’ β„‚) (l : L) (a : A) :
z (l,a) = (Real.sqrt (lineMass z l) : β„‚) * normalizedLine z l a := by
by_cases hz : lineMass z l=0
Β· simp [normalizedLine, hz, lineMass_zero z l hz a]
Β· have h : (Real.sqrt (lineMass z l) : β„‚) β‰  0 := by
exact_mod_cast (Real.sqrt_ne_zero'.mpr (lt_of_le_of_ne (lineMass_nonneg z l) (Ne.symm hz)))
simp [normalizedLine, h]
omit [Fintype L] [DecidableEq L] [DecidableEq A] in
lemma normalizedLine_norm (z : L Γ— A β†’ β„‚) (l : L) :
(βˆ‘ a, Complex.normSq (normalizedLine z l a)) ≀ 1 := by
by_cases hz : lineMass z l=0
Β· simp [normalizedLine, hz]
Β· have hp : 0 < lineMass z l := lt_of_le_of_ne (lineMass_nonneg z l) (Ne.symm hz)
simp_rw [normalizedLine, map_mul, map_invβ‚€, Complex.normSq_ofReal, Real.mul_self_sqrt (le_of_lt hp)]
rw [← Finset.mul_sum]
change (lineMass z l)⁻¹ * lineMass z l ≀ 1
rw [inv_mul_cancelβ‚€ hz]
omit [Fintype L] [DecidableEq L] [DecidableEq A] in
lemma labeled_tensor_pair (line : S β†’ L) (z : L Γ— A β†’ β„‚) (x : (S β†’ A) β†’ β„‚) :
Complex.normSq (βˆ‘ w : S β†’ A, tensorVector z (fun i => (line i,w i)) * x w) =
(∏ i, lineMass z (line i)) *
Complex.normSq (βˆ‘ w : S β†’ A, (∏ i, normalizedLine z (line i) (w i)) * x w) := by
have he (w : S β†’ A) : tensorVector z (fun i => (line i,w i)) =
(∏ i, (Real.sqrt (lineMass z (line i)) : β„‚)) * ∏ i, normalizedLine z (line i) (w i) := by
rw [← Finset.prod_mul_distrib]
exact Finset.prod_congr rfl (fun i _ => line_reconstruction z (line i) (w i))
simp_rw [he, mul_assoc]
rw [← Finset.mul_sum, map_mul]
congr 1
rw [map_prod]
apply Finset.prod_congr rfl
intro i _
exact (Complex.normSq_ofReal _).trans (Real.mul_self_sqrt (lineMass_nonneg z (line i)))
omit [DecidableEq S] [Fintype A] [DecidableEq A] in
lemma symExtension_supported (line : S β†’ L) (v : (S β†’ A) β†’ β„‚)
(good : A β†’ Prop) [DecidablePred good]
(hv : βˆ€ w, Β¬ (βˆ€ i, good (w i)) β†’ v w=0)
(w : S β†’ L Γ— A) (hw : Β¬ βˆ€ i, good (w i).2) : symExtension line v w=0 := by
unfold symExtension
split_ifs with hb
Β· apply hv
intro h
apply hw
intro i
simpa using h ((allocationPerm line _ hb).symm i)
Β· rfl
def lineAmplitude (line : S β†’ L) (aβ‚€ : S β†’ A) (good : A β†’ Prop) [DecidablePred good]
(q : Types (S := S) (A := L Γ— A)) (ΞΈ : Phases (L Γ— A) (Fintype.card S)) (l : L) (a : A) : β„‚ :=
normalizedLine (truncateAmplitude (fun c : L Γ— A => good c.2)
(twistedAmplitude (typeRepresentative (fun i => (line i,aβ‚€ i)) q) ΞΈ)) l a
omit [DecidableEq S] in
omit [Fintype L] in
lemma lineAmplitude_norm (line : S β†’ L) (aβ‚€ : S β†’ A) (good : A β†’ Prop) [DecidablePred good]
(q : Types (S := S) (A := L Γ— A)) (ΞΈ : Phases (L Γ— A) (Fintype.card S)) (l : L) :
(βˆ‘ a, Complex.normSq (lineAmplitude line aβ‚€ good q ΞΈ l a)) ≀ 1 :=
normalizedLine_norm _ _
omit [DecidableEq S] [Fintype L] in
lemma lineAmplitude_support (line : S β†’ L) (aβ‚€ : S β†’ A) (good : A β†’ Prop) [DecidablePred good]
(q : Types (S := S) (A := L Γ— A)) (ΞΈ : Phases (L Γ— A) (Fintype.card S)) (l : L) (a : A)
(ha : Β¬ good a) : lineAmplitude line aβ‚€ good q ΞΈ l a=0 := by
simp [lineAmplitude, normalizedLine, truncateAmplitude, ha]
/-- Independent fibre postselection, with the allocation factorial cancelled
by the exact multinomial probability rather than included in the overhead. -/
theorem line_symmetric_postselection (line : S β†’ L) (aβ‚€ : S β†’ A) (hn : 0 < Fintype.card S)
(good : A β†’ Prop) [DecidablePred good] (v x : (S β†’ A) β†’ β„‚)
(hv : βˆ€ p : Equiv.Perm S, (βˆ€ i, line (p i)=line i) β†’ βˆ€ w, v (w ∘ p)=v w)
(hsupp : βˆ€ w, Β¬ (βˆ€ i, good (w i)) β†’ v w=0) :
Complex.normSq (βˆ‘ w, v w*x w) ≀
(βˆ‘ w, Complex.normSq (v w)) *
(((Fintype.card S+1)^(Fintype.card (L Γ— A)) : β„•) /
(Fintype.card (Phases (L Γ— A) (Fintype.card S)) : ℝ) *
βˆ‘ q : Types (S := S) (A := L Γ— A), βˆ‘ ΞΈ : Phases (L Γ— A) (Fintype.card S),
Complex.normSq (βˆ‘ w : S β†’ A, (∏ i, lineAmplitude line aβ‚€ good q ΞΈ (line i) (w i)) * x w)) := by
let z (q : Types (S := S) (A := L Γ— A)) (ΞΈ : Phases (L Γ— A) (Fintype.card S)) :=
truncateAmplitude (fun c : L Γ— A => good c.2)
(twistedAmplitude (typeRepresentative (fun i => (line i,aβ‚€ i)) q) ΞΈ)
let R (q : Types (S := S) (A := L Γ— A)) (ΞΈ : Phases (L Γ— A) (Fintype.card S)) :=
Complex.normSq (βˆ‘ w : S β†’ A, (∏ i, normalizedLine (z q ΞΈ) (line i) (w i)) * x w)
have hz (q : Types (S := S) (A := L Γ— A)) (ΞΈ : Phases (L Γ— A) (Fintype.card S)) :
(Fintype.card (Allocations line) : ℝ) * (∏ i, lineMass (z q ΞΈ) (line i)) ≀ 1 := by
apply allocation_probability line _ (lineMass_nonneg _)
rw [show (βˆ‘ l, lineMass (z q ΞΈ) l) = βˆ‘ c : L Γ— A, Complex.normSq (z q ΞΈ c) from
(Fintype.sum_prod_type (fun c : L Γ— A => Complex.normSq (z q ΞΈ c))).symm]
exact truncated_twisted_subnormalized _ _ hn _
have hh := supported_symmetric_postselection (fun i => (line i,aβ‚€ i)) hn
(fun c : L Γ— A => good c.2) (symExtension line v) (labelTest line x)
(symExtension_counts line v hv) (symExtension_supported line v good hsupp)
rw [labeled_pair] at hh
simp_rw [symExtension_on_line line v hv] at hh
rw [symExtension_norm] at hh
simp_rw [labeled_pair, labeled_tensor_pair] at hh
let c : ℝ := ((Fintype.card S+1)^(Fintype.card (L Γ— A)) : β„•) /
(Fintype.card (Phases (L Γ— A) (Fintype.card S)) : ℝ)
change _ ≀ ((Fintype.card (Allocations line) : ℝ) * βˆ‘ w, Complex.normSq (v w)) *
(c * βˆ‘ q, βˆ‘ ΞΈ, (∏ i, lineMass (z q ΞΈ) (line i)) * R q ΞΈ) at hh
change _ ≀ (βˆ‘ w, Complex.normSq (v w)) * (c * βˆ‘ q, βˆ‘ ΞΈ, R q ΞΈ)
apply hh.trans
rw [show ((Fintype.card (Allocations line) : ℝ) * βˆ‘ w, Complex.normSq (v w)) *
(c * βˆ‘ q, βˆ‘ ΞΈ, (∏ i, lineMass (z q ΞΈ) (line i)) * R q ΞΈ) =
(βˆ‘ w, Complex.normSq (v w)) * (c * ((Fintype.card (Allocations line) : ℝ) *
βˆ‘ q, βˆ‘ ΞΈ, (∏ i, lineMass (z q ΞΈ) (line i)) * R q ΞΈ)) by ring]
apply mul_le_mul_of_nonneg_left _ (Finset.sum_nonneg (fun _ _ => Complex.normSq_nonneg _))
apply mul_le_mul_of_nonneg_left _ (by positivity : 0 ≀ c)
simp_rw [Finset.mul_sum, ← mul_assoc]
exact Finset.sum_le_sum (fun q _ => Finset.sum_le_sum (fun ΞΈ _ =>
(mul_le_mul_of_nonneg_right (hz q ΞΈ) (Complex.normSq_nonneg _)).trans_eq (one_mul _)))
end RowColumn.Postselection
end
end
section
noncomputable section
open scoped BigOperators Classical Matrix.Norms.L2Operator ComplexOrder MatrixOrder
namespace RowColumn.Postselection
open MatrixState WordOrbits
variable {S L C : Type*} [Fintype S] [DecidableEq S] [Fintype L] [DecidableEq L]
[Fintype C] [DecidableEq C]
def lineState (line : S β†’ L) (aβ‚€ : S β†’ C Γ— C) (odd : C β†’ Prop) [DecidablePred odd]
(q : Types (S := S) (A := L Γ— (C Γ— C))) (ΞΈ : Phases (L Γ— (C Γ— C)) (Fintype.card S))
(l : L) : Matrix C C β„‚ :=
gramState (lineAmplitude line aβ‚€ (fun p : C Γ— C => odd p.1 ↔ odd p.2) q ΞΈ l)
omit [DecidableEq S] [Fintype L] in
lemma lineState_positive (line : S β†’ L) (aβ‚€ : S β†’ C Γ— C) (odd : C β†’ Prop) [DecidablePred odd]
(q : Types (S := S) (A := L Γ— (C Γ— C))) (ΞΈ : Phases (L Γ— (C Γ— C)) (Fintype.card S)) (l : L) :
(lineState line aβ‚€ odd q ΞΈ l).PosSemidef := gramState_posSemidef _
omit [DecidableEq S] in
omit [Fintype L] in
lemma lineState_trace (line : S β†’ L) (aβ‚€ : S β†’ C Γ— C) (odd : C β†’ Prop) [DecidablePred odd]
(q : Types (S := S) (A := L Γ— (C Γ— C))) (ΞΈ : Phases (L Γ— (C Γ— C)) (Fintype.card S)) (l : L) :
(lineState line aβ‚€ odd q ΞΈ l).trace.re ≀ 1 := by
rw [lineState, gramState_trace]
exact lineAmplitude_norm _ _ _ _ _ _
omit [DecidableEq S] [Fintype L] in
lemma lineState_even (line : S β†’ L) (aβ‚€ : S β†’ C Γ— C) (odd : C β†’ Prop) [DecidablePred odd]
(q : Types (S := S) (A := L Γ— (C Γ— C))) (ΞΈ : Phases (L Γ— (C Γ— C)) (Fintype.card S))
(l : L) (c d : C) (h : Β¬ (odd c ↔ odd d)) : lineState line aβ‚€ odd q ΞΈ l c d=0 := by
apply gramState_parity_supported odd _ _ c d h
exact fun c d h => lineAmplitude_support _ _ _ _ _ _ _ h
lemma variable_purification_pair (z : S β†’ C Γ— C β†’ β„‚) (x : (S β†’ C) β†’ β„‚) (v : S β†’ C) :
(βˆ‘ a : S β†’ C Γ— C, (∏ i, z i (a i)) * purificationTest x v a) =
βˆ‘ w : S β†’ C, tensorMatrix (fun i => letterMatrix (z i)) w v * x w := by
exact purification_pair (tensorMatrix (fun i => letterMatrix (z i))) x v
lemma variable_purification_quadratic (z : S β†’ C Γ— C β†’ β„‚) (x : (S β†’ C) β†’ β„‚) :
(βˆ‘ v : S β†’ C, Complex.normSq (βˆ‘ a : S β†’ C Γ— C,
(∏ i, z i (a i)) * purificationTest x v a)) =
quadratic (tensorMatrix (fun i => gramState (z i))) x := by
simp_rw [variable_purification_pair]
change factorQuadratic (tensorMatrix (fun i => letterMatrix (z i))) x = _
rw [factorQuadratic_eq, tensorMatrix_star, tensorMatrix_mul]
rfl
/-- Explicit local domination for independent row/column permutation fibres.
All mixture terms are genuine even positive identical-slot substates within
each fibre, irrespective of its size and the deletion layout. -/
theorem positive_line_postselection (line : S β†’ L) (aβ‚€ : S β†’ C Γ— C) (hn : 0 < Fintype.card S)
(odd : C β†’ Prop) [DecidablePred odd] (A : Matrix (S β†’ C) (S β†’ C) β„‚)
(hA : A.PosSemidef)
(hinv : βˆ€ (p : Equiv.Perm S), (βˆ€ i, line (p i)=line i) β†’ βˆ€ (w v : S β†’ C),
A (w ∘ p) (v ∘ p)=A w v)
(hsupp : βˆ€ w v, Β¬ (βˆ€ i, odd (w i) ↔ odd (v i)) β†’ A w v=0)
(x : (S β†’ C) β†’ β„‚) :
quadratic A x ≀ A.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),
quadratic (tensorMatrix (fun i : S => lineState line aβ‚€ odd q ΞΈ (line i))) x) := by
let B : Matrix (S β†’ C) (S β†’ C) β„‚ := CFC.sqrt A
have hi (p : Equiv.Perm S) (hp : βˆ€ i, line (p i)=line i) (w v : S β†’ C) :
B (w ∘ p) (v ∘ p)=B w v :=
sqrt_permutation_invariant A hA (reindexWord p) (hinv p hp) w v
have hz (w v : S β†’ C) (hh : Β¬ βˆ€ i, odd (w i) ↔ odd (v i)) : B w v=0 := by
apply sqrt_block_supported (fun u : S β†’ C => fun i => odd (u i)) A hA
(fun u v he => hsupp u v (fun ht => he (funext fun i => propext (ht i)))) w v
intro he
exact hh (fun i => Iff.of_eq (congrFun he i))
have hv (p : Equiv.Perm S) (hp : βˆ€ i, line (p i)=line i) (w : S β†’ C Γ— C) :
purificationVector B (w ∘ p)=purificationVector B w :=
hi p hp (fun i => (w i).1) (fun i => (w i).2)
have hs (w : S β†’ C Γ— C) (hw : Β¬ βˆ€ i, odd (w i).1 ↔ odd (w i).2) : purificationVector B w=0 :=
hz _ _ hw
have hh (v : S β†’ C) := line_symmetric_postselection line aβ‚€ hn
(fun p : C Γ— C => odd p.1 ↔ odd p.2) (purificationVector B) (purificationTest x v) hv hs
simp only [purification_pair B x, purification_normSq B] at hh
have hsum := Finset.sum_le_sum (fun v (_ : v ∈ Finset.univ) => hh v)
change factorQuadratic B x ≀ _ at hsum
have ht : purifierTrace B=A.trace.re := sqrt_trace A hA
rw [ht] at hsum
change factorQuadratic (CFC.sqrt A) x ≀ _ at hsum
rw [sqrt_factorQuadratic A hA] at hsum
apply hsum.trans_eq
simp only [Finset.mul_sum]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro q _
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro ΞΈ _
rw [← Finset.mul_sum, ← Finset.mul_sum]
congr 2
exact variable_purification_quadratic _ x
end RowColumn.Postselection
end
end
end OAI