Skip to content

Commit d07fa9a

Browse files
Jlh18joelriou
andcommitted
feat: free groupoid on a category, free-forgetful adjunction (#29279)
- define `CategoryTheory.FreeGroupoid` - show the universal property of this construction, as the initial category localizing all maps in the category. These are the defs `of`, `lift`, and their related theorems - Show that this construction is functorial `CategoryTheory.FreeGroupoid.map` - Convert this to a functor `CategoryTheory.Grpd.free` from `Cat` to `Grpd`, and show that it is left adjoint to the forgetful functor - `CategoryTheory.Grpd.freeForgetAdjunction` Co-authored-by: jlh18 <josephhua73@yahoo.com> Co-authored-by: Joël Riou <37772949+joelriou@users.noreply.github.com>
1 parent 9b5ec45 commit d07fa9a

File tree

9 files changed

+393
-21
lines changed

9 files changed

+393
-21
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,7 @@ import Mathlib.CategoryTheory.Groupoid
23982398
import Mathlib.CategoryTheory.Groupoid.Basic
23992399
import Mathlib.CategoryTheory.Groupoid.Discrete
24002400
import Mathlib.CategoryTheory.Groupoid.FreeGroupoid
2401+
import Mathlib.CategoryTheory.Groupoid.FreeGroupoidOfCategory
24012402
import Mathlib.CategoryTheory.Groupoid.Subgroupoid
24022403
import Mathlib.CategoryTheory.Groupoid.VertexGroup
24032404
import Mathlib.CategoryTheory.GuitartExact.Basic

Mathlib/CategoryTheory/Category/Grpd.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def forgetToCat : Grpd.{v, u} ⥤ Cat.{v, u} where
7474
obj C := Cat.of C
7575
map := id
7676

77+
instance (X : Grpd) : Groupoid (Grpd.forgetToCat.obj X) := inferInstanceAs (Groupoid X)
78+
7779
instance forgetToCat_full : forgetToCat.Full where map_surjective f := ⟨f, rfl⟩
7880

7981
instance forgetToCat_faithful : forgetToCat.Faithful where

Mathlib/CategoryTheory/Functor/Basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ theorem map_dite (F : C ⥤ D) {X Y : C} {P : Prop} [Decidable P]
137137
theorem toPrefunctor_comp (F : C ⥤ D) (G : D ⥤ E) :
138138
F.toPrefunctor.comp G.toPrefunctor = (F ⋙ G).toPrefunctor := rfl
139139

140+
lemma toPrefunctor_injective {F G : C ⥤ D} (h : F.toPrefunctor = G.toPrefunctor) :
141+
F = G := by
142+
obtain ⟨obj, map, _, _⟩ := F
143+
obtain ⟨obj', map', _, _⟩ := G
144+
obtain rfl : obj = obj' := congr_arg Prefunctor.obj h
145+
obtain rfl : @map = @map' := by simpa [Functor.toPrefunctor] using h
146+
rfl
147+
140148
end
141149

142150
end Functor

Mathlib/CategoryTheory/Groupoid.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Mathlib.CategoryTheory.Pi.Basic
99
import Mathlib.CategoryTheory.Category.Basic
1010
import Mathlib.Combinatorics.Quiver.Symmetric
1111
import Mathlib.CategoryTheory.Functor.ReflectsIso.Basic
12+
import Mathlib.CategoryTheory.MorphismProperty.Basic
1213

1314
/-!
1415
# Groupoids
@@ -186,4 +187,15 @@ instance isGroupoidProd {α : Type u} {β : Type u₂} [Category.{v} α] [Catego
186187

187188
end
188189

190+
open MorphismProperty in
191+
lemma isGroupoid_iff_isomorphisms_eq_top (C : Type*) [Category C] :
192+
IsGroupoid C ↔ isomorphisms C = ⊤ := by
193+
constructor
194+
· rw [eq_top_iff]
195+
intro _ _
196+
simp only [isomorphisms.iff, top_apply]
197+
infer_instance
198+
· intro h
199+
exact ⟨of_eq_top h⟩
200+
189201
end CategoryTheory

Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ extension as a functor from the free groupoid, and proves uniqueness of this ext
1616
1717
Given the type `V` and a quiver instance on `V`:
1818
19-
- `FreeGroupoid V`: a type synonym for `V`.
20-
- `FreeGroupoid.instGroupoid`: the `Groupoid` instance on `FreeGroupoid V`.
19+
- `Quiver.FreeGroupoid V`: a type synonym for `V`.
20+
- `Quiver.FreeGroupoid.instGroupoid`: the `Groupoid` instance on `Quiver.FreeGroupoid V`.
2121
- `lift`: the lifting of a prefunctor from `V` to `V'` where `V'` is a groupoid, to a functor.
22-
`FreeGroupoid V ⥤ V'`.
22+
`Quiver.FreeGroupoid V ⥤ V'`.
2323
- `lift_spec` and `lift_unique`: the proofs that, respectively, `lift` indeed is a lifting
2424
and is the unique one.
2525
@@ -56,16 +56,14 @@ inductive FreeGroupoid.redStep : HomRel (Paths (Quiver.Symmetrify V))
5656
redStep (𝟙 ((Paths.of (Quiver.Symmetrify V)).obj X)) (f.toPath ≫ (Quiver.reverse f).toPath)
5757

5858
/-- The underlying vertices of the free groupoid -/
59-
def FreeGroupoid (V) [Q : Quiver V] :=
59+
protected def FreeGroupoid (V) [Q : Quiver V] :=
6060
CategoryTheory.Quotient (@FreeGroupoid.redStep V Q)
6161

62-
@[deprecated (since := "2025-10-02")] alias _root_.CategoryTheory.FreeGroupoid := FreeGroupoid
63-
6462
namespace FreeGroupoid
6563

6664
open Quiver
6765

68-
instance {V} [Quiver V] [Nonempty V] : Nonempty (FreeGroupoid V) := by
66+
instance {V} [Quiver V] [Nonempty V] : Nonempty (Quiver.FreeGroupoid V) := by
6967
inhabit V; exact ⟨⟨@default V _⟩⟩
7068

7169
theorem congr_reverse {X Y : Paths <| Quiver.Symmetrify V} (p q : X ⟶ Y) :
@@ -113,21 +111,21 @@ theorem congr_reverse_comp {X Y : Paths <| Quiver.Symmetrify V} (p : X ⟶ Y) :
113111
nth_rw 2 [← Quiver.Path.reverse_reverse p]
114112
apply congr_comp_reverse
115113

116-
instance : Category (FreeGroupoid V) :=
114+
instance : Category (Quiver.FreeGroupoid V) :=
117115
Quotient.category redStep
118116

119117
/-- The inverse of an arrow in the free groupoid -/
120-
def quotInv {X Y : FreeGroupoid V} (f : X ⟶ Y) : Y ⟶ X :=
118+
def quotInv {X Y : Quiver.FreeGroupoid V} (f : X ⟶ Y) : Y ⟶ X :=
121119
Quot.liftOn f (fun pp => Quot.mk _ <| pp.reverse) fun pp qq con =>
122120
Quot.sound <| congr_reverse pp qq con
123121

124-
instance instGroupoid : Groupoid (FreeGroupoid V) where
122+
instance instGroupoid : Groupoid (Quiver.FreeGroupoid V) where
125123
inv := quotInv
126124
inv_comp p := Quot.inductionOn p fun pp => congr_reverse_comp pp
127125
comp_inv p := Quot.inductionOn p fun pp => congr_comp_reverse pp
128126

129127
/-- The inclusion of the quiver on `V` to the underlying quiver on `FreeGroupoid V` -/
130-
def of (V) [Quiver V] : V ⥤q FreeGroupoid V where
128+
def of (V) [Quiver V] : V ⥤q Quiver.FreeGroupoid V where
131129
obj X := ⟨X⟩
132130
map f := Quot.mk _ f.toPosPath
133131

@@ -140,7 +138,7 @@ section UniversalProperty
140138
variable {V' : Type u'} [Groupoid V']
141139

142140
/-- The lift of a prefunctor to a groupoid, to a functor from `FreeGroupoid V` -/
143-
def lift (φ : V ⥤q V') : FreeGroupoid V ⥤ V' :=
141+
def lift (φ : V ⥤q V') : Quiver.FreeGroupoid V ⥤ V' :=
144142
CategoryTheory.Quotient.lift _ (Paths.lift <| Quiver.Symmetrify.lift φ) <| by
145143
rintro _ _ _ _ ⟨X, Y, f⟩
146144
-- Porting note: `simp` does not work, so manually `rewrite`
@@ -154,8 +152,8 @@ theorem lift_spec (φ : V ⥤q V') : of V ⋙q (lift φ).toPrefunctor = φ := by
154152
dsimp [lift]
155153
rw [Quotient.lift_spec, Paths.lift_spec, Quiver.Symmetrify.lift_spec]
156154

157-
theorem lift_unique (φ : V ⥤q V') (Φ : FreeGroupoid V ⥤ V') (hΦ : of V ⋙q Φ.toPrefunctor = φ) :
158-
Φ = lift φ := by
155+
theorem lift_unique (φ : V ⥤q V') (Φ : Quiver.FreeGroupoid V ⥤ V')
156+
(hΦ : of V ⋙q Φ.toPrefunctor = φ) : Φ = lift φ := by
159157
apply Quotient.lift_unique
160158
apply Paths.lift_unique
161159
fapply @Quiver.Symmetrify.lift_unique _ _ _ _ _ _ _ _ _
@@ -179,11 +177,11 @@ open FreeGroupoid
179177
variable {V' : Type u'} [Quiver.{v' + 1} V'] {V'' : Type u''} [Quiver.{v'' + 1} V'']
180178

181179
/-- The functor of free groupoid induced by a prefunctor of quivers -/
182-
def freeGroupoidFunctor (φ : V ⥤q V') : FreeGroupoid V ⥤ FreeGroupoid V' :=
180+
def freeGroupoidFunctor (φ : V ⥤q V') : Quiver.FreeGroupoid V ⥤ Quiver.FreeGroupoid V' :=
183181
lift (φ ⋙q of V')
184182

185183
theorem freeGroupoidFunctor_id :
186-
freeGroupoidFunctor (Prefunctor.id V) = Functor.id (FreeGroupoid V) := by
184+
freeGroupoidFunctor (Prefunctor.id V) = Functor.id (Quiver.FreeGroupoid V) := by
187185
dsimp only [freeGroupoidFunctor]; symm
188186
apply lift_unique; rfl
189187

0 commit comments

Comments
 (0)