Download data/lean/OAI/Probability/LogConcave/Sampling/ContinuousFirstOrderReply.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Sampling/ContinuousFirstOrderReply.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/Sampling/ContinuousFirstOrderReply.lean
-
curl -L -o ContinuousFirstOrderReply.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Sampling/ContinuousFirstOrderReply.lean
7.6 kB
| import Mathlib | |
| import OAI.Probability.LogConcave.Model | |
| namespace OAI | |
| section | |
| section | |
| noncomputable section | |
| open MeasureTheory Filter | |
| open scoped ENNReal NNReal Topology | |
| section UpperProof | |
| namespace LogConcaveSampling | |
| theorem Admissible.continuous_firstOrderReply {d : β} {V : Point d β β} | |
| (hV : Admissible V) : Continuous (firstOrderReply V) := by | |
| have hg : Continuous (gradient V) := | |
| (InnerProductSpace.toDual β (Point d)).symm.continuous.comp | |
| (hV.smooth.continuous_fderiv (by norm_num)) | |
| exact hV.smooth.continuous.prodMk hg | |
| theorem OracleAlgorithm.measurable_history {Ξ© : Type*} [MeasurableSpace Ξ©] {d q : β} | |
| (A : OracleAlgorithm Ξ© d q) {V : Point d β β} (hV : Admissible V) (n : β) : | |
| Measurable (fun Ο => A.history V Ο n) := by | |
| induction n with | |
| | zero => exact measurable_const | |
| | succ n ih => | |
| by_cases hn : n < q | |
| Β· have hr : Measurable (fun Ο => | |
| firstOrderReply V (A.query β¨n, hnβ© (Ο, A.history V Ο n))) := | |
| hV.continuous_firstOrderReply.measurable.comp | |
| ((A.query_measurable β¨n, hnβ©).comp (measurable_id.prodMk ih)) | |
| apply Measurable.of_eval | |
| intro i | |
| by_cases hi : i = β¨n, hnβ© | |
| Β· simpa [history, hn, Function.update_apply, hi] using hr | |
| Β· simpa [history, hn, Function.update_apply, hi, Function.comp_def] using | |
| (measurable_pi_apply i).comp ih | |
| Β· simpa [history, hn] using ih | |
| theorem OracleAlgorithm.measurable_run {Ξ© : Type*} [MeasurableSpace Ξ©] {d q : β} | |
| (A : OracleAlgorithm Ξ© d q) {V : Point d β β} (hV : Admissible V) : | |
| Measurable (A.run V) := | |
| A.output_measurable.comp (measurable_id.prodMk (A.measurable_history hV q)) | |
| theorem queryComplexity_le_of_canSample {d q : β} (h : CanSample d q) : | |
| queryComplexity d β€ (q : ββ) := | |
| sInf_le β¨q, h, rflβ© | |
| end LogConcaveSampling | |
| namespace LogConcaveSampling | |
| open scoped RealInnerProductSpace | |
| theorem quadratic_lower_bound_of_hasDerivAt {f g h : β β β} {a : β} | |
| (hf : β t, HasDerivAt f (g t) t) (hg : β t, HasDerivAt g (h t) t) | |
| (ha : β t, a β€ h t) : | |
| f 0 + g 0 + a / 2 β€ f 1 := by | |
| have hd : β t, HasDerivAt (fun s => g s - a * s) (h t - a) t := fun t => by | |
| convert! (hg t).sub ((hasDerivAt_id t).const_mul a) using 1 | |
| simp | |
| have hm : Monotone (fun t => g t - a * t) := | |
| monotone_of_hasDerivAt_nonneg hd (fun t => sub_nonneg.mpr (ha t)) | |
| have hgt : β t, 0 β€ t β g 0 + a * t β€ g t := by | |
| intro t ht | |
| have hh := hm ht | |
| dsimp at hh | |
| linarith | |
| have he : β t, HasDerivAt (fun s => f s - g 0 * s - a / 2 * s ^ 2) | |
| (g t - g 0 - a * t) t := fun t => by | |
| convert! ((hf t).sub ((hasDerivAt_id t).const_mul (g 0))).sub | |
| (((hasDerivAt_id t).pow 2).const_mul (a / 2)) using 1 | |
| simp | |
| ring | |
| have hem : MonotoneOn (fun t => f t - g 0 * t - a / 2 * t ^ 2) (Set.Ici 0) := | |
| monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ici 0) | |
| (fun t _ => (he t).continuousAt.continuousWithinAt) | |
| (fun t _ => (he t).hasDerivWithinAt) | |
| (fun t ht => by | |
| have ht0 : 0 β€ t := Set.mem_Ici.mp (interior_subset ht) | |
| have := hgt t ht0 | |
| linarith) | |
| have hend := hem (by simp : (0 : β) β Set.Ici 0) (by simp : (1 : β) β Set.Ici 0) | |
| (by norm_num : (0 : β) β€ 1) | |
| dsimp at hend | |
| norm_num at hend | |
| linarith | |
| theorem quadratic_bounds_of_hasDerivAt {f g h : β β β} {a b : β} | |
| (hf : β t, HasDerivAt f (g t) t) (hg : β t, HasDerivAt g (h t) t) | |
| (hb : β t, a β€ h t β§ h t β€ b) : | |
| f 0 + g 0 + a / 2 β€ f 1 β§ f 1 β€ f 0 + g 0 + b / 2 := by | |
| refine β¨quadratic_lower_bound_of_hasDerivAt hf hg (fun t => (hb t).1), ?_β© | |
| have hn := quadratic_lower_bound_of_hasDerivAt | |
| (fun t => (hf t).neg) (fun t => (hg t).neg) | |
| (a := -b) (fun t => neg_le_neg (hb t).2) | |
| dsimp at hn | |
| linarith | |
| theorem Admissible.contDiff_gradient {d : β} {V : Point d β β} | |
| (hV : Admissible V) : ContDiff β 1 (gradient V) := by | |
| exact (InnerProductSpace.toDual β (Point d)).symm.contDiff.comp | |
| (hV.smooth.fderiv_right (by norm_num)) | |
| theorem Admissible.quadratic_bounds {d : β} {V : Point d β β} | |
| (hV : Admissible V) (x : Point d) : | |
| βxβ ^ 2 / 2 β€ V x β§ V x β€ βxβ ^ 2 := by | |
| let f : β β β := fun t => V (t β’ x) | |
| let g : β β β := fun t => inner β x (gradient V (t β’ x)) | |
| let h : β β β := fun t => inner β x (fderiv β (gradient V) (t β’ x) x) | |
| have hp : β t : β, HasDerivAt (fun s : β => s β’ x) x t := fun t => by | |
| simpa using (hasDerivAt_id t).smul_const x | |
| have hdg := hV.contDiff_gradient.differentiable (by norm_num) | |
| have hf : β t, HasDerivAt f (g t) t := by | |
| intro t | |
| have hh := ((hV.smooth.differentiable (by norm_num) (t β’ x)).hasFDerivAt).comp_hasDerivAt t (hp t) | |
| convert! hh using 1 | |
| change inner β x (gradient V (t β’ x)) = fderiv β V (t β’ x) x | |
| rw [real_inner_comm] | |
| exact InnerProductSpace.toDual_symm_apply | |
| have hg : β t, HasDerivAt g (h t) t := by | |
| intro t | |
| have hh := (hdg (t β’ x)).hasFDerivAt.comp_hasDerivAt t (hp t) | |
| simpa [g, h, Function.comp_def] using | |
| (hasDerivAt_const t x).inner β hh | |
| have ht := quadratic_bounds_of_hasDerivAt hf hg | |
| (fun t => hV.hessian_bounds (t β’ x) x) | |
| dsimp only [f, g] at ht | |
| rw [zero_smul, one_smul, hV.value_zero, hV.gradient_zero, inner_zero_right, zero_add] at ht | |
| constructor <;> linarith [ht.1, ht.2] | |
| theorem integrable_gaussian_envelope (d : β) {b : β} (hb : 0 < b) : | |
| Integrable (fun x : Point d => Real.exp (-b * βxβ ^ 2)) := by | |
| have hg := (GaussianFourier.integrable_cexp_neg_mul_sq_norm_add | |
| (V := Point d) (b := (b : β)) (by exact hb) 0 0).norm | |
| convert! hg using 1 | |
| funext x | |
| simp [Complex.norm_exp, β Complex.ofReal_pow, β Complex.ofReal_mul] | |
| theorem Admissible.integrable_exp_neg {d : β} {V : Point d β β} | |
| (hV : Admissible V) : Integrable (fun x => Real.exp (-V x)) := by | |
| apply (integrable_gaussian_envelope d (b := 1 / 2) (by norm_num)).mono' | |
| ((Real.continuous_exp.comp hV.smooth.continuous.neg).aestronglyMeasurable) | |
| exact Filter.Eventually.of_forall fun x => by | |
| dsimp only [Function.comp_apply, Pi.neg_apply] | |
| rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] | |
| apply Real.exp_le_exp.mpr | |
| have := (hV.quadratic_bounds x).1 | |
| linarith | |
| theorem Admissible.partition_ne_top {d : β} {V : Point d β β} | |
| (hV : Admissible V) : partition V β β€ := by | |
| exact (lintegral_ofReal_ne_top_iff_integrable | |
| hV.integrable_exp_neg.aestronglyMeasurable | |
| (Filter.Eventually.of_forall fun x => (Real.exp_pos (-V x)).le)).2 | |
| hV.integrable_exp_neg | |
| theorem Admissible.partition_pos {d : β} {V : Point d β β} | |
| (hV : Admissible V) : 0 < partition V := by | |
| have hm : Measurable (gibbsDensity V) := | |
| (ENNReal.continuous_ofReal.comp (Real.continuous_exp.comp hV.smooth.continuous.neg)).measurable | |
| rw [partition, lintegral_pos_iff_support hm] | |
| have hs : Function.support (gibbsDensity V) = Set.univ := by | |
| ext x | |
| simp [Function.mem_support, gibbsDensity, not_le_of_gt (Real.exp_pos (-V x))] | |
| rw [hs] | |
| exact isOpen_univ.measure_pos volume Set.univ_nonempty | |
| theorem Admissible.isProbabilityMeasure_gibbs {d : β} {V : Point d β β} | |
| (hV : Admissible V) : IsProbabilityMeasure (gibbs V) := by | |
| constructor | |
| rw [gibbs, Measure.smul_apply, withDensity_apply _ MeasurableSet.univ, | |
| Measure.restrict_univ] | |
| exact ENNReal.inv_mul_cancel hV.partition_pos.ne' hV.partition_ne_top | |
| end LogConcaveSampling | |
| end UpperProof | |
| end | |
| end | |
| end | |
| end OAI | |