/- Released under Apache 2.0; see adjacent LICENSE. Modified adaptation of OpenAI math revision adc7f1241b42e322a6451854ab7e4b4c146bf78a, OAI/NumberTheory/TotientAsymptotic/MertensLogMass.lean: the finite weighted summation and prime-log proof. No foreign CofactorEnvelope/project imports. Elementary theta fragments adapted from pinned Mathlib Chebyshev.lean: Copyright (c) 2025 Alastair Irving. All rights reserved. Authors: Alastair Irving, Terry Tao, Ruben Van de Velde. The harmonic log bound is replaced with an elementary induction, avoiding uncached measure/integral dependencies. Density and restricted-prime-subset Selberg denominator bridges below are modifications for the actual manuscript. -/ import SelbergEuler import Mathlib.NumberTheory.Primorial import Mathlib.NumberTheory.Harmonic.Defs namespace PrimeLog noncomputable section open scoped BigOperators open Finset Nat Real /-- Only the elementary prime sum needed from the Chebyshev function. -/ def theta (x : ℝ) : ℝ := ∑ p ∈ Ioc 0 ⌊x⌋₊ with p.Prime, Real.log (p : ℝ) theorem theta_eq_sum_Icc (x : ℝ) : theta x = ∑ p ∈ Icc 0 ⌊x⌋₊ with p.Prime, Real.log (p : ℝ) := by rw [theta, sum_filter, sum_filter, ← add_sum_Ioc_eq_sum_Icc] <;> simp theorem theta_eq_log_primorial (x : ℝ) : theta x = Real.log (primorial ⌊x⌋₊) := by unfold theta primorial rw [cast_prod, Real.log_prod (fun p hp => by exact_mod_cast (mem_filter.mp hp).2.pos.ne')] congr 1 with p simp_all [Prime.pos] theorem theta_le_log4_mul_x {x : ℝ} (hx : 0 ≤ x) : theta x ≤ Real.log 4 * x := by rw [theta_eq_log_primorial] trans Real.log (4 ^ ⌊x⌋₊) · gcongr <;> norm_cast exacts [primorial_pos _, primorial_le_four_pow _] rw [Real.log_pow, mul_comm] gcongr exact floor_le hx /-- Elementary telescoping proof; no integral/harmonic-bound theorem assumed. -/ theorem harmonic_le_one_add_log (n : ℕ) : (harmonic n : ℝ) ≤ 1 + Real.log (n : ℝ) := by induction n with | zero => simp | succ n ih => by_cases hn0 : n = 0 · simp [hn0, harmonic_succ] have hn : (0 : ℝ) < n := by exact_mod_cast Nat.pos_of_ne_zero hn0 have hn1 : (0 : ℝ) < (n : ℝ) + 1 := by positivity have hh := Real.one_sub_inv_le_log_of_pos (div_pos hn1 hn) have he : 1 - (((n : ℝ) + 1) / (n : ℝ))⁻¹ = ((n : ℝ) + 1)⁻¹ := by field_simp ring rw [he, Real.log_div hn1.ne' hn.ne'] at hh have hrec : (harmonic (n + 1) : ℝ) = (harmonic n : ℝ) + ((n : ℝ) + 1)⁻¹ := by rw [harmonic_succ] push_cast rfl rw [hrec] push_cast linarith theorem weighted_sum_le_harmonic (a : ℕ → ℝ) (C : ℝ) (ha0 : a 0=0) (hA : ∀ n : ℕ, (∑ i ∈ Finset.range (n+1), a i) ≤ C*(n+1)) (n : ℕ) : (∑ i ∈ Finset.range (n+1), a i/(i : ℝ)) ≤ (∑ i ∈ Finset.range (n+1), a i)/(n+1)+C*(harmonic n : ℝ) := by induction n with | zero => simp [ha0] | succ n ih => have hn : (0 : ℝ) if n.Prime then Real.log n else 0 have he (n : ℕ) : (∑ i ∈ Finset.range (n+1), a i)=theta n := by rw [theta_eq_sum_Icc,Nat.floor_natCast,← Nat.range_succ_eq_Icc_zero, Finset.sum_filter] have hA (n : ℕ) : (∑ i ∈ Finset.range (n+1), a i) ≤ Real.log 4*(n+1) := by rw [he] have hh := theta_le_log4_mul_x (Nat.cast_nonneg n) have hc : 0 ≤ Real.log 4 := Real.log_nonneg (by norm_num) nlinarith have hb := weighted_sum_le_harmonic a (Real.log 4) (by simp [a]) hA N have hsum : (∑ i ∈ Finset.range (N+1), a i/(i : ℝ))= ∑ p ∈ (Finset.Icc 2 N).filter Nat.Prime, Real.log p/(p : ℝ) := by rw [Nat.range_succ_eq_Icc_zero,Finset.sum_filter] simp only [a,ite_div,zero_div] symm apply Finset.sum_subset (fun p hp => by have hh := Finset.mem_Icc.mp hp exact Finset.mem_Icc.mpr ⟨by omega,hh.2⟩) · intro p hp hnot have hp2 : p<2 := by have hh := Finset.mem_Icc.mp hp simp only [Finset.mem_Icc,not_and_or,not_le] at hnot omega have hprime : ¬p.Prime := fun hh => (not_le_of_gt hp2) hh.two_le simp [hprime] rw [hsum] at hb have ht := (div_le_iff₀ (show (0 : ℝ) Real.log (p : ℝ)) (fun p hp => SelbergEuler.odds_nonneg s p (hQ hp)) (fun p hp => Real.log_nonneg (by exact_mod_cast (Nat.prime_of_mem_primeFactors (hQ hp)).one_lt.le)) hl hm have he : (∏ p ∈ Q, (1 + SelbergEuler.odds s p)) = (∏ p ∈ Q, (1 - s.nu p))⁻¹ := by rw [← prod_inv_distrib] apply prod_congr rfl intro p hp exact SelbergEuler.one_add_odds s p (hQ hp) rw [he] at hh exact hh.trans (denominator_ge_subset_sum s Q hQ L (by linarith)) /-- Quantitative actual subset bound; the scale inequality is sufficient, not necessary. -/ theorem actual_subset_denominator_lower (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) : (∏ p ∈ (paperPrimes y).filter (fun p => p ≤ N), (1 - ActualBoundingSieve.density (omegaSet z0 z1) p))⁻¹ / 2 ≤ SelbergFinite.denominator (ActualBoundingSieve.sieve X y z0 z1 hz0) L := by let Q := (paperPrimes y).filter (fun p => p ≤ N) have hQ : Q ⊆ paperPrimes y := filter_subset _ _ have hP : (ActualBoundingSieve.sieve X y z0 z1 hz0).prodPrimes.primeFactors = paperPrimes y := by change (∏ p ∈ paperPrimes y, p).primeFactors = _ exact Nat.primeFactors_prod (paperPrimeFamily y) have hsub : Q ⊆ (ActualBoundingSieve.sieve X y z0 z1 hz0).prodPrimes.primeFactors := by rw [hP] exact hQ have hm := density_prime_log_mass_le Q (fun p hp => paperPrimeFamily y p (hQ hp)) N hN (fun p hp => (mem_filter.mp hp).2) z0 z1 hz0 have hmean : (∑ p ∈ Q, (ActualBoundingSieve.sieve X y z0 z1 hz0).nu p * Real.log (p : ℝ)) ≤ Real.log L / 4 := by change (∑ p ∈ Q, ActualBoundingSieve.density (omegaSet z0 z1) p * Real.log (p : ℝ)) ≤ _ nlinarith exact denominator_subset_lower (ActualBoundingSieve.sieve X y z0 z1 hz0) Q hsub L hL hmean end end PrimeLog #print axioms PrimeLog.theta #print axioms PrimeLog.theta_eq_sum_Icc #print axioms PrimeLog.theta_eq_log_primorial #print axioms PrimeLog.theta_le_log4_mul_x #print axioms PrimeLog.harmonic_le_one_add_log #print axioms PrimeLog.weighted_sum_le_harmonic #print axioms PrimeLog.prime_log_mass_le #print axioms PrimeLog.actual_density_le_four_div #print axioms PrimeLog.density_prime_log_mass_le #print axioms PrimeLog.paper_prime_le_floor #print axioms PrimeLog.actual_prime_log_mass_le #print axioms PrimeLog.actual_full_denominator_lower #print axioms PrimeLog.denominator_ge_subset_sum #print axioms PrimeLog.denominator_subset_lower #print axioms PrimeLog.actual_subset_denominator_lower