mathlib documentation

algebra.free

Free constructions #

Main definitions #

inductive free_magma (α : Type u) :
Type u

Free magma over a given alphabet.

Instances for free_magma
@[protected, instance]
def free_magma.decidable_eq (α : Type u) [a : decidable_eq α] :
@[protected, instance]
inductive free_add_magma (α : Type u) :
Type u

Free nonabelian additive magma over a given alphabet.

Instances for free_add_magma
@[protected, instance]
def free_magma.inhabited {α : Type u} [inhabited α] :
Equations
@[protected, instance]
def free_add_magma.has_add {α : Type u} :
Equations
@[protected, instance]
def free_magma.has_mul {α : Type u} :
Equations
@[simp]
theorem free_magma.mul_eq {α : Type u} (x y : free_magma α) :
x.mul y = x * y
@[simp]
theorem free_add_magma.add_eq {α : Type u} (x y : free_add_magma α) :
x.add y = x + y
def free_add_magma.rec_on_add {α : Type u} {C : free_add_magma αSort l} (x : free_add_magma α) (ih1 : Π (x : α), C (free_add_magma.of x)) (ih2 : Π (x y : free_add_magma α), C xC yC (x + y)) :
C x

Recursor for free_add_magma using x + y instead of free_add_magma.add x y.

Equations
def free_magma.rec_on_mul {α : Type u} {C : free_magma αSort l} (x : free_magma α) (ih1 : Π (x : α), C (free_magma.of x)) (ih2 : Π (x y : free_magma α), C xC yC (x * y)) :
C x

Recursor for free_magma using x * y instead of free_magma.mul x y.

Equations
def free_magma.lift_aux {α : Type u} {β : Type v} [has_mul β] (f : α → β) :
free_magma α → β

Lifts a function α → β to a magma homomorphism free_magma α → β given a magma β.

Equations
def free_add_magma.lift_aux {α : Type u} {β : Type v} [has_add β] (f : α → β) :
free_add_magma α → β

Lifts a function α → β to an additive magma homomorphism free_add_magma α → β given an additive magma β.

Equations
theorem free_magma.lift_aux_unique {α : Type u} {β : Type v} [has_mul β] (F : free_magma α →ₙ* β) :
def free_add_magma.lift {α : Type u} {β : Type v} [has_add β] :
(α → β) add_hom (free_add_magma α) β

The universal property of the free additive magma expressing its adjointness.

Equations
def free_magma.lift {α : Type u} {β : Type v} [has_mul β] :
(α → β) (free_magma α →ₙ* β)

The universal property of the free magma expressing its adjointness.

Equations
@[simp]
theorem free_add_magma.lift_of {α : Type u} {β : Type v} [has_add β] (f : α → β) (x : α) :
@[simp]
theorem free_magma.lift_of {α : Type u} {β : Type v} [has_mul β] (f : α → β) (x : α) :
def free_magma.map {α : Type u} {β : Type v} (f : α → β) :

The unique magma homomorphism free_magma α → free_magma β that sends each of x to of (f x).

Equations
def free_add_magma.map {α : Type u} {β : Type v} (f : α → β) :

The unique additive magma homomorphism free_add_magma α → free_add_magma β that sends each of x to of (f x).

Equations
@[simp]
theorem free_add_magma.map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :
@[simp]
theorem free_magma.map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :
@[simp]
theorem free_add_magma.map_add {α : Type u} {β : Type v} (f : α → β) (x y : free_add_magma α) :
@[simp]
theorem free_magma.map_mul {α : Type u} {β : Type v} (f : α → β) (x y : free_magma α) :
@[protected, instance]
Equations
@[protected]
def free_add_magma.rec_on_pure {α : Type u} {C : free_add_magma αSort l} (x : free_add_magma α) (ih1 : Π (x : α), C (has_pure.pure x)) (ih2 : Π (x y : free_add_magma α), C xC yC (x + y)) :
C x

Recursor on free_add_magma using pure instead of of.

Equations
@[protected]
def free_magma.rec_on_pure {α : Type u} {C : free_magma αSort l} (x : free_magma α) (ih1 : Π (x : α), C (has_pure.pure x)) (ih2 : Π (x y : free_magma α), C xC yC (x * y)) :
C x

Recursor on free_magma using pure instead of of.

