Download data/lean/OAI/NumberTheory/Jacobsthal/Paths/HighPrefixState.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.66 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Paths/HighPrefixState.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/Jacobsthal/Paths/HighPrefixState.lean
-
curl -L -o HighPrefixState.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Paths/HighPrefixState.lean
8.66 kB
| import Mathlib.Analysis.SpecialFunctions.Integrals.Basic | |
| import Mathlib.Probability.Distributions.Bernoulli | |
| import OAI.NumberTheory.Jacobsthal.Probability.HarmonicPrefixKernel | |
| namespace OAI | |
| namespace Erdos970 | |
| section | |
| namespace ErdosPrimeInputs.HarmonicPrefixTilt | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped ENNReal | |
| open WeightedKernelMass HarmonicPrefixKernel | |
| noncomputable def squareBoundE (ell B : β) : ββ₯0β := ENNReal.ofReal (bound ell B ^ 2) | |
| lemma squareBoundE_measurable (ell : β) : Measurable (squareBoundE ell) := by | |
| unfold squareBoundE bound | |
| fun_prop | |
| lemma linear_lintegral {ell B : β} (hell : 0<ell) (hB : ellβ€B) : | |
| (β«β» t in Ioc ell B, ENNReal.ofReal (t/ell^2)) = | |
| ENNReal.ofReal (((B^2-ell^2)/2)/ell^2) := by | |
| have hi : IntegrableOn (fun t : β => t/ell^2) (Ioc ell B) := | |
| ((continuous_id.div_const (ell^2)).continuousOn.integrableOn_Icc).mono_set Ioc_subset_Icc_self | |
| have hn : βα΅ t βvolume.restrict (Ioc ell B), 0β€t/ell^2 := by | |
| apply ae_restrict_of_forall_mem measurableSet_Ioc | |
| intro t ht | |
| exact div_nonneg (hell.le.trans ht.1.le) (sq_nonneg _) | |
| rw [β ofReal_integral_eq_lintegral_ofReal hi hn,β intervalIntegral.integral_of_le hB] | |
| simp only [div_eq_mul_inv,intervalIntegral.integral_mul_const,_root_.integral_id] | |
| lemma harmonic_square_integral {ell B : β} (hell : 0<ell) (hB : ellβ€B) : | |
| (β«β» t, squareBoundE ell t βkernel ell B) = | |
| ENNReal.ofReal (((B^2-ell^2)/2)/ell^2) := by | |
| rw [kernel_lintegral ell B (squareBoundE_measurable ell)] | |
| calc | |
| _ = β«β» t in Ioc ell B, ENNReal.ofReal (t/ell^2) := by | |
| apply lintegral_congr_ae | |
| apply ae_restrict_of_forall_mem measurableSet_Ioc | |
| intro t ht | |
| have ht0 : 0<t := hell.trans ht.1 | |
| change ENNReal.ofReal (tβ»ΒΉ)*ENNReal.ofReal (bound ell t ^ 2) = _ | |
| rw [bound_on hell ht.1.le,β ENNReal.ofReal_mul (inv_nonneg.mpr ht0.le)] | |
| congr 1 | |
| field_simp | |
| _ = _ := linear_lintegral hell hB | |
| theorem schur_two {ell : β} (hell : 0<ell) (B : β) : | |
| 1+2*(β«β» t, squareBoundE ell t βkernel ell B) = squareBoundE ell B := by | |
| by_cases hB : ellβ€B | |
| Β· rw [harmonic_square_integral hell hB,squareBoundE,bound_on hell hB] | |
| have hD : 0β€((B^2-ell^2)/2)/ell^2 := by | |
| apply div_nonneg | |
| Β· apply div_nonneg | |
| Β· nlinarith | |
| Β· norm_num | |
| Β· exact sq_nonneg _ | |
| calc | |
| _ = ENNReal.ofReal (1+2*(((B^2-ell^2)/2)/ell^2)) := by | |
| rw [ENNReal.ofReal_add (by norm_num) (mul_nonneg (by norm_num) hD), | |
| ENNReal.ofReal_mul (by norm_num : (0:β)β€2)] | |
| norm_num | |
| _ = _ := by | |
| congr 1 | |
| field_simp | |
| ring | |
| Β· rw [kernel_eq_zero (le_of_not_ge hB),squareBoundE,bound_below hell (le_of_not_ge hB)] | |
| simp | |
| theorem weighted_prefix_mass {ell B : β} (hell : 0<ell) (hB : ellβ€B) : | |
| (β' n : β, (2:ββ₯0β)^n * mass (kernel ell) n B) β€ ENNReal.ofReal ((B/ell)^2) := by | |
| have h := weighted_total_bound (kernel ell) 2 (squareBoundE ell) (fun x => (schur_two hell x).le) B | |
| simpa only [squareBoundE,bound_on hell hB] using h | |
| end ErdosPrimeInputs.HarmonicPrefixTilt | |
| end | |
| section | |
| namespace ErdosPrimeInputs.HarmonicLongPrefixes | |
| open scoped ENNReal | |
| open WeightedKernelMass HarmonicPrefixKernel HarmonicPrefixTilt | |
| noncomputable def tailMass (a : β β ββ₯0β) (m : β) : ββ₯0β := | |
| β' n : β, if mβ€n then a n else 0 | |
| lemma half_power_antitone {m n : β} (hmn : mβ€n) : | |
| ((2:ββ₯0β)β»ΒΉ)^n β€ ((2:ββ₯0β)β»ΒΉ)^m := by | |
| obtain β¨k,rflβ© := Nat.exists_eq_add_of_le hmn | |
| have hp : ((2:ββ₯0β)β»ΒΉ)^k β€ 1 := pow_le_oneβ zero_le (by norm_num) | |
| calc | |
| _ = ((2:ββ₯0β)β»ΒΉ)^m * ((2:ββ₯0β)β»ΒΉ)^k := pow_add _ _ _ | |
| _ β€ ((2:ββ₯0β)β»ΒΉ)^m * 1 := mul_le_mul le_rfl hp zero_le zero_le | |
| _ = _ := mul_one _ | |
| lemma unweight_two (a : ββ₯0β) (n : β) : | |
| a = ((2:ββ₯0β)β»ΒΉ)^n * ((2:ββ₯0β)^n*a) := by | |
| have hi : (2:ββ₯0β)β»ΒΉ*2=1 := ENNReal.inv_mul_cancel (by norm_num) (by norm_num) | |
| calc | |
| a = 1*a := (one_mul _).symm | |
| _ = ((2:ββ₯0β)β»ΒΉ*2)^n*a := by rw [hi,one_pow] | |
| _ = _ := by rw [mul_pow,mul_assoc] | |
| theorem weighted_tail_bound (a : β β ββ₯0β) (m : β) {W : ββ₯0β} | |
| (hW : (β' n : β, (2:ββ₯0β)^n*a n) β€ W) : | |
| tailMass a m β€ ((2:ββ₯0β)β»ΒΉ)^m*W := by | |
| calc | |
| _ β€ β' n : β, ((2:ββ₯0β)β»ΒΉ)^m*((2:ββ₯0β)^n*a n) := by | |
| apply ENNReal.tsum_le_tsum | |
| intro n | |
| by_cases hn : mβ€n | |
| Β· rw [ite_eq_left hn] | |
| exact (unweight_two (a n) n).trans_le (mul_le_mul (half_power_antitone hn) le_rfl zero_le zero_le) | |
| Β· rw [ite_eq_right hn] | |
| exact zero_le | |
| _ = ((2:ββ₯0β)β»ΒΉ)^m*(β' n : β, (2:ββ₯0β)^n*a n) := ENNReal.tsum_mul_left | |
| _ β€ _ := mul_le_mul le_rfl hW zero_le zero_le | |
| noncomputable def longPrefixMass (ell B : β) (m : β) : ββ₯0β := | |
| tailMass (fun n => mass (kernel ell) n B) m | |
| theorem long_prefix_mass {ell B : β} (hell : 0<ell) (hB : ellβ€B) (m : β) : | |
| longPrefixMass ell B m β€ ((2:ββ₯0β)β»ΒΉ)^m*ENNReal.ofReal ((B/ell)^2) := | |
| weighted_tail_bound _ m (weighted_prefix_mass hell hB) | |
| end ErdosPrimeInputs.HarmonicLongPrefixes | |
| end | |
| section | |
| namespace ErdosPrimeInputs.HighPrefixState | |
| open Set MeasureTheory | |
| abbrev State := β Γ β Γ Bool | |
| noncomputable def initial (S B R : β) : State := | |
| (B,R,if S<R/B then true else false) | |
| noncomputable def update (S : β) (z : State) (t : β) : State := | |
| (t,z.2.1-t,if z.2.2=true β¨ S<(z.2.1-t)/t then true else false) | |
| lemma update_measurable (S : β) : Measurable (Function.uncurry (update S)) := by | |
| have hf : Measurable (fun x : State Γ β => x.1.2.2) := by fun_prop | |
| have hr : Measurable (fun x : State Γ β => (x.1.2.1-x.2)/x.2) := by fun_prop | |
| have hset : MeasurableSet {x : State Γ β | x.1.2.2=true β¨ S<(x.1.2.1-x.2)/x.2} := | |
| (hf (measurableSet_singleton true)).union (measurableSet_lt measurable_const hr) | |
| exact measurable_snd.prodMk ((by fun_prop : Measurable (fun x : State Γ β => x.1.2.1-x.2)).prodMk | |
| (Measurable.ite hset measurable_const measurable_const)) | |
| lemma update_flag (S : β) (z : State) (t : β) : | |
| (update S z t).2.2=true β z.2.2=true β¨ S<(z.2.1-t)/t := by | |
| by_cases h : z.2.2=true β¨ S<(z.2.1-t)/t <;> simp [update,h] | |
| def Invariant (ell S : β) (n : β) (z : State) : Prop := | |
| ellβ€z.1 β§ (z.2.2=true β (S-(n:β))*z.1<z.2.1) | |
| lemma invariant_measurable (ell S : β) (n : β) : MeasurableSet {z : State | Invariant ell S n z} := by | |
| have hf : Measurable (fun z : State => z.2.2) := measurable_snd.comp measurable_snd | |
| have hg : Measurable (fun z : State => z.2.1) := measurable_fst.comp measurable_snd | |
| have hb : MeasurableSet {z : State | ellβ€z.1} := measurableSet_le measurable_const measurable_fst | |
| have hh : MeasurableSet {z : State | z.2.2=true} := hf (measurableSet_singleton true) | |
| have hr : MeasurableSet {z : State | (S-(n:β))*z.1<z.2.1} := | |
| measurableSet_lt (measurable_const.mul measurable_fst) hg | |
| simpa only [Invariant,imp_iff_not_or] using! hb.inter (hh.compl.union hr) | |
| lemma initial_invariant {ell S B R : β} (hell : 0<ell) (hB : ellβ€B) : | |
| Invariant ell S 0 (initial S B R) := by | |
| have hB0 : 0<B := hell.trans_le hB | |
| refine β¨hB,?_β© | |
| intro hf | |
| have hhigh : S<R/B := by | |
| by_contra hn | |
| simp [initial,hn] at hf | |
| have h := (lt_div_iffβ hB0).mp hhigh | |
| simpa only [Nat.cast_zero,sub_zero,initial] using! h | |
| lemma update_invariant {ell S : β} (hell : 0<ell) (n : β) (z : State) (t : β) | |
| (hz : Invariant ell S n z) (ht : ell<t β§ tβ€z.1) (hn : (n:β)β€S) : | |
| Invariant ell S (n+1) (update S z t) := by | |
| have ht0 : 0<t := hell.trans ht.1 | |
| refine β¨ht.1.le,?_β© | |
| intro hf | |
| have hcases := (update_flag S z t).mp hf | |
| change (S-((n+1:β):β))*t<z.2.1-t | |
| push_cast | |
| rcases hcases with hold | hnew | |
| Β· have hgap := hz.2 hold | |
| have hmul := mul_le_mul_of_nonneg_left ht.2 (sub_nonneg.mpr hn) | |
| nlinarith | |
| Β· have hgap := (lt_div_iffβ ht0).mp hnew | |
| have hn0 : 0β€(n:β)+1 := by positivity | |
| nlinarith [mul_nonneg hn0 ht0.le] | |
| theorem short_high_gap {ell S : β} (hell : 0<ell) (n : β) (z : State) | |
| (hz : Invariant ell S n z) (hf : z.2.2=true) (hn : (n:β)β€S/2) : | |
| S*ell/2<z.2.1 := by | |
| have hn0 : 0β€(n:β) := Nat.cast_nonneg _ | |
| have hS0 : 0β€S/2 := le_trans hn0 hn | |
| have hcoef : S/2β€S-(n:β) := by linarith | |
| calc | |
| S*ell/2=(S/2)*ell := by ring | |
| _ β€ (S-(n:β))*z.1 := mul_le_mul hcoef hz.1 hell.le (hS0.trans hcoef) | |
| _ < z.2.1 := hz.2 hf | |
| end ErdosPrimeInputs.HighPrefixState | |
| end | |
| end Erdos970 | |
| end OAI | |