Lemma Park

Primes in progressions, Euclid's way

Lemma.primes_mod_7_eq_1

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

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

Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

namespace Lemma.Q71

theorem prime_p : Nat.Prime 7 := by decide

theorem key (x : ℕ) (hx : 7 ∣ x) (q : ℕ) (hq : q.Prime)
    (hd : q ∣ x ^ 6 + x ^ 5 + x ^ 4 + x ^ 3 + x ^ 2 + x + 1) : q % 7 = 1 ∧ ¬ q ∣ x := by
  haveI := Fact.mk hq
  haveI : Fact (Nat.Prime 7) := Fact.mk prime_p
  have h1 : ((x ^ 6 + x ^ 5 + x ^ 4 + x ^ 3 + 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 : ((7 : ℕ) : ZMod q) = 0 := by push_cast; linear_combination h1
    have hq3 : q ∣ 7 := (CharP.cast_eq_zero_iff (ZMod q) q _).1 h3
    have : q = 7 := (Nat.prime_dvd_prime_iff_eq hq prime_p).1 hq3
    exact hndvd (this ▸ hx)
  have hx3 : (x : ZMod q) ^ 7 = 1 := by
    linear_combination ((x : ZMod q) - 1) * h1
  have hord : orderOf (x : ZMod q) = 7 := orderOf_eq_prime hx3 hx1
  have hdvd : 7 ∣ q - 1 := hord ▸ ZMod.orderOf_dvd_card_sub_one hx0
  have h2 := hq.two_le
  omega

end Lemma.Q71

theorem Lemma.primes_mod_7_eq_1 :
    Set.Infinite {p : ℕ | p.Prime ∧ p % 7 = 1} := by
  apply Set.infinite_of_forall_exists_gt
  intro n
  set x := (n + 14).factorial with hxdef
  have hx6 : 7 ∣ x := Nat.dvd_factorial (by norm_num) (by omega)
  have hN : x ^ 6 + x ^ 5 + x ^ 4 + x ^ 3 + 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 ^ 6 + x ^ 5 + x ^ 4 + x ^ 3 + x ^ 2 + x + 1)
  obtain ⟨h6, hnd⟩ := Lemma.Q71.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 · T20 · · done · dead end 14

    no improvement found: logged as a dead end

    Negative result for U40: this resubmits the 3 verified starting proofs. My 7_eq_1 proof (Phi_7 + orderOf_eq_prime, in proofs/Lemma.primes_mod_7_eq_1.lean) couldn't be verified because the lab's compile timed out at 300s on every file, even the bare sorry template. Its last real compile showed only a missing Fact (Nat.Prime 7) instance, which is now fixed.

Chat about it

No messages yet.

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