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

Commit a0846da

Browse files
committed
chore(category_theory/limits/over): split a slow file (#3399)
This was previously the last file to finish compiling when compiling `category_theory/`. This PR splits it into some smaller pieces which can compile in parallel (and some pieces now come earlier in the import hierarchy). No change to content. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent 0fff477 commit a0846da

File tree

6 files changed

+271
-218
lines changed

6 files changed

+271
-218
lines changed

src/category_theory/connected.lean

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Bhavik Mehta
55
-/
66
import data.list.chain
7-
import category_theory.const
8-
import category_theory.discrete_category
9-
import category_theory.eq_to_hom
107
import category_theory.punit
118

129
/-!

src/category_theory/limits/connected.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Bhavik Mehta
55
-/
66
import category_theory.limits.shapes.pullbacks
7-
import category_theory.limits.shapes.wide_pullbacks
8-
import category_theory.limits.shapes.binary_products
97
import category_theory.limits.shapes.equalizers
108
import category_theory.limits.preserves
119
import category_theory.connected

src/category_theory/limits/over.lean

Lines changed: 1 addition & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johan Commelin, Reid Barton, Bhavik Mehta
55
-/
66
import category_theory.over
7-
import category_theory.pempty
8-
import category_theory.limits.connected
9-
import category_theory.limits.creates
10-
import category_theory.limits.shapes.constructions.limits_of_products_and_equalizers
11-
import category_theory.limits.shapes.constructions.equalizers
7+
import category_theory.limits.preserves
128

139
universes v u -- declare the `v`'s first; see `category_theory.category` for an explanation
1410

@@ -93,214 +89,6 @@ instance forget_preserves_colimits [has_colimits C] {X : C} :
9389
preserves_colimits (forget : over X ⥤ C) :=
9490
{ preserves_colimits_of_shape := λ J 𝒥, by apply_instance }
9591

96-
namespace construct_products
97-
98-
/-- (Impl) Given a product shape in `C/B`, construct the corresponding wide pullback diagram in `C`. -/
99-
@[reducible]
100-
def wide_pullback_diagram_of_diagram_over (B : C) {J : Type v} (F : discrete J ⥤ over B) : wide_pullback_shape J ⥤ C :=
101-
wide_pullback_shape.wide_cospan B (λ j, (F.obj j).left) (λ j, (F.obj j).hom)
102-
103-
/-- (Impl) A preliminary definition to avoid timeouts. -/
104-
@[simps]
105-
def cones_equiv_inverse_obj (B : C) {J : Type v} (F : discrete J ⥤ over B) (c : cone F) :
106-
cone (wide_pullback_diagram_of_diagram_over B F) :=
107-
{ X := c.X.left,
108-
π :=
109-
{ app := λ X, option.cases_on X c.X.hom (λ (j : J), (c.π.app j).left),
110-
-- `tidy` can do this using `case_bash`, but let's try to be a good `-T50000` citizen:
111-
naturality' := λ X Y f,
112-
begin
113-
dsimp, cases X; cases Y; cases f,
114-
{ rw [category.id_comp, category.comp_id], },
115-
{ rw [over.w, category.id_comp], },
116-
{ rw [category.id_comp, category.comp_id], },
117-
end } }
118-
119-
/-- (Impl) A preliminary definition to avoid timeouts. -/
120-
@[simps]
121-
def cones_equiv_inverse (B : C) {J : Type v} (F : discrete J ⥤ over B) :
122-
cone F ⥤ cone (wide_pullback_diagram_of_diagram_over B F) :=
123-
{ obj := cones_equiv_inverse_obj B F,
124-
map := λ c₁ c₂ f,
125-
{ hom := f.hom.left,
126-
w' := λ j,
127-
begin
128-
cases j,
129-
{ simp },
130-
{ dsimp,
131-
rw ← f.w j,
132-
refl }
133-
end } }
134-
135-
/-- (Impl) A preliminary definition to avoid timeouts. -/
136-
@[simps]
137-
def cones_equiv_functor (B : C) {J : Type v} (F : discrete J ⥤ over B) :
138-
cone (wide_pullback_diagram_of_diagram_over B F) ⥤ cone F :=
139-
{ obj := λ c,
140-
{ X := over.mk (c.π.app none),
141-
π := { app := λ j, over.hom_mk (c.π.app (some j)) (by apply c.w (wide_pullback_shape.hom.term j)) } },
142-
map := λ c₁ c₂ f,
143-
{ hom := over.hom_mk f.hom } }
144-
145-
local attribute [tidy] tactic.case_bash
146-
147-
/-- (Impl) A preliminary definition to avoid timeouts. -/
148-
@[simp]
149-
def cones_equiv_unit_iso (B : C) {J : Type v} (F : discrete J ⥤ over B) :
150-
𝟭 (cone (wide_pullback_diagram_of_diagram_over B F)) ≅
151-
cones_equiv_functor B F ⋙ cones_equiv_inverse B F :=
152-
nat_iso.of_components (λ _, cones.ext {hom := 𝟙 _, inv := 𝟙 _} (by tidy)) (by tidy)
153-
154-
/-- (Impl) A preliminary definition to avoid timeouts. -/
155-
@[simp]
156-
def cones_equiv_counit_iso (B : C) {J : Type v} (F : discrete J ⥤ over B) :
157-
cones_equiv_inverse B F ⋙ cones_equiv_functor B F ≅ 𝟭 (cone F) :=
158-
nat_iso.of_components
159-
(λ _, cones.ext {hom := over.hom_mk (𝟙 _), inv := over.hom_mk (𝟙 _)} (by tidy)) (by tidy)
160-
161-
-- TODO: Can we add `. obviously` to the second arguments of `nat_iso.of_components` and `cones.ext`?
162-
/-- (Impl) Establish an equivalence between the category of cones for `F` and for the "grown" `F`. -/
163-
@[simps]
164-
def cones_equiv (B : C) {J : Type v} (F : discrete J ⥤ over B) :
165-
cone (wide_pullback_diagram_of_diagram_over B F) ≌ cone F :=
166-
{ functor := cones_equiv_functor B F,
167-
inverse := cones_equiv_inverse B F,
168-
unit_iso := cones_equiv_unit_iso B F,
169-
counit_iso := cones_equiv_counit_iso B F, }
170-
171-
/-- Use the above equivalence to prove we have a limit. -/
172-
def has_over_limit_discrete_of_wide_pullback_limit {B : C} {J : Type v} (F : discrete J ⥤ over B)
173-
[has_limit (wide_pullback_diagram_of_diagram_over B F)] :
174-
has_limit F :=
175-
{ cone := _,
176-
is_limit := is_limit.of_cone_equiv
177-
(cones_equiv B F).functor (limit.is_limit (wide_pullback_diagram_of_diagram_over B F)) }
178-
179-
/-- Given a wide pullback in `C`, construct a product in `C/B`. -/
180-
def over_product_of_wide_pullback {J : Type v} [has_limits_of_shape (wide_pullback_shape J) C] {B : C} :
181-
has_limits_of_shape (discrete J) (over B) :=
182-
{ has_limit := λ F, has_over_limit_discrete_of_wide_pullback_limit F }
183-
184-
/-- Given a pullback in `C`, construct a binary product in `C/B`. -/
185-
def over_binary_product_of_pullback [has_pullbacks C] {B : C} :
186-
has_binary_products (over B) :=
187-
{ has_limits_of_shape := over_product_of_wide_pullback }
188-
189-
/-- Given all wide pullbacks in `C`, construct products in `C/B`. -/
190-
def over_products_of_wide_pullbacks [has_wide_pullbacks C] {B : C} :
191-
has_products (over B) :=
192-
{ has_limits_of_shape := λ J, over_product_of_wide_pullback }
193-
194-
/-- Given all finite wide pullbacks in `C`, construct finite products in `C/B`. -/
195-
def over_finite_products_of_finite_wide_pullbacks [has_finite_wide_pullbacks C] {B : C} :
196-
has_finite_products (over B) :=
197-
{ has_limits_of_shape := λ J 𝒥₁ 𝒥₂, by exactI over_product_of_wide_pullback }
198-
199-
end construct_products
200-
201-
/--
202-
Construct terminal object in the over category. This isn't an instance as it's not typically the
203-
way we want to define terminal objects.
204-
(For instance, this gives a terminal object which is different from the generic one given by
205-
`over_product_of_wide_pullback` above.)
206-
-/
207-
def over_has_terminal (B : C) : has_terminal (over B) :=
208-
{ has_limits_of_shape :=
209-
{ has_limit := λ F,
210-
{ cone :=
211-
{ X := over.mk (𝟙 _),
212-
π := { app := λ p, pempty.elim p } },
213-
is_limit :=
214-
{ lift := λ s, over.hom_mk _,
215-
fac' := λ _ j, j.elim,
216-
uniq' := λ s m _,
217-
begin
218-
ext,
219-
rw over.hom_mk_left,
220-
have := m.w,
221-
dsimp at this,
222-
rwa [category.comp_id, category.comp_id] at this
223-
end } } } }
224-
225-
namespace creates_connected
226-
227-
/--
228-
(Impl) Given a diagram in the over category, produce a natural transformation from the
229-
diagram legs to the specific object.
230-
-/
231-
def nat_trans_in_over {B : C} (F : J ⥤ over B) :
232-
F ⋙ forget ⟶ (category_theory.functor.const J).obj B :=
233-
{ app := λ j, (F.obj j).hom }
234-
235-
local attribute [tidy] tactic.case_bash
236-
237-
/--
238-
(Impl) Given a cone in the base category, raise it to a cone in the over category. Note this is
239-
where the connected assumption is used.
240-
-/
241-
@[simps]
242-
def raise_cone [connected J] {B : C} {F : J ⥤ over B} (c : cone (F ⋙ forget)) :
243-
cone F :=
244-
{ X := over.mk (c.π.app (default J) ≫ (F.obj (default J)).hom),
245-
π :=
246-
{ app := λ j, over.hom_mk (c.π.app j) (nat_trans_from_connected (c.π ≫ nat_trans_in_over F) j) } }
247-
248-
lemma raised_cone_lowers_to_original [connected J] {B : C} {F : J ⥤ over B}
249-
(c : cone (F ⋙ forget)) (t : is_limit c) :
250-
forget.map_cone (raise_cone c) = c :=
251-
by tidy
252-
253-
/-- (Impl) Show that the raised cone is a limit. -/
254-
def raised_cone_is_limit [connected J] {B : C} {F : J ⥤ over B} {c : cone (F ⋙ forget)} (t : is_limit c) :
255-
is_limit (raise_cone c) :=
256-
{ lift := λ s, over.hom_mk (t.lift (forget.map_cone s))
257-
(by { dsimp, simp }),
258-
uniq' := λ s m K, by { ext1, apply t.hom_ext, intro j, simp [← K j] } }
259-
260-
end creates_connected
261-
262-
/-- The forgetful functor from the over category creates any connected limit. -/
263-
instance forget_creates_connected_limits [connected J] {B : C} : creates_limits_of_shape J (forget : over B ⥤ C) :=
264-
{ creates_limit := λ K,
265-
creates_limit_of_reflects_iso (λ c t,
266-
{ lifted_cone := creates_connected.raise_cone c,
267-
valid_lift := eq_to_iso (creates_connected.raised_cone_lowers_to_original c t),
268-
makes_limit := creates_connected.raised_cone_is_limit t } ) }
269-
270-
/-- The over category has any connected limit which the original category has. -/
271-
instance has_connected_limits {B : C} [connected J] [has_limits_of_shape J C] : has_limits_of_shape J (over B) :=
272-
{ has_limit := λ F, has_limit_of_created F (forget : over B ⥤ C) }
273-
274-
/-- Make sure we can derive pullbacks in `over B`. -/
275-
example {B : C} [has_pullbacks C] : has_pullbacks (over B) :=
276-
{ has_limits_of_shape := infer_instance }
277-
278-
/-- Make sure we can derive equalizers in `over B`. -/
279-
example {B : C} [has_equalizers C] : has_equalizers (over B) :=
280-
{ has_limits_of_shape := infer_instance }
281-
282-
instance has_finite_limits {B : C} [has_finite_wide_pullbacks C] : has_finite_limits (over B) :=
283-
begin
284-
apply @finite_limits_from_equalizers_and_finite_products _ _ _ _,
285-
{ exact construct_products.over_finite_products_of_finite_wide_pullbacks },
286-
{ apply @has_equalizers_of_pullbacks_and_binary_products _ _ _ _,
287-
{ haveI: has_pullbacks C := ⟨infer_instance⟩,
288-
exact construct_products.over_binary_product_of_pullback },
289-
{ split,
290-
apply_instance} }
291-
end
292-
293-
instance has_limits {B : C} [has_wide_pullbacks C] : has_limits (over B) :=
294-
begin
295-
apply @limits_from_equalizers_and_products _ _ _ _,
296-
{ exact construct_products.over_products_of_wide_pullbacks },
297-
{ apply @has_equalizers_of_pullbacks_and_binary_products _ _ _ _,
298-
{ haveI: has_pullbacks C := ⟨infer_instance⟩,
299-
exact construct_products.over_binary_product_of_pullback },
300-
{ split,
301-
apply_instance } }
302-
end
303-
30492
end category_theory.over
30593

30694
namespace category_theory.under
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/-
2+
Copyright (c) 2018 Johan Commelin. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Johan Commelin, Reid Barton, Bhavik Mehta
5+
-/
6+
import category_theory.over
7+
import category_theory.limits.connected
8+
import category_theory.limits.creates
9+
10+
universes v u -- declare the `v`'s first; see `category_theory.category` for an explanation
11+
12+
open category_theory category_theory.limits
13+
14+
variables {J : Type v} [small_category J]
15+
variables {C : Type u} [category.{v} C]
16+
variable {X : C}
17+
18+
namespace category_theory.over
19+
20+
namespace creates_connected
21+
22+
/--
23+
(Impl) Given a diagram in the over category, produce a natural transformation from the
24+
diagram legs to the specific object.
25+
-/
26+
def nat_trans_in_over {B : C} (F : J ⥤ over B) :
27+
F ⋙ forget ⟶ (category_theory.functor.const J).obj B :=
28+
{ app := λ j, (F.obj j).hom }
29+
30+
local attribute [tidy] tactic.case_bash
31+
32+
/--
33+
(Impl) Given a cone in the base category, raise it to a cone in the over category. Note this is
34+
where the connected assumption is used.
35+
-/
36+
@[simps]
37+
def raise_cone [connected J] {B : C} {F : J ⥤ over B} (c : cone (F ⋙ forget)) :
38+
cone F :=
39+
{ X := over.mk (c.π.app (default J) ≫ (F.obj (default J)).hom),
40+
π :=
41+
{ app := λ j, over.hom_mk (c.π.app j) (nat_trans_from_connected (c.π ≫ nat_trans_in_over F) j) } }
42+
43+
lemma raised_cone_lowers_to_original [connected J] {B : C} {F : J ⥤ over B}
44+
(c : cone (F ⋙ forget)) (t : is_limit c) :
45+
forget.map_cone (raise_cone c) = c :=
46+
by tidy
47+
48+
/-- (Impl) Show that the raised cone is a limit. -/
49+
def raised_cone_is_limit [connected J] {B : C} {F : J ⥤ over B} {c : cone (F ⋙ forget)} (t : is_limit c) :
50+
is_limit (raise_cone c) :=
51+
{ lift := λ s, over.hom_mk (t.lift (forget.map_cone s))
52+
(by { dsimp, simp }),
53+
uniq' := λ s m K, by { ext1, apply t.hom_ext, intro j, simp [← K j] } }
54+
55+
end creates_connected
56+
57+
/-- The forgetful functor from the over category creates any connected limit. -/
58+
instance forget_creates_connected_limits [connected J] {B : C} : creates_limits_of_shape J (forget : over B ⥤ C) :=
59+
{ creates_limit := λ K,
60+
creates_limit_of_reflects_iso (λ c t,
61+
{ lifted_cone := creates_connected.raise_cone c,
62+
valid_lift := eq_to_iso (creates_connected.raised_cone_lowers_to_original c t),
63+
makes_limit := creates_connected.raised_cone_is_limit t } ) }
64+
65+
/-- The over category has any connected limit which the original category has. -/
66+
instance has_connected_limits {B : C} [connected J] [has_limits_of_shape J C] : has_limits_of_shape J (over B) :=
67+
{ has_limit := λ F, has_limit_of_created F (forget : over B ⥤ C) }
68+
69+
end category_theory.over
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/-
2+
Copyright (c) 2018 Johan Commelin. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Johan Commelin, Reid Barton, Bhavik Mehta
5+
-/
6+
import category_theory.limits.shapes.constructions.over.products
7+
import category_theory.limits.shapes.constructions.over.connected
8+
import category_theory.limits.shapes.constructions.limits_of_products_and_equalizers
9+
import category_theory.limits.shapes.constructions.equalizers
10+
11+
universes v u -- declare the `v`'s first; see `category_theory.category` for an explanation
12+
13+
open category_theory category_theory.limits
14+
15+
variables {J : Type v} [small_category J]
16+
variables {C : Type u} [category.{v} C]
17+
variable {X : C}
18+
19+
namespace category_theory.over
20+
21+
/-- Make sure we can derive pullbacks in `over B`. -/
22+
example {B : C} [has_pullbacks C] : has_pullbacks (over B) :=
23+
{ has_limits_of_shape := infer_instance }
24+
25+
/-- Make sure we can derive equalizers in `over B`. -/
26+
example {B : C} [has_equalizers C] : has_equalizers (over B) :=
27+
{ has_limits_of_shape := infer_instance }
28+
29+
instance has_finite_limits {B : C} [has_finite_wide_pullbacks C] : has_finite_limits (over B) :=
30+
begin
31+
apply @finite_limits_from_equalizers_and_finite_products _ _ _ _,
32+
{ exact construct_products.over_finite_products_of_finite_wide_pullbacks },
33+
{ apply @has_equalizers_of_pullbacks_and_binary_products _ _ _ _,
34+
{ haveI: has_pullbacks C := ⟨infer_instance⟩,
35+
exact construct_products.over_binary_product_of_pullback },
36+
{ split,
37+
apply_instance} }
38+
end
39+
40+
instance has_limits {B : C} [has_wide_pullbacks C] : has_limits (over B) :=
41+
begin
42+
apply @limits_from_equalizers_and_products _ _ _ _,
43+
{ exact construct_products.over_products_of_wide_pullbacks },
44+
{ apply @has_equalizers_of_pullbacks_and_binary_products _ _ _ _,
45+
{ haveI: has_pullbacks C := ⟨infer_instance⟩,
46+
exact construct_products.over_binary_product_of_pullback },
47+
{ split,
48+
apply_instance } }
49+
end
50+
51+
end category_theory.over

0 commit comments

Comments
 (0)