/- Released under Apache 2.0; see adjacent LICENSE. New finite exceptional-prime, polynomial-error and actual-survivor arguments. Reuses unchanged SelbergError and PrimeLog; their adapted source provenance and credit remain in the imported frozen modules. No foreign project/toolchain imports. -/ import PrimeLog import SelbergError namespace SieveCoarse noncomputable section open scoped BigOperators ArithmeticFunction.omega open Finset Nat ArithmeticFunction /-- Exact correction for the only two primes with p²<12. -/ def correction (p : ℕ) : ℝ := if p = 2 then 3 else if p = 3 then 4 / 3 else 1 theorem correction_ge_one (p : ℕ) : 1 ≤ correction p := by unfold correction split_ifs <;> norm_num theorem correction_prod_le_four (T : Finset ℕ) : (∏ p ∈ T, correction p) ≤ 4 := by classical have he : (∏ p ∈ T, correction p) = ∏ p ∈ T ∩ {2, 3}, correction p := by symm apply prod_subset inter_subset_left intro p hp hnot have hn : p ∉ ({2, 3} : Finset ℕ) := fun h => hnot (mem_inter.mpr ⟨hp, h⟩) simp only [mem_insert, mem_singleton, not_or] at hn simp [correction, hn.1, hn.2] rw [he] calc _ ≤ ∏ p ∈ ({2, 3} : Finset ℕ), correction p := prod_le_prod_of_subset_of_one_le₀ inter_subset_right (fun p _ => zero_le_one.trans (correction_ge_one p)) (fun p _ _ => correction_ge_one p) _ = 4 := by norm_num [correction] theorem prime_factor_twelve_le (p : ℕ) (hp : p.Prime) : (12 : ℝ) ≤ correction p * (p : ℝ) ^ 2 := by by_cases h2 : p = 2 · subst p norm_num [correction] by_cases h3 : p = 3 · subst p norm_num [correction] have hp5 : (5 : ℝ) ≤ p := by exact_mod_cast hp.five_le_of_ne_two_of_ne_three h2 h3 simp only [correction, ite_eq_right h2, ite_eq_right h3, one_mul] nlinarith /-- Squarefreeness includes d≠0; the bound includes d=1 and is sharp at d=6. -/ theorem twelve_pow_omega_le_four_square (d : ℕ) (hd : Squarefree d) : (12 : ℝ) ^ ω d ≤ 4 * (d : ℝ) ^ 2 := by have hcard : d.primeFactors.card = ω d := by simp only [cardDistinctFactors_apply, Nat.primeFactors, List.card_toFinset] have he : (∏ p ∈ d.primeFactors, (p : ℝ)) = (d : ℝ) := by simpa only [Nat.cast_prod, id_eq] using congrArg (fun n : ℕ => (n : ℝ)) (Nat.prod_primeFactors_of_squarefree hd) calc _ = ∏ _p ∈ d.primeFactors, (12 : ℝ) := by rw [prod_const, hcard] _ ≤ ∏ p ∈ d.primeFactors, correction p * (p : ℝ) ^ 2 := prod_le_prod₀ (fun _ _ => by norm_num) (fun p hp => prime_factor_twelve_le p (Nat.prime_of_mem_primeFactors hp)) _ = (∏ p ∈ d.primeFactors, correction p) * (d : ℝ) ^ 2 := by rw [prod_mul_distrib, prod_pow, he] _ ≤ _ := mul_le_mul_of_nonneg_right (correction_prod_le_four d.primeFactors) (sq_nonneg _) /-- Exact polynomial bound for the original squarefree-divisor coarse error sum. -/ theorem truncated_error_le (P : ℕ) (hP : Squarefree P) (L : ℝ) (hL : 1 ≤ L) : (∑ d ∈ P.divisors, if (d : ℝ) ≤ L then (d : ℝ) ^ 2 * (12 : ℝ) ^ ω d else 0) ≤ 4 * L ^ 5 := by classical let D : Finset ℕ := P.divisors.filter (fun d : ℕ => (d : ℝ) ≤ L) have hL0 : 0 ≤ L := zero_le_one.trans hL have hD : D ⊆ Icc 1 ⌊L⌋₊ := by intro d hd have hh := mem_filter.mp hd exact mem_Icc.mpr ⟨Nat.pos_of_mem_divisors hh.1, (Nat.le_floor_iff hL0).mpr hh.2⟩ have hc : D.card ≤ ⌊L⌋₊ := by simpa using card_le_card hD have hcR : (D.card : ℝ) ≤ L := by exact (show (D.card : ℝ) ≤ (⌊L⌋₊ : ℝ) by exact_mod_cast hc).trans (Nat.floor_le hL0) rw [← sum_filter] change (∑ d ∈ D, (d : ℝ) ^ 2 * (12 : ℝ) ^ ω d) ≤ _ calc _ ≤ ∑ _d ∈ D, 4 * L ^ 4 := by apply sum_le_sum intro d hd have hh := mem_filter.mp hd have hs : Squarefree d := Squarefree.squarefree_of_dvd (Nat.dvd_of_mem_divisors hh.1) hP calc _ ≤ (d : ℝ) ^ 2 * (4 * (d : ℝ) ^ 2) := mul_le_mul_of_nonneg_left (twelve_pow_omega_le_four_square d hs) (sq_nonneg _) _ = 4 * (d : ℝ) ^ 4 := by ring _ ≤ 4 * L ^ 4 := by gcongr; exact hh.2 _ = (D.card : ℝ) * (4 * L ^ 4) := by rw [sum_const, nsmul_eq_mul] _ ≤ L * (4 * L ^ 4) := mul_le_mul_of_nonneg_right hcR (by positivity) _ = 4 * L ^ 5 := by ring open ManuscriptResidues /-- Actual restricted Euler product; the full original sieve is not replaced. -/ def restrictedV (y z0 z1 : ℝ) (N : ℕ) : ℝ := ∏ p ∈ (paperPrimes y).filter (fun p => p ≤ N), (1 - ActualBoundingSieve.density (omegaSet z0 z1) p) theorem restrictedV_pos (y z0 z1 : ℝ) (hz0 : 3 < z0) (N : ℕ) : 0 < restrictedV y z0 z1 N := by apply prod_pos intro p hp exact sub_pos.mpr (ActualBoundingSieve.density_prime_lt_one z0 z1 hz0 p (paperPrimeFamily y p (mem_filter.mp hp).1)) /-- The proved half-Euler lower bound controls the actual main term. -/ theorem actual_main_term_le (X : ℕ) (y z0 z1 L : ℝ) (hz0 : 3 < z0) (N : ℕ) (hN : 2 ≤ N) (hL : 1 < L) (hscale : 16 * Real.log 4 * (2 + Real.log (N : ℝ)) ≤ Real.log L) : (X : ℝ) / SelbergFinite.denominator (ActualBoundingSieve.sieve X y z0 z1 hz0) L ≤ 2 * (X : ℝ) * restrictedV y z0 z1 N := by have hV := restrictedV_pos y z0 z1 hz0 N have hS := SelbergFinite.denominator_pos (ActualBoundingSieve.sieve X y z0 z1 hz0) L hL.le have hl := PrimeLog.actual_subset_denominator_lower X y z0 z1 L hz0 N hN hL hscale change (restrictedV y z0 z1 N)⁻¹ / 2 ≤ _ at hl have hm := mul_le_mul_of_nonneg_right hl (show 0 ≤ 2 * restrictedV y z0 z1 N by positivity) have he : ((restrictedV y z0 z1 N)⁻¹ / 2) * (2 * restrictedV y z0 z1 N) = 1 := by field_simp rw [he] at hm apply (div_le_iff₀ hS).mpr calc (X : ℝ) = (X : ℝ) * 1 := by ring _ ≤ (X : ℝ) * (SelbergFinite.denominator (ActualBoundingSieve.sieve X y z0 z1 hz0) L * (2 * restrictedV y z0 z1 N)) := mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg X) _ = _ := by ring /-- Quantitative finite survivor bound for the unchanged actual manuscript sieve. -/ theorem actual_survivor_le (X : ℕ) (y z0 z1 L : ℝ) (hz0 : 3 < z0) (N : ℕ) (hN : 2 ≤ N) (hL : 1 < L) (hscale : 16 * Real.log 4 * (2 + Real.log (N : ℝ)) ≤ Real.log L) : (SieveInterface.survivorCount X y z0 z1 : ℝ) ≤ 2 * (X : ℝ) * restrictedV y z0 z1 N + 4 * L ^ 5 := by apply (SelbergError.actual_upper_coarse_error X y z0 z1 L hz0 hL.le).trans apply _root_.add_le_add · exact actual_main_term_le X y z0 z1 L hz0 N hN hL hscale · exact truncated_error_le _ (ActualBoundingSieve.sieve X y z0 z1 hz0).prodPrimes_squarefree L hL.le end end SieveCoarse #print axioms SieveCoarse.correction #print axioms SieveCoarse.correction_ge_one #print axioms SieveCoarse.correction_prod_le_four #print axioms SieveCoarse.prime_factor_twelve_le #print axioms SieveCoarse.twelve_pow_omega_le_four_square #print axioms SieveCoarse.truncated_error_le #print axioms SieveCoarse.restrictedV #print axioms SieveCoarse.restrictedV_pos #print axioms SieveCoarse.actual_main_term_le #print axioms SieveCoarse.actual_survivor_le