|
| 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