The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V09. Commutative algebra I: ideals, polynomials, factorization

Mathlib.Algebra.Polynomial.Basic

159 declarations and 77 deprecated aliases. Mathlib docs · Source

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 ∈ 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.
  • ofMultiset s is the monic polynomial p which has roots s.

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 cannot 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.

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.

abbrev Polynomial E3 #

(R : Type u_1) → [Semiring R] → Type u_1

Polynomial R is the type of univariate polynomials over R, denoted as R[X] within the Polynomial namespace.

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

def Polynomial.«term__[_X_]» E1 #

Lean.TrailingParserDescr

Polynomial R is the type of univariate polynomials over R, denoted as R[X] within the Polynomial namespace.

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

def Polynomial.unexpander E1 #

Lean.PrettyPrinter.Unexpander

Unexpander for Polynomial.

theorem IsSMulRegular.polynomial E1 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : SMulZeroClass S R] {a : S},
  IsSMulRegular R a → IsSMulRegular (Polynomial R) a

def Polynomial.support E1 #

{R : Type u} → [inst : Semiring R] → Polynomial R → Finset ℕ

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

theorem Polynomial.support_ofCoeff E1 #

∀ {R : Type u} [inst : Semiring R] (q : ℕ →₀ R), Polynomial.support (AddMonoidAlgebra.ofCoeff q) = q.support

theorem Polynomial.support_zero E0 #

∀ {R : Type u} [inst : Semiring R], Polynomial.support 0 = ∅

theorem Polynomial.support_eq_empty E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R}, p.support = ∅ ↔ p = 0

theorem Polynomial.support_nonempty E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R}, p.support.Nonempty ↔ p ≠ 0

theorem Polynomial.card_support_eq_zero E1 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R}, p.support.card = 0 ↔ p = 0

def Polynomial.monomial E1 #

{R : Type u} → [inst : Semiring R] → ℕ → R →ₗ[R] Polynomial R

monomial s a is the monomial a * X^s

theorem Polynomial.coeff_monomial E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (r : R), ((Polynomial.monomial n) r).coeff = fun₀ | n => r

theorem Polynomial.single_eq_monomial E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (r : R), AddMonoidAlgebra.single n r = (Polynomial.monomial n) r

theorem Polynomial.monomial_zero_right E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ), (Polynomial.monomial n) 0 = 0

theorem Polynomial.monomial_zero_one E1 #

∀ {R : Type u} [inst : Semiring R], (Polynomial.monomial 0) 1 = 1

theorem Polynomial.monomial_mul_monomial E1 #

∀ {R : Type u} [inst : Semiring R] (n m : ℕ) (r s : R),
  (Polynomial.monomial n) r * (Polynomial.monomial m) s = (Polynomial.monomial (n + m)) (r * s)

theorem Polynomial.monomial_pow E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (r : R) (k : ℕ),
  (Polynomial.monomial n) r ^ k = (Polynomial.monomial (n * k)) (r ^ k)

theorem Polynomial.smul_monomial E1 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : SMulZeroClass S R] (a : S) (n : ℕ) (b : R),
  a • (Polynomial.monomial n) b = (Polynomial.monomial n) (a • b)

theorem Polynomial.monomial_injective E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ), Function.Injective ⇑(Polynomial.monomial n)

theorem Polynomial.monomial_eq_zero_iff E0 #

∀ {R : Type u} [inst : Semiring R] (t : R) (n : ℕ), (Polynomial.monomial n) t = 0 ↔ t = 0

theorem Polynomial.monomial_eq_monomial_iff E0 #

∀ {R : Type u} [inst : Semiring R] {m n : ℕ} {a b : R},
  (Polynomial.monomial m) a = (Polynomial.monomial n) b ↔ m = n ∧ a = b ∨ a = 0 ∧ b = 0

theorem Polynomial.support_add E1 #

∀ {R : Type u} [inst : Semiring R] {p q : Polynomial R}, (p + q).support ⊆ p.support ∪ q.support

def Polynomial.C E1 #

{R : Type u} → [inst : Semiring R] → R →+* Polynomial R

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

theorem Polynomial.monomial_zero_left E0 #

∀ {R : Type u} [inst : Semiring R] ⦃a : R⦄, (Polynomial.monomial 0) a = Polynomial.C a

theorem Polynomial.C_0 E1 #

∀ {R : Type u} [inst : Semiring R], Polynomial.C 0 = 0

theorem Polynomial.C_1 E1 #

∀ {R : Type u} [inst : Semiring R], Polynomial.C 1 = 1

theorem Polynomial.C_ofNat E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) [inst_1 : n.AtLeastTwo], Polynomial.C (OfNat.ofNat n) = OfNat.ofNat n

