Download data/lean/OAI/Probability/LogConcave/Analysis/PrimitivePotentialModeBounds.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 15.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Analysis/PrimitivePotentialModeBounds.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/Analysis/PrimitivePotentialModeBounds.lean
-
curl -L -o PrimitivePotentialModeBounds.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Analysis/PrimitivePotentialModeBounds.lean
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 | |