# Theory of univariate polynomials #

This file defines Polynomial R, the type of univariate polynomials over the semiring R, builds a semiring structure on it, and gives basic definitions that are expanded in other files in this directory.

## Main definitions #

• monomial n a is the polynomial a X^n. Note that monomial n is defined as an R-linear map.
• C a is the constant polynomial a. Note that C is defined as a ring homomorphism.
• X is the polynomial X, i.e., monomial 1 1.
• p.sum f is ∑ n in p.support, f n (p.coeff n), i.e., one sums the values of functions applied to coefficients of the polynomial p.
• p.erase n is the polynomial p in which one removes the c X^n term.

There are often two natural variants of lemmas involving sums, depending on whether one acts on the polynomials, or on the function. The naming convention is that one adds index when acting on the polynomials. For instance,

• sum_add_index states that (p + q).sum f = p.sum f + q.sum f;
• sum_add states that p.sum (fun n x ↦ f n x + g n x) = p.sum f + p.sum g.
• Notation to refer to Polynomial R, as R[X] or R[t].

## Implementation #

Polynomials are defined using R[ℕ], where R is a semiring. The variable X commutes with every polynomial p: lemma X_mul proves the identity X * p = p * X. The relationship to R[ℕ] is through a structure to make polynomials irreducible from the point of view of the kernel. Most operations are irreducible since Lean can not compute anyway with AddMonoidAlgebra. There are two exceptions that we make semireducible:

• The zero polynomial, so that its coefficients are definitionally equal to 0.
• The scalar action, to permit typeclass search to unfold it to resolve potential instance diamonds.

The raw implementation of the equivalence between R[X] and R[ℕ] is done through ofFinsupp and toFinsupp (or, equivalently, rcases p when p is a polynomial gives an element q of R[ℕ], and conversely ⟨q⟩ gives back p). The equivalence is also registered as a ring equiv in Polynomial.toFinsuppIso. These should in general not be used once the basic API for polynomials is constructed.

structure Polynomial (R : Type u_1) [] :
Type u_1

Polynomial R is the type of univariate polynomials over R.

Polynomials should be seen as (semi-)rings with the additional constructor X. The embedding from R is called C.

• ofFinsupp :: (
• toFinsupp :
• )
Instances For

Polynomial R is the type of univariate polynomials over R.

Polynomials should be seen as (semi-)rings with the additional constructor X. The embedding from R is called C.

Equations
Instances For
theorem Polynomial.forall_iff_forall_finsupp {R : Type u} [] (P : ) :
(∀ (p : ), P p) ∀ (q : ), P { toFinsupp := q }
theorem Polynomial.exists_iff_exists_finsupp {R : Type u} [] (P : ) :
(∃ (p : ), P p) ∃ (q : ), P { toFinsupp := q }
@[simp]
theorem Polynomial.eta {R : Type u} [] (f : ) :
{ toFinsupp := f.toFinsupp } = f

### Conversions to and from AddMonoidAlgebra#

Since R[X] is not defeq to R[ℕ], but instead is a structure wrapping it, we have to copy across all the arithmetic operators manually, along with the lemmas about how they unfold around Polynomial.ofFinsupp and Polynomial.toFinsupp.

