Free monoid over a given alphabet #
Main definitions #
FreeMonoid α: free monoid over alphabetα; defined as a one-field structure aroundList αwith multiplication given by(++).FreeMonoid.of: embeddingα → FreeMonoid αsending each elementxto[x];FreeMonoid.lift: natural equivalence betweenα → MandFreeMonoid α →* MFreeMonoid.map: embedding ofα → βintoFreeMonoid α →* FreeMonoid βgiven byList.map.
If α is a type, then FreeMonoid α is the free monoid generated by α.
This is a monoid equipped with a function FreeMonoid.of : α → FreeMonoid α which has
the following universal property: if M is any monoid, and f : α → M is any function,
then this function is the composite of FreeMonoid.of and a unique monoid homomorphism
FreeMonoid.lift f : FreeMonoid α →* M.
A typical element of FreeMonoid α is a 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 FreeMonoid α. In particular if α is empty
then FreeMonoid α is isomorphic to the trivial monoid, and if α has one term
then FreeMonoid α is isomorphic to Multiplicative ℕ.
If α has two or more terms then FreeMonoid α is not commutative.
One can think of FreeMonoid α as the type of lists of α, with multiplication
given by concatenation.
- ofList :: (
- toList : List α
The underlying list
- )
Instances For
If α is a type, then FreeAddMonoid α is the free additive monoid generated by α.
This is a monoid equipped with a function FreeAddMonoid.of : α → FreeAddMonoid α which has
the following universal property: if M is any monoid, and f : α → M is any function,
then this function is the composite of FreeAddMonoid.of and a unique monoid homomorphism
FreeAddMonoid.lift f : FreeAddMonoid α →+ M.
A typical element of FreeAddMonoid α is a 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 FreeAddMonoid α. In particular if α is empty
then FreeAddMonoid α is isomorphic to the trivial monoid, and if α has one term
then FreeAddMonoid α is isomorphic to ℕ.
If α has two or more terms then FreeAddMonoid α is not commutative.
One can think of FreeAddMonoid α as the type of lists of α, with addition
given by concatenation.
- ofList :: (
- toList : List α
The underlying list
- )
Instances For
Alias of FreeMonoid.ofList_toList.
Alias of FreeAddMonoid.ofList_toList.
Alias of FreeMonoid.toList_ofList.
Alias of FreeAddMonoid.toList_ofList.
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.
Equations
- FreeMonoid.instInhabited = { default := 1 }
Equations
- FreeAddMonoid.instInhabited = { default := 0 }
Equations
- FreeMonoid.instUniqueOfIsEmpty = { toInhabited := FreeMonoid.instInhabited, uniq := ⋯ }
Equations
- FreeAddMonoid.instUniqueOfIsEmpty = { toInhabited := FreeAddMonoid.instInhabited, uniq := ⋯ }
Embeds an element of α into FreeMonoid α as a singleton list.
Instances For
Embeds an element of α into FreeAddMonoid α as a singleton list.
Instances For
The natural equivalence between FreeMonoid α and List α.
Equations
- FreeMonoid.toListEquiv = { toFun := FreeMonoid.toList, invFun := FreeMonoid.ofList, left_inv := ⋯, right_inv := ⋯ }
Instances For
The natural equivalence between FreeAddMonoid α and List α.
Equations
- FreeAddMonoid.toListEquiv = { toFun := FreeAddMonoid.toList, invFun := FreeAddMonoid.ofList, left_inv := ⋯, right_inv := ⋯ }
Instances For
Length #
The length of a free monoid element: 1.length = 0 and (a * b).length = a.length + b.length
Instances For
The length of a free additive monoid element: 0.length = 0 and (a + b).length = a.length + b.length
Instances For
Membership in a free monoid element
Instances For
Membership in a free additive monoid element
Instances For
Equations
- FreeMonoid.instMembership = { mem := fun (a : FreeMonoid α) (m : α) => m ∈ a.toList }
Equations
- FreeAddMonoid.instMembership = { mem := fun (a : FreeAddMonoid α) (m : α) => m ∈ a.toList }
Recursor for FreeMonoid using 1 and FreeMonoid.of x * xs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Recursor for FreeAddMonoid using 0 and FreeAddMonoid.of x + xs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Alias of FreeMonoid.mulRecOn_one.
Alias of FreeAddMonoid.addRecOn_zero.
Alias of FreeMonoid.mulRecOn_of_mul.
Alias of FreeAddMonoid.addRecOn_of_add.
Induction #
An induction principle on free monoids, with cases for 1, FreeMonoid.of and *.
An induction principle on
free additive monoids, with cases for 0, FreeAddMonoid.of and +.
An induction principle for free monoids which mirrors induction on lists, with cases analogous to the empty list and cons.
An induction principle for free additive monoids which mirrors induction on lists, with cases analogous to the empty list and cons.
A version of List.casesOn for FreeMonoid using 1 and FreeMonoid.of x * xs instead of
[] and x :: xs.
Equations
- FreeMonoid.mulCasesOn xs one of_mul = FreeMonoid.mulRecOn xs one fun (x : α) (xs : FreeMonoid α) (x_1 : motive xs) => of_mul x xs
Instances For
A version of List.casesOn for FreeAddMonoid using 0 and FreeAddMonoid.of x + xs
instead of [] and x :: xs.
Equations
- FreeAddMonoid.addCasesOn xs one of_mul = FreeAddMonoid.addRecOn xs one fun (x : α) (xs : FreeAddMonoid α) (x_1 : motive xs) => of_mul x xs
Instances For
Alias of FreeMonoid.mulCasesOn_one.
Alias of FreeAddMonoid.addCasesOn_zero.
Alias of FreeMonoid.mulCasesOn_of_mul.
Alias of FreeAddMonoid.addCasesOn_of_add.
A variant of List.prod that has [x].prod = x true definitionally.
The purpose is to make FreeMonoid.lift_eval_of true by rfl.
Equations
- FreeMonoid.prodAux [] = 1
- FreeMonoid.prodAux (x_1 :: xs) = List.foldl (fun (x1 x2 : M) => x1 * x2) x_1 xs
Instances For
A variant of List.sum that has [x].sum = x true definitionally.
The purpose is to make FreeAddMonoid.lift_eval_of true by rfl.
Equations
- FreeAddMonoid.sumAux [] = 0
- FreeAddMonoid.sumAux (x_1 :: xs) = List.foldl (fun (x1 x2 : M) => x1 + x2) x_1 xs
Instances For
Equivalence between maps α → M and monoid homomorphisms FreeMonoid α →* M.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equivalence between maps α → A and additive monoid homomorphisms
FreeAddMonoid α →+ A.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Define a multiplicative action of FreeMonoid α on β.
Equations
- FreeMonoid.mkMulAction f = { smul := fun (l : FreeMonoid α) (b : β) => List.foldr f b l.toList, mul_smul := ⋯, one_smul := ⋯ }
Instances For
Define an additive action of FreeAddMonoid α on β.
Equations
- FreeAddMonoid.mkAddAction f = { vadd := fun (l : FreeAddMonoid α) (b : β) => List.foldr f b l.toList, add_vadd := ⋯, zero_vadd := ⋯ }
Instances For
map #
The unique monoid homomorphism FreeMonoid α →* FreeMonoid β that sends
each of x to of (f x).
Equations
- FreeMonoid.map f = { toFun := fun (l : FreeMonoid α) => { toList := List.map f l.toList }, map_one' := ⋯, map_mul' := ⋯ }
Instances For
The unique additive monoid homomorphism FreeAddMonoid α →+ FreeAddMonoid β
that sends each of x to of (f x).
Equations
- FreeAddMonoid.map f = { toFun := fun (l : FreeAddMonoid α) => { toList := List.map f l.toList }, map_zero' := ⋯, map_add' := ⋯ }
Instances For
The only invertible element of the free monoid is 1; this instance enables units_eq_one.
Equations
- FreeMonoid.instUniqueUnits = { toInhabited := Units.instInhabited, uniq := ⋯ }
Equations
- FreeAddMonoid.instUniqueAddUnits = { toInhabited := AddUnits.instInhabited, uniq := ⋯ }
reverse #
Reverse the symbols in a FreeMonoid α.
Instances For
Reverses the symbols in a FreeAddMonoid α.
Instances For
Free monoids over isomorphic types are isomorphic.
Equations
- FreeMonoid.freeMonoidCongr e = { toFun := ⇑(FreeMonoid.map ⇑e), invFun := ⇑(FreeMonoid.map ⇑e.symm), left_inv := ⋯, right_inv := ⋯, map_mul' := ⋯ }
Instances For
Free additive monoids over isomorphic types are isomorphic.
Equations
- FreeAddMonoid.freeAddMonoidCongr e = { toFun := ⇑(FreeAddMonoid.map ⇑e), invFun := ⇑(FreeAddMonoid.map ⇑e.symm), left_inv := ⋯, right_inv := ⋯, map_add' := ⋯ }