import Mathlib import OAI.Probability.LogConcave.Sampling.VelocityJointLip import OAI.Probability.LogConcave.Sampling.NumericalLayerCount namespace OAI section noncomputable section namespace LogConcaveSampling open Filter Set MeasureTheory Quadrature open scoped Topology Classical BigOperators NNReal theorem velocityNormalizedBudget_calibrated (k n N : ℕ) (Ap Ah Lp : ℝ≥0) (C J₀ D : ℝ) {lam : ℕ → ℝ≥0} {r T : ℕ → ℝ} {κ J b t w : ℝ} (hκ : 0<κ) (hJ : 1≤J) (hb : 1/2≤b) (ht : 0 (lam d:ℝ)*(r d)^2) (κ*b)) (hT0 : ∀ᶠ d : ℕ in atTop,0 velocityNormalizedBudget d k n n N (lam d) Ap Ah Lp (r d) ((d:ℝ)^(-(κ*t))) (T d) ((d:ℝ)^(-(κ*w))) ((d:ℝ)^(-(κ*(4*t)))) C J₀ D) (2*κ*(J+8)) := by obtain ⟨hp,hh,hiter,ha₁,ha₂,hv₁,hv₂,hlip,hbeta,hcq,hniter,hmq⟩ := numerical_exponent_margins hJ hb ht htsmall hw hwt hnw hnt hnn hN have hB := kernelNormalizedTerm_rate k (n+1) N Ap Ah Lp (a:=κ*t) (b:=κ*w) (c:=κ*(4*t)) (e:=κ*(J+10)) (n:ℝ) hl (show κ*(J+10)≤((n+1:ℕ)+1:ℝ)*(κ*w) by have he := mul_le_mul_of_nonneg_left hp hκ.le push_cast; nlinarith) (show κ*(J+10)≤((n+1:ℕ)+1:ℝ)*(κ*(4*t)-2*(κ*t)) by have he := mul_le_mul_of_nonneg_left hh hκ.le push_cast; nlinarith) (show κ*(J+10)≤N*(κ*b) by have he := mul_le_mul_of_nonneg_left hiter hκ.le nlinarith) have hA := kernelActionNormalizedBudget_rate k (n+1) n N Ap Ah Lp C J₀ hB (show 2*κ*(J+9)≤2*(κ*(J+10)-κ*(4*t)) by have he := mul_le_mul_of_nonneg_left ha₁ hκ.le nlinarith) (show 2*κ*(J+9)≤2*(κ*(4*t))*n-4*(κ*t)*((n:ℝ)+1) by have he := mul_le_mul_of_nonneg_left ha₂ hκ.le nlinarith) obtain ⟨Dq,hDq,hDqu⟩ := exists_basisDerivative_budget (probabilityNodes (n+1)) have hW := terminalQuadratureWeight_rate n Dq (by linarith) hDqu (κ*t) (κ*w) hT0 hT1 hRT hsmall hlarge exact velocityNormalizedBudget_rate k n n N Ap Ah Lp C J₀ D hW hA (logMeshLength_rate (κ*t) hT0 hT1 hRT) (by have he := mul_le_mul_of_nonneg_left hv₁ hκ.le; nlinarith) (by have he := mul_le_mul_of_nonneg_left hv₂ hκ.le; nlinarith) lemma velocityJointLip_rate (n m : ℕ) (A : ℝ≥0) {lam : ℕ → ℝ≥0} {r s T : ℕ → ℝ} {b c u : ℝ} (hbc : 0≤b+c) (hr : ∀ᶠ d : ℕ in atTop,0 ∑v,|terminalQuadratureWeight (T d) ((d:ℝ)^(-b)) n v|) (-b)) (hα : LogPowerRate (fun d => (lam d:ℝ)*r d/s d) u) : LogPowerRate (fun d => (velocityJointLip n m A (lam d) (r d) (T d) ((d:ℝ)^(-b)) ((d:ℝ)^(-c)) (s d):ℝ)) (u-b-c) := by have hS := (LogPowerRate.inv_power c).const_mul (∑i,|derivativeWeight (angleNodes m) i|) have hQS := (hW.const_mul (16*(A:ℝ))).mul hS have h1 := (LogPowerRate.const 1).mono (show -b+-c≤0 by linarith) have he := (hα.const_mul (Real.pi^2)).mul (hQS.add h1) have he' : LogPowerRate (fun d => Real.pi^2*((lam d:ℝ)*r d/s d)* (16*(A:ℝ)*(∑v,|terminalQuadratureWeight (T d) ((d:ℝ)^(-b)) n v|)* ((∑i,|derivativeWeight (angleNodes m) i|)/(d:ℝ)^(-c))+1)) (u-b-c) := by convert! he using 1 first | (simp only [div_eq_mul_inv]) | ring apply LogPowerRate.of_le he' · exact Eventually.of_forall (fun d => NNReal.coe_nonneg _) · filter_upwards [hr,hs,hT0,hT1,eventually_ge_atTop (1:ℕ)] with d hdr hds hdT0 hdT1 hd have hd0 : (0:ℝ)