|
| 1 | +import CategoryTheoryInContextLean.Section_1_1 |
| 2 | +import CategoryTheoryInContextLean.Section_1_2 |
| 3 | + |
| 4 | +/-! |
| 5 | +# Category Theory in Context - Section 1.3 |
| 6 | +
|
| 7 | +We introduce functors |
| 8 | +
|
| 9 | +-/ |
| 10 | + |
| 11 | +namespace CategoryInContext |
| 12 | + |
| 13 | +open Category |
| 14 | + |
| 15 | +-- definition 1.3.1 |
| 16 | +class Functor (α β : Type*) [C : Category α] [D : Category β] where |
| 17 | + -- data |
| 18 | + -- map on objects |
| 19 | + F : α → β |
| 20 | + -- map on morphisms |
| 21 | + homF {X Y : α} : C.Hom X Y → D.Hom (F X) (F Y) |
| 22 | + -- properties / laws |
| 23 | + -- need to qualify id to avoid clash with id in root namespace. |
| 24 | + map_id (X : α) : homF (id X) = Category.id (F X) |
| 25 | + map_comp {X Y Z : α} (f : C.Hom X Y) (g : C.Hom Y Z) : |
| 26 | + homF (f ≫ g) = homF f ≫ homF g |
| 27 | + |
| 28 | +def EndoFunctor (α : Type*) [Category α] := @Functor α α |
| 29 | + |
| 30 | +variable {α : Type*} [C : Category α] |
| 31 | + |
| 32 | +-- examples 1.3.2.i |
| 33 | +def PowerSetFunctor (α : Type*) : Functor (Set α) (Set (Set α)) where |
| 34 | + F X := Set.powerset X |
| 35 | + homF f := sorry -- should be Set.image f but it doesn't work for some reason |
| 36 | + map_id X := by sorry |
| 37 | + map_comp f g := by sorry |
| 38 | + |
| 39 | +-- todo: add 1.3.2.ii-xi, once we have appropriate categories defined |
| 40 | +-- todo: add theorem 1.3.3 |
| 41 | + |
| 42 | +-- definition 1.3.5 |
| 43 | +class ContraFunctor (α β : Type*) [C : Category α] [D : Category β] where |
| 44 | + -- data |
| 45 | + -- map on objects |
| 46 | + F : α → β |
| 47 | + -- map on morphisms |
| 48 | + homF {X Y : α} : C.Hom X Y → D.Hom (F Y) (F X) |
| 49 | + -- properties / laws |
| 50 | + -- need to qualify id to avoid clash with id in root namespace. |
| 51 | + map_id (X : α) : homF (id X) = Category.id (F X) |
| 52 | + map_comp {X Y Z : α} (f : C.Hom X Y) (g : C.Hom Y Z) : |
| 53 | + homF (f ≫ g) = homF g ≫ homF f |
| 54 | + |
| 55 | +-- example 1.3.7.i |
| 56 | +def PowerSetContraFunctor (α : Type*) : ContraFunctor (Set α) (Set (Set α)) where |
| 57 | + F X := Set.powerset X |
| 58 | + homF f := sorry -- should be Set.preimage f but it doesn't work for some reason |
| 59 | + map_id X := by sorry |
| 60 | + map_comp f g := by sorry |
| 61 | + |
| 62 | +-- todo: add 1.3.7.ii-vi, once we have appropriate categories defined |
| 63 | + |
| 64 | +-- lemma 1.3.8 |
| 65 | +theorem Functor.iso_preserve {α β : Type*} [C : Category α] [D : Category β] |
| 66 | + (F : Functor α β) {X Y : α} (f : C.Hom X Y) (hf : IsIso f) : |
| 67 | + IsIso (F.homF f) := by |
| 68 | + rw [iso_iff_isIso] at hf |
| 69 | + obtain ⟨⟨f, g, hg, hf⟩, rfl⟩ := hf |
| 70 | + use F.homF g |
| 71 | + simp only |
| 72 | + constructor |
| 73 | + · rw [← F.map_comp] |
| 74 | + rw [hg] |
| 75 | + rw [F.map_id] |
| 76 | + · rw [← F.map_comp] |
| 77 | + rw [hf] |
| 78 | + rw [F.map_id] |
| 79 | + |
| 80 | +-- example 1.3.9 |
| 81 | +def Gset (α : Type*) [Group α] (β : Type*) : @Functor Unit (Set β) (Category.Monoid α) _ := by sorry |
| 82 | + |
| 83 | +end CategoryInContext |
0 commit comments