Download data/lean/OAI/NumberTheory/PrimeGaps/OrthantIntegrals.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 23.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/PrimeGaps/OrthantIntegrals.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/PrimeGaps/OrthantIntegrals.lean
-
curl -L -o OrthantIntegrals.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/PrimeGaps/OrthantIntegrals.lean
23.4 kB
| import OAI.NumberTheory.PrimeGaps.LevelMoments | |
| namespace OAI | |
| namespace LargePrimeGaps | |
| open Filter | |
| open Set Filter MeasureTheory | |
| open scoped Topology ContDiff | |
| theorem integral_eq_orthant_integral {j : β} {f : (Fin j β β) β β} | |
| (hf : Function.support f β {t | β i, 0 < t i}) : | |
| (β« t, f t) = β« t in {t : Fin j β β | β i, 0 β€ t i}, f t := by | |
| have hm : MeasurableSet {t : Fin j β β | β i, 0 β€ t i} := by | |
| have heq : {t : Fin j β β | β i, 0 β€ t i} = | |
| β i : Fin j, {t : Fin j β β | 0 β€ t i} := by ext t; simp | |
| rw [heq] | |
| exact MeasurableSet.iInter (fun i : Fin j => | |
| (isClosed_le continuous_const (continuous_apply i)).measurableSet) | |
| rw [β integral_indicator hm] | |
| apply integral_congr_ae | |
| filter_upwards [] with t | |
| by_cases ht : t β {t : Fin j β β | β i, 0 β€ t i} | |
| Β· rw [Set.indicator_of_mem ht] | |
| Β· rw [Set.indicator_of_notMem ht] | |
| by_contra hn | |
| exact ht (fun i => (hf hn i).le) | |
| theorem l2Mass_eq_orthant_integral {j : β} {f : (Fin j β β) β β} | |
| (hf : Function.support f β {t | β i, 0 < t i}) : | |
| l2Mass f = β« t in {t : Fin j β β | β i, 0 β€ t i}, f t^2 := by | |
| apply integral_eq_orthant_integral | |
| intro t ht | |
| apply hf | |
| exact fun h => ht (by simp only [h, zero_pow (by decide : 2 β 0)]) | |
| theorem deleteCoordinate_eq_orthant_integral {j : β} {f : (Fin (j+1) β β) β β} | |
| (hf : Function.support f β {t | β i, 0 < t i}) (t : Fin j β β) : | |
| deleteCoordinate f t = β« u in Ici (0:β), f (Fin.snoc t u) := by | |
| unfold deleteCoordinate | |
| rw [β integral_indicator measurableSet_Ici] | |
| apply integral_congr_ae | |
| filter_upwards [] with u | |
| by_cases hu : u β Ici (0:β) | |
| Β· rw [Set.indicator_of_mem hu] | |
| Β· rw [Set.indicator_of_notMem hu] | |
| by_contra hn | |
| apply hu | |
| change 0 β€ u | |
| simpa only [Fin.snoc_last] using (hf hn (Fin.last j)).le | |
| def squareDimension (m : β) : β := (m+1)^2 | |
| theorem squareDimension_pos (m : β) : 0 < squareDimension m := by | |
| unfold squareDimension | |
| positivity | |
| theorem active_length_le_squareDimension (m : β) : m+1 β€ squareDimension m := by | |
| unfold squareDimension | |
| nlinarith [Nat.zero_le m] | |
| theorem squareDimension_strictMono : StrictMono squareDimension := by | |
| intro m n hmn | |
| unfold squareDimension | |
| nlinarith | |
| theorem tendsto_squareDimension : Tendsto squareDimension atTop atTop := | |
| squareDimension_strictMono.tendsto_atTop | |
| theorem tendsto_inverse_squareDimension : | |
| Tendsto (fun m : β => ((squareDimension m:β):β)β»ΒΉ) atTop (nhds 0) := | |
| (tendsto_natCast_atTop_atTop.comp tendsto_squareDimension).inv_tendsto_atTop | |
| theorem tendsto_inverse_active_length : | |
| Tendsto (fun m : β => (((m+1):β):β)β»ΒΉ) atTop (nhds 0) := | |
| (tendsto_natCast_atTop_atTop.comp (tendsto_add_atTop_nat 1)).inv_tendsto_atTop | |
| theorem rectangle_error_tendsto_zero (v d : β) : | |
| Tendsto (fun m : β => v/((squareDimension m:β)*d^2)) atTop (nhds 0) := by | |
| have h := tendsto_inverse_squareDimension.const_mul (v/(d^2)) | |
| simpa only [mul_zero, div_eq_mul_inv, mul_inv_rev, mul_assoc, mul_comm (d^2)β»ΒΉ] using h | |
| theorem square_ratio_eq_inverse (m : β) : | |
| ((m+1:β):β)/(squareDimension m:β) = ((m+1:β):β)β»ΒΉ := by | |
| have hm : ((m+1:β):β) β 0 := by positivity | |
| unfold squareDimension | |
| rw [Nat.cast_pow] | |
| field_simp | |
| theorem cancellation_bound_tendsto_zero (lambda v d : β) : | |
| Tendsto (fun m : β => lambda * (2/((m+1:β):β) + | |
| (((m+1:β):β)/(squareDimension m:β))^2 + | |
| 4*v/((squareDimension m:β)*d^2))) atTop (nhds 0) := by | |
| have h1 := tendsto_inverse_active_length.const_mul 2 | |
| have h2 := tendsto_inverse_active_length.pow 2 | |
| have h3 := rectangle_error_tendsto_zero (4*v) d | |
| have h := ((h1.add h2).add h3).const_mul lambda | |
| simp only [square_ratio_eq_inverse] | |
| simpa only [mul_zero, zero_pow (by decide : 2 β 0), zero_add, div_eq_mul_inv] using h | |
| theorem cancellationFamily_W_tendsto {g chi : β β β} {lambda beta : β} | |
| (hlambda : 0 < lambda) (hg : Continuous g) (hgc : HasCompactSupport g) | |
| (hgs : Function.support g β Ioi 0) (hg2 : (β« u, g u^2) = 1) | |
| (hchi : Continuous chi) (hchi0 : β s, 0 β€ chi s) (hchi1 : β s, chi s β€ 1) | |
| (hflat : β s β€ beta, chi s = 1) (hmu : (β« u, u*g u^2) < beta) : | |
| Tendsto (fun m => familyW lambda (squareDimension m) | |
| (cancellationFamily g chi lambda (squareDimension m) (m+1))) atTop (nhds 1) := by | |
| let d := beta - β« u, u*g u^2 | |
| let v := β« u, (u-β« v, v*g v^2)^2 * g u^2 | |
| have hlo := (rectangle_error_tendsto_zero v d).const_sub 1 | |
| simp only [sub_zero] at hlo | |
| apply tendsto_of_tendsto_of_tendsto_of_le_of_le hlo tendsto_const_nhds | |
| Β· intro m | |
| exact (cancellationFamily_W_bounds hlambda (Nat.succ_pos m) | |
| (active_length_le_squareDimension m) hg hgc hgs hg2 hchi hchi0 hchi1 hflat hmu).1 | |
| Β· intro m | |
| exact (cancellationFamily_W_bounds hlambda (Nat.succ_pos m) | |
| (active_length_le_squareDimension m) hg hgc hgs hg2 hchi hchi0 hchi1 hflat hmu).2 | |
| theorem cancellationFamily_V_tendsto {g chi : β β β} {lambda beta B : β} | |
| (hlambda : 0 < lambda) (hg : Continuous g) (hgc : HasCompactSupport g) | |
| (hgs : Function.support g β Ioi 0) (hgn : β u, 0 β€ g u) | |
| (hg2 : (β« u, g u^2) = 1) (hg1 : (β« u, g u) = Real.sqrt lambda) | |
| (hB : β u β Function.support g, u β€ B) (hB0 : 0 β€ B) | |
| (hchi : Continuous chi) (hchi0 : β s, 0 β€ chi s) (hchi1 : β s, chi s β€ 1) | |
| (hflat : β s β€ beta, chi s = 1) (hmu : (β« u, u*g u^2) < beta) : | |
| Tendsto (fun m => familyV lambda (squareDimension m) | |
| (cancellationFamily g chi lambda (squareDimension m) (m+1))) atTop (nhds 0) := by | |
| let d := beta - β« u, u*g u^2 | |
| let v := β« u, (u-β« v, v*g v^2)^2 * g u^2 | |
| have hBdiv : Tendsto (fun m => B/(squareDimension m:β)) atTop (nhds 0) := by | |
| simpa only [div_eq_mul_inv, mul_zero] using tendsto_inverse_squareDimension.const_mul B | |
| have hBk : βαΆ m in atTop, B/(squareDimension m:β) β€ d/2 := by | |
| exact ((tendsto_order.mp hBdiv).2 (d/2) (by dsimp only [d]; linarith)).mono (fun _ h => h.le) | |
| apply squeeze_zero' (Eventually.of_forall fun m => familyV_nonneg hlambda _ _) | |
| _ (cancellation_bound_tendsto_zero lambda v d) | |
| filter_upwards [hBk] with m hm | |
| exact cancellationFamily_V_bound hlambda (Nat.succ_pos m) | |
| (active_length_le_squareDimension m) hg hgc hgs hgn hg2 hg1 hB hB0 hchi hchi0 hchi1 hflat hmu hm | |
| def AdmissibleFamily (tau : β) (k : β) (f : (j : β) β (Fin j β β) β β) : Prop := | |
| 0 < k β§ | |
| (β j, j β€ k β ContDiff β β (f j) β§ HasCompactSupport (f j) β§ | |
| tsupport (f j) β positiveSimplex j tau β§ SymmetricFunction (f j)) β§ | |
| (β j, k < j β f j = 0) | |
| theorem exists_canceling_families {lambda tau : β} (hlambda : 0 < lambda) (htau : 0 < tau) : | |
| β f : (m j : β) β (Fin j β β) β β, | |
| (β m, AdmissibleFamily tau (squareDimension m) (f m) β§ f m 0 = 0) β§ | |
| Tendsto (fun m => familyW lambda (squareDimension m) (f m)) atTop (nhds 1) β§ | |
| Tendsto (fun m => familyV lambda (squareDimension m) (f m)) atTop (nhds 0) := by | |
| let beta := tau/3 | |
| let gamma := 2*tau/3 | |
| have hb : 0 < beta := by dsimp only [beta]; positivity | |
| have hbg : beta < gamma := by dsimp only [beta, gamma]; linarith | |
| have hgt : gamma < tau := by dsimp only [gamma]; linarith | |
| obtain β¨g, hgsmooth, hgc, hgs, hgn, hg2, hg1, hmuβ© := exists_small_first_moment_profile hlambda hb | |
| let chi := simplexCutoff beta gamma | |
| have hchi : ContDiff β β chi := simplexCutoff_smooth beta gamma | |
| have hc0 : β s, 0 β€ chi s := simplexCutoff_nonneg beta gamma | |
| have hc1 : β s, chi s β€ 1 := simplexCutoff_le_one beta gamma | |
| have hcflat : β s β€ beta, chi s = 1 := fun _ hs => simplexCutoff_eq_one hbg hs | |
| have hcz : β s, gamma β€ s β chi s = 0 := fun _ hs => simplexCutoff_eq_zero hbg hs | |
| obtain β¨b, hbndβ© := hgc.bddAbove | |
| let B := max b 0 | |
| have hB : β u β Function.support g, u β€ B := fun u hu => | |
| (hbnd (subset_closure hu)).trans (le_max_left b 0) | |
| have hB0 : 0 β€ B := le_max_right b 0 | |
| have hsupport : Function.support g β Ioi 0 := fun _ hu => hgs (subset_closure hu) | |
| refine β¨fun m => cancellationFamily g chi lambda (squareDimension m) (m+1), ?_, ?_, ?_β© | |
| Β· intro m | |
| refine β¨β¨squareDimension_pos m, ?_, ?_β©, cancellationFamily_zero _ _ _ _ _β© | |
| Β· intro j _ | |
| exact cancellationFamily_properties (squareDimension_pos m) hgsmooth hgc hgs hchi hgt hcz j | |
| Β· intro j hj | |
| exact cancellationFamily_above _ _ _ _ _ hj | |
| Β· exact cancellationFamily_W_tendsto hlambda hgsmooth.continuous hgc hsupport hg2 | |
| hchi.continuous hc0 hc1 hcflat hmu | |
| Β· exact cancellationFamily_V_tendsto hlambda hgsmooth.continuous hgc hsupport hgn hg2 hg1 | |
| hB hB0 hchi.continuous hc0 hc1 hcflat hmu | |
| theorem exists_family_small_marked_ratio {lambda tau epsilon : β} | |
| (hlambda : 0 < lambda) (htau : 0 < tau) (hepsilon : 0 < epsilon) : | |
| β k : β, β f : (j : β) β (Fin j β β) β β, | |
| AdmissibleFamily tau k f β§ f 0 = 0 β§ | |
| 0 < familyW lambda k f β§ familyV lambda k f / familyW lambda k f β€ epsilon := by | |
| obtain β¨f, hf, hW, hVβ© := exists_canceling_families hlambda htau | |
| have hWpos : βαΆ m in atTop, 0 < familyW lambda (squareDimension m) (f m) := | |
| (tendsto_order.mp hW).1 0 (by norm_num) | |
| have hratio : Tendsto (fun m => familyV lambda (squareDimension m) (f m) / | |
| familyW lambda (squareDimension m) (f m)) atTop (nhds 0) := by | |
| have hdiv := hV.div hW (by norm_num : (1:β) β 0) | |
| rw [zero_div] at hdiv | |
| exact hdiv | |
| have hsmall := (tendsto_order.mp hratio).2 epsilon hepsilon | |
| obtain β¨m, hmW, hmVβ© := (hWpos.and hsmall).exists | |
| exact β¨squareDimension m, f m, (hf m).1, (hf m).2, hmW, hmV.leβ© | |
| def divisorMultiplicity (k n : β) : β := (ArithmeticFunction.zeta ^ k) n | |
| theorem divisorMultiplicity_one (k : β) : divisorMultiplicity k 1 = 1 := by | |
| exact (ArithmeticFunction.isMultiplicative_zeta.pow).1 | |
| theorem divisorMultiplicity_succ (k n : β) : | |
| divisorMultiplicity (k+1) n = β d β n.divisors, divisorMultiplicity k d := by | |
| simp only [divisorMultiplicity, pow_succ, ArithmeticFunction.mul_zeta_apply] | |
| theorem divisorMultiplicity_prime (k : β) {p : β} (hp : Nat.Prime p) : | |
| divisorMultiplicity k p = k := by | |
| induction k with | |
| | zero => simp [divisorMultiplicity, hp.ne_one] | |
| | succ k ih => | |
| rw [divisorMultiplicity_succ, hp.divisors] | |
| simp [hp.ne_one.symm, divisorMultiplicity_one, ih, Nat.add_comm] | |
| theorem divisorMultiplicity_squarefree (k : β) {q : β} (hq : Squarefree q) : | |
| divisorMultiplicity k q = k ^ q.primeFactors.card := by | |
| rw [divisorMultiplicity, β ArithmeticFunction.IsMultiplicative.prod_primeFactors | |
| (ArithmeticFunction.isMultiplicative_zeta.pow) hq] | |
| calc | |
| _ = β p β q.primeFactors, k := Finset.prod_congr rfl fun p hp => | |
| divisorMultiplicity_prime k (Nat.prime_of_mem_primeFactors hp) | |
| _ = _ := by simp | |
| theorem reciprocal_divisor_sum_le (f : β β β) (hf : β n, 0 β€ f n) (Q : β) : | |
| (β q β Finset.Icc 1 Q, (β d β q.divisors, f d) / (q : β)) β€ | |
| (β d β Finset.Icc 1 Q, f d / (d : β)) * (harmonic Q : β) := by | |
| classical | |
| let s := (Finset.Icc 1 Q).sigma fun q => q.divisors | |
| let t := (Finset.Icc 1 Q) ΓΛ’ (Finset.Icc 1 Q) | |
| let e : (a : β) Γ β β β Γ β := fun x => (x.2, x.1/x.2) | |
| have he_mem : β x β s, e x β t := by | |
| rintro β¨q,dβ© hx | |
| obtain β¨hq, hdβ© := Finset.mem_sigma.mp hx | |
| obtain β¨hq1,hqQβ© := Finset.mem_Icc.mp hq | |
| obtain β¨hdq,hq0β© := Nat.mem_divisors.mp hd | |
| have hd0 : 0 < d := Nat.pos_of_dvd_of_pos hdq hq1 | |
| have hdle : d β€ q := Nat.le_of_dvd hq1 hdq | |
| have hdivpos : 0 < q/d := Nat.div_pos hdle hd0 | |
| exact Finset.mem_product.mpr β¨Finset.mem_Icc.mpr β¨hd0, hdle.trans hqQβ©, | |
| Finset.mem_Icc.mpr β¨hdivpos, (Nat.div_le_self q d).trans hqQβ©β© | |
| have he_inj : Set.InjOn e s := by | |
| rintro β¨q,dβ© hx β¨q',d'β© hy he | |
| obtain β¨hq,hdβ© := Finset.mem_sigma.mp hx | |
| obtain β¨hq',hd'β© := Finset.mem_sigma.mp hy | |
| have hed : d = d' := congrArg Prod.fst he | |
| have heq : q/d = q'/d' := congrArg Prod.snd he | |
| have hdq : d β£ q := (Nat.mem_divisors.mp hd).1 | |
| have hdq' : d' β£ q' := (Nat.mem_divisors.mp hd').1 | |
| have hqq : q = q' := by | |
| rw [β Nat.div_mul_cancel hdq, β Nat.div_mul_cancel hdq', heq, hed] | |
| subst d' | |
| subst q' | |
| rfl | |
| have hsum : (β q β Finset.Icc 1 Q, (β d β q.divisors, f d) / (q : β)) = | |
| β x β s, f (e x).1 / (e x).1 / (e x).2 := by | |
| dsimp only [s] | |
| rw [Finset.sum_sigma] | |
| apply Finset.sum_congr rfl | |
| intro q hq | |
| rw [Finset.sum_div] | |
| apply Finset.sum_congr rfl | |
| intro d hd | |
| have hdq := (Nat.mem_divisors.mp hd).1 | |
| dsimp only [e] | |
| rw [div_div, β Nat.cast_mul, Nat.mul_div_cancel' hdq] | |
| rw [hsum] | |
| calc | |
| _ = β x β s.image e, f x.1 / (x.1 : β) / (x.2 : β) := by | |
| rw [Finset.sum_image he_inj] | |
| _ β€ β x β t, f x.1 / (x.1 : β) / (x.2 : β) := | |
| Finset.sum_le_sum_of_subset_of_nonneg (Finset.image_subset_iff.mpr he_mem) | |
| (fun x _ _ => div_nonneg (div_nonneg (hf _) (Nat.cast_nonneg _)) (Nat.cast_nonneg _)) | |
| _ = _ := by | |
| simp only [t, Finset.sum_product, div_eq_mul_inv, Finset.sum_mul, Finset.mul_sum, | |
| harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] | |
| rw [Finset.sum_comm] | |
| theorem sum_divisorMultiplicity_reciprocal_le (k Q : β) : | |
| (β q β Finset.Icc 1 Q, (divisorMultiplicity k q : β) / (q : β)) β€ | |
| (harmonic Q : β) ^ k := by | |
| induction k with | |
| | zero => | |
| by_cases hQ : Q = 0 | |
| Β· subst Q; simp | |
| Β· have hQ1 : 1 β€ Q := Nat.one_le_iff_ne_zero.mpr hQ | |
| simp [divisorMultiplicity, ArithmeticFunction.one_apply, ite_div, hQ1] | |
| | succ k ih => | |
| have h := reciprocal_divisor_sum_le (fun n => (divisorMultiplicity k n : β)) | |
| (fun n => Nat.cast_nonneg _) Q | |
| simp only [divisorMultiplicity_succ, Nat.cast_sum] at β’ | |
| apply h.trans | |
| rw [pow_succ] | |
| exact mul_le_mul_of_nonneg_right ih (by | |
| simp only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] | |
| exact Finset.sum_nonneg fun _ _ => inv_nonneg.mpr (Nat.cast_nonneg _)) | |
| theorem squarefree_reciprocal_weight_bound (T Q : β) : | |
| (β q β Finset.Icc 1 Q, if Squarefree q then (T : β)^q.primeFactors.card / q else 0) β€ | |
| (harmonic Q : β)^T := by | |
| classical | |
| apply (Finset.sum_le_sum (g := fun q => (divisorMultiplicity T q : β)/(q:β)) ?_).trans | |
| (sum_divisorMultiplicity_reciprocal_le T Q) | |
| intro q _ | |
| split_ifs with hq | |
| Β· rw [divisorMultiplicity_squarefree T hq, Nat.cast_pow] | |
| Β· positivity | |
| theorem squarefree_totient_lower {q : β} (hq : Squarefree q) : | |
| q β€ 2 ^ q.primeFactors.card * q.totient := by | |
| rw [Nat.totient_eq_div_primeFactors_mul, Nat.prod_primeFactors_of_squarefree hq, | |
| Nat.div_self (Nat.pos_of_ne_zero hq.ne_zero), one_mul] | |
| calc | |
| q = β p β q.primeFactors, p := (Nat.prod_primeFactors_of_squarefree hq).symm | |
| _ β€ β p β q.primeFactors, 2 * (p-1) := by | |
| apply Finset.prod_le_prod | |
| intro p hp | |
| have := (Nat.prime_of_mem_primeFactors hp).two_le | |
| omega | |
| _ = _ := by rw [Finset.prod_mul_distrib, Finset.prod_const] | |
| theorem weighted_error_square_bound (K Q : β) (E : β β β) (hE : β q, 0 β€ E q) | |
| {X L : β} (hX : 0 β€ X) (hL : 0 β€ L) | |
| (hb : β q β Finset.Icc 1 Q, Squarefree q β | |
| E q β€ X/(q:β) * (L + 2^q.primeFactors.card)) : | |
| (β q β Finset.Icc 1 Q, if Squarefree q then (K:β)^q.primeFactors.card * E q else 0)^2 β€ | |
| (β q β Finset.Icc 1 Q, E q) * X * | |
| (L * (harmonic Q : β)^(K^2) + (harmonic Q : β)^(2*K^2)) := by | |
| classical | |
| let s := Finset.Icc 1 Q | |
| let w : β β β := fun q => if Squarefree q then (K:β)^q.primeFactors.card else 0 | |
| have hcs := Finset.sum_mul_sq_le_sq_mul_sq s (fun q => Real.sqrt (E q)) | |
| (fun q => w q * Real.sqrt (E q)) | |
| have heq1 : β q, Real.sqrt (E q) * (w q * Real.sqrt (E q)) = w q * E q := by | |
| intro q | |
| calc | |
| _ = w q * (Real.sqrt (E q))^2 := by ring | |
| _ = _ := by rw [Real.sq_sqrt (hE q)] | |
| simp only [heq1, mul_pow, Real.sq_sqrt (hE _)] at hcs | |
| have hsecond : (β q β s, w q ^ 2 * E q) β€ | |
| X * (L * (harmonic Q : β)^(K^2) + (harmonic Q : β)^(2*K^2)) := by | |
| have hterm : β q β s, w q^2 * E q β€ | |
| X * (L * (if Squarefree q then ((K^2:β):β)^q.primeFactors.card / q else 0) + | |
| (if Squarefree q then ((2*K^2:β):β)^q.primeFactors.card / q else 0)) := by | |
| intro q hq | |
| have hqR : (0 : β) < q := by exact_mod_cast (Finset.mem_Icc.mp hq).1 | |
| by_cases hsq : Squarefree q | |
| Β· simp only [w, ite_eq_left hsq] | |
| calc | |
| _ β€ ((K:β)^q.primeFactors.card)^2 * (X/(q:β) * (L+2^q.primeFactors.card)) := | |
| mul_le_mul_of_nonneg_left (hb q hq hsq) (sq_nonneg _) | |
| _ = _ := by | |
| rw [Nat.cast_mul, Nat.cast_ofNat, Nat.cast_pow, mul_pow, β pow_mul, Nat.mul_comm, | |
| pow_mul] | |
| ring | |
| Β· simp [w, hsq] | |
| calc | |
| _ β€ β q β s, X * (L * | |
| (if Squarefree q then ((K^2:β):β)^q.primeFactors.card / q else 0) + | |
| (if Squarefree q then ((2*K^2:β):β)^q.primeFactors.card / q else 0)) := | |
| Finset.sum_le_sum hterm | |
| _ = X * (L * (β q β s, if Squarefree q then ((K^2:β):β)^q.primeFactors.card/q else 0) + | |
| β q β s, if Squarefree q then ((2*K^2:β):β)^q.primeFactors.card/q else 0) := by | |
| simp only [Finset.mul_sum, Finset.sum_add_distrib, mul_add] | |
| _ β€ _ := mul_le_mul_of_nonneg_left | |
| (add_le_add (mul_le_mul_of_nonneg_left (squarefree_reciprocal_weight_bound (K^2) Q) hL) | |
| (squarefree_reciprocal_weight_bound (2*K^2) Q)) hX | |
| have hsumE : 0 β€ β q β s, E q := Finset.sum_nonneg fun q _ => hE q | |
| have h := hcs.trans (mul_le_mul_of_nonneg_left hsecond hsumE) | |
| simp only [w, ite_mul, zero_mul] at h | |
| simpa only [mul_assoc] using h | |
| theorem markedClassError_trivial {X H q a c : β} (hX : 1 β€ X) (hq : 0 < q) | |
| (hqX : q β€ X) (ha : a β€ H) (hc : c < q) (hsq : Squarefree q) : | |
| |(β m β residueStarts X q c, theta (m+a)) - (X:β)/q.totient| β€ | |
| (X:β)/(q:β) * (3 * Real.log (2*X+H) + 2^q.primeFactors.card) := by | |
| have hqR : (0:β) < q := by exact_mod_cast hq | |
| have hphi : (0:β) < q.totient := by exact_mod_cast Nat.totient_pos.mpr hq | |
| have hXq : (1:β) β€ (X:β)/q := (le_div_iffβ hqR).mpr (by simpa using (show (q:β) β€ X by exact_mod_cast hqX)) | |
| have hboundpos : (1:β) β€ 2*X+H := by exact_mod_cast (show 1 β€ 2*X+H by omega) | |
| have hlog : 0 β€ Real.log (2*X+H) := Real.log_nonneg hboundpos | |
| have htheta : β m β residueStarts X q c, theta (m+a) β€ Real.log (2*X+H) := by | |
| intro m hm | |
| have hmhi := (Finset.mem_Ioc.mp (Finset.mem_filter.mp hm).1).2 | |
| by_cases hp : Nat.Prime (m+a) | |
| Β· rw [theta, ite_eq_left hp] | |
| exact Real.log_le_log (by exact_mod_cast hp.pos) (by exact_mod_cast (show m+a β€ 2*X+H by omega)) | |
| Β· simpa [theta, hp] | |
| have hsum : (β m β residueStarts X q c, theta (m+a)) β€ | |
| 3 * ((X:β)/q) * Real.log (2*X+H) := by | |
| calc | |
| _ β€ β m β residueStarts X q c, Real.log (2*X+H) := Finset.sum_le_sum htheta | |
| _ = ((residueStarts X q c).card:β) * Real.log (2*X+H) := by simp | |
| _ β€ ((X:β)/q+2) * Real.log (2*X+H) := by | |
| apply mul_le_mul_of_nonneg_right _ hlog | |
| have hh := (abs_le.mp (residueStarts_card_error X hq hc)).2 | |
| linarith | |
| _ β€ _ := mul_le_mul_of_nonneg_right (by linarith) hlog | |
| have htot : (X:β)/q.totient β€ (X:β)/q * (2:β)^q.primeFactors.card := by | |
| have ht : (q:β) β€ (2:β)^q.primeFactors.card * q.totient := by | |
| exact_mod_cast squarefree_totient_lower hsq | |
| apply (div_le_iffβ hphi).mpr | |
| have hx := mul_le_mul_of_nonneg_left ht (show 0 β€ (X:β)/q by positivity) | |
| field_simp at hx β’ | |
| nlinarith | |
| calc | |
| _ β€ (β m β residueStarts X q c, theta (m+a)) + (X:β)/q.totient := by | |
| have hs0 : 0 β€ β m β residueStarts X q c, theta (m+a) := | |
| Finset.sum_nonneg fun m _ => theta_nonneg (m+a) | |
| have ht0 : 0 β€ (X:β)/q.totient := by positivity | |
| exact abs_sub_le_iff.mpr β¨by linarith, by linarithβ© | |
| _ β€ 3 * ((X:β)/q) * Real.log (2*X+H) + (X:β)/q * 2^q.primeFactors.card := | |
| add_le_add hsum htot | |
| _ = _ := by ring | |
| theorem markedError_trivial {X H q : β} (hX : 1 β€ X) (hq : 0 < q) | |
| (hqX : q β€ X) (hsq : Squarefree q) : | |
| (markedError X H q : β) β€ | |
| (X:β)/(q:β) * (3 * Real.log (2*X+H) + 2^q.primeFactors.card) := by | |
| have hnonneg : 0 β€ (X:β)/(q:β) * | |
| (3 * Real.log (2*X+H) + 2^q.primeFactors.card) := by | |
| have : 0 β€ Real.log (2*X+H) := Real.log_nonneg (by | |
| exact_mod_cast (show 1 β€ 2*X+H by omega)) | |
| positivity | |
| change markedError X H q β€ NNReal.mk _ hnonneg | |
| apply Finset.sup_le | |
| rintro β¨a,cβ© hac | |
| have ha : a β€ H := by simpa using (Finset.mem_product.mp hac).1 | |
| have hc : c < q := Finset.mem_range.mp (Finset.mem_product.mp hac).2 | |
| dsimp only | |
| split_ifs | |
| Β· exact markedClassError_trivial hX hq hqX ha hc hsq | |
| Β· exact zero_le | |
| noncomputable def residueSlice (f : β β β) (L U q c : β) : β := | |
| β n β (Finset.Ioc L U).filter (fun n => n % q = c), f n | |
| noncomputable def residuePrefix (f : β β β) (Y q c : β) : β := | |
| residueSlice f 0 Y q c | |
| theorem residuePrefix_sub (f : β β β) {L U : β} (hLU : L β€ U) (q c : β) : | |
| residuePrefix f U q c - residuePrefix f L q c = residueSlice f L U q c := by | |
| classical | |
| have hunion : Finset.Ioc 0 U = Finset.Ioc 0 L βͺ Finset.Ioc L U := by | |
| ext n | |
| simp only [Finset.mem_Ioc, Finset.mem_union] | |
| omega | |
| have hd : Disjoint ((Finset.Ioc 0 L).filter fun n => n % q = c) | |
| ((Finset.Ioc L U).filter fun n => n % q = c) := by | |
| apply Finset.disjoint_left.mpr | |
| intro n hn hm | |
| have hl := (Finset.mem_Ioc.mp (Finset.mem_filter.mp hn).1).2 | |
| have hu := (Finset.mem_Ioc.mp (Finset.mem_filter.mp hm).1).1 | |
| omega | |
| simp only [residuePrefix, residueSlice, hunion, Finset.filter_union, Finset.sum_union hd] | |
| ring | |
| theorem shifted_sum_eq_residueSlice (f : β β β) (X q a : β) {c : β} (hc : c < q) : | |
| (β m β residueStarts X q c, f (m+a)) = | |
| residueSlice f (X+a) (2*X+a) q ((c+a)%q) := by | |
| classical | |
| apply Finset.sum_bij (fun m _ => m+a) | |
| Β· intro m hm | |
| obtain β¨hm,hmcβ© := Finset.mem_filter.mp hm | |
| obtain β¨hmlo,hmhiβ© := Finset.mem_Ioc.mp hm | |
| apply Finset.mem_filter.mpr | |
| refine β¨Finset.mem_Ioc.mpr β¨by omega, by omegaβ©, ?_β© | |
| have hh : Nat.ModEq q m c := by | |
| change m % q = c % q | |
| rw [hmc, Nat.mod_eq_of_lt hc] | |
| exact hh.add_right a | |
| Β· intro m _ n _ heq | |
| omega | |
| Β· intro n hn | |
| obtain β¨hn,hncβ© := Finset.mem_filter.mp hn | |
| obtain β¨hnlo,hnhiβ© := Finset.mem_Ioc.mp hn | |
| have ha : a β€ n := by omega | |
| refine β¨n-a, Finset.mem_filter.mpr β¨Finset.mem_Ioc.mpr β¨by omega, by omegaβ©, ?_β©, | |
| Nat.sub_add_cancel haβ© | |
| have hh : Nat.ModEq q ((n-a)+a) (c+a) := by | |
| change ((n-a)+a) % q = (c+a) % q | |
| simpa only [Nat.sub_add_cancel ha] using hnc | |
| have hhc := Nat.ModEq.add_right_cancel' a hh | |
| simpa only [Nat.ModEq, Nat.mod_eq_of_lt hc] using hhc | |
| Β· intro m _ | |
| rfl | |
| end LargePrimeGaps | |
| end OAI | |