{"attempts":[],"challenge":{"imports":["Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity"],"name":"Lemma.primes_mod_4_eq_3","statement":"Set.Infinite {p : ℕ | p.Prime ∧ p % 4 = 3}"},"chat":[],"disproof":null,"program":{"checked_by":"nodes","id":"euclid-primes","lean":"v4.34.1","mathlib":"v4.34.1","project":null,"title":"Primes in progressions, Euclid's way"},"proof":"import Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity\n\nnamespace Lemma.P43\n\ntheorem exists_factor (N : ℕ) (hN : N % 4 = 3) :\n    ∃ q, q.Prime ∧ q % 4 = 3 ∧ q ∣ N := by\n  induction N using Nat.strong_induction_on with\n  | _ N ih =>\n    have hN1 : N ≠ 1 := by omega\n    have hq := Nat.minFac_prime hN1\n    have hqd := Nat.minFac_dvd N\n    set q := N.minFac with hqdef\n    have hq2 : q % 2 = 1 := by\n      by_contra h\n      have h2 : 2 ∣ q := by omega\n      have : q = 2 := ((Nat.prime_dvd_prime_iff_eq Nat.prime_two hq).1 h2).symm\n      rw [this] at hqd\n      omega\n    by_cases h5 : q % 4 = 3\n    · exact ⟨q, hq, h5, hqd⟩\n    · have h1 : q % 4 = 1 := by omega\n      obtain ⟨m, hm⟩ := hqd\n      have hmod := Nat.mul_mod q m 4\n      rw [h1, ← hm, hN] at hmod\n      have hm5 : m % 4 = 3 := by omega\n      have hq2' := hq.two_le\n      have hmlt : m < N := by\n        have hm0 : 0 < m := by\n          apply Nat.pos_of_ne_zero\n          rintro rfl\n          rw [mul_zero] at hm\n          omega\n        rw [hm]\n        calc m = 1 * m := (one_mul m).symm\n          _ < q * m := Nat.mul_lt_mul_of_pos_right hq.one_lt hm0\n      obtain ⟨r, hr, hr5, hrd⟩ := ih m hmlt hm5\n      exact ⟨r, hr, hr5, hrd.trans ⟨q, by rw [hm, mul_comm]⟩⟩\n\nend Lemma.P43\n\ntheorem Lemma.primes_mod_4_eq_3 :\n    Set.Infinite {p : ℕ | p.Prime ∧ p % 4 = 3} := by\n  apply Set.infinite_of_forall_exists_gt\n  intro n\n  set x := (n + 3).factorial with hxdef\n  have hx0 : 0 < x := Nat.factorial_pos _\n  obtain ⟨q, hq, h5, hd⟩ := Lemma.P43.exists_factor (4 * x - 1) (by omega)\n  refine ⟨q, ⟨hq, h5⟩, ?_⟩\n  by_contra hle\n  push_neg at hle\n  have hqx : q ∣ 4 * x := Dvd.dvd.mul_left (Nat.dvd_factorial hq.pos (by omega)) 4\n  have h1 : q ∣ 4 * x - (4 * x - 1) := Nat.dvd_sub hqx hd\n  have : 4 * x - (4 * x - 1) = 1 := by omega\n  rw [this] at h1\n  exact hq.one_lt.ne' (Nat.dvd_one.1 h1)\n","proposals":[],"row":{"attempts":0,"blocker":null,"either":false,"last":null,"name":"Lemma.primes_mod_4_eq_3","statement":null,"status":"proved"}}