theorem Polynomial.C_mul E1 #

∀ {R : Type u} {a b : R} [inst : Semiring R], Polynomial.C (a * b) = Polynomial.C a * Polynomial.C b

theorem Polynomial.C_add E1 #

∀ {R : Type u} {a b : R} [inst : Semiring R], Polynomial.C (a + b) = Polynomial.C a + Polynomial.C b

theorem Polynomial.smul_C E0 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : SMulZeroClass S R] (s : S) (r : R),
  s • Polynomial.C r = Polynomial.C (s • r)

theorem Polynomial.C_pow E1 #

∀ {R : Type u} {a : R} {n : ℕ} [inst : Semiring R], Polynomial.C (a ^ n) = Polynomial.C a ^ n

theorem Polynomial.C_eq_natCast E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ), Polynomial.C ↑n = ↑n

theorem Polynomial.C_mul_monomial E0 #

∀ {R : Type u} {a b : R} {n : ℕ} [inst : Semiring R],
  Polynomial.C a * (Polynomial.monomial n) b = (Polynomial.monomial n) (a * b)

theorem Polynomial.monomial_mul_C E0 #

∀ {R : Type u} {a b : R} {n : ℕ} [inst : Semiring R],
  (Polynomial.monomial n) a * Polynomial.C b = (Polynomial.monomial n) (a * b)

def Polynomial.X E1 #

{R : Type u} → [inst : Semiring R] → Polynomial R

X is the polynomial variable (aka indeterminate).

theorem Polynomial.monomial_one_one_eq_X E1 #

∀ {R : Type u} [inst : Semiring R], (Polynomial.monomial 1) 1 = Polynomial.X

theorem Polynomial.monomial_one_right_eq_X_pow E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ), (Polynomial.monomial n) 1 = Polynomial.X ^ n

theorem Polynomial.X_eq_single E1 #

∀ {R : Type u} [inst : Semiring R], Polynomial.X = AddMonoidAlgebra.single 1 1

theorem Polynomial.X_ne_C E1 #

∀ {R : Type u} [inst : Semiring R] [Nontrivial R] (a : R), Polynomial.X ≠ Polynomial.C a

theorem Polynomial.X_mul E1 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R}, Polynomial.X * p = p * Polynomial.X

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

theorem Polynomial.X_pow_mul E1 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R} {n : ℕ}, Polynomial.X ^ n * p = p * Polynomial.X ^ n

theorem Polynomial.X_mul_C E0 #

∀ {R : Type u} [inst : Semiring R] (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.

theorem Polynomial.X_pow_mul_C E0 #

∀ {R : Type u} [inst : Semiring R] (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 E1 #

∀ {R : Type u} [inst : Semiring R] {p q : Polynomial R} {n : ℕ}, p * Polynomial.X ^ n * q = p * q * Polynomial.X ^ n

theorem Polynomial.X_pow_mul_assoc_C E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R} {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 E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R), Commute Polynomial.X p

theorem Polynomial.commute_X_pow E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ), Commute (Polynomial.X ^ n) p

theorem Polynomial.monomial_mul_X E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (r : R),
  (Polynomial.monomial n) r * Polynomial.X = (Polynomial.monomial (n + 1)) r

theorem Polynomial.monomial_mul_X_pow E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (r : R) (k : ℕ),
  (Polynomial.monomial n) r * Polynomial.X ^ k = (Polynomial.monomial (n + k)) r

theorem Polynomial.X_mul_monomial E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (r : R),
  Polynomial.X * (Polynomial.monomial n) r = (Polynomial.monomial (n + 1)) r

theorem Polynomial.X_pow_mul_monomial E0 #

∀ {R : Type u} [inst : Semiring R] (k n : ℕ) (r : R),
  Polynomial.X ^ k * (Polynomial.monomial n) r = (Polynomial.monomial (n + k)) r

theorem Polynomial.coeff_monomial_apply E0 #

∀ {R : Type u} {a : R} {m n : ℕ} [inst : Semiring R], ((Polynomial.monomial n) a).coeff m = if n = m then a else 0

theorem Polynomial.coeff_monomial_same E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (c : R), ((Polynomial.monomial n) c).coeff n = c

theorem Polynomial.coeff_monomial_of_ne E1 #

∀ {R : Type u} [inst : Semiring R] {m n : ℕ} (c : R), m ≠ n → ((Polynomial.monomial n) c).coeff m = 0

theorem Polynomial.coeff_zero E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ), (AddMonoidAlgebra.coeff 0) n = 0

theorem Polynomial.coeff_one E1 #

∀ {R : Type u} [inst : Semiring R] {n : ℕ}, (AddMonoidAlgebra.coeff 1) n = if n = 0 then 1 else 0

