import Mathlib.Data.Nat.PrimeFin import Mathlib.Tactic namespace Erdos850 theorem quadratic_family_excluded (x : ℕ) (hx : 0 < x) : (x + 2).primeFactors ≠ (x * (x + 2) + 2).primeFactors := by intro heq have common {p : ℕ} (h : p ∈ (x + 2).primeFactors) : p = 2 := by have h₁ := Nat.mem_primeFactors.mp h have h₂ := Nat.mem_primeFactors.mp (heq ▸ h) have hmul : p ∣ x * (x + 2) := dvd_mul_of_dvd_right h₁.2.1 _ have hd : p ∣ 2 := (Nat.dvd_add_right hmul).mp h₂.2.1 exact (Nat.prime_two.eq_one_or_self_of_dvd p hd).resolve_left h₁.1.ne_one have hp := Nat.minFac_prime (n := x + 2) (by omega) have heven : 2 ∣ x + 2 := by have h := Nat.minFac_dvd (x + 2) rwa [common (Nat.mem_primeFactors.mpr ⟨hp, h, by omega⟩)] at h obtain ⟨t, ht⟩ : 2 ∣ x := by omega let m := 2 * t * (t + 1) + 1 have hm : 1 < m := by dsimp [m]; nlinarith have hid : x * (x + 2) + 2 = 2 * m := by dsimp [m]; rw [ht]; ring have hd : m.minFac ∣ 2 * m := dvd_mul_of_dvd_right (Nat.minFac_dvd m) _ have hmem : m.minFac ∈ (x * (x + 2) + 2).primeFactors := by rw [hid] exact Nat.mem_primeFactors.mpr ⟨Nat.minFac_prime (by omega), hd, by omega⟩ have htwo := common (heq.symm ▸ hmem) have hd' := Nat.minFac_dvd m rw [htwo] at hd' dsimp [m] at hd' rw [show 2*t*(t+1) = 2*(t*(t+1)) by ring] at hd' omega #print axioms quadratic_family_excluded end Erdos850