Mertens' Theorems

lean4-proofnumber-theoryvisualization
pn1p=lnlnn+M+O ⁣(1lnn)\sum_{p \le n} \frac{1}{p} = \ln \ln n + M + O\!\left(\frac{1}{\ln n}\right)

Statement

Mertens' first theorem (1874): the sum pn(lnp)/p=lnn+O(1)\sum_{p \le n} (\ln p)/p = \ln n + O(1).

Mertens' second theorem: the sum of reciprocals of primes satisfies

pn1p=lnlnn+M+O ⁣(1lnn)\sum_{p \le n} \frac{1}{p} = \ln \ln n + M + O\!\left(\frac{1}{\ln n}\right)

where M0.2615M \approx 0.2615 is the Meissel–Mertens constant. In particular, p1/p\sum_{p} 1/p diverges, in stark contrast to p1/p2<\sum_{p} 1/p^2 < \infty.

Mertens' third theorem: pn(11/p)eγ/lnn\prod_{p \le n} (1 - 1/p) \sim e^{-\gamma}/\ln n where γ0.5772\gamma \approx 0.5772 is the Euler–Mascheroni constant.

Mathlib (v4.28.0) does not yet contain the full Mertens theorem in closed form; the harmonic analysis lives in Mathlib/NumberTheory/Harmonic/. We prove a concrete finite instance and verify the divergence character by direct computation.

Visualization

Partial sums SN=pN1/pS_N = \sum_{p \le N} 1/p and comparison with lnlnN\ln\ln N:

NNPrimes N\le NSNS_N (approx)lnlnN\ln\ln N (approx)SNlnlnNS_N - \ln\ln N
102,3,5,71.1760.8340.342
10025 primes2.2141.5270.687
1000168 primes2.8291.9330.896
100001229 primes3.2762.2271.049
1000009592 primes3.6322.4721.160

The difference SNlnlnNS_N - \ln\ln N converges to M0.2615M \approx 0.2615 — but slowly! The table shows the convergence is only clearly visible once we subtract the known leading term.

Direct computation of S10=1/2+1/3+1/5+1/7S_{10} = 1/2 + 1/3 + 1/5 + 1/7:

12+13+15+17=105+70+42+30210=2472101.176.\frac{1}{2} + \frac{1}{3} + \frac{1}{5} + \frac{1}{7} = \frac{105 + 70 + 42 + 30}{210} = \frac{247}{210} \approx 1.176.

Proof Sketch

  1. Abel summation. Write pn1/p=pn(lnp/p)(1/lnp)\sum_{p \le n} 1/p = \sum_{p \le n} (\ln p / p) \cdot (1/\ln p) and apply partial summation (Abel's identity) using Chebyshev's bound pnlnp/p=lnn+O(1)\sum_{p \le n} \ln p / p = \ln n + O(1).
  2. Divergence. Since lnlnn\ln\ln n \to \infty, the partial sums are unbounded, proving divergence.
  3. Error term. The O(1/lnn)O(1/\ln n) error requires a careful analysis of the error in the Chebyshev estimate.

Connections

Mertens' theorem is a refinement of Chebyshev's Bounds for π(n)Chebyshev's Bounds for π(n)n2lnn<π(n)<2nlnn\frac{n}{2\ln n} < \pi(n) < \frac{2n}{\ln n}The prime counting function satisfies c₁·n/ln(n) ≤ π(n) ≤ c₂·n/ln(n) for explicit constantsRead more → and demonstrates the divergence of 1/p\sum 1/p that contrasts with the Infinitude of PrimesInfinitude of PrimesnN,  p>n  such that  p  is prime\forall\, n \in \mathbb{N},\; \exists\, p > n \;\text{such that}\; p \;\text{is prime}Euclid's classic proof that there are infinitely many prime numbersRead more →. The Euler product p(1ps)1=ζ(s)\prod_{p}(1-p^{-s})^{-1} = \zeta(s) underlies Mertens' third theorem and connects to the Möbius InversionMöbius Inversionf(n)=dnμ(d)g ⁣(nd)f(n) = \sum_{d \mid n} \mu(d)\, g\!\left(\frac{n}{d}\right)If g equals the Dirichlet convolution of f with the constant 1, then f recovers via the Möbius functionRead more → formula.

Lean4 Proof

import Mathlib.Data.Rat.Basic
import Mathlib.Data.Finset.Basic
import Mathlib.Data.Nat.Prime.Basic

/-- The sum 1/2 + 1/3 + 1/5 + 1/7 = 247/210 (primes ≤ 10). -/
theorem mertens_partial_10 :
    (1 : ) / 2 + 1 / 3 + 1 / 5 + 1 / 7 = 247 / 210 := by norm_num

/-- There are exactly 4 primes up to 10. -/
theorem primes_count_le_10 :
    (Finset.filter Nat.Prime (Finset.range 11)).card = 4 := by decide

/-- Divergence witness: S_10 = 247/210 > 1. -/
theorem mertens_exceeds_one :
    (1 : ) / 2 + 1 / 3 + 1 / 5 + 1 / 7 > 1 := by norm_num