theorem Polynomial.coeff_X_zero E0 #

∀ {R : Type u} [inst : Semiring R], Polynomial.X.coeff 0 = 0

theorem Polynomial.coeff_X_one E0 #

∀ {R : Type u} [inst : Semiring R], Polynomial.X.coeff 1 = 1

theorem Polynomial.coeff_monomial_succ E1 #

∀ {R : Type u} {a : R} {n : ℕ} [inst : Semiring R], ((Polynomial.monomial (n + 1)) a).coeff 0 = 0

theorem Polynomial.coeff_X E1 #

∀ {R : Type u} {n : ℕ} [inst : Semiring R], Polynomial.X.coeff n = if 1 = n then 1 else 0

theorem Polynomial.coeff_X_of_ne_one E1 #

∀ {R : Type u} [inst : Semiring R] {n : ℕ}, n ≠ 1 → Polynomial.X.coeff n = 0

theorem Polynomial.mem_support_iff E0 #

∀ {R : Type u} {n : ℕ} [inst : Semiring R] {p : Polynomial R}, n ∈ p.support ↔ p.coeff n ≠ 0

theorem Polynomial.notMem_support_iff E0 #

∀ {R : Type u} {n : ℕ} [inst : Semiring R] {p : Polynomial R}, n ∉ p.support ↔ p.coeff n = 0

theorem Polynomial.coeff_C E1 #

∀ {R : Type u} {a : R} {n : ℕ} [inst : Semiring R], (Polynomial.C a).coeff n = if n = 0 then a else 0

theorem Polynomial.coeff_C_zero E0 #

∀ {R : Type u} {a : R} [inst : Semiring R], (Polynomial.C a).coeff 0 = a

theorem Polynomial.coeff_C_of_ne_zero E1 #

∀ {R : Type u} {a : R} {n : ℕ} [inst : Semiring R], n ≠ 0 → (Polynomial.C a).coeff n = 0

theorem Polynomial.coeff_C_succ E0 #

∀ {R : Type u} [inst : Semiring R] {r : R} {n : ℕ}, (Polynomial.C r).coeff (n + 1) = 0

theorem Polynomial.coeff_natCast_ite E1 #

∀ {R : Type u} {m n : ℕ} [inst : Semiring R], (↑m).coeff n = ↑(if n = 0 then m else 0)

theorem Polynomial.coeff_ofNat_zero E1 #

∀ {R : Type u} [inst : Semiring R] (a : ℕ) [inst_1 : a.AtLeastTwo], (OfNat.ofNat a).coeff 0 = OfNat.ofNat a

theorem Polynomial.coeff_ofNat_succ E1 #

∀ {R : Type u} [inst : Semiring R] (a n : ℕ) [inst_1 : a.AtLeastTwo], (OfNat.ofNat a).coeff (n + 1) = 0

theorem Polynomial.C_mul_X_pow_eq_monomial E1 #

∀ {R : Type u} {a : R} [inst : Semiring R] {n : ℕ}, Polynomial.C a * Polynomial.X ^ n = (Polynomial.monomial n) a

theorem Polynomial.C_mul_X_eq_monomial E1 #

∀ {R : Type u} {a : R} [inst : Semiring R], Polynomial.C a * Polynomial.X = (Polynomial.monomial 1) a

theorem Polynomial.C_injective E1 #

∀ {R : Type u} [inst : Semiring R], Function.Injective ⇑Polynomial.C

theorem Polynomial.C_inj E0 #

∀ {R : Type u} {a b : R} [inst : Semiring R], Polynomial.C a = Polynomial.C b ↔ a = b

theorem Polynomial.C_eq_zero E0 #

∀ {R : Type u} {a : R} [inst : Semiring R], Polynomial.C a = 0 ↔ a = 0

theorem Polynomial.C_ne_zero E1 #

∀ {R : Type u} {a : R} [inst : Semiring R], Polynomial.C a ≠ 0 ↔ a ≠ 0

theorem Polynomial.subsingleton_iff_subsingleton E1 #

∀ {R : Type u} [inst : Semiring R], Subsingleton (Polynomial R) ↔ Subsingleton R

theorem Polynomial.Nontrivial.of_polynomial_ne E1 #

∀ {R : Type u} [inst : Semiring R] {p q : Polynomial R}, p ≠ q → Nontrivial R

theorem Polynomial.forall_eq_iff_forall_eq E0 #

∀ {R : Type u} [inst : Semiring R], (∀ (f g : Polynomial R), f = g) ↔ ∀ (a b : R), a = b

theorem Polynomial.addSubmonoid_closure_setOfPred_eq_monomial E1 #

