Skip to content

Commit ed23607

Browse files
dagurtomasbjoernkjoshanssen
authored andcommitted
refactor(Topology/Category): use CompHausLike API for limits in LightProfinite (#15362)
1 parent 6a0f6ba commit ed23607

File tree

2 files changed

+32
-302
lines changed

2 files changed

+32
-302
lines changed

Mathlib/Topology/Category/LightProfinite/EffectiveEpi.lean

+13-47
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,37 @@ Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Dagur Asgeirsson
55
-/
6+
import Mathlib.Topology.Category.CompHausLike.EffectiveEpi
67
import Mathlib.Topology.Category.LightProfinite.Limits
7-
import Mathlib.CategoryTheory.Sites.Coherent.Comparison
88
/-!
99
1010
# Effective epimorphisms in `LightProfinite`
1111
12-
This file proves that `EffectiveEpi`, `Epi` and `Surjective` are all equivalent in `LightProfinite`.
13-
As a consequence we prove that `LightProfinite` is `Preregular`.
14-
It follows from the constructions in `Mathlib/Topology/Category/LightProfinite/Limits.lean` that
15-
`LightProfinite` is `FinitaryExtensive`.
16-
Together this implies that it is `Precoherent`.
17-
12+
This file proves that `EffectiveEpi` and `Surjective` are equivalent in `LightProfinite`.
13+
As a consequence we deduce from the material in
14+
`Mathlib.Topology.Category.CompHausLike.EffectiveEpi` that `LightProfinite` is `Preregular`
15+
and`Precoherent`.
1816
-/
1917

2018
universe u
2119

22-
/-
23-
Previously, this had accidentally been made a global instance,
24-
and we now turn it on locally when convenient.
25-
-/
26-
attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike
20+
open CategoryTheory Limits CompHausLike
2721

28-
open CategoryTheory Limits
22+
attribute [local instance] ConcreteCategory.instFunLike
2923

3024
namespace LightProfinite
3125

32-
/--
33-
Implementation: if `π` is a surjective morphism in `LightProfinite`, then it is an effective epi.
34-
The theorem `LightProfinite.effectiveEpi_iff_surjective` should be used instead.
35-
-/
36-
noncomputable
37-
def EffectiveEpi.struct {B X : LightProfinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
38-
EffectiveEpiStruct π where
39-
desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
40-
DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
41-
(by ext; exact hab)) a
42-
fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
43-
fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
44-
(by ext; exact hab)) a)
45-
uniq e h g hm := by
46-
suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
47-
fun a b hab ↦
48-
DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
49-
(by ext; exact hab)) a⟩ by assumption
50-
rw [← Equiv.symm_apply_eq (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv]
51-
ext
52-
simp only [QuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm]
53-
rfl
54-
5526
theorem effectiveEpi_iff_surjective {X Y : LightProfinite.{u}} (f : X ⟶ Y) :
5627
EffectiveEpi f ↔ Function.Surjective f := by
57-
refine ⟨fun h ↦ ?_, fun h ↦ ⟨⟨EffectiveEpi.struct f h⟩⟩⟩
28+
refine ⟨fun h ↦ ?_, fun h ↦ ⟨⟨effectiveEpiStruct f h⟩⟩⟩
5829
rw [← epi_iff_surjective]
5930
infer_instance
6031

61-
instance : Preregular LightProfinite where
62-
exists_fac := by
63-
intro X Y Z f π hπ
64-
refine ⟨pullback f π, pullback.fst f π, ?_, pullback.snd f π, (pullback.condition _ _).symm⟩
65-
rw [effectiveEpi_iff_surjective] at hπ ⊢
66-
intro y
67-
obtain ⟨z,hz⟩ := hπ (f y)
68-
exact ⟨⟨(y, z), hz.symm⟩, rfl⟩
32+
instance : Preregular LightProfinite.{u} := by
33+
apply CompHausLike.preregular
34+
intro _ _ f
35+
exact (effectiveEpi_iff_surjective f).mp
6936

70-
-- Was an `example`, but that made the linter complain about unused imports
71-
instance : Precoherent LightProfinite.{u} := inferInstance
37+
example : Precoherent LightProfinite.{u} := inferInstance
7238

7339
end LightProfinite

Mathlib/Topology/Category/LightProfinite/Limits.lean

+19-255
Original file line numberDiff line numberDiff line change
@@ -3,276 +3,40 @@ Copyright (c) 2024 Dagur Asgeirsson. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Dagur Asgeirsson
55
-/
6+
import Mathlib.Topology.Category.CompHausLike.Limits
67
import Mathlib.Topology.Category.LightProfinite.Basic
7-
import Mathlib.Topology.Category.Profinite.Limits
88
/-!
99
1010
# Explicit limits and colimits
1111
12-
This file collects some constructions of explicit limits and colimits in `LightProfinite`,
13-
which may be useful due to their definitional properties.
14-
15-
## Main definitions
16-
17-
* `LightProfinite.pullback`: Explicit pullback, defined in the "usual" way as a subset of the
18-
product.
19-
20-
* `LightProfinite.finiteCoproduct`: Explicit finite coproducts, defined as a disjoint union.
21-
12+
This file applies the general API for explicit limits and colimits in `CompHausLike P` (see
13+
the file `Mathlib.Topology.Category.CompHausLike.Limits`) to the special case of `LightProfinite`.
2214
-/
2315

2416
namespace LightProfinite
2517

2618
universe u w
2719

28-
/-
29-
Previously, this had accidentally been made a global instance,
30-
and we now turn it on locally when convenient.
31-
-/
32-
attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike
33-
34-
open CategoryTheory Limits
35-
36-
section Pullbacks
37-
38-
variable {X Y B : LightProfinite.{u}} (f : X ⟶ B) (g : Y ⟶ B)
39-
40-
/--
41-
The pullback of two morphisms `f, g` in `LightProfinite`, constructed explicitly as the set of
42-
pairs `(x, y)` such that `f x = g y`, with the topology induced by the product.
43-
-/
44-
def pullback : LightProfinite.{u} :=
45-
letI set := { xy : X × Y | f xy.fst = g xy.snd }
46-
haveI : CompactSpace set := isCompact_iff_compactSpace.mp
47-
(isClosed_eq (f.continuous.comp continuous_fst) (g.continuous.comp continuous_snd)).isCompact
48-
LightProfinite.of set
49-
50-
/-- The projection from the pullback to the first component. -/
51-
def pullback.fst : pullback f g ⟶ X where
52-
toFun := fun ⟨⟨x, _⟩, _⟩ ↦ x
53-
continuous_toFun := Continuous.comp continuous_fst continuous_subtype_val
54-
55-
/-- The projection from the pullback to the second component. -/
56-
def pullback.snd : pullback f g ⟶ Y where
57-
toFun := fun ⟨⟨_, y⟩, _⟩ ↦ y
58-
continuous_toFun := Continuous.comp continuous_snd continuous_subtype_val
59-
60-
@[reassoc]
61-
lemma pullback.condition : pullback.fst f g ≫ f = pullback.snd f g ≫ g := by
62-
ext ⟨_, h⟩
63-
exact h
64-
65-
/--
66-
Construct a morphism to the explicit pullback given morphisms to the factors
67-
which are compatible with the maps to the base.
68-
This is essentially the universal property of the pullback.
69-
-/
70-
def pullback.lift {Z : LightProfinite.{u}} (a : Z ⟶ X) (b : Z ⟶ Y) (w : a ≫ f = b ≫ g) :
71-
Z ⟶ pullback f g where
72-
toFun := fun z ↦ ⟨⟨a z, b z⟩, by apply_fun (· z) at w; exact w⟩
73-
continuous_toFun := by
74-
apply Continuous.subtype_mk
75-
rw [continuous_prod_mk]
76-
exact ⟨a.continuous, b.continuous⟩
77-
78-
@[reassoc (attr := simp)]
79-
lemma pullback.lift_fst {Z : LightProfinite.{u}} (a : Z ⟶ X) (b : Z ⟶ Y) (w : a ≫ f = b ≫ g) :
80-
pullback.lift f g a b w ≫ pullback.fst f g = a := rfl
81-
82-
@[reassoc (attr := simp)]
83-
lemma pullback.lift_snd {Z : LightProfinite.{u}} (a : Z ⟶ X) (b : Z ⟶ Y) (w : a ≫ f = b ≫ g) :
84-
pullback.lift f g a b w ≫ pullback.snd f g = b := rfl
85-
86-
lemma pullback.hom_ext {Z : LightProfinite.{u}} (a b : Z ⟶ pullback f g)
87-
(hfst : a ≫ pullback.fst f g = b ≫ pullback.fst f g)
88-
(hsnd : a ≫ pullback.snd f g = b ≫ pullback.snd f g) : a = b := by
89-
ext z
90-
apply_fun (· z) at hfst hsnd
91-
apply Subtype.ext
92-
apply Prod.ext
93-
· exact hfst
94-
· exact hsnd
95-
96-
/-- The pullback cone whose cone point is the explicit pullback. -/
97-
@[simps! pt π]
98-
def pullback.cone : Limits.PullbackCone f g :=
99-
Limits.PullbackCone.mk (pullback.fst f g) (pullback.snd f g) (pullback.condition f g)
100-
101-
/-- The explicit pullback cone is a limit cone. -/
102-
@[simps! lift]
103-
def pullback.isLimit : Limits.IsLimit (pullback.cone f g) :=
104-
Limits.PullbackCone.isLimitAux _
105-
(fun s ↦ pullback.lift f g s.fst s.snd s.condition)
106-
(fun _ ↦ pullback.lift_fst _ _ _ _ _)
107-
(fun _ ↦ pullback.lift_snd _ _ _ _ _)
108-
(fun _ _ hm ↦ pullback.hom_ext _ _ _ _ (hm .left) (hm .right))
109-
110-
section Isos
111-
112-
/-- The isomorphism from the explicit pullback to the abstract pullback. -/
113-
noncomputable
114-
def pullbackIsoPullback : LightProfinite.pullback f g ≅ Limits.pullback f g :=
115-
Limits.IsLimit.conePointUniqueUpToIso (pullback.isLimit f g) (Limits.limit.isLimit _)
116-
117-
/-- The homeomorphism from the explicit pullback to the abstract pullback. -/
118-
noncomputable
119-
def pullbackHomeoPullback : (LightProfinite.pullback f g).toTop ≃ₜ
120-
(Limits.pullback f g).toTop :=
121-
CompHausLike.homeoOfIso (pullbackIsoPullback f g)
122-
123-
theorem pullback_fst_eq :
124-
LightProfinite.pullback.fst f g = (pullbackIsoPullback f g).hom ≫ Limits.pullback.fst f g := by
125-
dsimp [pullbackIsoPullback]
126-
simp only [Limits.limit.conePointUniqueUpToIso_hom_comp, pullback.cone_pt, pullback.cone_π]
127-
128-
theorem pullback_snd_eq :
129-
LightProfinite.pullback.snd f g = (pullbackIsoPullback f g).hom ≫ Limits.pullback.snd f g := by
130-
dsimp [pullbackIsoPullback]
131-
simp only [Limits.limit.conePointUniqueUpToIso_hom_comp, pullback.cone_pt, pullback.cone_π]
132-
133-
end Isos
134-
135-
end Pullbacks
136-
137-
section FiniteCoproducts
138-
139-
variable {α : Type w} [Finite α] (X : α → LightProfinite.{max u w})
140-
141-
/--
142-
The "explicit" coproduct of a finite family of objects in `LightProfinite`, whose underlying
143-
profinite set is the disjoint union with its usual topology.
144-
-/
145-
def finiteCoproduct : LightProfinite := LightProfinite.of <| Σ (a : α), X a
146-
147-
/-- The inclusion of one of the factors into the explicit finite coproduct. -/
148-
def finiteCoproduct.ι (a : α) : X a ⟶ finiteCoproduct X where
149-
toFun := (⟨a, ·⟩)
150-
continuous_toFun := continuous_sigmaMk (σ := fun a ↦ X a)
151-
152-
/--
153-
To construct a morphism from the explicit finite coproduct, it suffices to
154-
specify a morphism from each of its factors. This is the universal property of the coproduct.
155-
-/
156-
def finiteCoproduct.desc {B : LightProfinite.{max u w}} (e : (a : α) → (X a ⟶ B)) :
157-
finiteCoproduct X ⟶ B where
158-
toFun := fun ⟨a, x⟩ ↦ e a x
159-
continuous_toFun := by
160-
apply continuous_sigma
161-
intro a
162-
exact (e a).continuous
163-
164-
@[reassoc (attr := simp)]
165-
lemma finiteCoproduct.ι_desc {B : LightProfinite.{max u w}} (e : (a : α) → (X a ⟶ B)) (a : α) :
166-
finiteCoproduct.ι X a ≫ finiteCoproduct.desc X e = e a := rfl
167-
168-
lemma finiteCoproduct.hom_ext {B : LightProfinite.{max u w}} (f g : finiteCoproduct X ⟶ B)
169-
(h : ∀ a : α, finiteCoproduct.ι X a ≫ f = finiteCoproduct.ι X a ≫ g) : f = g := by
170-
ext ⟨a, x⟩
171-
specialize h a
172-
apply_fun (· x) at h
173-
exact h
174-
175-
/-- The coproduct cocone associated to the explicit finite coproduct. -/
176-
abbrev finiteCoproduct.cofan : Limits.Cofan X :=
177-
Cofan.mk (finiteCoproduct X) (finiteCoproduct.ι X)
178-
179-
/-- The explicit finite coproduct cocone is a colimit cocone. -/
180-
def finiteCoproduct.isColimit : Limits.IsColimit (finiteCoproduct.cofan X) :=
181-
mkCofanColimit _
182-
(fun s ↦ desc _ fun a ↦ s.inj a)
183-
(fun s a ↦ ι_desc _ _ _)
184-
fun s m hm ↦ finiteCoproduct.hom_ext _ _ _ fun a ↦
185-
(by ext t; exact congrFun (congrArg DFunLike.coe (hm a)) t)
186-
187-
instance (n : ℕ) (F : Discrete (Fin n) ⥤ LightProfinite) :
188-
HasColimit (Discrete.functor (F.obj ∘ Discrete.mk) : Discrete (Fin n) ⥤ LightProfinite) where
189-
exists_colimit := ⟨⟨finiteCoproduct.cofan _, finiteCoproduct.isColimit _⟩⟩
190-
191-
instance : HasFiniteCoproducts LightProfinite where
192-
out _ := { has_colimit := fun _ ↦ hasColimitOfIso Discrete.natIsoFunctor }
193-
194-
195-
section Iso
196-
197-
/-- The isomorphism from the explicit finite coproducts to the abstract coproduct. -/
198-
noncomputable
199-
def coproductIsoCoproduct : finiteCoproduct X ≅ ∐ X :=
200-
Limits.IsColimit.coconePointUniqueUpToIso (finiteCoproduct.isColimit X) (Limits.colimit.isColimit _)
201-
202-
theorem Sigma.ι_comp_toFiniteCoproduct (a : α) :
203-
(Limits.Sigma.ι X a) ≫ (coproductIsoCoproduct X).inv = finiteCoproduct.ι X a := by
204-
simp [coproductIsoCoproduct]
205-
206-
/-- The homeomorphism from the explicit finite coproducts to the abstract coproduct. -/
207-
noncomputable
208-
def coproductHomeoCoproduct : finiteCoproduct X ≃ₜ (∐ X : _) :=
209-
CompHausLike.homeoOfIso (coproductIsoCoproduct X)
210-
211-
end Iso
212-
213-
lemma finiteCoproduct.ι_injective (a : α) : Function.Injective (finiteCoproduct.ι X a) := by
214-
intro x y hxy
215-
exact eq_of_heq (Sigma.ext_iff.mp hxy).2
216-
217-
lemma finiteCoproduct.ι_jointly_surjective (R : finiteCoproduct X) :
218-
∃ (a : α) (r : X a), R = finiteCoproduct.ι X a r := ⟨R.fst, R.snd, rfl⟩
219-
220-
lemma finiteCoproduct.ι_desc_apply {B : LightProfinite} {π : (a : α) → X a ⟶ B} (a : α) :
221-
∀ x, finiteCoproduct.desc X π (finiteCoproduct.ι X a x) = π a x := by
222-
intro x
223-
change (ι X a ≫ desc X π) _ = _
224-
simp only [ι_desc]
225-
226-
end FiniteCoproducts
227-
228-
section HasPreserves
229-
230-
instance : HasPullbacks LightProfinite where
231-
has_limit F := hasLimitOfIso (diagramIsoCospan F).symm
232-
233-
noncomputable
234-
instance : PreservesFiniteCoproducts lightToProfinite := by
235-
refine ⟨fun J hJ ↦ ⟨fun {F} ↦ ?_⟩⟩
236-
suffices PreservesColimit (Discrete.functor (F.obj ∘ Discrete.mk)) lightToProfinite from
237-
preservesColimitOfIsoDiagram _ Discrete.natIsoFunctor.symm
238-
apply preservesColimitOfPreservesColimitCocone (finiteCoproduct.isColimit _)
239-
have : Finite J := Finite.of_fintype _
240-
exact Profinite.finiteCoproduct.isColimit (X := fun (j : J) ↦ (Profinite.of (F.obj ⟨j⟩)))
241-
242-
noncomputable
243-
instance : PreservesLimitsOfShape WalkingCospan lightToProfinite := by
244-
suffices ∀ {X Y B} (f : X ⟶ B) (g : Y ⟶ B), PreservesLimit (cospan f g) lightToProfinite from
245-
fun {F} ↦ preservesLimitOfIsoDiagram _ (diagramIsoCospan F).symm⟩
246-
intro _ _ _ f g
247-
apply preservesLimitOfPreservesLimitCone (pullback.isLimit f g)
248-
exact (isLimitMapConePullbackConeEquiv lightToProfinite (pullback.condition f g)).symm
249-
(Profinite.pullback.isLimit _ _)
250-
251-
instance (X : LightProfinite) :
252-
Unique (X ⟶ LightProfinite.of PUnit.{u+1}) :=
253-
⟨⟨⟨fun _ ↦ PUnit.unit, continuous_const⟩⟩, fun _ ↦ rfl⟩
254-
255-
/-- A one-element space is terminal in `LightProfinite` -/
256-
def isTerminalPUnit : IsTerminal (LightProfinite.of PUnit.{u+1}) := Limits.IsTerminal.ofUnique _
257-
258-
instance : HasTerminal LightProfinite.{u} :=
259-
Limits.hasTerminal_of_unique (LightProfinite.of PUnit.{u+1})
20+
open CategoryTheory Limits CompHausLike
26021

261-
/-- The isomorphism from an arbitrary terminal object of `LightProfinite` to a one-element space. -/
262-
noncomputable def terminalIsoPUnit : ⊤_ LightProfinite.{u} ≅ LightProfinite.of PUnit.{u+1} :=
263-
terminalIsTerminal.uniqueUpToIso LightProfinite.isTerminalPUnit
22+
instance : HasExplicitPullbacks
23+
(fun Y ↦ TotallyDisconnectedSpace Y ∧ SecondCountableTopology Y) where
24+
hasProp _ _ := {
25+
hasProp := ⟨show TotallyDisconnectedSpace {_xy : _ | _} from inferInstance,
26+
show SecondCountableTopology {_xy : _ | _} from inferInstance⟩ }
26427

265-
noncomputable instance : PreservesFiniteCoproducts LightProfinite.toTopCat.{u} where
266-
preserves _ _ := (inferInstance :
267-
PreservesColimitsOfShape _ (lightToProfinite.{u} ⋙ Profinite.toTopCat.{u}))
28+
instance : HasExplicitFiniteCoproducts.{w, u}
29+
(fun Y ↦ TotallyDisconnectedSpace Y ∧ SecondCountableTopology Y) where
30+
hasProp _ := { hasProp :=
31+
show TotallyDisconnectedSpace (Σ (_a : _), _) from inferInstance,
32+
show SecondCountableTopology (Σ (_a : _), _) from inferInstance⟩ }
26833

269-
noncomputable instance : PreservesLimitsOfShape WalkingCospan LightProfinite.toTopCat.{u} :=
270-
(inferInstance : PreservesLimitsOfShape WalkingCospan
271-
(lightToProfinite.{u} ⋙ Profinite.toTopCat.{u}))
34+
/-- A one-element space is terminal in `Profinite` -/
35+
abbrev isTerminalPUnit : IsTerminal (LightProfinite.of PUnit.{u + 1}) :=
36+
CompHausLike.isTerminalPUnit
27237

273-
instance : FinitaryExtensive LightProfinite.{u} :=
274-
finitaryExtensive_of_preserves_and_reflects lightToProfinite
38+
example : FinitaryExtensive LightProfinite.{u} := inferInstance
27539

276-
end HasPreserves
40+
noncomputable example : PreservesFiniteCoproducts lightProfiniteToCompHaus.{u} := inferInstance
27741

27842
end LightProfinite

0 commit comments

Comments
 (0)