Download data/lean/OAI/LinearAlgebra/MatrixState/Postselection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 43.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixState/Postselection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixState/Postselection.lean
-
curl -L -o Postselection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixState/Postselection.lean
43.8 kB
| import OAI.LinearAlgebra.MatrixState.QuarterRoot | |
| import OAI.RepresentationTheory.RowColumn.SignedWords | |
| namespace OAI | |
| section | |
| noncomputable section | |
| open scoped BigOperators Classical Nat | |
| namespace RowColumn.WordOrbits | |
| variable {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A] [DecidableEq A] | |
| /-- All transporters between two words are exactly the independent bijections | |
| between corresponding color fibres. -/ | |
| def transporterEquiv (a b : S β A) : | |
| {p : Equiv.Perm S // β x, b (p x) = a x} β | |
| (β c : A, {x : S // a x = c} β {x : S // b x = c}) where | |
| toFun p c := | |
| { toFun := fun x => β¨p.1 x.1, (p.2 x.1).trans x.2β© | |
| invFun := fun y => β¨p.1.symm y.1, by | |
| have h := p.2 (p.1.symm y.1) | |
| rw [Equiv.apply_symm_apply] at h | |
| exact h.symm.trans y.2β© | |
| left_inv := by intro x; apply Subtype.ext; simp | |
| right_inv := by intro x; apply Subtype.ext; simp } | |
| invFun f := β¨(Equiv.sigmaFiberEquiv a).symm |>.trans | |
| ((Equiv.sigmaCongrRight f).trans (Equiv.sigmaFiberEquiv b)), fun x => (f (a x) β¨x,rflβ©).2β© | |
| left_inv := by intro p; apply Subtype.ext; ext x; rfl | |
| right_inv := by | |
| intro f | |
| funext c | |
| apply Equiv.ext | |
| rintro β¨x,rflβ© | |
| apply Subtype.ext | |
| rfl | |
| lemma card_transporters (a b : S β A) (he : counts a = counts b) : | |
| Fintype.card {p : Equiv.Perm S // β x, b (p x) = a x} = | |
| β c : A, (Fintype.card {x : S // a x = c})! := by | |
| rw [Fintype.card_congr (transporterEquiv a b), Fintype.card_pi] | |
| apply Finset.prod_congr rfl | |
| intro c _ | |
| have hc : Fintype.card {x : S // a x = c} = Fintype.card {x : S // b x = c} := | |
| congrArg (fun f : A β Fin (Fintype.card S + 1) => (f c).val) he | |
| let e := Fintype.equivOfCardEq hc | |
| let ee : ({x : S // a x = c} β {x : S // b x = c}) β | |
| Equiv.Perm {x : S // a x = c} := | |
| { toFun := fun f => f.trans e.symm | |
| invFun := fun g => g.trans e | |
| left_inv := by intro f; ext x; simp | |
| right_inv := by intro g; ext x; simp } | |
| rw [Fintype.card_congr ee, Fintype.card_perm] | |
| /-- Orbit-stabilizer with all factors explicit. It is the exact multinomial | |
| cardinality needed for the finite postselection probability. -/ | |
| lemma type_card_factorial (a : S β A) : | |
| Fintype.card {b : S β A // counts b = counts a} * | |
| (β c : A, (Fintype.card {x : S // a x = c})!) = (Fintype.card S)! := by | |
| let e : Equiv.Perm S β | |
| Ξ£ b : {b : S β A // counts b = counts a}, | |
| {p : Equiv.Perm S // β x, b.1 (p x) = a x} := | |
| { toFun := fun p => | |
| β¨β¨(fun x => a (p.symm x)), by | |
| funext c | |
| apply Fin.ext | |
| exact Fintype.card_congr | |
| { toFun := fun x => β¨p.symm x.1,x.2β© | |
| invFun := fun x => β¨p x.1,by simpa using x.2β© | |
| left_inv := by intro x; apply Subtype.ext; simp | |
| right_inv := by intro x; apply Subtype.ext; simp }β©, | |
| β¨p,fun x => by simpβ©β© | |
| invFun := fun z => z.2.1 | |
| left_inv := by intro p; rfl | |
| right_inv := by | |
| rintro β¨β¨b,hbβ©,p,hpβ© | |
| have he : (fun x => a (p.symm x)) = b := by | |
| funext x | |
| have h := hp (p.symm x) | |
| simpa using h.symm | |
| cases he | |
| rfl } | |
| have hc := Fintype.card_congr e | |
| rw [Fintype.card_perm, Fintype.card_sigma] at hc | |
| have hn (b : {b : S β A // counts b = counts a}) : | |
| Fintype.card {p : Equiv.Perm S // β x, b.1 (p x) = a x} = | |
| β c : A, (Fintype.card {x : S // a x = c})! := | |
| card_transporters a b.1 b.2.symm | |
| simp_rw [hn] at hc | |
| simpa using hc.symm | |
| end RowColumn.WordOrbits | |
| namespace RowColumn.WordOrbits | |
| open scoped BigOperators Classical Nat | |
| lemma factorial_le_factorial_mul_pow {b a : β} (h : b β€ a) : | |
| a.factorial β€ b.factorial * a^(a-b) := by | |
| induction a,h using Nat.le_induction with | |
| | base => simp | |
| | succ a ha ih => | |
| rw [Nat.factorial_succ, show a+1-b = (a-b)+1 by omega, pow_succ] | |
| calc | |
| (a+1)*a.factorial β€ (a+1)*(b.factorial*a^(a-b)) := Nat.mul_le_mul_left _ ih | |
| _ β€ (a+1)*(b.factorial*(a+1)^(a-b)) := by gcongr; omega | |
| _ = _ := by ring | |
| lemma factorial_mode (a b : β) : a^b * a.factorial β€ a^a * b.factorial := by | |
| rcases le_total a b with h | h | |
| Β· have hh := Nat.factorial_mul_pow_sub_le_factorial h | |
| calc | |
| a^b * a.factorial = a^a * (a.factorial * a^(b-a)) := by | |
| calc | |
| _ = a^(a+(b-a)) * a.factorial := by rw [Nat.add_sub_of_le h] | |
| _ = _ := by rw [pow_add]; ring | |
| _ β€ _ := Nat.mul_le_mul_left _ hh | |
| Β· have hh := factorial_le_factorial_mul_pow h | |
| calc | |
| a^b * a.factorial β€ a^b * (b.factorial * a^(a-b)) := Nat.mul_le_mul_left _ hh | |
| _ = a^a * b.factorial := by | |
| calc | |
| _ = a^(b+(a-b)) * b.factorial := by rw [pow_add]; ring | |
| _ = _ := by rw [Nat.add_sub_of_le h] | |
| variable {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A] [DecidableEq A] | |
| omit [DecidableEq S] in | |
| lemma prod_by_counts {M : Type*} [CommMonoid M] (w : S β A) (f : A β M) : | |
| (β x : S, f (w x)) = β c : A, f c ^ (counts w c).val := by | |
| rw [β Fintype.prod_fiberwise w] | |
| apply Finset.prod_congr rfl | |
| intro c _ | |
| simp only [counts] | |
| simp only [show β x : {x : S // w x = c}, f (w x.1) = f c from fun x => congrArg f x.2] | |
| simp | |
| omit [DecidableEq S] in | |
| lemma sum_counts (w : S β A) : β c : A, (counts w c).val = Fintype.card S := by | |
| exact (Fintype.card_congr (Equiv.sigmaFiberEquiv w)).symm.trans (by rw [Fintype.card_sigma]; rfl) |>.symm | |
| /-- Under its own empirical product distribution, a type is a mode among | |
| all types. This gives a polynomial lower bound without Stirling or entropy. -/ | |
| lemma empirical_type_mode (a b : S β A) : | |
| Fintype.card {w : S β A // counts w = counts b} * | |
| (β c : A, (counts a c).val ^ (counts b c).val) β€ | |
| Fintype.card {w : S β A // counts w = counts a} * | |
| (β c : A, (counts a c).val ^ (counts a c).val) := by | |
| have h := Finset.prod_le_prod (fun c (_ : c β Finset.univ) => | |
| factorial_mode (counts a c).val (counts b c).val) | |
| simp only [Finset.prod_mul_distrib] at h | |
| have ha := type_card_factorial a | |
| have hb := type_card_factorial b | |
| change _ * (β c : A, (counts a c).val !) = _ at ha | |
| change _ * (β c : A, (counts b c).val !) = _ at hb | |
| have hp : 0 < (β c : A, (counts a c).val !) * (β c : A, (counts b c).val !) := by | |
| exact Nat.mul_pos (Finset.prod_pos (fun _ _ => Nat.factorial_pos _)) | |
| (Finset.prod_pos (fun _ _ => Nat.factorial_pos _)) | |
| apply (Nat.mul_le_mul_right_iff hp).mp | |
| calc | |
| _ = (Fintype.card S)! * ((β c, (counts a c).val ^ (counts b c).val) * | |
| β c, (counts a c).val !) := by rw [β hb]; ring | |
| _ β€ (Fintype.card S)! * ((β c, (counts a c).val ^ (counts a c).val) * | |
| β c, (counts b c).val !) := Nat.mul_le_mul_left _ h | |
| _ = _ := by rw [β ha]; ring | |
| end RowColumn.WordOrbits | |
| namespace RowColumn.WordOrbits | |
| open scoped BigOperators Classical Nat | |
| variable {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A] [DecidableEq A] | |
| def typeMass (a : S β A) (q : A β Fin (Fintype.card S + 1)) : β := | |
| Fintype.card {w : S β A // counts w = q} * β c, (counts a c).val ^ (q c).val | |
| lemma typeMass_le_mode (a : S β A) (q : A β Fin (Fintype.card S + 1)) : | |
| typeMass a q β€ typeMass a (counts a) := by | |
| by_cases hn : Nonempty {w : S β A // counts w = q} | |
| Β· obtain β¨w,hwβ© := hn | |
| rw [β hw] | |
| exact empirical_type_mode a w | |
| Β· let : IsEmpty {w : S β A // counts w = q} := not_nonempty_iff.mp hn | |
| simp [typeMass] | |
| lemma sum_typeMass (a : S β A) : | |
| (β q : A β Fin (Fintype.card S+1), typeMass a q) = | |
| (Fintype.card S)^(Fintype.card S) := by | |
| have he (q : A β Fin (Fintype.card S+1)) : typeMass a q = | |
| β w : {w : S β A // counts w = q}, β x : S, (counts a (w.1 x)).val := by | |
| have hh (w : {w : S β A // counts w = q}) : | |
| (β x : S, (counts a (w.1 x)).val) = β c : A, (counts a c).val ^ (q c).val := by | |
| rw [prod_by_counts w.1 (fun c => (counts a c).val), w.2] | |
| simp only [hh, Finset.sum_const, Finset.card_univ, smul_eq_mul, typeMass] | |
| simp_rw [he] | |
| rw [Fintype.sum_fiberwise counts (fun w : S β A => β x : S, (counts a (w x)).val), | |
| β Fintype.prod_sum (fun (_ : S) (c : A) => (counts a c).val)] | |
| simp only [sum_counts, Finset.prod_const, Finset.card_univ] | |
| /-- Elementary finite postselection mass bound: an empirical type has at | |
| least the inverse number of possible occupation tables. -/ | |
| lemma empirical_mass_lower (a : S β A) : | |
| (Fintype.card S)^(Fintype.card S) β€ | |
| (Fintype.card S+1)^(Fintype.card A) * typeMass a (counts a) := by | |
| rw [β sum_typeMass a] | |
| have hh := Finset.sum_le_sum (fun q (_ : q β Finset.univ) => typeMass_le_mode a q) | |
| simpa using hh | |
| end RowColumn.WordOrbits | |
| namespace RowColumn.Postselection | |
| open scoped BigOperators Classical | |
| open WordOrbits | |
| variable {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A] [DecidableEq A] | |
| def empiricalAmplitude (a : S β A) (c : A) : β := | |
| Real.sqrt ((counts a c).val / (Fintype.card S : β)) | |
| def tensorVector (z : A β β) (w : S β A) : β := β x : S, z (w x) | |
| omit [DecidableEq S] [Fintype A] in | |
| lemma normSq_empiricalAmplitude (a : S β A) (c : A) : | |
| Complex.normSq (empiricalAmplitude a c) = | |
| (counts a c).val / (Fintype.card S : β) := by | |
| simp only [empiricalAmplitude, Complex.normSq_ofReal] | |
| exact Real.mul_self_sqrt (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) | |
| omit [DecidableEq S] in | |
| lemma empiricalAmplitude_normalized (a : S β A) (hn : 0 < Fintype.card S) : | |
| (β c : A, Complex.normSq (empiricalAmplitude a c)) = 1 := by | |
| simp only [normSq_empiricalAmplitude, β Finset.sum_div] | |
| rw [β Nat.cast_sum, sum_counts] | |
| exact div_self (by exact_mod_cast Nat.ne_of_gt hn) | |
| omit [DecidableEq S] [Fintype A] [DecidableEq A] in | |
| lemma normSq_tensorVector (z : A β β) (w : S β A) : | |
| Complex.normSq (tensorVector z w) = β x : S, Complex.normSq (z (w x)) := by | |
| exact map_prod Complex.normSq _ _ | |
| omit [DecidableEq S] in | |
| lemma normSq_empirical_tensor (a : S β A) : | |
| Complex.normSq (tensorVector (empiricalAmplitude a) a) = | |
| (β c : A, ((counts a c).val : β)^(counts a c).val) / | |
| (Fintype.card S : β)^(Fintype.card S) := by | |
| rw [normSq_tensorVector] | |
| simp_rw [normSq_empiricalAmplitude] | |
| rw [Finset.prod_div_distrib, prod_by_counts a (fun c => ((counts a c).val : β))] | |
| simp | |
| lemma empirical_type_probability (a : S β A) (hn : 0 < Fintype.card S) : | |
| 1 β€ ((Fintype.card S+1)^(Fintype.card A) : β) * | |
| ((Fintype.card {w : S β A // counts w = counts a} : β) * | |
| Complex.normSq (tensorVector (empiricalAmplitude a) a)) := by | |
| have hh := empirical_mass_lower a | |
| rw [normSq_empirical_tensor] | |
| have hden : 0 < (Fintype.card S : β)^Fintype.card S := by positivity | |
| rw [β mul_div_assoc, β mul_div_assoc, le_div_iffβ hden, one_mul] | |
| dsimp only [typeMass] at hh | |
| exact_mod_cast hh | |
| end RowColumn.Postselection | |
| noncomputable section | |
| open scoped BigOperators Classical | |
| namespace RowColumn.Postselection | |
| variable {A : Type*} [Fintype A] [DecidableEq A] {n : β} | |
| abbrev CountIndex (A : Type*) (n : β) := A β Fin (n+1) | |
| abbrev Phases (A : Type*) (n : β) := A β ZMod (n+1) | |
| def countCharacter (q : CountIndex A n) : AddChar (Phases A n) β := | |
| ZMod.stdAddChar.compAddMonoidHom | |
| { toFun := fun ΞΈ => β c, ((q c).val : ZMod (n+1)) * ΞΈ c | |
| map_zero' := by simp | |
| map_add' := by intros; simp [mul_add, Finset.sum_add_distrib] } | |
| @[simp] lemma countCharacter_single (q : CountIndex A n) (a : A) : | |
| countCharacter q (Pi.single a 1) = ZMod.stdAddChar ((q a).val : ZMod (n+1)) := by | |
| simp [countCharacter, Pi.single_apply] | |
| lemma countCharacter_injective : Function.Injective (countCharacter (A := A) (n := n)) := by | |
| intro q r h | |
| funext a | |
| have he := congrArg (fun f : AddChar (Phases A n) β => f (Pi.single a 1)) h | |
| simp only [countCharacter_single] at he | |
| have hc := ZMod.injective_stdAddChar he | |
| change ((q a).val : ZMod (n+1)) = (r a).val at hc | |
| rw [ZMod.natCast_eq_natCast_iff', Nat.mod_eq_of_lt (q a).isLt, | |
| Nat.mod_eq_of_lt (r a).isLt] at hc | |
| exact Fin.ext hc | |
| lemma character_orthogonality (q r : CountIndex A n) : | |
| (β ΞΈ : Phases A n, countCharacter q ΞΈ * (starRingEnd β) (countCharacter r ΞΈ)) = | |
| if q = r then (Fintype.card (Phases A n) : β) else 0 := by | |
| have he (ΞΈ : Phases A n) : (countCharacter q - countCharacter r) ΞΈ = | |
| countCharacter q ΞΈ * (starRingEnd β) (countCharacter r ΞΈ) := by | |
| rw [AddChar.sub_apply, AddChar.map_neg_eq_inv, | |
| Complex.inv_eq_conj ((countCharacter r).norm_apply ΞΈ)] | |
| simp_rw [β he] | |
| rw [AddChar.sum_eq_ite] | |
| simp only [sub_eq_zero, countCharacter_injective.eq_iff] | |
| /-- Finite exact phase integration: order n+1 resolves every occupation | |
| vector with entries in 0,...,n, with no analytical Haar integral. -/ | |
| lemma phase_parseval (f : CountIndex A n β β) : | |
| (β ΞΈ : Phases A n, Complex.normSq (β q, countCharacter q ΞΈ * f q)) = | |
| (Fintype.card (Phases A n) : β) * β q, Complex.normSq (f q) := by | |
| apply Complex.ofReal_injective | |
| push_cast | |
| simp_rw [β Complex.mul_conj, map_sum, map_mul] | |
| simp only [Finset.sum_mul, Finset.mul_sum] | |
| have he (ΞΈ : Phases A n) (q r : CountIndex A n) : | |
| (countCharacter q ΞΈ * f q) * ((starRingEnd β) (countCharacter r ΞΈ) * | |
| (starRingEnd β) (f r)) = | |
| (countCharacter q ΞΈ * (starRingEnd β) (countCharacter r ΞΈ)) * | |
| (f q * (starRingEnd β) (f r)) := by ring | |
| simp_rw [he] | |
| rw [Finset.sum_comm] | |
| conv_lhs => arg 2; ext q; rw [Finset.sum_comm] | |
| simp_rw [β Finset.sum_mul, character_orthogonality] | |
| simp [ite_mul] | |
| lemma phase_single_bound (f : CountIndex A n β β) (q : CountIndex A n) : | |
| (Fintype.card (Phases A n) : β) * Complex.normSq (f q) β€ | |
| β ΞΈ : Phases A n, Complex.normSq (β r, countCharacter r ΞΈ * f r) := by | |
| rw [phase_parseval] | |
| apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) | |
| exact Finset.single_le_sum (fun _ _ => Complex.normSq_nonneg _) (Finset.mem_univ q) | |
| end RowColumn.Postselection | |
| namespace RowColumn.Postselection | |
| open scoped BigOperators Classical | |
| open WordOrbits | |
| lemma normSq_sum_mul_le {I : Type*} [Fintype I] (v x : I β β) : | |
| Complex.normSq (β i, v i * x i) β€ | |
| (β i, Complex.normSq (v i)) * β i, Complex.normSq (x i) := by | |
| have hh : ββ i, v i * x iβ β€ β i, βv iβ * βx iβ := by | |
| simpa only [norm_mul] using norm_sum_le Finset.univ (fun i => v i * x i) | |
| calc | |
| Complex.normSq (β i, v i * x i) = ββ i, v i * x iβ^2 := (Complex.sq_norm _).symm | |
| _ β€ (β i, βv iβ * βx iβ)^2 := pow_le_pow_leftβ (norm_nonneg _) hh 2 | |
| _ β€ (β i, βv iβ^2) * β i, βx iβ^2 := Finset.sum_mul_sq_le_sq_mul_sq _ _ _ | |
| _ = _ := by simp only [Complex.sq_norm] | |
| variable {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A] [DecidableEq A] | |
| abbrev Types := CountIndex A (Fintype.card S) | |
| def typeSize (q : Types (S := S) (A := A)) := Fintype.card {w : S β A // counts w = q} | |
| def typeSum (x : (S β A) β β) (q : Types (S := S) (A := A)) : β := | |
| β w : {w : S β A // counts w = q}, x w.1 | |
| def typeAverage (x : (S β A) β β) (w : S β A) : β := | |
| typeSum x (counts w) / (typeSize (counts w) : β) | |
| def typeRepresentative (aβ : S β A) (q : Types (S := S) (A := A)) : S β A := | |
| if h : Nonempty {w : S β A // counts w = q} then h.some.1 else aβ | |
| omit [DecidableEq S] [Fintype A] in | |
| lemma representative_counts (aβ : S β A) (q : Types (S := S) (A := A)) | |
| (h : Nonempty {w : S β A // counts w = q}) : | |
| counts (typeRepresentative aβ q) = q := by | |
| simp only [typeRepresentative, dite_eq_left h] | |
| exact h.some.2 | |
| lemma typeAverage_pair (v x : (S β A) β β) | |
| (hv : β a b, counts a = counts b β v a = v b) : | |
| (β w : S β A, v w * typeAverage x w) = β w : S β A, v w * x w := by | |
| rw [β Fintype.sum_fiberwise counts (fun w : S β A => v w * typeAverage x w), | |
| β Fintype.sum_fiberwise counts (fun w : S β A => v w * x w)] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| by_cases hn : Nonempty {w : S β A // counts w = q} | |
| Β· obtain β¨a,haβ© := hn | |
| have hc : (typeSize q : β) β 0 := by | |
| have hn : 0 < typeSize q := Fintype.card_pos_iff.mpr β¨β¨a,haβ©β© | |
| exact_mod_cast Nat.ne_of_gt hn | |
| have he (w : {w : S β A // counts w = q}) : v w.1 = v a := hv _ _ (w.2.trans ha.symm) | |
| simp only [typeAverage, he, | |
| show β w : {w : S β A // counts w = q}, counts w.1 = q from fun w => w.2] | |
| rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, β Finset.mul_sum] | |
| change (typeSize q : β) * (v a * (typeSum x q / typeSize q)) = v a * typeSum x q | |
| field_simp | |
| Β· let : IsEmpty {w : S β A // counts w = q} := not_nonempty_iff.mp hn | |
| simp | |
| lemma typeAverage_normSq (x : (S β A) β β) : | |
| (β w : S β A, Complex.normSq (typeAverage x w)) = | |
| β q : Types (S := S) (A := A), Complex.normSq (typeSum x q) / typeSize q := by | |
| rw [β Fintype.sum_fiberwise counts (fun w : S β A => Complex.normSq (typeAverage x w))] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| simp only [typeAverage, | |
| show β w : {w : S β A // counts w = q}, counts w.1 = q from fun w => w.2, | |
| Finset.sum_const, Finset.card_univ, nsmul_eq_mul] | |
| change (typeSize q : β) * Complex.normSq (typeSum x q / (typeSize q : β)) = _ | |
| rw [Complex.normSq_div] | |
| have he : Complex.normSq (typeSize q : β) = (typeSize q : β)^2 := by simp [Complex.normSq_apply]; ring | |
| rw [he] | |
| by_cases hh : typeSize q = 0 | |
| Β· simp [hh] | |
| Β· have hc : (typeSize q : β) β 0 := by exact_mod_cast hh | |
| field_simp | |
| lemma invariant_vector_bound (v x : (S β A) β β) | |
| (hv : β a b, counts a = counts b β v a = v b) : | |
| Complex.normSq (β w, v w * x w) β€ | |
| (β w, Complex.normSq (v w)) * | |
| β q : Types (S := S) (A := A), Complex.normSq (typeSum x q) / typeSize q := by | |
| rw [β typeAverage_pair v x hv, β typeAverage_normSq] | |
| exact normSq_sum_mul_le v (typeAverage x) | |
| end RowColumn.Postselection | |
| namespace RowColumn.Postselection | |
| open scoped BigOperators Classical | |
| open WordOrbits | |
| lemma char_sum {I G : Type*} [AddCommMonoid G] (Ο : AddChar G β) | |
| (s : Finset I) (f : I β G) : Ο (β i β s, f i) = β i β s, Ο (f i) := by | |
| induction s using Finset.cons_induction with | |
| | empty => simp | |
| | cons a s ha ih => simp only [Finset.sum_cons, Finset.prod_cons, Ο.map_add_eq_mul, ih] | |
| variable {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A] [DecidableEq A] | |
| def typeAmplitude (z : A β β) (q : Types (S := S) (A := A)) : β := | |
| β c, z c ^ (q c).val | |
| omit [DecidableEq S] in | |
| lemma tensorVector_by_counts (z : A β β) (w : S β A) : | |
| tensorVector z w = typeAmplitude z (counts w) := prod_by_counts w z | |
| def twistedAmplitude (a : S β A) (ΞΈ : Phases A (Fintype.card S)) (c : A) : β := | |
| empiricalAmplitude a c * ZMod.stdAddChar (ΞΈ c) | |
| omit [DecidableEq S] in | |
| lemma twistedAmplitude_normalized (a : S β A) (hn : 0 < Fintype.card S) | |
| (ΞΈ : Phases A (Fintype.card S)) : | |
| (β c : A, Complex.normSq (twistedAmplitude a ΞΈ c)) = 1 := by | |
| have hc (c : A) : Complex.normSq (ZMod.stdAddChar (ΞΈ c)) = 1 := by | |
| rw [β Complex.sq_norm, AddChar.norm_apply]; norm_num | |
| simp only [twistedAmplitude, Complex.normSq_mul, hc, mul_one] | |
| exact empiricalAmplitude_normalized a hn | |
| omit [DecidableEq S] [DecidableEq A] in | |
| lemma countCharacter_eq_prod (q : Types (S := S) (A := A)) (ΞΈ : Phases A (Fintype.card S)) : | |
| countCharacter q ΞΈ = β c, ZMod.stdAddChar (ΞΈ c) ^ (q c).val := by | |
| change ZMod.stdAddChar (β c, ((q c).val : ZMod (Fintype.card S + 1)) * ΞΈ c) = _ | |
| rw [char_sum] | |
| apply Finset.prod_congr rfl | |
| intro c _ | |
| rw [β nsmul_eq_mul, AddChar.map_nsmul_eq_pow] | |
| omit [DecidableEq S] in | |
| lemma tensorVector_twisted (a w : S β A) (ΞΈ : Phases A (Fintype.card S)) : | |
| tensorVector (twistedAmplitude a ΞΈ) w = | |
| countCharacter (counts w) ΞΈ * typeAmplitude (empiricalAmplitude a) (counts w) := by | |
| change (β x : S, empiricalAmplitude a (w x) * ZMod.stdAddChar (ΞΈ (w x))) = _ | |
| rw [Finset.prod_mul_distrib, prod_by_counts w (empiricalAmplitude a), | |
| prod_by_counts w (fun c => ZMod.stdAddChar (ΞΈ c)), β countCharacter_eq_prod] | |
| exact mul_comm _ _ | |
| lemma twisted_pair (a : S β A) (ΞΈ : Phases A (Fintype.card S)) (x : (S β A) β β) : | |
| (β w, tensorVector (twistedAmplitude a ΞΈ) w * x w) = | |
| β q : Types (S := S) (A := A), | |
| countCharacter q ΞΈ * (typeAmplitude (empiricalAmplitude a) q * typeSum x q) := by | |
| simp_rw [tensorVector_twisted] | |
| rw [β Fintype.sum_fiberwise counts (fun w : S β A => | |
| countCharacter (counts w) ΞΈ * typeAmplitude (empiricalAmplitude a) (counts w) * x w)] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| simp only [show β w : {w : S β A // counts w = q}, counts w.1 = q from fun w => w.2] | |
| rw [β Finset.mul_sum] | |
| exact mul_assoc _ _ _ | |
| lemma type_phase_bound (a : S β A) (x : (S β A) β β) : | |
| (Fintype.card (Phases A (Fintype.card S)) : β) * | |
| (Complex.normSq (tensorVector (empiricalAmplitude a) a) * | |
| Complex.normSq (typeSum x (counts a))) β€ | |
| β ΞΈ : Phases A (Fintype.card S), | |
| Complex.normSq (β w, tensorVector (twistedAmplitude a ΞΈ) w * x w) := by | |
| simp_rw [twisted_pair] | |
| have hh := phase_single_bound (fun q : Types (S := S) (A := A) => | |
| typeAmplitude (empiricalAmplitude a) q * typeSum x q) (counts a) | |
| simpa only [Complex.normSq_mul, tensorVector_by_counts] using hh | |
| lemma type_representative_bound (aβ : S β A) (hn : 0 < Fintype.card S) | |
| (x : (S β A) β β) (q : Types (S := S) (A := A)) : | |
| Complex.normSq (typeSum x q) / typeSize q β€ | |
| ((Fintype.card S+1)^(Fintype.card A) : β) / | |
| (Fintype.card (Phases A (Fintype.card S)) : β) * | |
| β ΞΈ : Phases A (Fintype.card S), | |
| Complex.normSq (β w, tensorVector (twistedAmplitude (typeRepresentative aβ q) ΞΈ) w * x w) := by | |
| by_cases he : Nonempty {w : S β A // counts w = q} | |
| Β· let a := typeRepresentative aβ q | |
| have ha : counts a = q := representative_counts aβ q he | |
| have hp := empirical_type_probability a hn | |
| have ht := type_phase_bound a x | |
| rw [ha] at ht | |
| change 1 β€ ((Fintype.card S+1)^(Fintype.card A) : β) * | |
| ((typeSize (counts a) : β) * Complex.normSq (tensorVector (empiricalAmplitude a) a)) at hp | |
| rw [ha] at hp | |
| have hq : (0 : β) < typeSize q := by | |
| exact_mod_cast Fintype.card_pos_iff.mpr he | |
| have hP : (0 : β) < Fintype.card (Phases A (Fintype.card S)) := by | |
| exact_mod_cast Fintype.card_pos | |
| have ha0 := Complex.normSq_nonneg (tensorVector (empiricalAmplitude a) a) | |
| have hx0 := Complex.normSq_nonneg (typeSum x q) | |
| have hD0 : (0 : β) β€ ((Fintype.card S+1)^(Fintype.card A) : β) := Nat.cast_nonneg _ | |
| rw [div_le_iffβ hq] | |
| rw [div_mul_eq_mul_div, div_mul_eq_mul_div, le_div_iffβ hP] | |
| nlinarith [mul_le_mul_of_nonneg_right hp hx0, | |
| mul_le_mul_of_nonneg_left ht (mul_nonneg hD0 (le_of_lt hq))] | |
| Β· let : IsEmpty {w : S β A // counts w = q} := not_nonempty_iff.mp he | |
| have hx : typeSum x q = 0 := by simp [typeSum] | |
| rw [hx, Complex.normSq_zero, zero_div] | |
| exact mul_nonneg (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) | |
| (Finset.sum_nonneg (fun _ _ => Complex.normSq_nonneg _)) | |
| /-- Exact finite symmetric-vector postselection, with a polynomial cost | |
| in the slot number and alphabet size. Every mixture vector is a normalized | |
| identical-slot tensor power; the construction is explicit and finite. -/ | |
| theorem symmetric_postselection (aβ : S β A) (hn : 0 < Fintype.card S) | |
| (v x : (S β A) β β) (hv : β a b, counts a = counts b β v a = v b) : | |
| Complex.normSq (β w, v w * x w) β€ | |
| (β w, Complex.normSq (v w)) * | |
| (((Fintype.card S+1)^(Fintype.card A) : β) / | |
| (Fintype.card (Phases A (Fintype.card S)) : β) * | |
| β q : Types (S := S) (A := A), | |
| β ΞΈ : Phases A (Fintype.card S), | |
| Complex.normSq (β w, tensorVector (twistedAmplitude (typeRepresentative aβ q) ΞΈ) w * x w)) := by | |
| apply (invariant_vector_bound v x hv).trans | |
| apply mul_le_mul_of_nonneg_left _ (Finset.sum_nonneg (fun _ _ => Complex.normSq_nonneg _)) | |
| rw [Finset.mul_sum] | |
| exact Finset.sum_le_sum (fun q _ => type_representative_bound aβ hn x q) | |
| end RowColumn.Postselection | |
| namespace RowColumn.Postselection | |
| open scoped BigOperators Classical | |
| open WordOrbits | |
| variable {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A] [DecidableEq A] | |
| /-- Truncating purification letters preserves positivity after partial trace. | |
| It is how the postselection mixture is constrained to even one-slot states. -/ | |
| def truncateAmplitude (good : A β Prop) [DecidablePred good] (z : A β β) : A β β := | |
| fun c => if good c then z c else 0 | |
| omit [DecidableEq S] [Fintype A] [DecidableEq A] in | |
| lemma tensorVector_truncate (good : A β Prop) [DecidablePred good] | |
| (z : A β β) (w : S β A) : | |
| tensorVector (truncateAmplitude good z) w = | |
| if β i, good (w i) then tensorVector z w else 0 := by | |
| by_cases h : β i, good (w i) | |
| Β· simp [tensorVector, truncateAmplitude, h] | |
| Β· rw [ite_eq_right h] | |
| obtain β¨i,hiβ© := not_forall.mp h | |
| exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [truncateAmplitude, hi]) | |
| omit [DecidableEq S] in | |
| lemma truncated_twisted_subnormalized (good : A β Prop) [DecidablePred good] | |
| (a : S β A) (hn : 0 < Fintype.card S) (ΞΈ : Phases A (Fintype.card S)) : | |
| (β c, Complex.normSq (truncateAmplitude good (twistedAmplitude a ΞΈ) c)) β€ 1 := by | |
| rw [β twistedAmplitude_normalized a hn ΞΈ] | |
| apply Finset.sum_le_sum | |
| intro c _ | |
| by_cases hc : good c | |
| Β· simp [truncateAmplitude, hc] | |
| Β· simpa [truncateAmplitude, hc] using Complex.normSq_nonneg (twistedAmplitude a ΞΈ c) | |
| /-- Symmetric postselection retaining a prescribed alphabet support. In the | |
| application good(c,e) means that the physical and auxiliary parities agree, | |
| so the resulting Gram states are block diagonal. -/ | |
| theorem supported_symmetric_postselection (aβ : S β A) (hn : 0 < Fintype.card S) | |
| (good : A β Prop) [DecidablePred good] (v x : (S β A) β β) | |
| (hv : β a b, counts a = counts b β v a = v b) | |
| (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 A) : β) / | |
| (Fintype.card (Phases A (Fintype.card S)) : β) * | |
| β q : Types (S := S) (A := A), | |
| β ΞΈ : Phases A (Fintype.card S), | |
| Complex.normSq (β w, | |
| tensorVector (truncateAmplitude good (twistedAmplitude (typeRepresentative aβ q) ΞΈ)) w * x w)) := by | |
| let y : (S β A) β β := fun w => if β i, good (w i) then x w else 0 | |
| have he (w : S β A) : v w * y w = v w * x w := by | |
| by_cases hw : β i, good (w i) | |
| Β· simp [y, hw] | |
| Β· simp [y, hw, hsupp w hw] | |
| have ht (z : A β β) (w : S β A) : | |
| tensorVector z w * y w = tensorVector (truncateAmplitude good z) w * x w := by | |
| rw [tensorVector_truncate] | |
| by_cases hw : β i, good (w i) <;> simp [y, hw] | |
| have hh := symmetric_postselection aβ hn v y hv | |
| simpa only [he, ht] using hh | |
| end RowColumn.Postselection | |
| namespace RowColumn.Postselection | |
| open scoped BigOperators Classical | |
| open WordOrbits | |
| variable {S C : Type*} [Fintype S] [DecidableEq S] [Fintype C] [DecidableEq C] | |
| def pairWordsEquiv : (S β C Γ C) β (S β C) Γ (S β C) where | |
| toFun a := (fun i => (a i).1, fun i => (a i).2) | |
| invFun w := fun i => (w.1 i,w.2 i) | |
| left_inv := by intro a; rfl | |
| right_inv := by intro w; rfl | |
| def purificationVector (B : (S β C) β (S β C) β β) (a : S β C Γ C) : β := | |
| B (fun i => (a i).1) (fun i => (a i).2) | |
| def purificationTest (x : (S β C) β β) (v : S β C) (a : S β C Γ C) : β := | |
| if (fun i => (a i).2) = v then x (fun i => (a i).1) else 0 | |
| def productPurifier (z : C Γ C β β) (w v : S β C) : β := β i : S, z (w i,v i) | |
| def purifierQuadratic (B : (S β C) β (S β C) β β) (x : (S β C) β β) : β := | |
| β v : S β C, Complex.normSq (β w : S β C, B w v * x w) | |
| def purifierTrace (B : (S β C) β (S β C) β β) : β := | |
| β w : S β C, β v : S β C, Complex.normSq (B w v) | |
| lemma purification_pair (B : (S β C) β (S β C) β β) (x : (S β C) β β) (v : S β C) : | |
| (β a : S β C Γ C, purificationVector B a * purificationTest x v a) = | |
| β w : S β C, B w v * x w := by | |
| calc | |
| _ = β p : (S β C) Γ (S β C), B p.1 p.2 * (if p.2 = v then x p.1 else 0) := | |
| Fintype.sum_equiv pairWordsEquiv _ _ (fun _ => rfl) | |
| _ = _ := by rw [Fintype.sum_prod_type]; simp [mul_ite] | |
| omit [DecidableEq C] in | |
| lemma purification_normSq (B : (S β C) β (S β C) β β) : | |
| (β a : S β C Γ C, Complex.normSq (purificationVector B a)) = purifierTrace B := by | |
| calc | |
| _ = β p : (S β C) Γ (S β C), Complex.normSq (B p.1 p.2) := | |
| Fintype.sum_equiv pairWordsEquiv _ _ (fun _ => rfl) | |
| _ = _ := Fintype.sum_prod_type _ | |
| lemma productPurifier_pair (z : C Γ C β β) (x : (S β C) β β) (v : S β C) : | |
| (β a : S β C Γ C, tensorVector z a * purificationTest x v a) = | |
| β w : S β C, productPurifier z w v * x w := by | |
| exact purification_pair (productPurifier z) x v | |
| omit [DecidableEq S] [Fintype C] in | |
| lemma purification_invariant (B : (S β C) β (S β C) β β) | |
| (hB : β (p : Equiv.Perm S) (w v : S β C), | |
| B (fun i => w (p i)) (fun i => v (p i)) = B w v) | |
| (a b : S β C Γ C) (he : counts a = counts b) : | |
| purificationVector B a = purificationVector B b := by | |
| obtain β¨p,hpβ© := same_counts_permutation a b he | |
| have hβ : (fun i => (a i).1) = fun i => (b (p i)).1 := by | |
| funext i; exact congrArg Prod.fst (hp i).symm | |
| have hβ : (fun i => (a i).2) = fun i => (b (p i)).2 := by | |
| funext i; exact congrArg Prod.snd (hp i).symm | |
| change B (fun i => (a i).1) (fun i => (a i).2) = _ | |
| rw [hβ,hβ] | |
| exact hB p (fun i => (b i).1) (fun i => (b i).2) | |
| /-- Explicit positive identical-slot domination at the purification level. | |
| The matrix factor is symmetric under actual slot permutations and has the | |
| specified letter support. This is the quantitative local-state dependency | |
| of the occupied-board main, not an assumed main overlap estimate. -/ | |
| theorem matrix_postselection (aβ : S β C Γ C) (hn : 0 < Fintype.card S) | |
| (good : C Γ C β Prop) [DecidablePred good] | |
| (B : (S β C) β (S β C) β β) | |
| (hB : β (p : Equiv.Perm S) (w v : S β C), | |
| B (fun i => w (p i)) (fun i => v (p i)) = B w v) | |
| (hsupp : β w v, Β¬ (β i, good (w i,v i)) β B w v = 0) | |
| (x : (S β C) β β) : | |
| purifierQuadratic B x β€ purifierTrace B * | |
| (((Fintype.card S+1)^(Fintype.card (C Γ C)) : β) / | |
| (Fintype.card (Phases (C Γ C) (Fintype.card S)) : β) * | |
| β q : Types (S := S) (A := C Γ C), | |
| β ΞΈ : Phases (C Γ C) (Fintype.card S), | |
| purifierQuadratic (productPurifier | |
| (truncateAmplitude good (twistedAmplitude (typeRepresentative aβ q) ΞΈ))) x) := by | |
| have hv := purification_invariant B hB | |
| have hs (a : S β C Γ C) (ha : Β¬ β i, good (a i)) : purificationVector B a = 0 := by | |
| exact hsupp _ _ ha | |
| have hh (v : S β C) := supported_symmetric_postselection aβ hn good | |
| (purificationVector B) (purificationTest x v) hv hs | |
| simp_rw [purification_pair, purification_normSq, productPurifier_pair] at hh | |
| have hsum := Finset.sum_le_sum (fun v (_ : v β Finset.univ) => hh v) | |
| change purifierQuadratic B x β€ _ at hsum | |
| apply hsum.trans_eq | |
| simp only [Finset.mul_sum, purifierQuadratic] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| rw [Finset.sum_comm] | |
| end RowColumn.Postselection | |
| noncomputable section | |
| open scoped BigOperators Classical MatrixOrder Matrix.Norms.L2Operator ComplexOrder | |
| namespace RowColumn.MatrixState | |
| variable {I J : Type*} [Fintype I] [DecidableEq I] | |
| lemma sqrt_commute (A T : Matrix I I β) (_ : A.PosSemidef) (h : Commute A T) : | |
| Commute (CFC.sqrt A) T := by | |
| rw [CFC.sqrt_eq_cfc] | |
| exact h.cfc_nnreal _ | |
| lemma commute_perm_iff (A : Matrix I I β) (p : Equiv.Perm I) : | |
| Commute A (p.permMatrix β) β β i j, A (p i) (p j) = A i j := by | |
| change A * p.permMatrix β = p.permMatrix β * A β _ | |
| rw [PEquiv.mul_toMatrix_toPEquiv, PEquiv.toMatrix_toPEquiv_mul] | |
| constructor | |
| Β· intro h i j | |
| have hh := congrArg (fun M : Matrix I I β => M i (p j)) h | |
| simpa using hh.symm | |
| Β· intro h | |
| ext i j | |
| exact (h i (p.symm j)).symm.trans (by simp) | |
| lemma sqrt_permutation_invariant (A : Matrix I I β) (hA : A.PosSemidef) | |
| (p : Equiv.Perm I) (h : β i j, A (p i) (p j) = A i j) : | |
| β i j, CFC.sqrt A (p i) (p j) = CFC.sqrt A i j := | |
| (commute_perm_iff _ p).mp (sqrt_commute A _ hA ((commute_perm_iff A p).mpr h)) | |
| lemma commute_diagonal_iff (A : Matrix I I β) (d : I β β) : | |
| Commute A (Matrix.diagonal d) β β i j, A i j * d j = d i * A i j := by | |
| change _ = _ β _ | |
| constructor | |
| Β· intro h i j | |
| simpa only [Matrix.mul_diagonal, Matrix.diagonal_mul] using | |
| congrArg (fun M : Matrix I I β => M i j) h | |
| Β· intro h; ext i j; simpa only [Matrix.mul_diagonal, Matrix.diagonal_mul] using h i j | |
| lemma sqrt_block_supported [DecidableEq J] (b : I β J) | |
| (A : Matrix I I β) (hA : A.PosSemidef) (h : β i j, b i β b j β A i j = 0) : | |
| β i j, b i β b j β CFC.sqrt A i j = 0 := by | |
| intro i j hij | |
| let d : I β β := fun k => if b k = b i then 1 else 0 | |
| have hc : Commute A (Matrix.diagonal d) := by | |
| apply (commute_diagonal_iff A d).mpr | |
| intro k l | |
| by_cases he : b k = b l | |
| Β· simp [d, he, mul_comm] | |
| Β· simp [h k l he] | |
| have hs := (commute_diagonal_iff (CFC.sqrt A) d).mp (sqrt_commute A _ hA hc) i j | |
| simpa [d, Ne.symm hij] using hs.symm | |
| /-- Bilinear-coordinate quadratic form. Complex conjugation is placed in the | |
| second coordinate, matching the purification formulas used below. -/ | |
| def quadratic (A : Matrix I I β) (x : I β β) : β := | |
| (β i, β j, A i j * x i * star (x j)).re | |
| def factorQuadratic (B : Matrix I I β) (x : I β β) : β := | |
| β v, Complex.normSq (β w, B w v * x w) | |
| lemma normSq_eq_re (z : β) : Complex.normSq z = (z * star z).re := by | |
| rw [Complex.star_def, Complex.mul_conj] | |
| rfl | |
| omit [DecidableEq I] in | |
| lemma factorQuadratic_eq (B : Matrix I I β) (x : I β β) : | |
| factorQuadratic B x = quadratic (B * B.conjTranspose) x := by | |
| simp only [factorQuadratic, quadratic, Matrix.mul_apply, Matrix.conjTranspose_apply, | |
| normSq_eq_re, star_sum, star_mul, Complex.re_sum] | |
| simp only [Finset.sum_mul, Finset.mul_sum, Complex.re_sum] | |
| conv_rhs => rw [Finset.sum_comm] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro w _ | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| apply Finset.sum_congr rfl | |
| intro v _ | |
| congr 1 | |
| ring | |
| lemma sqrt_factorQuadratic (A : Matrix I I β) (hA : A.PosSemidef) (x : I β β) : | |
| factorQuadratic (CFC.sqrt A) x = quadratic A x := by | |
| rw [factorQuadratic_eq, (Matrix.nonneg_iff_posSemidef.mp (CFC.sqrt_nonneg A)).isHermitian.eq, | |
| CFC.sqrt_mul_sqrt_self A hA.nonneg] | |
| lemma sqrt_trace (A : Matrix I I β) (hA : A.PosSemidef) : | |
| (β w, β v, Complex.normSq (CFC.sqrt A w v)) = A.trace.re := by | |
| have hs : (CFC.sqrt A).conjTranspose = CFC.sqrt A := | |
| (Matrix.nonneg_iff_posSemidef.mp (CFC.sqrt_nonneg A)).isHermitian.eq | |
| have he : CFC.sqrt A * (CFC.sqrt A).conjTranspose = A := by | |
| rw [hs, CFC.sqrt_mul_sqrt_self A hA.nonneg] | |
| conv_rhs => rw [β he] | |
| simp only [Matrix.trace, Matrix.diag, Complex.re_sum, Matrix.mul_apply, | |
| Matrix.conjTranspose_apply] | |
| apply Finset.sum_congr rfl | |
| intro w _ | |
| apply Finset.sum_congr rfl | |
| intro v _ | |
| exact normSq_eq_re _ | |
| end RowColumn.MatrixState | |
| noncomputable section | |
| open scoped BigOperators Classical MatrixOrder Matrix.Norms.L2Operator ComplexOrder | |
| namespace RowColumn.MatrixState | |
| variable {S C : Type*} [Fintype S] [DecidableEq S] [Fintype C] [DecidableEq C] | |
| def tensorMatrix (M : S β Matrix C C β) : Matrix (S β C) (S β C) β := | |
| fun w v => β i, M i (w i) (v i) | |
| omit [DecidableEq C] in | |
| lemma tensorMatrix_mul (A B : S β Matrix C C β) : | |
| tensorMatrix A * tensorMatrix B = tensorMatrix (fun i => A i * B i) := by | |
| ext w v | |
| simp only [tensorMatrix, Matrix.mul_apply, β Finset.prod_mul_distrib] | |
| exact (Fintype.prod_sum (fun i : S => fun c : C => A i (w i) c * B i c (v i))).symm | |
| omit [DecidableEq S] [Fintype C] [DecidableEq C] in | |
| lemma tensorMatrix_star (A : S β Matrix C C β) : | |
| (tensorMatrix A).conjTranspose = tensorMatrix (fun i => (A i).conjTranspose) := by | |
| ext w v | |
| simp [tensorMatrix, Matrix.conjTranspose_apply, star_prod] | |
| omit [DecidableEq C] in | |
| lemma tensorMatrix_trace (A : S β Matrix C C β) : | |
| (tensorMatrix A).trace = β i, (A i).trace := by | |
| simp only [tensorMatrix, Matrix.trace, Matrix.diag] | |
| exact (Fintype.prod_sum (fun i : S => fun c : C => A i c c)).symm | |
| omit [DecidableEq S] [Fintype C] in | |
| lemma tensorMatrix_one : tensorMatrix (fun _ : S => (1 : Matrix C C β)) = 1 := by | |
| ext w v | |
| by_cases he : w = v | |
| Β· subst v; simp [tensorMatrix] | |
| Β· have hn : β i, w i β v i := Function.ne_iff.mp he | |
| obtain β¨i,hiβ© := hn | |
| rw [Matrix.one_apply_ne he] | |
| exact Finset.prod_eq_zero (Finset.mem_univ i) (Matrix.one_apply_ne hi) | |
| lemma tensorMatrix_posSemidef (A : S β Matrix C C β) (hA : β i, (A i).PosSemidef) : | |
| (tensorMatrix A).PosSemidef := by | |
| let B := fun i => CFC.sqrt (A i) | |
| have hb (i : S) : (B i).conjTranspose * B i = A i := by | |
| rw [(Matrix.nonneg_iff_posSemidef.mp (CFC.sqrt_nonneg (A i))).isHermitian.eq] | |
| exact CFC.sqrt_mul_sqrt_self _ (hA i).nonneg | |
| have he : (tensorMatrix B).conjTranspose * tensorMatrix B = tensorMatrix A := by | |
| rw [tensorMatrix_star, tensorMatrix_mul] | |
| simp_rw [hb] | |
| rw [β he] | |
| exact Matrix.posSemidef_conjTranspose_mul_self _ | |
| def letterMatrix (z : C Γ C β β) : Matrix C C β := fun c d => z (c,d) | |
| /-- A purification letter z is an actual one-slot substate after partial trace. -/ | |
| def gramState (z : C Γ C β β) : Matrix C C β := | |
| letterMatrix z * (letterMatrix z).conjTranspose | |
| omit [DecidableEq C] in | |
| lemma gramState_posSemidef (z : C Γ C β β) : (gramState z).PosSemidef := by | |
| have hh := Matrix.posSemidef_conjTranspose_mul_self | |
| (letterMatrix z).conjTranspose | |
| simpa only [Matrix.conjTranspose_conjTranspose, gramState] using hh | |
| omit [DecidableEq C] in | |
| lemma gramState_trace (z : C Γ C β β) : | |
| (gramState z).trace.re = β p : C Γ C, Complex.normSq (z p) := by | |
| rw [Fintype.sum_prod_type] | |
| simp only [gramState, letterMatrix, Matrix.trace, Matrix.diag, Matrix.mul_apply, | |
| Matrix.conjTranspose_apply, Complex.re_sum] | |
| apply Finset.sum_congr rfl | |
| intro c _ | |
| apply Finset.sum_congr rfl | |
| intro d _ | |
| rw [Complex.star_def, Complex.mul_conj] | |
| rfl | |
| omit [DecidableEq C] in | |
| lemma gramState_parity_supported (odd : C β Prop) [DecidablePred odd] | |
| (z : C Γ C β β) (hz : β c d, Β¬ (odd c β odd d) β z (c,d) = 0) | |
| (c d : C) (hc : Β¬ (odd c β odd d)) : gramState z c d = 0 := by | |
| simp only [gramState, Matrix.mul_apply, letterMatrix, Matrix.conjTranspose_apply] | |
| apply Finset.sum_eq_zero | |
| intro e _ | |
| by_cases he : odd c β odd e | |
| Β· have hd : Β¬ (odd d β odd e) := fun h => hc (he.trans h.symm) | |
| simp [hz d e hd] | |
| Β· simp [hz c e he] | |
| end RowColumn.MatrixState | |
| namespace RowColumn.Postselection | |
| open scoped BigOperators Classical MatrixOrder Matrix.Norms.L2Operator ComplexOrder | |
| open MatrixState WordOrbits | |
| variable {S C : Type*} [Fintype S] [DecidableEq S] [Fintype C] [DecidableEq C] | |
| def reindexWord (p : Equiv.Perm S) : Equiv.Perm (S β C) where | |
| toFun w := fun i => w (p i) | |
| invFun w := fun i => w (p.symm i) | |
| left_inv := by intro w; ext i; simp | |
| right_inv := by intro w; ext i; simp | |
| omit [DecidableEq C] in | |
| lemma productPurifier_quadratic (z : C Γ C β β) (x : (S β C) β β) : | |
| purifierQuadratic (productPurifier z) x = | |
| quadratic (tensorMatrix (fun _ : S => gramState z)) x := by | |
| change factorQuadratic (tensorMatrix (fun _ : S => letterMatrix z)) x = _ | |
| rw [factorQuadratic_eq, tensorMatrix_star, tensorMatrix_mul] | |
| rfl | |
| def localAmplitude (aβ : S β C Γ C) (odd : C β Prop) [DecidablePred odd] | |
| (q : Types (S := S) (A := C Γ C)) (ΞΈ : Phases (C Γ C) (Fintype.card S)) : C Γ C β β := | |
| truncateAmplitude (fun p : C Γ C => odd p.1 β odd p.2) | |
| (twistedAmplitude (typeRepresentative aβ q) ΞΈ) | |
| def localState (aβ : S β C Γ C) (odd : C β Prop) [DecidablePred odd] | |
| (q : Types (S := S) (A := C Γ C)) (ΞΈ : Phases (C Γ C) (Fintype.card S)) : Matrix C C β := | |
| gramState (localAmplitude aβ odd q ΞΈ) | |
| omit [DecidableEq S] in | |
| lemma localState_positive (aβ : S β C Γ C) (odd : C β Prop) [DecidablePred odd] | |
| (q : Types (S := S) (A := C Γ C)) (ΞΈ : Phases (C Γ C) (Fintype.card S)) : | |
| (localState aβ odd q ΞΈ).PosSemidef := gramState_posSemidef _ | |
| omit [DecidableEq S] in | |
| lemma localState_trace_le_one (aβ : S β C Γ C) (odd : C β Prop) [DecidablePred odd] | |
| (hn : 0 < Fintype.card S) | |
| (q : Types (S := S) (A := C Γ C)) (ΞΈ : Phases (C Γ C) (Fintype.card S)) : | |
| (localState aβ odd q ΞΈ).trace.re β€ 1 := by | |
| rw [localState, gramState_trace] | |
| exact truncated_twisted_subnormalized _ _ hn _ | |
| omit [DecidableEq S] in | |
| lemma localState_even (aβ : S β C Γ C) (odd : C β Prop) [DecidablePred odd] | |
| (q : Types (S := S) (A := C Γ C)) (ΞΈ : Phases (C Γ C) (Fintype.card S)) | |
| (c d : C) (hp : Β¬ (odd c β odd d)) : localState aβ odd q ΞΈ c d = 0 := by | |
| apply gramState_parity_supported odd _ _ c d hp | |
| intro c d h | |
| simp [localAmplitude, truncateAmplitude, h] | |
| /-- Quantitative positive mixture of genuine even identical-slot states for a | |
| PSD matrix invariant under unsigned slot permutations and supported on physical | |
| parity blocks. The polynomial includes only the explicitly finite type count; | |
| no structural duality or postselection axiom is assumed. -/ | |
| theorem positive_state_postselection (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) (w v : S β C), | |
| A (fun i => w (p i)) (fun i => v (p i)) = 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 (C Γ C)) : β) / | |
| (Fintype.card (Phases (C Γ C) (Fintype.card S)) : β) * | |
| β q : Types (S := S) (A := C Γ C), | |
| β ΞΈ : Phases (C Γ C) (Fintype.card S), | |
| quadratic (tensorMatrix (fun _ : S => localState aβ odd q ΞΈ)) x) := by | |
| let B : Matrix (S β C) (S β C) β := CFC.sqrt A | |
| have hi (p : Equiv.Perm S) (w v : S β C) : | |
| B (fun i => w (p i)) (fun i => v (p i)) = B w v := | |
| sqrt_permutation_invariant A hA (reindexWord p) (hinv p) 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 h := matrix_postselection aβ hn (fun p : C Γ C => odd p.1 β odd p.2) | |
| B hi hz x | |
| change factorQuadratic B x β€ _ at h | |
| change factorQuadratic (CFC.sqrt A) x β€ _ at h | |
| rw [sqrt_factorQuadratic A hA] at h | |
| have ht : purifierTrace B = A.trace.re := sqrt_trace A hA | |
| rw [ht] at h | |
| simpa only [productPurifier_quadratic, localState, localAmplitude] using h | |
| end RowColumn.Postselection | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end OAI | |