Lean / Reader
Lean reader

BealPartial.lean

227 lines16 declarationsno sorryimports Mathlib
  1. import Mathlib
  2. /-!
  3. # Beal's conjecture: cases that follow from Mathlib, reductions, and two lemmas
  4. Beal's conjecture: if `A^x + B^y = C^z` with positive integers and `x, y, z > 2`, then `A, B, C` have a common
  5. prime factor. `bealConjecture` below is copied word for word from Formal Conjectures
  6. (`FormalConjectures/Wikipedia/BealConjecture.lean`), which also proves `bealConjecture → FermatLastTheorem`.
  7. Nothing here proves the conjecture. What is proved:
  8. * `not_sum_of_three_dvd`: no solutions at all when `3` divides all three exponents (Mathlib's FLT for `n = 3`).
  9. * `not_sum_of_four_four_two`: no solutions when `4 ∣ x`, `4 ∣ y`, `2 ∣ z` (Fermat: `a⁴ + b⁴ = c²` has none).
  10. * `not_sum_of_common_dvd`: assuming `FermatLastTheorem` (stated in Mathlib, not proved there), no solutions when the
  11. three exponents have a common divisor `g ≥ 3`.
  12. * `coprime_of_gcd_eq_one`: in a counterexample `A, B, C` are pairwise coprime.
  13. * `bealConjecture_of_reduced`: it suffices to treat exponents in `{4} ∪ {odd primes}`.
  14. * `abc_quality_bound`: if `m ≤ x, y, z` then `(A·B·C)^m < (C^z)^3`, so a counterexample is an abc triple of quality
  15. greater than `m/3` (for `m = 5`, above the largest quality known).
  16. * `gcd_sum_cubes_factors`: the first step of the classical attack on `A³ + B³ = Cⁿ`.
  17. -/
  18. namespace BealPartial
  19. /-- Beal's conjecture, copied from Formal Conjectures (`BealConjecture.bealConjecture`). -/
  20. def bealConjecture : Prop := ∀ {A B C x y z : ℕ},
  21. A ≠ 0 → B ≠ 0 → C ≠ 0 → 2 < x → 2 < y → 2 < z →
  22. A^x + B^y = C^z → 1 < Finset.gcd {A, B, C} id
  23. /-- Beal's conclusion for one exponent triple `(x, y, z)`. -/
  24. def BealFor (x y z : ℕ) : Prop := ∀ {A B C : ℕ},
  25. A ≠ 0 → B ≠ 0 → C ≠ 0 → A^x + B^y = C^z → 1 < Finset.gcd {A, B, C} id
  26. theorem bealConjecture_iff :
  27. bealConjecture ↔ ∀ x y z : ℕ, 2 < x → 2 < y → 2 < z → BealFor x y z := by
  28. constructor
  29. · intro h x y z hx hy hz A B C hA hB hC hs
  30. exact h hA hB hC hx hy hz hs
  31. · intro h A B C x y z hA hB hC hx hy hz hs
  32. exact h x y z hx hy hz hA hB hC hs
  33. theorem gcd_triple (A B C : ℕ) : Finset.gcd {A, B, C} id = Nat.gcd A (Nat.gcd B C) := by
  34. simp [Finset.gcd_insert, Finset.gcd_singleton]
  35. rfl
  36. /-! ## Cases that follow from Fermat's Last Theorem for exponents 3 and 4 (both in Mathlib) -/
  37. /-- If `3` divides all three exponents there is no solution at all: `fermatLastTheoremThree`. -/
  38. theorem not_sum_of_three_dvd {A B C x y z : ℕ} (hA : A ≠ 0) (hB : B ≠ 0) (hC : C ≠ 0)
  39. (hx : 3 ∣ x) (hy : 3 ∣ y) (hz : 3 ∣ z) : A ^ x + B ^ y ≠ C ^ z := by
  40. obtain ⟨a, rfl⟩ := hx
  41. obtain ⟨b, rfl⟩ := hy
  42. obtain ⟨c, rfl⟩ := hz
  43. rw [pow_mul', pow_mul', pow_mul']
  44. exact fermatLastTheoremThree (A ^ a) (B ^ b) (C ^ c)
  45. (pow_ne_zero _ hA) (pow_ne_zero _ hB) (pow_ne_zero _ hC)
  46. /-- If `4 ∣ x`, `4 ∣ y` and `2 ∣ z` there is no solution: `a⁴ + b⁴ = c²` has none (`not_fermat_42`). -/
  47. theorem not_sum_of_four_four_two {A B C x y z : ℕ} (hA : A ≠ 0) (hB : B ≠ 0)
  48. (hx : 4 ∣ x) (hy : 4 ∣ y) (hz : 2 ∣ z) : A ^ x + B ^ y ≠ C ^ z := by
  49. obtain ⟨a, rfl⟩ := hx
  50. obtain ⟨b, rfl⟩ := hy
  51. obtain ⟨c, rfl⟩ := hz
  52. intro h
  53. rw [pow_mul', pow_mul', pow_mul'] at h
  54. have h' : ((A ^ a : ℕ) : ℤ) ^ 4 + ((B ^ b : ℕ) : ℤ) ^ 4 = ((C ^ c : ℕ) : ℤ) ^ 2 := by
  55. exact_mod_cast h
  56. exact not_fermat_42 (by exact_mod_cast pow_ne_zero a hA) (by exact_mod_cast pow_ne_zero b hB) h'
  57. /-- Assuming Fermat's Last Theorem (stated in Mathlib, not proved there): a common divisor `g ≥ 3` of the three
  58. exponents rules out solutions. -/
  59. theorem not_sum_of_common_dvd (hFLT : FermatLastTheorem) {A B C x y z g : ℕ}
  60. (hA : A ≠ 0) (hB : B ≠ 0) (hC : C ≠ 0)
  61. (hg : 3 ≤ g) (hx : g ∣ x) (hy : g ∣ y) (hz : g ∣ z) : A ^ x + B ^ y ≠ C ^ z := by
  62. obtain ⟨a, rfl⟩ := hx
  63. obtain ⟨b, rfl⟩ := hy
  64. obtain ⟨c, rfl⟩ := hz
  65. rw [pow_mul', pow_mul', pow_mul']
  66. exact hFLT g hg (A ^ a) (B ^ b) (C ^ c) (pow_ne_zero _ hA) (pow_ne_zero _ hB) (pow_ne_zero _ hC)
  67. theorem bealFor_of_three_dvd {x y z : ℕ} (hx : 3 ∣ x) (hy : 3 ∣ y) (hz : 3 ∣ z) : BealFor x y z := by
  68. intro A B C hA hB hC hs
  69. exact absurd hs (not_sum_of_three_dvd hA hB hC hx hy hz)
  70. theorem bealFor_of_four_four_two {x y z : ℕ} (hx : 4 ∣ x) (hy : 4 ∣ y) (hz : 2 ∣ z) : BealFor x y z := by
  71. intro A B C hA hB _ hs
  72. exact absurd hs (not_sum_of_four_four_two hA hB hx hy hz)
  73. theorem bealFor_of_flt (hFLT : FermatLastTheorem) {x y z g : ℕ} (hg : 3 ≤ g)
  74. (hx : g ∣ x) (hy : g ∣ y) (hz : g ∣ z) : BealFor x y z := by
  75. intro A B C hA hB hC hs
  76. exact absurd hs (not_sum_of_common_dvd hFLT hA hB hC hg hx hy hz)
  77. /-! ## Structure of a counterexample -/
  78. /-- If no prime divides all of `A, B, C` and `A^x + B^y = C^z` (positive exponents), they are pairwise coprime. -/
  79. theorem coprime_of_gcd_eq_one {A B C x y z : ℕ} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0)
  80. (h : A ^ x + B ^ y = C ^ z) (hg : Nat.gcd A (Nat.gcd B C) = 1) :
  81. Nat.Coprime A B ∧ Nat.Coprime A C ∧ Nat.Coprime B C := by
  82. refine ⟨Nat.coprime_of_dvd fun p hp hpA hpB => ?_, Nat.coprime_of_dvd fun p hp hpA hpC => ?_,
  83. Nat.coprime_of_dvd fun p hp hpB hpC => ?_⟩
  84. · have hpC : p ∣ C := hp.dvd_of_dvd_pow (h ▸ dvd_add (dvd_pow hpA hx) (dvd_pow hpB hy))
  85. have h1 : p ∣ Nat.gcd A (Nat.gcd B C) := Nat.dvd_gcd hpA (Nat.dvd_gcd hpB hpC)
  86. rw [hg] at h1
  87. exact hp.one_lt.ne' (Nat.dvd_one.mp h1)
  88. · have hpB : p ∣ B := by
  89. have hs : p ∣ A ^ x + B ^ y := h ▸ dvd_pow hpC hz
  90. exact hp.dvd_of_dvd_pow ((Nat.dvd_add_right (dvd_pow hpA hx)).mp hs)
  91. have h1 : p ∣ Nat.gcd A (Nat.gcd B C) := Nat.dvd_gcd hpA (Nat.dvd_gcd hpB hpC)
  92. rw [hg] at h1
  93. exact hp.one_lt.ne' (Nat.dvd_one.mp h1)
  94. · have hpA : p ∣ A := by
  95. have hs : p ∣ A ^ x + B ^ y := h ▸ dvd_pow hpC hz
  96. exact hp.dvd_of_dvd_pow ((Nat.dvd_add_left (dvd_pow hpB hy)).mp hs)
  97. have h1 : p ∣ Nat.gcd A (Nat.gcd B C) := Nat.dvd_gcd hpA (Nat.dvd_gcd hpB hpC)
  98. rw [hg] at h1
  99. exact hp.one_lt.ne' (Nat.dvd_one.mp h1)
  100. /-! ## Reduction of the exponents -/
  101. /-- Every `n ≥ 3` has a divisor that is `4` or an odd prime. -/
  102. theorem exists_dvd_four_or_odd_prime {n : ℕ} (hn : 3 ≤ n) :
  103. ∃ d, d ∣ n ∧ (d = 4 ∨ (d.Prime ∧ Odd d)) := by
  104. rcases Nat.eq_two_pow_or_exists_odd_prime_and_dvd n with ⟨k, rfl⟩ | ⟨p, hp, hpn, hodd⟩
  105. · refine ⟨4, ?_, Or.inl rfl⟩
  106. have hk : 2 ≤ k := by
  107. rcases Nat.lt_or_ge k 2 with hk | hk
  108. · interval_cases k <;> simp at hn
  109. · exact hk
  110. refine ⟨2 ^ (k - 2), ?_⟩
  111. rw [show (4 : ℕ) = 2 ^ 2 by norm_num, ← pow_add]
  112. congr 1
  113. omega
  114. · exact ⟨p, hpn, Or.inr ⟨hp, hodd⟩⟩
  115. /-- A counterexample for exponents `(x, y, z)` gives one for any divisors `(d, e, f)`. -/
  116. theorem bealFor_of_dvd {x y z d e f : ℕ} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0)
  117. (hd : d ∣ x) (he : e ∣ y) (hf : f ∣ z) (H : BealFor d e f) : BealFor x y z := by
  118. intro A B C hA hB hC hs
  119. obtain ⟨a, rfl⟩ := hd
  120. obtain ⟨b, rfl⟩ := he
  121. obtain ⟨c, rfl⟩ := hf
  122. rw [pow_mul', pow_mul', pow_mul'] at hs
  123. have h1 := H (pow_ne_zero a hA) (pow_ne_zero b hB) (pow_ne_zero c hC) hs
  124. rw [gcd_triple] at h1 ⊢
  125. obtain ⟨p, hp, hpg⟩ := Nat.exists_prime_and_dvd (ne_of_gt h1)
  126. have hpA : p ∣ A := hp.dvd_of_dvd_pow (hpg.trans (Nat.gcd_dvd_left _ _))
  127. have hpB : p ∣ B :=
  128. hp.dvd_of_dvd_pow ((hpg.trans (Nat.gcd_dvd_right _ _)).trans (Nat.gcd_dvd_left _ _))
  129. have hpC : p ∣ C :=
  130. hp.dvd_of_dvd_pow ((hpg.trans (Nat.gcd_dvd_right _ _)).trans (Nat.gcd_dvd_right _ _))
  131. have hpos : 0 < Nat.gcd A (Nat.gcd B C) := Nat.gcd_pos_of_pos_left _ (Nat.pos_of_ne_zero hA)
  132. exact lt_of_lt_of_le hp.one_lt (Nat.le_of_dvd hpos (Nat.dvd_gcd hpA (Nat.dvd_gcd hpB hpC)))
  133. /-- Beal's conjecture follows from its cases with exponents in `{4} ∪ {odd primes}`. -/
  134. theorem bealConjecture_of_reduced
  135. (H : ∀ p q r : ℕ, (p = 4 ∨ (p.Prime ∧ Odd p)) → (q = 4 ∨ (q.Prime ∧ Odd q)) →
  136. (r = 4 ∨ (r.Prime ∧ Odd r)) → BealFor p q r) : bealConjecture := by
  137. rw [bealConjecture_iff]
  138. intro x y z hx hy hz
  139. obtain ⟨d, hd, hd'⟩ := exists_dvd_four_or_odd_prime hx
  140. obtain ⟨e, he, he'⟩ := exists_dvd_four_or_odd_prime hy
  141. obtain ⟨f, hf, hf'⟩ := exists_dvd_four_or_odd_prime hz
  142. exact bealFor_of_dvd (by omega) (by omega) (by omega) hd he hf (H d e f hd' he' hf')
  143. /-! ## A counterexample is an abc triple of high quality -/
  144. /-- If `m ≤ x, y, z` and `A^x + B^y = C^z` with `A, B ≥ 1`, then `(A·B·C)^m < (C^z)^3`. Since
  145. `rad(A^x B^y C^z) = rad(ABC) ≤ ABC`, the abc triple `(A^x, B^y, C^z)` then has quality
  146. `log C^z / log rad > m/3`. -/
  147. theorem abc_quality_bound {A B C x y z m : ℕ} (hA : A ≠ 0) (hB : B ≠ 0)
  148. (hmx : m ≤ x) (hmy : m ≤ y) (hmz : m ≤ z) (h : A ^ x + B ^ y = C ^ z) :
  149. (A * B * C) ^ m < (C ^ z) ^ 3 := by
  150. have hAx0 : 0 < A ^ x := Nat.pos_of_ne_zero (pow_ne_zero x hA)
  151. have hBy0 : 0 < B ^ y := Nat.pos_of_ne_zero (pow_ne_zero y hB)
  152. have hAx : A ^ x < C ^ z := by omega
  153. have hBy : B ^ y < C ^ z := by omega
  154. have hC : C ≠ 0 := by
  155. rintro rfl
  156. rcases Nat.eq_zero_or_pos z with hz | hz
  157. · subst hz
  158. rw [pow_zero] at hAx
  159. omega
  160. · rw [zero_pow hz.ne'] at hAx
  161. omega
  162. have hAm : A ^ m < C ^ z := lt_of_le_of_lt (Nat.pow_le_pow_right (Nat.pos_of_ne_zero hA) hmx) hAx
  163. have hBm : B ^ m < C ^ z := lt_of_le_of_lt (Nat.pow_le_pow_right (Nat.pos_of_ne_zero hB) hmy) hBy
  164. have hCm : C ^ m ≤ C ^ z := Nat.pow_le_pow_right (Nat.pos_of_ne_zero hC) hmz
  165. have hCz : 0 < C ^ z := lt_of_le_of_lt (Nat.zero_le _) hAx
  166. calc (A * B * C) ^ m = A ^ m * B ^ m * C ^ m := by rw [mul_pow, mul_pow]
  167. _ < C ^ z * C ^ z * C ^ z :=
  168. Nat.mul_lt_mul_of_lt_of_le (Nat.mul_lt_mul_of_lt_of_le hAm hBm.le hCz) hCm hCz
  169. _ = (C ^ z) ^ 3 := by ring
  170. /-! ## The first step of the classical attack on `A³ + B³ = Cⁿ` -/
  171. /-- For coprime integers `A, B`, the factors `A + B` and `A² − AB + B²` of `A³ + B³` have gcd dividing `3`.
  172. So a primitive solution of `A³ + B³ = Cⁿ` makes each factor an `n`-th power up to a power of `3`. -/
  173. theorem gcd_sum_cubes_factors {A B : ℤ} (h : IsCoprime A B) :
  174. ((Int.gcd (A + B) (A ^ 2 - A * B + B ^ 2) : ℕ) : ℤ) ∣ 3 := by
  175. have h1 : ((Int.gcd (A + B) (A ^ 2 - A * B + B ^ 2) : ℕ) : ℤ) ∣ A + B := Int.gcd_dvd_left ..
  176. have h2 : ((Int.gcd (A + B) (A ^ 2 - A * B + B ^ 2) : ℕ) : ℤ) ∣ A ^ 2 - A * B + B ^ 2 :=
  177. Int.gcd_dvd_right ..
  178. have hB3 : ((Int.gcd (A + B) (A ^ 2 - A * B + B ^ 2) : ℕ) : ℤ) ∣ 3 * B ^ 2 := by
  179. have e : 3 * B ^ 2 = (A ^ 2 - A * B + B ^ 2) - (A + B) * (A - 2 * B) := by ring
  180. rw [e]
  181. exact dvd_sub h2 (dvd_mul_of_dvd_left h1 _)
  182. have hA3 : ((Int.gcd (A + B) (A ^ 2 - A * B + B ^ 2) : ℕ) : ℤ) ∣ 3 * A ^ 2 := by
  183. have e : 3 * A ^ 2 = (A ^ 2 - A * B + B ^ 2) - (A + B) * (B - 2 * A) := by ring
  184. rw [e]
  185. exact dvd_sub h2 (dvd_mul_of_dvd_left h1 _)
  186. obtain ⟨u, v, huv⟩ := h.pow (m := 2) (n := 2)
  187. have e3 : (3 : ℤ) = u * (3 * A ^ 2) + v * (3 * B ^ 2) := by linear_combination (-3 : ℤ) * huv
  188. rw [e3]
  189. exact dvd_add (dvd_mul_of_dvd_right hA3 _) (dvd_mul_of_dvd_right hB3 _)
  190. end BealPartial
  191. /-! ## Axiom check -/
  192. #print axioms BealPartial.not_sum_of_three_dvd
  193. #print axioms BealPartial.not_sum_of_four_four_two
  194. #print axioms BealPartial.not_sum_of_common_dvd
  195. #print axioms BealPartial.coprime_of_gcd_eq_one
  196. #print axioms BealPartial.bealConjecture_of_reduced
  197. #print axioms BealPartial.abc_quality_bound
  198. #print axioms BealPartial.gcd_sum_cubes_factors