|
| 1 | +/- |
| 2 | +Copyright (c) 2018 Scott Morrison. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Scott Morrison, Johannes Hölzl, Reid Barton, Sean Leather |
| 5 | +
|
| 6 | +Bundled type and structure. |
| 7 | +-/ |
| 8 | +import category_theory.functor |
| 9 | +import category_theory.types |
| 10 | + |
| 11 | +universes u v |
| 12 | + |
| 13 | +namespace category_theory |
| 14 | +variables {c d : Type u → Type v} {α : Type u} |
| 15 | + |
| 16 | +/-- |
| 17 | +`concrete_category @hom` collects the evidence that a type constructor `c` and a |
| 18 | +morphism predicate `hom` can be thought of as a concrete category. |
| 19 | +
|
| 20 | +In a typical example, `c` is the type class `topological_space` and `hom` is |
| 21 | +`continuous`. |
| 22 | +-/ |
| 23 | +structure concrete_category (hom : out_param $ ∀ {α β}, c α → c β → (α → β) → Prop) := |
| 24 | +(hom_id : ∀ {α} (ia : c α), hom ia ia id) |
| 25 | +(hom_comp : ∀ {α β γ} (ia : c α) (ib : c β) (ic : c γ) {f g}, hom ia ib f → hom ib ic g → hom ia ic (g ∘ f)) |
| 26 | + |
| 27 | +attribute [class] concrete_category |
| 28 | + |
| 29 | +/-- `bundled` is a type bundled with a type class instance for that type. Only |
| 30 | +the type class is exposed as a parameter. -/ |
| 31 | +structure bundled (c : Type u → Type v) : Type (max (u+1) v) := |
| 32 | +(α : Type u) |
| 33 | +(str : c α) |
| 34 | + |
| 35 | +def mk_ob {c : Type u → Type v} (α : Type u) [str : c α] : bundled c := ⟨α, str⟩ |
| 36 | + |
| 37 | +namespace bundled |
| 38 | + |
| 39 | +instance : has_coe_to_sort (bundled c) := |
| 40 | +{ S := Type u, coe := bundled.α } |
| 41 | + |
| 42 | +/-- Map over the bundled structure -/ |
| 43 | +def map (f : ∀ {α}, c α → d α) (b : bundled c) : bundled d := |
| 44 | +⟨b.α, f b.str⟩ |
| 45 | + |
| 46 | +section concrete_category |
| 47 | +variables (hom : ∀ {α β : Type u}, c α → c β → (α → β) → Prop) |
| 48 | +variables [h : concrete_category @hom] |
| 49 | +include h |
| 50 | + |
| 51 | +instance : category (bundled c) := |
| 52 | +{ hom := λ a b, subtype (hom a.2 b.2), |
| 53 | + id := λ a, ⟨@id a.1, h.hom_id a.2⟩, |
| 54 | + comp := λ a b c f g, ⟨g.1 ∘ f.1, h.hom_comp a.2 b.2 c.2 f.2 g.2⟩ } |
| 55 | + |
| 56 | +variables {X Y Z : bundled c} |
| 57 | + |
| 58 | +@[simp] lemma concrete_category_id (X : bundled c) : subtype.val (𝟙 X) = id := |
| 59 | +rfl |
| 60 | + |
| 61 | +@[simp] lemma concrete_category_comp (f : X ⟶ Y) (g : Y ⟶ Z) : |
| 62 | + subtype.val (f ≫ g) = g.val ∘ f.val := |
| 63 | +rfl |
| 64 | + |
| 65 | +instance : has_coe_to_fun (X ⟶ Y) := |
| 66 | +{ F := λ f, X → Y, |
| 67 | + coe := λ f, f.1 } |
| 68 | + |
| 69 | +@[simp] lemma bundled_hom_coe {X Y : bundled c} (val : X → Y) (prop) (x : X) : |
| 70 | + (⟨val, prop⟩ : X ⟶ Y) x = val x := rfl |
| 71 | + |
| 72 | +end concrete_category |
| 73 | + |
| 74 | +end bundled |
| 75 | + |
| 76 | +def concrete_functor |
| 77 | + {C : Type u → Type v} {hC : ∀{α β}, C α → C β → (α → β) → Prop} [concrete_category @hC] |
| 78 | + {D : Type u → Type v} {hD : ∀{α β}, D α → D β → (α → β) → Prop} [concrete_category @hD] |
| 79 | + (m : ∀{α}, C α → D α) (h : ∀{α β} {ia : C α} {ib : C β} {f}, hC ia ib f → hD (m ia) (m ib) f) : |
| 80 | + bundled C ⥤ bundled D := |
| 81 | +{ obj := bundled.map @m, |
| 82 | + map := λ X Y f, ⟨ f, h f.2 ⟩} |
| 83 | + |
| 84 | +section forget |
| 85 | +variables {C : Type u → Type v} {hom : ∀α β, C α → C β → (α → β) → Prop} [i : concrete_category hom] |
| 86 | +include i |
| 87 | + |
| 88 | +/-- The forgetful functor from a bundled category to `Type`. -/ |
| 89 | +def forget : bundled C ⥤ Type u := { obj := bundled.α, map := λa b h, h.1 } |
| 90 | + |
| 91 | +instance forget.faithful : faithful (forget : bundled C ⥤ Type u) := {} |
| 92 | + |
| 93 | +end forget |
| 94 | + |
| 95 | +end category_theory |
0 commit comments