instance Polynomial.zero {R : Type u} [] :
Zero ()
Equations
• Polynomial.zero = { zero := { toFinsupp := 0 } }
instance Polynomial.one {R : Type u} [] :
One ()
Equations
• Polynomial.one = { one := { toFinsupp := 1 } }
instance Polynomial.add' {R : Type u} [] :
Equations
instance Polynomial.neg' {R : Type u} [Ring R] :
Neg ()
Equations
• Polynomial.neg' = { neg := Polynomial.neg }
instance Polynomial.sub {R : Type u} [Ring R] :
Sub ()
Equations
• Polynomial.sub = { sub := fun (a b : ) => a + -b }
instance Polynomial.mul' {R : Type u} [] :
Mul ()
Equations
• Polynomial.mul' = { mul := Polynomial.mul }
instance Polynomial.smulZeroClass {R : Type u} [] {S : Type u_1} [] :
Equations
• Polynomial.smulZeroClass = SMulZeroClass.mk (_ : ∀ (a : S), { toFinsupp := a 0.toFinsupp } = { toFinsupp := 0 })
instance Polynomial.pow {R : Type u} [] :
Pow ()
Equations
• Polynomial.pow = { pow := fun (p : ) (n : ) => npowRec n p }
@[simp]
theorem Polynomial.ofFinsupp_zero {R : Type u} [] :
{ toFinsupp := 0 } = 0
@[simp]
theorem Polynomial.ofFinsupp_one {R : Type u} [] :
{ toFinsupp := 1 } = 1
@[simp]
theorem Polynomial.ofFinsupp_add {R : Type u} [] {a : } {b : } :
{ toFinsupp := a + b } = { toFinsupp := a } + { toFinsupp := b }
@[simp]
theorem Polynomial.ofFinsupp_neg {R : Type u} [Ring R] {a : } :
{ toFinsupp := -a } = -{ toFinsupp := a }
@[simp]
theorem Polynomial.ofFinsupp_sub {R : Type u} [Ring R] {a : } {b : } :
{ toFinsupp := a - b } = { toFinsupp := a } - { toFinsupp := b }
@[simp]
theorem Polynomial.ofFinsupp_mul {R : Type u} [] (a : ) (b : ) :
{ toFinsupp := a * b } = { toFinsupp := a } * { toFinsupp := b }
@[simp]
theorem Polynomial.ofFinsupp_smul {R : Type u} [] {S : Type u_1} [] (a : S) (b : ) :
{ toFinsupp := a b } = a { toFinsupp := b }
@[simp]
theorem Polynomial.ofFinsupp_pow {R : Type u} [] (a : ) (n : ) :
{ toFinsupp := a ^ n } = { toFinsupp := a } ^ n
@[simp]
theorem Polynomial.toFinsupp_zero {R : Type u} [] :
0.toFinsupp = 0
@[simp]
theorem Polynomial.toFinsupp_one {R : Type u} [] :
1.toFinsupp = 1
@[simp]
theorem Polynomial.toFinsupp_add {R : Type u} [] (a : ) (b : ) :
(a + b).toFinsupp = a.toFinsupp + b.toFinsupp
@[simp]
theorem Polynomial.toFinsupp_neg {R : Type u} [Ring R] (a : ) :
(-a).toFinsupp = -a.toFinsupp
@[simp]
theorem Polynomial.toFinsupp_sub {R : Type u} [Ring R] (a : ) (b : ) :
(a - b).toFinsupp = a.toFinsupp - b.toFinsupp
@[simp]
theorem Polynomial.toFinsupp_mul {R : Type u} [] (a : ) (b : ) :
(a * b).toFinsupp = a.toFinsupp * b.toFinsupp
@[simp]
theorem Polynomial.toFinsupp_smul {R : Type u} [] {S : Type u_1} [] (a : S) (b : ) :
(a b).toFinsupp = a b.toFinsupp
@[simp]
theorem Polynomial.toFinsupp_pow {R : Type u} [] (a : ) (n : ) :
(a ^ n).toFinsupp = a.toFinsupp ^ n
theorem IsSMulRegular.polynomial {R : Type u} [] {S : Type u_1} [] [] {a : S} (ha : ) :
theorem Polynomial.toFinsupp_injective {R : Type u} [] :
Function.Injective Polynomial.toFinsupp
@[simp]
theorem Polynomial.toFinsupp_inj {R : Type u} [] {a : } {b : } :
a.toFinsupp = b.toFinsupp a = b
@[simp]
theorem Polynomial.toFinsupp_eq_zero {R : Type u} [] {a : } :
a.toFinsupp = 0 a = 0
@[simp]
theorem Polynomial.toFinsupp_eq_one {R : Type u} [] {a : } :
a.toFinsupp = 1 a = 1
theorem Polynomial.ofFinsupp_inj {R : Type u} [] {a : } {b : } :
{ toFinsupp := a } = { toFinsupp := b } a = b

A more convenient spelling of Polynomial.ofFinsupp.injEq in terms of Iff.