∀ {R : Type u} [inst : Semiring R], AddSubmonoid.closure {p | ∃ n a, p = (Polynomial.monomial n) a} = ⊤

Monomials generate the additive monoid of polynomials.

theorem Polynomial.addHom_ext_iff E0 #

∀ {R : Type u} [inst : Semiring R] {M : Type u_1} [inst_1 : AddZeroClass M] {f g : Polynomial R →+ M},
  f = g ↔ ∀ (n : ℕ) (a : R), f ((Polynomial.monomial n) a) = g ((Polynomial.monomial n) a)

theorem Polynomial.addHom_ext E1 #

∀ {R : Type u} [inst : Semiring R] {M : Type u_1} [inst_1 : AddZeroClass M] {f g : Polynomial R →+ M},
  (∀ (n : ℕ) (a : R), f ((Polynomial.monomial n) a) = g ((Polynomial.monomial n) a)) → f = g

theorem Polynomial.addHom_ext' E1 #

∀ {R : Type u} [inst : Semiring R] {M : Type u_1} [inst_1 : AddZeroClass M] {f g : Polynomial R →+ M},
  (∀ (n : ℕ), f.comp (Polynomial.monomial n).toAddMonoidHom = g.comp (Polynomial.monomial n).toAddMonoidHom) → f = g

theorem Polynomial.addHom_ext'_iff E0 #

∀ {R : Type u} [inst : Semiring R] {M : Type u_1} [inst_1 : AddZeroClass M] {f g : Polynomial R →+ M},
  f = g ↔ ∀ (n : ℕ), f.comp (Polynomial.monomial n).toAddMonoidHom = g.comp (Polynomial.monomial n).toAddMonoidHom

theorem Polynomial.lhom_ext'_iff E0 #

∀ {R : Type u} [inst : Semiring R] {M : Type u_1} [inst_1 : AddCommMonoid M] [inst_2 : Module R M]
  {f g : Polynomial R →ₗ[R] M}, f = g ↔ ∀ (n : ℕ), f ∘ₗ Polynomial.monomial n = g ∘ₗ Polynomial.monomial n

theorem Polynomial.lhom_ext' E1 #

∀ {R : Type u} [inst : Semiring R] {M : Type u_1} [inst_1 : AddCommMonoid M] [inst_2 : Module R M]
  {f g : Polynomial R →ₗ[R] M}, (∀ (n : ℕ), f ∘ₗ Polynomial.monomial n = g ∘ₗ Polynomial.monomial n) → f = g

theorem Polynomial.support_monomial E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) {a : R}, a ≠ 0 → ((Polynomial.monomial n) a).support = {n}

theorem Polynomial.support_monomial_subset E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (a : R), ((Polynomial.monomial n) a).support ⊆ {n}

theorem Polynomial.support_C E0 #

∀ {R : Type u} [inst : Semiring R] {a : R}, a ≠ 0 → (Polynomial.C a).support = {0}

theorem Polynomial.support_C_subset E1 #

∀ {R : Type u} [inst : Semiring R] (a : R), (Polynomial.C a).support ⊆ {0}

theorem Polynomial.support_C_mul_X E0 #

∀ {R : Type u} [inst : Semiring R] {c : R}, c ≠ 0 → (Polynomial.C c * Polynomial.X).support = {1}

theorem Polynomial.support_C_mul_X_subset E1 #

∀ {R : Type u} [inst : Semiring R] (c : R), (Polynomial.C c * Polynomial.X).support ⊆ {1}

theorem Polynomial.support_C_mul_X_pow E0 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) {c : R}, c ≠ 0 → (Polynomial.C c * Polynomial.X ^ n).support = {n}

theorem Polynomial.support_C_mul_X_pow_subset E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (c : R), (Polynomial.C c * Polynomial.X ^ n).support ⊆ {n}

theorem Polynomial.support_binomial_subset E1 #

∀ {R : Type u} [inst : Semiring R] (k m : ℕ) (x y : R),
  (Polynomial.C x * Polynomial.X ^ k + Polynomial.C y * Polynomial.X ^ m).support ⊆ {k, m}

theorem Polynomial.support_trinomial_subset E1 #

∀ {R : Type u} [inst : Semiring R] (k m n : ℕ) (x y z : R),
  (Polynomial.C x * Polynomial.X ^ k + Polynomial.C y * Polynomial.X ^ m + Polynomial.C z * Polynomial.X ^ n).support ⊆
    {k, m, n}

theorem Polynomial.X_pow_eq_monomial E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ), Polynomial.X ^ n = (Polynomial.monomial n) 1

theorem Polynomial.smul_X_eq_monomial E1 #

