Primes in progressions, Euclid's way
Lemma.primes_mod_12_eq_1
Proved. 0 attempts so far.
Set.Infinite {p : ℕ | p.Prime ∧ p % 12 = 1}Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
namespace Lemma.P121
theorem key (x N : ℕ) (hx : 6 ∣ x) (hN : N + x ^ 2 = x ^ 4 + 1) (q : ℕ) (hq : q.Prime)
(hd : q ∣ N) : q % 12 = 1 ∧ ¬ q ∣ x := by
haveI := Fact.mk hq
haveI : Fact (Nat.Prime 3) := Fact.mk Nat.prime_three
have hN0 : ((N : ℕ) : ZMod q) = 0 :=
(CharP.cast_eq_zero_iff (ZMod q) q _).2 hd
have hNc : ((N : ℕ) : ZMod q) + (x : ZMod q) ^ 2 = (x : ZMod q) ^ 4 + 1 := by
have := congrArg (fun m : ℕ => (m : ZMod q)) hN
push_cast at this
exact this
have h1 : (x : ZMod q) ^ 4 + 1 = (x : ZMod q) ^ 2 := by
linear_combination -hNc + hN0
have hndvd : ¬ q ∣ x := by
intro hqx
have : (x : ZMod q) = 0 := (CharP.cast_eq_zero_iff (ZMod q) q _).2 hqx
rw [this] at h1
simp at h1
refine ⟨?_, hndvd⟩
have hx0 : (x : ZMod q) ≠ 0 := by
intro h
exact hndvd ((CharP.cast_eq_zero_iff (ZMod q) q _).1 h)
have hq2 : q ≠ 2 := by
rintro rfl
obtain ⟨k, rfl⟩ := hx
have e1 : (6 * k) ^ 2 = 2 * (18 * k ^ 2) := by ring
have e2 : (6 * k) ^ 4 = 2 * (648 * k ^ 4) := by ring
rw [e1, e2] at hN
have := Nat.mod_eq_zero_of_dvd hd
omega
set u : ZMod q := -(x : ZMod q) ^ 2 with hudef
have hu3 : u ^ 3 = 1 := by
rw [hudef]
linear_combination (-((x : ZMod q) ^ 2 + 1)) * h1
have hu1 : u ≠ 1 := by
intro hu
rw [hudef] at hu
have h3 : ((3 : ℕ) : ZMod q) = 0 := by
push_cast
linear_combination h1 + ((x : ZMod q) ^ 2 - 2) * hu
have hq3 : q ∣ 3 := (CharP.cast_eq_zero_iff (ZMod q) q _).1 h3
have : q = 3 := (Nat.prime_dvd_prime_iff_eq hq Nat.prime_three).1 hq3
exact hndvd (this ▸ (Dvd.dvd.trans (by norm_num : 3 ∣ 6) hx))
have hu0 : u ≠ 0 := by
rw [hudef]
exact neg_ne_zero.mpr (pow_ne_zero 2 hx0)
have hord : orderOf u = 3 := orderOf_eq_prime hu3 hu1
have hdvd : 3 ∣ q - 1 := hord ▸ ZMod.orderOf_dvd_card_sub_one hu0
have hinv : (x : ZMod q) * (x : ZMod q)⁻¹ = 1 := mul_inv_cancel₀ hx0
have hsq : IsSquare (-1 : ZMod q) :=
⟨((x : ZMod q) ^ 2 - 1) * (x : ZMod q)⁻¹, by
linear_combination (-((x : ZMod q)⁻¹) ^ 2) * h1
+ ((x : ZMod q) * (x : ZMod q)⁻¹ + 1) * hinv⟩
have h4 := (ZMod.exists_sq_eq_neg_one_iff (p := q)).1 hsq
have hodd := hq.eq_two_or_odd
have h2 := hq.two_le
omega
end Lemma.P121
theorem Lemma.primes_mod_12_eq_1 :
Set.Infinite {p : ℕ | p.Prime ∧ p % 12 = 1} := by
apply Set.infinite_of_forall_exists_gt
intro n
set x := (n + 6).factorial with hxdef
have hx6 : 6 ∣ x := Nat.dvd_factorial (by norm_num) (by omega)
have hxpos : 0 < x := Nat.factorial_pos _
have hx2 : 2 ≤ x := by
have : (6 : ℕ) ≤ x := Nat.le_of_dvd hxpos hx6
omega
have hx4 : 4 ≤ x ^ 2 := by nlinarith
have h4 : x ^ 4 = x ^ 2 * x ^ 2 := by ring
have hle : x ^ 2 ≤ x ^ 4 + 1 := by
rw [h4]
have := Nat.mul_le_mul_left (x ^ 2) hx4
omega
set N := x ^ 4 + 1 - x ^ 2 with hNdef
have hN : N + x ^ 2 = x ^ 4 + 1 := Nat.sub_add_cancel hle
have hN1 : N ≠ 1 := by
have hm : x ^ 2 * 4 ≤ x ^ 2 * x ^ 2 := Nat.mul_le_mul_left _ hx4
rw [h4] at hN
generalize x ^ 2 * x ^ 2 = b at *
generalize x ^ 2 = a at *
omega
have hq := Nat.minFac_prime hN1
have hqd := Nat.minFac_dvd N
obtain ⟨h12, hnd⟩ := Lemma.P121.key x N hx6 hN _ hq hqd
refine ⟨_, ⟨hq, h12⟩, ?_⟩
by_contra hle'
push_neg at hle'
exact hnd (Nat.dvd_factorial hq.pos (by omega))
Attempts
Nobody has worked on this yet.
Chat about it
No messages yet.
Messages in the program's chat that name primes_mod_12_eq_1 or one of its units.