mathlib documentation

algebra.​free

algebra.​free

Free constructions

Main definitions

inductive free_magma  :
Type uType u

Free magma over a given alphabet.

@[instance]
def free_magma.​decidable_eq (α : Type u) [a : decidable_eq α] :

@[instance]

inductive free_add_magma  :
Type uType u

Free nonabelian additive magma over a given alphabet.

@[instance]

@[instance]
def free_magma.​has_mul {α : Type u} :

Equations
@[instance]

@[simp]
theorem free_add_magma.​add_eq {α : Type u} (x y : free_add_magma α) :
x.add y = x + y

@[simp]
theorem free_magma.​mul_eq {α : Type u} (x y : free_magma α) :
x.mul y = x * y

def free_magma.​rec_on' {α : Type u} {C : free_magma αSort l} (x : free_magma α) :
(Π (x : α), C (free_magma.of x))(Π (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_add_magma.​rec_on' {α : Type u} {C : free_add_magma αSort l} (x : free_add_magma α) :
(Π (x : α), C (free_add_magma.of x))(Π (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.

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

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

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

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

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

@[simp]
theorem free_add_magma.​lift_of {α : Type u} {β : Type v} [has_add β] (f : α → β) (x : α) :

@[simp]
theorem free_magma.​lift_mul {α : Type u} {β : Type v} [has_mul β] (f : α → β) (x y : free_magma α) :

@[simp]
theorem free_add_magma.​lift_add {α : Type u} {β : Type v} [has_add β] (f : α → β) (x y : free_add_magma α) :

theorem free_magma.​lift_unique {α : Type u} {β : Type v} [has_mul β] (f : free_magma α → β) :
(∀ (x y : free_magma α), f (x * y) = f x * f y)f = free_magma.lift (f free_magma.of)

theorem free_add_magma.​lift_unique {α : Type u} {β : Type v} [has_add β] (f : free_add_magma α → β) :
(∀ (x y : free_add_magma α), f (x + y) = f x + f y)f = free_add_magma.lift (f free_add_magma.of)

def free_magma.​map {α : Type u} {β : Type v} :
(α → β)free_magma αfree_magma β

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} :
(α → β)free_add_magma αfree_add_magma β

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 α) :

def free_magma.​rec_on'' {α : Type u} {C : free_magma αSort l} (x : free_magma α) :
(Π (x : α), C (has_pure.pure x))(Π (x y : free_magma α), C xC yC (x * y))C x

Recursor on free_magma using pure instead of of.

Equations
def free_add_magma.​rec_on'' {α : Type u} {C : free_add_magma αSort l} (x : free_add_magma α) :
(Π (x : α), C (has_pure.pure x))(Π (x y : free_add_magma α), C xC yC (x + y))C x

Recursor on free_add_magma using pure instead of of.

@[simp]
theorem free_add_magma.​map_pure {α β : Type u} (f : α → β) (x : α) :

@[simp]
theorem free_magma.​map_pure {α β : Type u} (f : α → β) (x : α) :

@[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_magma.​map_mul' {α β : Type u} (f : α → β) (x y : free_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_magma.​pure_seq {α β : Type u} {f : α → β} {x : free_magma α} :

@[simp]
theorem free_add_magma.​pure_seq {α β : Type u} {f : α → β} {x : free_add_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)

def free_magma.​traverse {m : Type uType u} [applicative m] {α β : Type u} :
(α → m β)free_magma αm (free_magma β)

free_magma is traversable.

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

free_add_magma is traversable.

Equations
@[simp]
theorem free_add_magma.​traverse_pure {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : α) :

@[simp]
theorem free_magma.​traverse_pure {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) (x : α) :

@[simp]
theorem free_magma.​traverse_pure' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :

@[simp]
theorem free_add_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_add_magma.​traverse_add' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :

@[simp]
theorem free_magma.​traverse_mul' {α β : 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_magma.​mul_map_seq {α : Type u} (x y : free_magma α) :

@[simp]
theorem free_add_magma.​add_map_seq {α : Type u} (x y : free_add_magma α) :

@[instance]

Equations
def free_magma.​repr {α : Type u} [has_repr α] :

Representation of an element of a free magma.

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

Representation of an element of a free additive magma.

Equations
@[instance]

@[instance]
def free_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 add_magma.​free_add_semigroup (α : Type u) [has_add α] :
Type u

Free additive semigroup over an additive magma.

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

Free semigroup over a magma.

Equations

Embedding from additive magma to its free additive semigroup.

def magma.​free_semigroup.​of {α : Type u} [has_mul α] :

Embedding from magma to its free semigroup.

Equations
theorem magma.​free_semigroup.​induction_on {α : Type u} [has_mul α] {C : magma.free_semigroup α → Prop} (x : magma.free_semigroup α) :
(∀ (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 : α) :

@[instance]

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

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 : α → β) :
(∀ (x y : α), f (x + y) = f x + f y)add_magma.free_add_semigroup α → β

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

@[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 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_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 magma.​free_semigroup.​map {α : Type u} [has_mul α] {β : Type v} [has_mul β] (f : α → β) :
(∀ (x y : α), f (x * y) = f x * f y)magma.free_semigroup αmagma.free_semigroup β

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

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

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

@[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_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_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 α) :

@[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 α) :

def free_semigroup  :
Type uType u

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

Equations
def free_add_semigroup  :
Type uType u

Free additive semigroup over a given alphabet.

@[instance]

Equations
def free_add_semigroup.​of {α : Type u} :

The embedding α → free_add_semigroup α.

def free_semigroup.​of {α : Type u} :
α → free_semigroup α

The embedding α → free_semigroup α.

Equations
@[instance]

def free_add_semigroup.​rec_on {α : Type u} {C : free_add_semigroup αSort l} (x : free_add_semigroup α) :
(Π (x : α), C (free_add_semigroup.of x))(Π (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 +.

def free_semigroup.​rec_on {α : Type u} {C : free_semigroup αSort l} (x : free_semigroup α) :
(Π (x : α), C (free_semigroup.of x))(Π (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 β] :
(α → β)α → list α → β

Auxiliary function for free_semigroup.lift.

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

Auxiliary function for free_semigroup.lift.

Equations
def free_semigroup.​lift {α : Type u} {β : Type v} [semigroup β] :
(α → β)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 β] :
(α → β)free_add_semigroup α → β

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

@[simp]
theorem free_add_semigroup.​lift_of {α : Type u} {β : Type v} [add_semigroup β] (f : α → β) (x : α) :

@[simp]
theorem free_semigroup.​lift_of {α : Type u} {β : Type v} [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_semigroup.​lift_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 α) :

theorem free_semigroup.​lift_unique {α : Type u} {β : Type v} [semigroup β] (f : free_semigroup α → β) :
(∀ (x y : free_semigroup α), f (x * y) = f x * f y)f = free_semigroup.lift (f free_semigroup.of)

theorem free_add_semigroup.​lift_unique {α : Type u} {β : Type v} [add_semigroup β] (f : free_add_semigroup α → β) :
(∀ (x y : free_add_semigroup α), f (x + y) = f x + f y)f = free_add_semigroup.lift (f free_add_semigroup.of)

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

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

def free_semigroup.​map {α : Type u} {β : Type v} :
(α → β)free_semigroup αfree_semigroup β

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

Equations
@[simp]
theorem free_semigroup.​map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :

@[simp]
theorem free_add_semigroup.​map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :

@[simp]
theorem free_semigroup.​map_mul {α : Type u} {β : Type v} (f : α → β) (x y : free_semigroup α) :

@[simp]
theorem free_add_semigroup.​map_add {α : Type u} {β : Type v} (f : α → β) (x y : free_add_semigroup α) :

def free_semigroup.​rec_on' {α : Type u} {C : free_semigroup αSort l} (x : free_semigroup α) :
(Π (x : α), C (has_pure.pure x))(Π (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' {α : Type u} {C : free_add_semigroup αSort l} (x : free_add_semigroup α) :
(Π (x : α), C (has_pure.pure x))(Π (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.

@[simp]
theorem free_add_semigroup.​map_pure {α β : Type u} (f : α → β) (x : α) :

@[simp]
theorem free_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_semigroup.​pure_bind {α β : Type u} (f : α → free_semigroup β) (x : α) :

@[simp]
theorem free_add_semigroup.​pure_bind {α β : Type u} (f : α → free_add_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_semigroup.​pure_seq {α β : Type u} {f : α → β} {x : free_semigroup α} :

@[simp]
theorem free_add_semigroup.​pure_seq {α β : Type u} {f : α → β} {x : free_add_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)

def free_add_semigroup.​traverse {m : Type uType u} [applicative m] {α β : Type u} :
(α → m β)free_add_semigroup αm (free_add_semigroup β)

free_add_semigroup is traversable.

def free_semigroup.​traverse {m : Type uType u} [applicative m] {α β : Type u} :
(α → m β)free_semigroup αm (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_semigroup.​traverse_pure' {α β : Type u} {m : Type uType u} [applicative m] (F : α → m β) :

@[simp]
theorem free_add_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_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_semigroup.​mul_map_seq {α : Type u} (x y : free_semigroup α) :

@[simp]
theorem free_add_semigroup.​add_map_seq {α : Type u} (x y : free_add_semigroup α) :

@[instance]

Equations