import Mathlib import OAI.Probability.LogConcave.Analysis.InterpolationPotential 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 namespace LogConcaveSampling open MeasureTheory open scoped RealInnerProductSpace lemma interpolation_conditional_exponent {d : ℕ} (F : Point d → ℝ) (x : Point d) (r ρ : ℝ) (y z : Point d) (ha : 1-ρ^2≠0) : -primitivePotential F x r z-‖y-ρ • z‖^2/(2*(1-ρ^2))= -‖y‖^2/2-conditionalPotential F x r ρ y z := by simp only [primitivePotential,conditionalPotential,norm_sub_sq_real,norm_smul, Real.norm_eq_abs,mul_pow,sq_abs,inner_smul_right] rw [real_inner_comm z y] field_simp ring lemma weighted_integral_zero_of_gibbs {d : ℕ} {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {H : Point d → ℝ} (hc : Continuous H) (hi : Integrable (fun z => Real.exp (-H z))) {u : Point d → E} (hu : (∫ z,u z ∂gibbs H)=0) : (∫ z,Real.exp (-H z) • u z)=0 := by rw [integral_gibbs_vector hc hi] at hu exact (smul_eq_zero.mp hu).resolve_left (inv_ne_zero (integral_exp_pos hi).ne') def jointInterpolationLaw {d : ℕ} (F : Point d → ℝ) (x : Point d) (r ρ : ℝ) := (((gibbs (primitivePotential F x r)).prod (stdGaussian (Point d))).map (fun p => (p.1,ρ • p.1+Real.sqrt (1-ρ^2) • p.2))) theorem interpolation_joint_integral_zero {d : ℕ} {F : Point d → ℝ} {lam : ℝ≥0} (hF : Primitive F lam) (x : Point d) {r ρ : ℝ} (hr : 0≤r) (hl : (lam:ℝ)*r^2≤1/2) (hρ0 : 0≤ρ) (hρ1 : ρ<1) {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {u : Point d × Point d → E} (hi : Integrable u (jointInterpolationLaw F x r ρ)) (hu : ∀ y,(∫ z,u (z,y) ∂gibbs (conditionalPotential F x r ρ y))=0) : (∫ p,u p ∂jointInterpolationLaw F x r ρ)=0 := by unfold jointInterpolationLaw at hi ⊢ have ha := (probability_time hρ0 hρ1).1 have hσ := (Real.sqrt_pos.mpr ha).ne' have hp0 := (partition_pos_of_continuous (hF.continuous_potential x r)).ne' have hpt := partition_ne_top_of_integrable (hF.integrable_exp_neg_potential x hr (by linarith)) let c := (partition (primitivePotential F x r))⁻¹* EulerDensity.noiseCoefficient d (Real.sqrt (1-ρ^2)) have hc0 : c≠0 := mul_ne_zero (ENNReal.inv_ne_zero.mpr hpt) (EulerDensity.noiseCoefficient_positive d hσ).ne' have hct : c≠⊤ := ENNReal.mul_ne_top (ENNReal.inv_ne_top.mpr hp0) (EulerDensity.noiseCoefficient_finite _ _) let w := fun p : Point d × Point d => Real.exp (-primitivePotential F x r p.1- ‖p.2-ρ • p.1‖^2/(2*(1-ρ^2))) have hw0 : ∀ p,0≤w p := fun _ => (Real.exp_pos _).le have hw : Measurable w := by have := (hF.continuous_potential x r).measurable dsimp [w]; fun_prop have hden : Measurable (fun p => ENNReal.ofReal (w p)) := ENNReal.measurable_ofReal.comp hw have hd := EulerDensity.joint_density (hF.continuous_potential x r).measurable (fun z => ρ • z) (by fun_prop) hσ simp only [Real.sq_sqrt ha.le] at hd change _=c • ((volume : Measure (Point d)).prod volume).withDensity (fun p => ENNReal.ofReal (w p)) at hd rw [hd] at hi ⊢ have hif : Integrable (fun p => w p • u p) ((volume : Measure (Point d)).prod volume) := by have hi' := (integrable_smul_measure hc0 hct).mp hi rw [integrable_withDensity_iff_integrable_smul' (hden) (Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] at hi' simpa only [ENNReal.toReal_ofReal (hw0 _)] using hi' rw [integral_smul_measure,integral_withDensity_eq_integral_toReal_smul hden (Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] simp only [ENNReal.toReal_ofReal (hw0 _)] rw [integral_prod_symm _ hif] have hz : ∀ y,(∫ z,w (z,y) • u (z,y))=0 := by intro y have hci := (conditional_hasGaussianLowerTail hF x hr hl hρ0 hρ1 y).integrable_exp (conditionalPotential_smooth hF x r ρ y).continuous have hh := weighted_integral_zero_of_gibbs (conditionalPotential_smooth hF x r ρ y).continuous hci (hu y) have he : ∀ z,w (z,y)=Real.exp (-‖y‖^2/2)*Real.exp (-conditionalPotential F x r ρ y z) := by intro z; dsimp [w] rw [interpolation_conditional_exponent F x r ρ y z ha.ne',sub_eq_add_neg,Real.exp_add] simp_rw [he,mul_smul] rw [integral_smul,hh,smul_zero] simp_rw [hz] simp end LogConcaveSampling end UpperProof end end end end OAI