Extended Euclidean Algorithm for CPolynomial #
xgcd p q returns a triple (r, s, t) with r = s * p + t * q.
Early stop when r.natDegree < threshold.
The default threshold = 0 makes r the Greatest Common Divisor of p and q.
For positive thresholds, xgcd_stopSpec characterizes the output: BezoutStopSpec packages
the Bézout identity together with the residue/cofactor degree bounds at the stopping point,
via the loop invariant BezoutDegreeInvariant.
Extended euclidean algorithm on p, q.
Stops when r.natDegree < threshold, r = 0, or fuel n exhausted.
If threshold > 0 then xgcdAux need not compute the greatest common divisor.
Potential optimization: the raw long division behind r' / r already computes
r' - (r' / r) * r but it's not exposed through CPolynomial R.
Instances For
Extended euclidean algorithm for (p, q).
Returns (r, s, t) with r = s * p + t * q.
With the default threshold = 0 returns the gcd of p and q.
With threshold > 0 stops when r.natDegree < threshold.
If threshold > 0 then xgcdAux need not compute the greatest common divisor.
Instances For
Bezout-identity correctness #
Bezout predicate on a triple (r, s, t): r = s * p + t * q.
Instances For
The gcd component of CompPoly's xgcdAux at threshold 0 coincides with
Mathlib's EuclideanDomain.gcd.
The gcd component of CompPoly's xgcd at threshold 0
coincides with Mathlib's EuclideanDomain.gcd.
CompPoly's xgcdAux at threshold 0 coincides with
Mathlib's EuclideanDomain.xgcdAux.
The Bezout component of CompPoly's xgcd coincides with
Mathlib's EuclideanDomain.xgcd.
CompPoly's xgcd p q scaled by the inverse leading coefficient
of the gcd component, normalizing it to monic.
Instances For
The normalized extended-gcd output satisfies the Bezout identity.
The gcd component of CompPoly's normXgcd is the normalization
of Mathlib's EuclideanDomain.gcd
Monic normalization of computable polynomials agrees with Mathlib normalization.
The specialized monic gcd has the normalized Mathlib gcd as its toPoly
image.
The specialized monic gcd agrees with the gcd component of normalized extended gcd.
The Bezout component of normXgcd under toPoly is Mathlib's
EuclideanDomain.xgcd scaled by the inverse leading coefficient
of the gcd
normXgcd is commutative for the gcd component
Stop specification for positive thresholds #
BezoutDegreeInvariant is the invariant of the partial-EEA (xgcd) loop: each non-stop
step preserves it (BezoutDegreeInvariant.step), and at the stopping threshold it yields
the output specification BezoutStopSpec (xgcd_stopSpec).
This is the classical degree theory of the extended Euclidean algorithm — the row identity
deg t + deg r' = deg g₀ and the complementary cofactor bound at the stop — i.e. the
contract behind rational-function reconstruction and Reed-Solomon decoding.
Loop invariant of one partial-EEA (xgcd) step.
Instances For
BezoutDegreeInvariant on the toPoly images of a CPolynomial reference pair g₀, g₁ and
the two state triples (r, s, t), (r', s', t').
Instances For
BezoutDegreeInvariant implies deg t + deg r' = deg g₀.
A non-stop Euclidean step preserves the invariant.
Stop spec of the partial EEA: R = S g₀ + T g₁, residue degree below threshold,
and the cofactor T nonzero with complementary degree deg T + threshold ≤ deg g₀.
Instances For
BezoutStopSpec on the toPoly images of a CPolynomial reference pair g₀, g₁ and
result triple.
Instances For
BezoutDegreeInvariant implies xgcdAux's output satisfies the stop spec.