math / data /lean /OAI /Probability /LogConcave /Analysis /PrimitivePotentialModeBounds.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
15.6 kB
import Mathlib
import OAI.Probability.LogConcave.Analysis.SymmetricGradientDerivative
import OAI.Probability.LogConcave.Sampling.Primitive
namespace OAI
section
section
noncomputable section
open MeasureTheory Filter
open scoped ENNReal NNReal Topology
section UpperProof
namespace LogConcaveSampling
open scoped RealInnerProductSpace NNReal
theorem primitivePotential_mode_bounds {d : β„•} {F : Point d β†’ ℝ} {lam : ℝβ‰₯0}
(hF : Primitive F lam) (x : Point d) {r : ℝ} (hr : 0 ≀ r)
{zβ‚€ : Point d} (hz : zβ‚€ = -r β€’ gradient F (x + r β€’ zβ‚€)) (v : Point d) :
primitivePotential F x r zβ‚€ + (1 - (lam : ℝ) * r ^ 2) * β€–vβ€– ^ 2 / 2 ≀
primitivePotential F x r (zβ‚€ + v) ∧
primitivePotential F x r (zβ‚€ + v) ≀
primitivePotential F x r zβ‚€ + (1 + (lam : ℝ) * r ^ 2) * β€–vβ€– ^ 2 / 2 := by
have hb := quadratic_remainder_of_gradient_lipschitz hF.smooth hF.gradient_lipschitz
(x + r β€’ zβ‚€) (r β€’ v)
rw [abs_le] at hb
simp only [norm_smul, Real.norm_eq_abs, abs_of_nonneg hr] at hb
have hlin : inner ℝ zβ‚€ v + inner ℝ (r β€’ v) (gradient F (x + r β€’ zβ‚€)) = 0 := by
conv_lhs => arg 1; rw [hz]
simp only [real_inner_smul_left]
rw [real_inner_comm]
ring
dsimp only [primitivePotential]
rw [norm_add_sq_real, smul_add, ← add_assoc]
constructor <;> nlinarith [hb.1, hb.2]
theorem Primitive.exists_unique_mode {d : β„•} {F : Point d β†’ ℝ} {lam : ℝβ‰₯0}
(hF : Primitive F lam) (x : Point d) {r : ℝ} (hr : 0 ≀ r)
(hl : (lam : ℝ) * r ^ 2 < 1) :
βˆƒ zβ‚€ : Point d, zβ‚€ = -r β€’ gradient F (x + r β€’ zβ‚€) ∧
(βˆ€ z : Point d, primitivePotential F x r zβ‚€ ≀ primitivePotential F x r z) ∧
(βˆ€ z : Point d, primitivePotential F x r z ≀ primitivePotential F x r zβ‚€ β†’ z = zβ‚€) := by
obtain ⟨zβ‚€, hz, _, _, _⟩ := exists_mode_with_iteration_bound hF.gradient_lipschitz x hr hl
refine ⟨zβ‚€, hz, ?_, ?_⟩
Β· intro z
have hb := (primitivePotential_mode_bounds hF x hr hz (z - zβ‚€)).1
rw [add_sub_cancel] at hb
have hn : 0 ≀ (1 - (lam : ℝ) * r ^ 2) * β€–z - zβ‚€β€– ^ 2 / 2 := by positivity
linarith
Β· intro z hzmin
have hb := (primitivePotential_mode_bounds hF x hr hz (z - zβ‚€)).1
rw [add_sub_cancel] at hb
have hnorm : β€–z - zβ‚€β€– = 0 := by
have hp : 0 < 1 - (lam : ℝ) * r ^ 2 := by linarith
have hmul : (1 - (lam : ℝ) * r ^ 2) * β€–z - zβ‚€β€– ^ 2 ≀ 0 := by linarith
rcases eq_or_lt_of_le (norm_nonneg (z - zβ‚€)) with hn | hn
Β· exact hn.symm
Β· have hpos := mul_pos hp (sq_pos_of_pos hn)
linarith
exact sub_eq_zero.mp (norm_eq_zero.mp hnorm)
end LogConcaveSampling
namespace LogConcaveSampling
open scoped RealInnerProductSpace NNReal
theorem Primitive.continuous_potential {d : β„•} {F : Point d β†’ ℝ} {lam : ℝβ‰₯0}
(hF : Primitive F lam) (x : Point d) (r : ℝ) :
Continuous (primitivePotential F x r) := by
exact (continuous_norm.pow 2 |>.div_const 2).add
(hF.smooth.continuous.comp (continuous_const.add (continuous_id.const_smul r)))
theorem Primitive.integrable_exp_neg_potential {d : β„•} {F : Point d β†’ ℝ} {lam : ℝβ‰₯0}
(hF : Primitive F lam) (x : Point d) {r : ℝ} (hr : 0 ≀ r)
(hl : (lam : ℝ) * r ^ 2 < 1) :
Integrable (fun z => Real.exp (-primitivePotential F x r z)) := by
obtain ⟨zβ‚€, hz, _, _⟩ := hF.exists_unique_mode x hr hl
let a := (1 - (lam : ℝ) * r ^ 2) / 2
have ha : 0 < a := by dsimp [a]; linarith
have hi := (integrable_gaussian_envelope d ha).comp_sub_right zβ‚€
apply (hi.const_mul (Real.exp (-primitivePotential F x r zβ‚€))).mono'
((Real.continuous_exp.comp (hF.continuous_potential x r).neg).aestronglyMeasurable)
filter_upwards [] with z
change |Real.exp (-primitivePotential F x r z)| ≀ _
rw [abs_of_pos (Real.exp_pos _), ← Real.exp_add]
have hb := (primitivePotential_mode_bounds hF x hr hz (z - zβ‚€)).1
rw [add_sub_cancel] at hb
apply Real.exp_le_exp.mpr
dsimp [a]
linarith
end LogConcaveSampling
namespace LogConcaveSampling
open scoped RealInnerProductSpace
lemma polynomial_gaussian_absorb {b x : ℝ} (hb : 0 < b) (_hx : 0 ≀ x) :
x * Real.exp (-b*x) ≀ (2/b) * Real.exp (-(b/2)*x) := by
have he : (b/2)*x ≀ Real.exp ((b/2)*x) := by
linarith [Real.add_one_le_exp ((b/2)*x)]
have he' := mul_le_mul_of_nonneg_right he (Real.exp_pos (-b*x)).le
rw [← Real.exp_add] at he'
have hexp : (b/2)*x + -b*x = -(b/2)*x := by ring
rw [hexp] at he'
have hbp : 0 < b/2 := by positivity
have hh : (x * Real.exp (-b*x)) * (b/2) ≀ Real.exp (-(b/2)*x) := by nlinarith only [he']
have hh' := (le_div_iffβ‚€ hbp).mpr hh
calc
_ ≀ Real.exp (-(b/2)*x) / (b/2) := hh'
_ = _ := by field_simp
lemma integrable_sq_norm_gaussian (d : β„•) {b : ℝ} (hb : 0 < b) :
Integrable (fun x : Point d => β€–xβ€–^2 * Real.exp (-b * β€–xβ€–^2)) := by
apply ((integrable_gaussian_envelope d (b := b/2) (by positivity)).const_mul (2/b)).mono'
((continuous_norm.pow 2).mul (Real.continuous_exp.comp
(continuous_const.mul (continuous_norm.pow 2)))).aestronglyMeasurable
filter_upwards [] with x
change |β€–xβ€–^2 * Real.exp (-b * β€–xβ€–^2)| ≀ _
rw [abs_of_nonneg (by positivity)]
exact polynomial_gaussian_absorb hb (sq_nonneg _)
theorem radial_integration_by_parts {d : β„•} {H : Point d β†’ ℝ} {m K : ℝ}
(hH : ContDiff ℝ 1 H) (hm : 0 < m) (hK : 0 ≀ K)
(htail : βˆ€ x, m * β€–xβ€–^2 / 2 ≀ H x)
(hgrad : βˆ€ x, β€–gradient H xβ€– ≀ K * β€–xβ€–) :
Integrable (fun x => inner ℝ (gradient H x) x * Real.exp (-H x)) ∧
(∫ x, inner ℝ (gradient H x) x * Real.exp (-H x)) =
(d : ℝ) * ∫ x, Real.exp (-H x) := by
let F : ℝ β†’ Point d β†’ ℝ := fun a x => Real.exp (-H (a β€’ x))
let F' : ℝ β†’ Point d β†’ ℝ := fun a x =>
-(inner ℝ (gradient H (a β€’ x)) x) * Real.exp (-H (a β€’ x))
have hgc : Continuous (gradient H) :=
(InnerProductSpace.toDual ℝ (Point d)).symm.continuous.comp
(hH.continuous_fderiv (by norm_num))
have hdiff : βˆ€ (x : Point d) (a : ℝ), HasDerivAt (fun a => F a x) (F' a x) a := by
intro x a
have hh := ((hH.differentiable (by norm_num) (a β€’ x)).hasFDerivAt).comp_hasDerivAt a
((hasDerivAt_id a).smul_const x)
have hh' : HasDerivAt (fun a => H (a β€’ x)) (inner ℝ (gradient H (a β€’ x)) x) a := by
convert! hh using 1
change inner ℝ (gradient H (a β€’ x)) x = fderiv ℝ H (a β€’ x) ((1 : ℝ) β€’ x)
rw [one_smul,inner_gradient_left]
convert! hh'.neg.exp using 1; simp only [F',mul_comm,Pi.neg_apply]
have hbase : Integrable (F 1) := by
simp only [F,one_smul]
apply (integrable_gaussian_envelope d (b := m/2) (by positivity)).mono'
((Real.continuous_exp.comp hH.continuous.neg).aestronglyMeasurable)
filter_upwards [] with x
change |Real.exp (-H x)| ≀ _
rw [abs_of_pos (Real.exp_pos _)]
apply Real.exp_le_exp.mpr
linarith [htail x]
have hbnd : βˆ€ (x : Point d) (a : ℝ), a ∈ Set.Ioo (1/2 : ℝ) 2 β†’
β€–F' a xβ€– ≀ (2*K) * (β€–xβ€–^2 * Real.exp (-(m/8) * β€–xβ€–^2)) := by
intro x a ha
have hap : 0 ≀ a := by linarith [ha.1]
have hga : β€–gradient H (a β€’ x)β€– ≀ 2*K*β€–xβ€– := by
calc
_ ≀ K * β€–a β€’ xβ€– := hgrad _
_ = K * (a*β€–xβ€–) := by rw [norm_smul,Real.norm_eq_abs,abs_of_nonneg hap]
_ ≀ 2*K*β€–xβ€– := by
calc
_ ≀ K * (2*β€–xβ€–) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right ha.2.le (norm_nonneg x)) hK
_ = _ := by ring
have hinner : |inner ℝ (gradient H (a β€’ x)) x| ≀ 2*K*β€–xβ€–^2 := by
calc
_ ≀ β€–gradient H (a β€’ x)β€– * β€–xβ€– := abs_real_inner_le_norm _ _
_ ≀ (2*K*β€–xβ€–)*β€–xβ€– := mul_le_mul_of_nonneg_right hga (norm_nonneg x)
_ = _ := by ring
have htail' : (m/8)*β€–xβ€–^2 ≀ H (a β€’ x) := by
have ht := htail (a β€’ x)
rw [norm_smul,Real.norm_eq_abs,abs_of_nonneg hap,mul_pow] at ht
have ha2 : (1/4 : ℝ) ≀ a^2 := by nlinarith [ha.1]
have hh := mul_le_mul_of_nonneg_left ha2 (show 0 ≀ m*β€–xβ€–^2 by positivity)
nlinarith
dsimp [F']
rw [abs_mul,abs_neg,abs_of_pos (Real.exp_pos _)]
calc
_ ≀ (2*K*β€–xβ€–^2) * Real.exp (-H (a β€’ x)) := mul_le_mul_of_nonneg_right hinner (by positivity)
_ ≀ (2*K*β€–xβ€–^2) * Real.exp (-(m/8)*β€–xβ€–^2) := by
gcongr
linarith
_ = _ := by ring
have hparam := hasDerivAt_integral_of_dominated_loc_of_deriv_le
(ΞΌ := (volume : Measure (Point d))) (F := F) (F' := F')
(bound := fun x => (2*K) * (β€–xβ€–^2 * Real.exp (-(m/8)*β€–xβ€–^2)))
(xβ‚€ := (1 : ℝ)) (s := Set.Ioo (1/2 : ℝ) 2)
(Ioo_mem_nhds (by norm_num) (by norm_num))
(Filter.Eventually.of_forall fun a =>
((Real.continuous_exp.comp (hH.continuous.comp (continuous_id.const_smul a)).neg)).aestronglyMeasurable)
hbase
(by
have hh : Continuous (fun x => -(inner ℝ (gradient H x) x) * Real.exp (-H x)) :=
(hgc.inner continuous_id).neg.mul (Real.continuous_exp.comp hH.continuous.neg)
convert! hh.aestronglyMeasurable using 1
simp only [F',one_smul])
(Filter.Eventually.of_forall hbnd)
((integrable_sq_norm_gaussian d (b := m/8) (by positivity)).const_mul (2*K))
(Filter.Eventually.of_forall fun x a _ => hdiff x a)
have hidentity : (fun a : ℝ => ∫ x, F a x) =αΆ [𝓝 1]
(fun a => (a^d)⁻¹ * ∫ x, Real.exp (-H x)) := by
filter_upwards [eventually_gt_nhds (show (0 : ℝ) < 1 by norm_num)] with a ha
simpa [F,finrank_euclideanSpace_fin] using
(Measure.integral_comp_smul_of_nonneg (volume : Measure (Point d))
(fun x => Real.exp (-H x)) a (hR := ha.le))
have halgebra : HasDerivAt (fun a : ℝ => (a^d)⁻¹ * ∫ x, Real.exp (-H x))
(-(d : ℝ) * ∫ x, Real.exp (-H x)) 1 := by
convert! (((hasDerivAt_id (1 : ℝ)).pow d).inv (by simp)).mul_const (∫ x, Real.exp (-H x)) using 1; simp
have heq := hparam.2.unique (halgebra.congr_of_eventuallyEq hidentity)
have hi : Integrable (fun x => inner ℝ (gradient H x) x * Real.exp (-H x)) := by
simpa [F',neg_mul] using hparam.1.neg
refine ⟨hi, ?_⟩
have heq' : -(∫ x, inner ℝ (gradient H x) x * Real.exp (-H x)) =
-((d : ℝ) * ∫ x, Real.exp (-H x)) := by
simpa only [F',one_smul,neg_mul,integral_neg] using heq
exact neg_inj.mp heq'
end LogConcaveSampling
namespace LogConcaveSampling
open scoped RealInnerProductSpace
lemma partition_toReal {d : β„•} {H : Point d β†’ ℝ}
(hi : Integrable (fun x => Real.exp (-H x))) :
(partition H).toReal = ∫ x, Real.exp (-H x) := by
exact (integral_eq_lintegral_of_nonneg_ae
(Filter.Eventually.of_forall fun x => (Real.exp_pos (-H x)).le)
hi.aestronglyMeasurable).symm
lemma integral_gibbs {d : β„•} {H : Point d β†’ ℝ} (hc : Continuous H)
(hi : Integrable (fun x => Real.exp (-H x))) (f : Point d β†’ ℝ) :
(∫ x, f x βˆ‚gibbs H) = (∫ x, Real.exp (-H x) * f x) / ∫ x, Real.exp (-H x) := by
rw [gibbs,integral_smul_measure,ENNReal.toReal_inv,partition_toReal hi]
have hden : Measurable (gibbsDensity H) :=
(ENNReal.continuous_ofReal.comp (Real.continuous_exp.comp hc.neg)).measurable
rw [integral_withDensity_eq_integral_toReal_smul hden
(Filter.Eventually.of_forall fun x => ENNReal.ofReal_lt_top) f]
simp only [gibbsDensity,ENNReal.toReal_ofReal (Real.exp_pos _).le,smul_eq_mul]
ring
lemma integrable_gibbs_of_weighted {d : β„•} {H f : Point d β†’ ℝ} (hc : Continuous H)
(hi : Integrable (fun x => Real.exp (-H x)))
(hf : Integrable (fun x => Real.exp (-H x) * f x)) : Integrable f (gibbs H) := by
have hp : partition H β‰  ⊀ := (lintegral_ofReal_ne_top_iff_integrable hi.aestronglyMeasurable
(Filter.Eventually.of_forall fun x => (Real.exp_pos (-H x)).le)).2 hi
have hpos : 0 < partition H := by
have hmeasure : Measurable (gibbsDensity H) :=
(ENNReal.continuous_ofReal.comp (Real.continuous_exp.comp hc.neg)).measurable
rw [partition,lintegral_pos_iff_support hmeasure]
have hh : Function.support (gibbsDensity H) = Set.univ := by
ext x
simp [Function.mem_support,gibbsDensity,not_le_of_gt (Real.exp_pos (-H x))]
rw [hh]
exact isOpen_univ.measure_pos volume Set.univ_nonempty
have hw : Integrable f (volume.withDensity (gibbsDensity H)) := by
have hden : Measurable (gibbsDensity H) :=
(ENNReal.continuous_ofReal.comp (Real.continuous_exp.comp hc.neg)).measurable
rw [integrable_withDensity_iff_integrable_smul' hden
(Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)]
simpa only [gibbsDensity,ENNReal.toReal_ofReal (Real.exp_pos _).le,smul_eq_mul] using hf
exact hw.smul_measure (by simpa using hpos.ne')
theorem Admissible.radial_gradient_lower {d : β„•} {V : Point d β†’ ℝ}
(hV : Admissible V) (x : Point d) : β€–xβ€–^2 ≀ inner ℝ (gradient V x) x := by
let g : ℝ β†’ ℝ := fun t => inner ℝ x (gradient V (t β€’ x))
let h : ℝ β†’ ℝ := fun t => inner ℝ x (fderiv ℝ (gradient V) (t β€’ x) x)
have hdg := hV.contDiff_gradient.differentiable (by norm_num)
have hg : βˆ€ t, HasDerivAt g (h t) t := by
intro t
have hh := (hdg (t β€’ x)).hasFDerivAt.comp_hasDerivAt t
((hasDerivAt_id t).smul_const x)
simpa [g,h,Function.comp_def] using (hasDerivAt_const t x).inner ℝ hh
have hderiv : βˆ€ t, HasDerivAt (fun t => g t - β€–xβ€–^2*t) (h t-β€–xβ€–^2) t := by
intro t
convert! (hg t).sub ((hasDerivAt_id t).const_mul (β€–xβ€–^2)) using 1
simp
have hmono : Monotone (fun t => g t-β€–xβ€–^2*t) :=
monotone_of_hasDerivAt_nonneg hderiv (fun t => sub_nonneg.mpr (hV.hessian_bounds (t β€’ x) x).1)
have hh := hmono (show (0 : ℝ) ≀ 1 by norm_num)
simp only [g,zero_smul,one_smul,hV.gradient_zero,inner_zero_right,mul_zero,sub_zero,mul_one] at hh
rw [real_inner_comm] at hh
linarith only [hh]
theorem Admissible.second_moment_bound {d : β„•} {V : Point d β†’ ℝ}
(hV : Admissible V) :
Integrable (fun x => β€–xβ€–^2) (gibbs V) ∧ (∫ x, β€–xβ€–^2 βˆ‚gibbs V) ≀ d := by
have hi := radial_integration_by_parts (hV.smooth.of_le (by norm_num))
(m := 1) (K := 2) (by norm_num) (by norm_num)
(fun x => by simpa using (hV.quadratic_bounds x).1) hV.gradient_norm_le
have hisq : Integrable (fun x => Real.exp (-V x) * β€–xβ€–^2) := by
apply (integrable_sq_norm_gaussian d (b := 1/2) (by norm_num)).mono'
((Real.continuous_exp.comp hV.smooth.continuous.neg).mul (continuous_norm.pow 2)).aestronglyMeasurable
filter_upwards [] with x
change |Real.exp (-V x) * β€–xβ€–^2| ≀ _
rw [abs_of_nonneg (by positivity)]
calc
_ ≀ Real.exp (-(1/2)*β€–xβ€–^2) * β€–xβ€–^2 := by
gcongr
linarith [(hV.quadratic_bounds x).1]
_ = _ := by ring
have hnum : (∫ x, Real.exp (-V x) * β€–xβ€–^2) ≀ (d : ℝ) * ∫ x, Real.exp (-V x) := by
rw [← hi.2]
apply integral_mono hisq hi.1
intro x
simpa only [mul_comm] using mul_le_mul_of_nonneg_right
(hV.radial_gradient_lower x) (Real.exp_pos (-V x)).le
have hZ : 0 < ∫ x, Real.exp (-V x) := by
rw [← partition_toReal hV.integrable_exp_neg]
exact ENNReal.toReal_pos hV.partition_pos.ne' hV.partition_ne_top
refine ⟨integrable_gibbs_of_weighted hV.smooth.continuous hV.integrable_exp_neg hisq, ?_⟩
rw [integral_gibbs hV.smooth.continuous hV.integrable_exp_neg]
exact (div_le_iffβ‚€ hZ).mpr hnum
end LogConcaveSampling
end UpperProof
end
end
end
end OAI