Primes in progressions, Euclid's way
Lemma.primes_mod_8_eq_3
Proved. 0 attempts so far.
Set.Infinite {p : ℕ | p.Prime ∧ p % 8 = 3}Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
namespace Lemma.P83
def Q (n : ℕ) : ℕ := ∏ i ∈ Finset.range n, (2 * i + 1)
theorem Q_odd (n : ℕ) : Q n % 2 = 1 := by
unfold Q
apply Finset.prod_induction _ (fun x => x % 2 = 1)
· intro a b ha hb; rw [Nat.mul_mod, ha, hb]
· rfl
· intro i _; omega
theorem Q_pos (n : ℕ) : 0 < Q n := by have := Q_odd n; omega
theorem Q_sq (n : ℕ) : Q n ^ 2 % 8 = 1 := by
have h := Q_odd n
have h8 : Q n % 8 = 1 ∨ Q n % 8 = 3 ∨ Q n % 8 = 5 ∨ Q n % 8 = 7 := by omega
rw [Nat.pow_mod]
rcases h8 with h8 | h8 | h8 | h8 <;> rw [h8]
theorem dvd_Q (n q : ℕ) (hq : q % 2 = 1) (hle : q ≤ n) : q ∣ Q n := by
unfold Q
have hmem : q / 2 ∈ Finset.range n := Finset.mem_range.2 (by omega)
have := Finset.dvd_prod_of_mem (fun i => 2 * i + 1) hmem
have he : 2 * (q / 2) + 1 = q := by omega
simpa [he] using this
theorem key (n q : ℕ) (hq : q.Prime) (hd : q ∣ Q n ^ 2 + 2) :
(q % 8 = 1 ∨ q % 8 = 3) ∧ ¬ q ∣ Q n := by
haveI := Fact.mk hq
have h2 : ((Q n : ℕ) : ZMod q) ^ 2 + 2 = 0 := by
have := (CharP.cast_eq_zero_iff (ZMod q) q _).2 hd
push_cast at this
exact this
have hq2 : q ≠ 2 := by
rintro rfl
have h := Q_sq n
have : (Q n ^ 2 + 2) % 2 = 0 := Nat.mod_eq_zero_of_dvd hd
omega
have hndvd : ¬ q ∣ Q n := by
intro hqy
have hq2' : q ∣ 2 := (Nat.dvd_add_right (dvd_pow hqy two_ne_zero)).1 hd
exact hq2 ((Nat.prime_dvd_prime_iff_eq hq Nat.prime_two).1 hq2')
refine ⟨?_, hndvd⟩
have hsq : IsSquare (-2 : ZMod q) := ⟨(Q n : ZMod q), by linear_combination (-1) * h2⟩
exact (ZMod.exists_sq_eq_neg_two_iff hq2).1 hsq
theorem existsA (N : ℕ) (hN : N % 8 = 3)
(hf : ∀ q, q.Prime → q ∣ N → q % 8 = 1 ∨ q % 8 = 3) :
∃ q, q.Prime ∧ q ∣ N ∧ q % 8 = 3 := 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 % 8 = 3 := 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.P83
theorem Lemma.primes_mod_8_eq_3 :
Set.Infinite {p : ℕ | p.Prime ∧ p % 8 = 3} := by
apply Set.infinite_of_forall_exists_gt
intro n
have hN : (Lemma.P83.Q n ^ 2 + 2) % 8 = 3 := by
have := Lemma.P83.Q_sq n
omega
obtain ⟨q, hq, hqd, hq4⟩ := Lemma.P83.existsA _ hN
(fun q hq hd => (Lemma.P83.key n q hq hd).1)
refine ⟨q, ⟨hq, hq4⟩, ?_⟩
by_contra hle
push_neg at hle
exact (Lemma.P83.key n q hq hqd).2 (Lemma.P83.dvd_Q n q (by omega) hle)
Attempts
Nobody has worked on this yet.
Chat about it
No messages yet.
Messages in the program's chat that name primes_mod_8_eq_3 or one of its units.