Primes in progressions, Euclid's way
Lemma.primes_mod_12_eq_11
Proved. 0 attempts so far.
Set.Infinite {p : ℕ | p.Prime ∧ p % 12 = 11}Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
namespace Lemma.P1211
theorem z3 : (3 : ZMod 3) = 0 := by decide
theorem nsq2 : ∀ r : ZMod 3, ((2 : ℕ) : ZMod 3) ≠ r * r := by decide
theorem sq1 : IsSquare ((1 : ℕ) : ZMod 3) := ⟨1, by decide⟩
theorem prime_three' : Nat.Prime 3 := by decide
theorem key (y : ℕ) (hy : 2 ∣ y) (hy0 : 0 < y) (q : ℕ) (hq : q.Prime)
(hd : q ∣ 3 * y ^ 2 - 1) : (q % 12 = 1 ∨ q % 12 = 11) ∧ ¬ q ∣ y := by
haveI := Fact.mk hq
haveI : Fact (Nat.Prime 3) := Fact.mk prime_three'
have h1 : ((3 * y ^ 2 - 1 : ℕ) : ZMod q) = 0 :=
(CharP.cast_eq_zero_iff (ZMod q) q _).2 hd
have h5 : 1 ≤ 3 * y ^ 2 := by
have : 1 ≤ y ^ 2 := Nat.one_le_pow _ _ hy0
omega
have h2 : (3 : ZMod q) * (y : ZMod q) ^ 2 = 1 := by
rw [Nat.cast_sub h5] at h1
push_cast at h1
linear_combination h1
have hndvd : ¬ q ∣ y := by
intro hqy
have : (y : ZMod q) = 0 := (CharP.cast_eq_zero_iff (ZMod q) q _).2 hqy
rw [this] at h2
simp at h2
refine ⟨?_, hndvd⟩
have hq2 : q ≠ 2 := by
rintro rfl
exact hndvd hy
have hq3 : q ≠ 3 := by
rintro rfl
have : (3 : ZMod 3) = 0 := z3
rw [this] at h2
simp at h2
have hsq : IsSquare ((3 : ℕ) : ZMod q) := ⟨3 * y, by push_cast; linear_combination (-3) * h2⟩
have hodd := hq.eq_two_or_odd
have hq30 : q % 3 ≠ 0 := by
intro h0
exact hq3 ((Nat.prime_dvd_prime_iff_eq prime_three' hq).1
(Nat.dvd_of_mod_eq_zero h0)).symm
have hlt3 := Nat.mod_lt q (by norm_num : 3 > 0)
rcases hodd with h | hodd
· exact absurd h hq2
have h4 : q % 4 = 1 ∨ q % 4 = 3 := by omega
rcases h4 with h4 | h4
· obtain ⟨r, hr⟩ :=
(ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_one (p := q) (q := 3) h4 (by norm_num)).1 hsq
rw [← ZMod.natCast_mod q 3] at hr
have : q % 3 ≠ 2 := by
intro h32
rw [h32] at hr
exact nsq2 r hr
left; omega
· have hns : ¬ IsSquare ((q : ℕ) : ZMod 3) := fun hh =>
(ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_three (p := 3) (q := q) (by norm_num) h4
(Ne.symm hq3)).1 hh hsq
rw [← ZMod.natCast_mod q 3] at hns
have : q % 3 ≠ 1 := by
intro h31
rw [h31] at hns
exact hns sq1
right; omega
theorem exists11 (N : ℕ) (hN : N % 12 = 11)
(hf : ∀ q, q.Prime → q ∣ N → q % 12 = 1 ∨ q % 12 = 11) :
∃ q, q.Prime ∧ q ∣ N ∧ q % 12 = 11 := by
induction N using Nat.strong_induction_on with
| _ N ih =>
have hN1 : N ≠ 1 := by omega
have hq := Nat.minFac_prime hN1
have hqd := Nat.minFac_dvd N
rcases hf _ hq hqd with h | h
· obtain ⟨k, hk⟩ := hqd
have hk5 : k % 12 = 11 := by
rw [hk, Nat.mul_mod, h] at hN
omega
have hklt : k < N := by
have := hq.two_le
have hk0 : 0 < k := by omega
rw [hk]
nlinarith
have hdiv : k ∣ N := Dvd.intro_left _ hk.symm
obtain ⟨p, hp, hpd, hp4⟩ :=
ih k hklt hk5 (fun p hp hpd => hf p hp (hpd.trans hdiv))
exact ⟨p, hp, hpd.trans hdiv, hp4⟩
· exact ⟨_, hq, hqd, h⟩
end Lemma.P1211
theorem Lemma.primes_mod_12_eq_11 :
Set.Infinite {p : ℕ | p.Prime ∧ p % 12 = 11} := by
apply Set.infinite_of_forall_exists_gt
intro n
have hy2 : 2 ∣ (n + 3).factorial := Nat.dvd_factorial (by norm_num) (by omega)
have hy0 : 0 < (n + 3).factorial := Nat.factorial_pos _
have hN : (3 * (n + 3).factorial ^ 2 - 1) % 12 = 11 := by
obtain ⟨k, hk⟩ := hy2
have hz : (n + 3).factorial ^ 2 = 4 * k ^ 2 := by rw [hk]; ring
have : 1 ≤ (n + 3).factorial ^ 2 := Nat.one_le_pow _ _ hy0
rw [hz] at this ⊢
omega
obtain ⟨q, hq, hqd, hq4⟩ := Lemma.P1211.exists11 _ hN
(fun q hq hd => (Lemma.P1211.key _ hy2 hy0 q hq hd).1)
refine ⟨q, ⟨hq, hq4⟩, ?_⟩
by_contra hle
push_neg at hle
exact (Lemma.P1211.key _ hy2 hy0 q hq hqd).2 (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_11 or one of its units.