Download data/lean/OAI/Probability/Renewal/LocalInversion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Renewal/LocalInversion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Renewal/LocalInversion.lean
-
curl -L -o LocalInversion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Renewal/LocalInversion.lean
10.8 kB
| import OAI.Probability.Renewal.Centered | |
| import OAI.Probability.Renewal.GaussianCore | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped Topology ENNReal | |
| namespace HoneycombLocal | |
| def localIntegrand (p : PMF β) (k m : β) (Ο t : β) : β := | |
| charFun (centeredMeasure p) (t / Ο) ^ k * | |
| Complex.exp (-(((m : β) - k * natMean p) / Ο * t : β) * Complex.I) | |
| lemma localIntegrand_eq (p : PMF β) (k m : β) (Ο t : β) : | |
| localIntegrand p k m Ο t = latticeChar p (t / Ο) ^ k * | |
| Complex.exp (-((m : β) * (t / Ο) : β) * Complex.I) := by | |
| rw [localIntegrand, centered_char, mul_pow, β Complex.exp_nat_mul] | |
| have hid : ((k : β) * (-((natMean p * (t / Ο) : β) : β) * Complex.I)) + | |
| (-(((m : β) - k * natMean p) / Ο * t : β) * Complex.I) = | |
| -((m : β) * (t / Ο) : β) * Complex.I := by | |
| push_cast | |
| ring | |
| rw [mul_comm (Complex.exp _), mul_assoc, β Complex.exp_add, hid] | |
| lemma continuous_localIntegrand (p : PMF β) (k m : β) (Ο : β) : | |
| Continuous (localIntegrand p k m Ο) := by | |
| unfold localIntegrand | |
| fun_prop | |
| lemma norm_localIntegrand (p : PMF β) (k m : β) (Ο t : β) : | |
| βlocalIntegrand p k m Ο tβ = βlatticeChar p (t / Ο)β ^ k := by | |
| rw [localIntegrand_eq, norm_mul, norm_pow] | |
| simp only [β Complex.ofReal_neg, Complex.norm_exp_ofReal_mul_I, mul_one] | |
| lemma scaled_inversion (p : PMF β) (k m : β) {Ο : β} (hΟ : 0 < Ο) : | |
| (β« t : β in Icc (-Real.pi * Ο) (Real.pi * Ο), localIntegrand p k m Ο t) = | |
| (2 * Real.pi * Ο : β) * ((sumLaw p k m).toReal : β) := by | |
| rw [integral_Icc_eq_integral_Ioc, β intervalIntegral.integral_of_le (by nlinarith [Real.pi_pos] : -Real.pi * Ο β€ Real.pi * Ο)] | |
| simp_rw [localIntegrand_eq] | |
| rw [intervalIntegral.integral_comp_div (fun t => latticeChar p t ^ k * | |
| Complex.exp (-((m : β) * t : β) * Complex.I)) hΟ.ne'] | |
| simp only [mul_div_cancel_rightβ _ hΟ.ne', sumLaw_inversion, Complex.real_smul] | |
| ring | |
| def gaussianIntegrand (b t : β) : β := | |
| Complex.exp (-((t : β) ^ 2 / 2)) * Complex.exp (-((b * t : β) : β) * Complex.I) | |
| lemma continuous_gaussianIntegrand (b : β) : Continuous (gaussianIntegrand b) := by | |
| unfold gaussianIntegrand | |
| fun_prop | |
| lemma gaussianIntegrand_re (b t : β) : | |
| (gaussianIntegrand b t).re = Real.exp (-t ^ 2 / 2) * Real.cos (b * t) := by | |
| have hid : -((t : β) ^ 2 / 2) = ((-t ^ 2 / 2 : β) : β) := by push_cast; ring | |
| rw [gaussianIntegrand, hid, β Complex.ofReal_exp] | |
| rw [Complex.mul_re] | |
| simp only [Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero] | |
| simp [Complex.exp_re, Real.cos_neg] | |
| lemma gaussian_core_lower {Ο b : β} (hΟ : 1 β€ Ο) (hb : |b| * Ο β€ 1) : | |
| Real.exp (-1) β€ (β« t : β in Icc (-Ο) Ο, gaussianIntegrand b t).re := by | |
| have hΟ0 : 0 < Ο := lt_of_lt_of_le zero_lt_one hΟ | |
| have hcos {t : β} (ht : t β Icc (-Ο) Ο) : (1 : β) / 2 β€ Real.cos (b * t) := by | |
| have habs : |b * t| β€ 1 := by | |
| rw [abs_mul] | |
| exact (mul_le_mul_of_nonneg_left (abs_le.mpr ht) (abs_nonneg b)).trans hb | |
| have hsq : (b * t) ^ 2 β€ 1 := by nlinarith [sq_abs (b * t), abs_nonneg (b * t)] | |
| nlinarith [Real.one_sub_sq_div_two_le_cos (x := b * t)] | |
| have hcont : Continuous (fun t => (gaussianIntegrand b t).re) := Complex.continuous_re.comp (continuous_gaussianIntegrand b) | |
| change Real.exp (-1) β€ RCLike.re (β« t : β in Icc (-Ο) Ο, gaussianIntegrand b t) | |
| rw [β integral_re (continuous_gaussianIntegrand b).integrableOn_Icc] | |
| calc | |
| Real.exp (-1) = β« _ : β in Icc (-1) 1, Real.exp (-1) / 2 := by norm_num; ring | |
| _ β€ β« t : β in Icc (-1) 1, (gaussianIntegrand b t).re := by | |
| apply setIntegral_mono_on (integrable_const _) hcont.integrableOn_Icc measurableSet_Icc | |
| intro t ht | |
| have htΟ : t β Icc (-Ο) Ο := β¨by linarith [ht.1], ht.2.trans hΟβ© | |
| rw [gaussianIntegrand_re] | |
| have ht2 : t ^ 2 β€ 1 := by nlinarith [ht.1, ht.2] | |
| have hexp : Real.exp (-1) β€ Real.exp (-t ^ 2 / 2) := Real.exp_le_exp.mpr (by linarith) | |
| have hh := mul_le_mul hexp (hcos htΟ) (by norm_num : (0 : β) β€ 1 / 2) (Real.exp_pos _).le | |
| nlinarith | |
| _ β€ β« t : β in Icc (-Ο) Ο, (gaussianIntegrand b t).re := by | |
| apply setIntegral_mono_set hcont.integrableOn_Icc | |
| Β· filter_upwards [ae_restrict_mem measurableSet_Icc] with t ht | |
| rw [gaussianIntegrand_re] | |
| exact mul_nonneg (Real.exp_pos _).le (by linarith [hcos ht]) | |
| Β· exact ae_of_all _ (fun t ht => β¨by linarith [ht.1], ht.2.trans hΟβ©) | |
| lemma local_core_error (p : PMF β) | |
| (h3 : Integrable (fun j : β => (j : β) ^ 3) p.toMeasure) | |
| {k : β} (hk : 0 < k) (m : β) {Ο Ο : β} (hΟ : 0 < Ο) (hΟ : 0 β€ Ο) | |
| (hvar : Ο ^ 2 = k * natVariance p) (hsmall : Ο ^ 2 β€ 2 * k) : | |
| β(β« t : β in Icc (-Ο) Ο, localIntegrand p k m Ο t) - | |
| (β« t : β in Icc (-Ο) Ο, gaussianIntegrand (((m : β) - k * natMean p) / Ο) t)β β€ | |
| 2 * Ο * ((k * natThird p / Ο ^ 3) * Ο ^ 3 / 2 + Ο ^ 4 / (4 * k)) := by | |
| have h1 : Integrable (fun j : β => (j : β)) p.toMeasure := by | |
| have hh := (nat_memLp p (by norm_num : (3 : β) β 0) h3).mono_exponent (by norm_num : (1 : ENNReal) β€ 3) | |
| simpa using hh.integrable | |
| rw [β integral_sub (continuous_localIntegrand p k m Ο).integrableOn_Icc | |
| (continuous_gaussianIntegrand _).integrableOn_Icc] | |
| have hh := norm_setIntegral_le_of_norm_le_const (ΞΌ := volume) (s := Icc (-Ο) Ο) | |
| (f := fun t => localIntegrand p k m Ο t - gaussianIntegrand (((m : β) - k * natMean p) / Ο) t) | |
| (C := (k * natThird p / Ο ^ 3) * Ο ^ 3 / 2 + Ο ^ 4 / (4 * k)) (by simp) (fun t ht => ?_) | |
| Β· rw [Real.volume_real_Icc] at hh | |
| simp only [sub_neg_eq_add, max_eq_left (by linarith : 0 β€ Ο + Ο)] at hh | |
| exact hh.trans_eq (by ring) | |
| Β· have ht2 : t ^ 2 β€ Ο ^ 2 := by | |
| nlinarith [mul_nonneg (sub_nonneg.mpr ht.2) (by linarith [ht.1] : 0 β€ Ο + t)] | |
| have h := normalized_gaussian_power_error (centered_memLp p (by norm_num) h3) | |
| (centered_mean p h1) hk hΟ (by simpa only [centered_variance] using hvar) t (ht2.trans hsmall) | |
| rw [centered_third] at h | |
| dsimp only [localIntegrand, gaussianIntegrand] | |
| rw [β sub_mul, norm_mul, β Complex.ofReal_neg, Complex.norm_exp_ofReal_mul_I, mul_one] | |
| refine h.trans ?_ | |
| apply add_le_add | |
| Β· apply div_le_div_of_nonneg_right _ (by norm_num) | |
| exact mul_le_mul_of_nonneg_left (pow_le_pow_leftβ (abs_nonneg t) (abs_le.mpr ht) 3) | |
| (by positivity [natThird_nonneg p]) | |
| Β· apply div_le_div_of_nonneg_right _ (by positivity) | |
| nlinarith [mul_nonneg (sub_nonneg.mpr ht2) (by positivity : 0 β€ Ο ^ 2 + t ^ 2)] | |
| lemma fourier_tail_bound {f : β β β} (hf : Continuous f) {g : β β β} | |
| (hg : Integrable g) (hg0 : β t, 0 β€ g t) {R Ο Ξ· : β} (hR : 0 β€ R) (hΞ· : 0 β€ Ξ·) | |
| (hbound : β t β Icc (-R) R, βf tβ β€ g t + Ξ·) : | |
| ββ« t : β in Icc (-R) R \ Icc (-Ο) Ο, f tβ β€ | |
| (β« t : β in (Icc (-Ο) Ο)αΆ, g t) + 2 * R * Ξ· := by | |
| let s := Icc (-R) R \ Icc (-Ο) Ο | |
| have hfi : IntegrableOn f s := hf.integrableOn_Icc.mono_set sdiff_subset | |
| have hci : IntegrableOn (fun _ : β => Ξ·) s := | |
| (integrableOn_const (C := Ξ·) (s := Icc (-R) R) (by simp)).mono_set sdiff_subset | |
| calc | |
| ββ« t in s, f tβ β€ β« t in s, βf tβ := norm_integral_le_integral_norm _ | |
| _ β€ β« t in s, g t + Ξ· := by | |
| apply setIntegral_mono_on hfi.norm (hg.integrableOn.add hci) (measurableSet_Icc.diff measurableSet_Icc) | |
| exact fun t ht => hbound t ht.1 | |
| _ = (β« t in s, g t) + β« _ in s, Ξ· := integral_add hg.integrableOn hci | |
| _ β€ (β« t in (Icc (-Ο) Ο)αΆ, g t) + β« _ : β in Icc (-R) R, Ξ· := by | |
| apply add_le_add | |
| Β· apply setIntegral_mono_set hg.integrableOn (ae_of_all _ hg0) | |
| exact ae_of_all _ (fun _ ht => ht.2) | |
| Β· apply setIntegral_mono_set (integrable_const _) (ae_of_all _ (fun _ => hΞ·)) | |
| exact ae_of_all _ (fun _ ht => ht.1) | |
| _ = _ := by | |
| simp only [integral_const, smul_eq_mul, measureReal_restrict_apply_univ, Real.volume_real_Icc] | |
| rw [max_eq_left (by linarith : 0 β€ R - -R)] | |
| ring | |
| lemma local_lower_of_envelope (p : PMF β) | |
| (h3 : Integrable (fun j : β => (j : β) ^ 3) p.toMeasure) | |
| {k : β} (hk : 0 < k) (m : β) {Ο Ο Ξ· : β} (hΟ : 0 < Ο) (hΟ : 1 β€ Ο) | |
| (hvar : Ο ^ 2 = k * natVariance p) (hsmall : Ο ^ 2 β€ 2 * k) | |
| (hwidth : Ο β€ Real.pi * Ο) | |
| (hcenter : |((m : β) - k * natMean p) / Ο| * Ο β€ 1) | |
| {g : β β β} (hg : Integrable g) (hg0 : β t, 0 β€ g t) (hΞ· : 0 β€ Ξ·) | |
| (hbound : β t β Icc (-Real.pi * Ο) (Real.pi * Ο), | |
| βlatticeChar p (t / Ο)β ^ k β€ g t + Ξ·) | |
| (htail : (β« t : β in (Icc (-Ο) Ο)αΆ, g t) β€ Real.exp (-1) / 4) | |
| (hhigh : 2 * (Real.pi * Ο) * Ξ· β€ Real.exp (-1) / 4) | |
| (herror : 2 * Ο * ((k * natThird p / Ο ^ 3) * Ο ^ 3 / 2 + Ο ^ 4 / (4 * k)) β€ | |
| Real.exp (-1) / 4) : | |
| Real.exp (-1) / (8 * Real.pi * Ο) β€ (sumLaw p k m).toReal := by | |
| have hΟ0 : 0 β€ Ο := zero_le_one.trans hΟ | |
| have hR : 0 β€ Real.pi * Ο := by positivity | |
| have hsub : Icc (-Ο) Ο β Icc (-Real.pi * Ο) (Real.pi * Ο) := | |
| fun _ ht => β¨by linarith [ht.1], ht.2.trans hwidthβ© | |
| have he := (local_core_error p h3 hk m hΟ hΟ0 hvar hsmall).trans herror | |
| have hc := gaussian_core_lower hΟ hcenter | |
| have ht := fourier_tail_bound (Ο := Ο) (continuous_localIntegrand p k m Ο) hg hg0 hR hΞ· (by | |
| intro t ht | |
| rw [norm_localIntegrand] | |
| exact hbound t (by simpa [neg_mul] using ht)) | |
| have htail' : ββ« t : β in Icc (-Real.pi * Ο) (Real.pi * Ο) \ Icc (-Ο) Ο, | |
| localIntegrand p k m Ο tβ β€ Real.exp (-1) / 2 := by | |
| have hh := ht.trans (add_le_add htail hhigh) | |
| simp only [β neg_mul] at hh | |
| linarith | |
| have hdiff := Complex.re_le_norm ((β« t : β in Icc (-Ο) Ο, gaussianIntegrand | |
| (((m : β) - k * natMean p) / Ο) t) - β« t : β in Icc (-Ο) Ο, localIntegrand p k m Ο t) | |
| rw [norm_sub_rev, Complex.sub_re] at hdiff | |
| have hl := (abs_le.mp (Complex.abs_re_le_norm (β« t : β in Icc (-Real.pi * Ο) (Real.pi * Ο) \ Icc (-Ο) Ο, | |
| localIntegrand p k m Ο t))).1 | |
| have hlower : -Real.exp (-1) / 2 β€ | |
| (β« t : β in Icc (-Real.pi * Ο) (Real.pi * Ο) \ Icc (-Ο) Ο, | |
| localIntegrand p k m Ο t).re := by linarith | |
| rw [setIntegral_sdiff measurableSet_Icc (continuous_localIntegrand p k m Ο).integrableOn_Icc hsub, | |
| Complex.sub_re, scaled_inversion p k m hΟ] at hlower | |
| norm_num [Complex.mul_re] at hlower | |
| apply (div_le_iffβ (by positivity : 0 < 8 * Real.pi * Ο)).mpr | |
| nlinarith | |
| end HoneycombLocal | |
| end | |
| end OAI | |