Equations
@[simp]
theorem free_magma.map_pure {α β : Type u} (f : α → β) (x : α) :
@[simp]
theorem free_add_magma.map_pure {α β : Type u} (f : α → β) (x : α) :
@[simp]
theorem free_magma.map_mul' {α β : Type u} (f : α → β) (x y : free_magma α) :
f <$> (x * y) = f <$> x * f <$> y
@[simp]
theorem free_add_magma.map_add' {α β : Type u} (f : α → β) (x y : free_add_magma α) :
f <$> (x + y) = f <$> x + f <$> y
@[simp]
theorem free_add_magma.pure_bind {α β : Type u} (f : α → free_add_magma β) (x : α) :
@[simp]
theorem free_magma.pure_bind {α β : Type u} (f : α → free_magma β) (x : α) :
@[simp]
theorem free_add_magma.add_bind {α β : Type u} (f : α → free_add_magma β) (x y : free_add_magma α) :
x + y >>= f = (x >>= f) + (y >>= f)
@[simp]
theorem free_magma.mul_bind {α β : Type u} (f : α → free_magma β) (x y : free_magma α) :
x * y >>= f = (x >>= f) * (y >>= f)
@[simp]
theorem free_add_magma.pure_seq {α β : Type u} {f : α → β} {x : free_add_magma α} :
@[simp]
theorem free_magma.pure_seq {α β : Type u} {f : α → β} {x : free_magma α} :
@[simp]
theorem free_add_magma.add_seq {α β : Type u} {f g : free_add_magma (α → β)} {x : free_add_magma α} :
f + g <*> x = (f <*> x) + (g <*> x)
@[simp]
theorem free_magma.mul_seq {α β : Type u} {f g : free_magma (α → β)} {x : free_magma α} :
f * g <*> x = (f <*> x) * (g <*> x)
@[protected]
def free_magma.traverse {m : Type uType u} [applicative m] {α β : Type u} (F : α → m β) :
free_magma αm (free_magma β)

free_magma is traversable.

Equations
@[protected]
def free_add_magma.traverse {m : Type uType u} [applicative m] {α β : Type u} (F : α → m β) :

free_add_magma is traversable.

Equations
@[simp]
theorem free_magma.traverse_pure {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : α) :
@[simp]
theorem free_add_magma.traverse_pure {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : α) :
@[simp]
theorem free_add_magma.traverse_pure' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :
@[simp]
theorem free_magma.traverse_pure' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :
@[simp]
theorem free_add_magma.traverse_add {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x y : free_add_magma α) :
@[simp]
theorem free_magma.traverse_mul {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x y : free_magma α) :
@[simp]
theorem free_magma.traverse_mul' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :
@[simp]
theorem free_add_magma.traverse_add' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :
@[simp]
theorem free_magma.traverse_eq {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : free_magma α) :
@[simp]
theorem free_add_magma.traverse_eq {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : free_add_magma α) :
@[simp]
theorem free_add_magma.add_map_seq {α : Type u} (x y : free_add_magma α) :
@[simp]
theorem free_magma.mul_map_seq {α : Type u} (x y : free_magma α) :
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected]
def free_magma.repr {α : Type u} [has_repr α] :

Representation of an element of a free magma.

Equations
@[protected]
def free_add_magma.repr {α : Type u} [has_repr α] :

Representation of an element of a free additive magma.

Equations
@[protected, instance]
def free_magma.has_repr {α : Type u} [has_repr α] :
Equations
@[protected, instance]
def free_add_magma.has_repr {α : Type u} [has_repr α] :
Equations
def free_magma.length {α : Type u} :

Length of an element of a free magma.

Equations
def free_add_magma.length {α : Type u} :

Length of an element of a free additive magma.

Equations
inductive magma.free_semigroup.r (α : Type u) [has_mul α] :
α → α → Prop

Associativity relations for a magma.

inductive add_magma.free_add_semigroup.r (α : Type u) [has_add α] :
α → α → Prop

Associativity relations for an additive magma.

def magma.free_semigroup (α : Type u) [has_mul α] :
Type u

Free semigroup over a magma.

Equations
Instances for magma.free_semigroup
def add_magma.free_add_semigroup (α : Type u) [has_add α] :
Type u

Free additive semigroup over an additive magma.

Equations
Instances for add_magma.free_add_semigroup
def magma.free_semigroup.of {α : Type u} [has_mul α] :

Embedding from magma to its free semigroup.

Equations

Embedding from additive magma to its free additive semigroup.

