Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The Siegel–Walfisz theorem for arithmetic progressions (Davenport §22)

Proved
Davenport.siegel_walfisz_ap

by alya · Sep 3, 2026 · Mathlib c5ea003 (Lean v4.30.0)

analytic-number-theorydirichlet-l-functionnumber-theorysiegel-walfiszthree-primes

The Siegel–Walfisz theorem, progression form (Davenport §22). For any fixed A>0A>0A>0 there are constants c,C>0c,C>0c,C>0 such that for all N≥2N\ge2N≥2, all moduli 1≤q≤(log⁡N)A1\le q\le(\log N)^A1≤q≤(logN)A and all aaa with gcd⁡(a,q)=1\gcd(a,q)=1gcd(a,q)=1,

∣ψ(N;q,a)−Nφ(q)∣  ≤  C Nexp⁡(−clog⁡N),ψ(N;q,a)=∑n<Nn≡a (q)Λ(n),\Bigl|\psi(N;q,a)-\frac{N}{\varphi(q)}\Bigr|\;\le\;C\,N\exp\bigl(-c\sqrt{\log N}\bigr),\qquad \psi(N;q,a)=\sum_{\substack{n<N\\ n\equiv a\ (q)}}\Lambda(n),​ψ(N;q,a)−φ(q)N​​≤CNexp(−clogN​),ψ(N;q,a)=n<Nn≡a (q)​∑​Λ(n),

i.e. ψ(x;q,a)=x/φ(q)+O(xexp⁡(−CA(log⁡x)1/2))\psi(x;q,a)=x/\varphi(q)+O\bigl(x\exp(-C_A(\log x)^{1/2})\bigr)ψ(x;q,a)=x/φ(q)+O(xexp(−CA​(logx)1/2)) uniformly for q≤(log⁡x)Aq\le(\log x)^Aq≤(logx)A. It follows from the character form by orthogonality of characters, ψ(N;q,a)=φ(q)−1∑χχ‾(a)ψ(N,χ)\psi(N;q,a)=\varphi(q)^{-1}\sum_{\chi}\overline{\chi}(a)\psi(N,\chi)ψ(N;q,a)=φ(q)−1∑χ​χ​(a)ψ(N,χ). The constants are ineffective.

Preamble
import Definitions.Def_Davenport_siegelWalfisz
import Mathlib.NumberTheory.LSeries.DirichletContinuation
import Mathlib.NumberTheory.DirichletCharacter.Basic
import Mathlib.NumberTheory.ArithmeticFunction.VonMangoldt
import Mathlib.NumberTheory.Chebyshev
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
import Mathlib.Analysis.SpecialFunctions.Log.Basic
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Analysis.SpecialFunctions.Sqrt
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Data.Nat.Totient

open Finset DirichletCharacter Vino
Formal statement
namespace Davenport

theorem siegel_walfisz_ap (A : ℝ) (hA : 0 < A) :
    ∃ c C : ℝ, 0 < c ∧ 0 < C ∧
      ∀ (N q a : ℕ), 2 ≤ N → 1 ≤ q → (q : ℝ) ≤ Real.log N ^ A → Nat.Coprime a q →
        |psiAP N q a - (N : ℝ) / (Nat.totient q : ℝ)|
          ≤ C * N * Real.exp (-c * Real.sqrt (Real.log N)) := by sorry

end Davenport
Source
H. Davenport, Multiplicative Number Theory, 3rd ed. (revised by H. L. Montgomery), GTM 74, Springer, 2000, https://doi.org/10.1007/978-1-4757-5927-3; §22 (The prime number theorem for arithmetic progressions (II)), pp. 132–134: ψ(x;q,a) = x/φ(q) + O(x exp(−C_N (log x)^{1/2})) uniformly for q ≤ (log x)^N, (a,q) = 1
Read-back

What the Lean code literally says, in plain math · claude-opus-4-8

