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

Commit 62abc4d

Browse files
kim-emjcommelinmergify[bot]
authored
feat(category_theory): images (#2100)
* feat(category_theory): images * oops, forgot to add file * Update src/category_theory/category/default.lean Co-Authored-By: Johan Commelin <johan@commelin.net> * some improvements * linting * oops * Update src/category_theory/limits/shapes/images.lean Co-authored-by: Johan Commelin <johan@commelin.net> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent d8d0927 commit 62abc4d

File tree

3 files changed

+270
-4
lines changed

3 files changed

+270
-4
lines changed

src/category_theory/category/default.lean

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,59 @@ class epi (f : X ⟶ Y) : Prop :=
110110
class mono (f : X ⟶ Y) : Prop :=
111111
(right_cancellation : Π {Z : C} (g h : Z ⟶ X) (w : g ≫ f = h ≫ f), g = h)
112112

113-
@[simp] lemma cancel_epi (f : X ⟶ Y) [epi f] {g h : Y ⟶ Z} : (f ≫ g = f ≫ h) ↔ g = h :=
113+
instance (X : C) : epi.{v} (𝟙 X) :=
114+
⟨λ Z g h w, by simpa using w⟩
115+
instance (X : C) : mono.{v} (𝟙 X) :=
116+
⟨λ Z g h w, by simpa using w⟩
117+
118+
lemma cancel_epi (f : X ⟶ Y) [epi f] {g h : Y ⟶ Z} : (f ≫ g = f ≫ h) ↔ g = h :=
114119
⟨ λ p, epi.left_cancellation g h p, begin intro a, subst a end
115-
@[simp] lemma cancel_mono (f : X ⟶ Y) [mono f] {g h : Z ⟶ X} : (g ≫ f = h ≫ f) ↔ g = h :=
120+
lemma cancel_mono (f : X ⟶ Y) [mono f] {g h : Z ⟶ X} : (g ≫ f = h ≫ f) ↔ g = h :=
116121
⟨ λ p, mono.right_cancellation g h p, begin intro a, subst a end
122+
123+
lemma cancel_epi_id (f : X ⟶ Y) [epi f] {h : Y ⟶ Y} : (f ≫ h = f) ↔ h = 𝟙 Y :=
124+
by { convert cancel_epi f, simp, }
125+
lemma cancel_mono_id (f : X ⟶ Y) [mono f] {g : X ⟶ X} : (g ≫ f = f) ↔ g = 𝟙 X :=
126+
by { convert cancel_mono f, simp, }
127+
128+
instance epi_comp {X Y Z : C} (f : X ⟶ Y) [epi f] (g : Y ⟶ Z) [epi g] : epi (f ≫ g) :=
129+
begin
130+
split, intros Z a b w,
131+
apply (cancel_epi g).1,
132+
apply (cancel_epi f).1,
133+
simpa using w,
134+
end
135+
instance mono_comp {X Y Z : C} (f : X ⟶ Y) [mono f] (g : Y ⟶ Z) [mono g] : mono (f ≫ g) :=
136+
begin
137+
split, intros Z a b w,
138+
apply (cancel_mono f).1,
139+
apply (cancel_mono g).1,
140+
simpa using w,
141+
end
142+
143+
lemma mono_of_mono {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [mono (f ≫ g)] : mono f :=
144+
begin
145+
split, intros Z a b w,
146+
replace w := congr_arg (λ k, k ≫ g) w,
147+
dsimp at w,
148+
rw [category.assoc, category.assoc] at w,
149+
exact (cancel_mono _).1 w,
150+
end
151+
152+
lemma mono_of_mono_fac {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [mono h] (w : f ≫ g = h) : mono f :=
153+
by { resetI, subst h, exact mono_of_mono f g, }
154+
155+
lemma epi_of_epi {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [epi (f ≫ g)] : epi g :=
156+
begin
157+
split, intros Z a b w,
158+
replace w := congr_arg (λ k, f ≫ k) w,
159+
dsimp at w,
160+
rw [←category.assoc, ←category.assoc] at w,
161+
exact (cancel_epi _).1 w,
162+
end
163+
164+
lemma epi_of_epi_fac {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [epi h] (w : f ≫ g = h) : epi g :=
165+
by { resetI, subst h, exact epi_of_epi f g, }
117166
end
118167

119168
section

src/category_theory/limits/shapes/equalizers.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ limit.lift (parallel_pair f g) (fork.of_ι k h)
292292
limit.hom_ext $ cone_parallel_pair_ext _ h
293293

294294
/-- An equalizer morphism is a monomorphism -/
295-
lemma equalizer.ι_mono : mono (equalizer.ι f g) :=
295+
instance equalizer.ι_mono : mono (equalizer.ι f g) :=
296296
{ right_cancellation := λ Z h k w, equalizer.hom_ext _ _ w }
297297

298298
end
@@ -378,7 +378,7 @@ colimit.desc (parallel_pair f g) (cofork.of_π k h)
378378
colimit.hom_ext $ cocone_parallel_pair_ext _ h
379379

380380
/-- A coequalizer morphism is an epimorphism -/
381-
lemma coequalizer.π_epi : epi (coequalizer.π f g) :=
381+
instance coequalizer.π_epi : epi (coequalizer.π f g) :=
382382
{ left_cancellation := λ Z h k w, coequalizer.hom_ext _ _ w }
383383

384384
end
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/-
2+
Copyright (c) 2019 Scott Morrison. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Scott Morrison, Markus Himmel
5+
-/
6+
import category_theory.limits.shapes.equalizers
7+
8+
/-!
9+
# Categorical images
10+
11+
We define the categorical image of `f` as a factorisation `f = e ≫ m` through a monomorphism `m`,
12+
so that `m` factors through the `m'` in any other such factorisation.
13+
14+
## Main statements
15+
16+
* When `C` has equalizers, the morphism `m` is an epimorphism.
17+
18+
## Future work
19+
* TODO: coimages, and abelian categories.
20+
* TODO: connect this with existing working in the group theory and ring theory libraries.
21+
22+
-/
23+
24+
universes v u
25+
26+
open category_theory
27+
open category_theory.limits.walking_parallel_pair
28+
29+
namespace category_theory.limits
30+
31+
variables {C : Type u} [𝒞 : category.{v} C]
32+
include 𝒞
33+
34+
variables {X Y : C} (f : X ⟶ Y)
35+
36+
/-- A factorisation of a morphism `f = e ≫ m`, with `m` monic. -/
37+
structure mono_factorisation (f : X ⟶ Y) :=
38+
(I : C)
39+
(m : I ⟶ Y)
40+
[m_mono : mono.{v} m]
41+
(e : X ⟶ I)
42+
(fac' : e ≫ m = f . obviously)
43+
44+
restate_axiom mono_factorisation.fac'
45+
attribute [simp, reassoc] mono_factorisation.fac
46+
47+
namespace mono_factorisation
48+
49+
/-- The obvious factorisation of a monomorphism through itself. -/
50+
def self [mono f] : mono_factorisation f :=
51+
{ I := X,
52+
m := f,
53+
e := 𝟙 X }
54+
55+
-- I'm not sure we really need this, but the linter says that an inhabited instance ought to exist...
56+
instance [mono f] : inhabited (mono_factorisation f) := ⟨self f⟩
57+
58+
/-- The morphism `m` in a factorisation `f = e ≫ m` through a monomorphism is uniquely determined. -/
59+
@[ext]
60+
lemma ext
61+
{F F' : mono_factorisation f} (hI : F.I = F'.I) (hm : F.m = (eq_to_hom hI) ≫ F'.m) : F = F' :=
62+
begin
63+
cases F, cases F',
64+
cases hI,
65+
simp at hm,
66+
dsimp at F_fac' F'_fac',
67+
congr,
68+
{ assumption },
69+
{ resetI, apply (cancel_mono F_m).1,
70+
rw [F_fac', hm, F'_fac'], }
71+
end
72+
73+
end mono_factorisation
74+
75+
variable {f}
76+
77+
/-- Data exhibiting that a given factorisation through a mono is initial. -/
78+
structure is_image (F : mono_factorisation f) :=
79+
(lift : Π (F' : mono_factorisation f), F.I ⟶ F'.I)
80+
(lift_fac' : Π (F' : mono_factorisation f), lift F' ≫ F'.m = F.m . obviously)
81+
82+
restate_axiom is_image.lift_fac'
83+
attribute [simp, reassoc] is_image.lift_fac
84+
85+
variable (f)
86+
87+
namespace is_image
88+
89+
/-- The trivial factorisation of a monomorphism satisfies the universal property. -/
90+
@[simps]
91+
def self [mono f] : is_image (mono_factorisation.self f) :=
92+
{ lift := λ F', F'.e }
93+
94+
instance [mono f] : inhabited (is_image (mono_factorisation.self f)) :=
95+
⟨self f⟩
96+
97+
variable {f}
98+
/-- Two factorisations through monomorphisms satisfying the universal property
99+
must factor through isomorphic objects. -/
100+
-- TODO this is another good candidate for a future `unique_up_to_canonical_iso`.
101+
@[simps]
102+
def iso_ext {F F' : mono_factorisation f} (hF : is_image F) (hF' : is_image F') : F.I ≅ F'.I :=
103+
{ hom := hF.lift F',
104+
inv := hF'.lift F,
105+
hom_inv_id' := begin haveI := F.m_mono, apply (cancel_mono F.m).1, simp end,
106+
inv_hom_id' := begin haveI := F'.m_mono, apply (cancel_mono F'.m).1, simp end }
107+
108+
end is_image
109+
110+
/-- Data exhibiting that a morphism `f` has an image. -/
111+
class has_image (f : X ⟶ Y) :=
112+
(F : mono_factorisation f)
113+
(is_image : is_image F)
114+
115+
variable [has_image f]
116+
117+
/-- The chosen factorisation of `f` through a monomorphism. -/
118+
def image.mono_factorisation : mono_factorisation f := has_image.F f
119+
/-- The witness of the universal property for the chosen factorisation of `f` through a monomorphism. -/
120+
def image.is_image : is_image (image.mono_factorisation f) := has_image.is_image f
121+
122+
/-- The categorical image of a morphism. -/
123+
def image : C := (image.mono_factorisation f).I
124+
/-- The inclusion of the image of a morphism into the target. -/
125+
def image.ι : image f ⟶ Y := (image.mono_factorisation f).m
126+
@[simp] lemma image.as_ι : (image.mono_factorisation f).m = image.ι f := rfl
127+
instance : mono (image.ι f) := (image.mono_factorisation f).m_mono
128+
/-- The 'corestriction' morphism from the source to the image. -/
129+
def image.c : X ⟶ image f := (image.mono_factorisation f).e
130+
@[simp] lemma image.as_c : (image.mono_factorisation f).e = image.c f := rfl
131+
@[simp] lemma image.c_ι : image.c f ≫ image.ι f = f := by erw (image.mono_factorisation f).fac
132+
133+
/-- The map from the source to the image of a morphism. -/
134+
def factor_thru_image : X ⟶ image f := (image.mono_factorisation f).e
135+
@[simp, reassoc]
136+
lemma image.fac : factor_thru_image f ≫ image.ι f = f := (image.mono_factorisation f).fac'
137+
138+
variable {f}
139+
/-- Any other factorisation of the morphism `f` through a monomorphism receives a map from the image. -/
140+
def image.lift (F' : mono_factorisation f) : image f ⟶ F'.I := (image.is_image f).lift F'
141+
@[simp, reassoc]
142+
lemma image.lift_fac (F' : mono_factorisation f) : image.lift F' ≫ F'.m = image.ι f :=
143+
(image.is_image f).lift_fac' F'
144+
145+
-- TODO we could put a category structure on `mono_factorisation f`,
146+
-- with the morphisms being `g : I ⟶ I'` commuting with the `m`s
147+
-- (they then automatically commute with the `e`s)
148+
-- and show that an `image_of f` gives an initial object there
149+
-- (uniqueness of the lift comes for free).
150+
151+
instance lift_mono (F' : mono_factorisation f) : mono.{v} (image.lift F') :=
152+
begin
153+
split, intros Z a b w,
154+
have w' : a ≫ image.ι f = b ≫ image.ι f :=
155+
calc a ≫ image.ι f = a ≫ (image.lift F' ≫ F'.m) : by simp
156+
... = (a ≫ image.lift F') ≫ F'.m : by rw [category.assoc]
157+
... = (b ≫ image.lift F') ≫ F'.m : by rw w
158+
... = b ≫ (image.lift F' ≫ F'.m) : by rw [←category.assoc]
159+
... = b ≫ image.ι f : by simp,
160+
exact (cancel_mono (image.ι f)).1 w',
161+
end
162+
lemma has_image.uniq
163+
(F' : mono_factorisation f) (l : image f ⟶ F'.I) (w : l ≫ F'.m = image.ι f) :
164+
l = image.lift F' :=
165+
begin
166+
haveI := F'.m_mono,
167+
apply (cancel_mono F'.m).1,
168+
rw w,
169+
simp,
170+
end
171+
172+
/-- `has_images` represents a choice of image for every morphism -/
173+
class has_images :=
174+
(has_image : Π {X Y : C} (f : X ⟶ Y), has_image.{v} f)
175+
176+
attribute [instance] has_images.has_image
177+
178+
variable (f)
179+
/-- The image of a monomorphism is isomorphic to the source. -/
180+
def image_mono_iso_source [mono f] : image f ≅ X :=
181+
is_image.iso_ext (image.is_image f) (is_image.self f)
182+
183+
@[simp, reassoc]
184+
lemma image_mono_iso_source_inv_ι [mono f] : (image_mono_iso_source f).inv ≫ image.ι f = f :=
185+
by simp [image_mono_iso_source]
186+
@[simp, reassoc]
187+
lemma image_mono_iso_source_hom_self [mono f] : (image_mono_iso_source f).hom ≫ f = image.ι f :=
188+
begin
189+
conv { to_lhs, congr, skip, rw ←image_mono_iso_source_inv_ι f, },
190+
rw [←category.assoc, iso.hom_inv_id, category.id_comp],
191+
end
192+
193+
-- This is the proof from https://en.wikipedia.org/wiki/Image_(category_theory), which is taken from:
194+
-- Mitchell, Barry (1965), Theory of categories, MR 0202787, p.12, Proposition 10.1
195+
instance [has_equalizers.{v} C] : epi (factor_thru_image f) :=
196+
⟨λ Z g h w,
197+
begin
198+
let q := equalizer.ι g h,
199+
let e' := equalizer.lift _ _ _ w, -- TODO make more of the arguments to equalizer.lift implicit?
200+
let F' : mono_factorisation f :=
201+
{ I := equalizer g h,
202+
m := q ≫ image.ι f,
203+
e := e' },
204+
let v := image.lift F',
205+
have t₀ : v ≫ q ≫ image.ι f = image.ι f := image.lift_fac F',
206+
have t : v ≫ q = 𝟙 (image f) := (cancel_mono_id (image.ι f)).1 (by { convert t₀ using 1, rw category.assoc }),
207+
-- The proof from wikipedia next proves `q ≫ v = 𝟙 _`,
208+
-- and concludes that `equalizer g h ≅ image f`,
209+
-- but this isn't necessary.
210+
calc g = 𝟙 (image f) ≫ g : by rw [category.id_comp]
211+
... = v ≫ q ≫ g : by rw [←t, category.assoc]
212+
... = v ≫ q ≫ h : by rw [equalizer.condition g h]
213+
... = 𝟙 (image f) ≫ h : by rw [←category.assoc, t]
214+
... = h : by rw [category.id_comp]
215+
end
216+
217+
end category_theory.limits

0 commit comments

Comments
 (0)