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
.
- of: {R : Type u_1} → {X : Type u_2} → X → FreeAlgebra.Pre R X
- of_scalar: {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
This inductive type is used to express representatives of the free algebra.
Instances For
Equations
- FreeAlgebra.Pre.instInhabitedPre R X = { default := FreeAlgebra.Pre.of_scalar 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.of_scalar }
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.of_scalar 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.of_scalar 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 m => FreeAlgebra.Pre.mul (FreeAlgebra.Pre.of_scalar r) 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 (FreeAlgebra.Pre.add a b) = FreeAlgebra.liftFun R X f a + FreeAlgebra.liftFun R X f b
- FreeAlgebra.liftFun R X f (FreeAlgebra.Pre.mul a b) = FreeAlgebra.liftFun R X f a * FreeAlgebra.liftFun R X f b
- FreeAlgebra.liftFun R X f (FreeAlgebra.Pre.of_scalar c) = ↑(algebraMap R A) c
Instances For
- add_scalar: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {r s : R}, FreeAlgebra.Rel R X (FreeAlgebra.Pre.of_scalar (r + s)) (FreeAlgebra.Pre.of_scalar r + FreeAlgebra.Pre.of_scalar s)
- mul_scalar: ∀ {R : Type u_1} [inst : CommSemiring R] {X : Type u_2} {r s : R}, FreeAlgebra.Rel R X (FreeAlgebra.Pre.of_scalar (r * s)) (FreeAlgebra.Pre.of_scalar r * FreeAlgebra.Pre.of_scalar 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.of_scalar r * a) (a * FreeAlgebra.Pre.of_scalar 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)
An inductively defined relation on Pre R X
used to force the initial algebra structure on
the associated quotient.
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
- One or more equations did not get rendered due to their size.
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
- 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.
Build the semiring structure. We do this one piece at a time as this is convenient for proving
the nsmul
fields.
Equations
- FreeAlgebra.instMonoidWithZero R X = MonoidWithZero.mk (_ : ∀ (a : FreeAlgebra R X), 0 * a = 0) (_ : ∀ (a : FreeAlgebra R X), a * 0 = 0)
Equations
- FreeAlgebra.instDistrib R X = Distrib.mk (_ : ∀ (a b c : FreeAlgebra R X), a * (b + c) = a * b + a * c) (_ : ∀ (a b c : FreeAlgebra R X), (a + b) * c = a * c + b * c)
Equations
- FreeAlgebra.instAddCommMonoid R X = AddCommMonoid.mk (_ : ∀ (a b : FreeAlgebra R X), a + b = b + a)
Equations
- One or more equations did not get rendered due to their size.
Equations
- FreeAlgebra.instInhabitedFreeAlgebra R X = { default := 0 }
Equations
- One or more equations did not get rendered due to their size.
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
- One or more equations did not get rendered due to their size.
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
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
.