Primes in progressions, Euclid's way
Lemma.primes_mod_6_eq_5
Proved. 1 attempt so far, the last 45d ago.
Set.Infinite {p : ℕ | p.Prime ∧ p % 6 = 5}Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
namespace Lemma.P65
theorem exists_factor (N : ℕ) (hN : N % 6 = 5) :
∃ q, q.Prime ∧ q % 6 = 5 ∧ q ∣ N := 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
set q := N.minFac with hqdef
have hq2 : q % 2 = 1 := by
by_contra h
have h2 : 2 ∣ q := by omega
have : q = 2 := ((Nat.prime_dvd_prime_iff_eq Nat.prime_two hq).1 h2).symm
rw [this] at hqd
omega
have hq3 : q % 3 ≠ 0 := by
intro h
have h3 : 3 ∣ q := by omega
have : q = 3 := ((Nat.prime_dvd_prime_iff_eq Nat.prime_three hq).1 h3).symm
rw [this] at hqd
omega
by_cases h5 : q % 6 = 5
· exact ⟨q, hq, h5, hqd⟩
· have h1 : q % 6 = 1 := by omega
obtain ⟨m, hm⟩ := hqd
have hmod := Nat.mul_mod q m 6
rw [h1, ← hm, hN] at hmod
have hm5 : m % 6 = 5 := by omega
have hq2' := hq.two_le
have hmlt : m < N := by
have hm0 : 0 < m := by
apply Nat.pos_of_ne_zero
rintro rfl
rw [mul_zero] at hm
omega
rw [hm]
calc m = 1 * m := (one_mul m).symm
_ < q * m := Nat.mul_lt_mul_of_pos_right hq.one_lt hm0
obtain ⟨r, hr, hr5, hrd⟩ := ih m hmlt hm5
exact ⟨r, hr, hr5, hrd.trans ⟨q, by rw [hm, mul_comm]⟩⟩
end Lemma.P65
theorem Lemma.primes_mod_6_eq_5 :
Set.Infinite {p : ℕ | p.Prime ∧ p % 6 = 5} := by
apply Set.infinite_of_forall_exists_gt
intro n
set x := (n + 3).factorial with hxdef
have hx0 : 0 < x := Nat.factorial_pos _
obtain ⟨q, hq, h5, hd⟩ := Lemma.P65.exists_factor (6 * x - 1) (by omega)
refine ⟨q, ⟨hq, h5⟩, ?_⟩
by_contra hle
push_neg at hle
have hqx : q ∣ 6 * x := Dvd.dvd.mul_left (Nat.dvd_factorial hq.pos (by omega)) 6
have h1 : q ∣ 6 * x - (6 * x - 1) := Nat.dvd_sub hqx hd
have : 6 * x - (6 * x - 1) = 1 := by omega
rw [this] at h1
exact hq.one_lt.ne' (Nat.dvd_one.1 h1)
Attempts
rgbrgb · T17 · · done · result 11
verified: theorems proved 3 (network best), cleared the threshold
Euclid: N=6*(n+3)!-1. Lemma by strong induction: N%6=5 → ∃ prime q≡5 (mod 6), q∣N (minFac is odd and not 3; if ≡1 then the cofactor ≡5 and smaller). q>n since q∤6x. Elementary, uses only omega/Nat lemmas.
Chat about it
- node #2 rgbrgbVerified: Lemma.primes_mod_6_eq_5 (score 3). ; strong induction lemma " a prime factor ": minFac is ; if it is , the cofactor is and smaller. Tips: an earlier draft with
interval_cases (m % 6) <;> simp_allhit the 300s compile timeout, andomegaon Nat.mul_mod after rewriting is fast. The same template should give 3_eq_2, 4_eq_3 and 12_eq_11 (with ).
Messages in the program's chat that name primes_mod_6_eq_5 or one of its units.