Download data/lean/OAI/Probability/LogConcave/Analysis/GaussianProposalPotential.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.51 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Analysis/GaussianProposalPotential.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/Analysis/GaussianProposalPotential.lean
-
curl -L -o GaussianProposalPotential.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Analysis/GaussianProposalPotential.lean
5.51 kB
| import Mathlib | |
| import OAI.Probability.LogConcave.Analysis.PrimitivePotentialModeBounds | |
| import OAI.Probability.LogConcave.Sampling.UnitUniform | |
| 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 scoped RealInnerProductSpace | |
| def gaussianProposalPotential (d : β) (x : Point d) : β := inner β x x / 2 | |
| lemma gaussianProposalPotential_eq (d : β) (x : Point d) : | |
| gaussianProposalPotential d x = βxβ^2/2 := by | |
| simp [gaussianProposalPotential] | |
| lemma gaussianProposalPotential_hasGradientAt (d : β) (x : Point d) : | |
| HasGradientAt (gaussianProposalPotential d) x x := by | |
| apply hasGradientAt_iff_hasFDerivAt.mpr | |
| have hd := ((hasFDerivAt_id x).inner β (hasFDerivAt_id x)).const_smul (1/2 : β) | |
| convert! hd using 1 | |
| Β· ext y | |
| simp only [gaussianProposalPotential,Pi.smul_apply,smul_eq_mul,id_eq] | |
| ring | |
| Β· ext y | |
| change inner β x y = (1/2 : β)*(inner β x y+inner β y x) | |
| rw [real_inner_comm y x] | |
| ring | |
| @[simp] lemma gaussianProposalPotential_gradient (d : β) : | |
| gradient (gaussianProposalPotential d) = id := | |
| gradient_eq (gaussianProposalPotential_hasGradientAt d) | |
| lemma gaussianProposalPotential_admissible (d : β) : | |
| Admissible (gaussianProposalPotential d) := by | |
| refine β¨(contDiff_id.inner β contDiff_id).div_const 2, ?_, ?_, ?_β© | |
| Β· simp [gaussianProposalPotential] | |
| Β· simp | |
| Β· intro x v | |
| simp only [gaussianProposalPotential_gradient,fderiv_id,ContinuousLinearMap.id_apply, | |
| real_inner_self_eq_norm_sq] | |
| constructor | |
| Β· rfl | |
| Β· nlinarith [sq_nonneg βvβ] | |
| lemma partition_comparison {d : β} {V : Point d β β} (hV : Admissible V) : | |
| (2:β)^(- (d:β€)) * (partition (gaussianProposalPotential d)).toReal β€ | |
| (partition V).toReal β§ | |
| (partition V).toReal β€ (partition (gaussianProposalPotential d)).toReal := by | |
| have hB := gaussianProposalPotential_admissible d | |
| rw [partition_toReal hV.integrable_exp_neg,partition_toReal hB.integrable_exp_neg] | |
| constructor | |
| Β· have hs := Measure.integral_comp_smul_of_nonneg (volume : Measure (Point d)) | |
| (fun x => Real.exp (-gaussianProposalPotential d x)) (2:β) (hR := by norm_num) | |
| simp only [finrank_euclideanSpace_fin,smul_eq_mul] at hs | |
| have hh : Integrable (fun x : Point d => Real.exp (-gaussianProposalPotential d ((2:β) β’ x))) := by | |
| convert integrable_gaussian_envelope d (b := 2) (by norm_num) using 1 | |
| ext x | |
| rw [gaussianProposalPotential_eq,norm_smul,Real.norm_of_nonneg (by norm_num)] | |
| congr 1 | |
| ring | |
| rw [zpow_neg,zpow_natCast,β hs] | |
| apply integral_mono hh hV.integrable_exp_neg | |
| intro x | |
| apply Real.exp_le_exp.mpr | |
| rw [gaussianProposalPotential_eq,norm_smul,Real.norm_of_nonneg (by norm_num)] | |
| have ht := (hV.quadratic_bounds x).2 | |
| nlinarith [sq_nonneg βxβ] | |
| Β· apply integral_mono hV.integrable_exp_neg hB.integrable_exp_neg | |
| intro x | |
| apply Real.exp_le_exp.mpr | |
| rw [gaussianProposalPotential_eq] | |
| linarith [(hV.quadratic_bounds x).1] | |
| def gaussianAcceptance {d : β} (V : Point d β β) (x : Point d) : β := | |
| Real.exp (-V x+gaussianProposalPotential d x) | |
| lemma gaussianAcceptance_bounds {d : β} {V : Point d β β} (hV : Admissible V) (x : Point d) : | |
| 0 β€ gaussianAcceptance V x β§ gaussianAcceptance V x β€ 1 := by | |
| refine β¨(Real.exp_pos _).le, ?_β© | |
| apply Real.exp_le_one_iff.mpr | |
| rw [gaussianProposalPotential_eq] | |
| linarith [(hV.quadratic_bounds x).1] | |
| @[fun_prop] lemma measurable_gaussianAcceptance {d : β} {V : Point d β β} (hV : Admissible V) : | |
| Measurable (gaussianAcceptance V) := | |
| (Real.continuous_exp.comp (hV.smooth.continuous.neg.add | |
| (gaussianProposalPotential_admissible d).smooth.continuous)).measurable | |
| lemma gaussian_accepted_measure {d : β} {V : Point d β β} (hV : Admissible V) : | |
| (((gibbs (gaussianProposalPotential d)).prod unitUniform).restrict | |
| (acceptanceEvent (gaussianAcceptance V))).map Prod.fst = | |
| ENNReal.ofReal ((partition V).toReal/(partition (gaussianProposalPotential d)).toReal) β’ gibbs V := by | |
| have hB := gaussianProposalPotential_admissible d | |
| have := hB.isProbabilityMeasure_gibbs | |
| rw [accepted_measure _ (measurable_gaussianAcceptance hV) | |
| (fun x => (gaussianAcceptance_bounds hV x).1) (fun x => (gaussianAcceptance_bounds hV x).2)] | |
| rw [gibbs,withDensity_smul_measure,β withDensity_mul] | |
| Β· have he : gibbsDensity (gaussianProposalPotential d) * | |
| (fun x => ENNReal.ofReal (gaussianAcceptance V x)) = gibbsDensity V := by | |
| funext x | |
| simp only [Pi.mul_apply,gibbsDensity,gaussianAcceptance,β ENNReal.ofReal_mul (Real.exp_pos _).le, | |
| β Real.exp_add] | |
| congr 2 | |
| ring | |
| rw [he,gibbs,smul_smul] | |
| congr 1 | |
| rw [ENNReal.ofReal_div_of_pos (ENNReal.toReal_pos hB.partition_pos.ne' hB.partition_ne_top), | |
| ENNReal.ofReal_toReal hV.partition_ne_top,ENNReal.ofReal_toReal hB.partition_ne_top,div_eq_mul_inv] | |
| rw [mul_right_comm,ENNReal.mul_inv_cancel hV.partition_pos.ne' hV.partition_ne_top,one_mul] | |
| Β· exact (Real.continuous_exp.comp hB.smooth.continuous.neg).measurable.ennreal_ofReal | |
| Β· exact (measurable_gaussianAcceptance hV).ennreal_ofReal | |
| end LogConcaveSampling | |
| end UpperProof | |
| end | |
| end | |
| end | |
| end OAI | |