import Mathlib import OAI.Probability.SKBarriers.Parisi.CDFPartitionRepresentation import OAI.Probability.SKBarriers.Gaussian.LipschitzObservable namespace OAI section noncomputable section open scoped NNReal Topology open MeasureTheory ProbabilityTheory Filter Set namespace SK.Analytic theorem scalarWindowDerivative_lipschitz_bound {g : ℝ → ℝ} {L : ℝ≥0} (hg : LipschitzWith L g) {h : ℝ} (hh : 0 (scalarWindow_hasDerivAt hg.continuous h x).differentiableAt) intro x rw [(scalarWindow_hasDerivAt hg.continuous h x).deriv] exact_mod_cast scalarWindowDerivative_lipschitz_bound hg hh x theorem scalarCDFAverage_eq_chainAverage_lipschitz {f g : ℝ → ℝ} (hf : BoundedDerivs f) {K B L : ℝ≥0} (hfK : LipschitzWith K f) (hgL : LipschitzWith L g) (hB : ∀ z, |g z| ≤ B) (β : ℝ) {α : ℝ → ℝ} (hα : ∀ z, α z∈Icc (0:ℝ) 1) (hmono : Monotone α) (l : List (ℝ × ℝ≥0)) (hm : ∀ p∈l, p.1∈Icc (0:ℝ) 1) (s : ℝ) (t : ℝ≥0) (ht : t≤1) (hdur : chainDuration l=t) (hmodel : TimeChainModels α s l) (x : ℝ) : scalarCDFAverage β α s t f g x=scalarTimeChainAverage β l f g x := by apply sub_eq_zero.mp apply abs_eq_zero.mp apply le_antisymm ?_ (abs_nonneg _) apply le_of_forall_pos_le_add intro ε hε simp only [zero_add] let h := ε/(2*((L:ℝ)+1)) have hL : 0<(L:ℝ)+1 := by positivity have hh : 0 (l.get i).1) (fun i => β*Real.sqrt ((l.get i).2:ℝ)) x change |scalarTimeChainAverage β l f g x-scalarTimeChainAverage β l f (scalarWindow g h) x|≤_ at H₂ have HE := scalarCDFAverage_eq_chainAverage hf (scalarWindow_hasDerivAt hgL.continuous h) (scalarWindowDerivative_continuous hgL.continuous h) hfK (scalarWindow_bound hgL.continuous hB hh) (scalarWindowDerivative_lipschitz_bound hgL hh) β hα hmono l hm s t ht hdur hmodel x rw [HE] at H₁ have H := abs_sub_le (scalarCDFAverage β α s t f g x) (scalarTimeChainAverage β l f (scalarWindow g h) x) (scalarTimeChainAverage β l f g x) rw [abs_sub_comm (scalarTimeChainAverage β l f (scalarWindow g h) x)] at H linarith theorem scalarCDFAverage_eq_partition_lipschitz {f g : ℝ → ℝ} (hf : BoundedDerivs f) {K B L : ℝ≥0} (hK : LipschitzWith K f) (hgL : LipschitzWith L g) (hB : ∀ y, |g y|≤B) (β : ℝ) {α : ℝ → ℝ} (hα : ∀ z, α z∈Icc (0:ℝ) 1) (hαm : Monotone α) (n : ℕ) (q : Fin (n+1) → ℝ) (hq : Monotone q) (m : Fin n → ℝ) (hm : ∀ i, m i∈Icc (0:ℝ) 1) (hmodel : ∀ i : Fin n, ∀ z∈Ico (q i.castSucc) (q i.succ), α z=m i) (t : ℝ≥0) (ht : t≤1) (hd : (t:ℝ)=q (Fin.last n)-q 0) (x : ℝ) : scalarCDFAverage β α (q 0) t f g x=scalarHierarchyAverage n m (timeGridCoefficients n β q) f g x := by have hdur : chainDuration (partitionTimeChain n q hq m)=t := by apply NNReal.coe_injective exact (partitionTimeChain_duration n q hq m).trans hd.symm have hml (p) (hp : p∈partitionTimeChain n q hq m) : p.1∈Icc (0:ℝ) 1 := by obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hp exact hm i have H := scalarCDFAverage_eq_chainAverage_lipschitz hf hK hgL hB β hα hαm (partitionTimeChain n q hq m) hml (q 0) t ht hdur (partitionTimeChain_models n q hq m hmodel) x simp only [partitionTimeChain,scalarTimeChainAverage_ofFn,NNReal.coe_mk] at H exact H end SK.Analytic end end end OAI