Multivariate polynomials #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file defines polynomial rings over a base ring (or even semiring),
with variables from a general type σ
(which could be infinite).
Important definitions #
Let R
be a commutative ring (or a semiring) and let σ
be an arbitrary
type. This file creates the type mv_polynomial σ R
, which mathematicians
might denote $R[X_i : i \in σ]$. It is the type of multivariate
(a.k.a. multivariable) polynomials, with variables
corresponding to the terms in σ
, and coefficients in R
.
Notation #
In the definitions below, we use the following notation:
σ : Type*
(indexing the variables)R : Type*
[comm_semiring R]
(the coefficients)s : σ →₀ ℕ
, a function fromσ
toℕ
which is zero away from a finite set. This will give rise to a monomial inmv_polynomial σ R
which mathematicians might callX^s
a : R
i : σ
, with corresponding monomialX i
, often denotedX_i
by mathematiciansp : mv_polynomial σ R
Definitions #
mv_polynomial σ R
: the type of polynomials with variables of typeσ
and coefficients in the commutative semiringR
monomial s a
: the monomial which mathematically would be denoteda * X^s
C a
: the constant polynomial with valuea
X i
: the degree one monomial corresponding to i; mathematically this might be denotedXᵢ
.coeff s p
: the coefficient ofs
inp
.eval₂ (f : R → S₁) (g : σ → S₁) p
: given a semiring homomorphism fromR
to another semiringS₁
, and a mapσ → S₁
, evaluatesp
at this valuation, returning a term of typeS₁
. Note thateval₂
can be made usingeval
andmap
(see below), and it has been suggested that sticking toeval
andmap
might make the code less brittle.eval (g : σ → R) p
: given a mapσ → R
, evaluatesp
at this valuation, returning a term of typeR
map (f : R → S₁) p
: returns the multivariate polynomial obtained fromp
by the change of coefficient semiring corresponding tof
Implementation notes #
Recall that if Y
has a zero, then X →₀ Y
is the type of functions from X
to Y
with finite
support, i.e. such that only finitely many elements of X
get sent to non-zero terms in Y
.
The definition of mv_polynomial σ R
is (σ →₀ ℕ) →₀ R
; here σ →₀ ℕ
denotes the space of all
monomials in the variables, and the function to R
sends a monomial to its coefficient in
the polynomial being represented.
Tags #
polynomial, multivariate polynomial, multivariable polynomial
Multivariate polynomial, where σ
is the index set of the variables and
R
is the coefficient ring
Equations
- mv_polynomial σ R = add_monoid_algebra R (σ →₀ ℕ)
Instances for mv_polynomial
- mv_polynomial.unique_factorization_monoid
- mv_polynomial.comm_semiring
- mv_polynomial.inhabited
- mv_polynomial.distrib_mul_action
- mv_polynomial.smul_zero_class
- mv_polynomial.has_faithful_smul
- mv_polynomial.module
- mv_polynomial.is_scalar_tower
- mv_polynomial.smul_comm_class
- mv_polynomial.is_central_scalar
- mv_polynomial.algebra
- mv_polynomial.is_scalar_tower_right
- mv_polynomial.smul_comm_class_right
- mv_polynomial.unique
- mv_polynomial.infinite_of_infinite
- mv_polynomial.infinite_of_nonempty
- mv_polynomial.comm_ring
- mv_polynomial.is_noetherian_ring
- mv_polynomial.no_zero_divisors
- mv_polynomial.is_domain
- mv_polynomial.coe_to_mv_power_series
- mv_power_series.algebra_mv_polynomial
- mv_polynomial.char_p
- mv_polynomial.monad
- mv_polynomial.is_lawful_functor
- mv_polynomial.is_lawful_monad
- ideal.mv_polynomial.is_jacobson
- algebra.formally_smooth.mv_polynomial
Equations
- mv_polynomial.inhabited = {default := 0}
Equations
Equations
If R
is a subsingleton, then mv_polynomial σ R
has a unique element
Equations
monomial s a
is the monomial with coefficient a
and exponents given by s
Equations
C a
is the constant polynomial with value a
Equations
- mv_polynomial.C = {to_fun := ⇑(mv_polynomial.monomial 0), map_one' := _, map_mul' := _, map_zero' := _, map_add' := _}
X n
is the degree 1
monomial $X_n$.
Equations
- mv_polynomial.X n = ⇑(mv_polynomial.monomial (finsupp.single n 1)) 1
λ s, monomial s 1
as a homomorphism.
Equations
- mv_polynomial.monomial_one_hom R σ = add_monoid_algebra.of R (σ →₀ ℕ)
Analog of polynomial.induction_on'
.
To prove something about mv_polynomials,
it suffices to show the condition is closed under taking sums,
and it holds for monomials.
Similar to mv_polynomial.induction_on
but only a weak form of h_add
is required.
Similar to mv_polynomial.induction_on
but only a yet weaker form of h_add
is required.
Analog of polynomial.induction_on
.
The finite set of all m : σ →₀ ℕ
such that X^m
has a non-zero coefficient.
The coefficient of the monomial m
in the multi-variable polynomial p
.
Equations
- mv_polynomial.coeff m p = ⇑p m
mv_polynomial.coeff m
but promoted to an add_monoid_hom
.
Equations
- mv_polynomial.coeff_add_monoid_hom m = {to_fun := mv_polynomial.coeff m, map_zero' := _, map_add' := _}
constant_coeff p
returns the constant term of the polynomial p
, defined as coeff 0 p
.
This is a ring homomorphism.
Equations
- mv_polynomial.constant_coeff = {to_fun := mv_polynomial.coeff 0, map_one' := _, map_mul' := _, map_zero' := _, map_add' := _}
Evaluate a polynomial p
given a valuation g
of all the variables
and a ring hom f
from the scalar ring to the target
Equations
- mv_polynomial.eval₂ f g p = finsupp.sum p (λ (s : σ →₀ ℕ) (a : R), ⇑f a * s.prod (λ (n : σ) (e : ℕ), g n ^ e))
mv_polynomial.eval₂
as a ring_hom
.
Equations
- mv_polynomial.eval₂_hom f g = {to_fun := mv_polynomial.eval₂ f g, map_one' := _, map_mul' := _, map_zero' := _, map_add' := _}
Evaluate a polynomial p
given a valuation f
of all the variables
Equations
map f p
maps a polynomial p
across a ring hom f
Equations
If f
is a left-inverse of g
then map f
is a left-inverse of map g
.
If f
is a right-inverse of g
then map f
is a right-inverse of map g
.
If f : S₁ →ₐ[R] S₂
is a morphism of R
-algebras, then so is mv_polynomial.map f
.
The algebra of multivariate polynomials #
A map σ → S₁
where S₁
is an algebra over R
generates an R
-algebra homomorphism
from multivariate polynomials over σ
to S₁
.
Equations
- mv_polynomial.aeval f = {to_fun := (mv_polynomial.eval₂_hom (algebra_map R S₁) f).to_fun, map_one' := _, map_mul' := _, map_zero' := _, map_add' := _, commutes' := _}
Version of aeval
for defining algebra homs out of mv_polynomial σ R
over a smaller base ring
than R
.