import Mathlib import OAI.Probability.LogConcave.Numerics.KernelActionPicardRms import OAI.Probability.LogConcave.Sampling.ProbabilityEndpoint namespace OAI section section noncomputable section namespace LogConcaveSampling open Set MeasureTheory ProbabilityTheory RMSIntegral Quadrature open scoped Classical BigOperators NNReal lemma kernelActionPicard_continuous {d : ℕ} {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) (x : Point d) {r T h : ℝ} (hr : 0≤r) (hl : (lam:ℝ)*r^2≤1/2) (hT0 : 0 ∑i,(derivativeWeight (angleNodes m) i/ψ) • kernelCorrectionPicard F x r T h (ψ*angleNodes m i) n N s e p) apply continuous_finsetSum intro i _ have hc : Continuous (fun v : Point d => (derivativeWeight (angleNodes m) i/ψ) • v) := continuous_const_smul _ exact hc.comp (kernelCorrectionPicard_continuous hF x hr hl hT0 hT1 hh (ψ*angleNodes m i) n hn N s e) def kernelActionRmsBudget {d : ℕ} (F : Point d → ℝ) (x : Point d) (lam Ap Ah Lp : ℝ≥0) (r R ρ h ψ C J : ℝ) (k n m N : ℕ) : ℝ := 2*((∑i,|derivativeWeight (angleNodes m) i/ψ|)* (∑i,|derivativeWeight (angleNodes m) i/ψ| * kernelValueRmsBudget F x lam Ap Ah Lp r R ρ h (ψ*angleNodes m i) C J k n N))+ 2*(((∑i,|derivativeWeight (angleNodes m) i|)/ψ)^2* (((ψ*m)^(m+1)/(m.factorial:ℝ))^2* ((d*((lam:ℝ)*r^2)^2)*(R⁻¹)^(4*(m+1))*harmonicCorrectionBudget (m+1)))) theorem kernelActionPicard_terminal_rms (n : ℕ) (hn : 0 kernelActionPicard F x r T h ψ n m N s (probabilityEndpoint hT0 hT1 hh n) p- (terminalJacobian hF x hr hl hT0.le hT1 (S,p.1)-ContinuousLinearMap.id ℝ (Point d)) p.2 Integrable (fun p => ‖err p‖^2) ((interpolationLaw F x r T).prod (stdGaussian (Point d))) ∧ (∫p,‖err p‖^2 ∂((interpolationLaw F x r T).prod (stdGaussian (Point d))))≤ kernelActionRmsBudget F x lam Ap Ah Lp r R S h ψ C J k n m N := by obtain ⟨Ap,Ah,Lp,Lh,C,J,hC,hJ,k,hA⟩ := kernelActionPicard_rms n hn refine ⟨Ap,Ah,Lp,Lh,C,J,hC,hJ,k,?_⟩ intro d F lam hF x r hr hlam hl hd T h hT0 hT1 hh hsmall hqp hqh hqlp hqlh N s dsimp only let S : Icc (0:ℝ) T := ⟨probabilityNodeTime T h n s,probabilityNodeTime_mem hT0 hT1 hh hn s⟩ let ep := probabilityEndpoint hT0 hT1 hh n let E : Icc (0:ℝ) T := ⟨probabilityNodeTime T h n ep,probabilityNodeTime_mem hT0 hT1 hh hn ep⟩ have hE : E=⟨T,hT0.le,le_rfl⟩ := Subtype.ext (probabilityEndpoint_time hT0 hT1 hh n hn) intro R hR hRT m hm1 ψ hψ hψm let fw := probabilityTransport hF x hr.le hl hT0.le hT1 S ⟨T,hT0.le,le_rfl⟩ let inp := fun y : Point (d+d) => (fw (productPointEquiv d d y).1,(productPointEquiv d d y).2) let err := fun p : Point d × Point d => kernelActionPicard F x r T h ψ n m N s ep p- (terminalJacobian hF x hr hl hT0.le hT1 (S,p.1)-ContinuousLinearMap.id ℝ (Point d)) p.2 have ha := hA hF x hr hlam hl hd hT0 hT1 hh hsmall hqp hqh hqlp hqlh N s ep R hR hRT m hm1 ψ hψ hψm let aerr := fun f : Point d → Point d => fun y : Point (d+d) => kernelActionPicard F x r T h ψ n m N s ep (f (productPointEquiv d d y).1,(productPointEquiv d d y).2)-kernelTransportAction f y change Integrable (fun y => ‖aerr (probabilityTransport hF x hr.le hl hT0.le hT1 S E) y‖^2) (gibbs (centeringPotential F x r S)) ∧ (∫y,‖aerr (probabilityTransport hF x hr.le hl hT0.le hT1 S E) y‖^2 ∂gibbs (centeringPotential F x r S))≤kernelActionRmsBudget F x lam Ap Ah Lp r R S h ψ C J k n m N at ha rw [hE] at ha have heq (y : Point (d+d)) : err (inp y)=kernelActionPicard F x r T h ψ n m N s ep (inp y)-kernelTransportAction fw y := by dsimp only [err,inp] rw [kernelTransportAction_terminal,terminalForward_eq] have hfw : Measurable fw := (probabilityTransport_continuous hF x hr.le hl hT0.le hT1 S ⟨T,hT0.le,le_rfl⟩).measurable have hinp : Measurable inp := (hfw.comp ((productPointEquiv d d).continuous.measurable.fst)).prodMk ((productPointEquiv d d).continuous.measurable.snd) have hlaw := centering_transport_joint_law hF x hr.le hl hT0.le hT1 S ⟨T,hT0.le,le_rfl⟩ have hK : Continuous (fun p : Point d × Point d => (terminalJacobian hF x hr hl hT0.le hT1 (S,p.1)-ContinuousLinearMap.id ℝ (Point d)) p.2) := (((terminalJacobian_smooth hF x hr hl hT0.le hT1).continuous.comp (continuous_const.prodMk continuous_fst)).sub continuous_const).clm_apply continuous_snd have he : Measurable err := ((kernelActionPicard_continuous hF x hr.le hl hT0 hT1 hh ψ n hn m N s ep).sub hK).measurable have hi : Integrable (fun y => ‖err (inp y)‖^2) (gibbs (centeringPotential F x r S)) := by simpa only [heq] using ha.1 have hb : (∫y,‖err (inp y)‖^2 ∂gibbs (centeringPotential F x r S))≤ kernelActionRmsBudget F x lam Ap Ah Lp r R S h ψ C J k n m N := by simpa only [heq] using ha.2 exact rms_bound_pushforward hinp hlaw he hi hb end LogConcaveSampling end end section noncomputable section namespace LogConcaveSampling open Set MeasureTheory ProbabilityTheory RMSIntegral Quadrature open scoped Classical BigOperators NNReal def kernelQuadraturePicard {d : ℕ} (F : Point d → ℝ) (x : Point d) (r T h ψ : ℝ) (n m N : ℕ) (e : ProbabilityNode T h n) (w : ProbabilityNode T h n → ℝ) (p : Point d × Point d) : Point d := ∑s,w s • kernelActionPicard F x r T h ψ n m N s e p theorem kernelQuadraturePicard_numerical_rms (n : ℕ) (hn : 0 kernelQuadraturePicard F x r T h ψ n m N (probabilityEndpoint hT0 hT1 hh n) w p- ∑s,w s • (terminalJacobian hF x hr hl hT0.le hT1 (probabilityNodeTime T h n s,p.1)-ContinuousLinearMap.id ℝ (Point d)) p.2 Integrable (fun p => ‖err p‖^2) ((interpolationLaw F x r T).prod (stdGaussian (Point d))) ∧ (∫p,‖err p‖^2 ∂((interpolationLaw F x r T).prod (stdGaussian (Point d))))≤ (∑s,|w s|)*(∑s,|w s| * kernelActionRmsBudget F x lam Ap Ah Lp r R (probabilityNodeTime T h n s) h ψ C J k n m N) := by obtain ⟨Ap,Ah,Lp,Lh,C,J,hC,hJ,k,hA⟩ := kernelActionPicard_terminal_rms n hn refine ⟨Ap,Ah,Lp,Lh,C,J,hC,hJ,k,?_⟩ intro d F lam hF x r hr hlam hl hd T h hT0 hT1 hh hsmall hqp hqh hqlp hqlh N R hR hRT m hm1 ψ hψ hψm w dsimp only let ep := probabilityEndpoint hT0 hT1 hh n let f := fun (s : ProbabilityNode T h n) (p : Point d × Point d) => kernelActionPicard F x r T h ψ n m N s ep p- (terminalJacobian hF x hr hl hT0.le hT1 (probabilityNodeTime T h n s,p.1)-ContinuousLinearMap.id ℝ (Point d)) p.2 have hs (s : ProbabilityNode T h n) := hA hF x hr hlam hl hd hT0 hT1 hh hsmall hqp hqh hqlp hqlh N s R hR hRT m hm1 ψ hψ hψm have hfc (s : ProbabilityNode T h n) : Continuous (f s) := by have hK : Continuous (fun p : Point d × Point d => (terminalJacobian hF x hr hl hT0.le hT1 (probabilityNodeTime T h n s,p.1)-ContinuousLinearMap.id ℝ (Point d)) p.2) := (((terminalJacobian_smooth hF x hr hl hT0.le hT1).continuous.comp (continuous_const.prodMk continuous_fst)).sub continuous_const).clm_apply continuous_snd exact (kernelActionPicard_continuous hF x hr.le hl hT0 hT1 hh ψ n hn m N s ep).sub hK have he (p : Point d × Point d) : kernelQuadraturePicard F x r T h ψ n m N ep w p- ∑s,w s • (terminalJacobian hF x hr hl hT0.le hT1 (probabilityNodeTime T h n s,p.1)-ContinuousLinearMap.id ℝ (Point d)) p.2= ∑s,w s • f s p := by simp only [kernelQuadraturePicard,f,smul_sub,Finset.sum_sub_distrib] simp_rw [show probabilityEndpoint hT0 hT1 hh n=ep from rfl,he] exact weighted_sum_sq_varying w f (fun s => kernelActionRmsBudget F x lam Ap Ah Lp r R (probabilityNodeTime T h n s) h ψ C J k n m N) (fun s => (hfc s).aestronglyMeasurable) (fun s => (hs s).1) (fun s => (hs s).2) end LogConcaveSampling end end section noncomputable section namespace LogConcaveSampling open Quadrature open scoped Classical BigOperators NNReal theorem kernelQuadraturePicard_lipschitz (n : ℕ) (hn : 0 kernelActionPicard F x r T h ψ n m N s e) (fun s => hAB hF x hr hl hT0 hT1 hh hψ m hψm hq hq' N s e) end LogConcaveSampling end end section noncomputable section namespace LogConcaveSampling.FinitePicard open MeasureTheory open scoped BigOperators NNReal RealInnerProductSpace variable {Ω E I : Type*} [MeasurableSpace Ω] {ν : Measure Ω} [IsFiniteMeasure ν] [NormedAddCommGroup E] [InnerProductSpace ℝ E] [Fintype I] lemma iterateLp_ae (w : I → I → ℝ) (φ : I → E → E) {K : ℝ≥0} (hφ : ∀i,LipschitzWith K (φ i)) (a : I → Lp E 2 ν) (n : ℕ) : ∀ᵐω ∂ν,∀i, ((stepLp w φ hφ a)^[n] a i) ω= nodes w φ (fun ω j => a j ω) n ω i := by induction n with | zero => exact Filter.Eventually.of_forall (fun _ _ => rfl) | succ n ih => have hs : ∀ᵐω ∂ν,∀i, (stepLp w φ hφ a ((stepLp w φ hφ a)^[n] a) i) ω= step w φ (fun j => a j ω) (fun j => (((stepLp w φ hφ a)^[n] a) j) ω) i := by rw [ae_all_iff] exact stepLp_ae w φ hφ a _ filter_upwards [hs,ih] with ω hs hi intro i rw [Function.iterate_succ_apply',hs i] simp only [nodes,hi] theorem actual_nodes_rms (w : I → I → ℝ) (φ : I → E → E) {A K : ℝ≥0} (hφ : ∀i,LipschitzWith K (φ i)) (a e : I → Lp E 2 ν) (hw : ∀i,∑j,|w i j|≤A) (hq : (A*K:ℝ≥0)≤1/2) {D : ℝ} (hD : 0≤D) (he : ∀i,(∫ω,‖(stepLp w φ hφ a e i) ω-e i ω‖^2 ∂ν)≤D^2) (n : ℕ) (i : I) : (∫ω,‖nodes w φ (fun ω j => a j ω) n ω i-e i ω‖^2 ∂ν)≤ (2*D+(A*K:ℝ≥0)^n*dist a e)^2 := by have hh := rms_picard_defect w φ hφ a e hw hq hD (fun i => nodewise_rms_le hD (he i)) n have hj := (dist_le_pi_dist ((stepLp w φ hφ a)^[n] a) e i).trans hh have hn : 0≤2*D+(A*K:ℝ≥0)^n*dist a e := by positivity have heq : (∫ω,‖nodes w φ (fun ω j => a j ω) n ω i-e i ω‖^2 ∂ν)= dist (((stepLp w φ hφ a)^[n] a) i) (e i)^2 := by rw [dist_eq_norm,lp_norm_sq_integral] apply integral_congr_ae filter_upwards [iterateLp_ae w φ hφ a n, Lp.coeFn_sub (((stepLp w φ hφ a)^[n] a) i) (e i)] with ω h1 h2 simp only [h2,Pi.sub_apply,h1 i] rw [heq] exact pow_le_pow_left₀ dist_nonneg hj 2 end LogConcaveSampling.FinitePicard end end end end OAI