<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Formalization of the prime number theorem and Dirichlet's theorem</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>(x) The latter expression is Metamath's notation for lim</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Mario Carneiro Pure and Applied Logic program Carnegie Mellon University</institution>
          ,
          <addr-line>Pittsburgh PA</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2016</year>
      </pub-date>
      <abstract>
        <p>We present the formalization of Dirichlet's theorem on the in nitude of primes in arithmetic progressions, and Selberg's elementary proof of the prime number theorem, which asserts that the number (x) of primes less than x is asymptotic to x= log x, within the proof system Metamath.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>N 2 N ^ A 2 Z ^ gcd(A; N ) = 1
! fp 2 P j N j(p
A)g</p>
      <p>N</p>
      <sec id="sec-1-1">
        <title>Theorem 2 (pnt, The prime number theorem).</title>
        <p>(x)
x 2 (1; 1) 7! x= log x</p>
        <p>These two theorems are interesting formalization targets as they both have simple statements and \deep"
proofs, and they are also both members of the \Formalizing 100 theorems" list maintained by Freek Wiedijk
[Wie16], which tracks formalizations of 100 of the most famous theorems in mathematics.</p>
        <p>Both proofs were written concurrently, over the course of about seven weeks between April 7 and June 1,
2016. This was done mostly because both theorems are in the same general subject (elementary number theory)
and required similar techniques (mostly asymptotic approximation of nite sums of reals). The primary informal
text used for the proof was Shapiro [Sha83], which devotes a section to Dirichlet's theorem and the whole nal
chapter to Selberg and Erd}os's proof of the prime number theorem.
2</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>Background</title>
      <p>The present work is only a broad overview of the problem and proof method. Interested readers are invited to
consult the main theorems pnt and dirith at [Met16], where the exact proof is discussed in detail.</p>
      <p>The main arithmetic functions used in the formalization are:
(x) = jfp 2 P j p
xgj =</p>
      <p>X 1
p x
(x) =</p>
      <p>X log p
p x
(n) =
(log p
0
9p 2 P; k &gt; 0 : n = pk
o:w:
(x) = X</p>
      <p>(n)
n x</p>
      <p>Additionally, the Mobius function (n) is a very useful tool in sum manipulations. It is the unique
multiplicative function such that (1) = 1 and Pdjn (d) = 0 for n &gt; 1. This yields the Mobius inversion formula: if
f (n) = Pdjn g(d), then g(n) = Pdjn (d)f (d). Since j (n)j 1, this is a very powerful technique for estimating
sums \by inversion".</p>
      <p>The proof of Hadamard and Vallee-Poussin relies on some deep theorems in complex analysis, such as Cauchy's
theorem, which were not available at the time of this formalization, so instead we targeted the \elementary"
proof discovered half a century later semi-independently by Erd}os and Selberg. The key step in both proofs is
the Selberg symmetry formula:</p>
      <sec id="sec-2-1">
        <title>Theorem 3 (selberg, Selberg symmetry formula). In Selberg's proof, we leverage this theorem to produce a bound on the residual R(x) = (x)</title>
        <p>x:
Theorem 4 (pntrlog2bnd).</p>
        <p>uv x
n x
X
n x
(n) log n + X</p>
        <p>(u) (v) = 2x log x + O(x):
jR(x)j log2 x</p>
        <p>2 X jR(x=n)j log n + O(x log x):</p>
        <p>The goal is to show (x) loxg x , but it is easily shown that (x) (x) (x) log x, so it is equivalent
to show that (x) x, or R(x)=x ! 0, to establish the PNT. Given an eventual bound jR(x)j ax and
the estimation Pn x long n = 12 log2 x + O( loxg x ), an application of Theorem 4 reproduces the original estimate
jR(x)j ax + o(x), but using improved bounds on R(x) on small intervals we can improve the estimate to
jR(x)j (a ca3)x + o(x) for a xed constant c, which produces a sequence of eventual bounds approaching
zero, which proves R(x)=x ! 0 as desired.</p>
        <p>In Dirichlet's theorem, the focal point is instead the Dirichlet characters modN , which are group
homomorphisms from (Z=N Z) to C , extended to Z=N Z with value 0 at non-units, but the general theme of estimation
of sums involving ; ; log and the characters (n) is the same.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Formalization</title>
      <p>In keeping with Metamath's tradition of minimal complexity, we used a minimum of de nition. Asymptotic
estimations are reduced to the class O(1) of eventually bounded functions, partial functions R ! C such that for
some c; A, x c implies jf (x)j A. An equation such as f 2 O(g) is rewritten as f =g 2 O(1) (which is correct
as long as g is eventually nonzero, which is always true in cases of interest), and similarly f 2 o(g) is rewritten
as f =g 0.</p>
      <p>A few nite summation theorems take us a long way; two number-theory speci c summation theorems are
the following divisor sum commutations:</p>
      <p>X X A(k; d) = X X A(dm; d)
kjn djk</p>
      <p>djn mjn=d