∀ {R : Type u} {a : R} [inst : Semiring R] {n : ℕ}, a • Polynomial.X ^ n = (Polynomial.monomial n) a

theorem Polynomial.support_X_pow E0 #

∀ {R : Type u} [inst : Semiring R] [Nontrivial R] (n : ℕ), (Polynomial.X ^ n).support = {n}

theorem Polynomial.support_X_empty E1 #

∀ {R : Type u} [inst : Semiring R], 1 = 0 → Polynomial.X.support = ∅

theorem Polynomial.support_X E0 #

∀ {R : Type u} [inst : Semiring R] [Nontrivial R], Polynomial.X.support = {1}

theorem Polynomial.monomial_left_inj E1 #

∀ {R : Type u} [inst : Semiring R] {a : R},
  a ≠ 0 → ∀ {i j : ℕ}, (Polynomial.monomial i) a = (Polynomial.monomial j) a ↔ i = j

theorem Polynomial.binomial_eq_binomial E1 #

∀ {R : Type u} [inst : Semiring R] {k l m n : ℕ} {u v : R},
  u ≠ 0 →
    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.natCast_mul E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) (p : Polynomial R), ↑n * p = n • p

def Polynomial.sum E1 #

{R : Type u} → [inst : Semiring R] → {S : Type u_1} → [AddCommMonoid S] → Polynomial R → (ℕ → R → S) → S

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

theorem Polynomial.sum_def E0 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] (p : Polynomial R) (f : ℕ → R → S),
  p.sum f = ∑ n ∈ p.support, f n (p.coeff n)

theorem Polynomial.sum_eq_of_subset E1 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] {p : Polynomial R} (f : ℕ → R → S),
  (∀ (i : ℕ), f i 0 = 0) → ∀ {s : Finset ℕ}, p.support ⊆ s → p.sum f = ∑ n ∈ s, f n (p.coeff n)

theorem Polynomial.mul_eq_sum_sum E1 #

∀ {R : Type u} [inst : Semiring R] {p q : Polynomial R},
  p * q = ∑ i ∈ p.support, q.sum fun j a ↦ (Polynomial.monomial (i + j)) (p.coeff i * a)

Expressing the product of two polynomials as a double sum.

theorem Polynomial.sum_zero_index E0 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] (f : ℕ → R → S), Polynomial.sum 0 f = 0

theorem Polynomial.sum_monomial_index E0 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] {n : ℕ} (a : R) (f : ℕ → R → S),
  f n 0 = 0 → ((Polynomial.monomial n) a).sum f = f n a

theorem Polynomial.sum_C_index E0 #

∀ {R : Type u} [inst : Semiring R] {a : R} {β : Type u_1} [inst_1 : AddCommMonoid β] {f : ℕ → R → β},
  f 0 0 = 0 → (Polynomial.C a).sum f = f 0 a

theorem Polynomial.sum_X_index E0 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] {f : ℕ → R → S},
  f 1 0 = 0 → Polynomial.X.sum f = f 1 1

theorem Polynomial.sum_add_index E3 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] (p q : Polynomial R) (f : ℕ → R → S),
  (∀ (i : ℕ), f i 0 = 0) → (∀ (a : ℕ) (b₁ b₂ : R), f a (b₁ + b₂) = f a b₁ + f a b₂) → (p + q).sum f = p.sum f + q.sum f

theorem Polynomial.sum_add' E0 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] (p : Polynomial R) (f g : ℕ → R → S),
  p.sum (f + g) = p.sum f + p.sum g

See also Polynomial.sum_add.

theorem Polynomial.sum_add E3 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] (p : Polynomial R) (f g : ℕ → R → S),
  (p.sum fun n x ↦ f n x + g n x) = p.sum f + p.sum g

See also Polynomial.sum_add'.

theorem Polynomial.sum_smul_index E1 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} [inst_1 : AddCommMonoid S] (p : Polynomial R) (b : R) (f : ℕ → R → S),
  (∀ (i : ℕ), f i 0 = 0) → (b • p).sum f = p.sum fun n a ↦ f n (b * a)

See also Polynomial.sum_smul_index' for a version using smul on the RHS.

theorem Polynomial.sum_smul_index' E1 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} {T : Type u_2} [inst_1 : DistribSMul T R] [inst_2 : AddCommMonoid S]
  (p : Polynomial R) (b : T) (f : ℕ → R → S), (∀ (i : ℕ), f i 0 = 0) → (b • p).sum f = p.sum fun n a ↦ f n (b • a)

See also Polynomial.sum_smul_index for a version using multiplication on the RHS.

theorem Polynomial.smul_sum E1 #

