fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
@[to_additive] FreeMagma (α : Type u) : Type u | of : α → FreeMagma α | mul : FreeMagma α → FreeMagma α → FreeMagma α deriving DecidableEq compile_inductive% FreeMagma
inductive
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeMagma
If `α` is a type, then `FreeMagma α` is the free magma generated by `α`. This is a magma equipped with a function `FreeMagma.of : α → FreeMagma α` which has the following universal property: if `M` is any magma, and `f : α → M` is any function, then this function is the composite of `FreeMagma.of` and a unique multiplicative homomorphism `FreeMagma.lift f : FreeMagma α →ₙ* M`. A typical element of `FreeMagma α` is a formal non-associative product of elements of `α`. For example if `x` and `y` are terms of type `α` then `x * ((y * y) * x)` is a "typical" element of `FreeMagma α`. One can think of `FreeMagma α` as the type of binary trees with leaves labelled by `α`. In general, no pair of distinct elements in `FreeMagma α` will commute.
@[to_additive (attr := simp)] mul_eq (x y : FreeMagma α) : mul x y = x * y := rfl
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mul_eq
null
@[to_additive (attr := elab_as_elim, induction_eliminator) /-- Recursor for `FreeAddMagma` using `x + y` instead of `FreeAddMagma.add x y`. -/] recOnMul {C : FreeMagma α → Sort l} (x) (ih1 : ∀ x, C (of x)) (ih2 : ∀ x y, C x → C y → C (x * y)) : C x := FreeMagma.recOn x ih1 ih2 @[to_additive (attr := ext 1100)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
recOnMul
Recursor for `FreeMagma` using `x * y` instead of `FreeMagma.mul x y`.
hom_ext {β : Type v} [Mul β] {f g : FreeMagma α →ₙ* β} (h : f ∘ of = g ∘ of) : f = g := (DFunLike.ext _ _) fun x ↦ recOnMul x (congr_fun h) <| by intros; simp only [map_mul, *]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
hom_ext
null
FreeMagma.liftAux {α : Type u} {β : Type v} [Mul β] (f : α → β) : FreeMagma α → β | FreeMagma.of x => f x | x * y => liftAux f x * liftAux f y
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeMagma.liftAux
Lifts a function `α → β` to a magma homomorphism `FreeMagma α → β` given a magma `β`.
FreeAddMagma.liftAux {α : Type u} {β : Type v} [Add β] (f : α → β) : FreeAddMagma α → β | FreeAddMagma.of x => f x | x + y => liftAux f x + liftAux f y attribute [to_additive existing] FreeMagma.liftAux
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeAddMagma.liftAux
Lifts a function `α → β` to an additive magma homomorphism `FreeAddMagma α → β` given an additive magma `β`.
@[to_additive (attr := simps symm_apply) /-- The universal property of the free additive magma expressing its adjointness. -/] lift : (α → β) ≃ (FreeMagma α →ₙ* β) where toFun f := { toFun := liftAux f map_mul' := fun _ _ ↦ rfl } invFun F := F ∘ of @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift
The universal property of the free magma expressing its adjointness.
lift_of (x) : lift f (of x) = f x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_of
null
lift_comp_of : lift f ∘ of = f := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_comp_of
null
lift_comp_of' (f : FreeMagma α →ₙ* β) : lift (f ∘ of) = f := lift.apply_symm_apply f
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_comp_of'
null
@[to_additive /-- The unique additive magma homomorphism `FreeAddMagma α → FreeAddMagma β` that sends each `of x` to `of (f x)`. -/] map (f : α → β) : FreeMagma α →ₙ* FreeMagma β := lift (of ∘ f) @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map
The unique magma homomorphism `FreeMagma α →ₙ* FreeMagma β` that sends each `of x` to `of (f x)`.
map_of (x) : map f (of x) = of (f x) := rfl
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map_of
null
@[to_additive (attr := elab_as_elim) /-- Recursor on `FreeAddMagma` using `pure` instead of `of`. -/] protected recOnPure {C : FreeMagma α → Sort l} (x) (ih1 : ∀ x, C (pure x)) (ih2 : ∀ x y, C x → C y → C (x * y)) : C x := FreeMagma.recOnMul x ih1 ih2 @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
recOnPure
Recursor on `FreeMagma` using `pure` instead of `of`.
protected map_pure (f : α → β) (x) : (f <$> pure x : FreeMagma β) = pure (f x) := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map_pure
null
map_mul' (f : α → β) (x y : FreeMagma α) : f <$> (x * y) = f <$> x * f <$> y := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map_mul'
null
pure_bind (f : α → FreeMagma β) (x) : pure x >>= f = f x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
pure_bind
null
mul_bind (f : α → FreeMagma β) (x y : FreeMagma α) : x * y >>= f = (x >>= f) * (y >>= f) := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mul_bind
null
pure_seq {α β : Type u} {f : α → β} {x : FreeMagma α} : pure f <*> x = f <$> x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
pure_seq
null
mul_seq {α β : Type u} {f g : FreeMagma (α → β)} {x : FreeMagma α} : f * g <*> x = (f <*> x) * (g <*> x) := rfl @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mul_seq
null
instLawfulMonad : LawfulMonad FreeMagma.{u} := LawfulMonad.mk' (pure_bind := fun _ _ ↦ rfl) (bind_assoc := fun x f g ↦ FreeMagma.recOnPure x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by rw [mul_bind, mul_bind, mul_bind, ih1, ih2]) (id_map := fun x ↦ FreeMagma.recOnPure x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by rw [map_mul', ih1, ih2])
instance
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
instLawfulMonad
null
protected FreeMagma.traverse {m : Type u → Type u} [Applicative m] {α β : Type u} (F : α → m β) : FreeMagma α → m (FreeMagma β) | FreeMagma.of x => FreeMagma.of <$> F x | x * y => (· * ·) <$> x.traverse F <*> y.traverse F
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeMagma.traverse
`FreeMagma` is traversable.
protected FreeAddMagma.traverse {m : Type u → Type u} [Applicative m] {α β : Type u} (F : α → m β) : FreeAddMagma α → m (FreeAddMagma β) | FreeAddMagma.of x => FreeAddMagma.of <$> F x | x + y => (· + ·) <$> x.traverse F <*> y.traverse F attribute [to_additive existing] FreeMagma.traverse
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeAddMagma.traverse
`FreeAddMagma` is traversable.
@[to_additive (attr := simp)] traverse_pure (x) : traverse F (pure x : FreeMagma α) = pure <$> F x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_pure
null
traverse_pure' : traverse F ∘ pure = fun x ↦ (pure <$> F x : m (FreeMagma β)) := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_pure'
null
traverse_mul (x y : FreeMagma α) : traverse F (x * y) = (· * ·) <$> traverse F x <*> traverse F y := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_mul
null
traverse_mul' : Function.comp (traverse F) ∘ (HMul.hMul : FreeMagma α → FreeMagma α → FreeMagma α) = fun x y ↦ (· * ·) <$> traverse F x <*> traverse F y := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_mul'
null
traverse_eq (x) : FreeMagma.traverse F x = traverse F x := rfl @[to_additive (attr := deprecated "Use map_pure and seq_pure" (since := "2025-05-21"))]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_eq
null
mul_map_seq (x y : FreeMagma α) : ((· * ·) <$> x <*> y : Id (FreeMagma α)) = (x * y : FreeMagma α) := rfl @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mul_map_seq
null
protected FreeMagma.repr {α : Type u} [Repr α] : FreeMagma α → Lean.Format | FreeMagma.of x => repr x | x * y => "( " ++ x.repr ++ " * " ++ y.repr ++ " )"
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeMagma.repr
Representation of an element of a free magma.
protected FreeAddMagma.repr {α : Type u} [Repr α] : FreeAddMagma α → Lean.Format | FreeAddMagma.of x => repr x | x + y => "( " ++ x.repr ++ " + " ++ y.repr ++ " )" attribute [to_additive existing] FreeMagma.repr @[to_additive]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeAddMagma.repr
Representation of an element of a free additive magma.
FreeMagma.length {α : Type u} : FreeMagma α → ℕ | FreeMagma.of _x => 1 | x * y => x.length + y.length
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeMagma.length
Length of an element of a free magma.
FreeAddMagma.length {α : Type u} : FreeAddMagma α → ℕ | FreeAddMagma.of _x => 1 | x + y => x.length + y.length attribute [to_additive existing (attr := simp)] FreeMagma.length
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeAddMagma.length
Length of an element of a free additive magma.
@[to_additive /-- The length of an element of a free additive magma is positive. -/] FreeMagma.length_pos {α : Type u} (x : FreeMagma α) : 0 < x.length := match x with | FreeMagma.of _ => Nat.succ_pos 0 | mul y z => Nat.add_pos_left (length_pos y) z.length
lemma
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeMagma.length_pos
The length of an element of a free magma is positive.
AddMagma.AssocRel (α : Type u) [Add α] : α → α → Prop | intro : ∀ x y z, AddMagma.AssocRel α (x + y + z) (x + (y + z)) | left : ∀ w x y z, AddMagma.AssocRel α (w + (x + y + z)) (w + (x + (y + z)))
inductive
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
AddMagma.AssocRel
Associativity relations for an additive magma.
@[to_additive AddMagma.AssocRel /-- Associativity relations for an additive magma. -/] Magma.AssocRel (α : Type u) [Mul α] : α → α → Prop | intro : ∀ x y z, Magma.AssocRel α (x * y * z) (x * (y * z)) | left : ∀ w x y z, Magma.AssocRel α (w * (x * y * z)) (w * (x * (y * z)))
inductive
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
Magma.AssocRel
Associativity relations for a magma.
@[to_additive AddMagma.FreeAddSemigroup /-- Additive semigroup quotient of an additive magma. -/] AssocQuotient (α : Type u) [Mul α] : Type u := Quot <| AssocRel α
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
AssocQuotient
Semigroup quotient of a magma.
@[to_additive] quot_mk_assoc (x y z : α) : Quot.mk (AssocRel α) (x * y * z) = Quot.mk _ (x * (y * z)) := Quot.sound (AssocRel.intro _ _ _) @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
quot_mk_assoc
null
quot_mk_assoc_left (x y z w : α) : Quot.mk (AssocRel α) (x * (y * z * w)) = Quot.mk _ (x * (y * (z * w))) := Quot.sound (AssocRel.left _ _ _ _) @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
quot_mk_assoc_left
null
@[to_additive /-- Embedding from additive magma to its free additive semigroup. -/] of : α →ₙ* AssocQuotient α where toFun := Quot.mk _; map_mul' _x _y := rfl @[to_additive]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
of
Embedding from magma to its free semigroup.
@[to_additive (attr := elab_as_elim, induction_eliminator)] protected induction_on {C : AssocQuotient α → Prop} (x : AssocQuotient α) (ih : ∀ x, C (of x)) : C x := Quot.induction_on x ih
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
induction_on
null
@[to_additive (attr := ext 1100)] hom_ext {f g : AssocQuotient α →ₙ* β} (h : f.comp of = g.comp of) : f = g := (DFunLike.ext _ _) fun x => AssocQuotient.induction_on x <| DFunLike.congr_fun h
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
hom_ext
null
@[to_additive (attr := simps symm_apply) /-- Lifts an additive magma homomorphism `α → β` to an additive semigroup homomorphism `AddMagma.AssocQuotient α → β` given an additive semigroup `β`. -/] lift : (α →ₙ* β) ≃ (AssocQuotient α →ₙ* β) where toFun f := { toFun := fun x ↦ Quot.liftOn x f <| by rintro a b (⟨c, d, e⟩ | ⟨c, d, e, f⟩) <;> simp only [map_mul, mul_assoc] map_mul' := fun x y ↦ Quot.induction_on₂ x y (map_mul f) } invFun f := f.comp of @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift
Lifts a magma homomorphism `α → β` to a semigroup homomorphism `Magma.AssocQuotient α → β` given a semigroup `β`.
lift_of (x : α) : lift f (of x) = f x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_of
null
lift_comp_of : (lift f).comp of = f := lift.symm_apply_apply f @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_comp_of
null
lift_comp_of' (f : AssocQuotient α →ₙ* β) : lift (f.comp of) = f := lift.apply_symm_apply f
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_comp_of'
null
@[to_additive /-- From an additive magma homomorphism `α → β` to an additive semigroup homomorphism `AddMagma.AssocQuotient α → AddMagma.AssocQuotient β`. -/] map : AssocQuotient α →ₙ* AssocQuotient β := lift (of.comp f) @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map
From a magma homomorphism `α →ₙ* β` to a semigroup homomorphism `Magma.AssocQuotient α →ₙ* Magma.AssocQuotient β`.
map_of (x) : map f (of x) = of (f x) := rfl
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map_of
null
FreeAddSemigroup (α : Type u) where /-- The head of the element -/ head : α /-- The tail of the element -/ tail : List α compile_inductive% FreeAddSemigroup
structure
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeAddSemigroup
If `α` is a type, then `FreeAddSemigroup α` is the free additive semigroup generated by `α`. This is an additive semigroup equipped with a function `FreeAddSemigroup.of : α → FreeAddSemigroup α` which has the following universal property: if `M` is any additive semigroup, and `f : α → M` is any function, then this function is the composite of `FreeAddSemigroup.of` and a unique semigroup homomorphism `FreeAddSemigroup.lift f : FreeAddSemigroup α →ₙ+ M`. A typical element of `FreeAddSemigroup α` is a nonempty 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 `FreeAddSemigroup α`. In particular if `α` is empty then `FreeAddSemigroup α` is also empty, and if `α` has one term then `FreeAddSemigroup α` is isomorphic to `ℕ+`. If `α` has two or more terms then `FreeAddSemigroup α` is not commutative. One can think of `FreeAddSemigroup α` as the type of nonempty lists of `α`, with addition given by concatenation.
@[to_additive (attr := ext)] FreeSemigroup (α : Type u) where /-- The head of the element -/ head : α /-- The tail of the element -/ tail : List α compile_inductive% FreeSemigroup
structure
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeSemigroup
If `α` is a type, then `FreeSemigroup α` is the free semigroup generated by `α`. This is a semigroup equipped with a function `FreeSemigroup.of : α → FreeSemigroup α` which has the following universal property: if `M` is any semigroup, and `f : α → M` is any function, then this function is the composite of `FreeSemigroup.of` and a unique semigroup homomorphism `FreeSemigroup.lift f : FreeSemigroup α →ₙ* M`. A typical element of `FreeSemigroup α` is a nonempty 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 `FreeSemigroup α`. In particular if `α` is empty then `FreeSemigroup α` is also empty, and if `α` has one term then `FreeSemigroup α` is isomorphic to `Multiplicative ℕ+`. If `α` has two or more terms then `FreeSemigroup α` is not commutative. One can think of `FreeSemigroup α` as the type of nonempty lists of `α`, with multiplication given by concatenation.
@[to_additive (attr := simp)] head_mul (x y : FreeSemigroup α) : (x * y).1 = x.1 := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
head_mul
null
tail_mul (x y : FreeSemigroup α) : (x * y).2 = x.2 ++ y.1 :: y.2 := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
tail_mul
null
mk_mul_mk (x y : α) (L1 L2 : List α) : mk x L1 * mk y L2 = mk x (L1 ++ y :: L2) := rfl
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mk_mul_mk
null
@[to_additive (attr := simps) /-- The embedding `α → FreeAddSemigroup α`. -/] of (x : α) : FreeSemigroup α := ⟨x, []⟩
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
of
The embedding `α → FreeSemigroup α`.
@[to_additive /-- Length of an element of free additive semigroup -/] length (x : FreeSemigroup α) : ℕ := x.tail.length + 1 @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
length
Length of an element of free semigroup.
length_mul (x y : FreeSemigroup α) : (x * y).length = x.length + y.length := by simp [length, Nat.add_right_comm, List.length, List.length_append] @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
length_mul
null
length_of (x : α) : (of x).length = 1 := rfl @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
length_of
null
@[to_additive (attr := elab_as_elim, induction_eliminator) /-- Recursor for free additive semigroup using `of` and `+`. -/] protected recOnMul {C : FreeSemigroup α → Sort l} (x) (ih1 : ∀ x, C (of x)) (ih2 : ∀ x y, C (of x) → C y → C (of x * y)) : C x := FreeSemigroup.recOn x fun f s ↦ List.recOn s ih1 (fun hd tl ih f ↦ ih2 f ⟨hd, tl⟩ (ih1 f) (ih hd)) f @[to_additive (attr := ext 1100)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
recOnMul
Recursor for free semigroup using `of` and `*`.
hom_ext {β : Type v} [Mul β] {f g : FreeSemigroup α →ₙ* β} (h : f ∘ of = g ∘ of) : f = g := (DFunLike.ext _ _) fun x ↦ FreeSemigroup.recOnMul x (congr_fun h) fun x y hx hy ↦ by simp only [map_mul, *]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
hom_ext
null
@[to_additive (attr := simps symm_apply) /-- Lifts a function `α → β` to an additive semigroup homomorphism `FreeAddSemigroup α → β` given an additive semigroup `β`. -/] lift : (α → β) ≃ (FreeSemigroup α →ₙ* β) where toFun f := { toFun := fun x ↦ x.2.foldl (fun a b ↦ a * f b) (f x.1) map_mul' := fun x y ↦ by simp [head_mul, tail_mul, ← List.foldl_map, List.foldl_append, List.foldl_cons, List.foldl_assoc] } invFun f := f ∘ of @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift
Lifts a function `α → β` to a semigroup homomorphism `FreeSemigroup α → β` given a semigroup `β`.
lift_of (x : α) : lift f (of x) = f x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_of
null
lift_comp_of : lift f ∘ of = f := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_comp_of
null
lift_comp_of' (f : FreeSemigroup α →ₙ* β) : lift (f ∘ of) = f := hom_ext rfl @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_comp_of'
null
lift_of_mul (x y) : lift f (of x * y) = f x * lift f y := by rw [map_mul, lift_of]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
lift_of_mul
null
@[to_additive /-- The unique additive semigroup homomorphism that sends `of x` to `of (f x)`. -/] map : FreeSemigroup α →ₙ* FreeSemigroup β := lift <| of ∘ f @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map
The unique semigroup homomorphism that sends `of x` to `of (f x)`.
map_of (x) : map f (of x) = of (f x) := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map_of
null
length_map (x) : (map f x).length = x.length := FreeSemigroup.recOnMul x (fun _ ↦ rfl) (fun x y hx hy ↦ by simp only [map_mul, length_mul, *])
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
length_map
null
@[to_additive (attr := elab_as_elim) /-- Recursor that uses `pure` instead of `of`. -/] recOnPure {C : FreeSemigroup α → Sort l} (x) (ih1 : ∀ x, C (pure x)) (ih2 : ∀ x y, C (pure x) → C y → C (pure x * y)) : C x := FreeSemigroup.recOnMul x ih1 ih2 @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
recOnPure
Recursor that uses `pure` instead of `of`.
protected map_pure (f : α → β) (x) : (f <$> pure x : FreeSemigroup β) = pure (f x) := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map_pure
null
map_mul' (f : α → β) (x y : FreeSemigroup α) : f <$> (x * y) = f <$> x * f <$> y := map_mul (map f) _ _ @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
map_mul'
null
pure_bind (f : α → FreeSemigroup β) (x) : pure x >>= f = f x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
pure_bind
null
mul_bind (f : α → FreeSemigroup β) (x y : FreeSemigroup α) : x * y >>= f = (x >>= f) * (y >>= f) := map_mul (lift f) _ _ @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mul_bind
null
pure_seq {f : α → β} {x : FreeSemigroup α} : pure f <*> x = f <$> x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
pure_seq
null
mul_seq {f g : FreeSemigroup (α → β)} {x : FreeSemigroup α} : f * g <*> x = (f <*> x) * (g <*> x) := mul_bind _ _ _ @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mul_seq
null
instLawfulMonad : LawfulMonad FreeSemigroup.{u} := LawfulMonad.mk' (pure_bind := fun _ _ ↦ rfl) (bind_assoc := fun x g f ↦ recOnPure x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by rw [mul_bind, mul_bind, mul_bind, ih1, ih2]) (id_map := fun x ↦ recOnPure x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by rw [map_mul', ih1, ih2])
instance
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
instLawfulMonad
null
@[to_additive /-- `FreeAddSemigroup` is traversable. -/] protected traverse {m : Type u → Type u} [Applicative m] {α β : Type u} (F : α → m β) (x : FreeSemigroup α) : m (FreeSemigroup β) := recOnPure x (fun x ↦ pure <$> F x) fun _x _y ihx ihy ↦ (· * ·) <$> ihx <*> ihy @[to_additive]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse
`FreeSemigroup` is traversable.
@[to_additive (attr := simp)] traverse_pure (x) : traverse F (pure x : FreeSemigroup α) = pure <$> F x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_pure
null
traverse_pure' : traverse F ∘ pure = fun x ↦ (pure <$> F x : m (FreeSemigroup β)) := rfl
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_pure'
null
@[to_additive (attr := simp)] traverse_mul (x y : FreeSemigroup α) : traverse F (x * y) = (· * ·) <$> traverse F x <*> traverse F y := let ⟨x, L1⟩ := x let ⟨y, L2⟩ := y List.recOn L1 (fun _ ↦ rfl) (fun hd tl ih x ↦ show (· * ·) <$> pure <$> F x <*> traverse F (mk hd tl * mk y L2) = (· * ·) <$> ((· * ·) <$> pure <$> F x <*> traverse F (mk hd tl)) <*> traverse F (mk y L2) by rw [ih]; simp only [Function.comp_def, (mul_assoc _ _ _).symm, functor_norm]) x @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_mul
null
traverse_mul' : Function.comp (traverse F) ∘ (HMul.hMul : FreeSemigroup α → FreeSemigroup α → FreeSemigroup α) = fun x y ↦ (· * ·) <$> traverse F x <*> traverse F y := funext fun x ↦ funext fun y ↦ traverse_mul F x y
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_mul'
null
@[to_additive (attr := simp)] traverse_eq (x) : FreeSemigroup.traverse F x = traverse F x := rfl @[to_additive (attr := deprecated "Use map_pure and seq_pure" (since := "2025-05-21"))]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
traverse_eq
null
mul_map_seq (x y : FreeSemigroup α) : ((· * ·) <$> x <*> y : Id (FreeSemigroup α)) = (x * y : FreeSemigroup α) := rfl @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
mul_map_seq
null
@[to_additive /-- The canonical additive morphism from `FreeAddMagma α` to `FreeAddSemigroup α`. -/] toFreeSemigroup : FreeMagma α →ₙ* FreeSemigroup α := FreeMagma.lift FreeSemigroup.of @[to_additive (attr := simp)]
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
toFreeSemigroup
The canonical multiplicative morphism from `FreeMagma α` to `FreeSemigroup α`.
toFreeSemigroup_of (x : α) : toFreeSemigroup (of x) = FreeSemigroup.of x := rfl @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
toFreeSemigroup_of
null
toFreeSemigroup_comp_of : @toFreeSemigroup α ∘ of = FreeSemigroup.of := rfl @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
toFreeSemigroup_comp_of
null
toFreeSemigroup_comp_map (f : α → β) : toFreeSemigroup.comp (map f) = (FreeSemigroup.map f).comp toFreeSemigroup := by ext1; rfl @[to_additive]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
toFreeSemigroup_comp_map
null
toFreeSemigroup_map (f : α → β) (x : FreeMagma α) : toFreeSemigroup (map f x) = FreeSemigroup.map f (toFreeSemigroup x) := DFunLike.congr_fun (toFreeSemigroup_comp_map f) x @[to_additive (attr := simp)]
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
toFreeSemigroup_map
null
length_toFreeSemigroup (x : FreeMagma α) : (toFreeSemigroup x).length = x.length := FreeMagma.recOnMul x (fun _ ↦ rfl) fun x y hx hy ↦ by rw [map_mul, FreeSemigroup.length_mul, hx, hy]; rfl
theorem
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
length_toFreeSemigroup
null
@[to_additive /-- Isomorphism between `AddMagma.AssocQuotient (FreeAddMagma α)` and `FreeAddSemigroup α`. -/] FreeMagmaAssocQuotientEquiv (α : Type u) : Magma.AssocQuotient (FreeMagma α) ≃* FreeSemigroup α := (Magma.AssocQuotient.lift FreeMagma.toFreeSemigroup).toMulEquiv (FreeSemigroup.lift (Magma.AssocQuotient.of ∘ FreeMagma.of)) (by ext; rfl) (by ext1; rfl)
def
Algebra
[ "Mathlib.Algebra.Group.Basic", "Mathlib.Algebra.Group.Equiv.Defs", "Mathlib.Control.Applicative", "Mathlib.Control.Traversable.Basic", "Mathlib.Logic.Equiv.Defs", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Algebra/Free.lean
FreeMagmaAssocQuotientEquiv
Isomorphism between `Magma.AssocQuotient (FreeMagma α)` and `FreeSemigroup α`.
Pre | of : X → Pre | ofScalar : R → Pre | add : Pre → Pre → Pre | mul : Pre → Pre → Pre
inductive
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
Pre
This inductive type is used to express representatives of the free algebra.
hasCoeGenerator : Coe X (Pre R X) := ⟨of⟩
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
hasCoeGenerator
Coercion from `X` to `Pre R X`. Note: Used for notation only.
hasCoeSemiring : Coe R (Pre R X) := ⟨ofScalar⟩
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
hasCoeSemiring
Coercion from `R` to `Pre R X`. Note: Used for notation only.
hasMul : Mul (Pre R X) := ⟨mul⟩
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
hasMul
Multiplication in `Pre R X` defined as `Pre.mul`. Note: Used for notation only.
hasAdd : Add (Pre R X) := ⟨add⟩
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
hasAdd
Addition in `Pre R X` defined as `Pre.add`. Note: Used for notation only.
hasZero : Zero (Pre R X) := ⟨ofScalar 0⟩
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
hasZero
Zero in `Pre R X` defined as the image of `0` from `R`. Note: Used for notation only.
hasOne : One (Pre R X) := ⟨ofScalar 1⟩
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
hasOne
One in `Pre R X` defined as the image of `1` from `R`. Note: Used for notation only.
hasSMul : SMul R (Pre R X) := ⟨fun r m ↦ mul (ofScalar r) m⟩
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
hasSMul
Scalar multiplication defined as multiplication by the image of elements from `R`. Note: Used for notation only.
liftFun {A : Type*} [Semiring A] [Algebra R A] (f : X → A) : Pre R X → A | .of t => f t | .add a b => liftFun f a + liftFun f b | .mul a b => liftFun f a * liftFun f b | .ofScalar c => algebraMap _ _ c
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
liftFun
Given a function from `X` to an `R`-algebra `A`, `lift_fun` provides a lift of `f` to a function from `Pre R X` to `A`. This is mainly used in the construction of `FreeAlgebra.lift`.
Rel : Pre R X → Pre R X → Prop | add_scalar {r s : R} : Rel (↑(r + s)) (↑r + ↑s) | mul_scalar {r s : R} : Rel (↑(r * s)) (↑r * ↑s) | central_scalar {r : R} {a : Pre R X} : Rel (r * a) (a * r) | add_assoc {a b c : Pre R X} : Rel (a + b + c) (a + (b + c)) | add_comm {a b : Pre R X} : Rel (a + b) (b + a) | zero_add {a : Pre R X} : Rel (0 + a) a | mul_assoc {a b c : Pre R X} : Rel (a * b * c) (a * (b * c)) | one_mul {a : Pre R X} : Rel (1 * a) a | mul_one {a : Pre R X} : Rel (a * 1) a | left_distrib {a b c : Pre R X} : Rel (a * (b + c)) (a * b + a * c) | right_distrib {a b c : Pre R X} : Rel ((a + b) * c) (a * c + b * c) | zero_mul {a : Pre R X} : Rel (0 * a) 0 | mul_zero {a : Pre R X} : Rel (a * 0) 0 | add_compat_left {a b c : Pre R X} : Rel a b → Rel (a + c) (b + c) | add_compat_right {a b c : Pre R X} : Rel a b → Rel (c + a) (c + b) | mul_compat_left {a b c : Pre R X} : Rel a b → Rel (a * c) (b * c) | mul_compat_right {a b c : Pre R X} : Rel a b → Rel (c * a) (c * b)
inductive
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
Rel
An inductively defined relation on `Pre R X` used to force the initial algebra structure on the associated quotient.
FreeAlgebra := Quot (FreeAlgebra.Rel R X)
def
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
FreeAlgebra
If `α` is a type, and `R` is a commutative semiring, then `FreeAlgebra R α` is the free (unital, associative) `R`-algebra generated by `α`. This is an `R`-algebra equipped with a function `FreeAlgebra.ι R : α → FreeAlgebra R α` which has the following universal property: if `A` is any `R`-algebra, and `f : α → A` is any function, then this function is the composite of `FreeAlgebra.ι R` and a unique `R`-algebra homomorphism `FreeAlgebra.lift R f : FreeAlgebra R α →ₐ[R] A`. A typical element of `FreeAlgebra R α` is an `R`-linear combination of formal products of elements of `α`. For example if `x` and `y` are terms of type `α` and `a`, `b` are terms of type `R` then `(3 * a * a) • (x * y * x) + (2 * b + 1) • (y * x) + (a * b * b + 3)` is a "typical" element of `FreeAlgebra R α`. In particular if `α` is empty then `FreeAlgebra R α` is isomorphic to `R`, and if `α` has one term `t` then `FreeAlgebra R α` is isomorphic to the polynomial ring `R[t]`. If `α` has two or more terms then `FreeAlgebra R α` is not commutative. One can think of `FreeAlgebra R α` as the free non-commutative polynomial ring with coefficients in `R` and variables indexed by `α`.
instSMul {A} [CommSemiring A] [Algebra R A] : SMul R (FreeAlgebra A X) where smul r := Quot.map (HMul.hMul (algebraMap R A r : Pre A X)) fun _ _ ↦ Rel.mul_compat_right
instance
Algebra
[ "Mathlib.Algebra.Algebra.Subalgebra.Basic", "Mathlib.Algebra.Algebra.Subalgebra.Lattice", "Mathlib.Algebra.FreeMonoid.UniqueProds", "Mathlib.Algebra.MonoidAlgebra.Basic", "Mathlib.Algebra.MonoidAlgebra.NoZeroDivisors" ]
Mathlib/Algebra/FreeAlgebra.lean
instSMul
null