@@ -6,6 +6,7 @@ Authors: Kenny Lau
6
6
import data.equiv.basic
7
7
import control.applicative
8
8
import control.traversable.basic
9
+ import algebra.group.hom
9
10
10
11
/-!
11
12
# Free constructions
@@ -19,6 +20,7 @@ import control.traversable.basic
19
20
(i.e. nonempty lists), with traversable instance and decidable equality.
20
21
* `free_semigroup_free_magma α`: isomorphism between `magma.free_semigroup (free_magma α)` and
21
22
`free_semigroup α`.
23
+ * `free_magma.lift`: the universal property of the free magma, expressing its adjointness.
22
24
-/
23
25
24
26
universes u v l
@@ -63,30 +65,38 @@ attribute [elab_as_eliminator] rec_on' free_add_magma.rec_on'
63
65
end free_magma
64
66
65
67
/-- Lifts a function `α → β` to a magma homomorphism `free_magma α → β` given a magma `β`. -/
66
- def free_magma.lift {α : Type u} {β : Type v} [has_mul β] (f : α → β) : free_magma α → β
68
+ def free_magma.lift_aux {α : Type u} {β : Type v} [has_mul β] (f : α → β) : free_magma α → β
67
69
| (free_magma.of x) := f x
68
- | (x * y) := x.lift * y.lift
70
+ | (x * y) := x.lift_aux * y.lift_aux
69
71
70
72
/-- Lifts a function `α → β` to an additive magma homomorphism `free_add_magma α → β` given
71
73
an additive magma `β`. -/
72
- def free_add_magma.lift {α : Type u} {β : Type v} [has_add β] (f : α → β) : free_add_magma α → β
74
+ def free_add_magma.lift_aux {α : Type u} {β : Type v} [has_add β] (f : α → β) : free_add_magma α → β
73
75
| (free_add_magma.of x) := f x
74
- | (x + y) := x.lift + y.lift
76
+ | (x + y) := x.lift_aux + y.lift_aux
75
77
76
- attribute [to_additive free_add_magma.lift ] free_magma.lift
78
+ attribute [to_additive free_add_magma.lift_aux ] free_magma.lift_aux
77
79
78
80
namespace free_magma
79
81
80
82
variables {α : Type u} {β : Type v} [has_mul β] (f : α → β)
81
83
82
- @[simp, to_additive] lemma lift_of (x) : lift f (of x) = f x := rfl
83
- @[simp, to_additive] lemma lift_mul (x y) : lift f (x * y) = lift f x * lift f y := rfl
84
-
85
84
@[to_additive]
86
- theorem lift_unique (f : free_magma α → β) (hf : ∀ x y, f (x * y) = f x * f y) :
87
- f = lift (f ∘ of) :=
85
+ theorem lift_aux_unique (F : mul_hom (free_magma α) β) : ⇑F = lift_aux (F ∘ of) :=
88
86
funext $ λ x, free_magma.rec_on x (λ x, rfl) $ λ x y ih1 ih2,
89
- (hf x y).trans $ congr (congr_arg _ ih1) ih2
87
+ (F.map_mul x y).trans $ congr (congr_arg _ ih1) ih2
88
+
89
+ /-- The universal property of the free magma expressing its adjointness. -/
90
+ @[to_additive " The universal property of the free additive magma expressing its adjointness." ]
91
+ def lift : (α → β) ≃ mul_hom (free_magma α) β :=
92
+ { to_fun := λ f,
93
+ { to_fun := lift_aux f,
94
+ map_mul' := λ x y, rfl, },
95
+ inv_fun := λ F, F ∘ of,
96
+ left_inv := λ f, by { ext, simp only [lift_aux, mul_hom.coe_mk, function.comp_app], },
97
+ right_inv := λ F, by { ext, rw [mul_hom.coe_mk, lift_aux_unique], } }
98
+
99
+ @[simp, to_additive] lemma lift_of (x) : lift f (of x) = f x := rfl
90
100
91
101
end free_magma
92
102
@@ -569,12 +579,13 @@ end free_semigroup
569
579
`add_magma.free_add_semigroup (free_add_magma α)` and `free_add_semigroup α`." ]
570
580
def free_semigroup_free_magma (α : Type u) :
571
581
magma.free_semigroup (free_magma α) ≃ free_semigroup α :=
572
- { to_fun := magma.free_semigroup.lift (free_magma.lift free_semigroup.of) (free_magma.lift_mul _),
573
- inv_fun := free_semigroup.lift (magma.free_semigroup.of ∘ free_magma.of),
574
- left_inv := λ x, magma.free_semigroup.induction_on x $ λ p, by rw magma.free_semigroup.lift_of;
582
+ { to_fun :=
583
+ magma.free_semigroup.lift (free_magma.lift free_semigroup.of) (free_magma.lift _).map_mul,
584
+ inv_fun := free_semigroup.lift (magma.free_semigroup.of ∘ free_magma.of),
585
+ left_inv := λ x, magma.free_semigroup.induction_on x $ λ p, by rw magma.free_semigroup.lift_of;
575
586
exact free_magma.rec_on' p
576
587
(λ x, by rw [free_magma.lift_of, free_semigroup.lift_of])
577
- (λ x y ihx ihy, by rw [free_magma.lift_mul , free_semigroup.lift_mul, ihx, ihy,
588
+ (λ x y ihx ihy, by rw [mul_hom.map_mul , free_semigroup.lift_mul, ihx, ihy,
578
589
magma.free_semigroup.of_mul]),
579
590
right_inv := λ x, free_semigroup.rec_on x
580
591
(λ x, by rw [free_semigroup.lift_of, magma.free_semigroup.lift_of, free_magma.lift_of])
0 commit comments