Monad operations on mv_polynomial #
This file defines two monadic operations on mv_polynomial. Given p : mv_polynomial σ R,
mv_polynomial.bind₁andmv_polynomial.join₁operate on the variable typeσ.mv_polynomial.bind₂andmv_polynomial.join₂operate on the coefficient typeR.
mv_polynomial.bind₁ f φwithf : σ → mv_polynomial τ Randφ : mv_polynomial σ R, is the polynomialφ(f 1, ..., f i, ...) : mv_polynomial τ R.mv_polynomial.join₁ φwithφ : mv_polynomial (mv_polynomial σ R) Rcollapsesφto amv_polynomial σ R, by evaluatingφunder the mapX f ↦ fforf : mv_polynomial σ R. In other words, if you have a polynomialφin a set of variables indexed by a polynomial ring, you evaluate the polynomial in these indexing polynomials.mv_polynomial.bind₂ f φwithf : R →+* mv_polynomial σ Sandφ : mv_polynomial σ Ris themv_polynomial σ Sobtained fromφby mapping the coefficients ofφthroughfand considering the resulting polynomial as polynomial expression inmv_polynomial σ R.mv_polynomial.join₂ φwithφ : mv_polynomial σ (mv_polynomial σ R)collapsesφto amv_polynomial σ R, by consideringφas polynomial expression inmv_polynomial σ R.
These operations themselves have algebraic structure: mv_polynomial.bind₁
and mv_polynomial.join₁ are algebra homs and
mv_polynomial.bind₂ and mv_polynomial.join₂ are ring homs.
They interact in convenient ways with mv_polynomial.rename, mv_polynomial.map,
mv_polynomial.vars, and other polynomial operations.
Indeed, mv_polynomial.rename is the "map" operation for the (bind₁, join₁) pair,
whereas mv_polynomial.map is the "map" operation for the other pair.
Implementation notes #
We add an is_lawful_monad instance for the (bind₁, join₁) pair.
The second pair cannot be instantiated as a monad,
since it is not a monad in Type but in CommRing (or rather CommSemiRing).
bind₁ is the "left hand side" bind operation on mv_polynomial, operating on the variable type.
Given a polynomial p : mv_polynomial σ R and a map f : σ → mv_polynomial τ R taking variables
in p to polynomials in the variable type τ, bind₁ f p replaces each variable in p with
its value under f, producing a new polynomial in τ. The coefficient type remains the same.
This operation is an algebra hom.
Equations
bind₂ is the "right hand side" bind operation on mv_polynomial,
operating on the coefficient type.
Given a polynomial p : mv_polynomial σ R and
a map f : R → mv_polynomial σ S taking coefficients in p to polynomials over a new ring S,
bind₂ f p replaces each coefficient in p with its value under f,
producing a new polynomial over S.
The variable type remains the same. This operation is a ring hom.
Equations
join₁ is the monadic join operation corresponding to mv_polynomial.bind₁. Given a polynomial p
with coefficients in R whose variables are polynomials in σ with coefficients in R,
join₁ p collapses p to a polynomial with variables in σ and coefficients in R.
This operation is an algebra hom.
Equations
join₂ is the monadic join operation corresponding to mv_polynomial.bind₂. Given a polynomial p
with variables in σ whose coefficients are polynomials in σ with coefficients in R,
join₂ p collapses p to a polynomial with variables in σ and coefficients in R.
This operation is a ring hom.