Read-back: Davenport.siegel_walfisz_ap

Statement. For every real number AAA satisfying A>0A > 0A>0, there exist real numbers ccc and CCC with c>0c > 0c>0 and C>0C > 0C>0, such that for all natural numbers NNN, qqq, aaa satisfying the four hypotheses

  • N≥2N \ge 2N≥2,
  • q≥1q \ge 1q≥1,
  • q≤(log⁡N)Aq \le (\log N)^{A}q≤(logN)A (the natural number qqq cast to a real, compared against the real power (log⁡N)A(\log N)^{A}(logN)A, i.e. exp⁡(Alog⁡log⁡N)\exp(A \log \log N)exp(AloglogN) when log⁡N>0\log N > 0logN>0),
  • gcd⁡(a,q)=1\gcd(a, q) = 1gcd(a,q)=1,

the following inequality holds:

∣Ψ(N;q,a)−Nφ(q)∣  ≤  C⋅N⋅exp⁡ ⁣(−clog⁡N),\left| \Psi(N; q, a) - \frac{N}{\varphi(q)} \right| \;\le\; C \cdot N \cdot \exp\!\left(-c \sqrt{\log N}\right),​Ψ(N;q,a)−φ(q)N​​≤C⋅N⋅exp(−clogN​),

where φ\varphiφ is Euler's totient function and Ψ(N;q,a)\Psi(N; q, a)Ψ(N;q,a) denotes the quantity written psiAP N q a in the code, which unfolds to

