Free Algebras #
Given a commutative semiring R
, and a type X
, we construct the free unital, associative
R
-algebra on X
.
Notation #
FreeAlgebra R X
is the free algebra itself. It is endowed with anR
-algebra structure.FreeAlgebra.ι R
is the functionX → FreeAlgebra R X
.- Given a function
f : X → A
to an R-algebraA
,lift R f
is the lift off
to anR
-algebra morphismFreeAlgebra R X → A
.
Theorems #
ι_comp_lift
states that the composition(lift R f) ∘ (ι R)
is identical tof
.lift_unique
states that whenever an R-algebra morphismg : FreeAlgebra R X → A
is given whose composition withι R
isf
, then one hasg = lift R f
.hom_ext
is a variant oflift_unique
in the form of an extensionality theorem.lift_comp_ι
is a combination ofι_comp_lift
andlift_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 fromR
andX
, and with two binary operationsadd
andmul
. - We construct an inductive relation
FreeAlgebra.Rel R X
onFreeAlgebra.Pre R X
. This is the smallest relation for which the quotient is anR
-algebra where addition resp. multiplication are induced byadd
resp.mul
from 1., and for which the map fromR
is the structure map for the algebra. - The free algebra
FreeAlgebra R X
is the quotient ofFreeAlgebra.Pre R X
by 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 → FreeAlgebra.Pre R X
- ofScalar: {R : Type u_1} → {X : Type u_2} → R → FreeAlgebra.Pre R X
- add: {R : Type u_1} → {X : Type u_2} → FreeAlgebra.Pre R X → FreeAlgebra.Pre R X → FreeAlgebra.Pre R X
- mul: {R : Type u_1} → {X : Type u_2} → FreeAlgebra.Pre R X → FreeAlgebra.Pre R X → FreeAlgebra.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} [inst : CommSemiring R] {X : Type u_2} {r s : R}, FreeAlgebra.Rel R X (FreeAlgebra.Pre.ofScalar (r + s)) (FreeAlgebra.Pre.ofScalar r + FreeAlgebra.Pre.ofScalar s)
- mul_scalar: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {r s : R}, FreeAlgebra.Rel R X (FreeAlgebra.Pre.ofScalar (r * s)) (FreeAlgebra.Pre.ofScalar r * FreeAlgebra.Pre.ofScalar s)
- central_scalar: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {r : R} {a : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (FreeAlgebra.Pre.ofScalar r * a) (a * FreeAlgebra.Pre.ofScalar r)
- add_assoc: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (a + b + c) (a + (b + c))
- add_comm: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (a + b) (b + a)
- zero_add: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (0 + a) a
- mul_assoc: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (a * b * c) (a * (b * c))
- one_mul: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (1 * a) a
- mul_one: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (a * 1) a
- left_distrib: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (a * (b + c)) (a * b + a * c)
- right_distrib: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X ((a + b) * c) (a * c + b * c)
- zero_mul: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (0 * a) 0
- mul_zero: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X (a * 0) 0
- add_compat_left: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X a b → FreeAlgebra.Rel R X (a + c) (b + c)
- add_compat_right: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X a b → FreeAlgebra.Rel R X (c + a) (c + b)
- mul_compat_left: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X a b → FreeAlgebra.Rel R X (a * c) (b * c)
- mul_compat_right: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {a b c : FreeAlgebra.Pre R X}, FreeAlgebra.Rel R X a b → FreeAlgebra.Rel R X (c * a) (c * b)
Instances For
The free algebra for the type X
over the commutative semiring R
.
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 }
Equations
- FreeAlgebra.instAdd R X = { add := Quot.map₂ HAdd.hAdd ⋯ ⋯ }
Equations
- FreeAlgebra.instMul R X = { mul := Quot.map₂ HMul.hMul ⋯ ⋯ }
Build the semiring structure. We do this one piece at a time as this is convenient for proving
the nsmul
fields.
Equations
Equations
- FreeAlgebra.instDistrib R X = Distrib.mk ⋯ ⋯
Equations
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
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
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.
See note [partially-applied ext lemmas].
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.
Equations
- ⋯ = ⋯
FreeAlgebra R X
has no zero-divisors when R
has no zero-divisors.
Equations
- ⋯ = ⋯
FreeAlgebra R X
is a domain when R
is an integral domain.
Equations
- ⋯ = ⋯
The left-inverse of algebraMap
.
Equations
- FreeAlgebra.algebraMapInv = (FreeAlgebra.lift R) 0
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 muliplication, 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
.