Grace/Cumulus/NumberTheory/CubicIntegerRoots.g17
Imports
Grace.Cumulus.Algebra.Field.CubicConjugation · Grace.Cumulus.NumberTheory.ReducedFraction · Grace.Cumulus.Real.Rationals
Declarations
- cubic.rational_root_integer theorem derivation
- cube.ne_two theorem derivation
- cube.ne_three_self_plus_one theorem derivation
- cubic.no_rational_cube_root_two theorem derivation
- cubic.no_rational_trisection_root theorem derivation
Source
1-- Rational roots of monic integer cubics are integers, and the two2-- integer cubics behind doubling the cube and trisecting the angle have3-- no integer root: z³ ≠ 2 and z³ ≠ 3z + 1.4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.NumberTheory.CubicIntegerRoots10import Grace.Cumulus.Algebra.Field.CubicConjugation11import Grace.Cumulus.NumberTheory.ReducedFraction12import Grace.Cumulus.Real.Rationals1314-- The rational root theorem for monic cubics1516-- x = p/q in lowest terms; q³ · cubic(x) = 0 gives the integer equation17-- p³ + a p² q + b p q² + c q³ = 0 by realInt.injective, so q divides p³18-- and q = ±1 by IntegerCoprime.divides_cube.19theorem cubic.rational_root_integer (a b c : Integer) (x : Real)20 requires xIn : x ∈ rationalReals21 requires root : cubic(realInt(a), realInt(b), realInt(c), x) = 022 shows ∃ z ∈ ℤ, x = realInt(z)23proof24 have xQuotient := rationalReals.quotient at x25 obtain ⟨p, pIn, q, qIn, qNonzero, quotient⟩ := xQuotient.forward with xIn26 obtain ⟨p2, p2In, q2, q2In, q2Nonzero, coprime, cross⟩ :=27 Integer.reduced_fraction at p, q with qNonzero28 -- The quotient in lowest terms: x · q2 = p2, by canceling q.29 have crossReal : (realInt(p):R) * realInt(q2) = (realInt(p2):R) * realInt(q)30 rw [← realInt.mul, ← realInt.mul, cross]31 rfl32 have qRealNonzero := realInt.nonzero at q with qNonzero33 have product : (x * realInt(q2) - realInt(p2)) * realInt(q) = 034 linear_combination realInt(q2) * quotient + crossReal35 have reduced : x * realInt(q2) = realInt(p2)36 rcases realMulValue.eq_zero_or at x * realInt(q2) - realInt(p2),37 realInt(q) with product with first | second38 . linarith39 . exfalso40 exact qRealNonzero with second41 -- Multiply the cubic equation by q2³ and read it in ℤ.42 unfold cubic at root43 have polynomial : realInt(p2) * realInt(p2) * realInt(p2)44 + realInt(a) * (realInt(p2) * realInt(p2)) * realInt(q2)45 + realInt(b) * realInt(p2) * (realInt(q2) * realInt(q2))46 + realInt(c) * (realInt(q2) * realInt(q2) * realInt(q2)) = 047 linear_combination (realInt(q2) * realInt(q2) * realInt(q2)) * root48 - (realInt(p2) * realInt(p2) + realInt(p2) * x * realInt(q2)49 + x * realInt(q2) * (x * realInt(q2))50 + realInt(a) * realInt(q2) * (realInt(p2) + x * realInt(q2))51 + realInt(b) * realInt(q2) * realInt(q2)) * reduced52 have integerEquation : p2 * p2 * p2 + a * (p2 * p2) * q253 + b * p2 * (q2 * q2) + c * (q2 * q2 * q2) = 054 apply realInt.injective55 simp [realInt.add, realInt.mul, realInt.zero, polynomial]56 -- q2 divides p2³, so q2 is a unit.57 have divides : IntegerDivides(q2, p2 * p2 * p2)58 witness -(a * (p2 * p2) + b * p2 * q2 + c * (q2 * q2))59 linear_combination -integerEquation60 have symmetric := IntegerCoprime.symmetric at p2, q2 with coprime61 rcases IntegerCoprime.divides_cube at p2, q2 with symmetric, divides62 with one | negOne63 . refine ⟨p2, p2In, _⟩64 rw [one, realInt.one] at reduced65 linear_combination reduced66 . have negInteger := integerNegValue.integer at p267 refine ⟨integerNegValue(p2), negInteger, _⟩68 rw [negOne, realInt.neg, realInt.one] at reduced69 rw realInt.neg70 linear_combination -reduced7172-- The two integer cubics7374-- The magnitude n = |z| has n³ = 2 in ℕ, so n divides 2 and n ≤ 275-- (divides.le); n = 0 and n = 1 fail at once, and n = 2 fails by76-- computation.77theorem cube.ne_two (z : Integer)78 shows z * z * z ≠ integerOfNat(2)79proof80 intro cubeEq81 have magnitudes : integerNatAbs(z) * integerNatAbs(z) * integerNatAbs(z) = 282 have two := integerNatAbs.ofNat at 283 rw [← integerNatAbs.mul, ← integerNatAbs.mul, cubeEq, two]84 rfl85 have dividesTwo : integerNatAbs(z) ∣ 286 witness integerNatAbs(z) * integerNatAbs(z)87 rw ← magnitudes88 ring89 have twoNonzero : (2:N) ≠ 0 by compute90 have below := divides.le at integerNatAbs(z), 2 with dividesTwo, twoNonzero91 have nonzero : integerNatAbs(z) ≠ 092 intro zero93 rw zero at magnitudes94 simp at magnitudes95 have notOne : integerNatAbs(z) ≠ 196 intro one97 rw one at magnitudes98 simp at magnitudes99 have two : integerNatAbs(z) = 2 by arith100 rw two at magnitudes101 simp at magnitudes102103-- z · (z² − 3) = 1 makes z a unit, and z = ±1 fails by computation.104theorem cube.ne_three_self_plus_one (z : Integer)105 shows z * z * z ≠ integerOfNat(3) * z + 1106proof107 intro cubeEq108 have unit : IntegerDivides(z, integerOne)109 witness z * z - integerOfNat(3)110 linear_combination cubeEq111 rcases IntegerDivides.unit_iff.forward with unit with one | negOne112 . rw one at cubeEq113 have shape : integerOfNat(3) = integerOfNat(0)114 rw integerOfNat.zero115 linear_combination -cubeEq116 have same := integerOfNat.injective with shape117 simp at same118 . rw negOne at cubeEq119 have shape : integerOfNat(3) = integerOfNat(1 + 1)120 rw [integerOfNat.add, integerOfNat.one]121 linear_combination cubeEq122 have same := integerOfNat.injective with shape123 simp at same124125-- The two cubics over the rationals126127-- x³ − 2 and x³ − 3x − 1 have no rational root: a rational root is an128-- integer root.129theorem cubic.no_rational_cube_root_two (x : Real)130 requires xIn : x ∈ rationalReals131 shows cubic((0:R), (0:R), -(2:R), x) ≠ 0132proof133 intro root134 have twoInt : realInt(-integerOfNat(2)) = -(2:R)135 rw [realInt.neg, realInt.nat, ← realNumeral.nat]136 rfl137 have rootInt : cubic(realInt(integerZero), realInt(integerZero),138 realInt(-integerOfNat(2)), x) = 0139 rw [realInt.zero, twoInt]140 exact root141 obtain ⟨z, zIn, shape⟩ := cubic.rational_root_integer142 at integerZero, integerZero, -integerOfNat(2), x with xIn, rootInt143 rw shape at root144 unfold cubic at root145 have cubeEq : realInt(z * z * z) = realInt(integerOfNat(2))146 rw [realInt.mul, realInt.mul, realInt.nat, ← realNumeral.nat]147 linear_combination root148 have same := realInt.injective at z * z * z, integerOfNat(2) with cubeEq149 exact cube.ne_two at z with same150151theorem cubic.no_rational_trisection_root (x : Real)152 requires xIn : x ∈ rationalReals153 shows cubic((0:R), -(3:R), -(1:R), x) ≠ 0154proof155 intro root156 have threeInt : realInt(-integerOfNat(3)) = -(3:R)157 rw [realInt.neg, realInt.nat, ← realNumeral.nat]158 rfl159 have oneInt : realInt(-integerOne) = -(1:R)160 rw [realInt.neg, realInt.one]161 rfl162 have rootInt : cubic(realInt(integerZero), realInt(-integerOfNat(3)),163 realInt(-integerOne), x) = 0164 rw [realInt.zero, threeInt, oneInt]165 exact root166 obtain ⟨z, zIn, shape⟩ := cubic.rational_root_integer167 at integerZero, -integerOfNat(3), -integerOne, x with xIn, rootInt168 rw shape at root169 unfold cubic at root170 have cubeEq : realInt(z * z * z) = realInt(integerOfNat(3) * z + 1)171 rw [realInt.mul, realInt.mul, realInt.add, realInt.mul, realInt.nat,172 ← realNumeral.nat, realInt.one]173 linear_combination root174 have same := realInt.injective at z * z * z, integerOfNat(3) * z + 1175 with cubeEq176 exact cube.ne_three_self_plus_one at z with same177