Ψ(N;q,a)  =  ∑n=0N−1{Λ(n)if n≡a(modq)0otherwise,\Psi(N; q, a) \;=\; \sum_{n = 0}^{N-1} \begin{cases} \Lambda(n) & \text{if } n \equiv a \pmod{q} \\ 0 & \text{otherwise,}\end{cases}Ψ(N;q,a)=n=0∑N−1​{Λ(n)0​if n≡a(modq)otherwise,​

i.e. the sum of the von Mangoldt function Λ\LambdaΛ over those nnn in the index range {0,1,…,N−1}\{0, 1, \dots, N-1\}{0,1,…,N−1} whose residue class modulo qqq equals that of aaa. Here Λ(n)=log⁡p\Lambda(n) = \log pΛ(n)=logp when n=pkn = p^{k}n=pk for a prime ppp and an integer k≥1k \ge 1k≥1, and Λ(n)=0\Lambda(n) = 0Λ(n)=0 otherwise; in particular Λ(0)=Λ(1)=0\Lambda(0) = \Lambda(1) = 0Λ(0)=Λ(1)=0, so the terms n=0n = 0n=0 and n=1n = 1n=1 contribute nothing even when they satisfy the congruence. All arithmetic in the displayed inequality is over the reals: Λ(n)\Lambda(n)Λ(n), NNN, and φ(q)\varphi(q)φ(q) are cast to real numbers, log⁡\loglog is the real natural logarithm, ⋅\sqrt{\cdot}⋅​ the real square root, exp⁡\expexp the real exponential, and ∣⋅∣|\cdot|∣⋅∣ the real absolute value.

Quantifier order. The order is: AAA first, then ccc and CCC (which may therefore depend on AAA but on nothing else), then NNN, qqq, aaa. Thus ccc and CCC are uniform in NNN, qqq, and aaa simultaneously: a single pair (c,C)(c, C)(c,C) must work for every admissible triple. The statement asserts only the existence of such a pair; it gives no formula for, or bound on, ccc or CCC, and does not claim any relation between them.

Range and endpoint conventions. The summation index runs over 0≤n<N0 \le n < N0≤n<N; the endpoint n=Nn = Nn=N is excluded. The main term subtracted is N/φ(q)N / \varphi(q)N/φ(q) with the full NNN in the numerator (not N−1N - 1N−1, and not a count of the summation range), and it is divided by φ(q)\varphi(q)φ(q) rather than by anything involving NNN or aaa.

Degenerate and edge cases silently included.

  • q=0q = 0q=0 is excluded by the hypothesis q≥1q \ge 1q≥1, so the division by φ(q)\varphi(q)φ(q) is never a division by φ(0)=0\varphi(0) = 0φ(0)=0; for q≥1q \ge 1q≥1 one has φ(q)≥1\varphi(q) \ge 1φ(q)≥1.
  • q=1q = 1q=1 is permitted. Then the ring Z/1Z\mathbb{Z}/1\mathbb{Z}Z/1Z is trivial, so the congruence condition n≡a(mod1)n \equiv a \pmod{1}n≡a(mod1) holds for every nnn, and Ψ(N;1,a)\Psi(N; 1, a)Ψ(N;1,a) is the full Chebyshev-type sum ∑n<NΛ(n)\sum_{n < N} \Lambda(n)∑n<N​Λ(n); also φ(1)=1\varphi(1) = 1φ(1)=1, so the main term is NNN, and gcd⁡(a,1)=1\gcd(a,1) = 1gcd(a,1)=1 holds for every aaa including a=0a = 0a=0.
  • No hypothesis requires a<qa < qa<q; aaa is an arbitrary natural number and only its residue class modulo qqq matters. Large values of aaa (including a≥qa \ge qa≥q, or aaa arbitrarily larger than NNN) are covered, as is a=0a = 0a=0 — though gcd⁡(0,q)=q\gcd(0, q) = qgcd(0,q)=q, so a=0a = 0a=0 is admissible only when q=1q = 1q=1.
  • No hypothesis relates qqq to NNN beyond q≤(log⁡N)Aq \le (\log N)^{A}q≤(logN)A; in particular there is no assumption q≤Nq \le Nq≤N or q<Nq < Nq<N beyond what that inequality forces, and no lower bound on NNN other than N≥2N \ge 2N≥2.
  • The hypotheses q≥1q \ge 1q≥1 and q≤(log⁡N)Aq \le (\log N)^{A}q≤(logN)A together force (log⁡N)A≥1(\log N)^{A} \ge 1(logN)A≥1, hence (as A>0A > 0A>0) log⁡N≥1\log N \ge 1logN≥1, i.e. N≥eN \ge eN≥e, i.e. N≥3N \ge 3N≥3. Consequently the case N=2N = 2N=2 — although admitted by the hypothesis N≥2N \ge 2N≥2 — is vacuous: no qqq satisfies both remaining constraints, so the theorem asserts nothing for N=2N = 2N=2. For all N≥2N \ge 2N≥2 one has log⁡N>0\log N > 0logN>0, so (log⁡N)A(\log N)^{A}(logN)A is the ordinary positive real power and log⁡N\sqrt{\log N}logN​ is a genuine (positive) square root rather than the value x=0\sqrt{x} = 0x​=0 that the total square-root function returns on negative inputs.
  • Nothing is asserted for pairs (N,q)(N, q)(N,q) with q>(log⁡N)Aq > (\log N)^{A}q>(logN)A: the range of moduli covered grows only like a fixed power of log⁡N\log NlogN, with the power AAA fixed before ccc and CCC are chosen.
  • The inequality is non-strict (≤\le≤) on both the modulus bound q≤(log⁡N)Aq \le (\log N)^{A}q≤(logN)A and the conclusion.

What is not said. The statement contains no reference to Dirichlet characters, LLL-functions, exceptional zeros, or any of the other definitions in the surrounding bundle; it is purely the displayed inequality on Ψ(N;q,a)\Psi(N; q, a)Ψ(N;q,a). It is an existence claim over c,Cc, Cc,C only, with no effectivity, no uniformity in AAA, and no assertion about the sharpness of the exponent log⁡N\sqrt{\log N}logN​.

Human review
  • Endorsed by Shuze Chen · Sep 3, 2026

  • Endorsed by alya · Sep 3, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me