import Mathlib.Tactic.Ringimport Mathlib.Tactic.Linarithimport Mathlib.Data.ZMod.Basic/-!# Round 9: the elementary steps of Theorem B (extensions of Theorem A)Theorem B extends Theorem A to `C` with all prime exponents odd and to `C ≡ 6 (mod 9)` with `3 ∥ C`. This filechecks the new identities and congruences; the class-group step and the divisibility arguments are on paper.-/namespace BealCubeDescent2/-- `3 ∣ C`, integral case: with `cv² = Cⁿ/9`, `3X = u(3u² - Cⁿ)`; from `Cⁿ = 27(u² - ε)` this is `3u(9ε - 8u²)`. -/theorem three_div_identity (u P ε : ℤ) (h : P = 27 * (u ^ 2 - ε)) :u * (3 * u ^ 2 - P) = 3 * (u * (9 * ε - 8 * u ^ 2)) := bysubst hring/-- `3 ∣ C`, half-integral case: from `Cⁿ = 27(u² + 8)`, `u(3u² - Cⁿ) = -24·u(u² + 9)`. -/theorem three_div_identity_half (u P : ℤ) (h : P = 27 * (u ^ 2 + 8)) :u * (3 * u ^ 2 - P) = -24 * (u * (u ^ 2 + 9)) := bysubst hring/-- `8s⁴ - 9` is never a square (mod 8). -/theorem not_sq_8_minus_9 (s t : ℤ) : t ^ 2 ≠ 8 * s ^ 4 - 9 := 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/-- `72s⁴ - 1` is never a square (mod 8). -/theorem not_sq_72_minus_1 (s t : ℤ) : t ^ 2 ≠ 72 * s ^ 4 - 1 := 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/-- For odd `s`, `s⁴ + 9` is not a square (mod 8). -/theorem odd_not_sq_plus_9 (s t : ℤ) (hs : s % 2 = 1) : t ^ 2 ≠ s ^ 4 + 9 := byintro hobtain ⟨k, rfl⟩ : ∃ k, s = 2 * k + 1 := ⟨s / 2, by omega⟩have h8 := congrArg (fun z : ℤ => (z : ZMod 8)) hpush_cast at h8generalize (t : ZMod 8) = a at h8generalize (k : ZMod 8) = c at h8revert a cdecide/-- Case (b) of `3 ∣ C`: if `3 ∤ v` and `c ≡ 2 (mod 3)`, then `3 ∤ u² - cv²`. -/theorem mod3_case_b (u v c : ZMod 3) (hv : v ≠ 0) (hc : c = 2) : u ^ 2 - c * v ^ 2 ≠ 0 := bysubst hcrevert u vdecideend BealCubeDescent2#print axioms BealCubeDescent2.odd_not_sq_plus_9#print axioms BealCubeDescent2.three_div_identity