Module docstring
{"# Free Algebras
Given a commutative semiring R, and a type X, we construct the free unital, associative
R-algebra on X.
Notation
FreeAlgebra R Xis the free algebra itself. It is endowed with anR-algebra structure.FreeAlgebra.ι Ris the functionX → FreeAlgebra R X.- Given a function
f : X → Ato an R-algebraA,lift R fis the lift offto anR-algebra morphismFreeAlgebra R X → A.
Theorems
ι_comp_liftstates that the composition(lift R f) ∘ (ι R)is identical tof.lift_uniquestates that whenever an R-algebra morphismg : FreeAlgebra R X → Ais given whose composition withι Risf, then one hasg = lift R f.hom_extis a variant oflift_uniquein the form of an extensionality theorem.lift_comp_ιis a combination ofι_comp_liftandlift_unique. It states that the lift of the composition of an algebra morphism withιis the algebra morphism itself.equivMonoidAlgebraFreeMonoid : FreeAlgebra R X ≃ₐ[R] MonoidAlgebra R (FreeMonoid X)- An inductive principle
induction.
Implementation details
We construct the free algebra on X as a quotient of an inductive type FreeAlgebra.Pre by an
inductively defined relation FreeAlgebra.Rel. Explicitly, the construction involves three steps:
1. We construct an inductive type FreeAlgebra.Pre R X, the terms of which should be thought
of as representatives for the elements of FreeAlgebra R X.
It is the free type with maps from R and X, and with two binary operations add and mul.
2. We construct an inductive relation FreeAlgebra.Rel R X on FreeAlgebra.Pre R X.
This is the smallest relation for which the quotient is an R-algebra where addition resp.
multiplication are induced by add resp. mul from 1., and for which the map from R is the
structure map for the algebra.
3. The free algebra FreeAlgebra R X is the quotient of FreeAlgebra.Pre R X by
the relation FreeAlgebra.Rel R X.
","Define the basic operations ","Build the semiring structure. We do this one piece at a time as this is convenient for proving
the nsmul fields. ","Since we have set the basic definitions as @[Irreducible], from this point onwards one
should only use the universal properties of the free algebra, and consider the actual implementation
as a quotient of an inductive type as completely hidden. "}