Equations
@[protected]
theorem add_magma.free_add_semigroup.induction_on {α : Type u} [has_add α] {C : add_magma.free_add_semigroup α → Prop} (x : add_magma.free_add_semigroup α) (ih : ∀ (x : α), C (add_magma.free_add_semigroup.of x)) :
C x
@[protected]
theorem magma.free_semigroup.induction_on {α : Type u} [has_mul α] {C : magma.free_semigroup α → Prop} (x : magma.free_semigroup α) (ih : ∀ (x : α), C (magma.free_semigroup.of x)) :
C x
theorem magma.free_semigroup.of_mul_assoc {α : Type u} [has_mul α] (x y z : α) :
theorem magma.free_semigroup.of_mul_assoc_left {α : Type u} [has_mul α] (w x y z : α) :
theorem magma.free_semigroup.of_mul_assoc_right {α : Type u} [has_mul α] (w x y z : α) :
@[protected, instance]
Equations
@[protected, instance]
Equations
def magma.free_semigroup.lift {α : Type u} [has_mul α] {β : Type v} [semigroup β] (f : α → β) (hf : ∀ (x y : α), f (x * y) = f x * f y) :

Lifts a magma homomorphism α → β to a semigroup homomorphism magma.free_semigroup α → β given a semigroup β.

Equations
def add_magma.free_add_semigroup.lift {α : Type u} [has_add α] {β : Type v} [add_semigroup β] (f : α → β) (hf : ∀ (x y : α), f (x + y) = f x + f y) :

Lifts an additive magma homomorphism α → β to an additive semigroup homomorphism add_magma.free_add_semigroup α → β given an additive semigroup β.

Equations
@[simp]
theorem magma.free_semigroup.lift_of {α : Type u} [has_mul α] {β : Type v} [semigroup β] (f : α → β) {hf : ∀ (x y : α), f (x * y) = f x * f y} (x : α) :
@[simp]
theorem add_magma.free_add_semigroup.lift_of {α : Type u} [has_add α] {β : Type v} [add_semigroup β] (f : α → β) {hf : ∀ (x y : α), f (x + y) = f x + f y} (x : α) :
@[simp]
theorem add_magma.free_add_semigroup.lift_add {α : Type u} [has_add α] {β : Type v} [add_semigroup β] (f : α → β) {hf : ∀ (x y : α), f (x + y) = f x + f y} (x y : add_magma.free_add_semigroup α) :
@[simp]
theorem magma.free_semigroup.lift_mul {α : Type u} [has_mul α] {β : Type v} [semigroup β] (f : α → β) {hf : ∀ (x y : α), f (x * y) = f x * f y} (x y : magma.free_semigroup α) :
theorem magma.free_semigroup.lift_unique {α : Type u} [has_mul α] {β : Type v} [semigroup β] (f : magma.free_semigroup α → β) (hf : ∀ (x y : magma.free_semigroup α), f (x * y) = f x * f y) :
def add_magma.free_add_semigroup.map {α : Type u} [has_add α] {β : Type v} [has_add β] (f : α → β) (hf : ∀ (x y : α), f (x + y) = f x + f y) :

From an additive magma homomorphism α → β to an additive semigroup homomorphism add_magma.free_add_semigroup α → add_magma.free_add_semigroup β.

Equations
def magma.free_semigroup.map {α : Type u} [has_mul α] {β : Type v} [has_mul β] (f : α → β) (hf : ∀ (x y : α), f (x * y) = f x * f y) :

From a magma homomorphism α → β to a semigroup homomorphism magma.free_semigroup α → magma.free_semigroup β.

Equations
@[simp]
theorem add_magma.free_add_semigroup.map_of {α : Type u} [has_add α] {β : Type v} [has_add β] (f : α → β) {hf : ∀ (x y : α), f (x + y) = f x + f y} (x : α) :
@[simp]
theorem magma.free_semigroup.map_of {α : Type u} [has_mul α] {β : Type v} [has_mul β] (f : α → β) {hf : ∀ (x y : α), f (x * y) = f x * f y} (x : α) :
@[simp]
theorem add_magma.free_add_semigroup.map_add {α : Type u} [has_add α] {β : Type v} [has_add β] (f : α → β) {hf : ∀ (x y : α), f (x + y) = f x + f y} (x y : add_magma.free_add_semigroup α) :
@[simp]
theorem magma.free_semigroup.map_mul {α : Type u} [has_mul α] {β : Type v} [has_mul β] (f : α → β) {hf : ∀ (x y : α), f (x * y) = f x * f y} (x y : magma.free_semigroup α) :
def free_semigroup (α : Type u) :
Type u

Free semigroup over a given alphabet. (Note: In this definition, the free semigroup does not contain the empty word.)

