|
| 1 | +/- |
| 2 | +Copyright (c) 2021 Scott Morrison. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Scott Morrison |
| 5 | +
|
| 6 | +! This file was ported from Lean 3 source module category_theory.category.Quiv |
| 7 | +! leanprover-community/mathlib commit 350a381705199e9a070f84e98e803c3c25a97a4c |
| 8 | +! Please do not edit these lines, except to modify the commit id |
| 9 | +! if you have ported upstream changes. |
| 10 | +-/ |
| 11 | +import Mathlib.CategoryTheory.Adjunction.Basic |
| 12 | +import Mathlib.CategoryTheory.Category.Cat |
| 13 | +import Mathlib.CategoryTheory.PathCategory |
| 14 | + |
| 15 | +/-! |
| 16 | +# The category of quivers |
| 17 | +
|
| 18 | +The category of (bundled) quivers, and the free/forgetful adjunction between `Cat` and `QuivCat`. |
| 19 | +
|
| 20 | +-/ |
| 21 | + |
| 22 | + |
| 23 | +universe v u |
| 24 | + |
| 25 | +namespace CategoryTheory |
| 26 | + |
| 27 | +-- intended to be used with explicit universe parameters |
| 28 | +/-- Category of quivers. -/ |
| 29 | +@[nolint checkUnivs] |
| 30 | +def QuivCat := |
| 31 | + Bundled Quiver.{v + 1, u} |
| 32 | +set_option linter.uppercaseLean3 false in |
| 33 | +#align category_theory.Quiv CategoryTheory.QuivCat |
| 34 | + |
| 35 | +namespace QuivCat |
| 36 | + |
| 37 | +instance : CoeSort QuivCat (Type u) where coe := Bundled.α |
| 38 | + |
| 39 | +instance str' (C : QuivCat.{v, u}) : Quiver.{v + 1, u} C := |
| 40 | + C.str |
| 41 | +set_option linter.uppercaseLean3 false in |
| 42 | +#align category_theory.Quiv.str CategoryTheory.QuivCat.str' |
| 43 | + |
| 44 | +/-- Construct a bundled `QuivCat` from the underlying type and the typeclass. -/ |
| 45 | +def of (C : Type u) [Quiver.{v + 1} C] : QuivCat.{v, u} := |
| 46 | + Bundled.of C |
| 47 | +set_option linter.uppercaseLean3 false in |
| 48 | +#align category_theory.Quiv.of CategoryTheory.QuivCat.of |
| 49 | + |
| 50 | +instance : Inhabited QuivCat := |
| 51 | + ⟨QuivCat.of (Quiver.Empty PEmpty)⟩ |
| 52 | + |
| 53 | +/-- Category structure on `QuivCat` -/ |
| 54 | +instance category : LargeCategory.{max v u} QuivCat.{v, u} |
| 55 | + where |
| 56 | + Hom C D := Prefunctor C D |
| 57 | + id C := Prefunctor.id C |
| 58 | + comp F G := Prefunctor.comp F G |
| 59 | +set_option linter.uppercaseLean3 false in |
| 60 | +#align category_theory.Quiv.category CategoryTheory.QuivCat.category |
| 61 | + |
| 62 | +/-- The forgetful functor from categories to quivers. -/ |
| 63 | +@[simps] |
| 64 | +def forget : Cat.{v, u} ⥤ QuivCat.{v, u} |
| 65 | + where |
| 66 | + obj C := QuivCat.of C |
| 67 | + map F := F.toPrefunctor |
| 68 | +set_option linter.uppercaseLean3 false in |
| 69 | +#align category_theory.Quiv.forget CategoryTheory.QuivCat.forget |
| 70 | + |
| 71 | +end QuivCat |
| 72 | + |
| 73 | +namespace Cat |
| 74 | + |
| 75 | +/-- The functor sending each quiver to its path category. -/ |
| 76 | +@[simps] |
| 77 | +def free : QuivCat.{v, u} ⥤ Cat.{max u v, u} |
| 78 | + where |
| 79 | + obj V := Cat.of (Paths V) |
| 80 | + map F := |
| 81 | + { obj := fun X => F.obj X |
| 82 | + map := fun f => F.mapPath f |
| 83 | + map_comp := fun f g => F.mapPath_comp f g } |
| 84 | + map_id V := by |
| 85 | + change (show Paths V ⥤ _ from _) = _ |
| 86 | + ext |
| 87 | + apply eq_conj_eqToHom |
| 88 | + rfl |
| 89 | + map_comp {U _ _} F G := by |
| 90 | + change (show Paths U ⥤ _ from _) = _ |
| 91 | + ext |
| 92 | + apply eq_conj_eqToHom |
| 93 | + rfl |
| 94 | +set_option linter.uppercaseLean3 false in |
| 95 | +#align category_theory.Cat.free CategoryTheory.Cat.free |
| 96 | + |
| 97 | +end Cat |
| 98 | + |
| 99 | +namespace QuivCat |
| 100 | + |
| 101 | +/-- Any prefunctor into a category lifts to a functor from the path category. -/ |
| 102 | +@[simps] |
| 103 | +def lift {V : Type u} [Quiver.{v + 1} V] {C : Type _} [Category C] (F : Prefunctor V C) : |
| 104 | + Paths V ⥤ C where |
| 105 | + obj X := F.obj X |
| 106 | + map f := composePath (F.mapPath f) |
| 107 | +set_option linter.uppercaseLean3 false in |
| 108 | +#align category_theory.Quiv.lift CategoryTheory.QuivCat.lift |
| 109 | + |
| 110 | +-- We might construct `of_lift_iso_self : Paths.of ⋙ lift F ≅ F` |
| 111 | +-- (and then show that `lift F` is initial amongst such functors) |
| 112 | +-- but it would require lifting quite a bit of machinery to quivers! |
| 113 | +/-- |
| 114 | +The adjunction between forming the free category on a quiver, and forgetting a category to a quiver. |
| 115 | +-/ |
| 116 | +def adj : Cat.free ⊣ QuivCat.forget := |
| 117 | + Adjunction.mkOfHomEquiv |
| 118 | + { homEquiv := fun V C => |
| 119 | + { toFun := fun F => Paths.of.comp F.toPrefunctor |
| 120 | + invFun := fun F => @lift V _ C _ F |
| 121 | + left_inv := fun F => Paths.ext_functor rfl (by simp) |
| 122 | + right_inv := by |
| 123 | + rintro ⟨obj, map⟩ |
| 124 | + dsimp only [Prefunctor.comp] |
| 125 | + congr |
| 126 | + funext X Y f |
| 127 | + exact Category.id_comp _ } |
| 128 | + homEquiv_naturality_left_symm := fun {V _ _} f g => by |
| 129 | + change (show Paths V ⥤ _ from _) = _ |
| 130 | + ext |
| 131 | + apply eq_conj_eqToHom |
| 132 | + rfl } |
| 133 | +set_option linter.uppercaseLean3 false in |
| 134 | +#align category_theory.Quiv.adj CategoryTheory.QuivCat.adj |
| 135 | + |
| 136 | +end QuivCat |
| 137 | + |
| 138 | +end CategoryTheory |
0 commit comments