/
homotopies.lagda.md
383 lines (288 loc) · 10.2 KB
/
homotopies.lagda.md
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# Homotopies
```agda
{-# OPTIONS --safe #-}
module foundation-core.homotopies where
```
<details><summary>Imports</summary>
```agda
open import foundation-core.functions
open import foundation-core.identity-types
open import foundation-core.universe-levels
```
</details>
## Idea
A homotopy of identifications is a pointwise equality between dependent
functions.
## Definitions
```agda
module _
{l1 l2 : Level} {X : UU l1} {P : X → UU l2} (f g : (x : X) → P x)
where
eq-value : X → UU l2
eq-value x = (f x = g x)
map-compute-path-over-eq-value :
{x y : X} (p : x = y) (q : eq-value x) (r : eq-value y) →
((apd f p) ∙ r) = ((ap (tr P p) q) ∙ (apd g p)) → tr eq-value p q = r
map-compute-path-over-eq-value refl q r =
inv ∘ (concat' r (right-unit ∙ ap-id q))
map-compute-path-over-eq-value' :
{l1 l2 : Level} {X : UU l1} {Y : UU l2} (f g : X → Y) →
{x y : X} (p : x = y) (q : eq-value f g x) (r : eq-value f g y) →
(ap f p ∙ r) = (q ∙ ap g p) → tr (eq-value f g) p q = r
map-compute-path-over-eq-value' f g refl q r = inv ∘ concat' r right-unit
map-compute-path-over-eq-value-id-id :
{l1 : Level} {A : UU l1} →
{a b : A} (p : a = b) (q : a = a) (r : b = b) →
(p ∙ r) = (q ∙ p) → (tr (eq-value id id) p q) = r
map-compute-path-over-eq-value-id-id refl q r s = inv (s ∙ right-unit)
```
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2}
where
_~_ : (f g : (x : A) → B x) → UU (l1 ⊔ l2)
f ~ g = (x : A) → eq-value f g x
```
## Properties
### Reflexivity
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2}
where
refl-htpy : {f : (x : A) → B x} → f ~ f
refl-htpy x = refl
refl-htpy' : (f : (x : A) → B x) → f ~ f
refl-htpy' f = refl-htpy
```
### Inverting homotopies
```agda
inv-htpy : {f g : (x : A) → B x} → f ~ g → g ~ f
inv-htpy H x = inv (H x)
```
### Concatenating homotopies
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2}
where
_∙h_ : {f g h : (x : A) → B x} → f ~ g → g ~ h → f ~ h
(H ∙h K) x = (H x) ∙ (K x)
concat-htpy :
{f g : (x : A) → B x} →
f ~ g → (h : (x : A) → B x) → g ~ h → f ~ h
concat-htpy H h K x = concat (H x) (h x) (K x)
concat-htpy' :
(f : (x : A) → B x) {g h : (x : A) → B x} →
g ~ h → f ~ g → f ~ h
concat-htpy' f K H = H ∙h K
concat-inv-htpy :
{f g : (x : A) → B x} →
f ~ g → (h : (x : A) → B x) → f ~ h → g ~ h
concat-inv-htpy = concat-htpy ∘ inv-htpy
concat-inv-htpy' :
(f : (x : A) → B x) {g h : (x : A) → B x} →
(g ~ h) → (f ~ h) → (f ~ g)
concat-inv-htpy' f K = concat-htpy' f (inv-htpy K)
```
### Whiskering of homotopies
```agda
htpy-left-whisk :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
(h : B → C) {f g : A → B} → f ~ g → (h ∘ f) ~ (h ∘ g)
htpy-left-whisk h H x = ap h (H x)
_·l_ = htpy-left-whisk
htpy-right-whisk :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : B → UU l3}
{g h : (y : B) → C y} (H : g ~ h) (f : A → B) → (g ∘ f) ~ (h ∘ f)
htpy-right-whisk H f x = H (f x)
_·r_ = htpy-right-whisk
```
**Note**: The infix whiskering operators `_·l_` and `_·r_` use the
[middle dot](https://codepoints.net/U+00B7) `·` (agda-input: `\cdot`
`\centerdot`), as opposed to the infix homotopy concatenation operator `_∙h_`
which uses the [bullet operator](https://codepoints.net/U+2219) `∙` (agda-input:
`\.`). If these look the same in your editor, we suggest that you change your
font. For a reference, see [How to install](HOWTO-INSTALL.md).
### Horizontal composition of homotopies
```agda
module _
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
{f f' : A → B} {g g' : B → C}
where
htpy-comp-horizontal : (f ~ f') → (g ~ g') → (g ∘ f) ~ (g' ∘ f')
htpy-comp-horizontal F G = (g ·l F) ∙h (G ·r f')
htpy-comp-horizontal' : (f ~ f') → (g ~ g') → (g ∘ f) ~ (g' ∘ f')
htpy-comp-horizontal' F G = (G ·r f) ∙h (g' ·l F)
```
### Transposition of homotopies
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x}
(H : f ~ g) (K : g ~ h) (L : f ~ h) (M : (H ∙h K) ~ L)
where
inv-con-htpy : K ~ ((inv-htpy H) ∙h L)
inv-con-htpy x = inv-con (H x) (K x) (L x) (M x)
inv-htpy-inv-con-htpy : ((inv-htpy H) ∙h L) ~ K
inv-htpy-inv-con-htpy = inv-htpy inv-con-htpy
con-inv-htpy : H ~ (L ∙h (inv-htpy K))
con-inv-htpy x = con-inv (H x) (K x) (L x) (M x)
inv-htpy-con-inv-htpy : (L ∙h (inv-htpy K)) ~ H
inv-htpy-con-inv-htpy = inv-htpy con-inv-htpy
```
### Associativity of concatenation of homotopies
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h k : (x : A) → B x}
(H : f ~ g) (K : g ~ h) (L : h ~ k)
where
assoc-htpy : ((H ∙h K) ∙h L) ~ (H ∙h (K ∙h L))
assoc-htpy x = assoc (H x) (K x) (L x)
inv-htpy-assoc-htpy : (H ∙h (K ∙h L)) ~ ((H ∙h K) ∙h L)
inv-htpy-assoc-htpy = inv-htpy assoc-htpy
```
### Unit laws for homotopies
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2}
{f g : (x : A) → B x} {H : f ~ g}
where
left-unit-htpy : (refl-htpy ∙h H) ~ H
left-unit-htpy x = left-unit
inv-htpy-left-unit-htpy : H ~ (refl-htpy ∙h H)
inv-htpy-left-unit-htpy = inv-htpy left-unit-htpy
right-unit-htpy : (H ∙h refl-htpy) ~ H
right-unit-htpy x = right-unit
inv-htpy-right-unit-htpy : H ~ (H ∙h refl-htpy)
inv-htpy-right-unit-htpy = inv-htpy right-unit-htpy
```
### Inverse laws for homotopies
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2}
{f g : (x : A) → B x} (H : f ~ g)
where
left-inv-htpy : ((inv-htpy H) ∙h H) ~ refl-htpy
left-inv-htpy = left-inv ∘ H
inv-htpy-left-inv-htpy : refl-htpy ~ ((inv-htpy H) ∙h H)
inv-htpy-left-inv-htpy = inv-htpy left-inv-htpy
right-inv-htpy : (H ∙h (inv-htpy H)) ~ refl-htpy
right-inv-htpy = right-inv ∘ H
inv-htpy-right-inv-htpy : refl-htpy ~ (H ∙h (inv-htpy H))
inv-htpy-right-inv-htpy = inv-htpy right-inv-htpy
```
### Distributivity of `inv` over `concat` for homotopies
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x}
(H : f ~ g) (K : g ~ h)
where
distributive-inv-concat-htpy :
(inv-htpy (H ∙h K)) ~ ((inv-htpy K) ∙h (inv-htpy H))
distributive-inv-concat-htpy x = distributive-inv-concat (H x) (K x)
inv-htpy-distributive-inv-concat-htpy :
((inv-htpy K) ∙h (inv-htpy H)) ~ (inv-htpy (H ∙h K))
inv-htpy-distributive-inv-concat-htpy =
inv-htpy distributive-inv-concat-htpy
```
### Naturality of homotopies with respect to identifications
```agda
nat-htpy :
{l1 l2 : Level} {A : UU l1} {B : UU l2} {f g : A → B} (H : f ~ g)
{x y : A} (p : x = y) →
((H x) ∙ (ap g p)) = ((ap f p) ∙ (H y))
nat-htpy H refl = right-unit
inv-nat-htpy :
{l1 l2 : Level} {A : UU l1} {B : UU l2} {f g : A → B} (H : f ~ g)
{x y : A} (p : x = y) →
((ap f p) ∙ (H y)) = ((H x) ∙ (ap g p))
inv-nat-htpy H p = inv (nat-htpy H p)
nat-htpy-id :
{l : Level} {A : UU l} {f : A → A} (H : f ~ id)
{x y : A} (p : x = y) → ((H x) ∙ p) = ((ap f p) ∙ (H y))
nat-htpy-id H refl = right-unit
inv-nat-htpy-id :
{l : Level} {A : UU l} {f : A → A} (H : f ~ id)
{x y : A} (p : x = y) → ((ap f p) ∙ (H y)) = ((H x) ∙ p)
inv-nat-htpy-id H p = inv (nat-htpy-id H p)
```
### A coherence for homotopies to the identity function
```agda
module _
{l : Level} {A : UU l} {f : A → A} (H : f ~ id)
where
coh-htpy-id : (H ·r f) ~ (f ·l H)
coh-htpy-id x = is-injective-concat' (H x) (nat-htpy-id H (H x))
inv-htpy-coh-htpy-id : (f ·l H) ~ (H ·r f)
inv-htpy-coh-htpy-id = inv-htpy coh-htpy-id
```
### Homotopies preserve the laws of the action on identity types
```agda
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x}
where
ap-concat-htpy :
(H : f ~ g) (K K' : g ~ h) → K ~ K' → (H ∙h K) ~ (H ∙h K')
ap-concat-htpy H K K' L x = ap (concat (H x) (h x)) (L x)
ap-concat-htpy' :
(H H' : f ~ g) (K : g ~ h) → H ~ H' → (H ∙h K) ~ (H' ∙h K)
ap-concat-htpy' H H' K L x =
ap (concat' _ (K x)) (L x)
module _
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g : (x : A) → B x}
{H H' : f ~ g}
where
ap-inv-htpy :
H ~ H' → (inv-htpy H) ~ (inv-htpy H')
ap-inv-htpy K x = ap inv (K x)
```
### Laws for whiskering an inverted homotopy
```agda
module _
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
where
left-whisk-inv-htpy :
{f f' : A → B} (g : B → C) (H : f ~ f') →
(g ·l (inv-htpy H)) ~ inv-htpy (g ·l H)
left-whisk-inv-htpy g H x = ap-inv g (H x)
inv-htpy-left-whisk-inv-htpy :
{f f' : A → B} (g : B → C) (H : f ~ f') →
inv-htpy (g ·l H) ~ (g ·l (inv-htpy H))
inv-htpy-left-whisk-inv-htpy g H =
inv-htpy (left-whisk-inv-htpy g H)
right-whisk-inv-htpy :
{g g' : B → C} (H : g ~ g') (f : A → B) →
((inv-htpy H) ·r f) ~ (inv-htpy (H ·r f))
right-whisk-inv-htpy H f = refl-htpy
inv-htpy-right-whisk-inv-htpy :
{g g' : B → C} (H : g ~ g') (f : A → B) →
((inv-htpy H) ·r f) ~ (inv-htpy (H ·r f))
inv-htpy-right-whisk-inv-htpy H f =
inv-htpy (right-whisk-inv-htpy H f)
```
## Reasoning with homotopies
Homotopies can be constructed by equational reasoning in the following way:
```text
homotopy-reasoning
f ~ g by htpy-1
~ h by htpy-2
~ i by htpy-3
```
The homotopy obtained in this way is `htpy-1 ∙h (htpy-2 ∙h htpy-3)`, i.e., it is
associated fully to the right.
```agda
infixl 1 homotopy-reasoning_
infixl 0 step-homotopy-reasoning
homotopy-reasoning_ :
{l1 l2 : Level} {X : UU l1} {Y : X → UU l2}
(f : (x : X) → Y x) → f ~ f
homotopy-reasoning f = refl-htpy
step-homotopy-reasoning :
{l1 l2 : Level} {X : UU l1} {Y : X → UU l2}
{f g : (x : X) → Y x} → (f ~ g) →
(h : (x : X) → Y x) → (g ~ h) → (f ~ h)
step-homotopy-reasoning p h q = p ∙h q
syntax step-homotopy-reasoning p h q = p ~ h by q
```
## See also
- We postulate that homotopies characterize identifications in (dependent)
function types in the file
[`foundation-core.function-extensionality`](foundation-core.function-extensionality.md).