Equations
Instances for free_semigroup
@[protected, instance]
Equations
@[protected, instance]
Equations
def free_semigroup.of {α : Type u} (x : α) :

The embedding α → free_semigroup α.

Equations
def free_add_semigroup.of {α : Type u} (x : α) :

The embedding α → free_add_semigroup α.

Equations
@[protected]
def free_add_semigroup.rec_on {α : Type u} {C : free_add_semigroup αSort l} (x : free_add_semigroup α) (ih1 : Π (x : α), C (free_add_semigroup.of x)) (ih2 : Π (x : α) (y : free_add_semigroup α), C (free_add_semigroup.of x)C yC (free_add_semigroup.of x + y)) :
C x

Recursor for free additive semigroup using of and +.

Equations
  • x.rec_on ih1 ih2 = prod.rec_on x (λ (f : α) (s : list α), s.rec_on ih1 (λ (hd : α) (tl : list α) (ih : Π (_a : α), C (_a, tl)) (f : α), ih2 f (hd, tl) (ih1 f) (ih hd)) f)
@[protected]
def free_semigroup.rec_on {α : Type u} {C : free_semigroup αSort l} (x : free_semigroup α) (ih1 : Π (x : α), C (free_semigroup.of x)) (ih2 : Π (x : α) (y : free_semigroup α), C (free_semigroup.of x)C yC (free_semigroup.of x * y)) :
C x

Recursor for free semigroup using of and *.

Equations
  • x.rec_on ih1 ih2 = prod.rec_on x (λ (f : α) (s : list α), s.rec_on ih1 (λ (hd : α) (tl : list α) (ih : Π (_a : α), C (_a, tl)) (f : α), ih2 f (hd, tl) (ih1 f) (ih hd)) f)
def free_semigroup.lift' {α : Type u} {β : Type v} [semigroup β] (f : α → β) :
α → list α → β

Auxiliary function for free_semigroup.lift.

Equations
def free_add_semigroup.lift' {α : Type u} {β : Type v} [add_semigroup β] (f : α → β) :
α → list α → β

Auxiliary function for free_semigroup.lift.

Equations
def free_semigroup.lift {α : Type u} {β : Type v} [semigroup β] (f : α → β) (x : free_semigroup α) :
β

Lifts a function α → β to a semigroup homomorphism free_semigroup α → β given a semigroup β.

Equations
def free_add_semigroup.lift {α : Type u} {β : Type v} [add_semigroup β] (f : α → β) (x : free_add_semigroup α) :
β

Lifts a function α → β to an additive semigroup homomorphism free_add_semigroup α → β given an additive semigroup β.

Equations
@[simp]
theorem free_semigroup.lift_of {α : Type u} {β : Type v} [semigroup β] (f : α → β) (x : α) :
@[simp]
theorem free_add_semigroup.lift_of {α : Type u} {β : Type v} [add_semigroup β] (f : α → β) (x : α) :
theorem free_add_semigroup.lift_of_add {α : Type u} {β : Type v} [add_semigroup β] (f : α → β) (x : α) (y : free_add_semigroup α) :
theorem free_semigroup.lift_of_mul {α : Type u} {β : Type v} [semigroup β] (f : α → β) (x : α) (y : free_semigroup α) :
@[simp]
theorem free_add_semigroup.lift_add {α : Type u} {β : Type v} [add_semigroup β] (f : α → β) (x y : free_add_semigroup α) :
@[simp]
theorem free_semigroup.lift_mul {α : Type u} {β : Type v} [semigroup β] (f : α → β) (x y : free_semigroup α) :
theorem free_add_semigroup.lift_unique {α : Type u} {β : Type v} [add_semigroup β] (f : free_add_semigroup α → β) (hf : ∀ (x y : free_add_semigroup α), f (x + y) = f x + f y) :
theorem free_semigroup.lift_unique {α : Type u} {β : Type v} [semigroup β] (f : free_semigroup α → β) (hf : ∀ (x y : free_semigroup α), f (x * y) = f x * f y) :
def free_semigroup.map {α : Type u} {β : Type v} (f : α → β) :

The unique semigroup homomorphism that sends of x to of (f x).

Equations
def free_add_semigroup.map {α : Type u} {β : Type v} (f : α → β) :

The unique additive semigroup homomorphism that sends of x to of (f x).

