/- Released under Apache-2.0; see adjacent LICENSE. New finite real-cutoff composition of frozen MertensBand and SieveParameters. Actual eq15 residues, sqrt(y) counting family and real band endpoints unchanged. No Mertens asymptotic, eventual manuscript parameters or main theorem assumed. -/ import MertensBand import SieveParameters namespace RealBand noncomputable section open scoped BigOperators open Finset Nat ManuscriptResidues def primeNatCutoff (N : ℕ) : Finset ℕ := (Icc 2 N).filter Nat.Prime theorem mem_primeNatCutoff (N p : ℕ) : p ∈ primeNatCutoff N ↔ p.Prime ∧ p ≤ N := by simp only [primeNatCutoff, mem_filter, mem_Icc] constructor · rintro ⟨⟨hp2, hpN⟩, hp⟩; exact ⟨hp, hpN⟩ · rintro ⟨hp, hpN⟩; exact ⟨⟨hp.two_le, hpN⟩, hp⟩ /-- Canonical finite enumeration equality, valid even for an empty cutoff. -/ theorem primeCutoff_eq_floor (z : ℝ) : primeCutoff z = primeNatCutoff ⌊z⌋₊ := by ext p rw [mem_primeNatCutoff] simp only [primeCutoff, mem_filter, mem_range] constructor · rintro ⟨hpN, hp⟩; exact ⟨hp, by omega⟩ · rintro ⟨hp, hpN⟩; exact ⟨by omega, hp⟩ theorem paperPrimes_eq_floor (y : ℝ) : paperPrimes y = primeNatCutoff ⌊Real.sqrt y⌋₊ := primeCutoff_eq_floor (Real.sqrt y) /-- Exact strict/closed real band becomes the strict/closed natural floor band. -/ theorem middle_filter_eq_floor_band (y z0 z1 : ℝ) (hz0 : 0 ≤ z0) (hz01 : z0 ≤ z1) (hz1 : z1 ≤ Real.sqrt y) : (paperPrimes y).filter (middleBand z0 z1) = (primeNatCutoff ⌊z1⌋₊).filter (fun p => ⌊z0⌋₊ < p) := by have hz10 : 0 ≤ z1 := hz0.trans hz01 ext p simp only [mem_filter, mem_paperPrimes, mem_primeNatCutoff, middleBand] constructor · rintro ⟨⟨hp, hps⟩, hp0, hp1⟩ refine ⟨⟨hp, (Nat.le_floor_iff hz10).mpr hp1⟩, ?_⟩ by_contra h have hh := (Nat.le_floor_iff hz0).mp (le_of_not_gt h) linarith · rintro ⟨⟨hp, hp1⟩, hp0⟩ have hr1 := (Nat.le_floor_iff hz10).mp hp1 have hr0 : z0 < (p : ℝ) := by by_contra h have hh := (Nat.le_floor_iff hz0).mpr (le_of_not_gt h) omega exact ⟨⟨hp, hr1.trans hz1⟩, hr0, hr1⟩ def ordinaryConstant : ℝ := 4 * Real.exp (10 * Real.log 4) def productConstant : ℝ := 128 * ordinaryConstant ^ 2 def survivorConstant : ℝ := SieveParameters.uniformConstant * productConstant private theorem square_mono {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) : a ^ 2 ≤ b ^ 2 := by have hb : 0 ≤ b := ha.trans hab nlinarith [mul_nonneg (sub_nonneg.mpr hab) (add_nonneg ha hb)] /-- Quantitative actual product with exact natural floors; no cutoff surrogate. -/ theorem actual_product_floor_le (y z0 z1 : ℝ) (hz0 : 3 < z0) (hz01 : z0 ≤ z1) (hz1 : z1 ≤ Real.sqrt y) : EulerRatio.fullV y z0 z1 ≤ 2 * ordinaryConstant ^ 2 * (Real.log (⌊z0⌋₊ : ℕ) / Real.log (⌊z1⌋₊ : ℕ)) ^ 2 / (Real.log (⌊Real.sqrt y⌋₊ : ℕ)) ^ 2 := by have hz00 : 0 ≤ z0 := by linarith have hz10 : 0 ≤ z1 := hz00.trans hz01 have hA : 2 ≤ ⌊z0⌋₊ := (Nat.le_floor_iff hz00).mpr (by norm_num only [Nat.cast_ofNat]; linarith) have hB : 2 ≤ ⌊z1⌋₊ := (Nat.le_floor_iff hz10).mpr (by norm_num only [Nat.cast_ofNat]; linarith) have hZ : 2 ≤ ⌊Real.sqrt y⌋₊ := (Nat.le_floor_iff (Real.sqrt_nonneg y)).mpr (by norm_num only [Nat.cast_ofNat]; linarith) have hAB : ⌊z0⌋₊ ≤ ⌊z1⌋₊ := Nat.floor_mono hz01 have hbase := MertensBand.ordinary_product_le ⌊Real.sqrt y⌋₊ hZ have hband := MertensBand.band_product_le ⌊z0⌋₊ ⌊z1⌋₊ hA hB hAB have hbasenonneg := (MertensBand.ordinary_product_pos ⌊Real.sqrt y⌋₊).le have hbandnonneg : 0 ≤ ∏ p ∈ (primeNatCutoff ⌊z1⌋₊).filter (fun p => ⌊z0⌋₊ < p), (1 - (p : ℝ)⁻¹) := by apply prod_nonneg intro p hp have hpp := ((mem_primeNatCutoff _ p).mp (mem_filter.mp hp).1).1 have hp1 : (1 : ℝ) < p := by exact_mod_cast hpp.one_lt exact sub_nonneg.mpr (((inv_lt_one₀ (by linarith)).mpr hp1).le) have hb := MertensBand.actual_auxiliary_product_le y z0 z1 hz0 have hbaseline : (∏ p ∈ paperPrimes y, (1 - (p : ℝ)⁻¹)) = MertensBand.ordinaryProduct ⌊Real.sqrt y⌋₊ := by rw [paperPrimes_eq_floor]; rfl rw [middle_filter_eq_floor_band y z0 z1 hz00 hz01 hz1, hbaseline] at hb change EulerRatio.fullV y z0 z1 ≤ 2 * (MertensBand.ordinaryProduct ⌊Real.sqrt y⌋₊) ^ 2 * (∏ p ∈ (primeNatCutoff ⌊z1⌋₊).filter (fun p => ⌊z0⌋₊ < p), (1 - (p : ℝ)⁻¹)) ^ 2 at hb have hsbase := square_mono hbasenonneg hbase have hsband := square_mono hbandnonneg hband calc _ ≤ _ := hb _ ≤ 2 * (1 / Real.log (⌊Real.sqrt y⌋₊ : ℕ)) ^ 2 * (ordinaryConstant * Real.log (⌊z0⌋₊ : ℕ) / Real.log (⌊z1⌋₊ : ℕ)) ^ 2 := by exact mul_le_mul (mul_le_mul_of_nonneg_left hsbase (by norm_num)) hsband (sq_nonneg _) (by positivity) _ = _ := by unfold ordinaryConstant; ring /-- Explicit positive-domain floor/log bounds; excludes negative-log conventions. -/ theorem floor_log_bounds (x : ℝ) (hx : 4 ≤ x) : 2 ≤ ⌊x⌋₊ ∧ 0 < Real.log x ∧ Real.log x / 2 ≤ Real.log (⌊x⌋₊ : ℕ) ∧ Real.log (⌊x⌋₊ : ℕ) ≤ Real.log x := by have hx0 : 0 ≤ x := by linarith have hN : 2 ≤ ⌊x⌋₊ := (Nat.le_floor_iff hx0).mpr (by norm_num only [Nat.cast_ofNat]; linarith) have hN0 : (0 : ℝ) < (⌊x⌋₊ : ℕ) := by exact_mod_cast (show 0 < ⌊x⌋₊ by omega) have hhalf : x / 2 ≤ (⌊x⌋₊ : ℕ) := by have hh := Nat.lt_floor_add_one x linarith have hlow := Real.log_le_log (show 0 < x / 2 by linarith) hhalf rw [Real.log_div (show x ≠ 0 by linarith) (by norm_num : (2 : ℝ) ≠ 0)] at hlow have h4 : Real.log (4 : ℝ) = 2 * Real.log 2 := by rw [show (4 : ℝ) = 2 * 2 by norm_num, Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) (by norm_num : (2 : ℝ) ≠ 0)] ring have hlog4 := Real.log_le_log (by norm_num : (0 : ℝ) < 4) hx rw [h4] at hlog4 exact ⟨hN, Real.log_pos (by linarith), by linarith, Real.log_le_log hN0 (Nat.floor_le hx0)⟩ /-- Main-sufficient upper direction of eq21 for the literal actual sieve product. -/ theorem actual_product_real_le (y z0 z1 : ℝ) (hy : 16 ≤ y) (hz0 : 4 ≤ z0) (hz01 : z0 ≤ z1) (hz1 : z1 ≤ Real.sqrt y) : EulerRatio.fullV y z0 z1 ≤ productConstant * (Real.log z0 / Real.log z1) ^ 2 / (Real.log y) ^ 2 := by have hy0 : 0 ≤ y := by linarith have hs4 : 4 ≤ Real.sqrt y := by nlinarith [Real.sqrt_nonneg y, Real.sq_sqrt hy0] have hA := floor_log_bounds z0 hz0 have hB := floor_log_bounds z1 (hz0.trans hz01) have hZ := floor_log_bounds (Real.sqrt y) hs4 have hL0 : 0 < Real.log z0 := hA.2.1 have hL1 : 0 < Real.log z1 := hB.2.1 have hlogB : 0 < Real.log (⌊z1⌋₊ : ℕ) := by linarith [hB.2.1, hB.2.2.1] have hlogZ : 0 < Real.log (⌊Real.sqrt y⌋₊ : ℕ) := by linarith [hZ.2.1, hZ.2.2.1] have hlogY : 0 < Real.log y := Real.log_pos (by linarith) have hRatio : Real.log (⌊z0⌋₊ : ℕ) / Real.log (⌊z1⌋₊ : ℕ) ≤ 2 * Real.log z0 / Real.log z1 := by apply (div_le_iff₀ hlogB).mpr calc _ ≤ Real.log z0 := hA.2.2.2 _ = (2 * Real.log z0 / Real.log z1) * (Real.log z1 / 2) := by field_simp [hL1.ne'] <;> ring _ ≤ _ := mul_le_mul_of_nonneg_left hB.2.2.1 (by positivity) have hZlower : Real.log y / 4 ≤ Real.log (⌊Real.sqrt y⌋₊ : ℕ) := by have hh := hZ.2.2.1 rw [Real.log_sqrt hy0] at hh linarith have hInvZ : 1 / Real.log (⌊Real.sqrt y⌋₊ : ℕ) ≤ 4 / Real.log y := by apply (div_le_iff₀ hlogZ).mpr calc (1 : ℝ) = (4 / Real.log y) * (Real.log y / 4) := by field_simp _ ≤ _ := mul_le_mul_of_nonneg_left hZlower (by positivity) have hRA0 : 0 ≤ Real.log (⌊z0⌋₊ : ℕ) / Real.log (⌊z1⌋₊ : ℕ) := by have hh : 0 ≤ Real.log (⌊z0⌋₊ : ℕ) := by linarith [hA.2.1, hA.2.2.1] exact div_nonneg hh hlogB.le have hRI0 : 0 ≤ 1 / Real.log (⌊Real.sqrt y⌋₊ : ℕ) := one_div_nonneg.mpr hlogZ.le have hsR := square_mono hRA0 hRatio have hsI := square_mono hRI0 hInvZ calc _ ≤ 2 * ordinaryConstant ^ 2 * (Real.log (⌊z0⌋₊ : ℕ) / Real.log (⌊z1⌋₊ : ℕ)) ^ 2 / (Real.log (⌊Real.sqrt y⌋₊ : ℕ)) ^ 2 := actual_product_floor_le y z0 z1 (by linarith) hz01 hz1 _ = 2 * ordinaryConstant ^ 2 * (Real.log (⌊z0⌋₊ : ℕ) / Real.log (⌊z1⌋₊ : ℕ)) ^ 2 * (1 / Real.log (⌊Real.sqrt y⌋₊ : ℕ)) ^ 2 := by ring _ ≤ 2 * ordinaryConstant ^ 2 * (2 * Real.log z0 / Real.log z1) ^ 2 * (4 / Real.log y) ^ 2 := mul_le_mul (mul_le_mul_of_nonneg_left hsR (by positivity)) hsI (sq_nonneg _) (by positivity) _ = _ := by unfold productConstant; ring /-- Uniform finite survivor estimate after product composition; original m not substituted. -/ theorem actual_survivor_band_le (X : ℕ) (y z0 z1 : ℝ) (hy : SieveParameters.threshold ≤ y) (hz0 : 4 ≤ z0) (hz01 : z0 ≤ z1) (hz1 : z1 ≤ Real.sqrt y) : (SieveInterface.survivorCount X y z0 z1 : ℝ) ≤ survivorConstant * (X : ℝ) * (Real.log z0 / Real.log z1) ^ 2 / (Real.log y) ^ 2 + y / (12 * Real.log y) := by have hY := SieveParameters.large_y_facts y hy have hy16 : 16 ≤ y := by have hh := Real.add_one_le_exp (Real.log y) rw [Real.exp_log hY.1] at hh linarith [hY.2.2.1] have hV := actual_product_real_le y z0 z1 hy16 hz0 hz01 hz1 have hC : 0 ≤ SieveParameters.uniformConstant := by unfold SieveParameters.uniformConstant; positivity calc _ ≤ SieveParameters.uniformConstant * (X : ℝ) * EulerRatio.fullV y z0 z1 + y / (12 * Real.log y) := SieveParameters.actual_uniform_survivor X y z0 z1 hy (by linarith) _ ≤ SieveParameters.uniformConstant * (X : ℝ) * (productConstant * (Real.log z0 / Real.log z1) ^ 2 / (Real.log y) ^ 2) + y / (12 * Real.log y) := _root_.add_le_add (mul_le_mul_of_nonneg_left hV (mul_nonneg hC (Nat.cast_nonneg X))) le_rfl _ = _ := by unfold survivorConstant; ring end end RealBand #print axioms RealBand.primeNatCutoff #print axioms RealBand.mem_primeNatCutoff #print axioms RealBand.primeCutoff_eq_floor #print axioms RealBand.paperPrimes_eq_floor #print axioms RealBand.middle_filter_eq_floor_band #print axioms RealBand.ordinaryConstant #print axioms RealBand.productConstant #print axioms RealBand.survivorConstant #print axioms RealBand.actual_product_floor_le #print axioms RealBand.floor_log_bounds #print axioms RealBand.actual_product_real_le #print axioms RealBand.actual_survivor_band_le