Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit e70093f

Browse files
committed
feat(algebra/free_non_unital_non_assoc_algebra): construction of the free non-unital, non-associative algebra on a type X with coefficients in a semiring R (#8141)
1 parent e713106 commit e70093f

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

src/algebra/free_algebra.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import data.equiv.transfer_instance
1111
/-!
1212
# Free Algebras
1313
14-
Given a commutative semiring `R`, and a type `X`, we construct the free `R`-algebra on `X`.
14+
Given a commutative semiring `R`, and a type `X`, we construct the free unital, associative
15+
`R`-algebra on `X`.
1516
1617
## Notation
1718
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/-
2+
Copyright (c) 2021 Oliver Nash. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Oliver Nash
5+
-/
6+
import algebra.free
7+
import algebra.monoid_algebra
8+
9+
/-!
10+
# Free algebras
11+
12+
Given a semiring `R` and a type `X`, we construct the free non-unital, non-associative algebra on
13+
`X` with coefficients in `R`, together with its universal property. The construction is valuable
14+
because it can be used to build free algebras with more structure, e.g., free Lie algebras.
15+
16+
Note that elsewhere we have a construction of the free unital, associative algebra. This is called
17+
`free_algebra`.
18+
19+
## Main definitions
20+
21+
* `free_non_unital_non_assoc_algebra`
22+
* `free_non_unital_non_assoc_algebra.lift`
23+
* `free_non_unital_non_assoc_algebra.of`
24+
25+
## Implementation details
26+
27+
We construct the free algebra as the magma algebra, with coefficients in `R`, of the free magma on
28+
`X`. However we regard this as an implementation detail and thus deliberately omit the lemmas
29+
`of_apply` and `lift_apply`, and we mark `free_non_unital_non_assoc_algebra` and `lift` as
30+
irreducible once we have established the universal property.
31+
32+
## Tags
33+
34+
free algebra, non-unital, non-associative, free magma, magma algebra, universal property,
35+
forgetful functor, adjoint functor
36+
-/
37+
38+
universes u v w
39+
40+
noncomputable theory
41+
42+
variables (R : Type u) (X : Type v) [semiring R]
43+
44+
/-- The free non-unital, non-associative algebra on the type `X` with coefficients in `R`. -/
45+
@[derive [inhabited, non_unital_non_assoc_semiring, module R]]
46+
def free_non_unital_non_assoc_algebra := monoid_algebra R (free_magma X)
47+
48+
namespace free_non_unital_non_assoc_algebra
49+
50+
variables {X}
51+
52+
/-- The embedding of `X` into the free algebra with coefficients in `R`. -/
53+
def of : X → free_non_unital_non_assoc_algebra R X :=
54+
(monoid_algebra.of_magma R _) ∘ free_magma.of
55+
56+
instance : is_scalar_tower R
57+
(free_non_unital_non_assoc_algebra R X) (free_non_unital_non_assoc_algebra R X) :=
58+
monoid_algebra.is_scalar_tower_self R
59+
60+
/-- If the coefficients are commutative amongst themselves, they also commute with the algebra
61+
multiplication. -/
62+
instance (R : Type u) [comm_semiring R] : smul_comm_class R
63+
(free_non_unital_non_assoc_algebra R X) (free_non_unital_non_assoc_algebra R X) :=
64+
monoid_algebra.smul_comm_class_self R
65+
66+
variables {A : Type w} [non_unital_non_assoc_semiring A]
67+
variables [module R A] [is_scalar_tower R A A] [smul_comm_class R A A]
68+
69+
/-- The functor `X ↦ free_non_unital_non_assoc_algebra R X` from the category of types to the
70+
category of non-unital, non-associative algebras over `R` is adjoint to the forgetful functor in the
71+
other direction. -/
72+
def lift : (X → A) ≃ non_unital_alg_hom R (free_non_unital_non_assoc_algebra R X) A :=
73+
free_magma.lift.trans (monoid_algebra.lift_magma R)
74+
75+
@[simp] lemma lift_symm_apply (F : non_unital_alg_hom R (free_non_unital_non_assoc_algebra R X) A) :
76+
(lift R).symm F = F ∘ (of R) :=
77+
rfl
78+
79+
@[simp] lemma of_comp_lift (f : X → A) : (lift R f) ∘ (of R) = f :=
80+
(lift R).left_inv f
81+
82+
@[simp] lemma lift_unique
83+
(f : X → A) (F : non_unital_alg_hom R (free_non_unital_non_assoc_algebra R X) A) :
84+
F ∘ (of R) = f ↔ F = lift R f :=
85+
(lift R).symm_apply_eq
86+
87+
attribute [irreducible] of lift
88+
89+
@[simp] lemma lift_of_apply (f : X → A) (x) : lift R f (of R x) = f x :=
90+
by rw [← function.comp_app (lift R f) (of R) x, of_comp_lift]
91+
92+
@[simp] lemma lift_comp_of (F : non_unital_alg_hom R (free_non_unital_non_assoc_algebra R X) A) :
93+
lift R (F ∘ (of R)) = F :=
94+
by rw [← lift_symm_apply, equiv.apply_symm_apply]
95+
96+
/-- See note [partially-applied ext lemmas]. -/
97+
@[ext] lemma hom_ext {F₁ F₂ : non_unital_alg_hom R (free_non_unital_non_assoc_algebra R X) A}
98+
(h : F₁ ∘ (of R) = F₂ ∘ (of R)) : F₁ = F₂ :=
99+
begin
100+
rw [← lift_symm_apply, ← lift_symm_apply] at h,
101+
exact (lift R).symm.injective h,
102+
end
103+
104+
end free_non_unital_non_assoc_algebra

0 commit comments

Comments
 (0)