∀ {R : Type u} [inst : Semiring R] {S : Type u_1} {T : Type u_2} [inst_1 : AddCommMonoid S] [inst_2 : DistribSMul T S]
  (p : Polynomial R) (b : T) (f : ℕ → R → S), b • p.sum f = p.sum fun n a ↦ b • f n a

theorem Polynomial.sum_monomial_eq E0 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R), (p.sum fun n a ↦ (Polynomial.monomial n) a) = p

theorem Polynomial.sum_C_mul_X_pow_eq E0 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R), (p.sum fun n a ↦ Polynomial.C a * Polynomial.X ^ n) = p

theorem Polynomial.induction_on E1 #

∀ {R : Type u} [inst : Semiring R] {motive : Polynomial R → Prop} (p : Polynomial R),
  (∀ (a : R), motive (Polynomial.C a)) →
    (∀ (p q : Polynomial R), motive p → motive q → motive (p + q)) →
      (∀ (n : ℕ) (a : R),
          motive (Polynomial.C a * Polynomial.X ^ n) → motive (Polynomial.C a * Polynomial.X ^ (n + 1))) →
        motive p

theorem Polynomial.induction_on' E1 #

∀ {R : Type u} [inst : Semiring R] {motive : Polynomial R → Prop} (p : Polynomial R),
  (∀ (p q : Polynomial R), motive p → motive q → motive (p + q)) →
    (∀ (n : ℕ) (a : R), motive ((Polynomial.monomial n) a)) → motive p

To prove something about polynomials, it suffices to show the condition is closed under taking sums, and it holds for monomials.

theorem Polynomial.support_erase E0 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ),
  Polynomial.support (AddMonoidAlgebra.erase n p) = p.support.erase n

theorem Polynomial.monomial_add_erase E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ),
  (Polynomial.monomial n) (p.coeff n) + AddMonoidAlgebra.erase n p = p

theorem Polynomial.coeff_erase E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n i : ℕ),
  (AddMonoidAlgebra.erase n p).coeff i = if i = n then 0 else p.coeff i

theorem Polynomial.erase_monomial E0 #

∀ {R : Type u} [inst : Semiring R] {n : ℕ} {a : R}, AddMonoidAlgebra.erase n ((Polynomial.monomial n) a) = 0

theorem Polynomial.coeff_update E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ) (a : R),
  ⇑(AddMonoidAlgebra.update n a p).coeff = Function.update (⇑p.coeff) n a

theorem Polynomial.coeff_update_apply E0 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ) (a : R) (i : ℕ),
  (AddMonoidAlgebra.update n a p).coeff i = if i = n then a else p.coeff i

theorem Polynomial.coeff_update_ne E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) {n i : ℕ} (a : R),
  i ≠ n → (AddMonoidAlgebra.update n a p).coeff i = p.coeff i

theorem Polynomial.update_zero_eq_erase E0 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ),
  AddMonoidAlgebra.update n 0 p = AddMonoidAlgebra.erase n p

theorem Polynomial.support_update E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ) (a : R) [inst_1 : Decidable (a = 0)],
  Polynomial.support (AddMonoidAlgebra.update n a p) = if a = 0 then p.support.erase n else insert n p.support

theorem Polynomial.support_update_zero E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ),
  Polynomial.support (AddMonoidAlgebra.update n 0 p) = p.support.erase n

theorem Polynomial.support_update_ne_zero E1 #

∀ {R : Type u} [inst : Semiring R] (p : Polynomial R) (n : ℕ) {a : R},
  a ≠ 0 → Polynomial.support (AddMonoidAlgebra.update n a p) = insert n p.support

def Polynomial.coeffs E1 #

{R : Type u} → [inst : Semiring R] → Polynomial R → Finset R

The finset of nonzero coefficients of a polynomial.

theorem Polynomial.coeffs_zero E0 #

∀ {R : Type u} [inst : Semiring R], Polynomial.coeffs 0 = ∅

theorem Polynomial.mem_coeffs_iff E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R} {c : R}, c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n

theorem Polynomial.coe_coeffs_subset_iff E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R} {s : Set R},
  ↑p.coeffs ⊆ s ↔ ∀ (n : ℕ), p.coeff n ≠ 0 → p.coeff n ∈ s

theorem Polynomial.coeffs_subset_iff E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R} {s : Finset R},
  p.coeffs ⊆ s ↔ ∀ (n : ℕ), p.coeff n ≠ 0 → p.coeff n ∈ s

theorem Polynomial.coeffs_one E1 #

∀ {R : Type u} [inst : Semiring R], Polynomial.coeffs 1 ⊆ {1}

theorem Polynomial.coeff_mem_coeffs E1 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R} {n : ℕ}, p.coeff n ≠ 0 → p.coeff n ∈ p.coeffs

