File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ module Week8 where
2+
3+ ---------------------------------------------------------------------------
4+ -- Monoids
5+ ---------------------------------------------------------------------------
6+
7+ -- Remember categories? A category is a fancy monoid:
8+ -- - It has a type of objects
9+ -- - It has a type of morphism with a source & target object
10+ -- - For each object, it has a unit morphism from the object to itself
11+ -- - It has a way to combine two morphisms
12+ -- (provided the target of one is the source of the other)
13+ -- - Combining morphisms is associative
14+
15+
16+ open import Relation.Binary.PropositionalEquality
17+ using (_≡_; refl; cong; sym; module ≡-Reasoning )
18+
19+ open import Week7 hiding (Category)
20+
21+ ---------------------------------------------------------------------------
22+ -- Category
23+ ---------------------------------------------------------------------------
24+
25+ record Category : Set₁ where
26+ field
27+ -- Type and operations
28+ Object : Set
29+ Morphism : (source target : Object) → Set
30+ _then_ : ∀ {s m t} → Morphism s m → Morphism m t → Morphism s t
31+ identity : ∀ {s} → Morphism s s
32+
33+ field
34+ then-assoc : ∀ {s m₁ m₂ t} (x : Morphism s m₁) (y : Morphism m₁ m₂) (z : Morphism m₂ t)
35+ → ((x then y) then z) ≡ (x then (y then z))
36+
37+ then-identity : ∀ {s t} (x : Morphism s t) → (x then identity) ≡ x
38+ identity-then : ∀ {s t} (x : Morphism s t) → (identity then x) ≡ x
39+
40+ open Category
41+
42+ -- Our favourite categories
43+
44+ -- Squish but for categories!
45+
46+ -- Proof by reflection
You can’t perform that action at this time.
0 commit comments