Download data/lean/OAI/Probability/LogConcave/Analysis/Operator.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 33.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Analysis/Operator.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/Analysis/Operator.lean
-
curl -L -o Operator.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Analysis/Operator.lean
33.6 kB
| import Mathlib | |
| import OAI.Probability.LogConcave.Analysis.ProposalLog | |
| import OAI.Probability.LogConcave.Analysis.EulerDrift | |
| 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 | |
| namespace EulerGeometry | |
| open MeasureTheory ProbabilityTheory WithLp | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace β E] | |
| [FiniteDimensional β E] [MeasurableSpace E] [BorelSpace E] | |
| lemma gaussian_noise_product (n : β) : | |
| (Measure.pi (fun _ : Fin n => stdGaussian E)).map (toLp 2) = | |
| stdGaussian (PiLp 2 (fun _ : Fin n => E)) := by | |
| apply Measure.ext_of_charFun | |
| ext t | |
| simp_rw [charFun_pi,charFun_stdGaussian,β Complex.exp_sum] | |
| congr 1 | |
| rw [β Complex.ofReal_pow, PiLp.norm_sq_eq_of_L2] | |
| simp only [Complex.ofReal_sum,Complex.ofReal_pow] | |
| rw [β Finset.sum_neg_distrib,Finset.sum_div] | |
| lemma bounded_integrable {Ξ© : Type*} [MeasurableSpace Ξ©] {ΞΌ : Measure Ξ©} [IsFiniteMeasure ΞΌ] | |
| {f : Ξ© β β} (hf : Measurable f) {B : β} (hb : β x, |f x| β€ B) : Integrable f ΞΌ := | |
| Integrable.mono' (integrable_const B) hf.aestronglyMeasurable | |
| (Filter.Eventually.of_forall (fun x => by simpa only [Real.norm_eq_abs] using hb x)) | |
| def operator (T : E β E) (Ο : β) (f : E β β) (x : E) : β := | |
| β« z, f (T x+Ο β’ z) βstdGaussian E | |
| lemma measurable_operator {T : E β E} (hT : Measurable T) (Ο : β) | |
| {f : E β β} (hf : Measurable f) : Measurable (operator T Ο f) := by | |
| exact (hf.comp ((hT.comp measurable_fst).add (measurable_snd.const_smul Ο))).stronglyMeasurable.integral_prod_right'.measurable | |
| omit [BorelSpace E] in | |
| lemma operator_bound (T : E β E) (Ο : β) {f : E β β} {B : β} | |
| (hb : β x, |f x| β€ B) (x : E) : |operator T Ο f x| β€ B := by | |
| have hn := norm_integral_le_of_norm_le_const (ΞΌ := stdGaussian E) | |
| (f := fun z => f (T x+Ο β’ z)) | |
| (Filter.Eventually.of_forall (fun z => by simpa only [Real.norm_eq_abs] using hb (T x+Ο β’ z))) | |
| simpa only [operator,Real.norm_eq_abs,probReal_univ,mul_one] using hn | |
| omit [BorelSpace E] in | |
| lemma operator_zero (T : E β E) (Ο : β) : operator T Ο (fun _ => 0) = fun _ => 0 := by | |
| funext x | |
| simp [operator] | |
| theorem iterated_defect {T : E β E} (hT : Measurable T) (Ο : β) | |
| (ΞΌ : Measure E) [IsProbabilityMeasure ΞΌ] {D : β} | |
| (hD : β (f : E β β), Measurable f β β B : β, 0 β€ B β | |
| (β x, |f x| β€ B) β |(β« x, operator T Ο f x βΞΌ)-β« x, f x βΞΌ| β€ B*D) | |
| {f : E β β} (hf : Measurable f) {B : β} (hB : 0 β€ B) (hb : β x, |f x| β€ B) | |
| (n : β) : | |
| |(β« x, ((operator T Ο)^[n] f) x βΞΌ)-β« x, f x βΞΌ| β€ (n:β)*B*D := by | |
| induction n generalizing f with | |
| | zero => simp | |
| | succ n ih => | |
| rw [Function.iterate_succ_apply] | |
| have hm := measurable_operator hT Ο hf | |
| have hbound := operator_bound T Ο hb | |
| have ha := ih hm hbound | |
| have hd := hD f hf B hB hb | |
| have ht := abs_sub_le (β« x, ((operator T Ο)^[n] (operator T Ο f)) x βΞΌ) | |
| (β« x, operator T Ο f x βΞΌ) (β« x, f x βΞΌ) | |
| push_cast | |
| nlinarith only [ha,hd,ht] | |
| end EulerGeometry | |
| end LogConcaveSampling | |
| namespace LogConcaveSampling | |
| namespace EulerGeometry | |
| open MeasureTheory ProbabilityTheory WithLp | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace β E] | |
| [FiniteDimensional β E] [MeasurableSpace E] [BorelSpace E] | |
| lemma measurable_iterate {T : E β E} (hT : Measurable T) (Ο : β) (n : β) | |
| {Ξ© : Type*} [MeasurableSpace Ξ©] {x : Ξ© β E} (hx : Measurable x) | |
| {g : Ξ© β Fin n β E} (hg : β i, Measurable (fun z => g z i)) : | |
| Measurable (fun z => iterate T Ο n (x z) (g z)) := by | |
| induction n with | |
| | zero => exact hx | |
| | succ n ih => | |
| exact (hT.comp (ih (fun i => hg i.castSucc))).add ((hg (Fin.last n)).const_smul Ο) | |
| lemma integral_iterate {T : E β E} (hT : Measurable T) (Ο : β) | |
| {f : E β β} (hf : Measurable f) {B : β} (hb : β x, |f x| β€ B) (n : β) (x : E) : | |
| (β« g : Fin n β E, f (iterate T Ο n x g) βMeasure.pi (fun _ => stdGaussian E)) = | |
| ((operator T Ο)^[n] f) x := by | |
| induction n generalizing f with | |
| | zero => simp [iterate] | |
| | succ n ih => | |
| have hm : Measurable (fun p : E Γ (Fin n β E) => f (T (iterate T Ο n x p.2)+Ο β’ p.1)) := by | |
| exact hf.comp ((hT.comp (measurable_iterate hT Ο n measurable_const | |
| (fun i => (measurable_pi_apply i).comp measurable_snd))).add (measurable_fst.const_smul Ο)) | |
| have hi := bounded_integrable (ΞΌ := (stdGaussian E).prod (Measure.pi (fun _ : Fin n => stdGaussian E))) | |
| hm (fun p => hb (T (iterate T Ο n x p.2)+Ο β’ p.1)) | |
| have he : (β« g : Fin (n+1) β E, f (iterate T Ο (n+1) x g) βMeasure.pi (fun _ => stdGaussian E)) = | |
| β« p : E Γ (Fin n β E), f (T (iterate T Ο n x p.2)+Ο β’ p.1) | |
| β(stdGaussian E).prod (Measure.pi (fun _ => stdGaussian E)) := by | |
| rw [β ((measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) => stdGaussian E) (Fin.last n)).symm).integral_comp'] | |
| simp only [MeasurableEquiv.piFinSuccAbove_symm_apply,Fin.insertNthEquiv, | |
| Equiv.coe_fn_mk,Fin.insertNth_last',iterate,Fin.snoc_castSucc,Fin.snoc_last] | |
| rw [he,integral_prod_symm _ hi] | |
| change (β« g : Fin n β E, operator T Ο f (iterate T Ο n x g) βMeasure.pi (fun _ => stdGaussian E)) = _ | |
| rw [ih (measurable_operator hT Ο hf) (operator_bound T Ο hb),Function.iterate_succ_apply] | |
| lemma integral_iterate_gaussian {T : E β E} (hT : Measurable T) (Ο : β) | |
| {f : E β β} (hf : Measurable f) {B : β} (hb : β x, |f x| β€ B) (n : β) (x : E) : | |
| (β« g : PiLp 2 (fun _ : Fin n => E), f (iterate T Ο n x g) βstdGaussian _) = | |
| ((operator T Ο)^[n] f) x := by | |
| rw [β gaussian_noise_product (E := E) n,integral_map (measurable_toLp 2 (Fin n β E)).aemeasurable] | |
| Β· exact integral_iterate hT Ο hf hb n x | |
| Β· exact (hf.comp (measurable_iterate hT Ο n measurable_const | |
| (fun i => (PiLp.proj 2 (fun _ : Fin n => E) i : PiLp 2 (fun _ : Fin n => E) βL[β] E).continuous.measurable))).aestronglyMeasurable | |
| omit [BorelSpace E] in | |
| lemma iterate_operator_bound (T : E β E) (Ο : β) {f : E β β} {B : β} | |
| (hb : β x, |f x| β€ B) (n : β) : β x, |((operator T Ο)^[n] f) x| β€ B := by | |
| induction n generalizing f with | |
| | zero => exact hb | |
| | succ n ih => | |
| rw [Function.iterate_succ_apply] | |
| exact ih (operator_bound T Ο hb) | |
| lemma measurable_iterate_operator {T : E β E} (hT : Measurable T) (Ο : β) | |
| {f : E β β} (hf : Measurable f) (n : β) : Measurable ((operator T Ο)^[n] f) := by | |
| induction n generalizing f with | |
| | zero => exact hf | |
| | succ n ih => | |
| rw [Function.iterate_succ_apply] | |
| exact ih (measurable_operator hT Ο hf) | |
| lemma iterate_operator_modulus {q : ββ₯0} {T : E β E} (hT : LipschitzWith q T) | |
| (Ο : β) {f : E β β} (hf : Measurable f) {B : β} (hb : β x, |f x| β€ B) | |
| {Ξ΄ Ξ΅ : β} (hmod : β x y, dist x y < Ξ΄ β |f x-f y| β€ Ξ΅) | |
| (n : β) {x y : E} (hxy : (q:β)^n*dist x y < Ξ΄) : | |
| |((operator T Ο)^[n] f) x-((operator T Ο)^[n] f) y| β€ Ξ΅ := by | |
| have hi (x : E) : Integrable (fun g : Fin n β E => f (iterate T Ο n x g)) | |
| (Measure.pi (fun _ => stdGaussian E)) := bounded_integrable (ΞΌ := Measure.pi (fun _ : Fin n => stdGaussian E)) | |
| (hf.comp (measurable_iterate hT.continuous.measurable Ο n measurable_const | |
| (fun i => measurable_pi_apply i))) (fun g => hb (iterate T Ο n x g)) | |
| rw [β integral_iterate hT.continuous.measurable Ο hf hb n x, | |
| β integral_iterate hT.continuous.measurable Ο hf hb n y,β integral_sub (hi x) (hi y)] | |
| have hh := norm_integral_le_of_norm_le_const (ΞΌ := Measure.pi (fun _ : Fin n => stdGaussian E)) | |
| (f := fun g => f (iterate T Ο n x g)-f (iterate T Ο n y g)) | |
| (Filter.Eventually.of_forall (fun g => by | |
| rw [Real.norm_eq_abs] | |
| exact hmod _ _ ((initial_contraction hT Ο n x y g).trans_lt hxy))) | |
| simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using hh | |
| end EulerGeometry | |
| end LogConcaveSampling | |
| namespace LogConcaveSampling | |
| namespace EulerGeometry | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped Topology | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace β E] | |
| [FiniteDimensional β E] [MeasurableSpace E] [BorelSpace E] | |
| theorem integral_collapse (ΞΌ : Measure E) [IsProbabilityMeasure ΞΌ] | |
| {q : β β ββ₯0} {T : β β E β E} (hT : β k, LipschitzWith (q k) (T k)) | |
| (Ο : β β β) (N : β β β) | |
| (hq : Tendsto (fun k => (q k:β)^(N k)) atTop (π 0)) | |
| {f : E β β} (hf : UniformContinuous f) {B : β} (hb : β x, |f x| β€ B) (xβ : E) : | |
| Tendsto (fun k => (β« x, ((operator (T k) (Ο k))^[N k] f) x βΞΌ)- | |
| ((operator (T k) (Ο k))^[N k] f) xβ) atTop (π 0) := by | |
| let F := fun k x => ((operator (T k) (Ο k))^[N k] f) x- | |
| ((operator (T k) (Ο k))^[N k] f) xβ | |
| have hm k : Measurable (F k) := | |
| (measurable_iterate_operator (hT k).continuous.measurable (Ο k) hf.continuous.measurable (N k)).sub measurable_const | |
| have hpoint (x : E) : Tendsto (fun k => F k x) atTop (π 0) := by | |
| apply Metric.tendsto_nhds.mpr | |
| intro Ξ΅ hΞ΅ | |
| obtain β¨Ξ΄,hΞ΄,hmodβ© := Metric.uniformContinuous_iff.mp hf (Ξ΅/2) (by positivity) | |
| have hd : Tendsto (fun k => (q k:β)^(N k)*dist x xβ) atTop (π 0) := by | |
| simpa only [zero_mul] using hq.mul_const (dist x xβ) | |
| filter_upwards [hd.eventually (gt_mem_nhds hΞ΄)] with k hk | |
| rw [dist_zero_right,Real.norm_eq_abs] | |
| have hh := iterate_operator_modulus (hT k) (Ο k) hf.continuous.measurable hb | |
| (fun a b hab => (le_of_lt (hmod hab) : dist (f a) (f b) β€ Ξ΅/2)) (N k) hk | |
| exact hh.trans_lt (by linarith) | |
| have hh := tendsto_integral_of_dominated_convergence (ΞΌ := ΞΌ) (f := fun _ => (0:β)) (fun _ => (2*B:β)) | |
| (fun k => (hm k).aestronglyMeasurable) (integrable_const _) (fun k => ?_) ?_ | |
| Β· have he (k : β) : (β« x, F k x βΞΌ) = | |
| (β« x, ((operator (T k) (Ο k))^[N k] f) x βΞΌ)-((operator (T k) (Ο k))^[N k] f) xβ := by | |
| rw [show F k = (fun x => ((operator (T k) (Ο k))^[N k] f) x- | |
| ((operator (T k) (Ο k))^[N k] f) xβ) from rfl, | |
| integral_sub (bounded_integrable | |
| (measurable_iterate_operator (hT k).continuous.measurable (Ο k) hf.continuous.measurable (N k)) | |
| (iterate_operator_bound (T k) (Ο k) hb (N k))) (integrable_const _), | |
| integral_const,probReal_univ,one_smul] | |
| simpa only [he,integral_zero] using hh | |
| Β· filter_upwards [] with x | |
| rw [Real.norm_eq_abs] | |
| exact (abs_sub _ _).trans (by | |
| have hβ := iterate_operator_bound (T k) (Ο k) hb (N k) x | |
| have hβ := iterate_operator_bound (T k) (Ο k) hb (N k) xβ | |
| linarith) | |
| Β· filter_upwards [] with x | |
| exact hpoint x | |
| theorem expectations_tendsto (ΞΌ : Measure E) [IsProbabilityMeasure ΞΌ] | |
| {q : β β ββ₯0} {T : β β E β E} (hT : β k, LipschitzWith (q k) (T k)) | |
| (Ο : β β β) (N : β β β) | |
| (hq : Tendsto (fun k => (q k:β)^(N k)) atTop (π 0)) | |
| {D : β β β} (hD : Tendsto (fun k => (N k:β)*D k) atTop (π 0)) | |
| (hstep : β k (f : E β β), Measurable f β β B : β, 0 β€ B β | |
| (β x, |f x| β€ B) β |(β« x, operator (T k) (Ο k) f x βΞΌ)-β« x, f x βΞΌ| β€ B*D k) | |
| {f : E β β} (hf : UniformContinuous f) {B : β} (hB : 0 β€ B) | |
| (hb : β x, |f x| β€ B) (xβ : E) : | |
| Tendsto (fun k => ((operator (T k) (Ο k))^[N k] f) xβ) atTop (π (β« x, f x βΞΌ)) := by | |
| have ha : Tendsto (fun k => (β« x, ((operator (T k) (Ο k))^[N k] f) x βΞΌ)-β« x, f x βΞΌ) | |
| atTop (π 0) := by | |
| apply tendsto_zero_iff_norm_tendsto_zero.mpr | |
| have hz : Tendsto (fun k => B*((N k:β)*D k)) atTop (π 0) := by | |
| simpa only [mul_zero] using hD.const_mul B | |
| apply squeeze_zero (fun _ => norm_nonneg _) ?_ hz | |
| intro k | |
| simpa only [Real.norm_eq_abs,mul_assoc,mul_comm (N k:β) B] using | |
| iterated_defect (hT k).continuous.measurable (Ο k) ΞΌ (hstep k) | |
| hf.continuous.measurable hB hb (N k) | |
| have hb := integral_collapse ΞΌ hT Ο N hq hf hb xβ | |
| have ht := (ha.sub hb).add_const (β« x, f x βΞΌ) | |
| convert! ht using 1 | |
| Β· funext k; ring_nf | |
| Β· simp only [sub_self,zero_add] | |
| end EulerGeometry | |
| end LogConcaveSampling | |
| namespace LogConcaveSampling | |
| namespace EulerGeometry | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped Topology NNReal | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace β E] | |
| [FiniteDimensional β E] [MeasurableSpace E] [BorelSpace E] | |
| omit [FiniteDimensional β E] [MeasurableSpace E] [BorelSpace E] in | |
| lemma compact_test_lipschitz {f : E β β} (hf : ContDiff β 1 f) | |
| (hc : HasCompactSupport f) : β K : ββ₯0, LipschitzWith K f := by | |
| obtain β¨K,hKβ© := (hc.fderiv β).exists_bound_of_continuous | |
| (hf.continuous_fderiv (by norm_num)) | |
| have hK0 : 0 β€ K := (norm_nonneg (fderiv β f 0)).trans (hK 0) | |
| exact β¨β¨K,hK0β©,lipschitzWith_of_nnnorm_fderiv_le (hf.differentiable (by norm_num)) | |
| (fun x => hK x)β© | |
| theorem poincare_of_euler_approximation (ΞΌ : Measure E) [IsProbabilityMeasure ΞΌ] | |
| {q : β β ββ₯0} {T : β β E β E} | |
| (hT : β k, ContDiff β 1 (T k)) (hl : β k, LipschitzWith (q k) (T k)) | |
| (Ο : β β ββ₯0) (N : β β β) (xβ : E) {C : β} | |
| (hC : β k, (Ο k:β)^2*energy (q k) (N k) β€ C) | |
| (hconv : β f : E β β, UniformContinuous f β (β B, β x, |f x| β€ B) β | |
| Tendsto (fun k => ((operator (T k) (Ο k))^[N k] f) xβ) atTop (π (β« x, f x βΞΌ))) | |
| {f : E β β} (hf : ContDiff β 1 f) (hc : HasCompactSupport f) : | |
| Var[f;ΞΌ] β€ (Real.pi^2/8)*C*β« x, βfderiv β f xβ^2 βΞΌ := by | |
| obtain β¨K,hKβ© := compact_test_lipschitz hf hc | |
| obtain β¨B,hBβ© := hc.exists_bound_of_continuous hf.continuous | |
| have hb : β x, |f x| β€ B := by simpa only [Real.norm_eq_abs] using hB | |
| have hd := hf.continuous_fderiv (by norm_num) | |
| obtain β¨D,hDβ© := (hc.fderiv β).exists_bound_of_continuous hd | |
| have hf2 : HasCompactSupport (fun x => (f x)^2) := | |
| hc.comp_left (g := fun y : β => y^2) (by norm_num) | |
| have hd2 : HasCompactSupport (fun x => βfderiv β f xβ^2) := | |
| (hc.fderiv β).norm.comp_left (g := fun y : β => y^2) (by norm_num) | |
| have hb2 (x : E) : |(f x)^2| β€ B^2 := by | |
| rw [abs_of_nonneg (sq_nonneg _)] | |
| simpa only [sq_abs] using (sq_le_sqβ (abs_nonneg _) ((abs_nonneg (f 0)).trans (hb 0))).mpr (hb x) | |
| have hd2b (x : E) : |βfderiv β f xβ^2| β€ D^2 := by | |
| rw [abs_of_nonneg (sq_nonneg _)] | |
| exact pow_le_pow_leftβ (norm_nonneg _) (hD x) 2 | |
| have hm : MemLp f 2 ΞΌ := MemLp.of_bound hf.continuous.aestronglyMeasurable B | |
| (Filter.Eventually.of_forall hB) | |
| have hfconv := hconv f (hc.uniformContinuous_of_continuous hf.continuous) β¨B,hbβ© | |
| have hf2conv := hconv (fun x => (f x)^2) | |
| (hf2.uniformContinuous_of_continuous (hf.continuous.pow 2)) β¨B^2,hb2β© | |
| have hdconv := hconv (fun x => βfderiv β f xβ^2) | |
| (hd2.uniformContinuous_of_continuous (hd.norm.pow 2)) β¨D^2,hd2bβ© | |
| rw [variance_eq_sub hm] | |
| apply le_of_tendsto_of_tendsto (hf2conv.sub (hfconv.pow 2)) | |
| (hdconv.const_mul ((Real.pi^2/8)*C)) | |
| filter_upwards [] with k | |
| let X := fun g : PiLp 2 (fun _ : Fin (N k) => E) => iterate (T k) (Ο k) (N k) xβ g | |
| let A : ββ₯0 := Ο k * β¨Real.sqrt (energy (q k) (N k)),Real.sqrt_nonneg _β© | |
| have hX : ContDiff β 1 X := contDiff_noise (hT k) (Ο k) (N k) xβ | |
| have hXL : LipschitzWith A X := noise_lipschitz (hl k) (Ο k) (N k) xβ | |
| have hp := GaussianPoincare.variance_lipschitz_image hX hXL hf hK | |
| have hmap {g : E β β} (hg : Measurable g) {b : β} (hb : β x, |g x| β€ b) : | |
| (β« y, g y β(stdGaussian _).map X) = ((operator (T k) (Ο k))^[N k] g) xβ := by | |
| rw [integral_map hX.continuous.aemeasurable hg.aestronglyMeasurable] | |
| exact integral_iterate_gaussian (hT k).continuous.measurable (Ο k) hg hb (N k) xβ | |
| have : IsProbabilityMeasure ((stdGaussian _).map X) := inferInstance | |
| have hmf : MemLp f 2 ((stdGaussian _).map X) := MemLp.of_bound | |
| hf.continuous.aestronglyMeasurable B (Filter.Eventually.of_forall hB) | |
| have hdm := hmap (g := fun x => βfderiv β f xβ^2) (hd.norm.pow 2).measurable hd2b | |
| rw [variance_eq_sub hmf] at hp | |
| simp only [Pi.pow_apply] at hp | |
| rw [hmap (hf.continuous.measurable.pow_const 2) hb2, | |
| hmap hf.continuous.measurable hb,hdm] at hp | |
| have hA : (A:β)^2 β€ C := by | |
| change ((Ο k:β)*Real.sqrt (energy (q k) (N k)))^2 β€ C | |
| rw [mul_pow,Real.sq_sqrt (energy_nonneg (q := (q k:β)) (N k))] | |
| exact hC k | |
| exact hp.trans (mul_le_mul_of_nonneg_right | |
| (mul_le_mul_of_nonneg_left hA (by positivity)) (by | |
| rw [β hdm] | |
| exact integral_nonneg (fun _ => sq_nonneg _))) | |
| end EulerGeometry | |
| end LogConcaveSampling | |
| namespace LogConcaveSampling | |
| namespace EulerGeometry | |
| open Filter | |
| open scoped Topology | |
| theorem exists_consistent_schedule {R : β β β} (hR : Tendsto R (π 0) (π 0)) | |
| (hR0 : β s, 0 β€ R s) {a : β} (ha : 0 < a) : | |
| β (N : β β β) (s : β β β), | |
| (β k, 0 < s k β§ s k β€ 1 β§ (s k)^2 β€ a β§ (N k:β)*(s k)^2=(k:β)+1) β§ | |
| Tendsto (fun k => (N k:β)*(2*(s k)^2*R (s k))) atTop (π 0) := by | |
| have hex (k : β) : β n : β, β s : β, | |
| (0 < s β§ s β€ 1 β§ s^2 β€ a β§ (n:β)*s^2=(k:β)+1) β§ | |
| (n:β)*(2*s^2*R s) β€ 1/((k:β)+1) := by | |
| let h : β β β := fun n => ((k:β)+1)/((n:β)+1) | |
| have ht : Tendsto h atTop (π 0) := by | |
| simpa only [h,mul_one_div,mul_zero] using tendsto_one_div_add_atTop_nhds_zero_nat.const_mul ((k:β)+1) | |
| have hs : Tendsto (fun n => Real.sqrt (h n)) atTop (π 0) := by | |
| simpa only [Real.sqrt_zero] using ht.sqrt | |
| have hr := hR.comp hs | |
| have hb : 0 < 1/(2*((k:β)+1)^2) := by positivity | |
| obtain β¨n,hnβ© := ((ht.eventually (gt_mem_nhds ha)).and | |
| ((hs.eventually (gt_mem_nhds (by norm_num : (0:β)<1))).and | |
| (hr.eventually (gt_mem_nhds hb)))).exists | |
| have hp : 0 < h n := by dsimp [h]; positivity | |
| refine β¨n+1,Real.sqrt (h n),β¨Real.sqrt_pos.mpr hp,hn.2.1.le,?_,?_β©,?_β© | |
| Β· rw [Real.sq_sqrt hp.le] | |
| exact hn.1.le | |
| Β· rw [Real.sq_sqrt hp.le] | |
| dsimp [h] | |
| push_cast | |
| field_simp | |
| Β· rw [Real.sq_sqrt hp.le] | |
| have hh := mul_le_mul_of_nonneg_left hn.2.2.le (show 0 β€ 2*((k:β)+1) by positivity) | |
| have he : (n+1:β)*(2*h n*R (Real.sqrt (h n))) = 2*((k:β)+1)*R (Real.sqrt (h n)) := by | |
| dsimp [h] | |
| field_simp | |
| push_cast | |
| rw [he] | |
| convert! hh using 1 | |
| field_simp | |
| choose N s hs using hex | |
| refine β¨N,s,(fun k => (hs k).1),?_β© | |
| apply squeeze_zero (fun k => mul_nonneg (Nat.cast_nonneg _) (mul_nonneg | |
| (mul_nonneg (by norm_num) (sq_nonneg _)) (hR0 _))) (fun k => (hs k).2) | |
| exact tendsto_one_div_add_atTop_nhds_zero_nat | |
| lemma contraction_geometric_bound {m h : β} (_hm : 0 < m) (hh : 0 β€ 1-m*h) | |
| (n k : β) (hn : (n:β)*h=(k:β)+1) : | |
| (1-m*h)^n β€ (Real.exp (-m))^(k+1) := by | |
| have hq : 1-m*h β€ Real.exp (-m*h) := by | |
| nlinarith only [Real.add_one_le_exp (-m*h)] | |
| have hp := pow_le_pow_leftβ hh hq n | |
| rw [β Real.exp_nat_mul] at hp | |
| rw [β Real.exp_nat_mul] | |
| convert! hp using 1 | |
| congr 1 | |
| push_cast | |
| linear_combination m*hn | |
| lemma schedule_contraction_tendsto {m : β} (hm : 0 < m) | |
| (N : β β β) (s : β β β) | |
| (hq : β k, 0 β€ 1-m*(s k)^2) | |
| (hn : β k, (N k:β)*(s k)^2=(k:β)+1) : | |
| Tendsto (fun k => (1-m*(s k)^2)^(N k)) atTop (π 0) := by | |
| have he := (tendsto_pow_atTop_nhds_zero_of_lt_one (Real.exp_pos (-m)).le | |
| (show Real.exp (-m) < 1 by simpa only [Real.exp_lt_one_iff] using neg_neg_of_pos hm)).comp | |
| (tendsto_add_atTop_nat 1) | |
| exact squeeze_zero (fun k => pow_nonneg (hq k) _) (fun k => contraction_geometric_bound hm (hq k) (N k) k (hn k)) he | |
| end EulerGeometry | |
| end LogConcaveSampling | |
| namespace LogConcaveSampling | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped Topology NNReal ENNReal | |
| lemma euler_noise_energy_bound {m h : β} (hm : 0 < m) (hm1 : m β€ 1) | |
| (hh : 0 < h) (hh1 : h β€ 1) (n : β) : | |
| 2*h*EulerGeometry.energy (1-m*h) n β€ 2/m := by | |
| have hq : 0 β€ 1-m*h := by nlinarith | |
| have hq1 : 1-m*h < 1 := by nlinarith | |
| have hden : 0 < 1-(1-m*h)^2 := by nlinarith | |
| have he := mul_le_mul_of_nonneg_left (EulerGeometry.energy_le hq hq1 n) (by positivity : 0 β€ 2*h) | |
| have hd : 2*h*(1-(1-m*h)^2)β»ΒΉ β€ 2/m := by | |
| rw [β div_eq_mul_inv,div_le_div_iffβ hden hm] | |
| have hp : m*h β€ 1 := by nlinarith | |
| nlinarith [mul_nonneg (mul_nonneg hm.le hh.le) (sub_nonneg.mpr hp)] | |
| exact he.trans hd | |
| lemma euler_operator_gibbs_defect {d : β} {H : Point d β β} | |
| (hH : ContDiff β 2 H) {M : ββ₯0} (hM : LipschitzWith M (gradient H)) | |
| [IsProbabilityMeasure (gibbs H)] | |
| (hp0 : partition H β 0) (hpt : partition H β β€) | |
| (hi : Integrable (fun z => βgradient H zβ^2) (gibbs H)) | |
| {s : β} (hs : s β 0) (hs1 : |s| β€ 1) | |
| {g : Point d β β} (hg : Measurable g) {B : β} (hB : 0 β€ B) (hb : β z, |g z| β€ B) : | |
| |(β« z, EulerGeometry.operator (eulerDrift H (s^2)) (Real.sqrt 2*s) g z βgibbs H)- | |
| β« z, g z βgibbs H| β€ B*(2*s^2*EulerDefect.rate H s) := by | |
| have he := EulerDefect.one_step_gibbs_defect hH hM hp0 hpt hi hs hs1 hg hB hb | |
| have hgm : Measurable (fun p : Point d Γ Point d => g (EulerDefect.proposal H s p.1 p.2)) := | |
| hg.comp (EulerDefect.measurable_joint_map hH s).snd | |
| rw [integral_prod _ (EulerGeometry.bounded_integrable hgm | |
| (fun p => hb (EulerDefect.proposal H s p.1 p.2)))] at he | |
| exact he | |
| theorem Primitive.poincare_compact {d : β} {F : Point d β β} {lam : ββ₯0} | |
| (hF : Primitive F lam) (x : Point d) {r : β} (hr : 0 β€ r) | |
| (hl : (lam:β)*r^2 < 1) {f : Point d β β} | |
| (hf : ContDiff β 1 f) (hc : HasCompactSupport f) : | |
| Var[f;gibbs (primitivePotential F x r)] β€ | |
| (Real.pi^2/8)*(2/(1-(lam:β)*r^2))*β« z, βfderiv β f zβ^2 βgibbs (primitivePotential F x r) := by | |
| let H := primitivePotential F x r | |
| let m : β := 1-(lam:β)*r^2 | |
| have hm : 0 < m := sub_pos.mpr hl | |
| have hm1 : m β€ 1 := by | |
| dsimp [m] | |
| nlinarith [mul_nonneg lam.coe_nonneg (sq_nonneg r)] | |
| have hH : ContDiff β 2 H := hF.contDiff_potential x r | |
| have hg := hF.gradient_potential_lipschitz x hr | |
| have hi := hF.gradient_sq_integrable x hr hl | |
| have hp0 : partition H β 0 := (partition_pos_of_continuous hH.continuous).ne' | |
| have hpt : partition H β β€ := partition_ne_top_of_integrable (hF.integrable_exp_neg_potential x hr hl) | |
| have : IsProbabilityMeasure (gibbs H) := probability_gibbs_of_partition hp0 hpt | |
| obtain β¨N,s,hs,hDβ© := EulerGeometry.exists_consistent_schedule | |
| (EulerDefect.rate_tendsto hH hg hi) (EulerDefect.rate_nonneg H) (a := 1) (by norm_num) | |
| let q : β β ββ₯0 := fun k => β¨1-m*(s k)^2,by | |
| have hp := (hs k).2.2.1 | |
| have hz := sq_nonneg (s k) | |
| nlinarithβ© | |
| let Ο : β β ββ₯0 := fun k => β¨Real.sqrt 2*s k,mul_nonneg (Real.sqrt_nonneg _) (hs k).1.leβ© | |
| let T := fun k => eulerDrift H ((s k)^2) | |
| have hTL (k : β) : LipschitzWith (q k) (T k) := by | |
| have hh := hF.eulerDrift_lipschitz x hr (sq_nonneg (s k)) (hs k).2.2.1 | |
| apply hh.weaken | |
| change 1-(s k)^2+(s k)^2*((lam:β)*r^2) β€ 1-m*(s k)^2 | |
| dsimp [m] | |
| nlinarith | |
| have hTC (k : β) : ContDiff β 1 (T k) := hF.contDiff_eulerDrift x r ((s k)^2) | |
| have hq : Tendsto (fun k => (q k:β)^(N k)) atTop (π 0) := | |
| EulerGeometry.schedule_contraction_tendsto hm N s (fun k => (q k).coe_nonneg) | |
| (fun k => (hs k).2.2.2) | |
| have hstep (k : β) (g : Point d β β) (hg' : Measurable g) (B : β) (hB : 0 β€ B) | |
| (hb : β z, |g z| β€ B) : | |
| |(β« z, EulerGeometry.operator (T k) (Ο k) g z βgibbs H)-β« z, g z βgibbs H| β€ | |
| B*(2*(s k)^2*EulerDefect.rate H (s k)) := by | |
| exact euler_operator_gibbs_defect hH hg hp0 hpt hi (hs k).1.ne' | |
| (by rw [abs_of_pos (hs k).1]; exact (hs k).2.1) hg' hB hb | |
| have hconv (g : Point d β β) (hg' : UniformContinuous g) (hb : β B, β z, |g z| β€ B) : | |
| Tendsto (fun k => ((EulerGeometry.operator (T k) (Ο k))^[N k] g) 0) | |
| atTop (π (β« z, g z βgibbs H)) := by | |
| obtain β¨B,hbβ© := hb | |
| exact EulerGeometry.expectations_tendsto (gibbs H) hTL (fun k => (Ο k:β)) N hq hD hstep | |
| hg' ((abs_nonneg (g 0)).trans (hb 0)) hb 0 | |
| apply EulerGeometry.poincare_of_euler_approximation (gibbs H) hTC hTL Ο N 0 | |
| (C := 2/m) ?_ hconv hf hc | |
| intro k | |
| change (Real.sqrt 2*s k)^2*EulerGeometry.energy (1-m*(s k)^2) (N k) β€ 2/m | |
| rw [mul_pow,Real.sq_sqrt (by norm_num : (0:β)β€2)] | |
| exact euler_noise_energy_bound hm hm1 (sq_pos_of_pos (hs k).1) (hs k).2.2.1 (N k) | |
| end LogConcaveSampling | |
| namespace LogConcaveSampling | |
| namespace PoincareCutoff | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped Topology NNReal ENNReal | |
| variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] | |
| [FiniteDimensional β E] | |
| def bump : ContDiffBump (0 : E) := β¨1,2,by norm_num,by norm_numβ© | |
| def cutoff (n : β) (x : E) : β := (bump (E := E)) (((n:β)+1)β»ΒΉ β’ x) | |
| lemma cutoff_smooth (n : β) : ContDiff β 1 (cutoff (E := E) n) := | |
| ((bump (E := E)).contDiff).comp (contDiff_id.const_smul _) | |
| lemma cutoff_compact (n : β) : HasCompactSupport (cutoff (E := E) n) := by | |
| exact (bump (E := E)).hasCompactSupport.comp_homeomorph | |
| (Homeomorph.smulOfNeZero (((n:β)+1)β»ΒΉ) (by positivity)) | |
| lemma cutoff_nonneg (n : β) (x : E) : 0 β€ cutoff n x := (bump (E := E)).nonneg | |
| lemma cutoff_le_one (n : β) (x : E) : cutoff n x β€ 1 := (bump (E := E)).le_one | |
| lemma cutoff_abs (n : β) (x : E) : |cutoff n x| β€ 1 := by | |
| rw [abs_of_nonneg (cutoff_nonneg n x)] | |
| exact cutoff_le_one n x | |
| lemma cutoff_tendsto (x : E) : Tendsto (fun n => cutoff n x) atTop (π 1) := by | |
| have ht : Tendsto (fun n : β => ((n:β)+1)β»ΒΉ) atTop (π 0) := by | |
| simpa only [one_div] using (tendsto_one_div_add_atTop_nhds_zero_nat : Tendsto (fun n : β => (1:β)/((n:β)+1)) atTop (π 0)) | |
| have hh := (((bump (E := E)).contDiff (n := 1)).continuous.tendsto (0:E)).comp | |
| (show Tendsto (fun n : β => ((n:β)+1)β»ΒΉ β’ x) atTop (π (0:E)) by simpa only [zero_smul] using ht.smul_const x) | |
| have he : (bump (E := E)) (0:E) = 1 := | |
| (bump (E := E)).one_of_mem_closedBall (by simp [bump]) | |
| simpa only [cutoff,he,Function.comp_def] using hh | |
| lemma exists_derivative_bound : β K : ββ₯0, β n x, | |
| βfderiv β (cutoff (E := E) n) xβ β€ (K:β)*((n:β)+1)β»ΒΉ := by | |
| have hc : ContDiff β 1 (bump (E := E)) := (bump (E := E)).contDiff | |
| obtain β¨B,hBβ© := ((bump (E := E)).hasCompactSupport.fderiv β).exists_bound_of_continuous | |
| (hc.continuous_fderiv (by norm_num)) | |
| let K : ββ₯0 := β¨B,(norm_nonneg (fderiv β (bump (E := E)) 0)).trans (hB 0)β© | |
| have hl : LipschitzWith K (bump (E := E)) := | |
| lipschitzWith_of_nnnorm_fderiv_le (hc.differentiable (by norm_num)) (fun x => hB x) | |
| refine β¨K,fun n x => ?_β© | |
| have hs : LipschitzWith (K * β((n:β)+1)β»ΒΉββ) (cutoff (E := E) n) := | |
| hl.comp (lipschitzWith_smul (((n:β)+1)β»ΒΉ) (Ξ² := E)) | |
| have hd := norm_fderiv_le_of_lipschitz β hs (xβ := x) | |
| simpa only [NNReal.coe_mul,coe_nnnorm,Real.norm_eq_abs, | |
| abs_of_nonneg (by positivity : 0 β€ ((n:β)+1)β»ΒΉ)] using hd | |
| lemma cutoff_derivative_tendsto {K : ββ₯0} | |
| (hK : β n x, βfderiv β (cutoff (E := E) n) xβ β€ (K:β)*((n:β)+1)β»ΒΉ) (x : E) : | |
| Tendsto (fun n => fderiv β (cutoff n) x) atTop (π 0) := by | |
| apply tendsto_zero_iff_norm_tendsto_zero.mpr | |
| have ht : Tendsto (fun n : β => (K:β)*((n:β)+1)β»ΒΉ) atTop (π 0) := by | |
| simpa only [one_div,mul_zero] using tendsto_one_div_add_atTop_nhds_zero_nat.const_mul (K:β) | |
| exact squeeze_zero (fun _ => norm_nonneg _) (fun n => hK n x) ht | |
| def truncation (f : E β β) (n : β) : E β β := fun x => cutoff n x*f x | |
| lemma truncation_smooth {f : E β β} (hf : ContDiff β 1 f) (n : β) : | |
| ContDiff β 1 (truncation f n) := (cutoff_smooth n).mul hf | |
| lemma truncation_compact (f : E β β) (n : β) : HasCompactSupport (truncation f n) := | |
| (cutoff_compact n).mul_right | |
| lemma truncation_tendsto (f : E β β) (x : E) : | |
| Tendsto (fun n => truncation f n x) atTop (π (f x)) := by | |
| simpa only [truncation,one_mul] using (cutoff_tendsto x).mul_const (f x) | |
| lemma truncation_derivative {f : E β β} (hf : ContDiff β 1 f) (n : β) (x : E) : | |
| fderiv β (truncation f n) x = cutoff n x β’ fderiv β f x + f x β’ fderiv β (cutoff n) x := | |
| fderiv_fun_mul ((cutoff_smooth n).differentiable (by norm_num) x) | |
| (hf.differentiable (by norm_num) x) | |
| lemma truncation_derivative_tendsto {f : E β β} (hf : ContDiff β 1 f) (x : E) : | |
| Tendsto (fun n => fderiv β (truncation f n) x) atTop (π (fderiv β f x)) := by | |
| obtain β¨K,hKβ© := exists_derivative_bound (E := E) | |
| simp_rw [truncation_derivative hf] | |
| simpa only [one_smul,smul_zero,add_zero] using | |
| ((cutoff_tendsto x).smul_const (fderiv β f x)).add | |
| ((cutoff_derivative_tendsto hK x).const_smul (f x)) | |
| lemma truncation_abs (f : E β β) (n : β) (x : E) : |truncation f n x| β€ |f x| := by | |
| rw [truncation,abs_mul] | |
| exact (mul_le_mul_of_nonneg_right (cutoff_abs n x) (abs_nonneg _)).trans_eq (one_mul _) | |
| lemma truncation_derivative_bound {f : E β β} (hf : ContDiff β 1 f) {K : ββ₯0} | |
| (hK : β n x, βfderiv β (cutoff (E := E) n) xβ β€ (K:β)*((n:β)+1)β»ΒΉ) (n : β) (x : E) : | |
| βfderiv β (truncation f n) xβ β€ βfderiv β f xβ + (K:β)*|f x| := by | |
| rw [truncation_derivative hf] | |
| apply (norm_add_le _ _).trans | |
| rw [norm_smul,norm_smul,Real.norm_eq_abs,Real.norm_eq_abs] | |
| have hle : ((n:β)+1)β»ΒΉ β€ 1 := by | |
| apply inv_le_one_of_one_leβ | |
| exact le_add_of_nonneg_left (Nat.cast_nonneg n) | |
| have hd := (hK n x).trans (by simpa only [mul_one] using mul_le_mul_of_nonneg_left hle K.coe_nonneg) | |
| calc | |
| _ β€ 1*βfderiv β f xβ+|f x| * (K:β) := add_le_add | |
| (mul_le_mul_of_nonneg_right (cutoff_abs n x) (norm_nonneg _)) | |
| (mul_le_mul_of_nonneg_left hd (abs_nonneg _)) | |
| _ = _ := by ring | |
| variable [MeasurableSpace E] [BorelSpace E] | |
| theorem extend (ΞΌ : Measure E) [IsProbabilityMeasure ΞΌ] {Ξ² : β} | |
| (hP : β (g : E β β), ContDiff β 1 g β HasCompactSupport g β | |
| Var[g;ΞΌ] β€ Ξ²*β« x, βfderiv β g xβ^2 βΞΌ) | |
| {f : E β β} (hf : ContDiff β 1 f) (hm : MemLp f 2 ΞΌ) | |
| (hd : Integrable (fun x => βfderiv β f xβ^2) ΞΌ) : | |
| Var[f;ΞΌ] β€ Ξ²*β« x, βfderiv β f xβ^2 βΞΌ := by | |
| obtain β¨K,hKβ© := exists_derivative_bound (E := E) | |
| have hi : Integrable f ΞΌ := hm.integrable (by norm_num) | |
| have h2 : Integrable (fun x => (f x)^2) ΞΌ := hm.integrable_sq | |
| have ht1 : Tendsto (fun n => β« x, truncation f n x βΞΌ) atTop (π (β« x, f x βΞΌ)) := by | |
| exact tendsto_integral_of_dominated_convergence (fun x => |f x|) | |
| (fun n => (truncation_smooth hf n).continuous.aestronglyMeasurable) | |
| hi.abs (fun n => Filter.Eventually.of_forall (by simpa only [Real.norm_eq_abs] using truncation_abs f n)) | |
| (Filter.Eventually.of_forall (truncation_tendsto f)) | |
| have ht2 : Tendsto (fun n => β« x, (truncation f n x)^2 βΞΌ) atTop (π (β« x, (f x)^2 βΞΌ)) := by | |
| apply tendsto_integral_of_dominated_convergence (fun x => (f x)^2) | |
| (fun n => ((truncation_smooth hf n).continuous.pow 2).aestronglyMeasurable) h2 | |
| Β· intro n | |
| filter_upwards [] with x | |
| rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)] | |
| simpa only [sq_abs,Pi.pow_apply] using (sq_le_sqβ (abs_nonneg _) (abs_nonneg _)).mpr (truncation_abs f n x) | |
| Β· exact Filter.Eventually.of_forall (fun x => (truncation_tendsto f x).pow 2) | |
| have htd : Tendsto (fun n => β« x, βfderiv β (truncation f n) xβ^2 βΞΌ) | |
| atTop (π (β« x, βfderiv β f xβ^2 βΞΌ)) := by | |
| apply tendsto_integral_of_dominated_convergence | |
| (fun x => 2*(βfderiv β f xβ^2+(K:β)^2*(f x)^2)) | |
| (fun n => (((truncation_smooth hf n).continuous_fderiv (by norm_num)).norm.pow 2).aestronglyMeasurable) | |
| ((hd.add (h2.const_mul ((K:β)^2))).const_mul 2) | |
| Β· intro n | |
| filter_upwards [] with x | |
| rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)] | |
| change βfderiv β (truncation f n) xβ^2 β€ _ | |
| have hh := truncation_derivative_bound hf hK n x | |
| have hsq := (sq_le_sqβ (norm_nonneg _) (by positivity)).mpr hh | |
| nlinarith [sq_nonneg (βfderiv β f xβ-(K:β)*|f x|),sq_abs (f x)] | |
| Β· exact Filter.Eventually.of_forall (fun x => (truncation_derivative_tendsto hf x).norm.pow 2) | |
| rw [variance_eq_sub hm] | |
| simp only [Pi.pow_apply] | |
| apply le_of_tendsto_of_tendsto (ht2.sub (ht1.pow 2)) (htd.const_mul Ξ²) | |
| filter_upwards [] with n | |
| have hp := hP (truncation f n) (truncation_smooth hf n) (truncation_compact f n) | |
| have hmt : MemLp (truncation f n) 2 ΞΌ := hm.norm.mono' | |
| (truncation_smooth hf n).continuous.aestronglyMeasurable | |
| (Filter.Eventually.of_forall (by simpa only [Real.norm_eq_abs] using truncation_abs f n)) | |
| simpa only [variance_eq_sub hmt,Pi.pow_apply] using hp | |
| end PoincareCutoff | |
| end LogConcaveSampling | |
| end UpperProof | |
| end | |
| end | |
| end | |
| end OAI | |