cs.CC — Computational Complexity
Exact prime counting and deterministic prime finding in time
We prove that the exact sum of the primes up to , the exact prime count and, for , a prime in can each be computed by a deterministic Turing machine in steps, where is the bit length of . For all three problems the best bounds known so far were ; for this exponent has stood since the analytic method of Lagarias and Odlyzko in 1987. In particular, whether a given interval in contains a prime can be decided in time . This establishes, in a much stronger form, a conjecture of the Polymath4 project, which asked for time for some and for intervals of length at most . The theorems are obtained by reducing the three problems to the subexponential counting algorithm behind the recent refutation of the Exponential Time Hypothesis; they are asymptotic statements, not practical algorithms. The reduction rests on an analytic idea: Ramanujan sums express the M\"obius function without factoring, and a Cauchy-kernel quadrature turns the phases, the logarithm and its reciprocal into short linear combinations of rational functions, which a counting network of linear size can evaluate. All three theorems, together with the counting algorithm they rely on, are formally verified in Lean~4 against a specification that imports only Mathlib.