import Mathlib import OAI.Probability.LogConcave.Dynamics.TriangularEquiv import OAI.Probability.LogConcave.Sampling.ProbabilityVelocity namespace OAI section section noncomputable section open MeasureTheory Filter open scoped ENNReal NNReal Topology section UpperProof open MeasureTheory ProbabilityTheory Filter open scoped ENNReal NNReal RealInnerProductSpace Topology open Function MeasureTheory Set Filter open scoped Topology NNReal namespace LogConcaveSampling open Set Function MeasureTheory Filter ProbabilityTheory open scoped Topology theorem probabilityFlow_integral {d : ℕ} {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) (x : Point d) {r T : ℝ} (hr : 0≤r) (hl : (lam:ℝ)*r^2≤1/2) (hT0 : 0 clampedProbabilityVelocity_lipschitz hF x hr hl hT0.le hT1 t obtain ⟨g,hg,hgb⟩ := interpolationPath_defect_bound hF x hr hl hT0.le hT1 have hh := GlobalODE.transport_expectation_of_flux (μ:=μ.prod ν) hT0 hc hL (clampedProbabilityDerivative_continuous hF x hr hl hT0.le hT1) (clampedProbabilityVelocity_hasFDerivAt hF x hr hl hT0.le hT1) (X:=interpolationPath) (X':=interpolationPathDerivative) interpolationPath_measurable interpolationPath_continuous (fun t ht p => interpolationPath_hasDerivAt (by have hh := (probability_time ht.1.le (ht.2.trans hT1)).1; linarith) p) interpolationPathDerivative_measurable hg (fun t ht => hgb t ⟨ht.1.le,ht.2.le⟩) (fun t ht S hS ⟨C,hC⟩ => by simp_rw [clampedProbabilityVelocity_eq F x r T hT0.le ⟨ht.1.le,ht.2.le⟩] exact interpolationPath_flux hF x hr hl ht.1.le (ht.2.trans hT1) hS hC) hφ hφL hφB have hfc := probabilityFlow_continuous hF x hr hl hT0.le hT1 have he := integral_map (μ:=μ.prod ν) measurable_snd.aemeasurable (hφ.continuous.comp hfc).aestronglyMeasurable rw [Measure.map_snd_prod,measure_univ,one_smul] at he change (∫ y,φ y ∂(μ.prod ν).map (interpolationPath T))=_ rw [integral_map (interpolationPath_measurable T).aemeasurable hφ.continuous.aestronglyMeasurable] change (∫ p,φ (interpolationPath T p) ∂μ.prod ν)=_ rw [hh] trans ∫ p,φ (probabilityFlow hF x hr hl hT0.le hT1 p.2) ∂μ.prod ν · apply integral_congr_ae filter_upwards [] with p rw [show interpolationPath 0 p=p.2 by simp [interpolationPath]] rfl · exact he.symm end LogConcaveSampling end UpperProof end end end end OAI