Skip to content

Commit 4cd3a90

Browse files
committed
feat(NumberTheory/Fermat): Fermat numbers (#17000)
Co-authored-by: Moritz Firsching <firsching@google.com>
1 parent 7f9e70c commit 4cd3a90

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,6 +3450,7 @@ import Mathlib.NumberTheory.FLT.Basic
34503450
import Mathlib.NumberTheory.FLT.Four
34513451
import Mathlib.NumberTheory.FLT.Three
34523452
import Mathlib.NumberTheory.FactorisationProperties
3453+
import Mathlib.NumberTheory.Fermat
34533454
import Mathlib.NumberTheory.FermatPsp
34543455
import Mathlib.NumberTheory.FrobeniusNumber
34553456
import Mathlib.NumberTheory.FunctionField

Mathlib/NumberTheory/Fermat.lean

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/-
2+
Copyright (c) 2024 Moritz Firsching. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Moritz Firsching
5+
-/
6+
import Mathlib.Algebra.BigOperators.Group.Finset
7+
import Mathlib.Algebra.Order.Ring.Basic
8+
import Mathlib.Algebra.Order.Star.Basic
9+
import Mathlib.Data.Nat.Prime.Defs
10+
import Mathlib.Tactic.Ring.RingNF
11+
12+
/-!
13+
# Fermat numbers
14+
15+
The Fermat numbers are a sequence of natural numbers defined as `fermat n = 2^(2^n) + 1`, for all
16+
natural numbers `n`.
17+
18+
## Main theorems
19+
20+
- `coprime_fermat_fermat`: two distinct Fermat numbers are coprime.
21+
-/
22+
23+
open Nat Finset
24+
open scoped BigOperators
25+
26+
/-- Fermat numbers: the `n`-th Fermat number is defined as `2^(2^n) + 1`. -/
27+
def fermat (n : ℕ) : ℕ := 2 ^ (2 ^ n) + 1
28+
29+
@[simp] theorem fermat_zero : fermat 0 = 3 := rfl
30+
@[simp] theorem fermat_one : fermat 1 = 5 := rfl
31+
@[simp] theorem fermat_two : fermat 2 = 17 := rfl
32+
33+
theorem strictMono_fermat : StrictMono fermat := by
34+
intro m n
35+
simp only [fermat, add_lt_add_iff_right, pow_lt_pow_iff_right (one_lt_two : 1 < 2), imp_self]
36+
37+
theorem two_lt_fermat (n : ℕ) : 2 < fermat n := by
38+
cases n
39+
· simp
40+
· exact lt_of_succ_lt <| strictMono_fermat <| zero_lt_succ _
41+
42+
theorem odd_fermat (n : ℕ) : Odd (fermat n) :=
43+
(even_pow.mpr ⟨even_two, (pow_pos two_pos n).ne'⟩).add_one
44+
45+
theorem fermat_product (n : ℕ) : ∏ k in range n, fermat k = fermat n - 2 := by
46+
induction' n with n hn
47+
· rfl
48+
rw [prod_range_succ, hn, fermat, fermat, mul_comm,
49+
(show 2 ^ 2 ^ n + 1 - 2 = 2 ^ 2 ^ n - 1 by omega), ← sq_sub_sq]
50+
ring_nf
51+
omega
52+
53+
theorem fermat_eq_prod_add_two (n : ℕ) : fermat n = (∏ k in range n, fermat k) + 2 := by
54+
rw [fermat_product, Nat.sub_add_cancel]
55+
exact le_of_lt <| two_lt_fermat _
56+
57+
/--
58+
**Goldbach's theorem** : no two distinct Fermat numbers share a common factor greater than one.
59+
60+
From a letter to Euler, see page 37 in [juskevic2022].
61+
-/
62+
theorem coprime_fermat_fermat {k n : ℕ} (h : k ≠ n) : Coprime (fermat n) (fermat k) := by
63+
wlog hkn : k < n
64+
· simpa only [coprime_comm] using this h.symm (by omega)
65+
let m := (fermat n).gcd (fermat k)
66+
have h_n : m ∣ fermat n := (fermat n).gcd_dvd_left (fermat k)
67+
have h_m : m ∣ 2 := (Nat.dvd_add_right <| (gcd_dvd_right _ _).trans <| dvd_prod_of_mem _
68+
<| mem_range.mpr hkn).mp <| fermat_eq_prod_add_two _ ▸ h_n
69+
refine ((dvd_prime prime_two).mp h_m).elim id (fun h_two ↦ ?_)
70+
exact ((odd_fermat _).not_two_dvd_nat (h_two ▸ h_n)).elim

docs/references.bib

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,14 @@ @Article{ Joyce1982
20882088
publisher = {Elsevier {BV}}
20892089
}
20902090

2091+
@Book{ juskevic2022,
2092+
author = {Ju{\v{s}}kevi{\v{c}}, Adolf P and Winter, Eduard},
2093+
title = {Leonhard Euler und Christian Goldbach: Briefwechsel
2094+
1729--1764},
2095+
year = {2022},
2096+
publisher = {Walter de Gruyter GmbH \& Co KG}
2097+
}
2098+
20912099
@Article{ KahnMaltsiniotis2008,
20922100
author = {Kahn, Bruno and Maltsiniotis, Georges},
20932101
title = {Structures de d\'{e}rivabilit\'{e}},

0 commit comments

Comments
 (0)