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

Commit d5c58eb

Browse files
committed
chore(category_theory/*): make all forgetful functors use explicit arguments (#4139)
As suggested as #4131 (comment), for the sake of more uniform API. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent a998fd1 commit d5c58eb

File tree

9 files changed

+86
-50
lines changed

9 files changed

+86
-50
lines changed

src/algebra/homology/chain_complex.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ and it seems we can use it straightforwardly:
1919
example (C : chain_complex V) : C.X 5 ⟶ C.X 6 := C.d 5
2020
```
2121
22-
We define the forgetful functor to `ℤ`-graded objects, and show that
23-
`chain_complex V` is concrete when `V` is, and `V` has coproducts.
2422
-/
2523

2624
universes v u

src/algebraic_geometry/presheafed_space.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,16 @@ by { op_induction U, cases U, simp only [id_c], dsimp, simp, }
152152
(α ≫ β).c.app U = (β.c).app U ≫ (α.c).app (op ((opens.map (β.base)).obj (unop U))) ≫
153153
(Top.presheaf.pushforward.comp _ _ _).inv.app U := rfl
154154

155+
section
156+
variables (C)
157+
155158
/-- The forgetful functor from `PresheafedSpace` to `Top`. -/
156159
def forget : PresheafedSpace C ⥤ Top :=
157160
{ obj := λ X, (X : Top.{v}),
158161
map := λ X Y f, f.base }
159162

163+
end
164+
160165
/--
161166
The restriction of a presheafed space along an open embedding into the space.
162167
-/

src/algebraic_geometry/sheafed_space.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ by { op_induction U, cases U, simp only [id_c], dsimp, simp, }
9292
(α ≫ β).c.app U = (β.c).app U ≫ (α.c).app (op ((opens.map (β.base)).obj (unop U))) ≫
9393
(Top.presheaf.pushforward.comp _ _ _).inv.app U := rfl
9494

95+
variables (C)
96+
9597
/-- The forgetful functor from `SheafedSpace` to `Top`. -/
9698
def forget : SheafedSpace C ⥤ Top :=
9799
{ obj := λ X, (X : Top.{v}),

src/category_theory/grothendieck.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,17 @@ instance : category (grothendieck F) :=
124124
refl, },
125125
end, }
126126

127+
section
128+
variables (F)
129+
127130
/-- The forgetful functor from `grothendieck F` to the source category. -/
128131
@[simps]
129132
def forget : grothendieck F ⥤ C :=
130133
{ obj := λ X, X.1,
131134
map := λ X Y f, f.1, }
132135

136+
end
137+
133138
universe w
134139
variables (G : C ⥤ Type w)
135140

src/category_theory/limits/over.lean

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,38 @@ variable {X : C}
1818

1919
namespace category_theory.functor
2020

21-
@[simps] def to_cocone (F : J ⥤ over X) : cocone (F ⋙ over.forget) :=
21+
@[simps] def to_cocone (F : J ⥤ over X) : cocone (F ⋙ over.forget X) :=
2222
{ X := X,
2323
ι := { app := λ j, (F.obj j).hom } }
2424

25-
@[simps] def to_cone (F : J ⥤ under X) : cone (F ⋙ under.forget) :=
25+
@[simps] def to_cone (F : J ⥤ under X) : cone (F ⋙ under.forget X) :=
2626
{ X := X,
2727
π := { app := λ j, (F.obj j).hom } }
2828

2929
end category_theory.functor
3030

3131
namespace category_theory.over
3232

33-
@[simps] def colimit (F : J ⥤ over X) [has_colimit (F ⋙ forget)] : cocone F :=
34-
{ X := mk $ colimit.desc (F ⋙ forget) F.to_cocone,
33+
@[simps] def colimit (F : J ⥤ over X) [has_colimit (F ⋙ forget X)] : cocone F :=
34+
{ X := mk $ colimit.desc (F ⋙ forget X) F.to_cocone,
3535
ι :=
36-
{ app := λ j, hom_mk $ colimit.ι (F ⋙ forget) j,
36+
{ app := λ j, hom_mk $ colimit.ι (F ⋙ forget X) j,
3737
naturality' :=
3838
begin
3939
intros j j' f,
40-
have := colimit.w (F ⋙ forget) f,
40+
have := colimit.w (F ⋙ forget X) f,
4141
tidy
4242
end } }
4343

44-
def forget_colimit_is_colimit (F : J ⥤ over X) [has_colimit (F ⋙ forget)] :
45-
is_colimit (forget.map_cocone (colimit F)) :=
46-
is_colimit.of_iso_colimit (colimit.is_colimit (F ⋙ forget)) (cocones.ext (iso.refl _) (by tidy))
44+
def forget_colimit_is_colimit (F : J ⥤ over X) [has_colimit (F ⋙ forget X)] :
45+
is_colimit ((forget X).map_cocone (colimit F)) :=
46+
is_colimit.of_iso_colimit (colimit.is_colimit (F ⋙ forget X)) (cocones.ext (iso.refl _) (by tidy))
4747

48-
instance : reflects_colimits (forget : over X ⥤ C) :=
48+
instance : reflects_colimits (forget X) :=
4949
{ reflects_colimits_of_shape := λ J 𝒥,
5050
{ reflects_colimit := λ F,
5151
by constructor; exactI λ t ht,
52-
{ desc := λ s, hom_mk (ht.desc (forget.map_cocone s))
52+
{ desc := λ s, hom_mk (ht.desc ((forget X).map_cocone s))
5353
begin
5454
apply ht.hom_ext, intro j,
5555
rw [←category.assoc, ht.fac],
@@ -58,17 +58,17 @@ instance : reflects_colimits (forget : over X ⥤ C) :=
5858
exact (w (t.ι.app j)).symm,
5959
end,
6060
fac' := begin
61-
intros s j, ext, exact ht.fac (forget.map_cocone s) j
61+
intros s j, ext, exact ht.fac ((forget X).map_cocone s) j
6262
-- TODO: Ask Simon about multiple ext lemmas for defeq types (comma_morphism & over.category.hom)
6363
end,
6464
uniq' :=
6565
begin
6666
intros s m w,
6767
ext1 j,
68-
exact ht.uniq (forget.map_cocone s) m.left (λ j, congr_arg comma_morphism.left (w j))
68+
exact ht.uniq ((forget X).map_cocone s) m.left (λ j, congr_arg comma_morphism.left (w j))
6969
end } } }
7070

71-
instance has_colimit {F : J ⥤ over X} [has_colimit (F ⋙ forget)] : has_colimit F :=
71+
instance has_colimit {F : J ⥤ over X} [has_colimit (F ⋙ forget X)] : has_colimit F :=
7272
has_colimit.mk { cocone := colimit F,
7373
is_colimit := reflects_colimit.reflects (forget_colimit_is_colimit F) }
7474

@@ -79,43 +79,43 @@ instance has_colimits_of_shape [has_colimits_of_shape J C] :
7979
instance has_colimits [has_colimits C] : has_colimits (over X) :=
8080
{ has_colimits_of_shape := λ J 𝒥, by resetI; apply_instance }
8181

82-
instance forget_preserves_colimit {X : C} {F : J ⥤ over X} [has_colimit (F ⋙ forget)] :
83-
preserves_colimit F (forget : over X ⥤ C) :=
82+
instance forget_preserves_colimit {X : C} {F : J ⥤ over X} [has_colimit (F ⋙ forget X)] :
83+
preserves_colimit F (forget X) :=
8484
preserves_colimit_of_preserves_colimit_cocone
8585
(reflects_colimit.reflects (forget_colimit_is_colimit F)) (forget_colimit_is_colimit F)
8686

8787
instance forget_preserves_colimits_of_shape [has_colimits_of_shape J C] {X : C} :
88-
preserves_colimits_of_shape J (forget : over X ⥤ C) :=
88+
preserves_colimits_of_shape J (forget X) :=
8989
{ preserves_colimit := λ F, by apply_instance }
9090

9191
instance forget_preserves_colimits [has_colimits C] {X : C} :
92-
preserves_colimits (forget : over X ⥤ C) :=
92+
preserves_colimits (forget X) :=
9393
{ preserves_colimits_of_shape := λ J 𝒥, by apply_instance }
9494

9595
end category_theory.over
9696

9797
namespace category_theory.under
9898

99-
@[simps] def limit (F : J ⥤ under X) [has_limit (F ⋙ forget)] : cone F :=
100-
{ X := mk $ limit.lift (F ⋙ forget) F.to_cone,
99+
@[simps] def limit (F : J ⥤ under X) [has_limit (F ⋙ forget X)] : cone F :=
100+
{ X := mk $ limit.lift (F ⋙ forget X) F.to_cone,
101101
π :=
102-
{ app := λ j, hom_mk $ limit.π (F ⋙ forget) j,
102+
{ app := λ j, hom_mk $ limit.π (F ⋙ forget X) j,
103103
naturality' :=
104104
begin
105105
intros j j' f,
106-
have := (limit.w (F ⋙ forget) f).symm,
106+
have := (limit.w (F ⋙ forget X) f).symm,
107107
tidy
108108
end } }
109109

110-
def forget_limit_is_limit (F : J ⥤ under X) [has_limit (F ⋙ forget)] :
111-
is_limit (forget.map_cone (limit F)) :=
112-
is_limit.of_iso_limit (limit.is_limit (F ⋙ forget)) (cones.ext (iso.refl _) (by tidy))
110+
def forget_limit_is_limit (F : J ⥤ under X) [has_limit (F ⋙ forget X)] :
111+
is_limit ((forget X).map_cone (limit F)) :=
112+
is_limit.of_iso_limit (limit.is_limit (F ⋙ forget X)) (cones.ext (iso.refl _) (by tidy))
113113

114-
instance : reflects_limits (forget : under X ⥤ C) :=
114+
instance : reflects_limits (forget X) :=
115115
{ reflects_limits_of_shape := λ J 𝒥,
116116
{ reflects_limit := λ F,
117117
by constructor; exactI λ t ht,
118-
{ lift := λ s, hom_mk (ht.lift (forget.map_cone s))
118+
{ lift := λ s, hom_mk (ht.lift ((forget X).map_cone s))
119119
begin
120120
apply ht.hom_ext, intro j,
121121
rw [category.assoc, ht.fac],
@@ -124,16 +124,16 @@ instance : reflects_limits (forget : under X ⥤ C) :=
124124
exact (w (t.π.app j)).symm,
125125
end,
126126
fac' := begin
127-
intros s j, ext, exact ht.fac (forget.map_cone s) j
127+
intros s j, ext, exact ht.fac ((forget X).map_cone s) j
128128
end,
129129
uniq' :=
130130
begin
131131
intros s m w,
132132
ext1 j,
133-
exact ht.uniq (forget.map_cone s) m.right (λ j, congr_arg comma_morphism.right (w j))
133+
exact ht.uniq ((forget X).map_cone s) m.right (λ j, congr_arg comma_morphism.right (w j))
134134
end } } }
135135

136-
instance has_limit {F : J ⥤ under X} [has_limit (F ⋙ forget)] : has_limit F :=
136+
instance has_limit {F : J ⥤ under X} [has_limit (F ⋙ forget X)] : has_limit F :=
137137
has_limit.mk { cone := limit F,
138138
is_limit := reflects_limit.reflects (forget_limit_is_limit F) }
139139

@@ -145,7 +145,7 @@ instance has_limits [has_limits C] : has_limits (under X) :=
145145
{ has_limits_of_shape := λ J 𝒥, by resetI; apply_instance }
146146

147147
instance forget_preserves_limits [has_limits C] {X : C} :
148-
preserves_limits (forget : under X ⥤ C) :=
148+
preserves_limits (forget X) :=
149149
{ preserves_limits_of_shape := λ J 𝒥,
150150
{ preserves_limit := λ F, by exactI
151151
preserves_limit_of_preserves_limit_cone

src/category_theory/limits/shapes/constructions/over/connected.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace creates_connected
2929
diagram legs to the specific object.
3030
-/
3131
def nat_trans_in_over {B : C} (F : J ⥤ over B) :
32-
F ⋙ forget ⟶ (category_theory.functor.const J).obj B :=
32+
F ⋙ forget B ⟶ (category_theory.functor.const J).obj B :=
3333
{ app := λ j, (F.obj j).hom }
3434

3535
local attribute [tidy] tactic.case_bash
@@ -39,27 +39,27 @@ local attribute [tidy] tactic.case_bash
3939
where the connected assumption is used.
4040
-/
4141
@[simps]
42-
def raise_cone [connected J] {B : C} {F : J ⥤ over B} (c : cone (F ⋙ forget)) :
42+
def raise_cone [connected J] {B : C} {F : J ⥤ over B} (c : cone (F ⋙ forget B)) :
4343
cone F :=
4444
{ X := over.mk (c.π.app (default J) ≫ (F.obj (default J)).hom),
4545
π :=
4646
{ app := λ j, over.hom_mk (c.π.app j) (nat_trans_from_connected (c.π ≫ nat_trans_in_over F) j) } }
4747

4848
lemma raised_cone_lowers_to_original [connected J] {B : C} {F : J ⥤ over B}
49-
(c : cone (F ⋙ forget)) (t : is_limit c) :
50-
forget.map_cone (raise_cone c) = c :=
49+
(c : cone (F ⋙ forget B)) (t : is_limit c) :
50+
(forget B).map_cone (raise_cone c) = c :=
5151
by tidy
5252

5353
/-- (Impl) Show that the raised cone is a limit. -/
54-
def raised_cone_is_limit [connected J] {B : C} {F : J ⥤ over B} {c : cone (F ⋙ forget)} (t : is_limit c) :
54+
def raised_cone_is_limit [connected J] {B : C} {F : J ⥤ over B} {c : cone (F ⋙ forget B)} (t : is_limit c) :
5555
is_limit (raise_cone c) :=
56-
{ lift := λ s, over.hom_mk (t.lift (forget.map_cone s)) (by { dsimp, simp }),
56+
{ lift := λ s, over.hom_mk (t.lift ((forget B).map_cone s)) (by { dsimp, simp }),
5757
uniq' := λ s m K, by { ext1, apply t.hom_ext, intro j, simp [← K j] } }
5858

5959
end creates_connected
6060

6161
/-- The forgetful functor from the over category creates any connected limit. -/
62-
instance forget_creates_connected_limits [connected J] {B : C} : creates_limits_of_shape J (forget : over B ⥤ C) :=
62+
instance forget_creates_connected_limits [connected J] {B : C} : creates_limits_of_shape J (forget B) :=
6363
{ creates_limit := λ K,
6464
creates_limit_of_reflects_iso (λ c t,
6565
{ lifted_cone := creates_connected.raise_cone c,
@@ -68,6 +68,6 @@ instance forget_creates_connected_limits [connected J] {B : C} : creates_limits_
6868

6969
/-- The over category has any connected limit which the original category has. -/
7070
instance has_connected_limits {B : C} [connected J] [has_limits_of_shape J C] : has_limits_of_shape J (over B) :=
71-
{ has_limit := λ F, has_limit_of_created F (forget : over B ⥤ C) }
71+
{ has_limit := λ F, has_limit_of_created F (forget B) }
7272

7373
end category_theory.over

src/category_theory/monad/bundled.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@ instance : category (Monad C) :=
5757
id := λ _, monad_hom.id _,
5858
comp := λ _ _ _, monad_hom.comp }
5959

60+
section
61+
variables (C)
62+
6063
/-- The forgetful functor from `Monad C` to `C ⥤ C`. -/
6164
def forget : Monad C ⥤ (C ⥤ C) :=
6265
{ obj := func,
6366
map := λ _ _ f, f.to_nat_trans }
6467

68+
end
69+
6570
@[simp]
6671
lemma comp_to_nat_trans {M N L : Monad C} (f : M ⟶ N) (g : N ⟶ L) :
6772
(f ≫ g).to_nat_trans = nat_trans.vcomp f.to_nat_trans g.to_nat_trans := rfl
@@ -95,11 +100,16 @@ instance : category (Comonad C) :=
95100
id := λ _, comonad_hom.id _,
96101
comp := λ _ _ _, comonad_hom.comp }
97102

103+
section
104+
variables (C)
105+
98106
/-- The forgetful functor from `CoMonad C` to `C ⥤ C`. -/
99107
def forget : Comonad C ⥤ (C ⥤ C) :=
100108
{ obj := func,
101109
map := λ _ _ f, f.to_nat_trans }
102110

111+
end
112+
103113
@[simp]
104114
lemma comp_to_nat_trans {M N L : Comonad C} (f : M ⟶ N) (g : N ⟶ L) :
105115
(f ≫ g).to_nat_trans = nat_trans.vcomp f.to_nat_trans g.to_nat_trans := rfl

src/category_theory/monoidal/internal.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,16 @@ instance : category (Mon_ C) :=
9999
@[simp] lemma comp_hom' {M N K : Mon_ C} (f : M ⟶ N) (g : N ⟶ K) :
100100
(f ≫ g : hom M K).hom = f.hom ≫ g.hom := rfl
101101

102+
section
102103
variables (C)
103104

104105
/-- The forgetful functor from monoid objects to the ambient category. -/
105106
def forget : Mon_ C ⥤ C :=
106107
{ obj := λ A, A.X,
107108
map := λ A B f, f.hom, }
108109

110+
end
111+
109112
instance {A B : Mon_ C} (f : A ⟶ B) [e : is_iso ((forget C).map f)] : is_iso f.hom := e
110113

111114
/-- The forgetful functor from monoid objects to the ambient category reflects isomorphisms. -/
@@ -258,6 +261,11 @@ def regular : Mod A :=
258261

259262
instance : inhabited (Mod A) := ⟨regular A⟩
260263

264+
/-- The forgetful functor from module objects to the ambient category. -/
265+
def forget : Mod A ⥤ C :=
266+
{ obj := λ A, A.X,
267+
map := λ A B f, f.hom, }
268+
261269
open category_theory.monoidal_category
262270

263271
/--

src/category_theory/over.lean

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,19 @@ direction gives a commutative triangle.
8989
def iso_mk {f g : over X} (hl : f.left ≅ g.left) (hw : hl.hom ≫ g.hom = f.hom . obviously) : f ≅ g :=
9090
comma.iso_mk hl (eq_to_iso (subsingleton.elim _ _)) (by simp [hw])
9191

92+
section
93+
variable (X)
9294
/--
9395
The forgetful functor mapping an arrow to its domain.
9496
9597
See https://stacks.math.columbia.edu/tag/001G.
9698
-/
9799
def forget : over X ⥤ T := comma.fst _ _
98100

99-
@[simp] lemma forget_obj {U : over X} : forget.obj U = U.left := rfl
100-
@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : forget.map f = f.left := rfl
101+
end
102+
103+
@[simp] lemma forget_obj {U : over X} : (forget X).obj U = U.left := rfl
104+
@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : (forget X).map f = f.left := rfl
101105

102106
/--
103107
A morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way.
@@ -122,9 +126,9 @@ nat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)
122126

123127
end
124128

125-
instance forget_reflects_iso : reflects_isomorphisms (forget : over X ⥤ T) :=
126-
{ reflects := λ X Y f t, by exactI
127-
{ inv := over.hom_mk t.inv ((as_iso (forget.map f)).inv_comp_eq.2 (over.w f).symm) } }
129+
instance forget_reflects_iso : reflects_isomorphisms (forget X) :=
130+
{ reflects := λ Y Z f t, by exactI
131+
{ inv := over.hom_mk t.inv ((as_iso ((forget X).map f)).inv_comp_eq.2 (over.w f).symm) } }
128132

129133
section iterated_slice
130134
variables (f : over X)
@@ -156,11 +160,11 @@ def iterated_slice_equiv : over f ≌ over f.left :=
156160
(λ X Y g, by { ext, dsimp, simp }) }
157161

158162
lemma iterated_slice_forward_forget :
159-
iterated_slice_forward f ⋙ forget = forget ⋙ forget :=
163+
iterated_slice_forward f ⋙ forget f.left = forget f ⋙ forget X :=
160164
rfl
161165

162166
lemma iterated_slice_backward_forget_forget :
163-
iterated_slice_backward f ⋙ forget ⋙ forget = forget :=
167+
iterated_slice_backward f ⋙ forget f ⋙ forget X = forget f.left :=
164168
rfl
165169

166170
end iterated_slice
@@ -235,11 +239,15 @@ lemma iso_mk_hom_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom
235239
lemma iso_mk_inv_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :
236240
(iso_mk hr hw).inv.right = hr.inv := rfl
237241

242+
section
243+
variables (X)
238244
/-- The forgetful functor mapping an arrow to its domain. -/
239245
def forget : under X ⥤ T := comma.snd _ _
240246

241-
@[simp] lemma forget_obj {U : under X} : forget.obj U = U.right := rfl
242-
@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : forget.map f = f.right := rfl
247+
end
248+
249+
@[simp] lemma forget_obj {U : under X} : (forget X).obj U = U.right := rfl
250+
@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : (forget X).map f = f.right := rfl
243251

244252
/-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/
245253
def map {Y : T} (f : X ⟶ Y) : under Y ⥤ under X := comma.map_left _ $ discrete.nat_trans (λ _, f)

0 commit comments

Comments
 (0)