@[simp]
theorem Polynomial.ofFinsupp_eq_zero {R : Type u} [] {a : } :
{ toFinsupp := a } = 0 a = 0
@[simp]
theorem Polynomial.ofFinsupp_eq_one {R : Type u} [] {a : } :
{ toFinsupp := a } = 1 a = 1
instance Polynomial.inhabited {R : Type u} [] :
Equations
• Polynomial.inhabited = { default := 0 }
instance Polynomial.natCast {R : Type u} [] :
Equations
• Polynomial.natCast = { natCast := fun (n : ) => { toFinsupp := n } }
instance Polynomial.semiring {R : Type u} [] :
Equations
• One or more equations did not get rendered due to their size.
instance Polynomial.distribSMul {R : Type u} [] {S : Type u_1} [] :
Equations
• One or more equations did not get rendered due to their size.
instance Polynomial.distribMulAction {R : Type u} [] {S : Type u_1} [] [] :
Equations
• One or more equations did not get rendered due to their size.
instance Polynomial.faithfulSMul {R : Type u} [] {S : Type u_1} [] [] :
Equations
• (_ : ) = (_ : )
instance Polynomial.module {R : Type u} [] {S : Type u_1} [] [Module S R] :
Module S ()
Equations
• One or more equations did not get rendered due to their size.
instance Polynomial.smulCommClass {R : Type u} [] {S₁ : Type u_1} {S₂ : Type u_2} [] [] [SMulCommClass S₁ S₂ R] :
SMulCommClass S₁ S₂ ()
Equations
instance Polynomial.isScalarTower {R : Type u} [] {S₁ : Type u_1} {S₂ : Type u_2} [SMul S₁ S₂] [] [] [IsScalarTower S₁ S₂ R] :
IsScalarTower S₁ S₂ ()
Equations
instance Polynomial.isScalarTower_right {α : Type u_1} {K : Type u_2} [] [] [] :
IsScalarTower α () ()
Equations
instance Polynomial.isCentralScalar {R : Type u} [] {S : Type u_1} [] [] [] :
Equations
• (_ : ) = (_ : )
instance Polynomial.unique {R : Type u} [] [] :
Equations
• Polynomial.unique = let src := Polynomial.inhabited; { toInhabited := src, uniq := (_ : ∀ (a : ), a = default) }
@[simp]
theorem Polynomial.toFinsuppIso_apply (R : Type u) [] (self : ) :
self = self.toFinsupp
@[simp]
theorem Polynomial.toFinsuppIso_symm_apply (R : Type u) [] (toFinsupp : ) :
toFinsupp = { toFinsupp := toFinsupp }
def Polynomial.toFinsuppIso (R : Type u) [] :

Ring isomorphism between R[X] and R[ℕ]. This is just an implementation detail, but it can be useful to transfer results from Finsupp to polynomials.

Equations
• One or more equations did not get rendered due to their size.
Instances For
Equations
theorem Polynomial.ofFinsupp_sum {R : Type u} [] {ι : Type u_1} (s : ) (f : ι) :
{ toFinsupp := Finset.sum s fun (i : ι) => f i } = Finset.sum s fun (i : ι) => { toFinsupp := f i }
theorem Polynomial.toFinsupp_sum {R : Type u} [] {ι : Type u_1} (s : ) (f : ι) :
(Finset.sum s fun (i : ι) => f i).toFinsupp = Finset.sum s fun (i : ι) => (f i).toFinsupp
def Polynomial.support {R : Type u} [] :

The set of all n such that X^n has a non-zero coefficient.

Equations
• = match x with | { toFinsupp := p } => p.support
Instances For
@[simp]
theorem Polynomial.support_ofFinsupp {R : Type u} [] (p : ) :
Polynomial.support { toFinsupp := p } = p.support
theorem Polynomial.support_toFinsupp {R : Type u} [] (p : ) :
p.toFinsupp.support =
@[simp]
theorem Polynomial.support_zero {R : Type u} [] :
@[simp]
theorem Polynomial.support_eq_empty {R : Type u} [] {p : } :
p = 0
theorem Polynomial.card_support_eq_zero {R : Type u} [] {p : } :
.card = 0 p = 0
def Polynomial.monomial {R : Type u} [] (n : ) :

monomial s a is the monomial a * X^s

Equations
• One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem Polynomial.toFinsupp_monomial {R : Type u} [] (n : ) (r : R) :
( r).toFinsupp =
@[simp]
theorem Polynomial.ofFinsupp_single {R : Type u} [] (n : ) (r : R) :
{ toFinsupp := } = r
theorem Polynomial.monomial_zero_right {R : Type u} [] (n : ) :
0 = 0
theorem Polynomial.monomial_zero_one {R : Type u} [] :
1 = 1
theorem Polynomial.monomial_add {R : Type u} [] (n : ) (r : R) (s : R) :
(r + s) = r + s
theorem Polynomial.monomial_mul_monomial {R : Type u} [] (n : ) (m : ) (r : R) (s : R) :
r * s = (Polynomial.monomial (n + m)) (r * s)
@[simp]
theorem Polynomial.monomial_pow {R : Type u} [] (n : ) (r : R) (k : ) :
r ^ k = (Polynomial.monomial (n * k)) (r ^ k)
theorem Polynomial.smul_monomial {R : Type u} [] {S : Type u_1} [] (a : S) (n : ) (b : R) :
a b = (a b)
theorem Polynomial.monomial_injective {R : Type u} [] (n : ) :
@[simp]
theorem Polynomial.monomial_eq_zero_iff {R : Type u} [] (t : R) (n : ) :
t = 0 t = 0
theorem Polynomial.support_add {R : Type u} [] {p : } {q : } :
def Polynomial.C {R : Type u} [] :