X X A(n; d) = X X</p>
      <p>A(dm; d)
n x djn</p>
      <p>d x m n=d</p>
      <p>A small amount of calculus was used in the proof, mostly through the following sum estimation theorem,
which for example evaluates Pn x long n = 12 log2 x + O( loxg x ):
Theorem 5 (dvfsumrlim). If F is a di erentiable function with F 0 = f , and f is a positive decreasing function
that converges to zero, then g(x) = Pn x f (n) F (x) converges to some L and jg(x) Lj f (x).
4</p>
    </sec>
    <sec id="sec-4">
      <title>Comparison and Conclusion</title>
      <p>The comparison of parallel proof attempts in di erent systems is usually confounded by the many other
factors, so these statistics should not be given undue credence. According to [Avi07], Avigad's PNT project was
a year-long project by four people, with the majority of the work happening during one summer, while this was
a solo project over about seven work weeks. Dirichlet's theorem is 10 pages of informal text of [Sha83], and the
PNT is 37 pages. Although the number of lines in the current proofs seem competitive, this is lost in the gzipped
version, because the stored Metamath proof is already largely compressed, while the Isabelle and HOL scripts
are plain text.</p>
      <p>The de Bruijn factors for this work had to be estimated because the TeX source for the informal text was not
available, but indications suggest that it fares poorly with comparatively large factors 19.9 and 7.67, respectively.
However, when reading these statistics it is important to realize that Metamath stores proofs, not proof scripts
like Isabelle and HOL. Every inference in the proof is an axiom or theorem of the system, and no proof searches
are conducted by the veri er. This is re ected in the incredibly small veri cation time, which is normal for
Metamath proofs. We do not have exact data on veri cation time for HOL Light, but it is believed to be on the
order of minutes to hours.</p>
      <p>These proofs are important milestones for the Metamath project. They demonstrate that even the largest
of formalization projects in high level languages can also be conducted in a \full transparency"-style system
like Metamath, with entirely worked-out proofs and with all automation o oaded from the veri er to the proof
generation.
[Dir37] Dirichlet, P. G. L.: Beweis des Satzes, dass jede unbegrenzte arithmetische Progression, deren erstes
Glied und Di erenz ganze Zahlen ohne gemeinschaftlichen Factor sind, unendlich viele Primzahlen
enthalt. Abhand. Ak. Wiss. Berlin 48, 313{342 (1837)
[Sha83] Shapiro, H.: Introduction to the theory of numbers. John Wiley &amp; Sons Inc., New York (1983)</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [Sel49]
          <string-name>
            <surname>Selberg</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>An elementary proof of the prime-number theorem</article-title>
          .
          <source>Ann. of Math. (2)</source>
          , Vol.
          <volume>50</volume>
          , pp.
          <volume>305</volume>
          {
          <issue>313</issue>
          ; reprinted in Atle Selberg Collected Papers, Springer{Verlag, Berlin Heidelberg New York,
          <year>1989</year>
          1,
          <issue>379</issue>
          {
          <fpage>387</fpage>
          (
          <year>1949</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [Erd49] Erd}os, P.:
          <article-title>On a new method in elementary number theory which leads to an elementary proof of the prime number theorem</article-title>
          .
          <source>Proc. Nat. Acad</source>
          . Scis. U.S.A.
          <volume>35</volume>
          ,
          <issue>374</issue>
          {
          <fpage>384</fpage>
          (
          <year>1949</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [Avi07]
          <string-name>
            <surname>Avigad</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Donnelly</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gray</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ra</surname>
            ,
            <given-names>P.:</given-names>
          </string-name>
          <article-title>A formally veri ed proof of the prime number theorem</article-title>
          .
          <source>ACM Trans. Comput. Logic</source>
          <volume>9</volume>
          (
          <issue>1</issue>
          :2),
          <volume>1</volume>
          {
          <fpage>23</fpage>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [Har09]
          <string-name>
            <surname>Harrison</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          :
          <article-title>Formalizing an analytic proof of the Prime Number Theorem (dedicated to Mike Gordon on the occasion of his 60th birthday)</article-title>
          .
          <source>Journal of Automated Reasoning</source>
          ,
          <volume>43</volume>
          :
          <fpage>243</fpage>
          {
          <fpage>261</fpage>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [Har10]
          <string-name>
            <surname>Harrison</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>A formalized proof of Dirichlet's theorem on primes in arithmetic progression</article-title>
          .
          <source>Journal of Formalized Reasoning</source>
          , [S.l.],
          <volume>2</volume>
          (
          <issue>1</issue>
          ),
          <volume>63</volume>
          {
          <fpage>83</fpage>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [Wie16]
          <string-name>
            <surname>Wiedijk</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          : Formalizing 100 Theorems, http://www.cs.ru.nl/~freek/100/ (accessed 20 May
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [Meg07]
          <string-name>
            <surname>Megill</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          :
          <article-title>Metamath: A Computer Language for Pure Mathematics</article-title>
          . Lulu Publishing, Morrisville, North Carolina (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>