theorem Polynomial.coeffs_empty_iff E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R}, p.coeffs = ∅ ↔ p = 0

theorem Polynomial.coeffs_nonempty_iff E0 #

∀ {R : Type u} [inst : Semiring R] {p : Polynomial R}, p.coeffs.Nonempty ↔ p ≠ 0

theorem Polynomial.coeffs_monomial E1 #

∀ {R : Type u} [inst : Semiring R] (n : ℕ) {c : R}, c ≠ 0 → ((Polynomial.monomial n) c).coeffs = {c}

theorem Polynomial.coeff_neg E0 #

∀ {R : Type u} [inst : Ring R] (p : Polynomial R) (n : ℕ), (-p).coeff n = -p.coeff n

theorem Polynomial.coeff_sub E0 #

∀ {R : Type u} [inst : Ring R] (p q : Polynomial R) (n : ℕ), (p - q).coeff n = p.coeff n - q.coeff n

theorem Polynomial.monomial_neg E0 #

∀ {R : Type u} [inst : Ring R] (n : ℕ) (a : R), (Polynomial.monomial n) (-a) = -(Polynomial.monomial n) a

theorem Polynomial.monomial_sub E1 #

∀ {R : Type u} {a b : R} [inst : Ring R] (n : ℕ),
  (Polynomial.monomial n) (a - b) = (Polynomial.monomial n) a - (Polynomial.monomial n) b

theorem Polynomial.support_neg E0 #

∀ {R : Type u} [inst : Ring R] {p : Polynomial R}, (-p).support = p.support

theorem Polynomial.C_eq_intCast E1 #

∀ {R : Type u} [inst : Ring R] (n : ℤ), Polynomial.C ↑n = ↑n

theorem Polynomial.C_neg E1 #

∀ {R : Type u} {a : R} [inst : Ring R], Polynomial.C (-a) = -Polynomial.C a

theorem Polynomial.C_sub E1 #

∀ {R : Type u} {a b : R} [inst : Ring R], Polynomial.C (a - b) = Polynomial.C a - Polynomial.C b

theorem Polynomial.X_ne_zero E0 #

∀ {R : Type u} [inst : Semiring R] [Nontrivial R], Polynomial.X ≠ 0

theorem Polynomial.noZeroDivisors_iff E0 #

∀ {R : Type u} [inst : Semiring R], NoZeroDivisors (Polynomial R) ↔ NoZeroDivisors R

See also Polynomial.isCancelMulZero_iff: in order for R[X] to have cancellative multiplication (stronger than NoZeroDivisors in general, but equivalent if R is a ring), R must have both cancellative multiplication and cancellative addition.

theorem Polynomial.nnqsmul_eq_C_mul E1 #

∀ {R : Type u} [inst : DivisionSemiring R] (q : ℚ≥0) (f : Polynomial R), q • f = Polynomial.C ↑q * f

theorem Polynomial.qsmul_eq_C_mul E1 #

∀ {R : Type u} [inst : DivisionRing R] (a : ℚ) (f : Polynomial R), a • f = Polynomial.C ↑a * f

theorem Polynomial.nontrivial_iff E0 #

∀ {R : Type u} [inst : Semiring R], Nontrivial (Polynomial R) ↔ Nontrivial R

def Polynomial.ofMultiset E1 #

{R : Type u} → [inst : CommRing R] → AddChar (Multiset R) (Polynomial R)

The map sending a collection of roots into a polynomial, as a morphism.

theorem Polynomial.ofMultiset_apply E0 #

∀ {R : Type u} [inst : CommRing R] (s : Multiset R),
  Polynomial.ofMultiset s = (Multiset.map (fun a ↦ Polynomial.X - Polynomial.C a) s).prod

instance Polynomial.repr E0 #

{R : Type u} → [inst : Semiring R] → [Repr R] → [DecidableEq R] → Repr (Polynomial R)

Deprecated aliases

