|
| 1 | +/- |
| 2 | +Copyright (c) 2021 Andrew Yang. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Andrew Yang |
| 5 | +-/ |
| 6 | +import category_theory.limits.filtered_colimit_commutes_finite_limit |
| 7 | +import category_theory.limits.preserves.functor_category |
| 8 | +import category_theory.limits.preserves.shapes.equalizers |
| 9 | +import category_theory.limits.bicones |
| 10 | +import category_theory.limits.comma |
| 11 | +import category_theory.limits.preserves.finite |
| 12 | +import category_theory.limits.shapes.finite_limits |
| 13 | + |
| 14 | +/-! |
| 15 | +# Representably flat functors |
| 16 | +
|
| 17 | +We define representably flat functors as functors such that the category of structured arrows |
| 18 | +over `X` is cofiltered for each `X`. This concept is also known as flat functors as in [Elephant] |
| 19 | +Remark C2.3.7, and this name is suggested by Mike Shulman in |
| 20 | +https://golem.ph.utexas.edu/category/2011/06/flat_functors_and_morphisms_of.html to avoid |
| 21 | +confusion with other notions of flatness. |
| 22 | +
|
| 23 | +This definition is equivalent to left exact functors (functors that preserves finite limits) when |
| 24 | +`C` has all finite limits. |
| 25 | +
|
| 26 | +## Main results |
| 27 | +
|
| 28 | +* `flat_of_preserves_finite_limits`: If `F : C ⥤ D` preserves finite limits and `C` has all finite |
| 29 | + limits, then `F` is flat. |
| 30 | +* `preserves_finite_limits_of_flat`: If `F : C ⥤ D` is flat, then it preserves all finite limits. |
| 31 | +* `preserves_finite_limits_iff_flat`: If `C` has all finite limits, |
| 32 | + then `F` is flat iff `F` is left_exact. |
| 33 | +* `Lan_preserves_finite_limits_of_flat`: If `F : C ⥤ D` is a flat functor between small categories, |
| 34 | + then the functor `Lan F.op` between presheaves of sets preserves all finite limits. |
| 35 | +* `flat_iff_Lan_flat`: If `C`, `D` are small and `C` has all finite limits, then `F` is flat iff |
| 36 | + `Lan F.op : (Cᵒᵖ ⥤ Type*) ⥤ (Dᵒᵖ ⥤ Type*)` is flat. |
| 37 | +* `preserves_finite_limits_iff_Lan_preserves_finite_limits`: If `C`, `D` are small and `C` has all |
| 38 | + finite limits, then `F` preserves finite limits iff `Lan F.op : (Cᵒᵖ ⥤ Type*) ⥤ (Dᵒᵖ ⥤ Type*)` |
| 39 | + does. |
| 40 | +
|
| 41 | +-/ |
| 42 | + |
| 43 | +universes v₁ v₂ v₃ u₁ u₂ u₃ |
| 44 | + |
| 45 | +open category_theory |
| 46 | +open category_theory.limits |
| 47 | +open opposite |
| 48 | + |
| 49 | +namespace category_theory |
| 50 | + |
| 51 | + |
| 52 | +namespace structured_arrow_cone |
| 53 | +open structured_arrow |
| 54 | +variables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₁} D] |
| 55 | +variables {J : Type v₁} [small_category J] |
| 56 | +variables {K : J ⥤ C} (F : C ⥤ D) (c : cone K) |
| 57 | + |
| 58 | +/-- |
| 59 | +Given a cone `c : cone K` and a map `f : X ⟶ c.X`, we can construct a cone of structured |
| 60 | +arrows over `X` with `f` as the cone point. This is the underlying diagram. |
| 61 | +-/ |
| 62 | +@[simps] |
| 63 | +def to_diagram : J ⥤ structured_arrow c.X K := |
| 64 | +{ obj := λ j, structured_arrow.mk (c.π.app j), |
| 65 | + map := λ j k g, structured_arrow.hom_mk g (by simpa) } |
| 66 | + |
| 67 | +/-- Given a diagram of `structured_arrow X F`s, we may obtain a cone with cone point `X`. -/ |
| 68 | +@[simps] |
| 69 | +def diagram_to_cone {X : D} (G : J ⥤ structured_arrow X F) : cone (G ⋙ proj X F ⋙ F) := |
| 70 | +{ X := X, π := { app := λ j, (G.obj j).hom } } |
| 71 | + |
| 72 | +/-- |
| 73 | +Given a cone `c : cone K` and a map `f : X ⟶ F.obj c.X`, we can construct a cone of structured |
| 74 | +arrows over `X` with `f` as the cone point. |
| 75 | +-/ |
| 76 | +@[simps] |
| 77 | +def to_cone {X : D} (f : X ⟶ F.obj c.X) : |
| 78 | + cone (to_diagram (F.map_cone c) ⋙ map f ⋙ pre _ K F) := |
| 79 | +{ X := mk f, π := { app := λ j, hom_mk (c.π.app j) rfl, |
| 80 | + naturality' := λ j k g, by { ext, dsimp, simp } } } |
| 81 | + |
| 82 | +end structured_arrow_cone |
| 83 | + |
| 84 | +section representably_flat |
| 85 | +variables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D] |
| 86 | + |
| 87 | +/-- |
| 88 | +A functor `F : C ⥤ D` is representably-flat functor if the comma category `(X/F)` |
| 89 | +is cofiltered for each `X : C`. |
| 90 | +-/ |
| 91 | +class representably_flat (F : C ⥤ D) : Prop := |
| 92 | +(cofiltered : ∀ (X : D), is_cofiltered (structured_arrow X F)) |
| 93 | + |
| 94 | +attribute [instance] representably_flat.cofiltered |
| 95 | + |
| 96 | +end representably_flat |
| 97 | + |
| 98 | +section has_limit |
| 99 | +variables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₁} D] |
| 100 | + |
| 101 | +@[priority 100] |
| 102 | +instance cofiltered_of_has_finite_limits [has_finite_limits C] : is_cofiltered C := |
| 103 | +{ cocone_objs := λ A B, ⟨limits.prod A B, limits.prod.fst, limits.prod.snd, trivial⟩, |
| 104 | + cocone_maps := λ A B f g, ⟨equalizer f g, equalizer.ι f g, equalizer.condition f g⟩, |
| 105 | + nonempty := ⟨⊤_ C⟩ } |
| 106 | + |
| 107 | +lemma flat_of_preserves_finite_limits [has_finite_limits C] (F : C ⥤ D) |
| 108 | + [preserves_finite_limits F] : representably_flat F := ⟨λ X, |
| 109 | +begin |
| 110 | + haveI : has_finite_limits (structured_arrow X F) := |
| 111 | + { out := λ J _ _, by { resetI, apply_instance } }, |
| 112 | + apply_instance |
| 113 | +end⟩ |
| 114 | + |
| 115 | +namespace preserves_finite_limits_of_flat |
| 116 | +open structured_arrow |
| 117 | +open structured_arrow_cone |
| 118 | +variables {J : Type v₁} [small_category J] [fin_category J] {K : J ⥤ C} |
| 119 | +variables (F : C ⥤ D) [representably_flat F] {c : cone K} (hc : is_limit c) (s : cone (K ⋙ F)) |
| 120 | +include hc |
| 121 | + |
| 122 | +/-- |
| 123 | +(Implementation). |
| 124 | +Given a limit cone `c : cone K` and a cone `s : cone (K ⋙ F)` with `F` representably flat, |
| 125 | +`s` can factor through `F.map_cone c`. |
| 126 | +-/ |
| 127 | +noncomputable def lift : s.X ⟶ F.obj c.X := |
| 128 | +let s' := is_cofiltered.cone (to_diagram s ⋙ structured_arrow.pre _ K F) in |
| 129 | +s'.X.hom ≫ (F.map $ hc.lift $ |
| 130 | + (cones.postcompose ({ app := λ X, 𝟙 _, naturality' := by simp } |
| 131 | + : (to_diagram s ⋙ pre s.X K F) ⋙ proj s.X F ⟶ K)).obj $ |
| 132 | + (structured_arrow.proj s.X F).map_cone s') |
| 133 | + |
| 134 | +lemma fac (x : J) : lift F hc s ≫ (F.map_cone c).π.app x = s.π.app x := |
| 135 | +by simpa [lift, ←functor.map_comp] |
| 136 | + |
| 137 | +lemma uniq {K : J ⥤ C} {c : cone K} (hc : is_limit c) |
| 138 | + (s : cone (K ⋙ F)) (f₁ f₂ : s.X ⟶ F.obj c.X) |
| 139 | + (h₁ : ∀ (j : J), f₁ ≫ (F.map_cone c).π.app j = s.π.app j) |
| 140 | + (h₂ : ∀ (j : J), f₂ ≫ (F.map_cone c).π.app j = s.π.app j) : f₁ = f₂ := |
| 141 | +begin |
| 142 | + -- We can make two cones over the diagram of `s` via `f₁` and `f₂`. |
| 143 | + let α₁ : to_diagram (F.map_cone c) ⋙ map f₁ ⟶ to_diagram s := |
| 144 | + { app := λ X, eq_to_hom (by simp [←h₁]), naturality' := λ _ _ _, by { ext, simp } }, |
| 145 | + let α₂ : to_diagram (F.map_cone c) ⋙ map f₂ ⟶ to_diagram s := |
| 146 | + { app := λ X, eq_to_hom (by simp [←h₂]), naturality' := λ _ _ _, by { ext, simp } }, |
| 147 | + let c₁ : cone (to_diagram s ⋙ pre s.X K F) := |
| 148 | + (cones.postcompose (whisker_right α₁ (pre s.X K F) : _)).obj (to_cone F c f₁), |
| 149 | + let c₂ : cone (to_diagram s ⋙ pre s.X K F) := |
| 150 | + (cones.postcompose (whisker_right α₂ (pre s.X K F) : _)).obj (to_cone F c f₂), |
| 151 | + |
| 152 | + -- The two cones can then be combined and we may obtain a cone over the two cones since |
| 153 | + -- `structured_arrow s.X F` is cofiltered. |
| 154 | + let c₀ := is_cofiltered.cone (bicone_mk _ c₁ c₂), |
| 155 | + let g₁ : c₀.X ⟶ c₁.X := c₀.π.app (bicone.left), |
| 156 | + let g₂ : c₀.X ⟶ c₂.X := c₀.π.app (bicone.right), |
| 157 | + |
| 158 | + -- Then `g₁.right` and `g₂.right` are two maps from the same cone into the `c`. |
| 159 | + have : ∀ (j : J), g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j, |
| 160 | + { intro j, |
| 161 | + injection c₀.π.naturality (bicone_hom.left j) with _ e₁, |
| 162 | + injection c₀.π.naturality (bicone_hom.right j) with _ e₂, |
| 163 | + simpa using e₁.symm.trans e₂ }, |
| 164 | + have : c.extend g₁.right = c.extend g₂.right, |
| 165 | + { unfold cone.extend, congr' 1, ext x, apply this }, |
| 166 | + |
| 167 | + -- And thus they are equal as `c` is the limit. |
| 168 | + have : g₁.right = g₂.right, |
| 169 | + calc g₁.right = hc.lift (c.extend g₁.right) : by { apply hc.uniq (c.extend _), tidy } |
| 170 | + ... = hc.lift (c.extend g₂.right) : by { congr, exact this } |
| 171 | + ... = g₂.right : by { symmetry, apply hc.uniq (c.extend _), tidy }, |
| 172 | + |
| 173 | + -- Finally, since `fᵢ` factors through `F(gᵢ)`, the result follows. |
| 174 | + calc f₁ = 𝟙 _ ≫ f₁ : by simp |
| 175 | + ... = c₀.X.hom ≫ F.map g₁.right : g₁.w |
| 176 | + ... = c₀.X.hom ≫ F.map g₂.right : by rw this |
| 177 | + ... = 𝟙 _ ≫ f₂ : g₂.w.symm |
| 178 | + ... = f₂ : by simp |
| 179 | +end |
| 180 | + |
| 181 | +end preserves_finite_limits_of_flat |
| 182 | + |
| 183 | +/-- Representably flat functors preserve finite limits. -/ |
| 184 | +noncomputable |
| 185 | +def preserves_finite_limits_of_flat (F : C ⥤ D) [representably_flat F] : |
| 186 | + preserves_finite_limits F := ⟨λ J _ _, by exactI ⟨λ K, ⟨λ c hc, |
| 187 | +{ lift := preserves_finite_limits_of_flat.lift F hc, |
| 188 | + fac' := preserves_finite_limits_of_flat.fac F hc, |
| 189 | + uniq' := λ s m h, by |
| 190 | + { apply preserves_finite_limits_of_flat.uniq F hc, |
| 191 | + exact h, |
| 192 | + exact preserves_finite_limits_of_flat.fac F hc s } }⟩⟩⟩ |
| 193 | + |
| 194 | +/-- |
| 195 | +If `C` is finitely cocomplete, then `F : C ⥤ D` is representably flat iff it preserves |
| 196 | +finite limits. |
| 197 | +-/ |
| 198 | +noncomputable |
| 199 | +def preserves_finite_limits_iff_flat [has_finite_limits C] (F : C ⥤ D) : |
| 200 | + representably_flat F ≃ preserves_finite_limits F := |
| 201 | +{ to_fun := λ _, by exactI preserves_finite_limits_of_flat F, |
| 202 | + inv_fun := λ _, by exactI flat_of_preserves_finite_limits F, |
| 203 | + left_inv := λ _, proof_irrel _ _, |
| 204 | + right_inv := λ x, by { cases x, unfold preserves_finite_limits_of_flat, congr } } |
| 205 | + |
| 206 | +end has_limit |
| 207 | + |
| 208 | + |
| 209 | +section small_category |
| 210 | +variables {C D : Type u₁} [small_category C] [small_category D] |
| 211 | + |
| 212 | +/-- |
| 213 | +(Implementation) |
| 214 | +The evaluation of `Lan F` at `X` is the colimit over the costructured arrows over `X`. |
| 215 | +-/ |
| 216 | +noncomputable |
| 217 | +def Lan_evaluation_iso_colim (E : Type u₂) [category.{u₁} E] (F : C ⥤ D) (X : D) |
| 218 | + [∀ (X : D), has_colimits_of_shape (costructured_arrow F X) E] : |
| 219 | + Lan F ⋙ (evaluation D E).obj X ≅ |
| 220 | + ((whiskering_left _ _ E).obj (costructured_arrow.proj F X)) ⋙ colim := |
| 221 | +nat_iso.of_components (λ G, colim.map_iso (iso.refl _)) |
| 222 | +begin |
| 223 | + intros G H i, |
| 224 | + ext, |
| 225 | + simp only [functor.comp_map, colimit.ι_desc_assoc, functor.map_iso_refl, evaluation_obj_map, |
| 226 | + whiskering_left_obj_map, category.comp_id, Lan_map_app, category.assoc], |
| 227 | + erw [colimit.ι_pre_assoc (Lan.diagram F H X) (costructured_arrow.map j.hom), |
| 228 | + category.id_comp, category.comp_id, colimit.ι_map], |
| 229 | + cases j, |
| 230 | + cases j_right, |
| 231 | + congr, |
| 232 | + rw [costructured_arrow.map_mk, category.id_comp, costructured_arrow.mk] |
| 233 | +end |
| 234 | + |
| 235 | +/-- |
| 236 | +If `F : C ⥤ D` is a representably flat functor between small categories, then the functor |
| 237 | +`Lan F.op` that takes presheaves over `C` to presheaves over `D` preserves finite limits. |
| 238 | +-/ |
| 239 | +noncomputable |
| 240 | +instance Lan_preserves_finite_limits_of_flat (F : C ⥤ D) [representably_flat F] : |
| 241 | + preserves_finite_limits (Lan F.op : _ ⥤ (Dᵒᵖ ⥤ Type u₁)) := |
| 242 | +⟨λ J _ _, begin |
| 243 | + resetI, |
| 244 | + apply preserves_limits_of_shape_of_evaluation (Lan F.op : (Cᵒᵖ ⥤ Type u₁) ⥤ (Dᵒᵖ ⥤ Type u₁)) J, |
| 245 | + intro K, |
| 246 | + haveI : is_filtered (costructured_arrow F.op K) := |
| 247 | + is_filtered.of_equivalence (structured_arrow_op_equivalence F (unop K)), |
| 248 | + exact preserves_limits_of_shape_of_nat_iso (Lan_evaluation_iso_colim _ _ _).symm |
| 249 | +end⟩ |
| 250 | + |
| 251 | +instance Lan_flat_of_flat (F : C ⥤ D) [representably_flat F] : |
| 252 | + representably_flat (Lan F.op : _ ⥤ (Dᵒᵖ ⥤ Type u₁)) := flat_of_preserves_finite_limits _ |
| 253 | + |
| 254 | +variable [has_finite_limits C] |
| 255 | + |
| 256 | +noncomputable |
| 257 | +instance Lan_preserves_finite_limits_of_preserves_finite_limits (F : C ⥤ D) |
| 258 | + [preserves_finite_limits F] : preserves_finite_limits (Lan F.op : _ ⥤ (Dᵒᵖ ⥤ Type u₁)) := |
| 259 | +begin |
| 260 | + haveI := flat_of_preserves_finite_limits F, |
| 261 | + apply_instance |
| 262 | +end |
| 263 | + |
| 264 | +lemma flat_iff_Lan_flat (F : C ⥤ D) : |
| 265 | + representably_flat F ↔ representably_flat (Lan F.op : _ ⥤ (Dᵒᵖ ⥤ Type u₁)) := |
| 266 | +⟨λ H, by exactI infer_instance, λ H, |
| 267 | +begin |
| 268 | + resetI, |
| 269 | + haveI := preserves_finite_limits_of_flat (Lan F.op : _ ⥤ (Dᵒᵖ ⥤ Type u₁)), |
| 270 | + haveI : preserves_finite_limits F := |
| 271 | + ⟨λ _ _ _, by exactI preserves_limit_of_Lan_presesrves_limit _ _⟩, |
| 272 | + apply flat_of_preserves_finite_limits |
| 273 | +end⟩ |
| 274 | + |
| 275 | +/-- |
| 276 | +If `C` is finitely complete, then `F : C ⥤ D` preserves finite limits iff |
| 277 | +`Lan F.op : (Cᵒᵖ ⥤ Type*) ⥤ (Dᵒᵖ ⥤ Type*)` preserves finite limits. |
| 278 | +-/ |
| 279 | +noncomputable |
| 280 | +def preserves_finite_limits_iff_Lan_preserves_finite_limits (F : C ⥤ D) : |
| 281 | + preserves_finite_limits F ≃ preserves_finite_limits (Lan F.op : _ ⥤ (Dᵒᵖ ⥤ Type u₁)) := |
| 282 | +{ to_fun := λ _, by exactI infer_instance, |
| 283 | + inv_fun := λ _, ⟨λ _ _ _, by exactI preserves_limit_of_Lan_presesrves_limit _ _⟩, |
| 284 | + left_inv := λ x, by { cases x, unfold preserves_finite_limits_of_flat, congr }, |
| 285 | + right_inv := λ x, |
| 286 | + begin |
| 287 | + cases x, |
| 288 | + unfold preserves_finite_limits_of_flat, |
| 289 | + congr, |
| 290 | + unfold category_theory.Lan_preserves_finite_limits_of_preserves_finite_limits |
| 291 | + category_theory.Lan_preserves_finite_limits_of_flat, congr |
| 292 | + end } |
| 293 | + |
| 294 | +end small_category |
| 295 | +end category_theory |
0 commit comments