Documentation

Mathlib.NumberTheory.Fermat

Fermat numbers #

The Fermat numbers are a sequence of natural numbers defined as Nat.fermatNumber n = 2^(2^n) + 1, for all natural numbers n.

Main theorems #

Fermat numbers: the n-th Fermat number is defined as 2^(2^n) + 1.

Equations
  • n.fermatNumber = 2 ^ 2 ^ n + 1
Instances For
    @[deprecated Nat.fermatNumber_strictMono]

    Alias of Nat.fermatNumber_strictMono.

    theorem Nat.three_le_fermatNumber (n : ) :
    3 n.fermatNumber
    theorem Nat.two_lt_fermatNumber (n : ) :
    2 < n.fermatNumber
    theorem Nat.fermatNumber_ne_one (n : ) :
    n.fermatNumber 1
    theorem Nat.odd_fermatNumber (n : ) :
    Odd n.fermatNumber
    theorem Nat.prod_fermatNumber (n : ) :
    kFinset.range n, k.fermatNumber = n.fermatNumber - 2
    @[deprecated Nat.prod_fermatNumber]
    theorem Nat.fermatNumber_product (n : ) :
    kFinset.range n, k.fermatNumber = n.fermatNumber - 2

    Alias of Nat.prod_fermatNumber.

    theorem Nat.fermatNumber_eq_prod_add_two (n : ) :
    n.fermatNumber = kFinset.range n, k.fermatNumber + 2
    theorem Nat.fermatNumber_succ (n : ) :
    (n + 1).fermatNumber = (n.fermatNumber - 1) ^ 2 + 1
    theorem Nat.two_mul_fermatNumber_sub_one_sq_le_fermatNumber_sq (n : ) :
    2 * (n.fermatNumber - 1) ^ 2 (n + 1).fermatNumber ^ 2
    theorem Nat.fermatNumber_eq_fermatNumber_sq_sub_two_mul_fermatNumber_sub_one_sq (n : ) :
    (n + 2).fermatNumber = (n + 1).fermatNumber ^ 2 - 2 * (n.fermatNumber - 1) ^ 2
    theorem Int.fermatNumber_eq_fermatNumber_sq_sub_two_mul_fermatNumber_sub_one_sq (n : ) :
    (n + 2).fermatNumber = (n + 1).fermatNumber ^ 2 - 2 * (n.fermatNumber - 1) ^ 2
    theorem Nat.coprime_fermatNumber_fermatNumber {m n : } (hmn : m n) :
    m.fermatNumber.Coprime n.fermatNumber

    Goldbach's theorem : no two distinct Fermat numbers share a common factor greater than one.

    From a letter to Euler, see page 37 in [JW22].

    theorem Nat.pairwise_coprime_fermatNumber :
    Pairwise fun (m n : ) => m.fermatNumber.Coprime n.fermatNumber
    theorem Nat.pow_of_pow_add_prime {a n : } (ha : 1 < a) (hn : n 0) (hP : Nat.Prime (a ^ n + 1)) :
    ∃ (m : ), n = 2 ^ m

    Prime a ^ n + 1 implies n is a power of two (Fermat primes).

    theorem Nat.pepin_primality (n : ) (h : 3 ^ 2 ^ (2 ^ n - 1) = -1) :
    Nat.Prime n.fermatNumber

    Fₙ = 2^(2^n)+1 is prime if 3^(2^(2^n-1)) = -1 mod Fₙ (Pépin's test).

    theorem Nat.pepin_primality' (n : ) (h : 3 ^ ((n.fermatNumber - 1) / 2) = -1) :
    Nat.Prime n.fermatNumber

    Fₙ = 2^(2^n)+1 is prime if 3^((Fₙ - 1)/2) = -1 mod Fₙ (Pépin's test).

    theorem Nat.pow_pow_add_primeFactors_one_lt {a n p : } (hp : Nat.Prime p) (hp2 : p 2) (hpdvd : p a ^ 2 ^ n + 1) :
    ∃ (k : ), p = k * 2 ^ (n + 1) + 1

    Prime factors of a ^ (2 ^ n) + 1 are of form k * 2 ^ (n + 1) + 1.

    theorem Nat.fermat_primeFactors_one_lt (n p : ) (hn : 1 < n) (hp : Nat.Prime p) (hpdvd : p n.fermatNumber) :
    ∃ (k : ), p = k * 2 ^ (n + 2) + 1

    Primality of Mersenne numbers Mₙ = a ^ n - 1 #

    theorem Nat.prime_of_pow_sub_one_prime {a n : } (hn1 : n 1) (hP : Nat.Prime (a ^ n - 1)) :

    Prime a ^ n - 1 implies a = 2 and prime n.