import Mathlib import OAI.Probability.LogConcave.OraclePrograms.CenteringMeanCircuitFull import OAI.Probability.LogConcave.Sampling.NumericalScalars namespace OAI section noncomputable section namespace LogConcaveSampling open Filter Set MeasureTheory Quadrature ProbabilityTheory open scoped Classical BigOperators NNReal def CalibratedMeanCircuit {d : ℕ} {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) (x : Point d) {r T h ψ s : ℝ} (hr : 0 ‖stationaryPicard n N (centeringVelocityJoint F x r T h ψ s n n N e) y i-X.path y (probabilityNodes n i)‖^2) μ) ∧ (∀i,(∫y,‖stationaryPicard n N (centeringVelocityJoint F x r T h ψ s n n N e) y i-X.path y (probabilityNodes n i)‖^2 ∂μ)≤ (circuitD F x)^2*err) ∧ Measurable (stationaryMeanTarget hF x hr hl hT0.le hT1 X) ∧ μ.map (stationaryMeanTarget hF x hr hl hT0.le hT1 X)= (stdGaussian (Point d)).map (fun g => primitiveExpectedField F x r+s • g) ∧ Integrable (fun y => ‖centeringMeanCircuit F x r T h ψ s n n N n N e y- stationaryMeanTarget hF x hr hl hT0.le hT1 X y‖^2) μ ∧ (∫y,‖centeringMeanCircuit F x r T h ψ s n n N n N e y- stationaryMeanTarget hF x hr hl hT0.le hT1 X y‖^2 ∂μ)≤(s*circuitD F x)^2*err theorem exists_calibrated_mean_circuit {κ J b t : ℝ} (hκ : 0<κ) (hJ : 1≤J) (hb : 1/2≤b) (ht : 0 first | nlinarith | skip constructor <;> first | nlinarith | skip constructor <;> first | nlinarith | skip constructor <;> first | nlinarith | skip constructor <;> nlinarith refine ⟨n,hnw,hnt,hnn,?_⟩ intro S hS ksize have hc := centeringScalarCalibration_uniform k n (numericalLayerCount J) ksize A Ap Ah Lp U C J₀ D hS hκ hJ hb ht htsmall hw hwt hnw hnt hnn (numericalLayerCount_bound J) have hT := sourceCorrelation_eventually (mul_pos hκ ht) have hmesh := sourceMesh_eventually (mul_pos hκ ht) (mul_pos hκ hw) have hangle := sourceAngle_eventually (show 0<κ*(4*t) by positivity) n filter_upwards [hc,hT,hmesh,hangle,eventually_ge_atTop (1:ℕ)] with d hdc hdT hdmesh hdangle hd intro T h ψ let R := (d:ℝ)^(-(κ*t)) have hd0 : (0:ℝ)