-- Rational roots of monic integer cubics are integers, and the two -- integer cubics behind doubling the cube and trisecting the angle have -- no integer root: z³ ≠ 2 and z³ ≠ 3z + 1. -- Part of Cumulus, the Grace17 mathematics library. -- Copyright (c) 2026 Grant Passmore. -- Released under the Apache License 2.0. See LICENSE in the repository root. -- Authors: Grant Passmore module Grace.Cumulus.NumberTheory.CubicIntegerRoots import Grace.Cumulus.Algebra.Field.CubicConjugation import Grace.Cumulus.NumberTheory.ReducedFraction import Grace.Cumulus.Real.Rationals -- The rational root theorem for monic cubics -- x = p/q in lowest terms; q³ · cubic(x) = 0 gives the integer equation -- p³ + a p² q + b p q² + c q³ = 0 by realInt.injective, so q divides p³ -- and q = ±1 by IntegerCoprime.divides_cube. theorem cubic.rational_root_integer (a b c : Integer) (x : Real) requires xIn : x ∈ rationalReals requires root : cubic(realInt(a), realInt(b), realInt(c), x) = 0 shows ∃ z ∈ ℤ, x = realInt(z) proof have xQuotient := rationalReals.quotient at x obtain ⟨p, pIn, q, qIn, qNonzero, quotient⟩ := xQuotient.forward with xIn obtain ⟨p2, p2In, q2, q2In, q2Nonzero, coprime, cross⟩ := Integer.reduced_fraction at p, q with qNonzero -- The quotient in lowest terms: x · q2 = p2, by canceling q. have crossReal : (realInt(p):R) * realInt(q2) = (realInt(p2):R) * realInt(q) rw [← realInt.mul, ← realInt.mul, cross] rfl have qRealNonzero := realInt.nonzero at q with qNonzero have product : (x * realInt(q2) - realInt(p2)) * realInt(q) = 0 linear_combination realInt(q2) * quotient + crossReal have reduced : x * realInt(q2) = realInt(p2) rcases realMulValue.eq_zero_or at x * realInt(q2) - realInt(p2), realInt(q) with product with first | second . linarith . exfalso exact qRealNonzero with second -- Multiply the cubic equation by q2³ and read it in ℤ. unfold cubic at root have polynomial : realInt(p2) * realInt(p2) * realInt(p2) + realInt(a) * (realInt(p2) * realInt(p2)) * realInt(q2) + realInt(b) * realInt(p2) * (realInt(q2) * realInt(q2)) + realInt(c) * (realInt(q2) * realInt(q2) * realInt(q2)) = 0 linear_combination (realInt(q2) * realInt(q2) * realInt(q2)) * root - (realInt(p2) * realInt(p2) + realInt(p2) * x * realInt(q2) + x * realInt(q2) * (x * realInt(q2)) + realInt(a) * realInt(q2) * (realInt(p2) + x * realInt(q2)) + realInt(b) * realInt(q2) * realInt(q2)) * reduced have integerEquation : p2 * p2 * p2 + a * (p2 * p2) * q2 + b * p2 * (q2 * q2) + c * (q2 * q2 * q2) = 0 apply realInt.injective simp [realInt.add, realInt.mul, realInt.zero, polynomial] -- q2 divides p2³, so q2 is a unit. have divides : IntegerDivides(q2, p2 * p2 * p2) witness -(a * (p2 * p2) + b * p2 * q2 + c * (q2 * q2)) linear_combination -integerEquation have symmetric := IntegerCoprime.symmetric at p2, q2 with coprime rcases IntegerCoprime.divides_cube at p2, q2 with symmetric, divides with one | negOne . refine ⟨p2, p2In, _⟩ rw [one, realInt.one] at reduced linear_combination reduced . have negInteger := integerNegValue.integer at p2 refine ⟨integerNegValue(p2), negInteger, _⟩ rw [negOne, realInt.neg, realInt.one] at reduced rw realInt.neg linear_combination -reduced -- The two integer cubics -- The magnitude n = |z| has n³ = 2 in ℕ, so n divides 2 and n ≤ 2 -- (divides.le); n = 0 and n = 1 fail at once, and n = 2 fails by -- computation. theorem cube.ne_two (z : Integer) shows z * z * z ≠ integerOfNat(2) proof intro cubeEq have magnitudes : integerNatAbs(z) * integerNatAbs(z) * integerNatAbs(z) = 2 have two := integerNatAbs.ofNat at 2 rw [← integerNatAbs.mul, ← integerNatAbs.mul, cubeEq, two] rfl have dividesTwo : integerNatAbs(z) ∣ 2 witness integerNatAbs(z) * integerNatAbs(z) rw ← magnitudes ring have twoNonzero : (2:N) ≠ 0 by compute have below := divides.le at integerNatAbs(z), 2 with dividesTwo, twoNonzero have nonzero : integerNatAbs(z) ≠ 0 intro zero rw zero at magnitudes simp at magnitudes have notOne : integerNatAbs(z) ≠ 1 intro one rw one at magnitudes simp at magnitudes have two : integerNatAbs(z) = 2 by arith rw two at magnitudes simp at magnitudes -- z · (z² − 3) = 1 makes z a unit, and z = ±1 fails by computation. theorem cube.ne_three_self_plus_one (z : Integer) shows z * z * z ≠ integerOfNat(3) * z + 1 proof intro cubeEq have unit : IntegerDivides(z, integerOne) witness z * z - integerOfNat(3) linear_combination cubeEq rcases IntegerDivides.unit_iff.forward with unit with one | negOne . rw one at cubeEq have shape : integerOfNat(3) = integerOfNat(0) rw integerOfNat.zero linear_combination -cubeEq have same := integerOfNat.injective with shape simp at same . rw negOne at cubeEq have shape : integerOfNat(3) = integerOfNat(1 + 1) rw [integerOfNat.add, integerOfNat.one] linear_combination cubeEq have same := integerOfNat.injective with shape simp at same -- The two cubics over the rationals -- x³ − 2 and x³ − 3x − 1 have no rational root: a rational root is an -- integer root. theorem cubic.no_rational_cube_root_two (x : Real) requires xIn : x ∈ rationalReals shows cubic((0:R), (0:R), -(2:R), x) ≠ 0 proof intro root have twoInt : realInt(-integerOfNat(2)) = -(2:R) rw [realInt.neg, realInt.nat, ← realNumeral.nat] rfl have rootInt : cubic(realInt(integerZero), realInt(integerZero), realInt(-integerOfNat(2)), x) = 0 rw [realInt.zero, twoInt] exact root obtain ⟨z, zIn, shape⟩ := cubic.rational_root_integer at integerZero, integerZero, -integerOfNat(2), x with xIn, rootInt rw shape at root unfold cubic at root have cubeEq : realInt(z * z * z) = realInt(integerOfNat(2)) rw [realInt.mul, realInt.mul, realInt.nat, ← realNumeral.nat] linear_combination root have same := realInt.injective at z * z * z, integerOfNat(2) with cubeEq exact cube.ne_two at z with same theorem cubic.no_rational_trisection_root (x : Real) requires xIn : x ∈ rationalReals shows cubic((0:R), -(3:R), -(1:R), x) ≠ 0 proof intro root have threeInt : realInt(-integerOfNat(3)) = -(3:R) rw [realInt.neg, realInt.nat, ← realNumeral.nat] rfl have oneInt : realInt(-integerOne) = -(1:R) rw [realInt.neg, realInt.one] rfl have rootInt : cubic(realInt(integerZero), realInt(-integerOfNat(3)), realInt(-integerOne), x) = 0 rw [realInt.zero, threeInt, oneInt] exact root obtain ⟨z, zIn, shape⟩ := cubic.rational_root_integer at integerZero, -integerOfNat(3), -integerOne, x with xIn, rootInt rw shape at root unfold cubic at root have cubeEq : realInt(z * z * z) = realInt(integerOfNat(3) * z + 1) rw [realInt.mul, realInt.mul, realInt.add, realInt.mul, realInt.nat, ← realNumeral.nat, realInt.one] linear_combination root have same := realInt.injective at z * z * z, integerOfNat(3) * z + 1 with cubeEq exact cube.ne_three_self_plus_one at z with same