Monad operations on MvPolynomial #
This file defines two monadic operations on MvPolynomial. Given p : MvPolynomial σ R,
- MvPolynomial.bind₁and- MvPolynomial.join₁operate on the variable type- σ.
- MvPolynomial.bind₂and- MvPolynomial.join₂operate on the coefficient type- R.
- MvPolynomial.bind₁ f φwith- f : σ → MvPolynomial τ Rand- φ : MvPolynomial σ R, is the polynomial- φ(f 1, ..., f i, ...) : MvPolynomial τ R.
- MvPolynomial.join₁ φwith- φ : MvPolynomial (MvPolynomial σ R) Rcollapses- φto a- MvPolynomial σ R, by evaluating- φunder the map- X f ↦ ffor- f : MvPolynomial σ 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.
- MvPolynomial.bind₂ f φwith- f : R →+* MvPolynomial σ Sand- φ : MvPolynomial σ Ris the- MvPolynomial σ Sobtained from- φby mapping the coefficients of- φthrough- fand considering the resulting polynomial as polynomial expression in- MvPolynomial σ R.
- MvPolynomial.join₂ φwith- φ : MvPolynomial σ (MvPolynomial σ R)collapses- φto a- MvPolynomial σ R, by considering- φas polynomial expression in- MvPolynomial σ R.
These operations themselves have algebraic structure: MvPolynomial.bind₁
and MvPolynomial.join₁ are algebra homs and
MvPolynomial.bind₂ and MvPolynomial.join₂ are ring homs.
They interact in convenient ways with MvPolynomial.rename, MvPolynomial.map,
MvPolynomial.vars, and other polynomial operations.
Indeed, MvPolynomial.rename is the "map" operation for the (bind₁, join₁) pair,
whereas MvPolynomial.map is the "map" operation for the other pair.
Implementation notes #
We add a LawfulMonad 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 MvPolynomial, operating on the variable type.
Given a polynomial p : MvPolynomial σ R and a map f : σ → MvPolynomial τ 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
Instances For
bind₂ is the "right hand side" bind operation on MvPolynomial,
operating on the coefficient type.
Given a polynomial p : MvPolynomial σ R and
a map f : R → MvPolynomial σ 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
- MvPolynomial.bind₂ f = MvPolynomial.eval₂Hom f MvPolynomial.X
Instances For
join₁ is the monadic join operation corresponding to MvPolynomial.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
- MvPolynomial.join₁ = MvPolynomial.aeval id
Instances For
join₂ is the monadic join operation corresponding to MvPolynomial.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.
Equations
- MvPolynomial.join₂ = MvPolynomial.eval₂Hom (RingHom.id (MvPolynomial σ R)) MvPolynomial.X
Instances For
Equations
- MvPolynomial.monad = Monad.mk
Equations
- (_ : LawfulFunctor fun (σ : Type u_6) => MvPolynomial σ R) = (_ : LawfulFunctor fun (σ : Type u_6) => MvPolynomial σ R)
Equations
- (_ : LawfulMonad fun (σ : Type u_6) => MvPolynomial σ R) = (_ : LawfulMonad fun (σ : Type u_6) => MvPolynomial σ R)