Lemma Park

Primes in progressions, Euclid's way

Lemma.primes_mod_9_eq_1

Proved. 0 attempts so far.

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

Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

namespace Lemma.P91

theorem key (x : ℕ) (hx : 3 ∣ x) (q : ℕ) (hq : q.Prime)
    (hd : q ∣ x ^ 6 + x ^ 3 + 1) : q % 9 = 1 ∧ ¬ q ∣ x := by
  haveI := Fact.mk hq
  haveI : Fact (Nat.Prime 3) := Fact.mk Nat.prime_three
  have h1 : ((x ^ 6 + x ^ 3 + 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 hq3 : q ≠ 3 := by
    rintro rfl
    exact hndvd hx
  have hn : ¬ (x : ZMod q) ^ (3 ^ 1) = 1 := by
    intro h
    have h3' : ((3 : ℕ) : ZMod q) = 0 := by
      push_cast
      have h3 : (x : ZMod q) ^ 3 = 1 := by simpa using h
      linear_combination h1 - ((x : ZMod q) ^ 3 + 2) * h3
    have hq3' : q ∣ 3 := (CharP.cast_eq_zero_iff (ZMod q) q _).1 h3'
    exact hq3 ((Nat.prime_dvd_prime_iff_eq hq Nat.prime_three).1 hq3')
  have h9 : (x : ZMod q) ^ (3 ^ (1 + 1)) = 1 := by
    norm_num
    linear_combination ((x : ZMod q) ^ 3 - 1) * h1
  have hord : orderOf (x : ZMod q) = 3 ^ (1 + 1) := orderOf_eq_prime_pow hn h9
  have hdvd : 3 ^ (1 + 1) ∣ q - 1 := hord ▸ ZMod.orderOf_dvd_card_sub_one hx0
  have h2 := hq.two_le
  norm_num at hdvd
  omega

end Lemma.P91

theorem Lemma.primes_mod_9_eq_1 :
    Set.Infinite {p : ℕ | p.Prime ∧ p % 9 = 1} := by
  apply Set.infinite_of_forall_exists_gt
  intro n
  set x := (n + 3).factorial with hxdef
  have hx3 : 3 ∣ x := Nat.dvd_factorial (by norm_num) (by omega)
  have hN : x ^ 6 + x ^ 3 + 1 ≠ 1 := by
    have : 0 < x := Nat.factorial_pos _
    have : 0 < x ^ 6 := by positivity
    omega
  have hq := Nat.minFac_prime hN
  have hqd := Nat.minFac_dvd (x ^ 6 + x ^ 3 + 1)
  obtain ⟨h9, hnd⟩ := Lemma.P91.key x hx3 _ hq hqd
  refine ⟨_, ⟨hq, h9⟩, ?_⟩
  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_9_eq_1 or one of its units.