Free constructions #
Main definitions #
FreeMagma α
: free magma (structure with binary operation without any axioms) over alphabetα
, defined inductively, with traversable instance and decidable equality.MagmaAssocQuotient α
: quotient of a magmaα
by the associativity equivalence relation.FreeSemigroup α
: free semigroup over alphabetα
, defined as a structure with two fieldshead : α
andtail : List α
(i.e. nonempty lists), with traversable instance and decidable equality.FreeMagmaAssocQuotientEquiv α
: isomorphism betweenMagmaAssocQuotient (FreeMagma α)
andFreeSemigroup α
.FreeMagma.lift
: the universal property of the free magma, expressing its adjointness.
If α
is a type, then FreeAddMagma α
is the free additive magma generated by α
.
This is an additive magma equipped with a function FreeAddMagma.of : α → FreeAddMagma α
which has
the following universal property: if M
is any magma, and f : α → M
is any function,
then this function is the composite of FreeAddMagma.of
and a unique additive homomorphism
FreeAddMagma.lift f : FreeAddMagma α →ₙ+ M
.
A typical element of FreeAddMagma α
is a formal non-associative sum of
elements of α
. For example if x
and y
are terms of type α
then x + ((y + y) + x)
is a
"typical" element of FreeAddMagma α
.
One can think of FreeAddMagma α
as the type of binary trees with leaves labelled by α
.
In general, no pair of distinct elements in FreeAddMagma α
will commute.
- of {α : Type u} : α → FreeAddMagma α
- add {α : Type u} : FreeAddMagma α → FreeAddMagma α → FreeAddMagma α
Instances For
If α
is a type, then FreeMagma α
is the free magma generated by α
.
This is a magma equipped with a function FreeMagma.of : α → FreeMagma α
which has
the following universal property: if M
is any magma, and f : α → M
is any function,
then this function is the composite of FreeMagma.of
and a unique multiplicative homomorphism
FreeMagma.lift f : FreeMagma α →ₙ* M
.
A typical element of FreeMagma α
is a formal non-associative product of
elements of α
. For example if x
and y
are terms of type α
then x * ((y * y) * x)
is a
"typical" element of FreeMagma α
.
One can think of FreeMagma α
as the type of binary trees with leaves labelled by α
.
In general, no pair of distinct elements in FreeMagma α
will commute.
Instances For
Equations
Equations
- FreeMagma.instInhabited = { default := FreeMagma.of default }
Equations
- FreeAddMagma.instInhabited = { default := FreeAddMagma.of default }
Equations
- FreeMagma.instMul = { mul := FreeMagma.mul }
Equations
- FreeAddMagma.instAdd = { add := FreeAddMagma.add }
Recursor for FreeMagma
using x * y
instead of FreeMagma.mul x y
.
Equations
- x.recOnMul ih1 ih2 = FreeMagma.recOn x ih1 ih2
Instances For
Recursor for FreeAddMagma
using x + y
instead of FreeAddMagma.add x y
.
Equations
- x.recOnAdd ih1 ih2 = FreeAddMagma.recOn x ih1 ih2
Instances For
Lifts a function α → β
to a magma homomorphism FreeMagma α → β
given a magma β
.
Equations
- FreeMagma.liftAux f (FreeMagma.of x_1) = f x_1
- FreeMagma.liftAux f (x_1.mul y) = FreeMagma.liftAux f x_1 * FreeMagma.liftAux f y
Instances For
Lifts a function α → β
to an additive magma homomorphism FreeAddMagma α → β
given
an additive magma β
.
Equations
- FreeAddMagma.liftAux f (FreeAddMagma.of x_1) = f x_1
- FreeAddMagma.liftAux f (x_1.add y) = FreeAddMagma.liftAux f x_1 + FreeAddMagma.liftAux f y
Instances For
The universal property of the free magma expressing its adjointness.
Equations
- FreeMagma.lift = { toFun := fun (f : α → β) => { toFun := FreeMagma.liftAux f, map_mul' := ⋯ }, invFun := fun (F : FreeMagma α →ₙ* β) => ⇑F ∘ FreeMagma.of, left_inv := ⋯, right_inv := ⋯ }
Instances For
The universal property of the free additive magma expressing its adjointness.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The unique additive magma homomorphism FreeAddMagma α → FreeAddMagma β
that sends
each of x
to of (f x)
.
Equations
Instances For
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.
Recursor on FreeAddMagma
using pure
instead of of
.
Instances For
FreeMagma
is traversable.
Equations
- FreeMagma.traverse F (FreeMagma.of x_1) = FreeMagma.of <$> F x_1
- FreeMagma.traverse F (x_1.mul y) = (fun (x1 x2 : FreeMagma β) => x1 * x2) <$> FreeMagma.traverse F x_1 <*> FreeMagma.traverse F y
Instances For
FreeAddMagma
is traversable.
Equations
- FreeAddMagma.traverse F (FreeAddMagma.of x_1) = FreeAddMagma.of <$> F x_1
- FreeAddMagma.traverse F (x_1.add y) = (fun (x1 x2 : FreeAddMagma β) => x1 + x2) <$> FreeAddMagma.traverse F x_1 <*> FreeAddMagma.traverse F y
Instances For
Equations
- FreeMagma.instTraversable = { toFunctor := Applicative.toFunctor, traverse := @FreeMagma.traverse }
Equations
- FreeAddMagma.instTraversable = { toFunctor := Applicative.toFunctor, traverse := @FreeAddMagma.traverse }
Representation of an element of a free magma.
Equations
- (FreeMagma.of x_1).repr = repr x_1
- (x_1.mul y).repr = Std.Format.text "( " ++ x_1.repr ++ Std.Format.text " * " ++ y.repr ++ Std.Format.text " )"
Instances For
Representation of an element of a free additive magma.
Equations
- (FreeAddMagma.of x_1).repr = repr x_1
- (x_1.add y).repr = Std.Format.text "( " ++ x_1.repr ++ Std.Format.text " + " ++ y.repr ++ Std.Format.text " )"
Instances For
Equations
- instReprFreeAddMagma = { reprPrec := fun (o : FreeAddMagma α) (x : ℕ) => o.repr }
Length of an element of a free additive magma.
Instances For
The length of an element of a free additive magma is positive.
Semigroup quotient of a magma.
Equations
Instances For
Additive semigroup quotient of an additive magma.
Equations
Instances For
Equations
- Magma.AssocQuotient.instSemigroup = { mul := fun (x y : Magma.AssocQuotient α) => Quot.liftOn₂ x y (fun (x y : α) => Quot.mk (Magma.AssocRel α) (x * y)) ⋯ ⋯, mul_assoc := ⋯ }
Equations
- One or more equations did not get rendered due to their size.
Embedding from magma to its free semigroup.
Equations
- Magma.AssocQuotient.of = { toFun := Quot.mk (Magma.AssocRel α), map_mul' := ⋯ }
Instances For
Embedding from additive magma to its free additive semigroup.
Equations
- AddMagma.FreeAddSemigroup.of = { toFun := Quot.mk (AddMagma.AssocRel α), map_add' := ⋯ }
Instances For
Equations
Equations
Lifts a magma homomorphism α → β
to a semigroup homomorphism Magma.AssocQuotient α → β
given a semigroup β
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Lifts an additive magma homomorphism α → β
to an
additive semigroup homomorphism AddMagma.AssocQuotient α → β
given an additive semigroup β
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
From a magma homomorphism α →ₙ* β
to a semigroup homomorphism
Magma.AssocQuotient α →ₙ* Magma.AssocQuotient β
.
Equations
Instances For
From an additive magma homomorphism α → β
to an additive semigroup homomorphism
AddMagma.AssocQuotient α → AddMagma.AssocQuotient β
.
Equations
Instances For
If α
is a type, then FreeAddSemigroup α
is the free additive semigroup generated by α
.
This is an additive semigroup equipped with a function
FreeAddSemigroup.of : α → FreeAddSemigroup α
which has the following universal property:
if M
is any additive semigroup, and f : α → M
is any function,
then this function is the composite of FreeAddSemigroup.of
and a unique semigroup homomorphism
FreeAddSemigroup.lift f : FreeAddSemigroup α →ₙ+ M
.
A typical element of FreeAddSemigroup α
is a nonempty formal sum of elements of α
.
For example if x
and y
are terms of type α
then x + y + y + x
is a
"typical" element of FreeAddSemigroup α
. In particular if α
is empty
then FreeAddSemigroup α
is also empty, and if α
has one term
then FreeAddSemigroup α
is isomorphic to ℕ+
.
If α
has two or more terms then FreeAddSemigroup α
is not commutative.
One can think of FreeAddSemigroup α
as the type of nonempty lists of α
, with addition
given by concatenation.
- head : α
The head of the element
- tail : List α
The tail of the element
Instances For
If α
is a type, then FreeSemigroup α
is the free semigroup generated by α
.
This is a semigroup equipped with a function FreeSemigroup.of : α → FreeSemigroup α
which has
the following universal property: if M
is any semigroup, and f : α → M
is any function,
then this function is the composite of FreeSemigroup.of
and a unique semigroup homomorphism
FreeSemigroup.lift f : FreeSemigroup α →ₙ* M
.
A typical element of FreeSemigroup α
is a nonempty formal product of elements of α
.
For example if x
and y
are terms of type α
then x * y * y * x
is a
"typical" element of FreeSemigroup α
. In particular if α
is empty
then FreeSemigroup α
is also empty, and if α
has one term
then FreeSemigroup α
is isomorphic to Multiplicative ℕ+
.
If α
has two or more terms then FreeSemigroup α
is not commutative.
One can think of FreeSemigroup α
as the type of nonempty lists of α
, with multiplication
given by concatenation.
- head : α
The head of the element
- tail : List α
The tail of the element
Instances For
The embedding α → FreeSemigroup α
.
Instances For
The embedding α → FreeAddSemigroup α
.
Instances For
Length of an element of free semigroup.
Instances For
Length of an element of free additive semigroup
Instances For
Equations
- FreeSemigroup.instInhabited = { default := FreeSemigroup.of default }
Equations
- FreeAddSemigroup.instInhabited = { default := FreeAddSemigroup.of default }
Recursor for free semigroup using of
and *
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Recursor for free additive semigroup using of
and +
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Lifts a function α → β
to a semigroup homomorphism FreeSemigroup α → β
given
a semigroup β
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Lifts a function α → β
to an additive semigroup
homomorphism FreeAddSemigroup α → β
given an additive semigroup β
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The unique additive semigroup homomorphism that sends of x
to of (f x)
.
Equations
Instances For
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.
Recursor that uses pure
instead of of
.
Instances For
Recursor that uses pure
instead of of
.
Instances For
FreeSemigroup
is traversable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
FreeAddSemigroup
is traversable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- FreeSemigroup.instTraversable = { toFunctor := Applicative.toFunctor, traverse := @FreeSemigroup.traverse }
Equations
- FreeAddSemigroup.instTraversable = { toFunctor := Applicative.toFunctor, traverse := @FreeAddSemigroup.traverse }
Equations
- x✝¹.instDecidableEq x✝ = decidable_of_iff' (x✝¹.head = x✝.head ∧ x✝¹.tail = x✝.tail) ⋯
Equations
- x✝¹.instDecidableEq x✝ = decidable_of_iff' (x✝¹.head = x✝.head ∧ x✝¹.tail = x✝.tail) ⋯
The canonical multiplicative morphism from FreeMagma α
to FreeSemigroup α
.
Instances For
The canonical additive morphism from FreeAddMagma α
to FreeAddSemigroup α
.
Instances For
Isomorphism between AddMagma.AssocQuotient (FreeAddMagma α)
and
FreeAddSemigroup α
.