C a is the constant polynomial a. C is provided as a ring homomorphism.

Equations
• One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem Polynomial.monomial_zero_left {R : Type u} [] (a : R) :
a = Polynomial.C a
@[simp]
theorem Polynomial.toFinsupp_C {R : Type u} [] (a : R) :
(Polynomial.C a).toFinsupp =
theorem Polynomial.C_0 {R : Type u} [] :
Polynomial.C 0 = 0
theorem Polynomial.C_1 {R : Type u} [] :
Polynomial.C 1 = 1
theorem Polynomial.C_mul {R : Type u} {a : R} {b : R} [] :
Polynomial.C (a * b) = Polynomial.C a * Polynomial.C b
theorem Polynomial.C_add {R : Type u} {a : R} {b : R} [] :
Polynomial.C (a + b) = Polynomial.C a + Polynomial.C b
@[simp]
theorem Polynomial.smul_C {R : Type u} [] {S : Type u_1} [] (s : S) (r : R) :
s Polynomial.C r = Polynomial.C (s r)
theorem Polynomial.C_bit0 {R : Type u} {a : R} [] :
Polynomial.C (bit0 a) = bit0 (Polynomial.C a)
theorem Polynomial.C_bit1 {R : Type u} {a : R} [] :
Polynomial.C (bit1 a) = bit1 (Polynomial.C a)
theorem Polynomial.C_pow {R : Type u} {a : R} {n : } [] :
Polynomial.C (a ^ n) = Polynomial.C a ^ n
theorem Polynomial.C_eq_nat_cast {R : Type u} [] (n : ) :
Polynomial.C n = n
@[simp]
theorem Polynomial.C_mul_monomial {R : Type u} {a : R} {b : R} {n : } [] :
Polynomial.C a * b = (a * b)
@[simp]
theorem Polynomial.monomial_mul_C {R : Type u} {a : R} {b : R} {n : } [] :
a * Polynomial.C b = (a * b)
def Polynomial.X {R : Type u} [] :

X is the polynomial variable (aka indeterminate).

Equations
• Polynomial.X = 1
Instances For
theorem Polynomial.monomial_one_one_eq_X {R : Type u} [] :
1 = Polynomial.X
theorem Polynomial.monomial_one_right_eq_X_pow {R : Type u} [] (n : ) :
1 = Polynomial.X ^ n
@[simp]
theorem Polynomial.toFinsupp_X {R : Type u} [] :
Polynomial.X.toFinsupp =
theorem Polynomial.X_mul {R : Type u} [] {p : } :
Polynomial.X * p = p * Polynomial.X

X commutes with everything, even when the coefficients are noncommutative.

theorem Polynomial.X_pow_mul {R : Type u} [] {p : } {n : } :
Polynomial.X ^ n * p = p * Polynomial.X ^ n
@[simp]
theorem Polynomial.X_mul_C {R : Type u} [] (r : R) :
Polynomial.X * Polynomial.C r = Polynomial.C r * Polynomial.X

Prefer putting constants to the left of X.

This lemma is the loop-avoiding simp version of Polynomial.X_mul.

@[simp]
theorem Polynomial.X_pow_mul_C {R : Type u} [] (r : R) (n : ) :
Polynomial.X ^ n * Polynomial.C r = Polynomial.C r * Polynomial.X ^ n

Prefer putting constants to the left of X ^ n.

This lemma is the loop-avoiding simp version of X_pow_mul.

theorem Polynomial.X_pow_mul_assoc {R : Type u} [] {p : } {q : } {n : } :
p * Polynomial.X ^ n * q = p * q * Polynomial.X ^ n
@[simp]
theorem Polynomial.X_pow_mul_assoc_C {R : Type u} [] {p : } {n : } (r : R) :
p * Polynomial.X ^ n * Polynomial.C r = p * Polynomial.C r * Polynomial.X ^ n

Prefer putting constants to the left of X ^ n.

This lemma is the loop-avoiding simp version of X_pow_mul_assoc.

