Exact prime counting and deterministic prime finding in time
Version 1 / Dec 01, 2026 / CC BY 4.0
Abstract
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.
Provenance statement
Tools used
- OpenAI
- CodexVersion 6 Astra
- Anthropic
- Claude FableVersion 5.2
References
- Anthropic, A time algorithm for 3-SAT , Hexagon 2610.00577 (2026); Lean formalization at https://github.com/anthropics/formal-math.link
- M. Agrawal, N. Kayal and N. Saxena, PRIMES is in P , Ann. of Math. (2) 160 (2004), 781--793.
- R. C. Baker, G. Harman and J. Pintz, The difference between consecutive primes, II , Proc. London Math. Soc. (3) 83 (2001), 532--562.
- L. Chen, Z. Lu, I. C. Oliveira, H. Ren and R. Santhanam, Polynomial-time pseudodeterministic construction of primes , Proc.\ 64th IEEE Symposium on Foundations of Computer Science (FOCS 2023); arXiv:2305.15140.arXiv
- H. Cramér, On the order of magnitude of the difference between consecutive prime numbers , Acta Arith. 2 (1936), 23--46.
- M. Deléglise and J. Rivat, Computing : the Meissel, Lehmer, Lagarias, Miller, Odlyzko method , Math. Comp. 65 (1996), 235--245.
- D. Hirsch, I. Kessler and U. Mendlovic, Computing : an elementary approach in time , Math. Comp. 94 (2025), no. 356, 3043--3081; arXiv:2212.09857.arXiv
- H. A. Helfgott and L. Thompson, Summing : a faster elementary algorithm , Res. Number Theory 9 (2023), Paper No. 6.
- R. Impagliazzo and R. Paturi, On the complexity of -SAT , J. Comput. System Sci. 62 (2001), 367--375.
- D. H. Lehmer, On the exact number of primes less than a given limit , Illinois J. Math. 3 (1959), 381--388.
Show all 22 referencesShow fewer references
- J. C. Lagarias, V. S. Miller and A. M. Odlyzko, Computing : the Meissel--Lehmer method , Math. Comp. 44 (1985), 537--560.
- J. C. Lagarias and A. M. Odlyzko, Computing : an analytic method , J. Algorithms 8 (1987), 173--191.
- OpenAI, The Exponential Time Hypothesis is false , preprint (October 2026), https://github.com/openai/math.link
- I. C. Oliveira and R. Santhanam, Pseudodeterministic constructions in subexponential time , Proc.\ 49th ACM Symposium on Theory of Computing (STOC 2017), 665--677.
- T. Tao, (Research thread II) Deterministic way to find primes , The polymath blog, August 9, 2009, https://polymathprojects.org/2009/08/09/research-thread-ii-deterministic-way-to-find-primes/.link
- D. J. Platt, Computing analytically , Math. Comp. 84 (2015), 1521--1535.
- S. Ramanujan, On certain trigonometrical sums and their applications in the theory of numbers , Trans. Cambridge Philos. Soc. 22 (1918), 259--276.
- I. Rudich and L.-M. Rousseau, Deterministic factoring in time , Hexagon 2610.00600 (2026).
- T. Tao, E. Croot III and H. Helfgott, Deterministic methods to find primes , Math. Comp. 81 (2012), 1233--1246; arXiv:1009.3956, as D. H. J. Polymath.arXiv
- L. N. Trefethen and J. A. C. Weideman, The exponentially convergent trapezoidal rule , SIAM Rev. 56 (2014), 385--458.
- V. Tulsyan, The parity of the prime-counting function in time , Hexagon 2611.00116 (2026); Lean library at https://github.com/xennygrimmato/eth-hamiltonicity.link
- V. Tulsyan, What the ETH refutations do not give: barriers for the counting engines, with machine-checked lemmas , Hexagon 2611.00149 (2026).