Documentation

CompPoly.Univariate.ToPoly.Impl

Proofs of Correctness for CPolynomial Operations, wrt Mathlib Specs #

Proofs that operations defined on CPolynomial and CPolynomial.Raw are correct wrt the mathlib specs, using the ring equivalence

CPolynomial.monomial is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.C_toPoly {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] (r : R) :

CPolynomial.C is correct wrt the Mathlib spec.

CPolynomial.X is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.eval_toPoly {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] (x : R) (p : CPolynomial R) :

CPolynomial.eval is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.eval_C {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] (a c : R) :
eval a (C c) = c

Evaluation of a constant computable polynomial.

theorem CompPoly.CPolynomial.Raw.eval₂_toPoly {R : Type u_1} [Semiring R] {S : Type u_2} [Semiring S] (f : R →+* S) (x : S) (p : Raw R) :

Raw.eval₂ is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.eval₂_toPoly {R : Type u_1} [Semiring R] {S : Type u_2} [Semiring S] (f : R →+* S) (x : S) (p : CPolynomial R) :

CPolynomial.eval₂ is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.coeff_toPoly {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] (p : CPolynomial R) (i : ) :

CPolynomial.coeff is correct wrt the Mathlib spec.

Evaluation at zero returns the constant coefficient.

CPolynomial.divX is correct wrt the Mathlib spec.

CPolynomial.support is correct wrt the Mathlib spec.

CPolynomial.degree is correct wrt the Mathlib spec.

CPolynomial.natDegree is correct wrt the Mathlib spec.

CPolynomial.leadingCoeff is correct wrt the Mathlib spec.

CPolynomial.monic is correct wrt the Mathlib spec

CPolynomial.erase is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.C_mul_X_pow_toPoly {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] [DecidableEq R] [Nontrivial R] (r : R) (n : ) :

CPolynomial.C r mul CPolynomial.X ^ n is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.lcoeff_toPoly {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] (n : ) (p : CPolynomial R) :

CPolynomial.lcoeff is correct wrt the Mathlib spec.

CPolynomial.degreeLE is correct wrt the Mathlib spec.

CPolynomial.degreeLT is correct wrt the Mathlib spec.

theorem CompPoly.CPolynomial.eval_mul {R : Type u_1} [CommSemiring R] [BEq R] [LawfulBEq R] (p q : CPolynomial R) (x : R) :
eval x (p * q) = eval x p * eval x q

Evaluation preserves multiplication.

theorem CompPoly.CPolynomial.eval_ext {R : Type u_1} [CommRing R] [DecidableEq R] [BEq R] [LawfulBEq R] [IsDomain R] {p q : CPolynomial R} {d : } {S : Finset R} (hdeg : (p - q).natDegree d) (hagree : d < {rS | eval r p = eval r q}.card) :
p = q

Univariate eval-extensionality (degree-bounded). Two CPolynomials over an integral domain that agree on more than $d$ points of a Finset S are equal, when $d$ bounds the natural degree of their difference.

The degree bound is needed over finite fields, where two distinct polynomials may agree on every field element.

theorem CompPoly.CPolynomial.eval_sub {R : Type u_1} [Ring R] [BEq R] [LawfulBEq R] (a : R) (p q : CPolynomial R) :
eval a (p - q) = eval a p - eval a q

Evaluation preserves subtraction.

theorem CompPoly.CPolynomial.eval_one {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] [Nontrivial R] (a : R) :
eval a 1 = 1

Evaluation of the constant one computable polynomial.

theorem CompPoly.CPolynomial.eval_divX_eq_zero_of_ne_zero_root {R : Type u_1} [Field R] [BEq R] [LawfulBEq R] {p : CPolynomial R} {a : R} (ha : a 0) (hcoeff : p.coeff 0 = 0) (hroot : eval a p = 0) :
eval a p.divX = 0

Dividing by X preserves a nonzero root when the constant coefficient vanishes.

theorem CompPoly.CPolynomial.divX_ne_zero_of_ne_zero_coeff_zero {R : Type u_1} [Field R] [BEq R] [LawfulBEq R] {p : CPolynomial R} (hp : p 0) (hcoeff : p.coeff 0 = 0) :
p.divX 0

If a nonzero polynomial has zero constant coefficient, its quotient by X is nonzero.

theorem CompPoly.CPolynomial.Raw.eval_sub_C_mul_X_pow_trim_eq_self_of_eval_eq_zero {R : Type u_1} [Field R] [BEq R] [LawfulBEq R] (p q : Raw R) (scale : R) (shift : ) {x : R} (hq : eval x q = 0) :
eval x (p - C scale * (q * X ^ shift)).trim = eval x p
theorem CompPoly.CPolynomial.Raw.eval_divModByMonicAux_go_snd_eq_self_of_eval_eq_zero {R : Type u_1} [Field R] [BEq R] [LawfulBEq R] (fuel : ) (p q : Raw R) {x : R} :
eval x q = 0eval x (divModByMonicAux.go fuel p q).2 = eval x p
theorem CompPoly.CPolynomial.Raw.eval_modByMonic_eq_self_of_eval_eq_zero {R : Type u_1} [Field R] [BEq R] [LawfulBEq R] (p q : Raw R) {x : R} (hq : eval x q = 0) :
eval x (p.modByMonic q) = eval x p

Reducing by a polynomial that vanishes at x preserves evaluation at x.

theorem CompPoly.CPolynomial.eval_modByMonic_eq_self_of_eval_eq_zero {R : Type u_1} [Field R] [BEq R] [LawfulBEq R] (p q : CPolynomial R) {x : R} (hq : eval x q = 0) :
eval x (p.modByMonic q) = eval x p

Reducing by a polynomial that vanishes at x preserves evaluation at x.