The areas / V09. Commutative algebra I: ideals, polynomials, factorization
Mathlib.Algebra.Polynomial.CoeffList
27 declarations. Mathlib docs · Source
A list of coefficients of a polynomial
Definition
coeffList f: aListof the coefficients, from leading term down to constant term.coeffList 0is defined to be[].
This is useful for talking about polynomials in terms of list operations. It is "redundant" data in
the sense that Polynomial is already a Finsupp (of its coefficients), and Polynomial.coeff
turns this into a function, and these have exactly the same data as coeffList. The difference is
that coeffList is intended for working together with list operations: getting List.head,
comparing adjacent coefficients with each other, or anything that involves induction on Polynomials
by dropping the leading term (which is Polynomial.eraseLead).
Note that coeffList starts with the highest-degree terms and ends with the constant term. This
might seem backwards in the sense that Polynomial.coeff and List.get! are reversed to one
another, but it means that induction on Lists is the same as induction on
Polynomial.leadingCoeff.
The most significant theorem here is coeffList_eraseLead, which says that coeffList P can be
written as leadingCoeff P :: List.replicate k 0 ++ coeffList P.eraseLead. That is, the list
of coefficients starts with the leading coefficient, followed by some number of zeros, and then the
coefficients of P.eraseLead.
Polynomials from coefficient lists
ofCoeffList l: constructs a polynomial from coefficients in the listl, starting with the constant coefficient. It invertscoeffListup to reversing the list, seeofCoeffList_reverse_coeffListandofCoeffList_coeffList.ofCoeffList_map_mul,ofCoeffList_zipWithAll_add,ofCoeffList_zero_cons, andofCoeffList_zipWithAll_subrelate the arithmetic of polynomials to operations on their respective lists.
def Polynomial.coeffList E1 #
{R : Type u_1} → [inst : Semiring R] → Polynomial R → List R
The list of coefficients starting from the leading term down to the constant term.
theorem Polynomial.coeffList_zero E0 #
∀ (R : Type u_1) [inst : Semiring R], Polynomial.coeffList 0 = []
theorem Polynomial.coeffList_eq_nil E0 #
∀ {R : Type u_1} [inst : Semiring R] {P : Polynomial R}, P.coeffList = [] ↔ P = 0
Only the zero polynomial has no coefficients.
theorem Polynomial.coeffList_of_ne_zero E1 #
∀ {R : Type u_1} [inst : Semiring R] {P : Polynomial R},
P ≠ 0 → P.coeffList = List.map (⇑P.coeff) (List.range (P.natDegree + 1)).reverse
theorem Polynomial.coeffList_C E0 #
∀ {R : Type u_1} [inst : Semiring R] {x : R}, x ≠ 0 → (Polynomial.C x).coeffList = [x]
theorem Polynomial.coeffList_eq_cons_leadingCoeff E1 #
∀ {R : Type u_1} [inst : Semiring R] {P : Polynomial R}, P ≠ 0 → ∃ ls, P.coeffList = P.leadingCoeff :: ls
theorem Polynomial.head?_coeffList E0 #
∀ {R : Type u_1} [inst : Semiring R] {P : Polynomial R}, P ≠ 0 → P.coeffList.head? = some P.leadingCoeff
theorem Polynomial.head_coeffList E0 #
∀ {R : Type u_1} [inst : Semiring R] (P : Polynomial R) (hP : P.coeffList ≠ []), P.coeffList.head hP = P.leadingCoeff
theorem Polynomial.length_coeffList_eq_withBotSucc_degree E1 #
∀ {R : Type u_1} [inst : Semiring R] (P : Polynomial R), P.coeffList.length = P.degree.succ
theorem Polynomial.length_coeffList_eq_ite E0 #
∀ {R : Type u_1} [inst : Semiring R] [inst_1 : DecidableEq R] (P : Polynomial R),
P.coeffList.length = if P = 0 then 0 else P.natDegree + 1
theorem Polynomial.leadingCoeff_cons_eraseLead E1 #
∀ {R : Type u_1} [inst : Semiring R] {P : Polynomial R},
P.nextCoeff ≠ 0 → P.leadingCoeff :: P.eraseLead.coeffList = P.coeffList
theorem Polynomial.coeffList_monomial E0 #
∀ {R : Type u_1} [inst : Semiring R] {x : R},
x ≠ 0 → ∀ (n : ℕ), ((Polynomial.monomial n) x).coeffList = x :: List.replicate n 0
theorem Polynomial.coeffList_eraseLead E1 #
∀ {R : Type u_1} [inst : Semiring R] {P : Polynomial R},
P ≠ 0 →
P.coeffList = P.leadingCoeff :: (List.replicate (P.natDegree - P.eraseLead.degree.succ) 0 ++ P.eraseLead.coeffList)
Coefficients of a polynomial P are always the leading coefficient, some number of zeros, and
then coeffList P.eraseLead.
def Polynomial.ofCoeffList E1 #
{R : Type u_1} → [inst : Semiring R] → List R → Polynomial R
Construct a polynomial from a little-endian (i.e. constant term first) coefficient list.
ofCoeffList [c₀, c₁, ...] = C c₀ + C c₁ * X + ...
Little-endian ordering of coefficients is convenient for:
- defining multiplication by X (by cons
(0 :: )) - defining addition of two polynomials of different degrees (their coefficient lists indexes align)
theorem Polynomial.ofCoeffList_nil E0 #
∀ {R : Type u_1} [inst : Semiring R], Polynomial.ofCoeffList [] = 0
theorem Polynomial.ofCoeffList_cons E1 #
∀ {R : Type u_1} [inst : Semiring R] (c : R) (p : List R),
Polynomial.ofCoeffList (c :: p) = Polynomial.C c + Polynomial.X * Polynomial.ofCoeffList p
theorem Polynomial.coeff_ofCoeffList E0 #
∀ {R : Type u_1} [inst : Semiring R] (l : List R) (i : ℕ), (Polynomial.ofCoeffList l).coeff i = l.getD i 0
theorem Polynomial.ofCoeffList_reverse_coeffList E0 #
∀ {R : Type u_1} [inst : Semiring R] (P : Polynomial R), Polynomial.ofCoeffList P.coeffList.reverse = P
theorem Polynomial.ofCoeffList_coeffList E0 #
∀ {R : Type u_1} [inst : Semiring R] (P : Polynomial R), Polynomial.ofCoeffList P.coeffList = P.reverse
theorem Polynomial.map_ofCoeffList E0 #
∀ {R : Type u_1} [inst : Semiring R] {S : Type u_2} [inst_1 : Semiring S] (f : R →+* S) (l : List R),
Polynomial.map f (Polynomial.ofCoeffList l) = Polynomial.ofCoeffList (List.map (⇑f) l)
theorem Polynomial.ofCoeffList_map_mul E0 #
∀ {R : Type u_1} [inst : Semiring R] (a : R) (l : List R),
Polynomial.ofCoeffList (List.map (fun x ↦ a * x) l) = Polynomial.C a * Polynomial.ofCoeffList l
theorem Polynomial.ofCoeffList_zipWithAll_add E0 #
∀ {R : Type u_1} [inst : Semiring R] (p q : List R),
Polynomial.ofCoeffList (List.zipWithAll (fun a b ↦ a.getD 0 + b.getD 0) p q) =
Polynomial.ofCoeffList p + Polynomial.ofCoeffList q
theorem Polynomial.ofCoeffList_zero_cons E0 #
∀ {R : Type u_1} [inst : Semiring R] (l : List R),
Polynomial.ofCoeffList (0 :: l) = Polynomial.X * Polynomial.ofCoeffList l
theorem Polynomial.coeffList_neg E0 #
∀ {R : Type u_1} [inst : Ring R] (P : Polynomial R), (-P).coeffList = List.map (fun x ↦ -x) P.coeffList
theorem Polynomial.ofCoeffList_map_neg E0 #
∀ {R : Type u_1} [inst : Ring R] (l : List R),
Polynomial.ofCoeffList (List.map (fun x ↦ -x) l) = -Polynomial.ofCoeffList l
theorem Polynomial.ofCoeffList_zipWithAll_sub E0 #
∀ {R : Type u_1} [inst : Ring R] (p q : List R),
Polynomial.ofCoeffList (List.zipWithAll (fun a b ↦ a.getD 0 - b.getD 0) p q) =
Polynomial.ofCoeffList p - Polynomial.ofCoeffList q
theorem Polynomial.coeffList_C_mul E1 #
∀ {R : Type u_1} [inst : Semiring R] [NoZeroDivisors R] (P : Polynomial R) {x : R},
x ≠ 0 → (Polynomial.C x * P).coeffList = List.map (fun x_1 ↦ x * x_1) P.coeffList