Equations
@[simp]
theorem free_add_semigroup.map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :
@[simp]
theorem free_semigroup.map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :
@[simp]
theorem free_add_semigroup.map_add {α : Type u} {β : Type v} (f : α → β) (x y : free_add_semigroup α) :
@[simp]
theorem free_semigroup.map_mul {α : Type u} {β : Type v} (f : α → β) (x y : free_semigroup α) :
def free_semigroup.rec_on_pure {α : Type u} {C : free_semigroup αSort l} (x : free_semigroup α) (ih1 : Π (x : α), C (has_pure.pure x)) (ih2 : Π (x : α) (y : free_semigroup α), C (has_pure.pure x)C yC (has_pure.pure x * y)) :
C x

Recursor that uses pure instead of of.

Equations
def free_add_semigroup.rec_on_pure {α : Type u} {C : free_add_semigroup αSort l} (x : free_add_semigroup α) (ih1 : Π (x : α), C (has_pure.pure x)) (ih2 : Π (x : α) (y : free_add_semigroup α), C (has_pure.pure x)C yC (has_pure.pure x + y)) :
C x

Recursor that uses pure instead of of.

Equations
@[simp]
theorem free_semigroup.map_pure {α β : Type u} (f : α → β) (x : α) :
@[simp]
theorem free_add_semigroup.map_pure {α β : Type u} (f : α → β) (x : α) :
@[simp]
theorem free_add_semigroup.map_add' {α β : Type u} (f : α → β) (x y : free_add_semigroup α) :
f <$> (x + y) = f <$> x + f <$> y
@[simp]
theorem free_semigroup.map_mul' {α β : Type u} (f : α → β) (x y : free_semigroup α) :
f <$> (x * y) = f <$> x * f <$> y
@[simp]
theorem free_add_semigroup.pure_bind {α β : Type u} (f : α → free_add_semigroup β) (x : α) :
@[simp]
theorem free_semigroup.pure_bind {α β : Type u} (f : α → free_semigroup β) (x : α) :
@[simp]
theorem free_add_semigroup.add_bind {α β : Type u} (f : α → free_add_semigroup β) (x y : free_add_semigroup α) :
x + y >>= f = (x >>= f) + (y >>= f)
@[simp]
theorem free_semigroup.mul_bind {α β : Type u} (f : α → free_semigroup β) (x y : free_semigroup α) :
x * y >>= f = (x >>= f) * (y >>= f)
@[simp]
theorem free_add_semigroup.pure_seq {α β : Type u} {f : α → β} {x : free_add_semigroup α} :
@[simp]
theorem free_semigroup.pure_seq {α β : Type u} {f : α → β} {x : free_semigroup α} :
@[simp]
theorem free_semigroup.mul_seq {α β : Type u} {f g : free_semigroup (α → β)} {x : free_semigroup α} :
f * g <*> x = (f <*> x) * (g <*> x)
@[simp]
theorem free_add_semigroup.add_seq {α β : Type u} {f g : free_add_semigroup (α → β)} {x : free_add_semigroup α} :
f + g <*> x = (f <*> x) + (g <*> x)
@[protected]
def free_add_semigroup.traverse {m : Type uType u} [applicative m] {α β : Type u} (F : α → m β) (x : free_add_semigroup α) :

free_add_semigroup is traversable.

Equations
@[protected]
def free_semigroup.traverse {m : Type uType u} [applicative m] {α β : Type u} (F : α → m β) (x : free_semigroup α) :

free_semigroup is traversable.

Equations
@[simp]
theorem free_add_semigroup.traverse_pure {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : α) :
@[simp]
theorem free_semigroup.traverse_pure {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : α) :
@[simp]
theorem free_add_semigroup.traverse_pure' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :
@[simp]
theorem free_semigroup.traverse_pure' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :
@[simp]
theorem free_add_semigroup.traverse_add {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) [is_lawful_applicative m] (x y : free_add_semigroup α) :
@[simp]
theorem free_semigroup.traverse_mul {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) [is_lawful_applicative m] (x y : free_semigroup α) :
@[simp]
@[simp]
theorem free_semigroup.traverse_mul' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) [is_lawful_applicative m] :
@[simp]
theorem free_semigroup.traverse_eq {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : free_semigroup α) :
@[simp]
theorem free_add_semigroup.traverse_eq {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : free_add_semigroup α) :
@[simp]
theorem free_add_semigroup.add_map_seq {α : Type u} (x y : free_add_semigroup α) :
@[simp]
theorem free_semigroup.mul_map_seq {α : Type u} (x y : free_semigroup α) :
@[protected, instance]
Equations
@[protected, instance]
Equations