Free constructions #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
Main definitions #
free_magma α
: free magma (structure with binary operation without any axioms) over alphabetα
, defined inductively, with traversable instance and decidable equality.magma.assoc_quotient α
: quotient of a magmaα
by the associativity equivalence relation.free_semigroup α
: free semigroup over alphabetα
, defined as a structure with two fieldshead : α
andtail : list α
(i.e. nonempty lists), with traversable instance and decidable equality.free_magma_assoc_quotient_equiv α
: isomorphism betweenmagma.assoc_quotient (free_magma α)
andfree_semigroup α
.free_magma.lift
: the universal property of the free magma, expressing its adjointness.
- of : Π {α : Type u}, α → free_magma α
- mul : Π {α : Type u}, free_magma α → free_magma α → free_magma α
Free magma over a given alphabet.
Instances for free_magma
- 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.
Instances for free_add_magma
Equations
Equations
Equations
Equations
Recursor for free_add_magma
using x + y
instead of free_add_magma.add x y
.
Equations
- x.rec_on_add ih1 ih2 = x.rec_on ih1 ih2
Recursor for free_magma
using x * y
instead of free_magma.mul x y
.
Equations
- x.rec_on_mul ih1 ih2 = x.rec_on ih1 ih2
Lifts a function α → β
to a magma homomorphism free_magma α → β
given a magma β
.
Equations
- free_magma.lift_aux f (x * y) = free_magma.lift_aux f x * free_magma.lift_aux f y
- free_magma.lift_aux 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_aux f (x + y) = free_add_magma.lift_aux f x + free_add_magma.lift_aux f y
- free_add_magma.lift_aux f (free_add_magma.of x) = f x
The universal property of the free additive magma expressing its adjointness.
Equations
- free_add_magma.lift = {to_fun := λ (f : α → β), {to_fun := free_add_magma.lift_aux f, map_add' := _}, inv_fun := λ (F : add_hom (free_add_magma α) β), ⇑F ∘ free_add_magma.of, left_inv := _, right_inv := _}
The universal property of the free magma expressing its adjointness.
Equations
- free_magma.lift = {to_fun := λ (f : α → β), {to_fun := free_magma.lift_aux f, map_mul' := _}, inv_fun := λ (F : free_magma α →ₙ* β), ⇑F ∘ free_magma.of, left_inv := _, right_inv := _}
The unique additive magma homomorphism free_add_magma α → free_add_magma β
that
sends each of x
to of (f x)
.
Equations
The unique magma homomorphism free_magma α →ₙ* free_magma β
that sends
each of x
to of (f x)
.
Equations
Equations
Equations
Recursor on free_add_magma
using pure
instead of of
.
Equations
- x.rec_on_pure ih1 ih2 = x.rec_on_add ih1 ih2
Recursor on free_magma
using pure
instead of of
.
Equations
- x.rec_on_pure ih1 ih2 = x.rec_on_mul ih1 ih2
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_add_magma.is_lawful_traversable = {to_is_lawful_functor := free_add_magma.is_lawful_traversable._proof_1, id_traverse := free_add_magma.is_lawful_traversable._proof_2, comp_traverse := free_add_magma.is_lawful_traversable._proof_3, traverse_eq_map_id := free_add_magma.is_lawful_traversable._proof_4, naturality := free_add_magma.is_lawful_traversable._proof_5}
Equations
- free_magma.has_repr = {repr := free_magma.repr _inst_1}
Equations
- free_add_magma.has_repr = {repr := free_add_magma.repr _inst_1}
Length of an element of a free magma.
Length of an element of a free additive magma.
Semigroup quotient of a magma.
Equations
- magma.assoc_quotient α = quot (magma.assoc_rel α)
Instances for magma.assoc_quotient
Additive semigroup quotient of an additive magma.
Equations
- add_magma.free_add_semigroup α = quot (add_magma.assoc_rel α)
Instances for add_magma.free_add_semigroup
Equations
- add_magma.free_add_semigroup.add_semigroup = {add := λ (x y : add_magma.free_add_semigroup α), quot.lift_on₂ x y (λ (x y : α), quot.mk (add_magma.assoc_rel α) (x + y)) add_magma.free_add_semigroup.add_semigroup._proof_1 add_magma.free_add_semigroup.add_semigroup._proof_2, add_assoc := _}
Equations
- magma.assoc_quotient.semigroup = {mul := λ (x y : magma.assoc_quotient α), quot.lift_on₂ x y (λ (x y : α), quot.mk (magma.assoc_rel α) (x * y)) magma.assoc_quotient.semigroup._proof_1 magma.assoc_quotient.semigroup._proof_2, mul_assoc := _}
Embedding from magma to its free semigroup.
Equations
- magma.assoc_quotient.of = {to_fun := quot.mk (magma.assoc_rel α), map_mul' := _}
Embedding from additive magma to its free additive semigroup.
Equations
- add_magma.free_add_semigroup.of = {to_fun := quot.mk (add_magma.assoc_rel α), map_add' := _}
Lifts an additive magma homomorphism α → β
to an additive semigroup homomorphism
add_magma.assoc_quotient α → β
given an additive semigroup β
.
Equations
- add_magma.free_add_semigroup.lift = {to_fun := λ (f : add_hom α β), {to_fun := λ (x : add_magma.free_add_semigroup α), quot.lift_on x ⇑f _, map_add' := _}, inv_fun := λ (f : add_hom (add_magma.free_add_semigroup α) β), f.comp add_magma.free_add_semigroup.of, left_inv := _, right_inv := _}
Lifts a magma homomorphism α → β
to a semigroup homomorphism magma.assoc_quotient α → β
given a semigroup β
.
Equations
- magma.assoc_quotient.lift = {to_fun := λ (f : α →ₙ* β), {to_fun := λ (x : magma.assoc_quotient α), quot.lift_on x ⇑f _, map_mul' := _}, inv_fun := λ (f : magma.assoc_quotient α →ₙ* β), f.comp magma.assoc_quotient.of, left_inv := _, right_inv := _}
From a magma homomorphism α →ₙ* β
to a semigroup homomorphism
magma.assoc_quotient α →ₙ* magma.assoc_quotient β
.
Equations
- head : α
- tail : list α
Free additive semigroup over a given alphabet.
Instances for free_add_semigroup
The embedding α → free_semigroup α
.
The embedding α → free_add_semigroup α
.
Length of an element of free semigroup.
Length of an element of free additive semigroup
Equations
Recursor for free additive semigroup using of
and +
.
Recursor for free semigroup using of
and *
.
Lifts a function α → β
to a semigroup homomorphism free_semigroup α → β
given
a semigroup β
.
Equations
- free_semigroup.lift = {to_fun := λ (f : α → β), {to_fun := λ (x : free_semigroup α), list.foldl (λ (a : β) (b : α), a * f b) (f x.head) x.tail, map_mul' := _}, inv_fun := λ (f : free_semigroup α →ₙ* β), ⇑f ∘ free_semigroup.of, left_inv := _, right_inv := _}
Lifts a function α → β
to an additive semigroup homomorphism
free_add_semigroup α → β
given an additive semigroup β
.
Equations
- free_add_semigroup.lift = {to_fun := λ (f : α → β), {to_fun := λ (x : free_add_semigroup α), list.foldl (λ (a : β) (b : α), a + f b) (f x.head) x.tail, map_add' := _}, inv_fun := λ (f : add_hom (free_add_semigroup α) β), ⇑f ∘ free_add_semigroup.of, left_inv := _, right_inv := _}
The unique semigroup homomorphism that sends of x
to of (f x)
.
Equations
The unique additive semigroup homomorphism that sends of x
to of (f x)
.
Equations
Equations
Equations
Recursor that uses pure
instead of of
.
Equations
- x.rec_on_pure ih1 ih2 = x.rec_on_mul ih1 ih2
Recursor that uses pure
instead of of
.
Equations
- x.rec_on_pure ih1 ih2 = x.rec_on_add ih1 ih2
free_add_semigroup
is traversable.
Equations
- free_add_semigroup.traverse F x = x.rec_on_pure (λ (x : α), has_pure.pure <$> F x) (λ (x : α) (y : free_add_semigroup α) (ihx ihy : m (free_add_semigroup β)), has_add.add <$> ihx <*> ihy)
free_semigroup
is traversable.
Equations
- free_semigroup.traverse F x = x.rec_on_pure (λ (x : α), has_pure.pure <$> F x) (λ (x : α) (y : free_semigroup α) (ihx ihy : m (free_semigroup β)), has_mul.mul <$> ihx <*> ihy)
Equations
- free_add_semigroup.is_lawful_traversable = {to_is_lawful_functor := free_add_semigroup.is_lawful_traversable._proof_1, id_traverse := free_add_semigroup.is_lawful_traversable._proof_2, comp_traverse := free_add_semigroup.is_lawful_traversable._proof_3, traverse_eq_map_id := free_add_semigroup.is_lawful_traversable._proof_4, naturality := free_add_semigroup.is_lawful_traversable._proof_5}
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
- free_add_semigroup.decidable_eq = λ (x y : free_add_semigroup α), decidable_of_iff' (x.head = y.head ∧ x.tail = y.tail) _
Equations
- free_semigroup.decidable_eq = λ (x y : free_semigroup α), decidable_of_iff' (x.head = y.head ∧ x.tail = y.tail) _
The canonical additive morphism from free_add_magma α
to free_add_semigroup α
.
The canonical multiplicative morphism from free_magma α
to free_semigroup α
.
Isomorphism between
add_magma.assoc_quotient (free_add_magma α)
and free_add_semigroup α
.
Isomorphism between magma.assoc_quotient (free_magma α)
and free_semigroup α
.