theorem Polynomial.commute_X {R : Type u} [] (p : ) :
Commute Polynomial.X p
theorem Polynomial.commute_X_pow {R : Type u} [] (p : ) (n : ) :
Commute (Polynomial.X ^ n) p
@[simp]
theorem Polynomial.monomial_mul_X {R : Type u} [] (n : ) (r : R) :
r * Polynomial.X = (Polynomial.monomial (n + 1)) r
@[simp]
theorem Polynomial.monomial_mul_X_pow {R : Type u} [] (n : ) (r : R) (k : ) :
r * Polynomial.X ^ k = (Polynomial.monomial (n + k)) r
@[simp]
theorem Polynomial.X_mul_monomial {R : Type u} [] (n : ) (r : R) :
Polynomial.X * r = (Polynomial.monomial (n + 1)) r
@[simp]
theorem Polynomial.X_pow_mul_monomial {R : Type u} [] (k : ) (n : ) (r : R) :
Polynomial.X ^ k * r = (Polynomial.monomial (n + k)) r
def Polynomial.coeff {R : Type u} [] :
R

coeff p n (often denoted p.coeff n) is the coefficient of X^n in p.

Equations
• = match (motive := R) x with | { toFinsupp := p } => p
Instances For
@[simp]
theorem Polynomial.coeff_ofFinsupp {R : Type u} [] (p : ) :
Polynomial.coeff { toFinsupp := p } = p
theorem Polynomial.coeff_injective {R : Type u} [] :
Function.Injective Polynomial.coeff
@[simp]
theorem Polynomial.coeff_inj {R : Type u} [] {p : } {q : } :
p = q
theorem Polynomial.toFinsupp_apply {R : Type u} [] (f : ) (i : ) :
f.toFinsupp i =
theorem Polynomial.coeff_monomial {R : Type u} {a : R} {m : } {n : } [] :
Polynomial.coeff ( a) m = if n = m then a else 0
@[simp]
theorem Polynomial.coeff_zero {R : Type u} [] (n : ) :
= 0
theorem Polynomial.coeff_one {R : Type u} [] {n : } :
= if n = 0 then 1 else 0
@[simp]
theorem Polynomial.coeff_one_zero {R : Type u} [] :
= 1
@[simp]
theorem Polynomial.coeff_X_one {R : Type u} [] :
Polynomial.coeff Polynomial.X 1 = 1
@[simp]
theorem Polynomial.coeff_X_zero {R : Type u} [] :
Polynomial.coeff Polynomial.X 0 = 0
@[simp]
theorem Polynomial.coeff_monomial_succ {R : Type u} {a : R} {n : } [] :
theorem Polynomial.coeff_X {R : Type u} {n : } [] :
Polynomial.coeff Polynomial.X n = if 1 = n then 1 else 0
theorem Polynomial.coeff_X_of_ne_one {R : Type u} [] {n : } (hn : n 1) :
Polynomial.coeff Polynomial.X n = 0
@[simp]
theorem Polynomial.mem_support_iff {R : Type u} {n : } [] {p : } :
0
theorem Polynomial.not_mem_support_iff {R : Type u} {n : } [] {p : } :
= 0
theorem Polynomial.coeff_C {R : Type u} {a : R} {n : } [] :
Polynomial.coeff (Polynomial.C a) n = if n = 0 then a else 0
@[simp]
theorem Polynomial.coeff_C_zero {R : Type u} {a : R} [] :
Polynomial.coeff (Polynomial.C a) 0 = a
theorem Polynomial.coeff_C_ne_zero {R : Type u} {a : R} {n : } [] (h : n 0) :
Polynomial.coeff (Polynomial.C a) n = 0
@[simp]
theorem Polynomial.coeff_C_succ {R : Type u} [] {r : R} {n : } :
Polynomial.coeff (Polynomial.C r) (n + 1) = 0
@[simp]
theorem Polynomial.coeff_nat_cast_ite {R : Type u} {m : } {n : } [] :
Polynomial.coeff (m) n = (if n = 0 then m else 0)
@[simp]
theorem Polynomial.coeff_ofNat_zero {R : Type u} [] (a : ) [] :
@[simp]
theorem Polynomial.coeff_ofNat_succ {R : Type u} [] (a : ) (n : ) [h : ] :
Polynomial.coeff () (n + 1) = 0
theorem Polynomial.C_mul_X_pow_eq_monomial {R : Type u} {a : R} [] {n : } :
Polynomial.C a * Polynomial.X ^ n = a
@[simp]
theorem Polynomial.toFinsupp_C_mul_X_pow {R : Type u} [] (a : R) (n : ) :
(Polynomial.C a * Polynomial.X ^ n).toFinsupp =
theorem Polynomial.C_mul_X_eq_monomial {R : Type u} {a : R} [] :
Polynomial.C a * Polynomial.X = a
@[simp]
theorem Polynomial.toFinsupp_C_mul_X {R : Type u} [] (a : R) :
(Polynomial.C a * Polynomial.X).toFinsupp =
theorem Polynomial.C_injective {R : Type u} [] :
Function.Injective Polynomial.C
@[simp]
theorem Polynomial.C_inj {R : Type u} {a : R} {b : R} [] :
Polynomial.C a = Polynomial.C b a = b
@[simp]
theorem Polynomial.C_eq_zero {R : Type u} {a : R} [] :
Polynomial.C a = 0 a = 0
theorem Polynomial.C_ne_zero {R : Type u} {a : R} [] :
Polynomial.C a 0 a 0
theorem Polynomial.Nontrivial.of_polynomial_ne {R : Type u} [] {p : } {q : } (h : p q) :
theorem Polynomial.forall_eq_iff_forall_eq {R : Type u} [] :
(∀ (f g : ), f = g) ∀ (a b : R), a = b
theorem Polynomial.ext_iff {R : Type u} [] {p : } {q : } :
p = q ∀ (n : ),
theorem Polynomial.ext {R : Type u} [] {p : } {q : } :
(∀ (n : ), )p = q
theorem Polynomial.addSubmonoid_closure_setOf_eq_monomial {R : Type u} [] :
AddSubmonoid.closure {p : | ∃ (n : ) (a : R), p = a} =

