import Mathlib.Tactic.Ringimport Mathlib.Tactic.Linarithimport Mathlib.Data.ZMod.Basic/-!# Round 8: the elementary steps of Theorem A (A³ = B⁴ + bⁿ, factorization in ℚ(√-b))Theorem A (paper on `A³ = B⁴ + bⁿ`): for squarefree `b ≥ 2` with `b ≢ 7 (mod 8)`, `3 ∤ b` and `3 ∤ h(ℚ(√-b))`, thereis no solution with `gcd(B, b) = 1` for odd `n ≥ 3`. The class-group step and Darmon–Merel are cited; this file checksthe algebraic identities and the congruence obstructions used in the proof.-/namespace BealCubeDescent/-- `(u + v√-b)³ = X + Y√-b` with `X = u(u² - 3bv²)`, `Y = v(3u² - bv²)`; its norm is the cube of the norm of`u + v√-b`. -/theorem cube_norm (u v b : ℤ) :(u * (u ^ 2 - 3 * b * v ^ 2)) ^ 2 + b * (v * (3 * u ^ 2 - b * v ^ 2)) ^ 2 = (u ^ 2 + b * v ^ 2) ^ 3 := byring/-- Integral case: from `3u² - bⁿ = ε` the coordinate `X = u(u² - 3bⁿ)` equals `u(3ε - 8u²)`. -/theorem endgame_identity (u P ε : ℤ) (h : 3 * u ^ 2 - P = ε) :u * (u ^ 2 - 3 * P) = u * (3 * ε - 8 * u ^ 2) := byhave hP : P = 3 * u ^ 2 - ε := by linarithsubst hPring/-- Half-integral case (`b ≡ 3 mod 8`): from `3u² - bⁿ = 8δ`, `u(u² - 3bⁿ) = 8·u(3δ - u²)`. -/theorem half_identity (u P δ : ℤ) (h : 3 * u ^ 2 - P = 8 * δ) :u * (u ^ 2 - 3 * P) = 8 * (u * (3 * δ - u ^ 2)) := byhave hP : P = 3 * u ^ 2 - 8 * δ := by linarithsubst hPring/-- `8s⁴ + 3` is never a square (mod 8). -/theorem not_sq_8_plus (s t : ℤ) : t ^ 2 ≠ 8 * s ^ 4 + 3 := byintro hhave h8 := congrArg (fun z : ℤ => (z : ZMod 8)) hpush_cast at h8generalize (t : ZMod 8) = a at h8generalize (s : ZMod 8) = c at h8revert a cdecide/-- `8s⁴ - 3` is never a square (mod 8). -/theorem not_sq_8_minus (s t : ℤ) : t ^ 2 ≠ 8 * s ^ 4 - 3 := byintro hhave h8 := congrArg (fun z : ℤ => (z : ZMod 8)) hpush_cast at h8generalize (t : ZMod 8) = a at h8generalize (s : ZMod 8) = c at h8revert a cdecide/-- `24s⁴ - 1` is never a square (mod 3). -/theorem not_sq_24_minus (s t : ℤ) : t ^ 2 ≠ 24 * s ^ 4 - 1 := byintro hhave h3 := congrArg (fun z : ℤ => (z : ZMod 3)) hpush_cast at h3generalize (t : ZMod 3) = a at h3generalize (s : ZMod 3) = c at h3revert a cdecide/-- `s⁴ - t² ≠ 3` (mod 8): the half-integral case with `3 ∤ w`, `δ = 1`. -/theorem not_diff_3 (s t : ℤ) : s ^ 4 - t ^ 2 ≠ 3 := byintro hhave h8 := congrArg (fun z : ℤ => (z : ZMod 8)) hpush_cast at h8generalize (t : ZMod 8) = a at h8generalize (s : ZMod 8) = c at h8revert a cdecide/-- The two equations of the case `3 | w`, integral: `t² = 24s⁴ + 1` and `bⁿ = 27s⁴ + 1` give `(3t)² - 1 = 8bⁿ`. -/theorem three_case_identity (s t P : ℤ) (ht : t ^ 2 = 24 * s ^ 4 + 1) (hP : P = 27 * s ^ 4 + 1) :(3 * t - 1) * (3 * t + 1) = 8 * P := bysubst hPhave e : (3 * t - 1) * (3 * t + 1) = 9 * t ^ 2 - 1 := by ringrw [e, ht]ring/-- Half-integral, `3 | w`: `t² = 3s⁴ + 1` and `bⁿ = 27s⁴ + 8` give `(3t - 1)(3t + 1) = bⁿ`. -/theorem three_case_identity_half (s t P : ℤ) (ht : t ^ 2 = 3 * s ^ 4 + 1) (hP : P = 27 * s ^ 4 + 8) :(3 * t - 1) * (3 * t + 1) = P := bysubst hPhave e : (3 * t - 1) * (3 * t + 1) = 9 * t ^ 2 - 1 := by ringrw [e, ht]ringend BealCubeDescent#print axioms BealCubeDescent.not_sq_8_plus#print axioms BealCubeDescent.three_case_identity