Free monoid over a given alphabet #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
Main definitions #
free_monoid α
: free monoid over alphabetα
; defined as a synonym forlist α
with multiplication given by(++)
.free_monoid.of
: embeddingα → free_monoid α
sending each elementx
to[x]
;free_monoid.lift
: natural equivalence betweenα → M
andfree_monoid α →* M
free_monoid.map
: embedding ofα → β
intofree_monoid α →* free_monoid β
given bylist.map
.
Free nonabelian additive monoid over a given alphabet
Equations
- free_add_monoid α = list α
Instances for free_add_monoid
Equations
Equations
The identity equivalence between free_monoid α
and list α
.
Equations
The identity equivalence between free_add_monoid α
and list α
.
Equations
The identity equivalence between list α
and free_monoid α
.
Equations
The identity equivalence between list α
and free_add_monoid α
.
Equations
Equations
- free_add_monoid.cancel_add_monoid = {add := λ (x y : free_add_monoid α), ⇑free_add_monoid.of_list (⇑free_add_monoid.to_list x ++ ⇑free_add_monoid.to_list y), add_assoc := _, add_left_cancel := _, zero := ⇑free_add_monoid.of_list list.nil, zero_add := _, add_zero := _, nsmul := add_left_cancel_monoid.nsmul._default (⇑free_add_monoid.of_list list.nil) (λ (x y : free_add_monoid α), ⇑free_add_monoid.of_list (⇑free_add_monoid.to_list x ++ ⇑free_add_monoid.to_list y)) list.nil_append list.append_nil, nsmul_zero' := _, nsmul_succ' := _, add_right_cancel := _}
Equations
- free_monoid.cancel_monoid = {mul := λ (x y : free_monoid α), ⇑free_monoid.of_list (⇑free_monoid.to_list x ++ ⇑free_monoid.to_list y), mul_assoc := _, mul_left_cancel := _, one := ⇑free_monoid.of_list list.nil, one_mul := _, mul_one := _, npow := left_cancel_monoid.npow._default (⇑free_monoid.of_list list.nil) (λ (x y : free_monoid α), ⇑free_monoid.of_list (⇑free_monoid.to_list x ++ ⇑free_monoid.to_list y)) list.nil_append list.append_nil, npow_zero' := _, npow_succ' := _, mul_right_cancel := _}
Equations
Equations
- free_monoid.inhabited = {default := 1}
Embeds an element of α
into free_monoid α
as a singleton list.
Equations
Embeds an element of α
into free_add_monoid α
as a singleton list.
Equations
Recursor for free_monoid
using 1
and free_monoid.of x * xs
instead of []
and
x :: xs
.
Recursor for free_add_monoid
using 0
and free_add_monoid.of x + xs
instead of []
and
x :: xs
.
A version of list.cases_on
for free_add_monoid
using 0
and free_add_monoid.of x + xs
instead of []
and x :: xs
.
A version of list.cases_on
for free_monoid
using 1
and free_monoid.of x * xs
instead of
[]
and x :: xs
.
A variant of list.sum
that has [x].sum = x
true definitionally.
The purpose is to make free_add_monoid.lift_eval_of
true by rfl
.
Equations
- free_add_monoid.sum_aux l = l.rec_on 0 (λ (x : M) (xs : list M) (_x : M), list.foldl has_add.add x xs)
A variant of list.prod
that has [x].prod = x
true definitionally.
The purpose is to make free_monoid.lift_eval_of
true by rfl
.
Equations
- free_monoid.prod_aux l = l.rec_on 1 (λ (x : M) (xs : list M) (_x : M), list.foldl has_mul.mul x xs)
Equivalence between maps α → A
and additive monoid homomorphisms
free_add_monoid α →+ A
.
Equations
- free_add_monoid.lift = {to_fun := λ (f : α → M), {to_fun := λ (l : free_add_monoid α), free_add_monoid.sum_aux (list.map f (⇑free_add_monoid.to_list l)), map_zero' := _, map_add' := _}, inv_fun := λ (f : free_add_monoid α →+ M) (x : α), ⇑f (free_add_monoid.of x), left_inv := _, right_inv := _}
Equivalence between maps α → M
and monoid homomorphisms free_monoid α →* M
.
Equations
- free_monoid.lift = {to_fun := λ (f : α → M), {to_fun := λ (l : free_monoid α), free_monoid.prod_aux (list.map f (⇑free_monoid.to_list l)), map_one' := _, map_mul' := _}, inv_fun := λ (f : free_monoid α →* M) (x : α), ⇑f (free_monoid.of x), left_inv := _, right_inv := _}
Define a multiplicative action of free_monoid α
on β
.
Equations
- free_monoid.mk_mul_action f = {to_has_smul := {smul := λ (l : free_monoid α) (b : β), list.foldr f b (⇑free_monoid.to_list l)}, one_smul := _, mul_smul := _}
Define an additive action of free_add_monoid α
on β
.
Equations
- free_add_monoid.mk_add_action f = {to_has_vadd := {vadd := λ (l : free_add_monoid α) (b : β), list.foldr f b (⇑free_add_monoid.to_list l)}, zero_vadd := _, add_vadd := _}
The unique additive monoid homomorphism free_add_monoid α →+ free_add_monoid β
that sends each of x
to of (f x)
.
Equations
- free_add_monoid.map f = {to_fun := λ (l : free_add_monoid α), ⇑free_add_monoid.of_list (list.map f (⇑free_add_monoid.to_list l)), map_zero' := _, map_add' := _}
The unique monoid homomorphism free_monoid α →* free_monoid β
that sends
each of x
to of (f x)
.
Equations
- free_monoid.map f = {to_fun := λ (l : free_monoid α), ⇑free_monoid.of_list (list.map f (⇑free_monoid.to_list l)), map_one' := _, map_mul' := _}