Monomials generate the additive monoid of polynomials.

theorem Polynomial.addHom_ext {R : Type u} [] {M : Type u_1} [] {f : →+ M} {g : →+ M} (h : ∀ (n : ) (a : R), f ( a) = g ( a)) :
f = g
theorem Polynomial.addHom_ext' {R : Type u} [] {M : Type u_1} [] {f : →+ M} {g : →+ M} (h : ∀ (n : ), ) :
f = g
theorem Polynomial.lhom_ext' {R : Type u} [] {M : Type u_1} [] [Module R M] {f : →ₗ[R] M} {g : →ₗ[R] M} (h : ∀ (n : ), f ∘ₗ = g ∘ₗ ) :
f = g
theorem Polynomial.eq_zero_of_eq_zero {R : Type u} [] (h : 0 = 1) (p : ) :
p = 0
theorem Polynomial.support_monomial {R : Type u} [] (n : ) {a : R} (H : a 0) :
= {n}
theorem Polynomial.support_monomial' {R : Type u} [] (n : ) (a : R) :
{n}
theorem Polynomial.support_C_mul_X {R : Type u} [] {c : R} (h : c 0) :
Polynomial.support (Polynomial.C c * Polynomial.X) = {1}
theorem Polynomial.support_C_mul_X' {R : Type u} [] (c : R) :
Polynomial.support (Polynomial.C c * Polynomial.X) {1}
theorem Polynomial.support_C_mul_X_pow {R : Type u} [] (n : ) {c : R} (h : c 0) :
Polynomial.support (Polynomial.C c * Polynomial.X ^ n) = {n}
theorem Polynomial.support_C_mul_X_pow' {R : Type u} [] (n : ) (c : R) :
Polynomial.support (Polynomial.C c * Polynomial.X ^ n) {n}
theorem Polynomial.support_binomial' {R : Type u} [] (k : ) (m : ) (x : R) (y : R) :
Polynomial.support (Polynomial.C x * Polynomial.X ^ k + Polynomial.C y * Polynomial.X ^ m) {k, m}
theorem Polynomial.support_trinomial' {R : Type u} [] (k : ) (m : ) (n : ) (x : R) (y : R) (z : R) :
Polynomial.support (Polynomial.C x * Polynomial.X ^ k + Polynomial.C y * Polynomial.X ^ m + Polynomial.C z * Polynomial.X ^ n) {k, m, n}
theorem Polynomial.X_pow_eq_monomial {R : Type u} [] (n : ) :
Polynomial.X ^ n = 1
@[simp]
theorem Polynomial.toFinsupp_X_pow {R : Type u} [] (n : ) :
(Polynomial.X ^ n).toFinsupp =
theorem Polynomial.smul_X_eq_monomial {R : Type u} {a : R} [] {n : } :
a Polynomial.X ^ n = a
theorem Polynomial.support_X_pow {R : Type u} [] (H : ¬1 = 0) (n : ) :
Polynomial.support (Polynomial.X ^ n) = {n}
theorem Polynomial.support_X_empty {R : Type u} [] (H : 1 = 0) :
Polynomial.support Polynomial.X =
theorem Polynomial.support_X {R : Type u} [] (H : ¬1 = 0) :
Polynomial.support Polynomial.X = {1}
theorem Polynomial.monomial_left_inj {R : Type u} [] {a : R} (ha : a 0) {i : } {j : } :
a = a i = j
theorem Polynomial.binomial_eq_binomial {R : Type u} [] {k : } {l : } {m : } {n : } {u : R} {v : R} (hu : u 0) (hv : v 0) :
Polynomial.C u * Polynomial.X ^ k + Polynomial.C v * Polynomial.X ^ l = Polynomial.C u * Polynomial.X ^ m + Polynomial.C v * Polynomial.X ^ n k = m l = n u = v k = n l = m u + v = 0 k = l m = n
theorem Polynomial.nat_cast_mul {R : Type u} [] (n : ) (p : ) :
n * p = n p
def Polynomial.sum {R : Type u} [] {S : Type u_1} [] (p : ) (f : RS) :
S

