Documentation

Mathlib.NumberTheory.PrimeCounting

The Prime Counting Function #

In this file we define the prime counting function: the function on natural numbers that returns the number of primes less than or equal to its input.

Main Results #

The main definitions for this file are

We then prove that these are monotone in Nat.monotone_primeCounting and Nat.monotone_primeCounting'. The last main theorem Nat.primeCounting'_add_le is an upper bound on π' which arises by observing that all numbers greater than k and not coprime to k are not prime, and so only at most φ(k)/k fraction of the numbers from k to n are prime.

Notation #

With open scoped Nat.Prime, we use the standard notation π to represent the prime counting function (and π' to represent the reindexed version).

def Nat.primeCounting' :

A variant of the traditional prime counting function which gives the number of primes strictly less than the input. More convenient for avoiding off-by-one errors.

With open scoped Nat.Prime, this has notation π'.

Instances For
    def Nat.primeCounting (n : ) :

    The prime counting function: Returns the number of primes less than or equal to the input.

    With open scoped Nat.Prime, this has notation π.

    Instances For
      def Nat.Prime.termπ :
      Lean.ParserDescr

      The prime counting function: Returns the number of primes less than or equal to the input.

      With open scoped Nat.Prime, this has notation π.

      Instances For
        def Nat.Prime.termπ' :
        Lean.ParserDescr

        A variant of the traditional prime counting function which gives the number of primes strictly less than the input. More convenient for avoiding off-by-one errors.

        With open scoped Nat.Prime, this has notation π'.

        Instances For
          theorem Nat.add_two_le_nth_prime (n : ) :
          n + 2 nth Prime n

          The nth prime is greater or equal to n + 2.

          @[simp]
          theorem Nat.prime_nth_prime (n : ) :
          @[simp]
          theorem Nat.primeCounting'_eq_zero_iff {n : } :
          n.primeCounting' = 0 n 2
          @[simp]
          theorem Nat.primeCounting_eq_zero_iff {n : } :
          n.primeCounting = 0 n 1

          The cardinality of the finset primesBelow n equals the counting function primeCounting' at n.

          theorem Nat.primeCounting'_add_le {a k : } (h0 : a 0) (h1 : a < k) (n : ) :
          (k + n).primeCounting' k.primeCounting' + a.totient * (n / a + 1)

          A linear upper bound on the size of the primeCounting' function