/- Released under Apache 2.0; see adjacent LICENSE. New finite Euler-product comparison for the unchanged actual manuscript sieve. Reuses frozen PrimeLog and SieveCoarse with their preserved source credit. No Mertens theorem, foreign project, or new toolchain is imported. -/ import SieveCoarse namespace EulerRatio noncomputable section open scoped BigOperators open Finset Nat ManuscriptResidues /-- Full actual auxiliary Euler product with the original real sqrt(y) cutoff. -/ def fullV (y z0 z1 : ℝ) : ℝ := ∏ p ∈ paperPrimes y, (1 - ActualBoundingSieve.density (omegaSet z0 z1) p) /-- Exact complementary prime set to the unchanged restricted product. -/ def tailPrimes (y : ℝ) (N : ℕ) : Finset ℕ := (paperPrimes y).filter (fun p => N < p) def tailV (y z0 z1 : ℝ) (N : ℕ) : ℝ := ∏ p ∈ tailPrimes y N, (1 - ActualBoundingSieve.density (omegaSet z0 z1) p) /-- The max2 occurs only in the quantitative bound, not in the original prime family. -/ def ratioExponent (y : ℝ) (N : ℕ) : ℝ := 20 * Real.log 4 * (2 + Real.log (max 2 ⌊Real.sqrt y⌋₊ : ℕ)) / Real.log (N : ℝ) theorem fullV_pos (y z0 z1 : ℝ) (hz0 : 3 < z0) : 0 < fullV y z0 z1 := by apply prod_pos intro p hp exact sub_pos.mpr (ActualBoundingSieve.density_prime_lt_one z0 z1 hz0 p (paperPrimeFamily y p hp)) theorem tailV_pos (y z0 z1 : ℝ) (hz0 : 3 < z0) (N : ℕ) : 0 < tailV 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)) /-- Exact finite partition, including empty restricted and tail families. -/ theorem product_split (y z0 z1 : ℝ) (N : ℕ) : fullV y z0 z1 = SieveCoarse.restrictedV y z0 z1 N * tailV y z0 z1 N := by classical symm simpa only [fullV, SieveCoarse.restrictedV, tailV, tailPrimes, not_le] using prod_filter_mul_prod_filter_not (paperPrimes y) (fun p => p ≤ N) (fun p => 1 - ActualBoundingSieve.density (omegaSet z0 z1) p) /-- No cancellation without the actual strict positivity proof. -/ theorem ratio_eq_tail_inv (y z0 z1 : ℝ) (hz0 : 3 < z0) (N : ℕ) : SieveCoarse.restrictedV y z0 z1 N / fullV y z0 z1 = (tailV y z0 z1 N)⁻¹ := by have hQ := SieveCoarse.restrictedV_pos y z0 z1 hz0 N have hT := tailV_pos y z0 z1 hz0 N rw [product_split] field_simp /-- The proved actual margin nu<=4/5 controls each reciprocal logarithm. -/ theorem neg_log_factor_le_five_density (z0 z1 : ℝ) (hz0 : 3 < z0) (p : ℕ) (hp : p.Prime) : -Real.log (1 - ActualBoundingSieve.density (omegaSet z0 z1) p) ≤ 5 * ActualBoundingSieve.density (omegaSet z0 z1) p := by let v := ActualBoundingSieve.density (omegaSet z0 z1) p have hv0 : 0 ≤ v := (ActualBoundingSieve.density_prime_pos z0 z1 hz0 p hp).le have hv : v ≤ (4 : ℝ) / 5 := ActualBoundingSieve.density_prime_margin z0 z1 hz0 p hp have hf : 0 < 1 - v := sub_pos.mpr (ActualBoundingSieve.density_prime_lt_one z0 z1 hz0 p hp) have hl := Real.log_le_sub_one_of_pos (inv_pos.mpr hf) rw [Real.log_inv] at hl have he : (1 - v)⁻¹ - 1 = v / (1 - v) := by field_simp; ring rw [he] at hl exact hl.trans ((div_le_iff₀ hf).mpr (by nlinarith)) /-- Exact actual tail mass; log(N)>0 and real/Nat cutoff casts are derived. -/ theorem tail_density_mass_le (y z0 z1 : ℝ) (hz0 : 3 < z0) (N : ℕ) (hN : 2 ≤ N) : (∑ p ∈ tailPrimes y N, ActualBoundingSieve.density (omegaSet z0 z1) p) ≤ 4 * Real.log 4 * (2 + Real.log (max 2 ⌊Real.sqrt y⌋₊ : ℕ)) / Real.log (N : ℝ) := by have hN1 : (1 : ℝ) < N := by exact_mod_cast (show 1 < N by omega) have hlN : 0 < Real.log (N : ℝ) := Real.log_pos hN1 have hlog : (∑ p ∈ tailPrimes y N, ActualBoundingSieve.density (omegaSet z0 z1) p) * Real.log (N : ℝ) ≤ ∑ p ∈ tailPrimes y N, ActualBoundingSieve.density (omegaSet z0 z1) p * Real.log (p : ℝ) := by rw [sum_mul] apply sum_le_sum intro p hp have hh := mem_filter.mp hp exact mul_le_mul_of_nonneg_left (Real.log_le_log (by linarith : (0 : ℝ) < N) (by exact_mod_cast hh.2.le)) (ActualBoundingSieve.density_prime_pos z0 z1 hz0 p (paperPrimeFamily y p hh.1)).le apply (le_div_iff₀ hlN).mpr apply hlog.trans apply PrimeLog.density_prime_log_mass_le (tailPrimes y N) (fun p hp => paperPrimeFamily y p (mem_filter.mp hp).1) (max 2 ⌊Real.sqrt y⌋₊) (le_max_left _ _) _ z0 z1 hz0 intro p hp exact (PrimeLog.paper_prime_le_floor y p (mem_filter.mp hp).1).trans (le_max_right _ _) /-- Finite logarithm of the actual reciprocal tail product has an explicit bound. -/ theorem log_tail_inv_le (y z0 z1 : ℝ) (hz0 : 3 < z0) (N : ℕ) (hN : 2 ≤ N) : Real.log ((tailV y z0 z1 N)⁻¹) ≤ ratioExponent y N := by rw [Real.log_inv, tailV, Real.log_prod] · rw [← sum_neg_distrib] calc _ ≤ ∑ p ∈ tailPrimes y N, 5 * ActualBoundingSieve.density (omegaSet z0 z1) p := by apply sum_le_sum intro p hp exact neg_log_factor_le_five_density z0 z1 hz0 p (paperPrimeFamily y p (mem_filter.mp hp).1) _ = 5 * ∑ p ∈ tailPrimes y N, ActualBoundingSieve.density (omegaSet z0 z1) p := by rw [mul_sum] _ ≤ 5 * (4 * Real.log 4 * (2 + Real.log (max 2 ⌊Real.sqrt y⌋₊ : ℕ)) / Real.log (N : ℝ)) := mul_le_mul_of_nonneg_left (tail_density_mass_le y z0 z1 hz0 N hN) (by norm_num) _ = ratioExponent y N := by unfold ratioExponent; ring · intro p hp exact (sub_pos.mpr (ActualBoundingSieve.density_prime_lt_one z0 z1 hz0 p (paperPrimeFamily y p (mem_filter.mp hp).1))).ne' /-- Restricted/full comparison uses only the proved prime-log bound and margin. -/ theorem actual_ratio_le_exp (y z0 z1 : ℝ) (hz0 : 3 < z0) (N : ℕ) (hN : 2 ≤ N) : SieveCoarse.restrictedV y z0 z1 N / fullV y z0 z1 ≤ Real.exp (ratioExponent y N) := by rw [ratio_eq_tail_inv y z0 z1 hz0 N] exact (Real.log_le_iff_le_exp (inv_pos.mpr (tailV_pos y z0 z1 hz0 N))).mp (log_tail_inv_le y z0 z1 hz0 N hN) theorem actual_restrictedV_le_exp_mul_full (y z0 z1 : ℝ) (hz0 : 3 < z0) (N : ℕ) (hN : 2 ≤ N) : SieveCoarse.restrictedV y z0 z1 N ≤ Real.exp (ratioExponent y N) * fullV y z0 z1 := (div_le_iff₀ (fullV_pos y z0 z1 hz0)).mp (actual_ratio_le_exp y z0 z1 hz0 N hN) /-- Finite full-product bound; the scale remains explicit and is sufficient only. -/ theorem actual_survivor_full_bound (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 : ℝ) * Real.exp (ratioExponent y N) * fullV y z0 z1 + 4 * L ^ 5 := by apply (SieveCoarse.actual_survivor_le X y z0 z1 L hz0 N hN hL hscale).trans apply _root_.add_le_add ?_ le_rfl calc _ ≤ (2 * (X : ℝ)) * (Real.exp (ratioExponent y N) * fullV y z0 z1) := mul_le_mul_of_nonneg_left (actual_restrictedV_le_exp_mul_full y z0 z1 hz0 N hN) (by positivity) _ = _ := by ring end end EulerRatio #print axioms EulerRatio.fullV #print axioms EulerRatio.tailPrimes #print axioms EulerRatio.tailV #print axioms EulerRatio.ratioExponent #print axioms EulerRatio.fullV_pos #print axioms EulerRatio.tailV_pos #print axioms EulerRatio.product_split #print axioms EulerRatio.ratio_eq_tail_inv #print axioms EulerRatio.neg_log_factor_le_five_density #print axioms EulerRatio.tail_density_mass_le #print axioms EulerRatio.log_tail_inv_le #print axioms EulerRatio.actual_ratio_le_exp #print axioms EulerRatio.actual_restrictedV_le_exp_mul_full #print axioms EulerRatio.actual_survivor_full_bound