import Mathlib import OAI.Probability.LogConcave.OraclePrograms.MeanCorrect import OAI.Probability.LogConcave.OraclePrograms.CalibratedMeanCircuit import OAI.Probability.LogConcave.OraclePrograms.PairDistBounds import OAI.Probability.LogConcave.OraclePrograms.ShiftInvariant import OAI.Probability.LogConcave.Sampling.PrependTape import OAI.Probability.LogConcave.Dynamics.ProbabilityFlowGrowth namespace OAI section noncomputable section namespace LogConcaveSampling.OracleCompiler.ReservedProgram open MeasureTheory ProbabilityTheory Function Coupling open scoped Classical NNReal variable {d : ℕ} def fullTape (k : ℕ) (z : (Fin k → Point d) × Point d) : Fin (k+1) → Point d := Fin.append z.1 (fun _ => z.2) lemma fullTape_preserving (k : ℕ) : MeasurePreserving (fullTape (d:=d) k) ((gaussianTape d k).prod (stdGaussian (Point d))) (gaussianTape d (k+1)) := by exact (MeanTree.appendSlots_preserving (stdGaussian (Point d)) k 1).comp ((MeasurePreserving.id _).prod (oneSlot_preserving (stdGaussian (Point d)))) lemma full_fixedSeed {V : Point d → ℝ} (S : ReservedProgram d) {K : ℝ} (h : ∀x y g,‖S.pre.run V (x,g)-S.pre.run V (y,g)‖≤K*‖x-y‖) : ∀x y g,‖S.full.program.run V (x,g)-S.full.program.run V (y,g)‖≤K*‖x-y‖ := by intro x y g have hx := full_run S V x g have hy := full_run S V y g rw [hx,hy,add_sub_add_right_eq_sub] exact h x y _ lemma anchor_squared {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) (x : Point d) (S : ReservedProgram d) {r T η B : ℝ} (hr : 0≤r) (hl : (lam:ℝ)*r^2<1) (hT : 0≤T) (hη : T*η=Real.sqrt (1-T^2)) (hreserve : S.reserve=η/2) (hpre : SquaredAt (gaussianTape d S.slots) ((gibbs (primitivePotential F x r)).prod (stdGaussian (Point d))) (fun g => S.pre.run F (x,g)) (fun z => z.1+(Real.sqrt 3*η/2) • z.2) B) : SquaredAt (gaussianTape d S.full.slots) (interpolationLaw F x r T) (fun g => T • S.full.program.run F (x,g)) id (T^2*B) := by let := probability_gibbs_of_partition (partition_pos_of_continuous (hF.continuous_potential x r)).ne' (partition_ne_top_of_integrable (hF.integrable_exp_neg_potential x hr hl)) have hV : Measurable (fun z => (F z,gradient F z)) := hF.smooth.continuous.measurable.prodMk hF.gradient_lipschitz.continuous.measurable have hf : Measurable (fun g => S.pre.run F (x,g)) := (S.pre.measurable_run F hV).comp (by fun_prop) have hfull : Measurable (fun g => T • S.full.program.run F (x,g)) := by have hh := (S.full.program.measurable_run F hV).comp (show Measurable (fun z : Fin S.full.slots → Point d => (x,z)) by fun_prop) fun_prop let H : Point d → Point d → Point d := fun a g => T • (a+S.reserve • g) have hh := hpre.shared_lipschitz (stdGaussian (Point d)) hf (by fun_prop) hT H (by fun_prop) (fun a b g => by simp only [H,←smul_sub,add_sub_add_right_eq_sub,norm_smul,Real.norm_eq_abs,abs_of_nonneg hT]; exact le_rfl) have hnoise := smoothing_add_gaussian ((gibbs (primitivePotential F x r)).prod (stdGaussian (Point d))) (gibbs (primitivePotential F x r)) (fun z => z.1+(Real.sqrt 3*η/2) • z.2) id (by fun_prop) measurable_id (Real.sqrt 3*η/2) (η/2) η (by rw [div_pow,mul_pow,Real.sq_sqrt (by norm_num : (0:ℝ)≤3),div_pow]; ring) rfl have hnoise' := congrArg (Measure.map (fun z : Point d => T • z)) hnoise rw [Measure.map_map (by fun_prop) (by fun_prop),Measure.map_map (by fun_prop) (by fun_prop)] at hnoise' have hlaw : (((gibbs (primitivePotential F x r)).prod (stdGaussian (Point d))).prod (stdGaussian (Point d))).map (fun z => H (z.1.1+(Real.sqrt 3*η/2) • z.1.2) z.2)=interpolationLaw F x r T := by convert hnoise' using 1 · simp only [H,hreserve,comp_def] · simp only [comp_def,smul_add,smul_smul,hη,interpolationLaw,id_eq] have hp := hh.reindex (fullTape S.slots) (fun z => H (z.1.1+(Real.sqrt 3*η/2) • z.1.2) z.2) (fullTape_preserving S.slots).measurable (by fun_prop) (fun g : Fin (S.slots+1) → Point d => T • S.full.program.run F (x,g)) id hfull measurable_id (fun z => by rw [full_run]; simp only [fullTape,Fin.append_left,Fin.append_right,H]) (fun _ => rfl) rw [(fullTape_preserving S.slots).map_eq,hlaw] at hp exact hp end LogConcaveSampling.OracleCompiler.ReservedProgram end end section noncomputable section namespace LogConcaveSampling.OracleCompiler.CircuitParameters open MeasureTheory ProbabilityTheory MeanTree Coupling Function open scoped Classical NNReal variable (C : CircuitParameters) {d : ℕ} theorem meanFrom_squared {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) {q Kf Ki Ks ef ei es ηmin r σ en : ℝ} (hd : 1 ≤ d) (hs : MeanSize lam q r σ) (hl : q ≤ 1/4) (hL : (lam:ℝ)*r ≤ 1) (hD : 1 ≤ C.D) (hψ : 0 ≤ C.ψ) (hA : C.A=C.actualA) (hAf : C.Af=C.actualAf) (hKf : 0 ≤ Kf) (hKi : 0 ≤ Ki) (hef : 0 < ef) (hei : 0 ≤ ei) (hsmall : (lam:ℝ)*C.meanCenterBudget r σ*(2*Real.pi+2) ≤ 1) (hcon : 4*(C.meanCenterBudget r σ)^2*((lam:ℝ)*Ki)^2 ≤ 1) (hRT : Real.sqrt (1-C.T^2) ≤ C.T) (hη : ηmin ≤ Real.sqrt (1-C.T^2)/C.T) (hm : C.m=C.n) (hnc : C.nc=C.n) (hNc : C.Nc=C.N) (Mf Mi : ℝ → ℝ → SeedProgram d) (S : ℝ → ℝ → ReservedProgram d) (B : ℕ) (hBD : (B:ℝ) ≤ C.D^2) (hbudget : ∀(s : Bool) r τ,MeanBudget B r ((if s then Mf else Mi) r τ)) (hf : MeanCorrect F lam ((1+4*C.Af)*Real.sqrt (1-C.T^2)*q) Kf ef Mf) (hi : MeanCorrect F lam (q*(1+16*C.D*C.A/Real.sqrt (1-C.T^2))) Ki ei Mi) (hS : SampleCorrect F lam (q/Real.sqrt (1-C.T^2)) Ks es ηmin S) (hrsv : (S r (Real.sqrt (1-C.T^2)/C.T)).reserve=(Real.sqrt (1-C.T^2)/C.T)/2) (x : Point d) (hcert : CalibratedMeanCircuit (r:=r) (T:=C.T) (h:=C.h) (ψ:=C.ψ) (s:=σ/2) hF x hs.1 (by linarith [hs.2.2.2.1] : (lam:ℝ)*r^2 ≤ 1/2) (by linarith [C.T_lower]) C.T_upper C.h_pos C.n C.N (en^2)) : let dep := (depth (C.meanTree (d:=d) r σ):ℝ) let a := 2*(1+2*dep)*(C.Af*Kf*q*ei+ef) SquaredAt (gaussianTape d (C.meanFrom Mf Mi S r σ).slots) (stdGaussian (Point d)) (fun g => (C.meanFrom Mf Mi S r σ).program.run F (x,g)) (fun g => primitiveExpectedField F x r+σ • g) (2*(C.Af*((lam:ℝ)*Kf)*dep*r)^2*(C.T^2*(es^2*(circuitD F x)^2))+ 80*(σ*a)^2*((20+16*circuitGrowthConstant^2)*(circuitD F x)^2)+ 8*((σ/2)*circuitD F x)^2*en^2) := by let dep := (depth (C.meanTree (d:=d) r σ):ℝ) let a := 2*(1+2*dep)*(C.Af*Kf*q*ei+ef) let P : Bool → ℝ → ℝ → Prop := fun s => if s then MeanSize lam ((1+4*C.Af)*Real.sqrt (1-C.T^2)*q) else MeanSize lam (q*(1+16*C.D*C.A/Real.sqrt (1-C.T^2))) let M : Bool → ℝ → ℝ → SeedProgram d := fun s => if s then Mf else Mi let E := compileDeclaredRoot C.D (C.meanCenterBudget r σ) C.Af Mf Mi (C.meanTree (d:=d) r σ) (Real.sqrt 3*σ/2) have hA0 : 0 < C.A := hA ▸ C.actualA_pos have hAf0 : 0 < C.Af := hAf ▸ C.actualAf_pos have hbud : 0 ≤ C.meanCenterBudget r σ := by unfold meanCenterBudget; positivity [hs.1,hs.2.2.1] have hLip : (lam:ℝ)*Ki*C.meanCenterBudget r σ ≤ 1 := by have hn : 0 ≤ (lam:ℝ)*Ki*C.meanCenterBudget r σ := by positivity nlinarith [sq_nonneg ((lam:ℝ)*Ki*C.meanCenterBudget r σ)] have hrad : (lam:ℝ)*r^2 ≤ 1/4 := hs.2.2.2.1.trans hl have hT : 0 ≤ C.T := by linarith [C.T_lower] have ha : 0 < a := by dsimp [a,dep]; positivity [hs.nonneg lam.coe_nonneg] have hv := C.meanTree_valid (d:=d) lam.coe_nonneg hs (by linarith) hψ hA hAf have hrdy := hv.shiftReady (P true) (P false) (fun _ _ h => h.1.ne') (fun _ _ h => h.1.ne') _ _ have hpos := C.meanCompiled_variation hs.1 hs.2.2.1 hψ hA hAf (mul_nonneg lam.coe_nonneg hKf) (mul_nonneg lam.coe_nonneg hKi) hLip F P M hf.lip hi.lip (Real.sqrt 3*σ/2) hrdy obtain ⟨Lf,hLf,hfl⟩ := C.meanCompiled_anchor_lipschitz hs.1 hs.2.2.1 hψ hA hAf (mul_nonneg lam.coe_nonneg hKf) (mul_nonneg lam.coe_nonneg hKi) hLip F P M hf.lip hi.lip (Real.sqrt 3*σ/2) hrdy x obtain ⟨Lg,hgl⟩ := C.meanTree_anchor_lipschitz (σ:=σ) hF hs.1 hrad x have hc (z : Point d × Point d) := C.meanCompiled_scaled hF hs (by linarith) hL hD hψ hA hAf hKf hKi hef.le hei hsmall hcon Mf Mi B hBD hbudget hf hi x z.1 z.2 have hanc := C.mean_anchor_size lam.coe_nonneg hs hRT have he := hS.error _ _ hanc hη x have hanc' := ReservedProgram.anchor_squared hF x _ hs.1.le (by linarith : (lam:ℝ)*r^2 < 1) hT (show C.T*(Real.sqrt (1-C.T^2)/C.T)=Real.sqrt (1-C.T^2) by field_simp [ne_of_gt (by linarith [C.T_lower] : 0 (C.meanTree r σ).eval F (x,z)) w (primitiveExpectedField F x r) σ (Real.sqrt 3*σ/2) hgl.continuous.measurable hw (pairGauge (circuitD F x)) (one_le_pairGauge (circuitD_nonneg F x)) (pairGauge_change _) hmoment.1 (show 0 ≤ C.Af*((lam:ℝ)*Kf)*dep*r by positivity [hs.1]) hLf Lg.coe_nonneg (mul_pos hs.2.2.1 ha) hanc' (hpos.2 x) hfl (fun z z' => by simpa only [dist_eq_norm] using hgl.dist_le_mul z z') hc hwi hnum hlaw unfold meanFrom rw [dite_eq_left hs.1] apply hp.mono have hh := mul_le_mul_of_nonneg_left hmoment.2 (show 0 ≤ 80*(σ*a)^2 by positivity) calc _ ≤ 2*(C.Af*((lam:ℝ)*Kf)*dep*r)^2*(C.T^2*(es^2*(circuitD F x)^2))+ 80*(σ*a)^2*((20+16*circuitGrowthConstant^2)*(circuitD F x)^2)+ 8*((σ/2*circuitD F x)^2*en^2) := add_le_add (add_le_add le_rfl hh) le_rfl _ = _ := by ring end LogConcaveSampling.OracleCompiler.CircuitParameters end end section noncomputable section namespace LogConcaveSampling.OracleCompiler.CircuitParameters open MeasureTheory ProbabilityTheory MeanTree Coupling Function open scoped Classical NNReal variable (C : CircuitParameters) {d : ℕ} theorem sampleFrom_squared {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) {q Kf Ki ef ei r η en : ℝ} (hd : 1 ≤ d) (hs : SampleSize lam q r η) (hl : q ≤ 1/4) (hL : (lam:ℝ)*r ≤ 1) (hRη : Real.sqrt (1-C.T^2) ≤ η) (hD : 1 ≤ C.D) (hA : C.A=C.actualA) (hAf : C.Af=C.actualAf) (hKf : 0 ≤ Kf) (hKi : 0 ≤ Ki) (hef : 0 < ef) (hei : 0 ≤ ei) (hsmall : (lam:ℝ)*C.sampleCenterBudget r*(2*Real.pi+2) ≤ 1) (hcon : 4*(C.sampleCenterBudget r)^2*((lam:ℝ)*Ki)^2 ≤ 1) (Mf Mi : ℝ → ℝ → SeedProgram d) (B : ℕ) (hBD : (B:ℝ) ≤ C.D^2) (hbudget : ∀(s : Bool) r τ,MeanBudget B r ((if s then Mf else Mi) r τ)) (hf : MeanCorrect F lam ((1+4*C.Af)*q) Kf ef Mf) (hi : MeanCorrect F lam (q*(1+16*C.D*C.A/Real.sqrt (1-C.T^2))) Ki ei Mi) (x : Point d) (hlr : (lam:ℝ)*r^2 ≤ 1/2) (hnumi : Integrable (fun Y => ‖sampleMeanCircuit F x r (sampleCorrelation η) C.h (C.n+1) C.N (C.sampleEndpoint η hs.2.2.1 hs.2.2.2.1) Y- (sampleCorrelation η)⁻¹ • fullProbabilityFlow hF x hs.1.le hlr (sampleCorrelation η) Y‖^2) (stdGaussian (Point d))) (hnum : (∫Y,‖sampleMeanCircuit F x r (sampleCorrelation η) C.h (C.n+1) C.N (C.sampleEndpoint η hs.2.2.1 hs.2.2.2.1) Y- (sampleCorrelation η)⁻¹ • fullProbabilityFlow hF x hs.1.le hlr (sampleCorrelation η) Y‖^2 ∂stdGaussian (Point d)) ≤ (circuitD F x)^2*en^2) : let dep := (depth (C.sampleTree (d:=d) r η hs.2.2.1 hs.2.2.2.1):ℝ) let a := 2*(1+dep)*(C.Af*Kf*q*ei+ef) SquaredAt (gaussianTape d (C.sampleFrom Mf Mi r η).slots) ((gibbs (primitivePotential F x r)).prod (stdGaussian (Point d))) (fun g => (C.sampleFrom Mf Mi r η).pre.run F (x,g)) (fun z => z.1+(Real.sqrt 3*η/2) • z.2) ((400*(η*a)^2+4*en^2)*(circuitD F x)^2) := by let dep := (depth (C.sampleTree (d:=d) r η hs.2.2.1 hs.2.2.2.1):ℝ) let a := 2*(1+dep)*(C.Af*Kf*q*ei+ef) let P : Bool → ℝ → ℝ → Prop := fun s => if s then MeanSize lam ((1+4*C.Af)*q) else MeanSize lam (q*(1+16*C.D*C.A/Real.sqrt (1-C.T^2))) let M : Bool → ℝ → ℝ → SeedProgram d := fun s => if s then Mf else Mi let E := compileDeclaredRoot C.D (C.sampleCenterBudget r) (C.sampleFinalBudget r) Mf Mi (C.sampleTree (d:=d) r η hs.2.2.1 hs.2.2.2.1) (η/Real.sqrt 2) have hA0 : 0 < C.A := hA ▸ C.actualA_pos have hAf0 : 0 < C.Af := hAf ▸ C.actualAf_pos have hbud : 0 ≤ C.sampleCenterBudget r := by unfold sampleCenterBudget; positivity have hLip : (lam:ℝ)*Ki*C.sampleCenterBudget r ≤ 1 := by have hn : 0 ≤ (lam:ℝ)*Ki*C.sampleCenterBudget r := by positivity nlinarith [sq_nonneg ((lam:ℝ)*Ki*C.sampleCenterBudget r)] have hrad : (lam:ℝ)*r^2 ≤ 1/4 := hs.2.2.2.2.trans ((mul_le_of_le_one_right (hs.nonneg lam.coe_nonneg) hs.2.2.2.1).trans hl) have ha : 0 < a := by dsimp [a,dep]; positivity [hs.nonneg lam.coe_nonneg] have hv := C.sampleTree_valid (d:=d) lam.coe_nonneg hs C.residual_pos hRη (by linarith) hA hAf have hrdy := hv.shiftReady (P true) (P false) (fun _ _ h => h.1.ne') (fun _ _ h => h.1.ne') _ _ obtain ⟨Lf,hLf,hfl⟩ := C.sampleCompiled_anchor_lipschitz hs.1 hs.2.2.1 hs.2.2.2.1 hA hAf (mul_nonneg lam.coe_nonneg hKf) (mul_nonneg lam.coe_nonneg hKi) hLip F P M hf.lip hi.lip (η/Real.sqrt 2) hrdy x obtain ⟨Lg,hgl⟩ := C.sampleTree_anchor_lipschitz hF hs.1 hs.2.2.1 hs.2.2.2.1 hrad x have heval : (fun Y => (C.sampleTree r η hs.2.2.1 hs.2.2.2.1).eval F (x,Y))= sampleMeanCircuit F x r (sampleCorrelation η) C.h (C.n+1) C.N (C.sampleEndpoint η hs.2.2.1 hs.2.2.2.1) := by funext Y; exact C.sampleTree_eval hF r η hs.2.2.1 hs.2.2.2.1 x Y rw [heval] at hgl have hc Y := C.sampleCompiled_scaled hF hs (by linarith) hL hRη hD hA hAf hKf hKi hef.le hei hsmall hcon Mf Mi B hBD hbudget hf hi x Y simp only [C.sampleTree_eval hF] at hc let v := compileDeclaredRootShift C.D (C.sampleCenterBudget r) (C.sampleFinalBudget r) Mf Mi (C.sampleTree (d:=d) r η hs.2.2.1 hs.2.2.2.1) (η/Real.sqrt 2) (C.sampleDrift r η hs.1 hs.2.2.1 hs.2.2.2.1) have hpr := sampleCorrelation_properties hs.2.2.1 hs.2.2.2.1 have hp := sampleParent_squared hF x hs.1.le hlr (by linarith [hpr.1]) hpr.2.1 hpr.2.2 (C.n+1) C.N (C.sampleEndpoint η hs.2.2.1 hs.2.2.2.1) (probabilityEndpoint_time _ _ C.h_pos _ (by omega)) E v hLf Lg.coe_nonneg (mul_pos hs.2.2.1 ha) hgl.continuous.measurable hfl (fun z z' => by simpa only [dist_eq_norm] using hgl.dist_le_mul z z') hc hnumi hnum unfold sampleFrom rw [dite_eq_left ⟨hs.1,hs.2.2.1,hs.2.2.2.1⟩] apply hp.mono have hh := mul_le_mul_of_nonneg_left (anchorGauge_circuitD_moment hd F x) (show 0 ≤ 40*(η*a)^2 by positivity) calc _ ≤ 40*(η*a)^2*(10*(circuitD F x)^2)+4*((circuitD F x)^2*en^2) := add_le_add hh le_rfl _ = _ := by ring end LogConcaveSampling.OracleCompiler.CircuitParameters end end section noncomputable section namespace LogConcaveSampling.OracleCompiler.CircuitParameters open MeanTree variable (C : CircuitParameters) {d : ℕ} def depthBound : ℕ := 4*(C.N+1)^2 lemma meanTree_depth (hN : C.Nc≤C.N) (r σ : ℝ) : depth (C.meanTree (d:=d) r σ)≤C.depthBound := by exact meanCircuit_fixed_depth r C.T C.h C.ψ (σ/2) C.n C.m C.N C.nc C.Nc hN C.meanEndpoint _ _ _ _ _ _ lemma sampleTree_depth (r η : ℝ) (hη : 0<η) (hη1 : η≤1) : depth (C.sampleTree (d:=d) r η hη hη1)≤C.depthBound := by have hh := depth_forward r (sampleCorrelation η) C.h (C.n+1) C.N (anchor (Prod.fst : SampleInput d → Point d) (by fun_prop)) (anchor Prod.snd (by fun_prop)) (C.sampleEndpoint η hη hη1) (b:=0) (by simp) (by simp) dsimp only [sampleTree,literalSample] at ⊢ rw [depth_scale] unfold depthBound nlinarith lemma depthBound_pos : 0 if s then MeanSize lam ((1+4*C.Af)*q) else MeanSize lam (q*(1+16*C.D*C.A/Real.sqrt (1-C.T^2))) let M : Bool → ℝ → ℝ → SeedProgram d := fun s => if s then Mf else Mi have hv := C.sampleTree_valid (d:=d) lam.coe_nonneg hs C.residual_pos hRη hD hA hAf have hrdy := hv.shiftReady (P true) (P false) (fun _ _ h => h.1.ne') (fun _ _ h => h.1.ne') _ _ have hE := C.sampleCompiled_variation hs.1 hs.2.2.1 hs.2.2.2.1 hA hAf (mul_nonneg lam.coe_nonneg hKf) (mul_nonneg lam.coe_nonneg hKi) hsmall F P M hf.lip hi.lip (η/Real.sqrt 2) hrdy unfold sampleFrom rw [dite_eq_left ⟨hs.1,hs.2.2.1,hs.2.2.2.1⟩] dsimp only intro x y g have he := sampleParent_lipschitz F _ _ _ _ _ hE x y g convert! he using 1 unfold sampleFinalBudget ring lemma meanFrom_lipschitz {F : Point d → ℝ} {lam : ℝ≥0} {q Kf Ki Ks ef ei es ηmin r σ : ℝ} (hs : MeanSize lam q r σ) (hD : 0 if s then MeanSize lam ((1+4*C.Af)*Real.sqrt (1-C.T^2)*q) else MeanSize lam (q*(1+16*C.D*C.A/Real.sqrt (1-C.T^2))) let M : Bool → ℝ → ℝ → SeedProgram d := fun s => if s then Mf else Mi have hv := C.meanTree_valid (d:=d) lam.coe_nonneg hs hD hψ hA hAf have hrdy := hv.shiftReady (P true) (P false) (fun _ _ h => h.1.ne') (fun _ _ h => h.1.ne') _ _ have hE := C.meanCompiled_variation hs.1 hs.2.2.1 hψ hA hAf (mul_nonneg lam.coe_nonneg hKf) (mul_nonneg lam.coe_nonneg hKi) hsmall F P M hf.lip hi.lip (Real.sqrt 3*σ/2) hrdy have ha := C.mean_anchor_size lam.coe_nonneg hs hRT have hSl := ReservedProgram.full_fixedSeed_lip _ F ((lam:ℝ)*r*Ks) (hS.lip _ _ ha hη) have hAf0 : 0 ‖sampleMeanCircuit F x r (sampleCorrelation η) C.h (C.n+1) C.N (C.sampleEndpoint η hs.2.2.1 hs.2.2.2.1) Y- (sampleCorrelation η)⁻¹ • fullProbabilityFlow hF x hs.1.le hl (sampleCorrelation η) Y‖^2) (stdGaussian (Point d)) ∧ (∫Y,‖sampleMeanCircuit F x r (sampleCorrelation η) C.h (C.n+1) C.N (C.sampleEndpoint η hs.2.2.1 hs.2.2.2.1) Y- (sampleCorrelation η)⁻¹ • fullProbabilityFlow hF x hs.1.le hl (sampleCorrelation η) Y‖^2 ∂stdGaussian (Point d))≤(circuitD F x)^2*en^2 lemma compilerError_mono {H H' Kf q ei ef : ℝ} (hHH : H≤H') (hAf : 0≤C.Af) (hK : 0≤Kf) (hq : 0≤q) (hei : 0≤ei) (hef : 0≤ef) : C.compilerError H Kf q ei ef≤C.compilerError H' Kf q ei ef := by unfold compilerError nlinarith [mul_nonneg (sub_nonneg.mpr hHH) (show 0≤C.Af*Kf*q*ei+ef by positivity)] end CircuitParameters end LogConcaveSampling.OracleCompiler end end section noncomputable section namespace LogConcaveSampling.OracleCompiler.CircuitParameters open MeanTree Coupling MeasureTheory ProbabilityTheory open scoped Classical NNReal variable (C : CircuitParameters) {d : ℕ} theorem meanFrom_correct {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) {q Kf Ki Ks ef ei es en ηmin : ℝ} (hd : 1≤d) (hlam : (lam:ℝ)≤1) (hq : 0≤q) (hql : q≤1/4) (hRT : Real.sqrt (1-C.T^2)≤C.T) (hη : ηmin≤Real.sqrt (1-C.T^2)/C.T) (hD : 1≤C.D) (hψ : 0≤C.ψ) (hA : C.A=C.actualA) (hAf : C.Af=C.actualAf) (hKf : 0≤Kf) (hKi : 0≤Ki) (hKs : 0≤Ks) (hef : 0