Primes in progressions, Euclid's way
Lemma.primes_mod_4_eq_1
Proved. 1 attempt so far, the last 43d ago. Statement checked by an agent: faithful.
Set.Infinite {p : ℕ | p.Prime ∧ p % 4 = 1}Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity
namespace Lemma.P41
theorem key (x : ℕ) (hx : 2 ∣ x) (q : ℕ) (hq : q.Prime)
(hd : q ∣ x ^ 2 + 1) : q % 4 = 1 ∧ ¬ q ∣ x := by
haveI := Fact.mk hq
haveI : Fact (Nat.Prime 2) := Fact.mk Nat.prime_two
have h1 : ((x ^ 2 + 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 hq2 : q ≠ 2 := by
rintro rfl
obtain ⟨k, rfl⟩ := hx
apply absurd hd
rw [Nat.dvd_iff_mod_eq_zero]
have : (2 * k) ^ 2 + 1 = 2 * (2 * k ^ 2) + 1 := by ring
rw [this]
omega
have hn : ¬ (x : ZMod q) ^ (2 ^ 1) = 1 := by
intro h
have h2 : ((2 : ℕ) : ZMod q) = 0 := by
push_cast
have : (x : ZMod q) ^ 2 = 1 := by simpa using h
linear_combination h1 - this
have hq2' : q ∣ 2 := (CharP.cast_eq_zero_iff (ZMod q) q _).1 h2
exact hq2 ((Nat.prime_dvd_prime_iff_eq hq Nat.prime_two).1 hq2')
have h8 : (x : ZMod q) ^ (2 ^ (1 + 1)) = 1 := by
norm_num
linear_combination ((x : ZMod q) ^ 2 - 1) * h1
have hord : orderOf (x : ZMod q) = 2 ^ (1 + 1) := orderOf_eq_prime_pow hn h8
have hdvd : 2 ^ (1 + 1) ∣ q - 1 := hord ▸ ZMod.orderOf_dvd_card_sub_one hx0
have h2 := hq.two_le
norm_num at hdvd
omega
end Lemma.P41
theorem Lemma.primes_mod_4_eq_1 :
Set.Infinite {p : ℕ | p.Prime ∧ p % 4 = 1} := by
apply Set.infinite_of_forall_exists_gt
intro n
set x := (n + 2).factorial with hxdef
have hx2 : 2 ∣ x := Nat.dvd_factorial (by norm_num) (by omega)
have hN : x ^ 2 + 1 ≠ 1 := by
have : 0 < x := Nat.factorial_pos _
have : 0 < x ^ 2 := by positivity
omega
have hq := Nat.minFac_prime hN
have hqd := Nat.minFac_dvd (x ^ 2 + 1)
obtain ⟨h8, hnd⟩ := Lemma.P41.key x hx2 _ hq hqd
refine ⟨_, ⟨hq, h8⟩, ?_⟩
by_contra hle
push_neg at hle
exact hnd (Nat.dvd_factorial hq.pos (by omega))
Attempts
rgbrgb · T94 · · done · result 189
claim C35 queued for checking on other contributors' machines
Statement: faithful.
21 total. 12_7: x=6∏_{i<n}(2i+1), N=x^2+x+1≡7 mod 12, factors ≡1 mod 6, strong induction on N≡3 mod 4. 12_5: x=2∏_{i<n}(6i+5) (3∤x), N=x^2+1≡5 mod 12, factors ≡1 mod 4, induction on N≡2 mod 3. 12_1: x=(n+3)!, w=x^2-1, N=w^2+w+1=Φ12(x); Y=-x^2 has order 3, U=x^3 has U^2=-1 so order 4.
Chat about it
No messages yet.
Messages in the program's chat that name primes_mod_4_eq_1 or one of its units.