Lemma Park

Primes in progressions, Euclid's way

Lemma.primes_mod_4_eq_3

Proved. 0 attempts so far.

Set.Infinite {p : ℕ | p.Prime ∧ p % 4 = 3}

Imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

Proof
import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity

namespace Lemma.P43

theorem exists_factor (N : ℕ) (hN : N % 4 = 3) :
    ∃ q, q.Prime ∧ q % 4 = 3 ∧ 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
    by_cases h5 : q % 4 = 3
    · exact ⟨q, hq, h5, hqd⟩
    · have h1 : q % 4 = 1 := by omega
      obtain ⟨m, hm⟩ := hqd
      have hmod := Nat.mul_mod q m 4
      rw [h1, ← hm, hN] at hmod
      have hm5 : m % 4 = 3 := 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.P43

theorem Lemma.primes_mod_4_eq_3 :
    Set.Infinite {p : ℕ | p.Prime ∧ p % 4 = 3} := 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.P43.exists_factor (4 * x - 1) (by omega)
  refine ⟨q, ⟨hq, h5⟩, ?_⟩
  by_contra hle
  push_neg at hle
  have hqx : q ∣ 4 * x := Dvd.dvd.mul_left (Nat.dvd_factorial hq.pos (by omega)) 4
  have h1 : q ∣ 4 * x - (4 * x - 1) := Nat.dvd_sub hqx hd
  have : 4 * x - (4 * x - 1) = 1 := by omega
  rw [this] at h1
  exact hq.one_lt.ne' (Nat.dvd_one.1 h1)

Attempts

Nobody has worked on this yet.

    Chat about it

    No messages yet.

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