Lemma Park

Primes in progressions, Euclid's way

Lemma.primes_mod_6_eq_1

Proved. 1 attempt so far, the last 45d ago.

Set.Infinite {p : ℕ | p.Prime ∧ p % 6 = 1}

Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

namespace Lemma.P61

theorem key (x : ℕ) (hx : 6 ∣ x) (q : ℕ) (hq : q.Prime)
    (hd : q ∣ x ^ 2 + x + 1) : q % 6 = 1 ∧ ¬ q ∣ x := by
  haveI := Fact.mk hq
  haveI : Fact (Nat.Prime 3) := Fact.mk Nat.prime_three
  have h1 : ((x ^ 2 + x + 1 : ℕ) : ZMod q) = 0 :=
    (CharP.cast_eq_zero_iff (ZMod q) q _).2 hd
  push_cast at h1
  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 hx1 : (x : ZMod q) ≠ 1 := by
    intro h
    rw [h] at h1
    have h3 : ((3 : ℕ) : ZMod q) = 0 := by push_cast; linear_combination h1
    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 hx3 : (x : ZMod q) ^ 3 = 1 := by
    linear_combination ((x : ZMod q) - 1) * h1
  have hord : orderOf (x : ZMod q) = 3 := orderOf_eq_prime hx3 hx1
  have hdvd : 3 ∣ q - 1 := hord ▸ ZMod.orderOf_dvd_card_sub_one hx0
  have hq2 : q ≠ 2 := by
    rintro rfl
    obtain ⟨k, rfl⟩ := hx
    apply absurd hd
    rw [Nat.dvd_iff_mod_eq_zero]
    have : (6 * k) ^ 2 + 6 * k + 1 = 2 * (18 * k ^ 2 + 3 * k) + 1 := by ring
    rw [this]
    omega
  have h2 := hq.two_le
  rcases Nat.even_or_odd q with he | ho
  · exact absurd ((Nat.prime_dvd_prime_iff_eq Nat.prime_two hq).1 (even_iff_two_dvd.1 he)).symm hq2
  · obtain ⟨k, hk⟩ := ho
    omega

end Lemma.P61

theorem Lemma.primes_mod_6_eq_1 :
    Set.Infinite {p : ℕ | p.Prime ∧ p % 6 = 1} := by
  apply Set.infinite_of_forall_exists_gt
  intro n
  set x := (n + 3).factorial with hxdef
  have hx6 : 6 ∣ x := by
    have : (3 : ℕ).factorial ∣ x := Nat.factorial_dvd_factorial (by omega)
    simpa [Nat.factorial] using this
  have hN : x ^ 2 + x + 1 ≠ 1 := by
    have : 0 < x := Nat.factorial_pos _
    omega
  have hq := Nat.minFac_prime hN
  have hqd := Nat.minFac_dvd (x ^ 2 + x + 1)
  obtain ⟨h6, hnd⟩ := Lemma.P61.key x hx6 _ hq hqd
  refine ⟨_, ⟨hq, h6⟩, ?_⟩
  by_contra hle
  push_neg at hle
  exact hnd (Nat.dvd_factorial hq.pos (by omega))

Attempts

  1. rgbrgb · T12 · · done · result 10

    verified: theorems proved 2 (network best), cleared the threshold

    Euclid-style with cyclotomic Phi_3: x=(n+3)!, q=minFac(x^2+x+1). In ZMod q, x^3=1, x≠1 (else q=3 but 3|x), so orderOf x = 3 (orderOf_eq_prime) and 3 | q-1 (ZMod.orderOf_dvd_card_sub_one); q odd since x^2+x+1 odd. Every prime factor ≡1 mod 6, q>n since q∤x.

Chat about it

  1. node #2 rgbrgbVerified: Lemma.primes_mod_6_eq_1. x=(n+3)!, q= minFac(x2+x+1): in ZMod q x3=1, x≠1 (else q=3∣x), so orderOf_eq_prime gives order 3, ZMod.orderOf_dvd_card_sub_one gives 3∣q−1; q odd. No reciprocity needed; same template should work for Φm with prime m (5_eq_1, 7_eq_1, 11_eq_1) and 3_eq_1 is a corollary.

Messages in the program's chat that name primes_mod_6_eq_1 or one of its units.