import OMAStatements.S_mo_504184 import Mathlib namespace OMA.R_mo_504184_R1 def H1 : Prop := ∃ k : ℕ, 30000 ≤ k ∧ k % 3 ≠ 0 ∧ (k ^ 2 + 1).Prime def H2 : Prop := ∀ B : ℤ, (30000 : ℤ) ≤ B → ∃ x : ℤ, B < x ∧ ∀ p : ℕ, p.Prime → (p : ℤ) ∣ x ^ 2 + 1 → p % 3 ≠ 1 lemma landau_mod3_prime_valid {k : ℕ} (hk3 : k % 3 ≠ 0) (hpr : (k ^ 2 + 1).Prime) : ∀ p : ℕ, p.Prime → (p : ℤ) ∣ (k : ℤ) ^ 2 + 1 → p % 3 ≠ 1 := by intro p hp hdvd have hcast : ((k : ℤ) ^ 2 + 1) = ((k ^ 2 + 1 : ℕ) : ℤ) := by push_cast; ring rw [hcast] at hdvd have hdvd_nat : p ∣ k ^ 2 + 1 := Int.ofNat_dvd.mp hdvd rcases hpr.eq_one_or_self_of_dvd p hdvd_nat with rfl | rfl · exact absurd rfl hp.ne_one · have hmod : (k ^ 2 + 1) % 3 = 2 := by have hr : k % 3 = 1 ∨ k % 3 = 2 := by omega rcases hr with hr | hr <;> rw [sq, Nat.add_mod, Nat.mul_mod, hr] omega theorem main : H1 → H2 → type_of% @OMA.S_mo_504184.main := by intro h1 h2 hfin obtain ⟨B, hB⟩ := hfin.bddAbove by_cases hb : B < 30000 · obtain ⟨k, hk_ge, hk3, hpr⟩ := h1 have hmem : (k : ℤ) ∈ {x : ℤ | ∀ p : ℕ, p.Prime → (p : ℤ) ∣ x ^ 2 + 1 → p % 3 ≠ 1} := landau_mod3_prime_valid hk3 hpr have hle : (k : ℤ) ≤ B := hB hmem omega · obtain ⟨x, hx_gt, hx_mem⟩ := h2 B (by omega) have hle : x ≤ B := hB hx_mem omega end OMA.R_mo_504184_R1