Documentation

MathlibNt.SieveTheory.Selberg.SelbergUpperBound

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):

  1. 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.
  2. Numerical integration (Lemma 4): Ξ£_a f(a)/(a log(N/a)) ≀ 0.49254/log N.

  3. Main term: for suitably controlled Ξ΅, M₁ ≀ [8 + O(Ξ΅)] Β· 0.49254 Β· 𝔖(N) N/logΒ²N ≀ 3.94033 𝔖(N) N/logΒ²N.

  4. Remainder: R β‰ͺ N/log^A N, using Pan's mean-value theorem.

  5. 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:

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. λ₁ = 1
    2. λ_d = 0 when d > z or d ∀ Q
    3. |Ξ»_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.

    Instances For
      theorem MathlibNt.SieveTheory.SelbergUpperBound.selberg_sieve_weights_exist (N : β„•) (Ξ΅ : ℝ) (hΞ΅ : 0 < Ξ΅) (hΞ΅' : Ξ΅ < 1 / 2) (hN : 2 ≀ N) :
      βˆƒ (SW : SelbergWeights N Ξ΅) (C : ℝ), |βˆ‘ d₁ ∈ (selbergQ N Ξ΅).divisors, (βˆ‘ dβ‚‚ ∈ (selbergQ N Ξ΅).divisors, SW.lambda d₁ * SW.lambda dβ‚‚ / ↑(d₁.lcm dβ‚‚).totient - 8 * 1 / Real.log ↑N)| ≀ C * Ξ΅ / Real.log ↑N

      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) #

      theorem MathlibNt.SieveTheory.SelbergUpperBound.lemma4_numerical_bound (N : β„•) (hN : 2 ≀ N) :
      βˆƒ (C : ℝ), βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ then 1 else 0) / (↑a * Real.log (↑N - ↑a)) ≀ 0.49254 / Real.log ↑N + C / Real.log ↑N ^ 2

      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₁ #

      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.

      theorem MathlibNt.SieveTheory.SelbergUpperBound.main_term_bound (N : β„•) (Ξ΅ : ℝ) (_hΞ΅ : 0 < Ξ΅) (_hΞ΅' : Ξ΅ < 1 / 2) (hN : 2 ≀ N) (SW : SelbergWeights N Ξ΅) :
      βˆƒ (C : ℝ), βˆ‘ d₁ ∈ (selbergQ N Ξ΅).divisors, βˆ‘ dβ‚‚ ∈ (selbergQ N Ξ΅).divisors, SW.lambda d₁ * SW.lambda dβ‚‚ / ↑(d₁.lcm dβ‚‚).totient * βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ then 1 else 0) * logarithmicIntegral_approx_term (↑N / ↑a) ≀ 3.94033 * 1 * ↑N / Real.log ↑N ^ 2 + C * ↑N / Real.log ↑N ^ 10

      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
      Instances For
        theorem MathlibNt.SieveTheory.SelbergUpperBound.error_term_bound (N : β„•) (Ξ΅ A : ℝ) (_hA : 0 < A) (_hΞ΅ : 0 < Ξ΅) (hN : 2 ≀ N) (_SW : SelbergWeights N Ξ΅) :
        βˆƒ (C : ℝ), |βˆ‘ d ∈ (selbergQ N Ξ΅).divisors with ↑d ≀ ↑N ^ (1 / 2 - Ξ΅), 3 ^ d.primeFactors.card * βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ then 1 else 0) * (↑(primesInAP N d (N % d)) - logarithmicIntegral_approx_term (↑N / ↑a) / ↑d.totient)| ≀ C * ↑N / Real.log ↑N ^ A

        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.

        theorem MathlibNt.SieveTheory.SelbergUpperBound.lcm_pair_count (d : β„•) (_hd : d β‰  0) (hsq : Squarefree d) :
        {x ∈ d.divisors Γ—Λ’ d.divisors | match x with | (d₁, dβ‚‚) => d₁.lcm dβ‚‚ = d}.card = 3 ^ d.primeFactors.card

        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 Ξ© #

        theorem MathlibNt.SieveTheory.SelbergUpperBound.chenOmega_complete_bound (N : β„•) (Ξ΅ : ℝ) (_hΞ΅ : 0 < Ξ΅) (_hΞ΅' : Ξ΅ < 1 / 2) (_hN : Even N) (hN_large : 2 ≀ N) :
        βˆƒ (C : ℝ), (βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ then 1 else 0) * βˆ‘ p₃ ∈ Finset.range (N + 1), if Nat.Prime p₃ ∧ a * p₃ ≀ N ∧ Nat.Prime (N - a * p₃) then 1 else 0) ≀ 3.9404 * 1 * ↑N / Real.log ↑N ^ 2 + C * ↑N / Real.log ↑N ^ 10

        Combined pointwise interface for Ξ©, motivated by the target Ξ© ≀ M₁ + |R| ≀ 3.9404 𝔖(N) N/logΒ²N.

        Classical proof outline:

        1. Ξ© ≀ Ξ£_a f(a) Ξ£_{ap ≀ N, (N-ap, Q)=1} 1 + N^(2/3) z, by prime factorization.
        2. Bound this by Ξ£_a f(a) Ξ£_{ap ≀ N} (Ξ£_d Ξ»_d)Β² + N^(11/12), using the Selberg upper sieve.
        3. Exchange the sums to obtain the main term M₁ and remainder R.
        4. Bound M₁ ≀ 3.94033 𝔖(N) N/logΒ²N, using Lemmas 3 and 4.
        5. Bound |R| β‰ͺ N/log^A N, using Pan's mean-value theorem.
        6. 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.

        theorem MathlibNt.SieveTheory.SelbergUpperBound.chenOmega_simple_bound (N : β„•) (hN : Even N) (hN_large : 1000 ≀ N) :
        βˆƒ (C : ℝ), (βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ then 1 else 0) * βˆ‘ p₃ ∈ Finset.range (N + 1), if Nat.Prime p₃ ∧ a * p₃ ≀ N ∧ Nat.Prime (N - a * p₃) then 1 else 0) ≀ 3.9404 * 1 * ↑N / Real.log ↑N ^ 2 + C * ↑N / Real.log ↑N ^ 10

        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

            6.5a. Ingredients for divisor_sum_bound #

            Weight f(d) = A^{Ο‰(d)}/Ο†(d), with f(0) = 0.

            Equations
            Instances For

              The real-valued zeta arithmetic function: 1 on positive integers, 0 at zero.

              Equations
              Instances For

                6.5. Lemma 2 (divisor-sum bound) #

                theorem MathlibNt.SieveTheory.SelbergUpperBound.divisor_sum_bound (A : ℝ) (hA : 0 < A) :
                βˆƒ (C : ℝ), βˆ€ (n : β„•), 1 ≀ n β†’ βˆ‘ d ∈ n.divisors, A ^ d.primeFactors.card / ↑d.totient ≀ C * Real.log (Real.log (3 * ↑n)) ^ A

                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₁.

                theorem MathlibNt.SieveTheory.SelbergUpperBound.divisor_sum_bound_mu2 (A : ℝ) (hA : 0 < A) :
                βˆƒ (C : ℝ), βˆ€ (n : β„•), 1 ≀ n β†’ βˆ‘ d ∈ n.divisors, ↑(ArithmeticFunction.moebius d) ^ 2 * (A ^ d.primeFactors.card / ↑d.totient) ≀ C * Real.log (Real.log (3 * ↑n)) ^ A

                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
                Instances For
                  theorem MathlibNt.SieveTheory.SelbergUpperBound.divisor_sum_bound_squarefree (A : ℝ) (hA : 0 < A) :
                  βˆƒ (C : ℝ), βˆ€ (n y : β„•), 1 ≀ n β†’ Squarefree n β†’ (βˆ€ (p : β„•), Nat.Prime p β†’ p ∣ n β†’ p ≀ y) β†’ 3 ≀ y β†’ βˆ‘ d ∈ n.divisors, A ^ d.primeFactors.card / ↑d.totient ≀ C * Real.log ↑y ^ A

                  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:

                  1. The weight f(d) = A^{Ο‰(d)}/Ο†(d) is multiplicative, so prodPrimeFactors_one_add_of_squarefree gives Ξ£_{d|n} f(d) = ∏_{p|n}(1 + f p).
                  2. At a prime p, f p = A/(p-1), hence ∏{p|n}(1 + A/(p-1)) ≀ exp(AΒ·Ξ£{p|n} 1/(p-1)).
                  3. Mertens' theorem (prime_inv_pminus1_bound) gives Ξ£_{p|n} 1/(p-1) ≀ Ξ£_{p≀y} 1/(p-1) ≀ log(log y) + C.
                  4. 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.

                  theorem MathlibNt.SieveTheory.SelbergUpperBound.divisor_sum_3_omega_bound (N : β„•) (Ξ΅ : ℝ) (hΞ΅ : 0 < Ξ΅) (hN : 3 ≀ N) :
                  βˆƒ (C : ℝ), βˆ‘ d ∈ (selbergQ N Ξ΅).divisors, 3 ^ d.primeFactors.card / ↑d.totient ≀ C * Real.log ↑N ^ 3

                  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) #

                  theorem MathlibNt.SieveTheory.SelbergUpperBound.coprime_condition_implies_bounded_ap (N a d : β„•) (_hN : 2 ≀ N) (ha : 1 ≀ a) (_hd : 1 ≀ d) (h_not_coprime : 1 < a.gcd d) :

                  (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.

                  theorem MathlibNt.SieveTheory.SelbergUpperBound.prime_divisor_recip_sum_bounded_real (N : β„•) (Ξ΅ : ℝ) (hΞ΅ : 0 < Ξ΅) (hN8 : 8 ≀ N) :
                  βˆƒ (Cβ‚€ : ℝ), 0 ≀ Cβ‚€ ∧ βˆ€ (d : β„•), d ∣ selbergQ N Ξ΅ β†’ βˆ‘ p₁ ∈ d.primeFactors with ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3), 1 / ↑p₁ ≀ Cβ‚€

                  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.

                  theorem MathlibNt.SieveTheory.SelbergUpperBound.r1_upper_bound (N : β„•) (Ξ΅ : ℝ) (hΞ΅ : 0 < Ξ΅) (hN : βˆƒ (Nβ‚€ : β„•), Nβ‚€ ≀ N) :
                  βˆƒ (C : ℝ), βˆ‘ d ∈ (selbergQ N Ξ΅).divisors, 3 ^ d.primeFactors.card / ↑d.totient * βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ ∧ 1 < a.gcd d then 1 else 0) * logarithmicIntegral_approx_term (↑N / ↑a) ≀ C * Real.log ↑N ^ 3 * ↑N

                  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.

                  theorem MathlibNt.SieveTheory.SelbergUpperBound.r1_simplified_bound (N : β„•) (Ξ΅ : ℝ) (_hΞ΅ : 0 < Ξ΅) (hN : 2 ≀ N) :
                  βˆƒ (C : ℝ), βˆ‘ d ∈ (selbergQ N Ξ΅).divisors, 3 ^ d.primeFactors.card / ↑d.totient * βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ ∧ 1 < a.gcd d then 1 else 0) * logarithmicIntegral_approx_term (↑N / ↑a) ≀ C * ↑N ^ (9 / 10) * Real.log ↑N ^ 2

                  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.

                  theorem MathlibNt.SieveTheory.SelbergUpperBound.complete_error_bound_corrected (N : β„•) (Ξ΅ A : ℝ) (_hΞ΅ : 0 < Ξ΅) (_hA : 0 < A) (hN : 2 ≀ N) :
                  βˆƒ (C : ℝ), βˆ‘ d ∈ (selbergQ N Ξ΅).divisors, 3 ^ d.primeFactors.card * βˆ‘ a ∈ Finset.range (N + 1), (if βˆƒ (p₁ : β„•) (pβ‚‚ : β„•), Nat.Prime p₁ ∧ Nat.Prime pβ‚‚ ∧ ↑N ^ (1 / 10) < ↑p₁ ∧ ↑p₁ ≀ ↑N ^ (1 / 3) ∧ ↑N ^ (1 / 3) < ↑pβ‚‚ ∧ ↑pβ‚‚ ≀ (↑N / ↑p₁) ^ (1 / 2) ∧ a = p₁ * pβ‚‚ then 1 else 0) * (↑(primesInAP N d (N % d)) - logarithmicIntegral_approx_term (↑N / ↑a) / ↑d.totient) ≀ C * ↑N / Real.log ↑N ^ A

                  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.

                  8. Mathematical scope #