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:
- We construct an inductive type
FreeAlgebra.Pre R X, the terms of which should be thought of as representatives for the elements ofFreeAlgebra R X. It is the free type with maps fromRandX, and with two binary operationsaddandmul. - We construct an inductive relation
FreeAlgebra.Rel R XonFreeAlgebra.Pre R X. This is the smallest relation for which the quotient is anR-algebra where addition resp. multiplication are induced byaddresp.mulfrom 1., and for which the map fromRis the structure map for the algebra. - The free algebra
FreeAlgebra R Xis the quotient ofFreeAlgebra.Pre R Xby the relationFreeAlgebra.Rel R X.
This inductive type is used to express representatives of the free algebra.
- of {R : Type u_1} {X : Type u_2} : X → Pre R X
- ofScalar {R : Type u_1} {X : Type u_2} : R → Pre R X
- add {R : Type u_1} {X : Type u_2} : Pre R X → Pre R X → Pre R X
- mul {R : Type u_1} {X : Type u_2} : Pre R X → Pre R X → Pre R X
Instances For
Equations
- FreeAlgebra.Pre.instInhabited R X = { default := FreeAlgebra.Pre.ofScalar 0 }
Coercion from X to Pre R X. Note: Used for notation only.
Equations
- FreeAlgebra.Pre.hasCoeGenerator R X = { coe := FreeAlgebra.Pre.of }
Instances For
Coercion from R to Pre R X. Note: Used for notation only.
Equations
- FreeAlgebra.Pre.hasCoeSemiring R X = { coe := FreeAlgebra.Pre.ofScalar }
Instances For
Multiplication in Pre R X defined as Pre.mul. Note: Used for notation only.
Equations
- FreeAlgebra.Pre.hasMul R X = { mul := FreeAlgebra.Pre.mul }
Instances For
Addition in Pre R X defined as Pre.add. Note: Used for notation only.
Equations
- FreeAlgebra.Pre.hasAdd R X = { add := FreeAlgebra.Pre.add }
Instances For
Zero in Pre R X defined as the image of 0 from R. Note: Used for notation only.
Equations
- FreeAlgebra.Pre.hasZero R X = { zero := FreeAlgebra.Pre.ofScalar 0 }
Instances For
One in Pre R X defined as the image of 1 from R. Note: Used for notation only.
Equations
- FreeAlgebra.Pre.hasOne R X = { one := FreeAlgebra.Pre.ofScalar 1 }
Instances For
Scalar multiplication defined as multiplication by the image of elements from R.
Note: Used for notation only.
Equations
- FreeAlgebra.Pre.hasSMul R X = { smul := fun (r : R) (m : FreeAlgebra.Pre R X) => (FreeAlgebra.Pre.ofScalar r).mul m }
Instances For
Given a function from X to an R-algebra A, lift_fun provides a lift of f to a function
from Pre R X to A. This is mainly used in the construction of FreeAlgebra.lift.
Equations
- FreeAlgebra.liftFun R X f (FreeAlgebra.Pre.of t) = f t
- FreeAlgebra.liftFun R X f (a.add b) = FreeAlgebra.liftFun R X f a + FreeAlgebra.liftFun R X f b
- FreeAlgebra.liftFun R X f (a.mul b) = FreeAlgebra.liftFun R X f a * FreeAlgebra.liftFun R X f b
- FreeAlgebra.liftFun R X f (FreeAlgebra.Pre.ofScalar c) = (algebraMap R A) c
Instances For
An inductively defined relation on Pre R X used to force the initial algebra structure on
the associated quotient.
- add_scalar {R : Type u_1} [CommSemiring R] {X : Type u_2} {r s : R} : Rel R X (Pre.ofScalar (r + s)) (Pre.ofScalar r + Pre.ofScalar s)
- mul_scalar {R : Type u_1} [CommSemiring R] {X : Type u_2} {r s : R} : Rel R X (Pre.ofScalar (r * s)) (Pre.ofScalar r * Pre.ofScalar s)
- central_scalar {R : Type u_1} [CommSemiring R] {X : Type u_2} {r : R} {a : Pre R X} : Rel R X (Pre.ofScalar r * a) (a * Pre.ofScalar r)
- add_assoc {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X (a + b + c) (a + (b + c))
- add_comm {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b : Pre R X} : Rel R X (a + b) (b + a)
- zero_add {R : Type u_1} [CommSemiring R] {X : Type u_2} {a : Pre R X} : Rel R X (0 + a) a
- mul_assoc {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X (a * b * c) (a * (b * c))
- one_mul {R : Type u_1} [CommSemiring R] {X : Type u_2} {a : Pre R X} : Rel R X (1 * a) a
- mul_one {R : Type u_1} [CommSemiring R] {X : Type u_2} {a : Pre R X} : Rel R X (a * 1) a
- left_distrib {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X (a * (b + c)) (a * b + a * c)
- right_distrib {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X ((a + b) * c) (a * c + b * c)
- zero_mul {R : Type u_1} [CommSemiring R] {X : Type u_2} {a : Pre R X} : Rel R X (0 * a) 0
- mul_zero {R : Type u_1} [CommSemiring R] {X : Type u_2} {a : Pre R X} : Rel R X (a * 0) 0
- add_compat_left {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X a b → Rel R X (a + c) (b + c)
- add_compat_right {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X a b → Rel R X (c + a) (c + b)
- mul_compat_left {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X a b → Rel R X (a * c) (b * c)
- mul_compat_right {R : Type u_1} [CommSemiring R] {X : Type u_2} {a b c : Pre R X} : Rel R X a b → Rel R X (c * a) (c * b)
Instances For
If α is a type, and R is a commutative semiring, then FreeAlgebra R α is the
free (unital, associative) R-algebra generated by α.
This is an R-algebra equipped with a function FreeAlgebra.ι R : α → FreeAlgebra R α which has
the following universal property: if A is any R-algebra, and f : α → A is any function,
then this function is the composite of FreeAlgebra.ι R and a unique R-algebra homomorphism
FreeAlgebra.lift R f : FreeAlgebra R α →ₐ[R] A.
A typical element of FreeAlgebra R α is an R-linear
combination of formal products of elements of α.
For example if x and y are terms of type α and a, b are terms of type R then
(3 * a * a) • (x * y * x) + (2 * b + 1) • (y * x) + (a * b * b + 3) is a
"typical" element of FreeAlgebra R α. In particular if α is empty
then FreeAlgebra R α is isomorphic to R, and if α has one term t
then FreeAlgebra R α is isomorphic to the polynomial ring R[t].
If α has two or more terms then FreeAlgebra R α is not commutative.
One can think of FreeAlgebra R α as the free non-commutative polynomial ring
with coefficients in R and variables indexed by α.
Equations
- FreeAlgebra R X = Quot (FreeAlgebra.Rel R X)
Instances For
Define the basic operations
Equations
- FreeAlgebra.instSMul R X = { smul := fun (r : R) => Quot.map (HMul.hMul (FreeAlgebra.Pre.ofScalar ((algebraMap R A) r))) ⋯ }
Equations
- FreeAlgebra.instZero R X = { zero := Quot.mk (FreeAlgebra.Rel R X) 0 }
Equations
- FreeAlgebra.instOne R X = { one := Quot.mk (FreeAlgebra.Rel R X) 1 }
Build the semiring structure. We do this one piece at a time as this is convenient for proving
the nsmul fields.
Equations
- One or more equations did not get rendered due to their size.
Equations
- FreeAlgebra.instDistrib R X = { toMul := FreeAlgebra.instMul R X, toAdd := FreeAlgebra.instAdd R X, left_distrib := ⋯, right_distrib := ⋯ }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- FreeAlgebra.instInhabited R X = { default := 0 }
Equations
- One or more equations did not get rendered due to their size.
Equations
The canonical function X → FreeAlgebra R X.
Equations
- FreeAlgebra.ι R m = Quot.mk (FreeAlgebra.Rel R X) (FreeAlgebra.Pre.of m)
Instances For
Given a function f : X → A where A is an R-algebra, lift R f is the unique lift
of f to a morphism of R-algebras FreeAlgebra R X → A.
Equations
- FreeAlgebra.lift R = { toFun := FreeAlgebra.liftAux✝ R, invFun := fun (F : FreeAlgebra R X →ₐ[R] A) => ⇑F ∘ FreeAlgebra.ι R, left_inv := ⋯, right_inv := ⋯ }
Instances For
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.
The free algebra on X is "just" the monoid algebra on the free monoid on X.
This would be useful when constructing linear maps out of a free algebra, for example.
Equations
- One or more equations did not get rendered due to their size.
Instances For
FreeAlgebra R X is nontrivial when R is.
FreeAlgebra R X has no zero-divisors when R has no zero-divisors.
FreeAlgebra R X is a domain when R is an integral domain.
The left-inverse of algebraMap.
Equations
Instances For
An induction principle for the free algebra.
If C holds for the algebraMap of r : R into FreeAlgebra R X, the ι of x : X, and is
preserved under addition and multiplication, then it holds for all of FreeAlgebra R X.
Noncommutative version of Algebra.adjoin_range_eq_range_aeval.
Noncommutative version of Algebra.adjoin_range_eq_range.