Grace/Cumulus/Algebra/Field/CubicConjugation.g17
Imports
Grace.Cumulus.Algebra.Field.QuadraticAdjoin
Declarations
- cubic def
- cubic.real theorem derivation
- cubic.mem instance derivation
- cubic.third_root theorem derivation
- cubic.split theorem derivation
- cubic.conjugate_root theorem derivation
- cubic.root_descends theorem derivation
Source
1-- Monic real cubics and conjugation: a root p + q√d of a cubic over F2-- with √d ∉ F has the conjugate root p − q√d, two distinct roots give the3-- third by Vieta, and a root in F(√d) descends to a root in F.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.Algebra.Field.CubicConjugation10import Grace.Cumulus.Algebra.Field.QuadraticAdjoin1112-- The cubic1314-- The monic cubic x³ + a x² + b x + c, with the cube written as a product15-- so that ring normalizes it.16def cubic (a b c x : Real) : Real := x * x * x + a * (x * x) + b * x + c1718theorem cubic.real (a b c x : Real)19 shows Real(cubic(a, b, c, x))20proof21 unfold cubic22 typecheck2324instance cubic.mem (F : Set) (a b c x : Real)25 requires field : RealSubfield(F)26 requires aIn : a ∈ F27 requires bIn : b ∈ F28 requires cIn : c ∈ F29 requires xIn : x ∈ F30 shows cubic(a, b, c, x) ∈ F31proof32 unfold cubic33 typecheck3435-- Vieta and conjugation3637-- Vieta for two distinct roots. The certificate is38-- (r − s) · cubic(−a − r − s) = (−a − 2s − r) · cubic(r)39-- − (−a − 2r − s) · cubic(s),40-- a ring identity, after which r − s cancels.41theorem cubic.third_root (a b c r s : Real)42 requires rootR : cubic(a, b, c, r) = 043 requires rootS : cubic(a, b, c, s) = 044 requires distinct : r ≠ s45 shows cubic(a, b, c, -a - r - s) = 046proof47 have difference : r - s ≠ 048 intro zero49 apply distinct50 linarith51 have cancel : (r - s) * cubic(a, b, c, -a - r - s) = 052 unfold cubic at rootR53 unfold cubic at rootS54 unfold cubic55 linear_combination (-a - (2:R) * s - r) * rootR -56 (-a - (2:R) * r - s) * rootS57 rcases realMulValue.eq_zero_or with cancel with zero | root58 . exfalso59 exact difference with zero60 . exact root6162-- The value at p ± q√d splits as U ± V√d with U, V polynomial in63-- a, b, c, p, q, d: ring after sqrt.square.64theorem cubic.split (a b c d p q : Real)65 requires dNonneg : (0:R) ≤ d66 shows cubic(a, b, c, p + q * √d) =67 (p * p * p + (3:R) * p * (q * q) * d + a * (p * p + q * q * d) +68 b * p + c) +69 ((3:R) * (p * p) * q + q * q * q * d + (2:R) * a * p * q + b * q) *70 √d ∧71 cubic(a, b, c, p - q * √d) =72 (p * p * p + (3:R) * p * (q * q) * d + a * (p * p + q * q * d) +73 b * p + c) -74 ((3:R) * (p * p) * q + q * q * q * d + (2:R) * a * p * q + b * q) *75 √d76proof77 have nonnegative := NonnegativeReal.of_le with dNonneg78 have square := sqrt.square at d with nonnegative79 constructor80 . unfold cubic81 linear_combination ((3:R) * p * (q * q) + q * q * q * √d + a * (q * q)) *82 square83 . unfold cubic84 linear_combination ((3:R) * p * (q * q) - q * q * q * √d + a * (q * q)) *85 square8687-- U + V√d = 0 with U, V ∈ F and √d ∉ F forces U = V = 0, so U − V√d = 0.88theorem cubic.conjugate_root (F : Set) (d a b c p q : Real)89 requires field : RealSubfield(F)90 requires dIn : d ∈ F91 requires dNonneg : (0:R) ≤ d92 requires rootOut : √d ∉ F93 requires aIn : a ∈ F94 requires bIn : b ∈ F95 requires cIn : c ∈ F96 requires pIn : p ∈ F97 requires qIn : q ∈ F98 requires root : cubic(a, b, c, p + q * √d) = 099 shows cubic(a, b, c, p - q * √d) = 0100proof101 obtain ⟨plus, minus⟩ := cubic.split at a, b, c, d, p, q with dNonneg102 have constantIn : p * p * p + (3:R) * p * (q * q) * d +103 a * (p * p + q * q * d) + b * p + c ∈ F104 typecheck105 have rootCoefficientIn : (3:R) * (p * p) * q + q * q * q * d +106 (2:R) * a * p * q + b * q ∈ F107 typecheck108 rw plus at root109 obtain ⟨constantZero, rootCoefficientZero⟩ := adjoinSqrt.coefficients_unique110 with field, dNonneg, rootOut, constantIn, rootCoefficientIn, root111 rw [minus, constantZero, rootCoefficientZero]112 ring113114-- Descent through one square root115116-- r = p + q√d. If q = 0 or √d ∈ F then r ∈ F; otherwise the conjugate is117-- a distinct root and the third root −a − 2p lies in F.118theorem cubic.root_descends (F : Set) (d a b c r : Real)119 requires field : RealSubfield(F)120 requires dIn : d ∈ F121 requires dNonneg : (0:R) ≤ d122 requires aIn : a ∈ F123 requires bIn : b ∈ F124 requires cIn : c ∈ F125 requires rIn : r ∈ adjoinSqrt(F, d)126 requires root : cubic(a, b, c, r) = 0127 shows ∃ s ∈ F, cubic(a, b, c, s) = 0128proof129 obtain ⟨p, pIn, q, qIn, same⟩ := adjoinSqrt.cases with dNonneg, rIn130 have realP := RealSubfield.real with field, pIn131 have realQ := RealSubfield.real with field, qIn132 have zeroIn := RealSubfield.zero_mem with field133 by_cases rootIn : √d ∈ F134 . have rInF : r ∈ F135 rw same136 typecheck137 exact ⟨r, rInF, root⟩138 . by_cases qZero : (q:R) = 0139 . have value : r = p140 rw [same, qZero]141 ring142 rw value at root143 exact ⟨p, pIn, root⟩144 . have rootPlus : cubic(a, b, c, (p:R) + (q:R) * √d) = 0 by rwa same at root145 have rootMinus := cubic.conjugate_root146 with field, dIn, dNonneg, rootIn, aIn, bIn, cIn, pIn, qIn, rootPlus147 have rootNonzero : √d ≠ 0148 intro zero149 apply rootIn150 rw zero151 exact zeroIn152 have distinct : (p:R) + (q:R) * √d ≠ (p:R) - (q:R) * √d153 intro equal154 have product : (q:R) * √d = 0 by linarith155 rcases realMulValue.eq_zero_or with product with qIsZero | rootIsZero156 . exact qZero with qIsZero157 . exact rootNonzero with rootIsZero158 have third := cubic.third_root with rootPlus, rootMinus, distinct159 have value : -a - ((p:R) + (q:R) * √d) - ((p:R) - (q:R) * √d) =160 -a - (2:R) * (p:R)161 ring162 rw value at third163 have thirdIn : -a - (2:R) * (p:R) ∈ F by typecheck164 exact ⟨-a - (2:R) * (p:R), thirdIn, third⟩165