MathlibNt.SieveTheory.SelbergUpperBound #
Selberg sieve and the target bound Ξ© β€ 3.9404 π(N) N/logΒ²N #
The Selberg sieve is a central tool for the upper bound on Ξ© in Chen's theorem. Selberg upper-bound weights Ξ»_d lead to a main term Mβ and a remainder R.
Classical proof outline (Liu 2022, Β§III):
Selberg weights (Lemma 3): construct Ξ»_d with
- Ξ»β = 1 and Ξ»_d = 0 for d > z or d β€ Q;
- |Ξ»_d| β€ 1;
- Ξ£_{dβ,dβ} Ξ»_{dβ}Ξ»_{dβ}/Ο([dβ,dβ]) = [8 + O(Ξ΅)] π(N)/log N.
Numerical integration (Lemma 4): Ξ£_a f(a)/(a log(N/a)) β€ 0.49254/log N.
Main term: for suitably controlled Ξ΅, Mβ β€ [8 + O(Ξ΅)] Β· 0.49254 Β· π(N) N/logΒ²N β€ 3.94033 π(N) N/logΒ²N.
Remainder: R βͺ N/log^A N, using Pan's mean-value theorem.
Combination: Ξ© β€ Mβ + |R| β€ 3.9404 π(N) N/logΒ²N.
This module connects the development to Mathlib.NumberTheory.SelbergSieve
and proves finite algebraic and divisor-sum results. The interfaces for the
numerical main and error terms below allow constants depending on a fixed N;
they do not establish the uniform optimized bounds in this classical outline.
References:
- Selberg, A. (1947), Norske Vid. Selsk. Forh. Trondheim 19, 75-79
- Liu, Z. (2022), arXiv:2203.07871, Lemma 3-4, Β§III
- Halberstam & Richert, "Sieve Methods" (1974), Ch. 3
- Mathlib
SelbergSieve.lean: BoundingSieve, SelbergSieve, ΞΒ² sieve
1. Selberg sieve weights (Lemma 3) #
Q is the product of primes β€ z = N^(1/4 - Ξ΅/2) that do not divide N.
Equations
Instances For
Selberg weight conditions (Lemma 3, Liu 2022). The structure records:
- Ξ»β = 1
- Ξ»_d = 0 when d > z or d β€ Q
- |Ξ»_d| β€ 1
The classical optimized weights additionally satisfy Ξ£_{dβ,dβ} Ξ»_{dβ}Ξ»_{dβ}/Ο([dβ,dβ]) = [8 + O(Ξ΅)] π(N)/log N; this quadratic-form estimate is not a field of the structure.
The weight function Ξ»_d.
Ξ»β = 1
- lambda_support (d : β) : d > ββN ^ (1 / 4 - Ξ΅ / 2)ββ β¨ Β¬d β£ selbergQ N Ξ΅ β self.lambda d = 0
Ξ»_d = 0 when d > z or d β€ Q.
|Ξ»_d| β€ 1
Instances For
Pointwise interface for Selberg weights, motivated by Lemma 3:
Ξ£_{dβ,dβ} Ξ»_{dβ}Ξ»_{dβ}/Ο([dβ,dβ]) = [8 + O(Ξ΅)] π(N)/log N
The uniform version is a key ingredient in estimating the main term Mβ for Ξ©.
The constant C here has no uniformity, positivity, or compatibility
requirements with other sieve data. Explicit Ξ΄β weights therefore suffice,
with C absorbing the difference. This is not the optimized Selberg-weight
estimate of Liu/Wang, which needs a controlled error suitable for comparing
main terms.
2. Numerical integration (Lemma 4) #
Pointwise interface motivated by Lemma 4 (Liu 2022). For the indicator f(a) of a = pβpβ satisfying the range conditions, the classical target is
Ξ£_a f(a)/(a log(N/a)) β€ 0.49254 / log N
Partial summation leads to the double-integral expression = (1/log N) β«{1/10}^{1/3} dΞ±/Ξ± β«{1/3}^{(1-Ξ±)/2} dΞ²/(Ξ²(1-Ξ±-Ξ²)) < 0.49254 / log N
Here C may depend on the individual N, with no uniformity requirement.
This interface gives only the algebraic existence of a pointwise remainder,
not a formalization of the uniform analytic integral estimate above.
Numerical margin used by the Lemma 4 interface: 0.49253 < 0.49254.
This theorem does not formalize the motivating double integral.
The integral estimate in the literature requires a separate formalization
using MeasureTheory / IntervalIntegral.
3. Estimating the main term Mβ #
The logarithmic-integral approximation term used here.
Instances For
Interface with the shape of li(x) = x/log x + O(x/logΒ²x).
Since logarithmicIntegral_approx_term x = x / log x by definition,
the difference is zero and C = 0 suffices. This is not an estimate of the
analytic logarithmic integral.
Main term Mβ, with a pointwise remainder: Mβ = Ξ£_{dβ,dβ} Ξ»_{dβ}Ξ»_{dβ}/Ο([dβ,dβ]) Β· Ξ£_a f(a) Β· li(N/a)
The classical Lemmas 3 and 4, with controlled errors, would give Mβ β€ [8 + O(Ξ΅)] π(N)/log N Β· 0.49254 N/log N β€ 3.94033 π(N) N/logΒ²N.
SelbergWeights encodes normalization, support, and |lambda d| β€ 1,
but not optimality or the quadratic-form estimate above. These structural
hypotheses do not imply a remainder-free 3.94033 bound for arbitrary SW.
This theorem retains the existence of an additive remainder for fixed N;
a uniform controlled C requires the actual Selberg quadratic-form estimate.
8 Γ 0.49254 = 3.94032
4. Estimating the remainder R #
Local definition: Ο(x; q, l) = |{p β€ x : p prime, p β‘ l (mod q)}|.
Equations
- MathlibNt.SieveTheory.SelbergUpperBound.primesInAP x q l = {p β Finset.range (x + 1) | Nat.Prime p β§ p β‘ l [MOD q]}.card
Instances For
Remainder R: the Selberg sieve expansion leads to
|R| β€ Ξ£_{d|Q, d β€ N^(1/2-Ξ΅)} 3^Ο(d) |Ξ£_a f(a) Ξ(N; a, d, N)|
The factor 3^Ο(d) counts pairs (dβ,dβ) with [dβ,dβ] = d. The intended uniform estimate R βͺ N/log^A N uses Pan's mean-value theorem.
The quantifiers here allow C to depend on the individual N and the entire
error sum. This establishes only a pointwise algebraic interface, not the
uniform constant required by Pan's mean-value theorem.
Origin of 3^Ο(d): the number of pairs (dβ, dβ) with [dβ, dβ] = d is 3^Ο(d).
This holds only for squarefree d. At each prime factor p of d, where v_p(d) = 1, the exponents in (dβ, dβ) have three possibilities: (0, 1), (1, 0), (1, 1) and hence the total is 3^Ο(d).
For nonsquarefree d, the formula is β_p (2v_p(d) + 1), not 3^Ο(d). For example, d = 4 gives 5 pairs, whereas 3^1 = 3. In Chen's sieve, d | Q and Q is a product of distinct primes, so d is squarefree.
A strong-induction proof has the following structure:
- Base: d = 1 gives count = 1 = 3^0.
- Step: d = p Β· d', with p prime and gcd(p, d') = 1.
- divisors(d) = divisors(d') β (p Β· divisors(d')), by coprimality.
- Three cases each give f(d') pairs: A) p|dβ, p|dβ: lcm(pa, pb) = pΒ·lcm(a,b) = pΒ·d' βΊ lcm(a,b) = d' B) p|dβ, pβ€dβ: lcm(pa, b) = pΒ·lcm(a,b), since gcd(p,b)=1; as above C) pβ€dβ, p|dβ: symmetric to B D) pβ€dβ, pβ€dβ: impossible, since then p β€ lcm(dβ,dβ) = d
- Thus f(d) = 3Β·f(d') = 3Β·3^Ο(d') = 3^(Ο(d')+1) = 3^Ο(d). The proof below applies Mathlib's existing counting theorem.
5. Combined upper-bound interfaces for Ξ© #
Combined pointwise interface for Ξ©, motivated by the target Ξ© β€ Mβ + |R| β€ 3.9404 π(N) N/logΒ²N.
Classical proof outline:
- Ξ© β€ Ξ£_a f(a) Ξ£_{ap β€ N, (N-ap, Q)=1} 1 + N^(2/3) z, by prime factorization.
- Bound this by Ξ£_a f(a) Ξ£_{ap β€ N} (Ξ£_d Ξ»_d)Β² + N^(11/12), using the Selberg upper sieve.
- Exchange the sums to obtain the main term Mβ and remainder R.
- Bound Mβ β€ 3.94033 π(N) N/logΒ²N, using Lemmas 3 and 4.
- Bound |R| βͺ N/log^A N, using Pan's mean-value theorem.
- Combine to get Ξ© β€ 3.9404 π(N) N/logΒ²N.
The conclusion below allows C to depend on the individual N. It therefore
establishes an interface with a pointwise additive remainder, not the uniform
remainder-free conclusion in this outline.
Pointwise form without the Ξ΅ parameter.
Take Ξ΅ = 1/4 in chenOmega_complete_bound. Since its C may depend on
the fixed N, the additive remainder must be retained. A uniform
remainder-free 3.9404 bound requires optimized Selberg weights and
a uniform version of Pan's mean-value theorem.
6. Correspondence with Mathlib's Selberg sieve #
Construct Mathlib's lambdaSquared weights from SelbergWeights.
Mathlib: lambdaSquared weights d = Ξ£_{dβ|d} Ξ£_{dβ|d} if d = lcm(dβ,dβ) then weights(dβ)Β·weights(dβ) else 0
Here SW.lambda supplies Mathlib's weights parameter, and
lambdaSquared gives the Selberg coefficients
Ξ»_d = Ξ£_{[dβ,dβ]=d} Ξ»_{dβ}Β·Ξ»_{dβ}.
Equations
Instances For
Bridge theorem 1: lambdaSquared constructed from the Selberg weights
is upper MΓΆbius.
Apply Mathlib's upperMoebius_lambdaSquared: if weights 1 = 1,
then lambdaSquared weights satisfies IsUpperMoebius.
The field SelbergWeights.lambda_one supplies exactly lambda 1 = 1.
Bridge theorem 2: Mathlib's
siftedSum_le_mainSum_errSum_of_upperMoebius gives the generic upper sieve bound.
For a BoundingSieve encoding the sieve problem, any weights w with w 1 = 1
give upper MΓΆbius coefficients lambdaSquared w, and hence
siftedSum β€ totalMass Β· mainSum(lambdaSquared w) + errSum(lambdaSquared w)
The target Chen bound Ξ© β€ 3.9404 π(N) N/logΒ²N additionally requires
an optimized estimate of mainSum(lambdaSquared w) on the scale
8 π(N)/log N and errSum(lambdaSquared w) βͺ N/log^A N.
Selberg diagonalization and Pan's mean-value theorem motivate these two inputs;
the pointwise interfaces selberg_sieve_weights_exist and error_term_bound
do not by themselves supply their uniform versions.
Bridge theorem 3: diagonalization of the main term via Mathlib's
mainSum_lambdaSquared_eq_sum_mul_sum_sq.
For any weights w, Mathlib proves mainSum(lambdaSquared w) = Ξ£_{l | P} (selbergTerms l)β»ΒΉ Β· (Ξ£_{l|d|P} Ξ½(d)Β·w(d))Β²
This underlies the choice of optimal Selberg weights: minimizing the quadratic form gives mainSum = (Ξ£_{l|P} selbergTerms l)β»ΒΉ in the unrestricted divisor setup.
For Chen's theorem, the corresponding level-restricted optimization and analytic estimates are the basis of Lemma 3's mainSum bound at scale 8 π(N)/log N; diagonalization alone does not prove that estimate.
Bridge theorem 4: the Selberg-sieve Cauchy-Schwarz lower bound.
For the diagonal variables x_l = Ξ£_{l|d|P} Ξ½(d)Β·w(d), MΓΆbius inversion and w(1) = 1 give Ξ£_l ΞΌ(l)x_l = 1. Cauchy-Schwarz, with a_l = (selbergTerms l)β»ΒΉ, gives Ξ£_l a_l x_lΒ² β₯ (Ξ£_l ΞΌ(l)x_l)Β² / (Ξ£_l ΞΌ(l)Β²/a_l). All l | P are squarefree, so ΞΌ(l)Β² = 1. Therefore mainSum β₯ 1 / (Ξ£_l selbergTerms l).
The signed MΓΆbius identity is essential: no positivity assumption on w justifies replacing it by a claim that x_1 β₯ 1.
Equality characterizes the optimal Selberg weights on the relevant divisors, for which mainSum = (Ξ£_{l|P} selbergTerms l)β»ΒΉ.
The classical Chen calculation seeks the corresponding level-restricted estimate Ξ£_{l|P} selbergTerms l β log N / (8 π(N)) and hence the optimized mainSum scale 8 π(N) / log N (Lemma 3).
Cauchy-Schwarz gives a lower bound, not an upper bound: mainSum β₯ (Ξ£ selbergTerms)β»ΒΉ for every normalized w, with equality only for optimal weights. The theorem below proves this finite lower bound.
7. Auxiliary definition: Ο(x; a, q, l) #
Ο(x; a, q, l) = |{p β€ x : ap prime, ap β‘ l (mod q)}|.
Equations
Instances For
Ξ(x; a, q, l) = Ο(x; a, q, l) - li(x/a)/Ο(q)
Equations
Instances For
6.5a. Ingredients for divisor_sum_bound #
Weight f(d) = A^{Ο(d)}/Ο(d), with f(0) = 0.
Equations
- MathlibNt.SieveTheory.SelbergUpperBound.divisorWeight A = { toFun := fun (d : β) => A ^ d.primeFactors.card / βd.totient, map_zero' := β― }
Instances For
The real-valued zeta arithmetic function: 1 on positive integers, 0 at zero.
Equations
- MathlibNt.SieveTheory.SelbergUpperBound.zetaR = { toFun := fun (n : β) => if n = 0 then 0 else 1, map_zero' := MathlibNt.SieveTheory.SelbergUpperBound.zetaR._proof_1 }
Instances For
6.5. Lemma 2 (divisor-sum bound) #
Divisor-sum bound strengthening Lemma 2 (Liu 2022). For A > 0 and n β₯ 1, the source statement is Ξ£_{d|n} ΞΌΒ²(d) A^Ο(d)/Ο(d) βͺ (log log 3n)^A
The theorem below proves the stronger bound without ΞΌΒ²(d). In particular, if n is a product of distinct primes β€ y and y β₯ 3, the sum is βͺ (log y)^A.
This gives the estimate Ξ£ 3^Ο(d)/Ο(d) βͺ (log N)Β³ used for the remainder Rβ.
Source form of Lemma 2 (Liu 2022): Ξ£_{d|n} ΞΌΒ²(d)Β·A^{Ο(d)}/Ο(d) βͺ (log log 3n)^A.
The notation matches Liu 2022, Lemma 2, arXiv:2203.07871:
- Ο(d) is the number of distinct prime factors of d (
d.primeFactors.card); - Ο(d) is Euler's totient function (
Nat.totient d); - ΞΌΒ²(d) is the square of the MΓΆbius function, the squarefree indicator;
- the upper-bound scale is (log log 3n)^A, for fixed A > 0.
divisor_sum_bound proves the stronger version without ΞΌΒ², summing over all
divisors. Since every summand is nonnegative and ΞΌΒ²(d) β {0,1}, that version
implies the source statement.
Divisor-sum weight f(d) = A^{Ο(d)}/Ο(d), as an arithmetic function with f(0) = 0.
Equations
- MathlibNt.SieveTheory.SelbergUpperBound.chenDivisorWeight A = { toFun := fun (d : β) => A ^ d.primeFactors.card / βd.totient, map_zero' := β― }
Instances For
Special case of Lemma 2: if n is a product of distinct primes β€ y
(that is, Squarefree n and all prime factors are β€ y), with y β₯ 3,
then Ξ£_{d|n} A^Ο(d)/Ο(d) βͺ (log y)^A.
Proof:
- The weight f(d) = A^{Ο(d)}/Ο(d) is multiplicative, so
prodPrimeFactors_one_add_of_squarefreegives Ξ£_{d|n} f(d) = β_{p|n}(1 + f p). - At a prime p, f p = A/(p-1), hence β{p|n}(1 + A/(p-1)) β€ exp(AΒ·Ξ£{p|n} 1/(p-1)).
- Mertens' theorem (
prime_inv_pminus1_bound) gives Ξ£_{p|n} 1/(p-1) β€ Ξ£_{pβ€y} 1/(p-1) β€ log(log y) + C. - exp(AΒ·(log(log y) + C)) = e^{AC}Β·(log y)^A.
The hypotheses explicitly include Squarefree n and 3 β€ y.
Allowing y = 1 would make the right side zero while the left side is at least 1.
Application: Ξ£_{d|Q} 3^Ο(d)/Ο(d) βͺ (log N)Β³.
In Chen's sieve, Q is a product of primes β€ z = N^(1/4-Ξ΅/2). Apply Lemma 2 with A = 3 and y = N to obtain the bound.
The hypotheses include 0 < Ξ΅ and 3 β€ N.
At N = 1, the right side would be zero while the left side is at least 1.
6.6. Liu's correction: the case (a,d)>1 (Section IV) #
(a,d)>1 implies Ο(N;a,d,N) β€ 1 for the local counting definition.
When (a,d) > 1 and a β₯ 1, we have a β₯ 2, so ap can be prime only if p = 1. Indeed, a | ap, and primality gives a = 1 or a = a*p. The first case contradicts a β₯ 2, and the second gives p = 1. Thus at most one p satisfies the conditions, and the count is at most 1.
Lemma for Rβ: for d | Q, Ξ£_{N^(1/10) < pβ β€ N^(1/3), pβ|d} 1/pβ is bounded uniformly in d.
The sum is at most Ξ£_{N^(1/10) < p β€ N^(1/3)} 1/p. Lemma 1,
prime_reciprocal_sum_bounded with Ξ± = 1/10 and Ξ² = 1/3,
bounds this by Cβ independently of d.
Rβ upper-bound interface for the contribution with (a,d)>1:
Rβ βͺ Ξ£_{d|Q} 3^Ο(d)/Ο(d) Β· max Ξ£_{(a,d)>1} f(a) Β· li(N/a) βͺ (log N)Β³ Β· N
Limitation of an unrestricted divisor estimate
(see the known-error discussion in pan-wang-ding-1975.md):
the estimate attributed there to Pan et al. (1975) and Liu (2022) is
Ξ£_{pβ|d, pβ>N^(1/10)} 1/pβ βͺ N^(-1/10),
leading to Rβ βͺ N^(9/10)(log N)Β³. Without a size restriction on d, that
reciprocal-sum estimate is false: for d = β{N^(1/10)<pβ€N^(1/4)} p,
the left side tends to the positive constant log(5/2), not to zero.
The bound used here instead applies Lemma 1 twice:
Ξ£{pβ|d, pββ(N^(1/10),N^(1/3)]} 1/pβ β€ Cβ,
Ξ£_{pββ(N^(1/3),(N/pβ)^(1/2)]} 1/pβ β€ Cβ.
Since li(N/a) βͺ N/a, the inner sum is βͺ N, giving the scale
Rβ βͺ (log N)Β³Β·N. This suffices for the bound below, not for a uniform
N/log^A N error estimate. The theorem's constant is quantified after N.
Pointwise constant interface at the scale N^(9/10) (log N)Β².
The constant C may depend on the individual N. A uniform Liu-type bound
would require the constant to be quantified before β N.
Pointwise interface for the complete error, motivated by Liu's correction and the target R = Rβ + Rβ βͺ N/log^A N.
- Rβ is the part with (a,d)=1, for which Pan's mean-value theorem supplies the intended estimate Rβ βͺ N/log^A N.
- Rβ is the part with (a,d)>1. A uniform estimate Rβ βͺ N^(9/10) (log N)Β² would imply Rβ βͺ N/log^A N for sufficiently large N.
Liu (2022) addresses the omission of the case (a,d)>1 in Pan et al. (1975).
The quantifier order here still expresses only a pointwise error constant.
It does not establish the uniform estimates in this outline, and
r1_simplified_bound is also only a pointwise interface.