|
| 1 | +import CategoryTheoryInContextLean.Section_1_1 |
| 2 | +import CategoryTheoryInContextLean.Section_1_2 |
| 3 | +import CategoryTheoryInContextLean.Section_1_3 |
| 4 | + |
| 5 | +/-! |
| 6 | +# Category Theory in Context - Section 1.4 |
| 7 | +
|
| 8 | +We introduce natural transformations. |
| 9 | +
|
| 10 | +We continue to use the custom definition of a category, functor, etc, from Chapter 1. |
| 11 | +-/ |
| 12 | + |
| 13 | +namespace CategoryInContext |
| 14 | +open Category |
| 15 | + |
| 16 | +-- definition 1.4.1 |
| 17 | +class NaturalTransformation {α β : Type*} [C : Category α] [D : Category β] |
| 18 | + (F G : Functor α β) where |
| 19 | + arrow : (X : α) → D.Hom (F.F X) (G.F X) |
| 20 | + naturality : ∀ {X Y : α} (f : C.Hom X Y), |
| 21 | + arrow X ≫ G.homF f = F.homF f ≫ arrow Y |
| 22 | + |
| 23 | +def IsNatIso {α β : Type*} [C : Category α] [D : Category β] |
| 24 | + {F G : Functor α β} (η : NaturalTransformation F G) : Prop := |
| 25 | + ∀ (X : α), IsIso (η.arrow X) |
| 26 | + |
| 27 | +-- example 1.4.3iii |
| 28 | +def NatTrans_Id_PowerSet : NaturalTransformation IdFunctor PowerSetFunctor where |
| 29 | + arrow X := fun x => ({x} : Set X) |
| 30 | + naturality {X Y} f := by |
| 31 | + funext x |
| 32 | + simp only [Category.comp, Function.comp_apply, IdFunctor, PowerSetFunctor] |
| 33 | + rw [Set.image] |
| 34 | + simp |
| 35 | + |
| 36 | +-- todo: add more examples from 1.4.3 |
| 37 | +-- todo: add examples 1.4.4-6 |
| 38 | + |
| 39 | +-- example 1.4.7 |
| 40 | +def NatTrans_Hom_c_?_Hom_?_c {α : Type*} [C : Category α] (c d : α) (h : Hom c d) : |
| 41 | + NaturalTransformation (Hom_c_? d) (Hom_c_? c) where |
| 42 | + arrow X := fun f => h ≫ f |
| 43 | + naturality {X Y} f := by |
| 44 | + funext g |
| 45 | + simp only [Category.comp, Function.comp_apply, Hom_c_?] |
| 46 | + rw [assoc] |
| 47 | + |
| 48 | +-- technically we haven't defined natural transformations for contravariant functors. |
| 49 | +-- def NatTrans_Hom_?_c_Hom_c_? {α : Type*} [C : Category α] (c d : α) (h : Hom c d) : |
| 50 | +-- NaturalTransformation (Hom_?_c d) (Hom_?_c c) where |
| 51 | + |
| 52 | +-- todo: add example 1.4.8 |
| 53 | +-- exercise 1.4.i |
| 54 | +noncomputable def NatIso_inverse {α β : Type*} [C : Category α] [D : Category β] |
| 55 | + {F G : Functor α β} (η : NaturalTransformation F G) (h : IsNatIso η) : |
| 56 | + NaturalTransformation G F where |
| 57 | + arrow X := by |
| 58 | + have := h X |
| 59 | + rw [iso_iff_isIso] at this |
| 60 | + choose f hf using this |
| 61 | + exact f.inv |
| 62 | + |
| 63 | + naturality {X Y} f := by |
| 64 | + sorry |
| 65 | + |
| 66 | +theorem NatIso_inverse_isNatIso {α β : Type*} [C : Category α] [D : Category β] |
| 67 | + {F G : Functor α β} (η : NaturalTransformation F G) (h : IsNatIso η) : |
| 68 | + IsNatIso (NatIso_inverse η h) := by sorry |
| 69 | + |
| 70 | +-- todo: exercise 1.4.ii, iii - are "what" problems formalizable in Lean? |
| 71 | + |
| 72 | +-- exercise 1.4.iv |
| 73 | +theorem NatTrans_Hom_c_?_Hom_?_c_distinct {α : Type*} [C : Category α] (c d : α) |
| 74 | + (h1 h2 : Hom c d) (h : h1 ≠ h2) : |
| 75 | + NatTrans_Hom_c_?_Hom_?_c c d h1 ≠ NatTrans_Hom_c_?_Hom_?_c c d h2 := by sorry |
| 76 | + |
| 77 | +-- exercise 1.4.v |
| 78 | +-- Natural transformation from G ∘ π₂ to F ∘ π₁ for comma category (F ↓ G) |
| 79 | +def Comma_NatTrans {C D E : Type*} [CC : Category C] [CD : Category D] [CE : Category E] |
| 80 | + (F : Functor D C) (G : Functor E C) : |
| 81 | + let CommaType := Σ (d : D) (e : E), Category.Hom (F.F d) (G.F e) |
| 82 | + letI : Category CommaType := Comma_category F G |
| 83 | + NaturalTransformation |
| 84 | + (Functor.comp (Comma_category_cod F G) G) |
| 85 | + (Functor.comp (Comma_category_dom F G) F) where |
| 86 | + arrow X := sorry |
| 87 | + naturality {X Y} f := by sorry |
| 88 | + |
| 89 | +-- exercise 1.4.vi |
| 90 | +class ExtraNatrualTransformation {α β γ δ : Type*} [Category α] [Category β] [Category γ] |
| 91 | + [Category δ] (F : Functor (α × β × Opposite β) δ) (G : Functor (α × γ × Opposite γ) δ) where |
| 92 | + |
| 93 | + arrow : (a : α) → (b : β) → (c : γ) → Hom (F.F (a, b, b)) (G.F (a, c, c)) |
| 94 | + |
| 95 | + lhs_prop {a a': α} {b : β} {c: γ} (f: Hom a a') : |
| 96 | + (arrow a b c) ≫ G.homF (f, id c, id c) = F.homF (f, id b, id b) ≫ (arrow a' b c) |
| 97 | + |
| 98 | + -- type cast needed to avoid a mysterious error |
| 99 | + mid_prop {a : α} {b b' : β} {c : γ} (g : Hom b b') : |
| 100 | + F.homF (id a, g, id b') ≫ (arrow a b' c) = F.homF ((id a, id b, g) : |
| 101 | + @Category.Hom (α × β × Opposite β) _ (a, b, b') (a, b, b)) ≫ (arrow a b c) |
| 102 | + |
| 103 | + -- type cast needed to avoid a mysterious error |
| 104 | + rhs_prop {a : α} {b : β} {c c' : γ} (h : Hom c c') : |
| 105 | + arrow a b c ≫ G.homF (id a, h, id c) = arrow a b c' ≫ G.homF ((id a, id c', h) : |
| 106 | + @Category.Hom (α × γ × Opposite γ) _ (a, c', c') (a, c', c)) |
| 107 | + |
| 108 | +end CategoryInContext |
0 commit comments