Skip to content

Commit 93efefb

Browse files
riccardobrascadagurtomas
authored andcommitted
feat(Mathlib.NumberTheory.Cyclotomic.Three): add various results (#13798)
We add various results about the third cyclotomic field needed to prove flt3. From the flt3 project at LFTCM2024.
1 parent c7b106d commit 93efefb

File tree

6 files changed

+171
-6
lines changed

6 files changed

+171
-6
lines changed

Mathlib/Algebra/CharP/CharAndCard.lean

+5
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,8 @@ theorem not_isUnit_prime_of_dvd_card {R : Type*} [CommRing R] [Fintype R] (p :
8282
mt (isUnit_iff_not_dvd_char R p).mp
8383
(Classical.not_not.mpr ((prime_dvd_char_iff_dvd_card p).mpr hp))
8484
#align not_is_unit_prime_of_dvd_card not_isUnit_prime_of_dvd_card
85+
86+
lemma charP_of_card_eq_prime {R : Type*} [NonAssocRing R] [Fintype R] (p : ℕ) [hp : Fact p.Prime]
87+
(hR : Fintype.card R = p) : CharP R p :=
88+
have := Fintype.one_lt_card_iff_nontrivial.1 (hR ▸ hp.1.one_lt)
89+
(CharP.charP_iff_prime_eq_zero hp.1).2 (hR ▸ Nat.cast_card_eq_zero R)

Mathlib/Data/ZMod/Basic.lean

+15
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,21 @@ noncomputable def ringEquiv [Fintype R] (h : Fintype.card R = n) : ZMod n ≃+*
491491
RingEquiv.ofBijective _ (ZMod.castHom_bijective R h)
492492
#align zmod.ring_equiv ZMod.ringEquiv
493493

494+
/-- The unique ring isomorphism between `ZMod p` and a ring `R` of cardinality a prime `p`.
495+
496+
If you need any property of this isomorphism, first of all use `ringEquivOfPrime_eq_ringEquiv`
497+
below (after `have : CharP R p := ...`) and deduce it by the results about `ZMod.ringEquiv`. -/
498+
noncomputable def ringEquivOfPrime [Fintype R] {p : ℕ} (hp : p.Prime) (hR : Fintype.card R = p) :
499+
ZMod p ≃+* R :=
500+
have : Nontrivial R := Fintype.one_lt_card_iff_nontrivial.1 (hR ▸ hp.one_lt)
501+
-- The following line exists as `charP_of_card_eq_prime` in `Mathlib.Algebra.CharP.CharAndCard`.
502+
have : CharP R p := (CharP.charP_iff_prime_eq_zero hp).2 (hR ▸ Nat.cast_card_eq_zero R)
503+
ZMod.ringEquiv R hR
504+
505+
@[simp]
506+
lemma ringEquivOfPrime_eq_ringEquiv [Fintype R] {p : ℕ} [CharP R p] (hp : p.Prime)
507+
(hR : Fintype.card R = p) : ringEquivOfPrime R hp hR = ringEquiv R hR := rfl
508+
494509
/-- The identity between `ZMod m` and `ZMod n` when `m = n`, as a ring isomorphism. -/
495510
def ringEquivCongr {m n : ℕ} (h : m = n) : ZMod m ≃+* ZMod n := by
496511
cases' m with m <;> cases' n with n

Mathlib/NumberTheory/Cyclotomic/Rat.lean

+22
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,28 @@ noncomputable def integralPowerBasis [IsCyclotomicExtension {p ^ k} ℚ K]
182182
/-- Abbreviation to see a primitive root of unity as a member of the ring of integers. -/
183183
abbrev toInteger {k : ℕ+} (hζ : IsPrimitiveRoot ζ k) : 𝓞 K := ⟨ζ, hζ.isIntegral k.pos⟩
184184

185+
lemma coe_toInteger {k : ℕ+} (hζ : IsPrimitiveRoot ζ k) : hζ.toInteger.1 = ζ := rfl
186+
187+
/-- `𝓞 K ⧸ Ideal.span {ζ - 1}` is finite. -/
188+
lemma finite_quotient_toInteger_sub_one [NumberField K] {k : ℕ+} (hk : 1 < k)
189+
(hζ : IsPrimitiveRoot ζ k) : Finite (𝓞 K ⧸ Ideal.span {hζ.toInteger - 1}) := by
190+
refine (finite_iff_nonempty_fintype _).2 ⟨?_⟩
191+
refine Ideal.fintypeQuotientOfFreeOfNeBot _ (fun h ↦ ?_)
192+
simp only [Ideal.span_singleton_eq_bot, sub_eq_zero, ← Subtype.coe_inj] at h
193+
exact hζ.ne_one hk (RingOfIntegers.ext_iff.1 h)
194+
195+
/-- We have that `𝓞 K ⧸ Ideal.span {ζ - 1}` has cardinality equal to the norm of `ζ - 1`.
196+
197+
See the results below to compute this norm in various cases. -/
198+
lemma card_quotient_toInteger_sub_one [NumberField K] {k : ℕ+} (hk : 1 < k)
199+
(hζ : IsPrimitiveRoot ζ k) :
200+
Nat.card (𝓞 K ⧸ Ideal.span {hζ.toInteger - 1}) =
201+
(Algebra.norm ℤ (hζ.toInteger - 1)).natAbs := by
202+
have := hζ.finite_quotient_toInteger_sub_one hk
203+
let _ := Fintype.ofFinite (𝓞 K ⧸ Ideal.span {hζ.toInteger - 1})
204+
rw [Nat.card_eq_fintype_card, ← Submodule.cardQuot_apply, ← Ideal.absNorm_apply,
205+
Ideal.absNorm_span_singleton]
206+
185207
lemma toInteger_isPrimitiveRoot {k : ℕ+} (hζ : IsPrimitiveRoot ζ k) :
186208
IsPrimitiveRoot hζ.toInteger k :=
187209
IsPrimitiveRoot.of_map_of_injective (by exact hζ) RingOfIntegers.coe_injective

Mathlib/NumberTheory/Cyclotomic/Three.lean

+86-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Authors: Riccardo Brasca, Pietro Monticone
77
import Mathlib.NumberTheory.Cyclotomic.Embeddings
88
import Mathlib.NumberTheory.Cyclotomic.Rat
99
import Mathlib.NumberTheory.NumberField.Units.DirichletTheorem
10+
import Mathlib.RingTheory.Fintype
1011

1112
/-!
1213
# Third Cyclotomic Field
@@ -33,7 +34,9 @@ namespace IsCyclotomicExtension.Rat.Three
3334
variable {K : Type*} [Field K] [NumberField K] [IsCyclotomicExtension {3} ℚ K]
3435
variable {ζ : K} (hζ : IsPrimitiveRoot ζ ↑(3 : ℕ+)) (u : (𝓞 K)ˣ)
3536
local notation3 "η" => (IsPrimitiveRoot.isUnit (hζ.toInteger_isPrimitiveRoot) (by decide)).unit
36-
local notation3 "λ" => (η : 𝓞 K) - 1
37+
local notation3 "λ" => hζ.toInteger - 1
38+
39+
lemma coe_eta : (η : 𝓞 K) = hζ.toInteger := rfl
3740

3841
/-- Let `u` be a unit in `(𝓞 K)ˣ`, then `u ∈ [1, -1, η, -η, η^2, -η^2]`. -/
3942
-- Here `List` is more convenient than `Finset`, even if further from the informal statement.
@@ -62,15 +65,16 @@ theorem Units.mem : u ∈ [1, -1, η, -η, η ^ 2, -η ^ 2] := by
6265
(isOfFinOrder_iff_pow_eq_one.2 ⟨n, hnpos, hn⟩)
6366
replace hr : r ∈ Finset.Ico 0 3 := Finset.mem_Ico.2by simp, hr3⟩
6467
replace hru : ↑u = η ^ r ∨ ↑u = -η ^ r := by
65-
rcases hru with (h | h)
68+
rcases hru with h | h
6669
· left; ext; exact h
6770
· right; ext; exact h
68-
fin_cases hr <;> rcases hru with (h | h) <;> simp [h]
71+
fin_cases hr <;> rcases hru with h | h <;> simp [h]
6972

7073
/-- We have that `λ ^ 2 = -3 * η`. -/
7174
private lemma lambda_sq : λ ^ 2 = -3 * η := by
7275
ext
73-
calc (λ ^ 2 : K) = η ^ 2 + η + 1 - 3 * η := by ring
76+
calc (λ ^ 2 : K) = η ^ 2 + η + 1 - 3 * η := by
77+
simp only [RingOfIntegers.map_mk, IsUnit.unit_spec]; ring
7478
_ = 0 - 3 * η := by simpa using hζ.isRoot_cyclotomic (by decide)
7579
_ = -3 * η := by ring
7680

@@ -109,3 +113,81 @@ theorem eq_one_or_neg_one_of_unit_of_congruent (hcong : ∃ n : ℤ, λ ^ 2 ∣
109113
have : (hζ.pow_of_coprime 2 (by decide)).toInteger = hζ.toInteger ^ 2 := by ext; simp
110114
simp only [this, PNat.val_ofNat, Nat.cast_ofNat, mul_neg, Int.cast_neg, ← neg_add, ←
111115
sub_eq_iff_eq_add.1 hx, Units.val_neg, val_pow_eq_pow_val, IsUnit.unit_spec, neg_neg]
116+
117+
variable (x : 𝓞 K)
118+
119+
/-- Let `(x : 𝓞 K)`. Then we have that `λ` divides one amongst `x`, `x - 1` and `x + 1`. -/
120+
lemma lambda_dvd_or_dvd_sub_one_or_dvd_add_one : λ ∣ x ∨ λ ∣ x - 1 ∨ λ ∣ x + 1 := by
121+
classical
122+
have := hζ.finite_quotient_toInteger_sub_one (by decide)
123+
let _ := Fintype.ofFinite (𝓞 K ⧸ Ideal.span {λ})
124+
let _ : Ring (𝓞 K ⧸ Ideal.span {λ}) := CommRing.toRing -- to speed up instance synthesis
125+
let _ : AddGroup (𝓞 K ⧸ Ideal.span {λ}) := AddGroupWithOne.toAddGroup -- dito
126+
have := Finset.mem_univ (Ideal.Quotient.mk (Ideal.span {λ}) x)
127+
have h3 : Fintype.card (𝓞 K ⧸ Ideal.span {λ}) = 3 := by
128+
rw [← Nat.card_eq_fintype_card, hζ.card_quotient_toInteger_sub_one (by decide),
129+
hζ.norm_toInteger_sub_one_of_prime_ne_two' (by decide)]
130+
simp only [PNat.val_ofNat, Nat.cast_ofNat, Int.reduceAbs]
131+
rw [Finset.univ_of_card_le_three h3.le] at this
132+
simp only [Finset.mem_insert, Finset.mem_singleton] at this
133+
rcases this with h | h | h
134+
· left
135+
exact Ideal.mem_span_singleton.1 <| Ideal.Quotient.eq_zero_iff_mem.1 h
136+
· right; left
137+
refine Ideal.mem_span_singleton.1 <| Ideal.Quotient.eq_zero_iff_mem.1 ?_
138+
rw [RingHom.map_sub, h, RingHom.map_one, sub_self]
139+
· right; right
140+
refine Ideal.mem_span_singleton.1 <| Ideal.Quotient.eq_zero_iff_mem.1 ?_
141+
rw [RingHom.map_add, h, RingHom.map_one, add_left_neg]
142+
143+
/-- We have that `η ^ 2 + η + 1 = 0`. -/
144+
lemma eta_sq_add_eta_add_one : (η : 𝓞 K) ^ 2 + η + 1 = 0 := by
145+
rw [eta_sq]
146+
ring
147+
148+
/-- We have that `x ^ 3 - 1 = (x - 1) * (x - η) * (x - η ^ 2)`. -/
149+
lemma cube_sub_one_eq_mul : x ^ 3 - 1 = (x - 1) * (x - η) * (x - η ^ 2) := by
150+
symm
151+
calc _ = x ^ 3 - x ^ 2 * (η ^ 2 + η + 1) + x * (η ^ 2 + η + η ^ 3) - η ^ 3 := by ring
152+
_ = x ^ 3 - x ^ 2 * (η ^ 2 + η + 1) + x * (η ^ 2 + η + 1) - 1 := by
153+
simp [show hζ.toInteger ^ 3 = 1 from hζ.toInteger_isPrimitiveRoot.pow_eq_one]
154+
_ = x ^ 3 - 1 := by rw [eta_sq_add_eta_add_one hζ]; ring
155+
156+
/-- We have that `λ` divides `x * (x - 1) * (x - (η + 1))`. -/
157+
lemma lambda_dvd_mul_sub_one_mul_sub_eta_add_one : λ ∣ x * (x - 1) * (x - (η + 1)) := by
158+
rcases lambda_dvd_or_dvd_sub_one_or_dvd_add_one hζ x with h | h | h
159+
· exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_left h _) _
160+
· exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_right h _) _
161+
· refine dvd_mul_of_dvd_right ?_ _
162+
rw [show x - (η + 1) = x + 1 - (η - 1 + 3) by ring]
163+
exact dvd_sub h <| dvd_add dvd_rfl hζ.toInteger_sub_one_dvd_prime'
164+
165+
/-- If `λ` divides `x - 1`, then `λ ^ 4` divides `x ^ 3 - 1`. -/
166+
lemma lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one {x : 𝓞 K} (h : λ ∣ x - 1) :
167+
λ ^ 4 ∣ x ^ 3 - 1 := by
168+
obtain ⟨y, hy⟩ := h
169+
have : x ^ 3 - 1 = λ ^ 3 * (y * (y - 1) * (y - (η + 1))) := by
170+
calc _ = (x - 1) * (x - 1 - λ) * (x - 1 - λ * (η + 1)) := by
171+
simp only [coe_eta, cube_sub_one_eq_mul hζ x]; ring
172+
_ = _ := by rw [hy]; ring
173+
rw [this, pow_succ]
174+
exact mul_dvd_mul_left _ (lambda_dvd_mul_sub_one_mul_sub_eta_add_one hζ y)
175+
176+
/-- If `λ` divides `x + 1`, then `λ ^ 4` divides `x ^ 3 + 1`. -/
177+
lemma lambda_pow_four_dvd_cube_add_one_of_dvd_add_one {x : 𝓞 K} (h : λ ∣ x + 1) :
178+
λ ^ 4 ∣ x ^ 3 + 1 := by
179+
replace h : λ ∣ -x - 1 := by
180+
convert h.neg_right using 1
181+
exact (neg_add' x 1).symm
182+
convert (lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one hζ h).neg_right using 1
183+
ring
184+
185+
/-- If `λ` does not divide `x`, then `λ ^ 4` divides `x ^ 3 - 1` or `x ^ 3 + 1`. -/
186+
lemma lambda_pow_four_dvd_cube_sub_one_or_add_one_of_lambda_not_dvd {x : 𝓞 K} (h : ¬ λ ∣ x) :
187+
λ ^ 4 ∣ x ^ 3 - 1 ∨ λ ^ 4 ∣ x ^ 3 + 1 := by
188+
rcases lambda_dvd_or_dvd_sub_one_or_dvd_add_one hζ x with H | H | H
189+
· contradiction
190+
· left
191+
exact lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one hζ H
192+
· right
193+
exact lambda_pow_four_dvd_cube_add_one_of_dvd_add_one hζ H

Mathlib/NumberTheory/FLT/Three.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ open NumberField
120120
variable {K : Type*} [Field K] [NumberField K] [IsCyclotomicExtension {3} ℚ K]
121121
variable {ζ : K} (hζ : IsPrimitiveRoot ζ (3 : ℕ+))
122122

123-
local notation3 "η" => hζ.toInteger
124-
local notation3 "λ" => η - 1
123+
local notation3 "η" => (IsPrimitiveRoot.isUnit (hζ.toInteger_isPrimitiveRoot) (by decide)).unit
124+
local notation3 "λ" => hζ.toInteger - 1
125125

126126
/-- `FermatLastTheoremForThreeGen` is the statement that `a ^ 3 + b ^ 3 = u * c ^ 3` has no
127127
nontrivial solutions in `𝓞 K` for all `u : (𝓞 K)ˣ` such that `¬ λ ∣ a`, `¬ λ ∣ b` and `λ ∣ c`.

Mathlib/RingTheory/Fintype.lean

+41
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Scott Morrison
55
-/
66
import Mathlib.Data.Fintype.Units
7+
import Mathlib.Data.ZMod.Basic
78

89
#align_import ring_theory.fintype from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe"
910

@@ -12,6 +13,46 @@ import Mathlib.Data.Fintype.Units
1213
-/
1314

1415

16+
open Finset ZMod
17+
18+
variable {R : Type*} [Ring R] [Fintype R] [DecidableEq R]
19+
20+
lemma Finset.univ_of_card_le_two (h : Fintype.card R ≤ 2) :
21+
(univ : Finset R) = {0, 1} := by
22+
rcases subsingleton_or_nontrivial R
23+
· exact le_antisymm (fun a _ ↦ by simp [Subsingleton.elim a 0]) (Finset.subset_univ _)
24+
· refine (eq_of_subset_of_card_le (subset_univ _) ?_).symm
25+
convert h
26+
simp
27+
28+
lemma Finset.univ_of_card_le_three (h : Fintype.card R ≤ 3) :
29+
(univ : Finset R) = {0, 1, -1} := by
30+
refine (eq_of_subset_of_card_le (subset_univ _) ?_).symm
31+
rcases lt_or_eq_of_le h with h | h
32+
· apply card_le_card
33+
rw [Finset.univ_of_card_le_two (Nat.lt_succ_iff.1 h)]
34+
intro a ha
35+
simp only [mem_insert, mem_singleton] at ha
36+
rcases ha with rfl | rfl <;> simp
37+
· have : Nontrivial R := by
38+
refine Fintype.one_lt_card_iff_nontrivial.1 ?_
39+
rw [h]
40+
norm_num
41+
rw [card_univ, h, card_insert_of_not_mem, card_insert_of_not_mem, card_singleton]
42+
· rw [mem_singleton]
43+
intro H
44+
rw [← add_eq_zero_iff_eq_neg, one_add_one_eq_two] at H
45+
apply_fun (ringEquivOfPrime R Nat.prime_three h).symm at H
46+
simp only [map_ofNat, map_zero] at H
47+
replace H : ((2 : ℕ) : ZMod 3) = 0 := H
48+
rw [natCast_zmod_eq_zero_iff_dvd] at H
49+
norm_num at H
50+
· intro h
51+
simp only [mem_insert, mem_singleton, zero_eq_neg] at h
52+
rcases h with (h | h)
53+
· exact zero_ne_one h
54+
· exact zero_ne_one h.symm
55+
1556
open scoped Classical
1657

1758
theorem card_units_lt (M₀ : Type*) [MonoidWithZero M₀] [Nontrivial M₀] [Fintype M₀] :

0 commit comments

Comments
 (0)