Summing the values of a function applied to the coefficients of a polynomial

Equations
Instances For
theorem Polynomial.sum_def {R : Type u} [] {S : Type u_1} [] (p : ) (f : RS) :
= Finset.sum fun (n : ) => f n ()
theorem Polynomial.sum_eq_of_subset {R : Type u} [] {S : Type u_1} [] {p : } (f : RS) (hf : ∀ (i : ), f i 0 = 0) {s : } (hs : ) :
= Finset.sum s fun (n : ) => f n ()
theorem Polynomial.mul_eq_sum_sum {R : Type u} [] {p : } {q : } :
p * q = Finset.sum fun (i : ) => Polynomial.sum q fun (j : ) (a : R) => (Polynomial.monomial (i + j)) ( * a)

Expressing the product of two polynomials as a double sum.

@[simp]
theorem Polynomial.sum_zero_index {R : Type u} [] {S : Type u_1} [] (f : RS) :
= 0
@[simp]
theorem Polynomial.sum_monomial_index {R : Type u} [] {S : Type u_1} [] {n : } (a : R) (f : RS) (hf : f n 0 = 0) :
Polynomial.sum ( a) f = f n a
@[simp]
theorem Polynomial.sum_C_index {R : Type u} [] {a : R} {β : Type u_1} [] {f : Rβ} (h : f 0 0 = 0) :
Polynomial.sum (Polynomial.C a) f = f 0 a
@[simp]
theorem Polynomial.sum_X_index {R : Type u} [] {S : Type u_1} [] {f : RS} (hf : f 1 0 = 0) :
Polynomial.sum Polynomial.X f = f 1 1
theorem Polynomial.sum_add_index {R : Type u} [] {S : Type u_1} [] (p : ) (q : ) (f : RS) (hf : ∀ (i : ), f i 0 = 0) (h_add : ∀ (a : ) (b₁ b₂ : R), f a (b₁ + b₂) = f a b₁ + f a b₂) :
Polynomial.sum (p + q) f = +
theorem Polynomial.sum_add' {R : Type u} [] {S : Type u_1} [] (p : ) (f : RS) (g : RS) :
Polynomial.sum p (f + g) = +
theorem Polynomial.sum_add {R : Type u} [] {S : Type u_1} [] (p : ) (f : RS) (g : RS) :
(Polynomial.sum p fun (n : ) (x : R) => f n x + g n x) = +
theorem Polynomial.sum_smul_index {R : Type u} [] {S : Type u_1} [] (p : ) (b : R) (f : RS) (hf : ∀ (i : ), f i 0 = 0) :
Polynomial.sum (b p) f = Polynomial.sum p fun (n : ) (a : R) => f n (b * a)
theorem Polynomial.sum_monomial_eq {R : Type u} [] (p : ) :
(Polynomial.sum p fun (n : ) (a : R) => a) = p
theorem Polynomial.sum_C_mul_X_pow_eq {R : Type u} [] (p : ) :
(Polynomial.sum p fun (n : ) (a : R) => Polynomial.C a * Polynomial.X ^ n) = p
@[irreducible]
def Polynomial.erase {R : Type u_1} [] (n : ) :

erase p n is the polynomial p in which the X^n term has been erased.

