Lean / Reader
Lean reader

Erdos850.lean

37 lines1 declarationsno sorryimports Mathlib.Data.Nat.PrimeFin Mathlib.Tactic
  1. import Mathlib.Data.Nat.PrimeFin
  2. import Mathlib.Tactic
  3. namespace Erdos850
  4. theorem quadratic_family_excluded (x : ℕ) (hx : 0 < x) :
  5. (x + 2).primeFactors ≠ (x * (x + 2) + 2).primeFactors := by
  6. intro heq
  7. have common {p : ℕ} (h : p ∈ (x + 2).primeFactors) : p = 2 := by
  8. have h₁ := Nat.mem_primeFactors.mp h
  9. have h₂ := Nat.mem_primeFactors.mp (heq ▸ h)
  10. have hmul : p ∣ x * (x + 2) := dvd_mul_of_dvd_right h₁.2.1 _
  11. have hd : p ∣ 2 := (Nat.dvd_add_right hmul).mp h₂.2.1
  12. exact (Nat.prime_two.eq_one_or_self_of_dvd p hd).resolve_left h₁.1.ne_one
  13. have hp := Nat.minFac_prime (n := x + 2) (by omega)
  14. have heven : 2 ∣ x + 2 := by
  15. have h := Nat.minFac_dvd (x + 2)
  16. rwa [common (Nat.mem_primeFactors.mpr ⟨hp, h, by omega⟩)] at h
  17. obtain ⟨t, ht⟩ : 2 ∣ x := by omega
  18. let m := 2 * t * (t + 1) + 1
  19. have hm : 1 < m := by dsimp [m]; nlinarith
  20. have hid : x * (x + 2) + 2 = 2 * m := by dsimp [m]; rw [ht]; ring
  21. have hd : m.minFac ∣ 2 * m := dvd_mul_of_dvd_right (Nat.minFac_dvd m) _
  22. have hmem : m.minFac ∈ (x * (x + 2) + 2).primeFactors := by
  23. rw [hid]
  24. exact Nat.mem_primeFactors.mpr ⟨Nat.minFac_prime (by omega), hd, by omega⟩
  25. have htwo := common (heq.symm ▸ hmem)
  26. have hd' := Nat.minFac_dvd m
  27. rw [htwo] at hd'
  28. dsimp [m] at hd'
  29. rw [show 2*t*(t+1) = 2*(t*(t+1)) by ring] at hd'
  30. omega
  31. #print axioms quadratic_family_excluded
  32. end Erdos850