import Mathlib import OAI.Probability.CoordinateSweeps.Perturbation namespace OAI open scoped Matrix.Norms.L2Operator namespace CoordinateSweeps lemma moment_le_exp_of_logMoment_le {t B : ℝ} (ht : 0≤t) (h : logMoment t ≤ (B:EReal)) : t ≤ Real.exp B := by by_cases hz : t=0 · rw [hz]; exact (Real.exp_pos _).le · rw [logMoment,ite_eq_right hz] at h have hh : Real.log t ≤ B := by exact_mod_cast h simpa only [Real.exp_log (lt_of_le_of_ne ht (Ne.symm hz))] using Real.exp_le_exp.mpr hh lemma logMoment_le_of_moment_le_exp {t B : ℝ} (ht : 0≤t) (h : t≤Real.exp B) : logMoment t ≤ (B:EReal) := by simpa only [Real.log_exp] using logMoment_le_of_le ht (Real.exp_pos B) h end CoordinateSweeps namespace CoordinateSweeps.Grid.Holes open SparseScalar SparseDimension ScalarInduction variable {G : Grid} {h r : ℕ} (H : G.Holes h) lemma conditionalAverage_free_cancel (hf : H.Feasible) (z : ℝ) (σ : UnitaryIrrep H.stabilizer) : H.conditionalAverage hf z ((σ.pullback H.stabilizerFreeEquiv.symm).pullback H.stabilizerFreeEquiv)= H.conditionalAverage hf z σ := by rw [H.conditionalAverage_eq_sum,H.conditionalAverage_eq_sum] apply Finset.sum_congr rfl intro ω hω change (_:ℂ) • σ.matrix (H.stabilizerFreeEquiv.symm (H.stabilizerFreeEquiv (H.residual hf ω)))=_ rw [MulEquiv.symm_apply_apply] /-- Entire nonautomatic sparse-dimension branch of the conditional main, with the actual stabilizer irrep, actual feasible paths and a common real z interval. -/ theorem conditional_sparse_main (hr : ScaleLarge r) (hrS : ScaleReady r) (hG : G.Allowed r) (hS : MainSizeReady SparseScalar.q G.size) (hf : H.Feasible) {zStar : ℝ} (hζ : SparsePerturb r zStar) {z : ℝ} (hz : z∈Set.Icc 0 zStar) (σ : UnitaryIrrep H.stabilizer) (hσ : σ.dimension≠1) (ha : ¬ (1+c G.size)*Real.log σ.dimension ≤ e G.size*h*Real.log G.size-H.cost) (hF : Real.log σ.dimension < (G.size:ℝ)^(1-a/4)) : schattenMoment SparseScalar.q (H.conditionalAverage hf z σ) ≤ Real.exp (-c G.size*Real.log σ.dimension+e G.size*h*Real.log G.size-H.cost) := by let ρ := σ.pullback H.stabilizerFreeEquiv.symm obtain ⟨k,t,hkt,ht,hD,hkM,⟨L⟩⟩ := exists_level ρ have hΩ : Fintype.card (H.FreeAt 0)≤G.size := by rw [H.card_freeAt]; exact Nat.sub_le _ _ have hks := hkM.trans hΩ have hlogs := level_log_bounds ρ G.size_pos hΩ hkt ht hD change Real.log σ.dimension≤k*Real.log G.size ∧ (k:ℝ)≤4*Real.log σ.dimension at hlogs have hk : 1≤k := by by_contra hh have he : k=0 := by omega rw [he,pow_zero] at hD have hdim : σ.dimension=1 := by have hh0:=σ.positive; change σ.dimension≤1 at hD; omega exact hσ hdim have hL := (scale_coefficients hr G hG).1 have hc := (scale_coefficients hr G hG).2.1 have hc1 : c G.size≤1 := hc.trans (by norm_num [c0,a]) have hF0 : 0≤Real.log σ.dimension := Real.log_nonneg (by exact_mod_cast σ.positive) have hallow := H.allowance_lower hr hG have hn := lt_of_not_ge ha have hhh : (h:ℝ)*Real.log G.size ≤ K0*Real.log σ.dimension := by have hm := mul_le_mul_of_nonneg_right hc1 hF0 norm_num [e0,a,K0] at hallow ⊢ nlinarith have hh : (h:ℝ)≤K0*k := by have hm := mul_le_mul_of_nonneg_left hlogs.1 (by norm_num [K0] : 0≤K0) exact (mul_le_mul_iff_right₀ hL).mp (by nlinarith) have hsp : ((h+k:ℕ):ℝ)≤(G.size:ℝ)^(1-theta) := by have hh0 := (Nat.cast_nonneg h : (0:ℝ)≤h) have hhle : (h:ℝ)≤K0*Real.log σ.dimension := by nlinarith [hS.one] have hsum : ((h+k:ℕ):ℝ)≤(100004:ℝ)*Real.log σ.dimension := by push_cast norm_num [K0] at hhle linarith [hlogs.2] apply hsum.trans apply (mul_le_mul_of_nonneg_left hF.le (by norm_num : (0:ℝ)≤100004)).trans simpa only [theta] using hS.sparse have hnorm := H.level_sparse_norm hrS hG hf hζ hz hk hks hh hsp ρ L rw [show ρ=σ.pullback H.stabilizerFreeEquiv.symm from rfl,H.conditionalAverage_free_cancel] at hnorm let : NeZero σ.dimension := ⟨σ.positive.ne'⟩ have hp := pow_le_pow_left₀ (norm_nonneg (H.conditionalAverage hf z σ)) hnorm (2*SparseScalar.q) calc _ ≤ (σ.dimension:ℝ)*‖H.conditionalAverage hf z σ‖^(2*SparseScalar.q) := trace_moment_le _ _ _ ≤ (σ.dimension:ℝ)*((G.size:ℝ)^(-rho*k))^(2*SparseScalar.q) := mul_le_mul_of_nonneg_left hp (Nat.cast_nonneg _) _ = Real.exp (Real.log σ.dimension-4*k*Real.log G.size) := by rw [rpow_exp _ _ (by exact_mod_cast G.size_pos),←Real.exp_nat_mul] nth_rw 1 [←Real.exp_log (by exact_mod_cast σ.positive : (0:ℝ)<σ.dimension)] rw [←Real.exp_add] congr 1 norm_num [SparseScalar.q,rho] ring _ ≤ Real.exp (-3*Real.log σ.dimension) := Real.exp_le_exp.mpr (by nlinarith [hlogs.1]) _ ≤ _ := Real.exp_le_exp.mpr (by have hm := mul_le_mul_of_nonneg_right hc1 hF0 have ha0 := H.allowance_nonneg hr hG linarith) end CoordinateSweeps.Grid.Holes namespace CoordinateSweeps /-- Real exponential version of the exact conditional main estimate, used only as the induction predicate; its equivalence to logMoment includes zero moments. -/ def MomentBound (G : Grid) (q : ℕ) (z : ℝ) : Prop := ∀ (h : ℕ) (H : G.Holes h) (hf : H.Feasible) (σ : UnitaryIrrep H.stabilizer), schattenMoment q (H.conditionalAverage hf z σ) ≤ Real.exp (-c G.size*Real.log σ.dimension+e G.size*h*Real.log G.size-H.cost) noncomputable def cHat (s : ℕ) : ℝ := c s+1/(20*Real.sqrt (Real.log s)) noncomputable def eHat (s : ℕ) : ℝ := e s-1/(20*Real.sqrt (Real.log s)) end CoordinateSweeps namespace CoordinateSweeps.Grid.Holes open ScalarInduction YoungCorner variable {A B : Grid} {r h q : ℕ} (H : (concat A B).Holes h) theorem hook_auxiliary (hr : ScaleLarge r) (hA : A.Allowed r) (hB : B.Allowed r) (hAB : A.b≤B.b) (hBA : B.b≤2*A.b) (hq : 1≤q) (hS : MainSizeReady q (concat A B).size) (z : ℝ) (hIA : MomentBound A q z) (hIB : MomentBound B q z) (hf : H.Feasible) (σ : UnitaryIrrep H.stabilizer) (p : ℕ) (hp : 0.trans_lt (removedPart_rank_lt μ p x) have hL0 : (0:ℝ) (2:ℝ)^r) atTop atTop := tendsto_pow_atTop_atTop_of_one_lt (by norm_num) have hall : ∀ᶠ r : ℕ in atTop, ScaleLarge r ∧ SparseScalar.ScaleReady r ∧ S≤(2:ℝ)^r := by filter_upwards [eventually_scaleLarge,SparseScalar.eventually_scaleReady, hp.eventually (eventually_ge_atTop S)] with r h1 h2 h3 exact ⟨h1,h2,h3⟩ obtain ⟨r,hr,hs,ht⟩ := hall.exists exact ⟨r,hr,hs,fun G hG => hS G.size (ht.trans (G.pow_r_le_size hG))⟩ /-- Strong induction on the literal ordered coordinate count; every child is an actual conditioned row/column grid, not a surrogate representation law. -/ theorem all_grid_moment {r : ℕ} (hr : ScaleLarge r) (hrS : SparseScalar.ScaleReady r) (hS : ∀ G : Grid, G.Allowed r → ScalarInduction.MainSizeReady SparseScalar.q G.size) {zStar : ℝ} (hζ : SparsePerturb r zStar) {z : ℝ} (hz : z∈Set.Icc 0 zStar) : ∀ G : Grid, G.Allowed r → MomentBound G SparseScalar.q z := by have hzB : z≤baseZeta r := hz.2.trans hζ.2.1 have hz1 : z<1 := lt_of_le_of_lt (hzB.trans (baseZeta_le_half r)) (by norm_num) have hq : 1≤SparseScalar.q := by norm_num [SparseScalar.q] have aux : ∀ n : ℕ, ∀ G : Grid, G.b=n → G.Allowed r → MomentBound G SparseScalar.q z := by intro n induction n using Nat.strong_induction_on with | h n ih => intro G hb hG h H hf σ have hnonneg := H.conditionalMoment_nonneg hf z σ SparseScalar.q by_cases hone : G.b=1 · exact moment_le_exp_of_logMoment_le hnonneg (Grid.conditional_main_b_one hr G hone hG H hf hz.1 hzB σ hq) by_cases hdim : σ.dimension=1 · exact moment_le_exp_of_logMoment_le hnonneg (H.conditional_dimension_one hr hG hf hz.1 hz1 σ hdim SparseScalar.q) by_cases haut : (1+c G.size)*Real.log σ.dimension ≤ e G.size*h*Real.log G.size-H.cost · exact moment_le_exp_of_logMoment_le hnonneg (H.conditional_automatic hf hz.1 hz1 σ SparseScalar.q haut) by_cases hF : Real.log σ.dimension < (G.size:ℝ)^(1-a/4) · exact H.conditional_sparse_main hr hrS hG (hS G hG) hf hζ hz σ hdim haut hF have hlarge : (G.size:ℝ)^(1-a/4)≤Real.log σ.dimension := le_of_not_gt hF have hb2 : 2≤G.b := by have hh:=G.positive; omega obtain ⟨A,B,hAB,hA,hB,hab,hba⟩ := G.exists_half_concat hb2 have hallowed : A.Allowed r ∧ B.Allowed r := (Grid.concat_allowed A B r).mp (by simpa only [hAB] using hG) have hIA : MomentBound A SparseScalar.q z := ih A.b (by omega) A rfl hallowed.1 have hIB : MomentBound B SparseScalar.q z := ih B.b (by omega) B rfl hallowed.2 subst G exact H.conditional_large_main hr hallowed.1 hallowed.2 hab hba hq (hS _ hG) z hz.1 hz1 (fun j g => (lineLaw_base_bounds (hG j).2 hz.1 hzB g).1) (fun j g => (lineLaw_base_bounds (hG j).2 hz.1 hzB g).2) hIA hIB hf σ hlarge exact fun G hG => aux G.b G rfl hG /-- Manuscript03 thm:conditional / ac:main, with c₀=e₀=a/100, a=1/100, natural logarithms, unnormalized integer Schatten moments, all feasible disjoint paths (including none and all), and log(0)=−∞. -/ theorem conditional_main : ConditionalMain := by obtain ⟨r,hr,hrS,hS⟩ := exists_main_scale obtain ⟨zStar,hζ⟩ := exists_sparsePerturb r have hq : 1≤SparseScalar.q := by norm_num [SparseScalar.q] refine ⟨r,SparseScalar.q,zStar,hr.1,hq,hζ.1,hζ.2.1.trans (baseZeta_le_half r),?_⟩ intro G hG h H hf z hz σ exact logMoment_le_of_moment_le_exp (H.conditionalMoment_nonneg hf z σ SparseScalar.q) (all_grid_moment hr hrS hS hζ hz G hG h H hf σ) end CoordinateSweeps end OAI