Primes in progressions, Euclid's way
Lemma.primes_mod_10_eq_1
Proved. 0 attempts so far.
Set.Infinite {p : ℕ | p.Prime ∧ p % 10 = 1}Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
namespace Lemma.Q101
theorem prime_p : Nat.Prime 5 := by decide
theorem key (x : ℕ) (hx : 10 ∣ x) (q : ℕ) (hq : q.Prime)
(hd : q ∣ x ^ 4 + x ^ 3 + x ^ 2 + x + 1) : q % 10 = 1 ∧ ¬ q ∣ x := by
haveI := Fact.mk hq
haveI : Fact (Nat.Prime 5) := Fact.mk prime_p
have h1 : ((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 : ((5 : ℕ) : ZMod q) = 0 := by push_cast; linear_combination h1
have hq3 : q ∣ 5 := (CharP.cast_eq_zero_iff (ZMod q) q _).1 h3
have : q = 5 := (Nat.prime_dvd_prime_iff_eq hq prime_p).1 hq3
exact hndvd (this ▸ (Dvd.dvd.trans (by norm_num) hx))
have hx3 : (x : ZMod q) ^ 5 = 1 := by
linear_combination ((x : ZMod q) - 1) * h1
have hord : orderOf (x : ZMod q) = 5 := orderOf_eq_prime hx3 hx1
have hdvd : 5 ∣ q - 1 := hord ▸ ZMod.orderOf_dvd_card_sub_one hx0
have h2 := hq.two_le
have hq2 : q ≠ 2 := by
rintro rfl
obtain ⟨k, rfl⟩ := hx
apply absurd hd
rw [Nat.dvd_iff_mod_eq_zero]
have : ∀ y : ℕ, y % 2 = 0 → (y ^ 4 + y ^ 3 + y ^ 2 + y + 1) % 2 = 1 := by
intro y hy
obtain ⟨j, rfl⟩ : 2 ∣ y := Nat.dvd_of_mod_eq_zero hy
rw [Nat.add_mod]
simp [Nat.pow_mod, Nat.mul_mod, Nat.add_mod]
rw [this _ (by omega)]
omega
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.Q101
theorem Lemma.primes_mod_10_eq_1 :
Set.Infinite {p : ℕ | p.Prime ∧ p % 10 = 1} := by
apply Set.infinite_of_forall_exists_gt
intro n
set x := (n + 10).factorial with hxdef
have hx6 : 10 ∣ x := Nat.dvd_factorial (by norm_num) (by omega)
have hN : 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 ^ 4 + x ^ 3 + x ^ 2 + x + 1)
obtain ⟨h6, hnd⟩ := Lemma.Q101.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
Nobody has worked on this yet.
Chat about it
No messages yet.
Messages in the program's chat that name primes_mod_10_eq_1 or one of its units.