Equations
Instances For
theorem Polynomial.erase_def {R : Type u_1} [] (n : ) :
∀ (x : ), = match x with | { toFinsupp := p } => { toFinsupp := }
@[simp]
theorem Polynomial.toFinsupp_erase {R : Type u} [] (p : ) (n : ) :
().toFinsupp = Finsupp.erase n p.toFinsupp
@[simp]
theorem Polynomial.ofFinsupp_erase {R : Type u} [] (p : ) (n : ) :
{ toFinsupp := } = Polynomial.erase n { toFinsupp := p }
@[simp]
theorem Polynomial.support_erase {R : Type u} [] (p : ) (n : ) :
theorem Polynomial.monomial_add_erase {R : Type u} [] (p : ) (n : ) :
() + = p
theorem Polynomial.coeff_erase {R : Type u} [] (p : ) (n : ) (i : ) :
= if i = n then 0 else
@[simp]
theorem Polynomial.erase_zero {R : Type u} [] (n : ) :
= 0
@[simp]
theorem Polynomial.erase_monomial {R : Type u} [] {n : } {a : R} :
@[simp]
theorem Polynomial.erase_same {R : Type u} [] (p : ) (n : ) :
= 0
@[simp]
theorem Polynomial.erase_ne {R : Type u} [] (p : ) (n : ) (i : ) (h : i n) :
=
def Polynomial.update {R : Type u} [] (p : ) (n : ) (a : R) :

Replace the coefficient of a p : R[X] at a given degree n : ℕ by a given value a : R. If a = 0, this is equal to p.erase n If p.natDegree < n and a ≠ 0, this increases the degree to n.

Equations
Instances For
theorem Polynomial.coeff_update {R : Type u} [] (p : ) (n : ) (a : R) :
=
theorem Polynomial.coeff_update_apply {R : Type u} [] (p : ) (n : ) (a : R) (i : ) :
Polynomial.coeff () i = if i = n then a else
@[simp]
theorem Polynomial.coeff_update_same {R : Type u} [] (p : ) (n : ) (a : R) :
theorem Polynomial.coeff_update_ne {R : Type u} [] (p : ) {n : } (a : R) {i : } (h : i n) :
@[simp]
theorem Polynomial.update_zero_eq_erase {R : Type u} [] (p : ) (n : ) :
=
theorem Polynomial.support_update {R : Type u} [] (p : ) (n : ) (a : R) [Decidable (a = 0)] :
= if a = 0 then else
theorem Polynomial.support_update_zero {R : Type u} [] (p : ) (n : ) :
theorem Polynomial.support_update_ne_zero {R : Type u} [] (p : ) (n : ) {a : R} (ha : a 0) :
=
instance Polynomial.commSemiring {R : Type u} [] :
Equations
• One or more equations did not get rendered due to their size.
instance Polynomial.intCast {R : Type u} [Ring R] :
Equations
• Polynomial.intCast = { intCast := fun (n : ) => { toFinsupp := n } }
instance Polynomial.ring {R : Type u} [Ring R] :
Ring ()
Equations
• One or more equations did not get rendered due to their size.
@[simp]
theorem Polynomial.coeff_neg {R : Type u} [Ring R] (p : ) (n : ) :
=
@[simp]
theorem Polynomial.coeff_sub {R : Type u} [Ring R] (p : ) (q : ) (n : ) :
theorem Polynomial.monomial_neg {R : Type u} [Ring R] (n : ) (a : R) :
(-a) = - a
theorem Polynomial.monomial_sub {R : Type u} {a : R} {b : R} [Ring R] (n : ) :
(a - b) = a - b
@[simp]
theorem Polynomial.support_neg {R : Type u} [Ring R] {p : } :
theorem Polynomial.C_eq_int_cast {R : Type u} [Ring R] (n : ) :
Polynomial.C n = n
theorem Polynomial.C_neg {R : Type u} {a : R} [Ring R] :
Polynomial.C (-a) = -Polynomial.C a
theorem Polynomial.C_sub {R : Type u} {a : R} {b : R} [Ring R] :
Polynomial.C (a - b) = Polynomial.C a - Polynomial.C b
instance Polynomial.commRing {R : Type u} [] :
Equations
instance Polynomial.nontrivial {R : Type u} [] [] :
Equations
• (_ : ) = (_ : )
@[simp]
theorem Polynomial.X_ne_zero {R : Type u} [] [] :
Polynomial.X 0
theorem Polynomial.rat_smul_eq_C_mul {R : Type u} [] (a : ) (f : ) :
a f = Polynomial.C a * f
@[simp]
theorem Polynomial.nontrivial_iff {R : Type u} [] :
instance Polynomial.repr {R : Type u} [] [Repr R] [] :
Repr ()
Equations
• One or more equations did not get rendered due to their size.