-
Notifications
You must be signed in to change notification settings - Fork 0
/
Groupoid.agda
150 lines (121 loc) Β· 5.4 KB
/
Groupoid.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{-# OPTIONS --cubical #-}
module Groupoid where
open import Prelude
private
variable
π π : Level
A : Set π
B : A β Set π
a b c d x y : A
sym : a β‘ b β b β‘ a
sym p = Ξ» i β p (~ i)
infix 6 _β»ΒΉ
_β»ΒΉ = sym
-- a β β β > d
-- ^ ^
-- pβ»ΒΉ | | r
-- | |
-- b - - - > c
-- q
_ββ_ββ_ : a β‘ b β b β‘ c β c β‘ d β a β‘ d
p ββ q ββ r = Ξ» i β hcomp (Ξ» j β Ξ» { (i = i0) β p (~ j)
; (i = i1) β r j })
(q i)
_ββ_ββ_ : (p : a β‘ b) (q : b β‘ c) (r : c β‘ d)
β q β‘ p ββ q ββ r [ (Ξ» j β p (~ j) β‘ r j) ]
p ββ q ββ r = Ξ» j i β hfill (Ξ» j β Ξ» { (i = i0) β p (~ j)
; (i = i1) β r j })
(inS (q i)) j
infixr 5 _β_
_β_ : a β‘ b β b β‘ c β a β‘ c
p β q = refl ββ p ββ q
module β‘-Reasoning where
infix 1 begin_
infixr 2 _β‘β¨_β©_
infix 3 _β
begin_ : a β‘ b β a β‘ b
begin p = p
_β‘β¨_β©_ : a β a β‘ b β b β‘ c β a β‘ c
a β‘β¨ p β© q = p β q
_β : (a : A) β a β‘ a
a β = refl
cong : (f : (x : A) β B x)
(p : x β‘ y)
β -----------------------------
f x β‘ f y [ B β p ]
cong f p = Ξ» i β f (p i)
{-# INLINE cong #-}
infixl 4 _<$>_
_<$>_ = cong
infixl 4 _<*>_
_<*>_ : {f g : (x : A) β B x}
(p : f β‘ g)
(q : x β‘ y)
β -----------------------------
f x β‘ g y [ B β q ]
p <*> q = Ξ» i β p i (q i)
transport : β {β} {A B : Set β} β A β‘ B β A β B
transport p a = transp (Ξ» i β p i) i0 a
subst : (B : A β Set π) β x β‘ y β B x β B y
subst P p u = transport (cong P p) u
infix 4 _βΌ_
_βΌ_ : β {π π} {A : Set π} {B : A β Set π} (f g : (x : A) β B x) β Set (π β π)
f βΌ g = β x β f x β‘ g x
funext : {f : (x : A) β B x}
{g : (x : A) β B x}
β f βΌ g
β f β‘ g
funext p i x = p x i
β»ΒΉ-involutive : (p : a β‘ b) β p β»ΒΉ β»ΒΉ β‘ p
β»ΒΉ-involutive p = refl
β-unitΛ‘ : (p : a β‘ b) β refl β p β‘ p
β-unitΛ‘ {a = a} {b = b} p = Ξ» j i β hcomp (Ξ» k β Ξ» { (i = i0) β a
; (i = i1) β p (j β¨ k)
; (j = i0) β (refl ββ refl ββ p) k i
; (j = i1) β p i })
(p (i β§ j))
-- β-unitΚ³ : (p : a β‘ b) β p β refl β‘ p
-- β-unitΚ³ {a = a} {b = b} p = sym (refl ββ p ββ refl)
β-unitΚ³ : (p : a β‘ b) β p β refl β‘ p
β-unitΚ³ {a = a} {b = b} p = Ξ» j i β hcomp (Ξ» k β Ξ» { (i = i0) β a
; (i = i1) β b
; (j = i0) β (refl ββ p ββ refl) k i
; (j = i1) β p i })
(p i)
β»ΒΉ-unit : reflβ a β β»ΒΉ β‘ refl
β»ΒΉ-unit {a = a} = Ξ» j i β a
β-invΛ‘ : (p : a β‘ b) β p β»ΒΉ β p β‘ refl
β-invΛ‘ {a = a} {b = b} p = Ξ» j i β hcomp (Ξ» k β Ξ» { (i = i0) β b
; (i = i1) β p (j β¨ k)
; (j = i0) β (refl ββ p β»ΒΉ ββ p) k i
; (j = i1) β b })
(p (~ i β¨ j))
β-invΛ‘β² : (p : a β‘ b) β p β»ΒΉ β p β‘ refl
β-invΛ‘β² {a = a} {b = b} p = Ξ» j i β hcomp (Ξ» k β Ξ» { (i = i0) β b
; (i = i1) β p k
; (j = i0) β (refl ββ p β»ΒΉ ββ p) k i
; (j = i1) β p (~ i β¨ k) })
(p (~ i))
β-invΚ³ : (p : a β‘ b) β p β p β»ΒΉ β‘ refl
β-invΚ³ {a = a} {b = b} p = β-invΛ‘ (p β»ΒΉ)
3-out-of-4 : (left : a β‘ b) (bottom : b β‘ c) (right : c β‘ d) {topβ topβ : a β‘ d}
(squareβ : bottom β‘ topβ [ (Ξ» j β left (~ j) β‘ right j) ])
(squareβ : bottom β‘ topβ [ (Ξ» j β left (~ j) β‘ right j) ])
β topβ β‘ topβ
3-out-of-4 p q r squareβ squareβ =
Ξ» j i β hcomp (Ξ» k β Ξ» { (i = i0) β p (~ k)
; (i = i1) β r k
; (j = i0) β squareβ k i
; (j = i1) β squareβ k i })
(q i)
β-assoc : (p : a β‘ b) (q : b β‘ c) (r : c β‘ d)
β (p β q) β r β‘ p β (q β r)
β-assoc {a = a} p q r = 3-out-of-4 refl p (q β r) squareβ squareβ
where squareβ : p β‘ (p β q) β r [ (Ξ» j β a β‘ (q β r) j) ]
squareβ = Ξ» j i β hcomp (Ξ» k β Ξ» { (i = i0) β a
; (i = i1) β (refl ββ q ββ r) k j
; (j = i0) β p i
; (j = i1) β (refl ββ p β q ββ r) k i })
((refl ββ p ββ q) j i)
squareβ : p β‘ p β (q β r) [ (Ξ» j β a β‘ (q β r) j) ]
squareβ = refl ββ p ββ (q β r)