Monad operations on MvPolynomial
#
This file defines two monadic operations on MvPolynomial
. Given p : MvPolynomial σ R
,
MvPolynomial.bind₁
andMvPolynomial.join₁
operate on the variable typeσ
.MvPolynomial.bind₂
andMvPolynomial.join₂
operate on the coefficient typeR
.
MvPolynomial.bind₁ f φ
withf : σ → MvPolynomial τ R
andφ : MvPolynomial σ R
, is the polynomialφ(f 1, ..., f i, ...) : MvPolynomial τ R
.MvPolynomial.join₁ φ
withφ : MvPolynomial (MvPolynomial σ R) R
collapsesφ
to aMvPolynomial σ R
, by evaluatingφ
under the mapX f ↦ f
forf : 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 φ
withf : R →+* MvPolynomial σ S
andφ : MvPolynomial σ R
is theMvPolynomial σ S
obtained fromφ
by mapping the coefficients ofφ
throughf
and considering the resulting polynomial as polynomial expression inMvPolynomial σ R
.MvPolynomial.join₂ φ
withφ : MvPolynomial σ (MvPolynomial σ R)
collapsesφ
to aMvPolynomial σ R
, by consideringφ
as polynomial expression inMvPolynomial σ 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)