NameNew nameSince
Polynomial.addSubmonoid_closure_setOf_eq_monomialPolynomial.addSubmonoid_closure_setOfPred_eq_monomial2026-07-09
Polynomial.coeff_C_ne_zeroPolynomial.coeff_C_of_ne_zero2026-05-20
Polynomial.coeff_injAddMonoidAlgebra.coeff_inj2026-10-25
Polynomial.coeff_injectiveAddMonoidAlgebra.coeff_injective2026-10-25
Polynomial.coeff_ofFinsupp2026-07-18
Polynomial.coeff_one_zeroAddMonoidAlgebra.coeff_one_zero2026-10-25
Polynomial.coeff_update_sameFunction.update_self2026-09-17
Polynomial.erase_neFinsupp.erase_ne2026-09-17
Polynomial.erase_sameFinsupp.erase_same2026-09-17
Polynomial.erase_zeroAddMonoidAlgebra.erase_zero2026-10-25
Polynomial.eta2026-07-18
Polynomial.exists_iff_exists_finsuppAddMonoidAlgebra.exists2026-09-11
Polynomial.extAddMonoidAlgebra.ext2026-10-25
Polynomial.ext_iffAddMonoidAlgebra.ext_iff2026-10-25
Polynomial.finite_range_coeffFinsupp.finite_range2026-10-25
Polynomial.forall_iff_forall_finsuppAddMonoidAlgebra.forall2026-09-11
Polynomial.ofFinsuppid2026-07-18
Polynomial.ofFinsupp_add2026-07-18
Polynomial.ofFinsupp_eq_one2026-07-18
Polynomial.ofFinsupp_eq_zero2026-07-18
Polynomial.ofFinsupp_erase2026-07-18
Polynomial.ofFinsupp_inj2026-07-18
Polynomial.ofFinsupp_intCast2026-07-18
Polynomial.ofFinsupp_mul2026-07-18
Polynomial.ofFinsupp_natCast2026-07-18
Polynomial.ofFinsupp_neg2026-07-18
Polynomial.ofFinsupp_nsmul2026-07-18
Polynomial.ofFinsupp_ofNat2026-07-18
Polynomial.ofFinsupp_one2026-07-18
Polynomial.ofFinsupp_pow2026-07-18
Polynomial.ofFinsupp_singlePolynomial.single_eq_monomial2026-07-18
Polynomial.ofFinsupp_smul2026-07-18
Polynomial.ofFinsupp_sub2026-07-18
Polynomial.ofFinsupp_sum2026-07-18
Polynomial.ofFinsupp_zero2026-07-18
Polynomial.ofFinsupp_zsmul2026-07-18
Polynomial.support_C_mul_X'Polynomial.support_C_mul_X_subset2026-06-09
Polynomial.support_C_mul_X_pow'Polynomial.support_C_mul_X_pow_subset2026-06-09
Polynomial.support_binomial'Polynomial.support_binomial_subset2026-06-09
Polynomial.support_monomial'Polynomial.support_monomial_subset2026-06-09
Polynomial.support_ofFinsupp2026-07-18
Polynomial.support_toFinsupp2026-07-18
Polynomial.support_trinomial'Polynomial.support_trinomial_subset2026-06-09
Polynomial.toFinsuppid2026-07-18
Polynomial.toFinsuppIso2026-07-18
Polynomial.toFinsuppIsoLinear2026-07-18
Polynomial.toFinsuppIsoLinear_apply2026-07-18
Polynomial.toFinsuppIsoLinear_symm_apply2026-07-18
Polynomial.toFinsuppIsoLinear_symm_apply_toFinsupp2026-10-25
Polynomial.toFinsuppIso_apply2026-07-18
Polynomial.toFinsuppIso_symm_apply2026-07-18
Polynomial.toFinsupp_C2026-07-18
Polynomial.toFinsupp_C_mul_XAddMonoidAlgebra.coeff_single2026-07-18
Polynomial.toFinsupp_C_mul_X_pow2026-07-18
Polynomial.toFinsupp_XPolynomial.X_eq_single2026-07-18
Polynomial.toFinsupp_X_pow2026-07-18
Polynomial.toFinsupp_add2026-07-18
Polynomial.toFinsupp_apply2026-07-18
Polynomial.toFinsupp_eq_one2026-07-18
Polynomial.toFinsupp_eq_zero2026-07-18
Polynomial.toFinsupp_erase2026-07-18
Polynomial.toFinsupp_inj2026-07-18
Polynomial.toFinsupp_injectiveFunction.injective_id2026-07-18
Polynomial.toFinsupp_intCast2026-07-18
Polynomial.toFinsupp_monomialPolynomial.coeff_monomial2026-07-18
Polynomial.toFinsupp_mul2026-07-18
Polynomial.toFinsupp_natCast2026-07-18
Polynomial.toFinsupp_neg2026-07-18
Polynomial.toFinsupp_nsmul2026-07-18
Polynomial.toFinsupp_ofNat2026-07-18
Polynomial.toFinsupp_one2026-07-18
Polynomial.toFinsupp_pow2026-07-18
Polynomial.toFinsupp_smul2026-07-18
Polynomial.toFinsupp_sub2026-07-18
Polynomial.toFinsupp_sum2026-07-18
Polynomial.toFinsupp_zero2026-07-18
Polynomial.toFinsupp_zsmul2026-07-18