|
| 1 | +{-# OPTIONS --without-K --safe #-} |
| 2 | + |
| 3 | +module Categories.Bicategory.Construction.Spans.Properties where |
| 4 | + |
| 5 | +open import Level |
| 6 | + |
| 7 | +open import Data.Product using (_,_; _×_) |
| 8 | +open import Relation.Binary.Bundles using (Setoid) |
| 9 | +import Relation.Binary.Reasoning.Setoid as SR |
| 10 | +open import Function.Equality as SΠ renaming (id to ⟶-id) |
| 11 | + |
| 12 | +open import Categories.Category |
| 13 | +open import Categories.Category.Helper |
| 14 | +open import Categories.Category.Instance.Setoids |
| 15 | +open import Categories.Category.Instance.Properties.Setoids.Limits.Canonical |
| 16 | + |
| 17 | +open import Categories.Diagram.Pullback |
| 18 | + |
| 19 | +open import Categories.Bicategory |
| 20 | +open import Categories.Bicategory.Monad |
| 21 | + |
| 22 | +import Categories.Category.Diagram.Span as Span |
| 23 | +import Categories.Bicategory.Construction.Spans as Spans |
| 24 | + |
| 25 | +-------------------------------------------------------------------------------- |
| 26 | +-- Monads in the Bicategory of Spans are Categories |
| 27 | + |
| 28 | +module _ {o ℓ : Level} (T : Monad (Spans.Spans (pullback o ℓ))) where |
| 29 | + |
| 30 | + private |
| 31 | + module T = Monad T |
| 32 | + |
| 33 | + open Span (Setoids (o ⊔ ℓ) ℓ) |
| 34 | + open Spans (pullback o ℓ) |
| 35 | + open Span⇒ |
| 36 | + open Bicategory Spans |
| 37 | + |
| 38 | + open Setoid renaming (_≈_ to [_][_≈_]) |
| 39 | + |
| 40 | + |
| 41 | + -- We can view the roof of the span as a hom set! However, we need to partition |
| 42 | + -- this big set up into small chunks with known domains/codomains. |
| 43 | + record Hom (X Y : Carrier T.C) : Set (o ⊔ ℓ) where |
| 44 | + field |
| 45 | + hom : Carrier (Span.M T.T) |
| 46 | + dom-eq : [ T.C ][ Span.dom T.T ⟨$⟩ hom ≈ X ] |
| 47 | + cod-eq : [ T.C ][ Span.cod T.T ⟨$⟩ hom ≈ Y ] |
| 48 | + |
| 49 | + open Hom |
| 50 | + |
| 51 | + private |
| 52 | + ObjSetoid : Setoid (o ⊔ ℓ) ℓ |
| 53 | + ObjSetoid = T.C |
| 54 | + |
| 55 | + HomSetoid : Setoid (o ⊔ ℓ) ℓ |
| 56 | + HomSetoid = Span.M T.T |
| 57 | + |
| 58 | + module ObjSetoid = Setoid ObjSetoid |
| 59 | + module HomSetoid = Setoid HomSetoid |
| 60 | + |
| 61 | + id⇒ : (X : Carrier T.C) → Hom X X |
| 62 | + id⇒ X = record |
| 63 | + { hom = arr T.η ⟨$⟩ X |
| 64 | + ; dom-eq = commute-dom T.η (refl T.C) |
| 65 | + ; cod-eq = commute-cod T.η (refl T.C) |
| 66 | + } |
| 67 | + |
| 68 | + _×ₚ_ : ∀ {A B C} → (f : Hom B C) → (g : Hom A B) → FiberProduct (Span.cod T.T) (Span.dom T.T) |
| 69 | + _×ₚ_ {B = B} f g = record |
| 70 | + { elem₁ = hom g |
| 71 | + ; elem₂ = hom f |
| 72 | + ; commute = begin |
| 73 | + Span.cod T.T ⟨$⟩ hom g ≈⟨ cod-eq g ⟩ |
| 74 | + B ≈⟨ ObjSetoid.sym (dom-eq f) ⟩ |
| 75 | + Span.dom T.T ⟨$⟩ hom f ∎ |
| 76 | + } |
| 77 | + where |
| 78 | + open SR ObjSetoid |
| 79 | + |
| 80 | + _∘⇒_ : ∀ {A B C} (f : Hom B C) → (g : Hom A B) → Hom A C |
| 81 | + _∘⇒_ {A = A} {C = C} f g = record |
| 82 | + { hom = arr T.μ ⟨$⟩ (f ×ₚ g) |
| 83 | + ; dom-eq = begin |
| 84 | + Span.dom T.T ⟨$⟩ (arr T.μ ⟨$⟩ (f ×ₚ g)) ≈⟨ (commute-dom T.μ {f ×ₚ g} {f ×ₚ g} (HomSetoid.refl , HomSetoid.refl)) ⟩ |
| 85 | + Span.dom T.T ⟨$⟩ hom g ≈⟨ dom-eq g ⟩ |
| 86 | + A ∎ |
| 87 | + ; cod-eq = begin |
| 88 | + Span.cod T.T ⟨$⟩ (arr T.μ ⟨$⟩ (f ×ₚ g)) ≈⟨ commute-cod T.μ {f ×ₚ g} {f ×ₚ g} (HomSetoid.refl , HomSetoid.refl) ⟩ |
| 89 | + Span.cod T.T ⟨$⟩ hom f ≈⟨ cod-eq f ⟩ |
| 90 | + C ∎ |
| 91 | + } |
| 92 | + where |
| 93 | + open SR ObjSetoid |
| 94 | + |
| 95 | + SpanMonad⇒Category : Category (o ⊔ ℓ) (o ⊔ ℓ) ℓ |
| 96 | + SpanMonad⇒Category = categoryHelper record |
| 97 | + { Obj = Setoid.Carrier T.C |
| 98 | + ; _⇒_ = Hom |
| 99 | + ; _≈_ = λ f g → [ HomSetoid ][ hom f ≈ hom g ] |
| 100 | + ; id = λ {X} → id⇒ X |
| 101 | + ; _∘_ = _∘⇒_ |
| 102 | + ; assoc = λ {A} {B} {C} {D} {f} {g} {h} → |
| 103 | + let f×ₚ⟨g×ₚh⟩ = record |
| 104 | + { elem₁ = record |
| 105 | + { elem₁ = hom f |
| 106 | + ; elem₂ = hom g |
| 107 | + ; commute = FiberProduct.commute (g ×ₚ f) |
| 108 | + } |
| 109 | + ; elem₂ = hom h |
| 110 | + ; commute = FiberProduct.commute (h ×ₚ g) |
| 111 | + } |
| 112 | + in begin |
| 113 | + arr T.μ ⟨$⟩ ((h ∘⇒ g) ×ₚ f) ≈⟨ cong (arr T.μ) (HomSetoid.refl , cong (arr T.μ) (HomSetoid.refl , HomSetoid.refl)) ⟩ |
| 114 | + arr T.μ ⟨$⟩ _ ≈⟨ T.sym-assoc {f×ₚ⟨g×ₚh⟩} {f×ₚ⟨g×ₚh⟩} ((HomSetoid.refl , HomSetoid.refl) , HomSetoid.refl) ⟩ |
| 115 | + arr T.μ ⟨$⟩ _ ≈⟨ (cong (arr T.μ) (cong (arr T.μ) (HomSetoid.refl , HomSetoid.refl) , HomSetoid.refl)) ⟩ |
| 116 | + arr T.μ ⟨$⟩ (h ×ₚ (g ∘⇒ f)) ∎ |
| 117 | + ; identityˡ = λ {A} {B} {f} → begin |
| 118 | + arr T.μ ⟨$⟩ (id⇒ B ×ₚ f) ≈⟨ cong (arr T.μ) (HomSetoid.refl , cong (arr T.η) (ObjSetoid.sym (cod-eq f))) ⟩ |
| 119 | + arr T.μ ⟨$⟩ _ ≈⟨ T.identityʳ HomSetoid.refl ⟩ |
| 120 | + hom f ∎ |
| 121 | + ; identityʳ = λ {A} {B} {f} → begin |
| 122 | + arr T.μ ⟨$⟩ (f ×ₚ id⇒ A) ≈⟨ cong (arr T.μ) (cong (arr T.η) (ObjSetoid.sym (dom-eq f)) , HomSetoid.refl) ⟩ |
| 123 | + arr T.μ ⟨$⟩ _ ≈⟨ T.identityˡ HomSetoid.refl ⟩ |
| 124 | + hom f ∎ |
| 125 | + ; equiv = record |
| 126 | + { refl = HomSetoid.refl |
| 127 | + ; sym = HomSetoid.sym |
| 128 | + ; trans = HomSetoid.trans |
| 129 | + } |
| 130 | + ; ∘-resp-≈ = λ f≈h g≈i → cong (arr T.μ) (g≈i , f≈h) |
| 131 | + } |
| 132 | + where |
| 133 | + open SR HomSetoid |
0 commit comments