Free constructions
Main definitions
free_magma α
: free magma (structure with binary operation without any axioms) over alphabetα
, defined inductively, with traversable instance and decidable equality.magma.free_semigroup α
: free semigroup over magmaα
.free_semigroup α
: free semigroup over alphabetα
, defined as a synonym forα × list α
(i.e. nonempty lists), with traversable instance and decidable equality.free_semigroup_free_magma α
: isomorphism betweenmagma.free_semigroup (free_magma α)
andfree_semigroup α
.
- of : Π (α : Type u), α → free_magma α
- mul : Π (α : Type u), free_magma α → free_magma α → free_magma α
Free magma over a given alphabet.
- of : Π (α : Type u), α → free_add_magma α
- add : Π (α : Type u), free_add_magma α → free_add_magma α → free_add_magma α
Free nonabelian additive magma over a given alphabet.
Equations
Equations
Recursor for free_magma
using x * y
instead of free_magma.mul x y
.
Recursor for free_add_magma
using x + y
instead of free_add_magma.add x y
.
Lifts a function α → β
to a magma homomorphism free_magma α → β
given a magma β
.
Equations
- free_magma.lift f (x * y) = free_magma.lift f x * free_magma.lift f y
- free_magma.lift f (free_magma.of x) = f x
Lifts a function α → β
to an additive magma homomorphism free_add_magma α → β
given
an additive magma β
.
Equations
- free_add_magma.lift f (x + y) = free_add_magma.lift f x + free_add_magma.lift f y
- free_add_magma.lift f (free_add_magma.of x) = f x
The unique magma homomorphism free_magma α → free_magma β
that sends
each of x
to of (f x)
.
Equations
- free_magma.map f (x * y) = free_magma.map f x * free_magma.map f y
- free_magma.map f (free_magma.of x) = free_magma.of (f x)
The unique additive magma homomorphism free_add_magma α → free_add_magma β
that sends
each of x
to of (f x)
.
Equations
- free_add_magma.map f (x + y) = free_add_magma.map f x + free_add_magma.map f y
- free_add_magma.map f (free_add_magma.of x) = free_add_magma.of (f x)
Recursor on free_magma
using pure
instead of of
.
Recursor on free_add_magma
using pure
instead of of
.
Equations
free_magma
is traversable.
Equations
- free_magma.traverse F (x * y) = has_mul.mul <$> free_magma.traverse F x <*> free_magma.traverse F y
- free_magma.traverse F (free_magma.of x) = free_magma.of <$> F x
free_add_magma
is traversable.
Equations
- free_add_magma.traverse F (x + y) = has_add.add <$> free_add_magma.traverse F x <*> free_add_magma.traverse F y
- free_add_magma.traverse F (free_add_magma.of x) = free_add_magma.of <$> F x
Equations
- free_magma.is_lawful_traversable = {to_is_lawful_functor := free_magma.is_lawful_traversable._proof_1, id_traverse := free_magma.is_lawful_traversable._proof_2, comp_traverse := free_magma.is_lawful_traversable._proof_3, traverse_eq_map_id := free_magma.is_lawful_traversable._proof_4, naturality := free_magma.is_lawful_traversable._proof_5}
Equations
- free_magma.has_repr = {repr := free_magma.repr _inst_1}
Length of an element of a free magma.
Length of an element of a free additive magma.
Free additive semigroup over an additive magma.
Free semigroup over a magma.
Equations
- magma.free_semigroup α = quot (magma.free_semigroup.r α)
Embedding from additive magma to its free additive semigroup.
Embedding from magma to its free semigroup.
Equations
- magma.free_semigroup.of = quot.mk (magma.free_semigroup.r α)
Equations
- magma.free_semigroup.semigroup = {mul := λ (x y : magma.free_semigroup α), quot.lift_on x (λ (p : α), quot.lift_on y (λ (q : α), quot.mk (magma.free_semigroup.r α) (p * q)) _) _, mul_assoc := _}
Lifts a magma homomorphism α → β
to a semigroup homomorphism magma.free_semigroup α → β
given a semigroup β
.
Equations
- magma.free_semigroup.lift f hf = quot.lift f _
Lifts an additive magma homomorphism α → β
to an additive semigroup homomorphism
add_magma.free_add_semigroup α → β
given an additive semigroup β
.
From a magma homomorphism α → β
to a semigroup homomorphism
magma.free_semigroup α → magma.free_semigroup β
.
Equations
From an additive magma homomorphism α → β
to an additive semigroup homomorphism
add_magma.free_add_semigroup α → add_magma.free_add_semigroup β
.
Free semigroup over a given alphabet. (Note: In this definition, the free semigroup does not contain the empty word.)
Equations
- free_semigroup α = (α × list α)
The embedding α → free_add_semigroup α
.
The embedding α → free_semigroup α
.
Equations
- free_semigroup.of x = (x, list.nil α)
Equations
Recursor for free additive semigroup using of
and +
.
Recursor for free semigroup using of
and *
.
Auxiliary function for free_semigroup.lift
.
Equations
- free_semigroup.lift' f x (hd :: tl) = f x * free_semigroup.lift' f hd tl
- free_semigroup.lift' f x list.nil = f x
Auxiliary function for free_semigroup.lift
.
Equations
- free_add_semigroup.lift' f x (hd :: tl) = f x + free_add_semigroup.lift' f hd tl
- free_add_semigroup.lift' f x list.nil = f x
Lifts a function α → β
to a semigroup homomorphism free_semigroup α → β
given
a semigroup β
.
Equations
- free_semigroup.lift f x = free_semigroup.lift' f x.fst x.snd
Lifts a function α → β
to an additive semigroup homomorphism
free_add_semigroup α → β
given an additive semigroup β
.
The unique additive semigroup homomorphism that sends of x
to of (f x)
.
Equations
Recursor that uses pure
instead of of
.
Recursor that uses pure
instead of of
.
Equations
free_add_semigroup
is traversable.
free_semigroup
is traversable.
Equations
- free_semigroup.traverse F x = x.rec_on' (λ (x : α), has_pure.pure <$> F x) (λ (x : α) (y : free_semigroup α) (ihx ihy : m (free_semigroup β)), has_mul.mul <$> ihx <*> ihy)
Equations
- free_semigroup.is_lawful_traversable = {to_is_lawful_functor := free_semigroup.is_lawful_traversable._proof_1, id_traverse := free_semigroup.is_lawful_traversable._proof_2, comp_traverse := free_semigroup.is_lawful_traversable._proof_3, traverse_eq_map_id := free_semigroup.is_lawful_traversable._proof_4, naturality := free_semigroup.is_lawful_traversable._proof_5}
Equations
Isomorphism between magma.free_semigroup (free_magma α)
and free_semigroup α
.
Equations
Isomorphism between
add_magma.free_add_semigroup (free_add_magma α)
and free_add_semigroup α
.