dlxjj commited on
Commit
c5fb0ef
·
1 Parent(s): f8fc3e1
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -1,4 +1,5 @@
1
  *.7z filter=lfs diff=lfs merge=lfs -text
 
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.avro filter=lfs diff=lfs merge=lfs -text
4
  *.bin filter=lfs diff=lfs merge=lfs -text
 
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.xcf filter=lfs diff=lfs merge=lfs -text
3
  *.arrow filter=lfs diff=lfs merge=lfs -text
4
  *.avro filter=lfs diff=lfs merge=lfs -text
5
  *.bin filter=lfs diff=lfs merge=lfs -text
.github/dependabot.yml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Set update schedule for GitHub Actions
2
+
3
+ version: 2
4
+ updates:
5
+ - package-ecosystem: "github-actions"
6
+ directory: "/"
7
+ schedule:
8
+ # Check for updates to GitHub Actions every weekday
9
+ interval: "daily"
10
+ labels:
11
+ - "dependencies"
.github/workflows/ci.yml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - master
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ name: Build and update nightlies
13
+ runs-on: ubuntu-latest
14
+ container: danteev/texlive:2025-07-15
15
+ steps:
16
+ - name: Checkout repo
17
+ uses: actions/checkout@v6
18
+
19
+ - name: Consider all directories safe
20
+ run: git config --global --add safe.directory '*'
21
+
22
+ - name: Fetch all tags for `git describe`
23
+ run: git fetch --force --prune --unshallow --tags
24
+
25
+ - name: Check em dash style
26
+ run: "! grep -r '[^ ]---[^ ]' --include='*.tex' || { echo 'Please space the em dashes'; exit 1; }"
27
+
28
+ - name: Update ./errata.tex
29
+ # ./mark-errata should only run on the master branch of the main repo.
30
+ # This job is thus disabled for pull requests and forked repos.
31
+ if: ${{ github.repository_owner == 'HoTT' && github.ref == 'refs/heads/master' }}
32
+ run: |
33
+ ./mark-errata
34
+ if ! git diff --quiet -- ./errata.tex; then
35
+ git config --global user.name "github-actions"
36
+ git config --global user.email "github-actions@github.com"
37
+ git add errata.tex
38
+ git commit -m "Mark Errata (auto)"
39
+ git push
40
+ fi
41
+
42
+ - name: Generate nightlies
43
+ run: ./generate-nightlies "./_www_dir/" "./_wiki_dir/"
44
+
45
+ - name: Check if errata.tex is clean
46
+ # Interrupt the uploading if errata.tex somehow is not clean.
47
+ # This should not happen, but it does not hurt to check.
48
+ if: ${{ github.repository_owner == 'HoTT' && github.ref == 'refs/heads/master' }}
49
+ run: ./check-errata
50
+
51
+ - name: Push GitHub pages
52
+ # This step is disabled for all forked repos. The idea is that the nightlies will
53
+ # not be useful for most usage of forked repos. However, there are no technical
54
+ # reasons not to enable it, if one wishes to do so.
55
+ if: ${{ github.repository_owner == 'HoTT' && github.ref == 'refs/heads/master' }}
56
+ uses: peaceiris/actions-gh-pages@v4
57
+ with:
58
+ force_orphan: true
59
+ github_token: ${{ secrets.GITHUB_TOKEN }}
60
+ publish_dir: "./_www_dir/"
61
+
62
+ - name: Install gh
63
+ # Needed for using Andrew-Chen-Wang/github-wiki-action@v5
64
+ run: |
65
+ apt-get update
66
+ apt-get install -y gh
67
+
68
+ - name: Push GitHub wiki pages
69
+ # This step would err if the forked repo does not already have wiki pages.
70
+ # As a workaround, it is disabled for all forked repos.
71
+ if: ${{ github.repository_owner == 'HoTT' && github.ref == 'refs/heads/master' }}
72
+ uses: Andrew-Chen-Wang/github-wiki-action@v5
73
+ with:
74
+ path: _wiki_dir
.gitignore ADDED
@@ -0,0 +1,612 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .svn
2
+ *.pyc
3
+ *.aux
4
+ *.aux.bak
5
+ hott-*.pdf
6
+ main.pdf
7
+ errata*.pdf
8
+ *.dvi
9
+ *.bbl
10
+ *.fls
11
+ *.toc
12
+ *.blg
13
+ *.brf
14
+ *.log
15
+ *.out
16
+ *.out.ps
17
+ *.sed
18
+ *.synctex.gz
19
+ *.nav
20
+ *.snm
21
+ *.idx
22
+ *.idx.bak
23
+ *.ilg
24
+ *.ind
25
+ auto/*
26
+ *~
27
+ \#*
28
+ .\#*
29
+ cover/torus/preimg/*
30
+ cover/torus/srcimg/*
31
+ cover/torus/dstimg/*
32
+ _region_*
33
+ TAGS
34
+ .DS_Store
35
+ *.fdb_latexmk
36
+ main.labels
37
+ main.labelnumbers
38
+ exercise_solutions.pdf
39
+ indexterms.txt
40
+ cover-*.pdf
41
+ version.tex
42
+ hott-arxiv.tex
43
+ hott-arxiv.tar.gz
44
+ /Ustmry.fd
45
+ /barrdoc.pdf
46
+ /base.zip
47
+ /base/
48
+ /braket.sty
49
+ /color.cfg
50
+ /comment.sty
51
+ /dvitogif89a
52
+ /empheq.drv
53
+ /empheq.dtx
54
+ /empheq.ins
55
+ /empheq.sty
56
+ /enumitem.sty
57
+ /etoolbox.def
58
+ /etoolbox.sty
59
+ /install-tds
60
+ /mathtools.drv
61
+ /mathtools.dtx
62
+ /mathtools.ins
63
+ /mathtools.sty
64
+ /mathtools.zip
65
+ /mathtools/
66
+ /mhsetup.drv
67
+ /mhsetup.dtx
68
+ /mhsetup.ins
69
+ /mhsetup.sty
70
+ /movie.cls
71
+ /nextpage.sty
72
+ /pgf.cfg
73
+ /pgf.revision.tex
74
+ /pgf.sty
75
+ /pgf.tex
76
+ /pgfarrows.sty
77
+ /pgfautomata.sty
78
+ /pgfbaseimage.sty
79
+ /pgfbaseimage.tex
80
+ /pgfbaselayers.sty
81
+ /pgfbaselayers.tex
82
+ /pgfbasematrix.sty
83
+ /pgfbasematrix.tex
84
+ /pgfbasepatterns.sty
85
+ /pgfbasepatterns.tex
86
+ /pgfbaseplot.sty
87
+ /pgfbaseplot.tex
88
+ /pgfbaseshapes.sty
89
+ /pgfbaseshapes.tex
90
+ /pgfbasesnakes.sty
91
+ /pgfbasesnakes.tex
92
+ /pgfcalendar.code.tex
93
+ /pgfcalendar.sty
94
+ /pgfcalendar.tex
95
+ /pgfcomp-version-0-65.sty
96
+ /pgfcomp-version-1-18.sty
97
+ /pgfcore.code.tex
98
+ /pgfcore.sty
99
+ /pgfcore.tex
100
+ /pgfcorearrows.code.tex
101
+ /pgfcoreexternal.code.tex
102
+ /pgfcoregraphicstate.code.tex
103
+ /pgfcoreimage.code.tex
104
+ /pgfcorelayers.code.tex
105
+ /pgfcoreobjects.code.tex
106
+ /pgfcorepathconstruct.code.tex
107
+ /pgfcorepathprocessing.code.tex
108
+ /pgfcorepathusage.code.tex
109
+ /pgfcorepatterns.code.tex
110
+ /pgfcorepoints.code.tex
111
+ /pgfcorequick.code.tex
112
+ /pgfcorerdf.code.tex
113
+ /pgfcorescopes.code.tex
114
+ /pgfcoreshade.code.tex
115
+ /pgfcoretransformations.code.tex
116
+ /pgfcoretransparency.code.tex
117
+ /pgfexternal.tex
118
+ /pgfexternalwithdepth.tex
119
+ /pgffor.code.tex
120
+ /pgffor.sty
121
+ /pgffor.tex
122
+ /pgfheaps.sty
123
+ /pgfint.code.tex
124
+ /pgfkeys.code.tex
125
+ /pgfkeys.sty
126
+ /pgfkeys.tex
127
+ /pgfkeysfiltered.code.tex
128
+ /pgflibraryarrows.code.tex
129
+ /pgflibraryarrows.meta.code.tex
130
+ /pgflibraryarrows.spaced.code.tex
131
+ /pgflibraryarrows.sty
132
+ /pgflibraryautomata.sty
133
+ /pgflibrarybbox.code.tex
134
+ /pgflibrarycurvilinear.code.tex
135
+ /pgflibrarydatavisualization.barcharts.code.tex
136
+ /pgflibrarydatavisualization.formats.functions.code.tex
137
+ /pgflibrarydatavisualization.polar.code.tex
138
+ /pgflibrarydecorations.footprints.code.tex
139
+ /pgflibrarydecorations.fractals.code.tex
140
+ /pgflibrarydecorations.markings.code.tex
141
+ /pgflibrarydecorations.pathmorphing.code.tex
142
+ /pgflibrarydecorations.pathreplacing.code.tex
143
+ /pgflibrarydecorations.shapes.code.tex
144
+ /pgflibrarydecorations.text.code.tex
145
+ /pgflibraryfadings.code.tex
146
+ /pgflibraryfixedpointarithmetic.code.tex
147
+ /pgflibraryfpu.code.tex
148
+ /pgflibrarygraphdrawing.circular.code.tex
149
+ /pgflibrarygraphdrawing.code.tex
150
+ /pgflibrarygraphdrawing.examples.code.tex
151
+ /pgflibrarygraphdrawing.force.code.tex
152
+ /pgflibrarygraphdrawing.layered.code.tex
153
+ /pgflibrarygraphdrawing.trees.code.tex
154
+ /pgflibraryintersections.code.tex
155
+ /pgflibrarylindenmayersystems.code.tex
156
+ /pgflibraryluamath.code.tex
157
+ /pgflibrarypatterns.code.tex
158
+ /pgflibrarypatterns.meta.code.tex
159
+ /pgflibraryplothandlers.code.tex
160
+ /pgflibraryplothandlers.sty
161
+ /pgflibraryplotmarks.code.tex
162
+ /pgflibraryplotmarks.sty
163
+ /pgflibraryprofiler.code.tex
164
+ /pgflibraryshadings.code.tex
165
+ /pgflibraryshapes.arrows.code.tex
166
+ /pgflibraryshapes.callouts.code.tex
167
+ /pgflibraryshapes.code.tex
168
+ /pgflibraryshapes.gates.ee.IEC.code.tex
169
+ /pgflibraryshapes.gates.ee.code.tex
170
+ /pgflibraryshapes.gates.logic.IEC.code.tex
171
+ /pgflibraryshapes.gates.logic.US.code.tex
172
+ /pgflibraryshapes.gates.logic.code.tex
173
+ /pgflibraryshapes.geometric.code.tex
174
+ /pgflibraryshapes.misc.code.tex
175
+ /pgflibraryshapes.multipart.code.tex
176
+ /pgflibraryshapes.sty
177
+ /pgflibraryshapes.symbols.code.tex
178
+ /pgflibrarysnakes.code.tex
179
+ /pgflibrarysnakes.sty
180
+ /pgflibrarysvg.path.code.tex
181
+ /pgflibrarytikzbackgrounds.sty
182
+ /pgflibrarytikztrees.sty
183
+ /pgflibrarytimelines.code.tex
184
+ /pgfmath.code.tex
185
+ /pgfmath.sty
186
+ /pgfmath.tex
187
+ /pgfmathcalc.code.tex
188
+ /pgfmathfloat.code.tex
189
+ /pgfmathfunctions.base.code.tex
190
+ /pgfmathfunctions.basic.code.tex
191
+ /pgfmathfunctions.code.tex
192
+ /pgfmathfunctions.comparison.code.tex
193
+ /pgfmathfunctions.integerarithmetics.code.tex
194
+ /pgfmathfunctions.misc.code.tex
195
+ /pgfmathfunctions.random.code.tex
196
+ /pgfmathfunctions.round.code.tex
197
+ /pgfmathfunctions.trigonometric.code.tex
198
+ /pgfmathode.code.tex
199
+ /pgfmathparser.code.tex
200
+ /pgfmathtestsuite.tex
201
+ /pgfmathutil.code.tex
202
+ /pgfmoduleanimations.code.tex
203
+ /pgfmodulebending.code.tex
204
+ /pgfmoduledatavisualization.code.tex
205
+ /pgfmoduledecorations.code.tex
206
+ /pgfmodulematrix.code.tex
207
+ /pgfmodulenonlineartransformations.code.tex
208
+ /pgfmoduleoo.code.tex
209
+ /pgfmoduleparser.code.tex
210
+ /pgfmoduleplot.code.tex
211
+ /pgfmoduleshapes.code.tex
212
+ /pgfmodulesnakes.code.tex
213
+ /pgfmodulesorting.code.tex
214
+ /pgfnodes.sty
215
+ /pgfpages.sty
216
+ /pgfpict2e.sty
217
+ /pgfrcs.code.tex
218
+ /pgfrcs.sty
219
+ /pgfrcs.tex
220
+ /pgfshade.sty
221
+ /pgfsys-common-pdf-via-dvi.def
222
+ /pgfsys-common-pdf.def
223
+ /pgfsys-common-postscript.def
224
+ /pgfsys-common-svg.def
225
+ /pgfsys-dvi.def
226
+ /pgfsys-dvipdfm.def
227
+ /pgfsys-dvipdfmx.def
228
+ /pgfsys-dvips.def
229
+ /pgfsys-dvisvgm.def
230
+ /pgfsys-luatex.def
231
+ /pgfsys-pdftex.def
232
+ /pgfsys-tex4ht.def
233
+ /pgfsys-textures.def
234
+ /pgfsys-vtex.def
235
+ /pgfsys-xetex.def
236
+ /pgfsys.code.tex
237
+ /pgfsys.sty
238
+ /pgfsys.tex
239
+ /pgfsysanimations.code.tex
240
+ /pgfsysprotocol.code.tex
241
+ /pgfsyssoftpath.code.tex
242
+ /pgfutil-common-lists.tex
243
+ /pgfutil-common.tex
244
+ /pgfutil-context.def
245
+ /pgfutil-latex.def
246
+ /pgfutil-plain.def
247
+ /pnmrawtopcropwhite.c
248
+ /soul.dtx
249
+ /soul.ins
250
+ /soul.sty
251
+ /stmary10.600pk
252
+ /stmary10.657pk
253
+ /stmary10.mf
254
+ /stmary10.tfm
255
+ /stmary5.600pk
256
+ /stmary5.mf
257
+ /stmary5.tfm
258
+ /stmary6.600pk
259
+ /stmary6.mf
260
+ /stmary6.tfm
261
+ /stmary7.600pk
262
+ /stmary7.mf
263
+ /stmary7.tfm
264
+ /stmary8.600pk
265
+ /stmary8.mf
266
+ /stmary8.tfm
267
+ /stmary9.600pk
268
+ /stmary9.mf
269
+ /stmary9.tfm
270
+ /stmaryaj.mf
271
+ /stmaryba.mf
272
+ /stmarych.mf
273
+ /stmaryjg.mf
274
+ /stmaryrd.dtx
275
+ /stmaryrd.ins
276
+ /stmaryrd.mf
277
+ /stmaryrd.sty
278
+ /stmaryrd.zip
279
+ /stmaryrd/
280
+ /supertabular.dtx
281
+ /supertabular.ins
282
+ /supertabular.sty
283
+ /svgnam.def
284
+ /t-pgf.tex
285
+ /t-pgfbim.tex
286
+ /t-pgfbla.tex
287
+ /t-pgfbma.tex
288
+ /t-pgfbpl.tex
289
+ /t-pgfbpt.tex
290
+ /t-pgfbsh.tex
291
+ /t-pgfbsn.tex
292
+ /t-pgfcal.tex
293
+ /t-pgfcor.tex
294
+ /t-pgffor.tex
295
+ /t-pgfkey.tex
296
+ /t-pgfmat.tex
297
+ /t-pgfmod.tex
298
+ /t-pgfrcs.tex
299
+ /t-pgfsys.tex
300
+ /t-tikz.tex
301
+ /tikz.code.tex
302
+ /tikz.sty
303
+ /tikz.tex
304
+ /tikzexternal.sty
305
+ /tikzexternalshared.code.tex
306
+ /tikzexternaltest.code.tex
307
+ /tikzexternaltest.sharedpreamble.tex
308
+ /tikzexternaltest.tex
309
+ /tikzexternaltestmakefile.tex
310
+ /tikzlibrary3d.code.tex
311
+ /tikzlibraryangles.code.tex
312
+ /tikzlibraryanimations.code.tex
313
+ /tikzlibraryarrows.code.tex
314
+ /tikzlibraryautomata.code.tex
315
+ /tikzlibrarybabel.code.tex
316
+ /tikzlibrarybackgrounds.code.tex
317
+ /tikzlibrarybending.code.tex
318
+ /tikzlibrarycalc.code.tex
319
+ /tikzlibrarycalendar.code.tex
320
+ /tikzlibrarychains.code.tex
321
+ /tikzlibrarycircuits.code.tex
322
+ /tikzlibrarycircuits.ee.IEC.code.tex
323
+ /tikzlibrarycircuits.ee.code.tex
324
+ /tikzlibrarycircuits.logic.CDH.code.tex
325
+ /tikzlibrarycircuits.logic.IEC.code.tex
326
+ /tikzlibrarycircuits.logic.US.code.tex
327
+ /tikzlibrarycircuits.logic.code.tex
328
+ /tikzlibrarydatavisualization.3d.code.tex
329
+ /tikzlibrarydatavisualization.barcharts.code.tex
330
+ /tikzlibrarydatavisualization.code.tex
331
+ /tikzlibrarydatavisualization.formats.functions.code.tex
332
+ /tikzlibrarydatavisualization.polar.code.tex
333
+ /tikzlibrarydatavisualization.sparklines.code.tex
334
+ /tikzlibrarydecorations.code.tex
335
+ /tikzlibrarydecorations.footprints.code.tex
336
+ /tikzlibrarydecorations.fractals.code.tex
337
+ /tikzlibrarydecorations.markings.code.tex
338
+ /tikzlibrarydecorations.pathmorphing.code.tex
339
+ /tikzlibrarydecorations.pathreplacing.code.tex
340
+ /tikzlibrarydecorations.shapes.code.tex
341
+ /tikzlibrarydecorations.text.code.tex
342
+ /tikzlibraryer.code.tex
343
+ /tikzlibraryexternal.code.tex
344
+ /tikzlibraryfadings.code.tex
345
+ /tikzlibraryfit.code.tex
346
+ /tikzlibraryfixedpointarithmetic.code.tex
347
+ /tikzlibraryfolding.code.tex
348
+ /tikzlibraryfpu.code.tex
349
+ /tikzlibrarygraphdrawing.code.tex
350
+ /tikzlibrarygraphdrawing.evolving.code.tex
351
+ /tikzlibrarygraphs.code.tex
352
+ /tikzlibrarygraphs.standard.code.tex
353
+ /tikzlibraryintersections.code.tex
354
+ /tikzlibrarylindenmayersystems.code.tex
355
+ /tikzlibrarymath.code.tex
356
+ /tikzlibrarymatrix.code.tex
357
+ /tikzlibrarymindmap.code.tex
358
+ /tikzlibrarypatterns.code.tex
359
+ /tikzlibrarypatterns.meta.code.tex
360
+ /tikzlibraryperspective.code.tex
361
+ /tikzlibrarypetri.code.tex
362
+ /tikzlibraryplothandlers.code.tex
363
+ /tikzlibraryplotmarks.code.tex
364
+ /tikzlibrarypositioning.code.tex
365
+ /tikzlibraryquotes.code.tex
366
+ /tikzlibraryrdf.code.tex
367
+ /tikzlibraryscopes.code.tex
368
+ /tikzlibraryshadings.code.tex
369
+ /tikzlibraryshadows.code.tex
370
+ /tikzlibraryshapes.arrows.code.tex
371
+ /tikzlibraryshapes.callouts.code.tex
372
+ /tikzlibraryshapes.code.tex
373
+ /tikzlibraryshapes.gates.logic.IEC.code.tex
374
+ /tikzlibraryshapes.gates.logic.US.code.tex
375
+ /tikzlibraryshapes.geometric.code.tex
376
+ /tikzlibraryshapes.misc.code.tex
377
+ /tikzlibraryshapes.multipart.code.tex
378
+ /tikzlibraryshapes.symbols.code.tex
379
+ /tikzlibrarysnakes.code.tex
380
+ /tikzlibraryspy.code.tex
381
+ /tikzlibrarysvg.path.code.tex
382
+ /tikzlibrarythrough.code.tex
383
+ /tikzlibrarytopaths.code.tex
384
+ /tikzlibrarytrees.code.tex
385
+ /tikzlibraryturtle.code.tex
386
+ /tikzlibraryviews.code.tex
387
+ /titleps.sty
388
+ /titlesec.sty
389
+ /titlesec.zip
390
+ /titlesec/
391
+ /titletoc.sty
392
+ /unittest_luamathparser.tex
393
+ /wallpaper.sty
394
+ /x11nam.def
395
+ /xcolor.dtx
396
+ /xcolor.ins
397
+ /xcolor.lox
398
+ /xcolor.pro
399
+ /xcolor.sty
400
+ /xcolor1.tex
401
+ /xcolor2.tex
402
+ /xcolor3.tex
403
+ /xcolor4.tex
404
+ /xstring.sty
405
+ /xstring.tex
406
+ /xxcolor.sty
407
+ /xy.sty
408
+ /xy.tex
409
+ /xy16textures.tex
410
+ /xy17oztex.tex
411
+ /xy2cell.tex
412
+ /xy389dict.pro
413
+ /xy389src.tar.gz
414
+ /xyall.tex
415
+ /xyarc.tex
416
+ /xyarrow.tex
417
+ /xyatip.mf
418
+ /xyatip10.afm
419
+ /xyatip10.mf
420
+ /xyatip10.pfb
421
+ /xyatip10.pfm
422
+ /xyatip10.tfm
423
+ /xyatri.mf
424
+ /xybarr.tex
425
+ /xybsql10.afm
426
+ /xybsql10.mf
427
+ /xybsql10.pfb
428
+ /xybsql10.pfm
429
+ /xybsql10.tfm
430
+ /xybtip.mf
431
+ /xybtip10.afm
432
+ /xybtip10.mf
433
+ /xybtip10.pfb
434
+ /xybtip10.pfm
435
+ /xybtip10.tfm
436
+ /xybtri.mf
437
+ /xycirc.enc
438
+ /xycirc10.afm
439
+ /xycirc10.mf
440
+ /xycirc10.pfb
441
+ /xycirc10.pfm
442
+ /xycirc10.tfm
443
+ /xycm.mf
444
+ /xycmactex.tex
445
+ /xycmat10.afm
446
+ /xycmat10.mf
447
+ /xycmat10.pfb
448
+ /xycmat10.pfm
449
+ /xycmat10.tfm
450
+ /xycmat11.afm
451
+ /xycmat11.mf
452
+ /xycmat11.pfb
453
+ /xycmat11.pfm
454
+ /xycmat11.tfm
455
+ /xycmat12.afm
456
+ /xycmat12.mf
457
+ /xycmat12.pfb
458
+ /xycmat12.pfm
459
+ /xycmat12.tfm
460
+ /xycmbt10.afm
461
+ /xycmbt10.mf
462
+ /xycmbt10.pfb
463
+ /xycmbt10.pfm
464
+ /xycmbt10.tfm
465
+ /xycmbt11.afm
466
+ /xycmbt11.mf
467
+ /xycmbt11.pfb
468
+ /xycmbt11.pfm
469
+ /xycmbt11.tfm
470
+ /xycmbt12.afm
471
+ /xycmbt12.mf
472
+ /xycmbt12.pfb
473
+ /xycmbt12.pfm
474
+ /xycmbt12.tfm
475
+ /xycmtip.tex
476
+ /xycolor.tex
477
+ /xycrayon.tex
478
+ /xycurve.tex
479
+ /xyd.enc
480
+ /xyd.mf
481
+ /xyd2.enc
482
+ /xyd2.mf
483
+ /xydash10.afm
484
+ /xydash10.mf
485
+ /xydash10.pfb
486
+ /xydash10.pfm
487
+ /xydash10.tfm
488
+ /xydummy.tex
489
+ /xydvidrv.tex
490
+ /xydvips.tex
491
+ /xydvitops.tex
492
+ /xyemtex.tex
493
+ /xyeuat10.afm
494
+ /xyeuat10.mf
495
+ /xyeuat10.pfb
496
+ /xyeuat10.pfm
497
+ /xyeuat10.tfm
498
+ /xyeuat11.afm
499
+ /xyeuat11.mf
500
+ /xyeuat11.pfb
501
+ /xyeuat11.pfm
502
+ /xyeuat11.tfm
503
+ /xyeuat12.afm
504
+ /xyeuat12.mf
505
+ /xyeuat12.pfb
506
+ /xyeuat12.pfm
507
+ /xyeuat12.tfm
508
+ /xyeubt10.afm
509
+ /xyeubt10.mf
510
+ /xyeubt10.pfb
511
+ /xyeubt10.pfm
512
+ /xyeubt10.tfm
513
+ /xyeubt11.afm
514
+ /xyeubt11.mf
515
+ /xyeubt11.pfb
516
+ /xyeubt11.pfm
517
+ /xyeubt11.tfm
518
+ /xyeubt12.afm
519
+ /xyeubt12.mf
520
+ /xyeubt12.pfb
521
+ /xyeubt12.pfm
522
+ /xyeubt12.tfm
523
+ /xyeuler.mf
524
+ /xyframe.tex
525
+ /xygraph.tex
526
+ /xyguide.pdf
527
+ /xyidioms.tex
528
+ /xyimport.tex
529
+ /xyknot.tex
530
+ /xyline.tex
531
+ /xyline10.mf
532
+ /xyline10.tfm
533
+ /xylu.mf
534
+ /xyluat10.afm
535
+ /xyluat10.mf
536
+ /xyluat10.pfb
537
+ /xyluat10.pfm
538
+ /xyluat10.tfm
539
+ /xyluat11.afm
540
+ /xyluat11.mf
541
+ /xyluat11.pfb
542
+ /xyluat11.pfm
543
+ /xyluat11.tfm
544
+ /xyluat12.afm
545
+ /xyluat12.mf
546
+ /xyluat12.pfb
547
+ /xyluat12.pfm
548
+ /xyluat12.tfm
549
+ /xylubt10.afm
550
+ /xylubt10.mf
551
+ /xylubt10.pfb
552
+ /xylubt10.pfm
553
+ /xylubt10.tfm
554
+ /xylubt11.afm
555
+ /xylubt11.mf
556
+ /xylubt11.pfb
557
+ /xylubt11.pfm
558
+ /xylubt11.tfm
559
+ /xylubt12.afm
560
+ /xylubt12.mf
561
+ /xylubt12.pfb
562
+ /xylubt12.pfm
563
+ /xylubt12.tfm
564
+ /xymacpat.xyp
565
+ /xymatrix.tex
566
+ /xymisc10.mf
567
+ /xymisc10.tfm
568
+ /xymovie.tex
569
+ /xynecula.tex
570
+ /xyoztex.tex
571
+ /xypdf-co.tex
572
+ /xypdf-cu.tex
573
+ /xypdf-fr.tex
574
+ /xypdf-li.tex
575
+ /xypdf-ro.tex
576
+ /xypdf.pdf
577
+ /xypdf.tex
578
+ /xypic.map
579
+ /xypic.sty
580
+ /xypic.tex
581
+ /xypic.zip
582
+ /xypic/
583
+ /xypicture.tex
584
+ /xypoly.tex
585
+ /xyps-c.tex
586
+ /xyps-col.tex
587
+ /xyps-f.tex
588
+ /xyps-l.tex
589
+ /xyps-pro.tex
590
+ /xyps-ps.tex
591
+ /xyps-r.tex
592
+ /xyps-s.tex
593
+ /xyps-t.tex
594
+ /xyps.tex
595
+ /xypsdict.tex
596
+ /xypspatt.tex
597
+ /xyqc10.mf
598
+ /xyqc10.tfm
599
+ /xyrecat.tex
600
+ /xyrefer.pdf
601
+ /xyrotate.tex
602
+ /xysmart.tex
603
+ /xysource.pdf
604
+ /xytech.mf
605
+ /xytextures.tex
606
+ /xytile.tex
607
+ /xytips.tex
608
+ /xytp-f.tex
609
+ /xytpic.tex
610
+ /xyv2.tex
611
+ /xyweb.tex
612
+ /xyxdvi.tex
.travis.yml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: c
2
+
3
+ sudo: true
4
+
5
+ cache:
6
+ directories:
7
+ - $HOME/.cache/latex
8
+
9
+ addons:
10
+ apt:
11
+ packages:
12
+ - wget
13
+ - curl
14
+ - sed
15
+ - grep
16
+ - texlive
17
+ - texlive-generic-extra
18
+ - texlive-latex-base
19
+ - texlive-latex-extra
20
+ - texlive-latex-recommended
21
+ - texlive-math-extra
22
+ - texlive-metapost
23
+ - texlive-omega
24
+ - texlive-plain-extra
25
+ - texlive-xetex
26
+
27
+ env:
28
+ global:
29
+ - secure: "ehec8FC6y923UXtB2fMULF/xkQJkwWwzD6xFxyz0lc80IqR8Rmxh16nLKGxI9jD11qjbYSzp1yPVadXyBoSheop5aZPxeXixL49y26ikIRkyuQQdHyjsM34etoPmCKw2vVXvD+JAwjTa6qYpihSOdDXltog8ZNHF6Wp28ZaWW8g="
30
+
31
+ matrix:
32
+ include:
33
+ # only one of these should have UPDATE_ERRATA set to "yes", otherwise we risk race conditions on pushing
34
+ - env: LATEXMK="yes" UPDATE_ERRATA="" UPDATE_NIGHTLIES="" TARGETS=""
35
+ - env: LATEXMK="" UPDATE_ERRATA="yes" UPDATE_NIGHTLIES="yes" TARGETS=""
36
+ - env: LATEXMK="" UPDATE_ERRATA="" UPDATE_NIGHTLIES="" TARGETS="dvi"
37
+
38
+ install:
39
+ - if test "$LATEXMK" = yes ; then sudo apt-get install latexmk ; fi
40
+
41
+ script: make $TARGETS
42
+
43
+ # add -f to force a push even if we're not on HoTT/HoTT.
44
+ # generally only useful for debugging
45
+ after_script:
46
+ - etc/ci/update_errata.sh
47
+ - etc/ci/update_nightlies.sh
CONTRIBUTING.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ We are very happy to receive suggestions which fix typos, formatting,
2
+ and obvious mathematical errors; which clarify exposition in a
3
+ straightforward way; or which add new technical functionality (such as
4
+ versions for other devices). We are not asking for new mathematical
5
+ content from the public at this time.
6
+
7
+ We are very grateful to everyone who is showing interest in our project,
8
+ and to anyone who helps us improve it! However, in order to avoid any
9
+ misunderstanding later, we should mention upfront that your
10
+ contributions will only be recorded on github commit logs, but not in
11
+ the book itself (because the book is officially an IAS project).
12
+
13
+ Note that the version of the book you are working from (including the
14
+ version posted on the public web site) may not be the most recent one.
15
+ If you've found an error and want to check whether it has already been
16
+ corrected in the most recent version, you may need to clone the git
17
+ repository and compile the sources yourself, or else look at the
18
+ source code on github.
19
+
20
+ If you only want to point out the existence of an error or make a
21
+ general suggestion, you can open an issue on the github project. The
22
+ authors will (eventually) respond and either implement a fix or decide
23
+ that no fix is necessary. If you would like to fix an error yourself
24
+ or suggest a specific concrete change, you can fork the github
25
+ project, commit the change in a branch on your fork, and open a pull
26
+ request to the parent project.
27
+
28
+ Please make sure that your pull request is attached to the correct
29
+ branch. Changes which add new mathematics, or which alter the
30
+ numbering of existing sections, theorems, or equations, must wait for
31
+ the second edition. Other changes, as long as they are not of
32
+ unreasonable size, can be released as updates to the first edition.
33
+ To ensure that your change does not alter existing numberings, you can
34
+ run "make labelcheck".
35
+
36
+ Corrections of mathematical typos and other errors, as well as changes
37
+ in exposition, should also be listed in the errata for the first
38
+ edition (`errata.tex`).
39
+
40
+ - The first column in the errata table should be the nearest
41
+ surrounding numbered label, be it a section, theorem, or exercise.
42
+
43
+ - The second column is obtained by running `git describe` on the
44
+ commit where the fix was merged into the master branch. You don't
45
+ know this when writing your fix, of course, so the correct thing to
46
+ put here is a comment of the form
47
+
48
+ % merge of 1234567
49
+
50
+ where `1234567` is the commit hash in which you made the fix. (This
51
+ necessitates making two commits, one to make the fix and one to
52
+ record the erratum.) Please use _exactly_ this syntax so that it can
53
+ be automatically updated by the errata-marking script.
54
+
55
+ - The third column is a description of the change. Please be specific
56
+ enough that someone looking at only a printed version (which may
57
+ have page breaks in different places) could easily find its
58
+ location.
59
+
60
+ It is generally a good idea not to submit github pull requests from
61
+ your master branch. This is because whatever branch you submit a pull
62
+ request from, any new commits on that branch that happen before the
63
+ pull request is merged get added to the pull request. Thus, if you
64
+ submit pull requests from your master branch, you cannot have multiple
65
+ unrelated pull requests open at once, or do unrelated work on your
66
+ master branch before your pull request is merged. To create a special
67
+ branch for your pull request, run
68
+
69
+ git checkout -b BRANCHNAME
70
+
71
+ Make your commits in that branch, then run
72
+
73
+ git push origin BRANCHNAME:BRANCHNAME
74
+
75
+ assuming that your git remote `origin` is set up to be your github
76
+ fork (rather than the main `HoTT/book` repository). The main page of
77
+ your github fork should then have a little prompt asking you whether
78
+ you want to issue a pull request from your most recently pushed
79
+ branch.
CONVENTIONS.txt ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Authorial conventions for the HoTT Book
2
+
3
+ 1. To denote equality/identity/path types, you can write simply "="
4
+ infix. Of course, this works for chains of equalities "a=b=c=d"
5
+ and also vertically-stacked ones. An alternative notation is
6
+ "\id{x}{y}", or "\id[A]{x}{y}" if you want to notate the type to
7
+ which x and y belong; this notation might produce "x=y" or
8
+ "Id(x,y)" in the future. If you want to be sure of producing
9
+ "Id(x,y)", write instead "\idtype{x}{y}" or "\idtype[A]{x}{y}".
10
+ Note that single-character non-optional arguments do not need
11
+ braces, so you can write "\idtype xy", but you need to write
12
+ "\idtype{(x+1)^2}{x^2+2x+1}".
13
+
14
+ 2. There are two macros that denote definitional/judgmental equality.
15
+ \jdeq or \judgeq should be used for an equality judgment being made
16
+ about two extant terms, while \defeq should be used when the
17
+ left-hand side is currently being defined to equal the right-hand
18
+ side. Both are used infix, and currently produce \equiv and
19
+ \coloneqq (that is, :=), respectively.
20
+
21
+ 3. Here is a cheatsheet of some more macros. Arguments in [brackets]
22
+ are optional and can be omitted.
23
+
24
+ x = y identity type (fixed notation "x=y")
25
+ \id[A]{x}{y} identity type (agnostic notation)
26
+ \idtype[A]{x}{y} identity type (fixed notation "Id(x,y)")
27
+ x \jdeq y x is judged to be definitionally equal to y
28
+ x \defeq y x is currently being defined to equal y
29
+ \refl{x} reflexivity term at x
30
+ p \ct q concatenation of equalities p and q (diagrammatic order)
31
+ \opp{p} or \rev{p} the opposite equality of p
32
+ \trans{p}{x} covariant transport of x along p
33
+ \map{f}{p} map the path p under the function f
34
+ \mapdep{f}{p} likewise, for a dependently typed function f
35
+ \idfunc[A] the identity function of a type A
36
+ \eqv{A}{B} the type of equivalences from A to B
37
+ \type,\set,\prop universes of types, sets, and propositions
38
+
39
+ 3. In the style of a textbook or lecture notes, generally try to keep
40
+ citations and references out of the main text. Rather, each
41
+ chapter should have an unnumbered "Notes" section at the end
42
+ containing references to the literature and relevant comments.
43
+ References should go in the references.bib file in BibTeX format.
44
+ Use \cite for your citations so that they will all have a uniform
45
+ appearance.
46
+
47
+ 4. The following theorem-type environments are predefined:
48
+
49
+ thm Theorem
50
+ cor Corollary
51
+ lem Lemma
52
+ defn Definition
53
+ rmk Remark
54
+ eg Example
55
+ egs Examples
56
+ ex Exercise
57
+
58
+ When referring to a theorem defined elsewhere, use the macro
59
+ \autoref. This automatically produces words before numbers, such
60
+ as "Theorem 3.1", and automatically changes them if (for instance)
61
+ you change a theorem to a lemma.
62
+
63
+ Similarly, try to add \label{}s to all of your theorem-environments
64
+ so that other people can refer to them. If you find yourself needing
65
+ a lemma that you think should appear in someone else's chapter, you
66
+ can add a stub to their chapter with a \label. Only the following
67
+ characters should be used in labels: letters, digits, colon : and
68
+ dash -.
69
+
70
+ 5. Each chapter is encouraged to also have an unnumbered section of
71
+ "Exercises" at the end.
GIT_CHEATSHEET.txt ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SETUP 1: Install git
2
+ # see http:/git-scm.com/downloads
3
+ # Remember to set user.name and user.email:
4
+ git config --global user.name "James Bond"
5
+ git config --global user.email "007@mi6.gov.uk"
6
+
7
+ # SETUP 2: signup for GitHub account
8
+ # see http://github.com
9
+ # Remember to email your username to:
10
+ # mshulman@ias.edu
11
+
12
+ # SETUP 3: clone
13
+ cd dir_where_you_want_book_dir
14
+ git clone https://github.com/HoTT/book.git
15
+ cd book
16
+ #...
17
+
18
+ # NOTE: Remaining commands must be run inside book/
19
+
20
+ # USAGE 1: add + commit
21
+ # To have git record your changes:
22
+ git commit -m "description of edit" <files-you-changed>
23
+
24
+ # USAGE 2: pull
25
+ # To pull changes by others from GitHub:
26
+ # (Your local directory will still have your changes.)
27
+ # FIRST commit your changes as above, then
28
+ git pull
29
+
30
+ # USAGE 3: compile + push
31
+ # To push your changes to GitHub:
32
+ # FIRST, commit your changes as above
33
+ # SECOND, pull changes from GitHub as above, then
34
+ latex main.tex
35
+ git push
36
+
37
+
38
+ # Which files did I change since the last commit?
39
+ git status
40
+
41
+ # What changes did I make in those files?
42
+ git diff
43
+
44
+ # Who wrote the crap in this file?
45
+ git blame
Makefile ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: default all clean version.tex dvi
2
+
3
+ # Default top-level LaTeX to generate
4
+ DEFAULTTOPTEX = hott-online.tex
5
+
6
+ # Top-level LaTeX files from which HoTT book can be generated
7
+ TOPTEXFILES = $(DEFAULTTOPTEX) hott-ustrade.tex hott-letter.tex hott-letter-exercises.tex hott-a4.tex hott-a4-exercises.tex hott-ebook.tex hott-ebook-wide.tex hott-ebook-narrow.tex hott-arxiv.tex
8
+
9
+ # LaTeX files that actually comprise the book
10
+ # (that is, all of them except configuration)
11
+ BOOKTEXFILES = main.tex \
12
+ macros.tex \
13
+ version.tex \
14
+ frontpage.tex \
15
+ front.tex \
16
+ preface.tex \
17
+ introduction.tex \
18
+ preliminaries.tex \
19
+ basics.tex \
20
+ logic.tex \
21
+ equivalences.tex \
22
+ induction.tex \
23
+ hits.tex \
24
+ hlevels.tex \
25
+ homotopy.tex \
26
+ categories.tex \
27
+ setmath.tex \
28
+ reals.tex \
29
+ formal.tex \
30
+ symbols.tex \
31
+ back.tex \
32
+ blurb.tex
33
+
34
+ # Configuration files
35
+ OPTFILES = opt-letter.tex \
36
+ opt-a4.tex \
37
+ opt-ustrade.tex \
38
+ opt-ebook.tex \
39
+ opt-ebook-wide.tex \
40
+ opt-ebook-narrow.tex \
41
+ opt-color.tex \
42
+ opt-black-white.tex \
43
+ opt-cover.tex \
44
+ opt-no-cover.tex \
45
+ opt-bastard.tex \
46
+ opt-no-bastard.tex
47
+
48
+ # Image files
49
+ LORESPNGFILES = cover-lores-back-bw.png \
50
+ cover-lores-back.png \
51
+ cover-lores-front-bw.png \
52
+ cover-lores-front.png \
53
+ cover-lores.png \
54
+ torus-lores-bw.png
55
+ HIRESPNGFILES = cover-hires-back-bw.png \
56
+ cover-hires-back.png \
57
+ cover-hires-front-bw.png \
58
+ cover-hires-front.png \
59
+ cover-hires.png \
60
+ cover-hires-bw.png \
61
+ torus-hires-bw.png
62
+
63
+ # All the LaTeX files for the HoTT book in order of dependency
64
+ TEXFILES = $(TOPTEXFILES) $(BOOKTEXFILES) $(OPTFILES)
65
+
66
+ # aux files to be used when combining info from HoTT book with
67
+ # exercises
68
+ BOOKAUXFILES := $(BOOKTEXFILES:.tex=.aux)
69
+
70
+ # PDF and DVI files corresponding to HoTT book files
71
+ TOPPDFFILES:=$(TOPTEXFILES:.tex=.pdf)
72
+ TOPDVIFILES:=$(TOPTEXFILES:.tex=.dvi)
73
+
74
+ # Default PDF file to make
75
+ DEFAULTPDF:=$(DEFAULTTOPTEX:.tex=.pdf)
76
+
77
+ default: $(DEFAULTPDF)
78
+
79
+ all: $(TOPPDFFILES) exercise_solutions.pdf errata.pdf cover-lulu-hardcover.pdf cover-lulu-paperback.pdf cover-letter.pdf cover-a4.pdf
80
+
81
+ dvi: $(TOPDVIFILES) exercise_solutions.dvi errata.dvi cover-lulu-hardcover.dvi cover-lulu-paperback.dvi cover-letter.dvi cover-a4.dvi
82
+
83
+ # Main targets
84
+ $(TOPPDFFILES) : %.pdf : %.tex $(TEXFILES) references.bib cover-lores-front.png cover-lores-back.png
85
+ if which latexmk > /dev/null 2>&1 ;\
86
+ then latexmk -interaction=batchmode -g -pdf $< ;\
87
+ else (echo "run 1: pdflatex $<"; pdflatex -halt-on-error -interaction=batchmode $< 2>&1 >/dev/null) && \
88
+ bibtex $(patsubst %.tex,%,$<) && \
89
+ makeindex $(patsubst %.tex,%,$<) && \
90
+ (echo "run 2: pdflatex $<"; pdflatex -halt-on-error -interaction=batchmode $< 2>&1 >/dev/null) ;\
91
+ pdflatex -halt-on-error $< ;\
92
+ echo "HINT: If you think this took a long time you should install latexmk." ;\
93
+ fi
94
+
95
+ $(TOPDVIFILES) : %.dvi : %.tex $(TEXFILES) references.bib cover-lores-front.png cover-lores-back.png
96
+ if which latexmk > /dev/null 2>&1 ;\
97
+ then latexmk -interaction=batchmode -dvi $< ;\
98
+ else (echo "run 1: latex $<"; latex -halt-on-error -interaction=batchmode $< 2>&1 >/dev/null) && \
99
+ bibtex $(patsubst %.tex,%,$<) && \
100
+ makeindex $(patsubst %.tex,%,$<) && \
101
+ (echo "run 2: latex $<"; latex -halt-on-error -interaction=batchmode $< 2>&1 >/dev/null) ;\
102
+ latex -halt-on-error $< ;\
103
+ echo "HINT: If you think this took a long time you should install latexmk." ;\
104
+ fi
105
+
106
+ all default: log-check
107
+ log-check:
108
+ : check for indexing errors
109
+ ! grep -n "!! Input index error" hott-online.ilg /dev/null
110
+
111
+ version.tex:
112
+ printf '\\newcommand{\\OPTversion}{%s}\n' "`git describe --always --long`" > version.tex
113
+
114
+ # these warnings are mostly spurious, and could have been prevented by a better makeindex algorithm
115
+ log-check-for-warnings:
116
+ : check for indexing warnings
117
+ - ! grep -n "## Warning" hott-online.ilg /dev/null
118
+
119
+ $(BOOKAUXFILES) : %.aux : %.tex
120
+ echo "WARNING: assuming $@ is up-to-date"
121
+
122
+ # Generate labels for the solutions
123
+ main.labels: $(BOOKAUXFILES)
124
+ cat $^ | grep ^.newlabel >$@
125
+
126
+ # Extract label numbers for verifying that they haven't changed within an edition.
127
+ # Discard symbol index numbers (not seen by user) and page numbers (we don't care about them).
128
+ main.labelnumbers: main.labels
129
+ sed 's/.*symindex.*//g' main.labels | sed 's/{\({[^}]*}\).*/\1/g' | sort >main.labelnumbers
130
+
131
+ # Check that no labels have changed, by making sure that all label
132
+ # numbers from the first edition are still present
133
+ labelcheck: main.labelnumbers
134
+ diff -u main.labelnumbers.first-edition main.labelnumbers | grep '^-\\newlabel' && echo Some label numbers have changed since the first edition!
135
+
136
+ cover-lulu-hardcover.pdf cover-lulu-paperback.pdf cover-letter.pdf cover-a4.pdf exercise_solutions.pdf errata.pdf : %.pdf : %.tex
137
+ if which latexmk > /dev/null 2>&1 ;\
138
+ then latexmk -interaction=batchmode -pdf $<;\
139
+ else pdflatex -halt-on-error $<; fi
140
+
141
+ cover-lulu-hardcover.dvi cover-lulu-paperback.dvi cover-letter.dvi cover-a4.dvi exercise_solutions.dvi errata.dvi : %.dvi : %.tex
142
+ if which latexmk > /dev/null 2>&1 ;\
143
+ then latexmk -interaction=batchmode -dvi $<;\
144
+ else latex -halt-on-error $<; fi
145
+
146
+ cover-lulu-hardcover.pdf cover-lulu-paperback.pdf cover-lulu-hardcover.dvi cover-lulu-paperback.dvi: cover-hires.png $(OPTFILES)
147
+
148
+ cover-letter.pdf cover-a4.pdf cover-letter.dvi cover-a4.dvi: cover-lores-front.png cover-lores-back.png $(OPTFILES)
149
+
150
+ hott-arxiv.tex: hott-online.tex main.tex
151
+ echo '% hott-arxiv.tex AUTOGENERATED FROM hott-online.tex AND main.tex' >hott-arxiv.tex
152
+ cat hott-online.tex >>hott-arxiv.tex
153
+ sed 's/\\input{main}//' <hott-arxiv.tex >hott-arxiv.tex.tmp
154
+ mv hott-arxiv.tex.tmp hott-arxiv.tex
155
+ cat main.tex >>hott-arxiv.tex
156
+
157
+ hott-arxiv.tar.gz: hott-arxiv.pdf
158
+ tar -czf hott-arxiv.tar.gz hott-arxiv.tex hott-arxiv.bbl hott-arxiv.ind $(BOOKTEXFILES) $(OPTFILES) $(LORESPNGFILES) mathpartir.sty
159
+
160
+ exercise_solutions.pdf exercise_solutions.dvi: main.labels
161
+
162
+ errata.pdf errata.dvi: version.tex main.labels
163
+
164
+ clean:
165
+ rm -f *~ *.aux {exercise_solutions,errata,hott-*}.{out,log,pdf,dvi,fls,fdb_latexmk,aux,brf,bbl,idx,ilg,ind,toc,sed}
166
+ if which latexmk > /dev/null 2>&1 ; then latexmk -interaction=batchmode -C hott-*.tex; fi
167
+
168
+ # list the tex files explicitly because:
169
+ # - we want to tag them in the same order they appear in the book, so tag search is in logical sequence
170
+ # - there are many *.tex garbage files in this directory
171
+ TAGS: $(TEXFILES) exercise_solutions.tex errata.tex
172
+ etags $^ -o $@.tmp
173
+ mv $@.tmp $@
174
+
175
+ indexterms.txt: \
176
+ other/index-helper.py \
177
+ front.tex \
178
+ preface.tex \
179
+ introduction.tex \
180
+ preliminaries.tex \
181
+ basics.tex \
182
+ logic.tex \
183
+ equivalences.tex \
184
+ induction.tex \
185
+ hits.tex \
186
+ hlevels.tex \
187
+ homotopy.tex \
188
+ categories.tex \
189
+ setmath.tex \
190
+ reals.tex \
191
+ formal.tex
192
+ other/index-helper.py >$@
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is a textbook on informal homotopy type theory.
2
+ It is part of the [Univalent foundations of mathematics](http://www.math.ias.edu/sp/univalent)
3
+ project that took place at the Institute for Advanced Study in 2012/13.
4
+
5
+ ## License
6
+
7
+ This work is licensed under the
8
+ [Creative Commons Attribution-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/).
9
+
10
+ ## Distribution
11
+
12
+ Compiled and printed versions of the book are available at the
13
+ [homotopy type theory website](http://homotopytypetheory.org/book),
14
+ and nightly builds are available on the
15
+ [github wiki](https://github.com/HoTT/book/wiki/Nightly-Builds).
16
+
17
+ ## Editing the book
18
+
19
+ This book is not a community project, but we do welcome our readers to suggest improvements. The best way to propose an edit is to [open a pull request](https://github.com/HoTT/book/compare) with your suggested change. You can also [open an issue](https://github.com/HoTT/book/issues/new/choose) if you do not have a concrete proposal yet. The issues and the pull requests are dedicated to improvements, questions, and other issues pertaining to the HoTT book itself. General discussions about homotopy type theory and topics related to the wider HoTT community are welcome at the [homotopytypetheory google group](https://groups.google.com/g/homotopytypetheory) or at the [HoTT zulip](https://hott.zulipchat.com). For further directions about editing the book, see the [guidelines for contributions](https://github.com/HoTT/book/blob/master/CONTRIBUTING.md)
20
+
21
+ ## Code of conduct
22
+
23
+ For many, the HoTT book is their introduction to our subject and our diverse community, including people from any nationality, gender identity, sexual orientation, race, color, ability, and background. In order to ensure for everyone a welcoming and inclusive environment in our discussions, we follow the guidelines of the [GitHub code of conduct](https://docs.github.com/en/site-policy/github-terms/github-community-forum-code-of-conduct). You can expect from the authors and any participant that we are kind and respectful in discussions, that we use inclusive language, and that we do our best to understand each other's different perspectives. It might not always be that we accept the change in the way you proposed it, but we always value your input, regardless of your level of experience or status within the community.
24
+
25
+ ## Prerequisites and compilation
26
+
27
+ To compile the book for yourself you need a fairly new version of LaTeX.
28
+ [Texlive](http://www.tug.org/texlive/) 2012 is confirmed to work. You might need
29
+ to install some packages; see `main.tex` for packages that are used by the book.
30
+
31
+ [BasicTeX](http://www.tug.org/mactex/morepackages.html), which is a minimalistic
32
+ version of MacTeX, is confirmed to work once the following packages have been
33
+ installed: `tlmgr`, `install`, `braket`, `comment`, `courier`, `enumitem`,
34
+ `helvetic`, `mathpazo`, `nextpage`, `ntheorem`, `palatino`, `rsfs`, `stmaryrd`,
35
+ `symbol`, `titlesec`, `wallpaper`, `wasy`, `wasysym`, `xstring`, `zapfding`.
36
+
37
+ You also need the `make` utility. The book is a fairly complex piece of LaTeX
38
+ code. Also, the file `version.tex` is generated on the fly, so you will need the
39
+ `make` utility with which you can compile the main files, as follows:
40
+
41
+ * `make hott-online.pdf` -- the book appropriate for online reading, with colors and green links
42
+ * `make hott-ebook.pdf` -- the book with small margins, suitable for ebook readers
43
+ * `make hott-ebook-wide.pdf` -- the book with small margins, suitable for ebook readers, wider page
44
+ * `make hott-ebook-narrow.pdf` -- the book with small margins, suitable for ebook readers, narrower page
45
+ * `make hott-letter.pdf cover-letter.pdf` -- the book in black & white, letter paper format,
46
+ for printing at home, as well as a color cover (just two pages)
47
+ * `make hott-a4.pdf cover-a4.pdf` -- the book in black & white, A4 paper format,
48
+ for printing at home, as well as a color cover (just two pages)
49
+ * `make hott-arxiv.pdf` -- the version that is uploaded to arXiv
50
+ * `make hott-letter-exercises.pdf` -- the book in black & white, letter paper format, but with exercises one-per-page
51
+ * `make hott-a4-exercises.pdf` -- the book in black & white, A4 paper format, but with exercises one-per-page
52
+ * `make hott-ustrade.pdf cover-lulu-hardcover.pdf cover-lulu-paperback.pdf` --
53
+ the book in US Trade format, without cover, used for the bound copy available
54
+ at http://lulu.com/
55
+ * `make exercise_solutions.pdf` -- (some) solutions to exercises
56
+ * `make errata.pdf` -- errata for the HoTT Book, first edition
57
+
58
+ Note: once `make` is run so that `version.tex` is generated, you need not run `make` every time you make
59
+ a change to the source file. You can just perform the usual LaTeX cycle from your favorite editor.
60
+
61
+ #### Compiling without `make`
62
+
63
+ If you do not have `make` (for example, because you are on MacOS and you did not
64
+ install the XCode command-line utilities), you can still fake it as follows.
65
+ Create the file `version.tex` and put in it (where "Joe Hacker" should be
66
+ replaced with your name):
67
+
68
+ \newcommand{\OPTversion}{Joe-Hacker-version}
69
+
70
+ Then use whatever tools you normally do to compile LaTeX. The main LaTeX files are called
71
+ `hott-XXX.tex`. But you really should have `make`, you know.
72
+
back.tex ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \ifOPTcover
2
+ \cleartooddpage[\thispagestyle{empty}]
3
+ \pagestyle{empty}
4
+ \cleartoevenpage
5
+
6
+ %%%%%%%%%%%%%%%%%%%% Back cover %%%%%%%%%%%%%%%%%%%%
7
+ \ThisLRCornerWallPaper{0.7}{\OPTbackimage}
8
+ \pagecolor{covercolor}
9
+ \color{covertext}
10
+ \input{blurb.tex}
11
+ \else
12
+ \fi
13
+
14
+ %%% Local Variables:
15
+ %%% mode: latex
16
+ %%% TeX-master: "hott-online"
17
+ %%% End:
basics.tex ADDED
The diff for this file is too large to render. See raw diff
 
blurb.tex ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % Blurb on back cover, gets included in lulu cover as well
2
+ % as regular version, so be careful with formatting
3
+
4
+ {
5
+ \parindent=0pt
6
+ \parskip=\baselineskip
7
+ {\OPTbacktitlefont
8
+ \textit{From the Introduction:}}
9
+ \OPTbackfont
10
+
11
+ \emph{Homotopy type theory} is a new branch of mathematics that combines aspects of several different fields in a surprising way. It is based on a recently discovered connection between \emph{homotopy theory} and \emph{type theory}.
12
+ It touches on topics as seemingly distant as the homotopy groups of spheres, the algorithms for type checking, and the definition of weak $\infty$-groupoids.
13
+
14
+ Homotopy type theory brings new ideas into the very foundation of mathematics.
15
+ On the one hand, there is Voevodsky's subtle and beautiful \emph{univalence axiom}.
16
+ The univalence axiom implies, in particular, that isomorphic structures can be identified, a principle that mathematicians have been happily using on workdays, despite its incompatibility with the ``official'' doctrines of conventional foundations.
17
+ On the other hand, we have \emph{higher inductive types}, which provide direct, logical descriptions of some of the basic spaces and constructions of homotopy theory: spheres, cylinders, truncations, localizations, etc.
18
+ Both ideas are impossible to capture directly in classical set-theoretic foundations, but when combined in homotopy type theory, they permit an entirely new kind of ``logic of homotopy types''.
19
+
20
+ This suggests a new conception of foundations of mathematics, with intrinsic homotopical content, an ``invariant'' conception of the objects of mathematics --- and convenient machine implementations, which can serve as a practical aid to the working mathematician.
21
+ This is the \emph{Univalent Foundations} program.
22
+
23
+ The present book is intended as a first systematic exposition of the basics of univalent foundations, and a collection of examples of this new style of reasoning --- but without requiring the reader to know or learn any formal logic, or to use any computer proof assistant.
24
+ We believe that univalent foundations will eventually become a viable alternative to set theory as the ``implicit foundation'' for the unformalized mathematics done by most mathematicians.
25
+
26
+ \bigskip
27
+
28
+ \begin{center}
29
+ {\Large
30
+ \textit{Get a free copy of the book at HomotopyTypeTheory.org.}}
31
+ \end{center}
32
+ }
bmpsize-hack.tex ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \RequirePackage{bmpsize-base}
2
+ \RequirePackage{ifpdf}
3
+ \makeatletter
4
+ % Fix \includegraphics for dvi mode, but only if not making a pdf
5
+ \ifpdf
6
+ \expandafter\@gobble
7
+ \else
8
+ \expandafter\@firstofone
9
+ \fi{%
10
+ \AtBeginDocument{%
11
+ \let\Gin@ii@old=\Gin@ii
12
+ \def\Gin@ii[#1]#2{%
13
+ \begingroup
14
+ \let\@found\@empty
15
+ \@for\@type:=\bmpsize@types\do{%
16
+ \ifx\@found\@empty
17
+ \@nameuse{bmpsize@read@\@type}{#2.\@type}%
18
+ \ifbmpsize@ok
19
+ \let\@found=\@type
20
+ \fi
21
+ \fi
22
+ \ifx\@found\@empty
23
+ \@nameuse{bmpsize@read@\@type}{#2}%
24
+ \ifbmpsize@ok
25
+ \let\@found=\@type
26
+ \fi
27
+ \fi
28
+ }%
29
+ \ifx\@found\@empty
30
+ \Gin@ii@old[#1]{#2}%
31
+ \else
32
+ \Gin@ii@old[natwidth=\bmpsize@width bp,natheight=\bmpsize@height bp,#1]{#2}%
33
+ \fi
34
+ \endgroup
35
+ }%
36
+ }
37
+ }
38
+ \makeatother
categories.tex ADDED
The diff for this file is too large to render. See raw diff
 
check-errata ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ ! grep -o '% merge of.\+' errata.tex
coq_introduction/.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ *.vo
2
+ *.glob
3
+ N*.cmi
4
+ N*.cmx
5
+ N*.cmxs
6
+ N*.native
7
+ N*.o
coq_introduction/Makefile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: all pdf html tex glob tidy clean
2
+
3
+ all: pdf html tex glob
4
+
5
+ glob: Reading_HoTT_in_Coq.v
6
+ coqc Reading_HoTT_in_Coq.v
7
+
8
+ tex: glob
9
+ coqdoc --latex --no-lib-name --toc Reading_HoTT_in_Coq.v
10
+
11
+ html: glob
12
+ coqdoc --html --no-lib-name --toc --no-index Reading_HoTT_in_Coq.v
13
+
14
+ pdf: tex
15
+ pdflatex Reading_HoTT_in_Coq.tex
16
+
17
+ tidy:
18
+ -rm Reading_HoTT_in_Coq.vo
19
+ -rm Reading_HoTT_in_Coq.out
20
+ -rm Reading_HoTT_in_Coq.log
21
+ -rm Reading_HoTT_in_Coq.aux
22
+ -rm NReading_HoTT_in_Coq*
23
+ -rm coqdoc.sty
24
+
25
+ clean: tidy
26
+ -rm Reading_HoTT_in_Coq.tex
27
+ -rm Reading_HoTT_in_Coq.html
28
+ -rm Reading_HoTT_in_Coq.glob
29
+ -rm Reading_HoTT_in_Coq.pdf
30
+ -rm coqdoc.css
31
+ -rm index.html
32
+
coq_introduction/Reading_HoTT_in_Coq.v ADDED
@@ -0,0 +1,1602 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (** * Reading Coq Files
2
+ *)
3
+
4
+ (**
5
+ ----------------------
6
+ If you're reading a #HTML# %PDF% file, it was generated from a Coq
7
+ file using Coq's documentation tool, "coqdoc".
8
+
9
+ If the file extension is ".v", you have the original Coq file and can
10
+ read it in any text editor ("Notepad" on Windows, "TextEdit" on Macs).
11
+ If you've installed CoqIDE, Coq's graphical editor, you can open it
12
+ there and verify the proofs. It can also be used on the web at
13
+ http://prover.cs.ru.nl/
14
+ *)
15
+ (* When reading the Coq file, you will see the coqdoc commands.
16
+ These include special text #only for HTML# or %only for LaTeX%
17
+ (or $LaTeX's math mode$). *)
18
+ (* The following stop coqdoc from changing the operators for HTML/PDF *)
19
+ (** remove printing -> *)
20
+ (** remove printing * *)
21
+ (** remove printing => *)
22
+ (** remove printing forall *)
23
+ (**
24
+ ----------------------
25
+ *)
26
+
27
+ (**
28
+ This document is a light-weight introduction to Coq using examples
29
+ from the first half of the book "Homotopy Type Theory". Our goal is
30
+ to give readers a taste of using a proof assistant. When you're done,
31
+ you will be able to read what other people have proven in Coq and
32
+ possibly prove some simple theorems of your own.
33
+
34
+ If you are interested in going further with Coq, at the end of this
35
+ document are instructions on how to install Coq, links to full
36
+ tutorials, and links to the Coq Reference Manual.
37
+
38
+ This file is written in "plain" Coq 8.4. This so it can be used with
39
+ the official distribution or on the web at http://prover.cs.ru.nl/.
40
+ This will prevent us from doing proofs that use "higher inductive
41
+ types", a feature that is only available with a special version of
42
+ Coq.
43
+
44
+ While this file stands on its own, where possible, we use the same
45
+ theorem names as the "HoTT" library for Coq. When you're done reading
46
+ this file, you should be able to read most of what has been proven in
47
+ that library.
48
+ *)
49
+
50
+ (** ** Background *)
51
+ (**
52
+ Coq is a good platform for homotopy type theory ("HoTT") work. Coq
53
+ has a long history - created in 1984 - and is supported by INRIA. Coq
54
+ has a number of features that have allowed it to be used for
55
+ significant proofs. Those proofs include the formalization of the
56
+ Four Color Theorem and the Feit-Thompson Theorem.
57
+
58
+ Coq uses a dependent type theory derived from "The Calculus of
59
+ Constructions". It differs from Martin-Loef's intentional
60
+ type theory, but, as we'll see, its propositional equality has the
61
+ same higher-groupoid structure that allows us to do HoTT.
62
+ *)
63
+
64
+ (** * Introduction *)
65
+ (**
66
+ Coq mostly works with two concepts:
67
+ - dependent functions (#Pi#$\Pi$-types)
68
+ - inductive types
69
+
70
+ Inductive types are used to implement the common types of type theory:
71
+ dependent pairs (#Sigma#$\Sigma$-types), disjoint unions, etc.. We'll
72
+ use those types as many of our examples.
73
+
74
+ We'll start with the familiar example of Peano's natural numbers.
75
+ *)
76
+
77
+ (** ** Natural Numbers *)
78
+ (**
79
+ The book's description of natural numbers says:
80
+ - the type N:U of natural numbers.
81
+ whose elements are constructed using
82
+ - 0:N, and
83
+ - the successor operation succ:N->N.
84
+
85
+ The equivalent in Coq is:
86
+ *)
87
+
88
+ Inductive nat : Set :=
89
+ | O : nat
90
+ | S : nat -> nat.
91
+
92
+ (**
93
+ As you can see, Coq's default library uses different names:
94
+ - [nat] instead of "N",
95
+ - [Set] instead of "U",
96
+ - [O] (the capital letter "oh") instead of "0", and
97
+ - [S] instead of "succ".
98
+
99
+ The command [Inductive] creates a new type. In this case, the type is
100
+ called [nat]. The type [nat] will live in the universe type called
101
+ [Set], which in Coq is the first universe or "the universe of small
102
+ types".
103
+
104
+ After the [:=] symbol comes the constructors for the new type. The
105
+ first says [O] (the capital letter "oh") is a term of type [nat]. The
106
+ second says [S] is a function from [nat]s to [nat]s.
107
+
108
+ After the last constructor is a period ("."). The command that
109
+ started with the word "Inductive" ends at the period. Every command
110
+ in Coq ends with a period.
111
+ *)
112
+
113
+ (** *** Properties of Constructors *)
114
+ (**
115
+ The constructors of an inductive type have a number of properties. In
116
+ a rough description, the major properties are:
117
+
118
+ - Constructors are axiomatic. The function [S] exists without any
119
+ definition - while it can be called, it cannot be evaluated.
120
+
121
+ - The constructors are exhaustive. There is no other way to create a
122
+ term of type [nat].
123
+
124
+ - Constructors create well-founded terms. There is no way to create a
125
+ self-referential [nat], such as having an [S] that returns itself.
126
+
127
+ - Terms created with different constructors are not equal. [O] is not
128
+ equal to [S] called with any other [nat].
129
+
130
+ If you know Peano's Axioms, these should all seem familiar. But these
131
+ conditions apply to every inductive type, not just [nat].
132
+
133
+ NOTE: Homotopy type theory changes some of these properties. The
134
+ univalence axiom and the path constructors of higher inductive types
135
+ create new elements of the identity type. Higher inductive types can
136
+ define terms created with different constructors as propositionally
137
+ equal.
138
+ *)
139
+
140
+ (** *** Examples of Natural Numbers *)
141
+ (**
142
+ Coq's command [Check] will print out the type of a term. Obviously,
143
+ [O] is a valid term and the [Check] will print the type [nat].
144
+ (Remember, [O] here is the capital letter "oh".)
145
+ *)
146
+ (* CoqIDE users: In CoqIDE, the Check command does nothing. Instead,
147
+ highlight the term, open the "Queries" menu, and select [Check]. *)
148
+
149
+ Check O.
150
+
151
+ (**
152
+ To get the number one, we have to call the function [S]. A function
153
+ call (or "function application") in Coq is done by juxtaposition, so
154
+ - gcd 4 6
155
+ instead of
156
+ - gcd(4, 6)
157
+
158
+ Thus, the number one is written:
159
+ *)
160
+
161
+ Check S O.
162
+
163
+ (**
164
+ For the number two, we have to add parentheses so that the second S is
165
+ interpreted as a function call rather than as a second argument to the
166
+ first S.
167
+ *)
168
+
169
+ Check S (S O).
170
+
171
+ (**
172
+ The number five is
173
+ *)
174
+
175
+ Check S (S (S (S (S O)))).
176
+
177
+
178
+ (**
179
+ By default, Coq loads a plugin that interprets decimal numbers as [nat]s.
180
+ *)
181
+
182
+ Require Import Datatypes.
183
+ Declare ML Module "nat_syntax_plugin".
184
+
185
+ (**
186
+ Thus, we could have checked the number five simply by doing
187
+ *)
188
+
189
+ Check 5.
190
+
191
+ (**
192
+ Now that we have seen the basics of Coq's inductive types, let's see
193
+ its other main feature: dependent functions.
194
+ *)
195
+
196
+ (** ** Identity function *)
197
+ (**
198
+ We'll start by defining the identity function on natural numbers and
199
+ then we'll write a dependently-typed identity function that works for
200
+ any type.
201
+
202
+ The identity function (or identity map) for natural numbers is:
203
+ *)
204
+
205
+ Definition idmap_nat : nat -> nat :=
206
+ fun (n:nat) => n.
207
+
208
+ (**
209
+ The [Definition] command assigns a value of a given type to a name.
210
+ Its format is:
211
+ - Definition <name> : <type> := <value> .
212
+
213
+ In our example, the name is "idmap_nat". The type is a function from
214
+ [nat] to [nat]. (Notice how the "->" operator approximates the arrow
215
+ used in the book for non-dependently typed functions.) The value for
216
+ "idmap_nat" is a function.
217
+
218
+ In Coq, a function is written:
219
+ - fun <params> => <term>
220
+
221
+ In the book, this would have been written as
222
+ - <param> #\mapsto# $\mapsto$ <term>
223
+ or
224
+ - #\lambda# $\lambda$ <param>.<term>
225
+
226
+ In the example, the function has one parameter, "n", which has type
227
+ [nat]. The function's result is simply "n" itself, since this is the
228
+ identity function.
229
+ *)
230
+
231
+ (** *** Shorthand *)
232
+ (**
233
+ Coq has a shorthand for defining functions. Here is the identity
234
+ function for [nat]s again.
235
+ *)
236
+
237
+ Definition idmap_nat_short (n:nat) : nat :=
238
+ n.
239
+
240
+ (**
241
+ Notice that the parameter is put immediately after the function's name
242
+ and we no longer need "fun ... =>".
243
+ *)
244
+
245
+ (** *** Examples of idmap_nat *)
246
+ (**
247
+ The Coq command [Compute] will evaluate a function and print the result.
248
+ *)
249
+ (* !!! There is no equivalent in CoqIDE? *)
250
+
251
+ Compute idmap_nat (S O).
252
+
253
+ (** prints (S O), like an identity function should. *)
254
+
255
+
256
+ (** *** Dependant types *)
257
+ (**
258
+ "idmap_nat" is not dependently typed, so we were able to use the arrow
259
+ ("->") to denote its type. We could have written the function's type
260
+ as if it was dependently typed. In the book, dependent types are
261
+ declared with a capital "#Pi#$\Pi$". Coq uses the keyword [forall].
262
+ *)
263
+
264
+ Definition idmap_nat_dep : forall nn:nat, nat :=
265
+ fun n:nat => n.
266
+
267
+ (**
268
+ In Coq, a dependent function type is written:
269
+ - forall <params> , <type>
270
+
271
+ In the book, this would have used capital #Pi#$\Pi$ and a subscript:
272
+ - #\Pi#$\Pi$ (<param>) <type>
273
+
274
+ As you'd expect, the names in the param list of a [forall] expression
275
+ are only bound inside the "<type>" part of the [forall]. In this
276
+ example, the parameter "nn" cannot be used when defining the function.
277
+ (Usually, we use the same name in the [forall] and the [fun] parts;
278
+ different ones were used here to demonstrate the point.)
279
+
280
+ A [forall] can have multiple parameters. If a parameter is
281
+ dependently typed on another parameter, the dependent one must come
282
+ later in the list. (We'll see an example soon.)
283
+
284
+
285
+ Now that we know how to write a dependent function type, we can
286
+ write an identity function that works for any type.
287
+ *)
288
+
289
+ Definition idmap : forall A:Type, A -> A :=
290
+ fun (A:Type) (x:A) => x.
291
+
292
+ (**
293
+ "idmap" is a dependently-typed function: its return type depends on the
294
+ type of its first parameter. Therefore, we had to use the [forall]
295
+ operator for that parameter.
296
+
297
+ In Coq, the type "Type" refers to _some_ universe type. Coq will do
298
+ the work of figuring out which universe type, as long as we don't
299
+ implicitly cause impredicativity.
300
+
301
+ We can, of course, rewrite the definition of "idmap" using Coq's
302
+ shorthand for functions.
303
+ *)
304
+
305
+ Definition idmap_short (A:Type) (x:A) : A :=
306
+ x.
307
+
308
+ (** *** Examples of idmap *)
309
+
310
+ Compute idmap nat (S (S O)).
311
+
312
+ (** Prints (S (S O)), like an identity function should. *)
313
+
314
+ (**
315
+ Coq has a number of features for making it easier to define and call functions. We've already seen the "shorthand" for definitions. In the rest of this section, we'll see:
316
+ - partial application,
317
+ - implicit arguments, and
318
+ - type inferencing.
319
+ *)
320
+
321
+ (** *** Partial application *)
322
+ (**
323
+ Since we've defined the identity function for any type, we can now
324
+ define the identity function for [nat]s in terms of it.
325
+ *)
326
+
327
+ Definition idmap_nat_from_idmap : nat -> nat :=
328
+ idmap nat.
329
+
330
+ (**
331
+ The value "idmap nat" is a function call. It calls the function
332
+ "idmap" with the type [nat]. Since "idmap" expected 2 arguments and
333
+ we only provided 1, this is called a "partial application". The
334
+ result of the partial application is a function that is still waiting
335
+ for 1 more argument. That function is the identity function on [nat]s
336
+ and this command assigns it a name.
337
+
338
+
339
+ We can check this new function by passing the second of the two arguments.
340
+ *)
341
+
342
+ Compute idmap_nat_from_idmap (S (S (S O))).
343
+
344
+
345
+ (** *** Implicit Arguments *)
346
+ (**
347
+ Calling "idmap nat (S O)" seems repetitive because Coq can determine
348
+ that "(S O)" has type [nat]. (Remember, in type theory, an element
349
+ can belong to only one type.) We can use Coq's implicit arguments
350
+ feature to tell Coq to always infer some argument values.
351
+
352
+ Curly braces are used to mark a parameter for implicit arguments.
353
+ *)
354
+
355
+ Definition idmap_implicit {A:Type} (x:A) : A :=
356
+ x.
357
+
358
+ (**
359
+ Now, we can call the general identity function with just one argument.
360
+ *)
361
+
362
+ Compute idmap_implicit (S O).
363
+
364
+ (**
365
+ Implicit arguments are usually handy, but sometimes they get in the
366
+ way. Before, we declared a version of "idmap_nat" by calling "idmap".
367
+ We did it by passing "nat" as the first parameter to "idmap".
368
+
369
+ If we call "idmap_implicit" with "nat", Coq will assume that [nat] is
370
+ "x" and use the type of [nat], which is [Set], for the implicit
371
+ parameter. Obviously, we don't want that. We can prevent Coq from
372
+ using implicit arguments by putting an "at sign" ("@") in front of the
373
+ function name.
374
+ *)
375
+
376
+ Definition idmap_nat_from_idmap_implicit : nat -> nat :=
377
+ @idmap_implicit nat.
378
+
379
+ Compute idmap_nat_from_idmap_implicit (S O).
380
+
381
+ (**
382
+ Another way to mark parameters for implicit arguments is with the
383
+ "Arguments" command. Because that command has a lot of features and
384
+ complex syntax, we won't go into its details in this document.
385
+ Nonetheless, we will use the command so that our examples look like
386
+ those of the HoTT Coq library.
387
+ *)
388
+
389
+
390
+ (** *** Type Inferencing *)
391
+ (**
392
+ In many cases, Coq can infer the type of a parameter or even a whole
393
+ function without us have to state it explicitly.
394
+ *)
395
+
396
+ Definition idmap_inferred {A} (n:A) :=
397
+ n.
398
+
399
+ (**
400
+ Here, both the type of "A" (which is [Type]) and the returned type of
401
+ the function (which is "A") are both inferred. As you can see, this
402
+ allows very concise definitions.
403
+ *)
404
+
405
+ Compute idmap_inferred (S (S O)).
406
+
407
+
408
+ (** ** Addition of Natural Numbers *)
409
+ (**
410
+ As the last part of our introduction, we define addition as a function
411
+ on natural numbers and show how to use the operator "+" to call it.
412
+ *)
413
+ (** *** Induction *)
414
+ (**
415
+ When we issued the command [Inductive] to create the type [nat], Coq
416
+ also created a function "nat_rect" for induction on natural numbers.
417
+ Its type is:
418
+ [[
419
+ nat_rect
420
+ : forall P : nat -> Type,
421
+ P 0 ->
422
+ (forall n : nat, P n -> P (S n)) ->
423
+ forall n : nat, P n
424
+ ]]
425
+ This is identical to the induction constant named "ind_N" in the HoTT
426
+ book. We can use this function to define addition.
427
+ *)
428
+
429
+ Definition plus (m n: nat) : nat :=
430
+ nat_rect (fun _ => nat) n (fun m' sum => S sum) m.
431
+
432
+ (**
433
+ The function "plus" is defined by a call to "nat_rect" with 4
434
+ arguments:
435
+
436
+ The first argument determines the type of the result. Addition always
437
+ results in a [nat], so the first argument is a function that always
438
+ returns the type [nat]. When specifying the function, we used
439
+ underscore ("_") which is a special parameter name that indicate to
440
+ Coq that the parameter isn't used in the function. (Multiple
441
+ parameters can be named "_" if they are all not needed.)
442
+
443
+ The second argument to "nat_rect" is "n". This is the base case; the
444
+ result when "m" is zero.
445
+
446
+ The third argument is the inductive case. It takes "m"-prime and the
447
+ result (sum) upto "m"-prime and produces the result for the successor
448
+ of "m"-prime, which is just the sum plus one.
449
+
450
+ The fourth argument is "m", the value to calculate the sum at.
451
+ *)
452
+
453
+ Compute plus 4 2.
454
+
455
+ (**
456
+ In this example, we directly called the induction constant "nat_rect".
457
+ This is one way to do induction in Coq. The other way is similar to
458
+ the "pattern matching" describing in the HoTT book.
459
+ *)
460
+
461
+ (** *** Match Expressions *)
462
+ (**
463
+ Addition can also be defined using a "match" expression.
464
+ *)
465
+
466
+ Fixpoint plus_using_match (m n: nat) : nat :=
467
+ match m with
468
+ | 0 => n
469
+ | S m' => S (plus_using_match m' n)
470
+ end.
471
+
472
+ (**
473
+ The [match] expression represents case analysis on an element of an
474
+ inductive type. Since every canonial element of an inductive type
475
+ must have been made with a constructor, the [match] expression gives a
476
+ value that depends on which constructor was used. The [match]
477
+ expression is very expressive, but a simplified understanding is:
478
+ [[
479
+ match <element> with
480
+ | <constructor_pattern> => <value>
481
+ | <constructor_pattern> => <value>
482
+ ...
483
+ end
484
+ ]]
485
+ NOTE: In HoTT, not every element of the identity type is made with a
486
+ constructor. Nonetheless, this case analysis still works. See the
487
+ HoTT book for an explanation.
488
+
489
+ In our example, "m" is treated as a canonical [nat]. If "m" was made
490
+ with the constructor constant [O] (capital-oh), the value of the
491
+ [match] expression is "n". If "m" was made with the constructor
492
+ function [S] called with some other [nat], called "m"-prime here, then
493
+ the value of the match expression is the successor of "m"-prime plus
494
+ "n".
495
+
496
+ Notice that the function is defined in terms of itself. In order to
497
+ allow that, we had to use command [Fixpoint] instead of the usual
498
+ [Definition].
499
+
500
+ Coq will transform the match expression into a call to "nat_rect". If
501
+ it cannot, Coq will print an error message.
502
+ *)
503
+ (** *** Notations *)
504
+ (**
505
+ We could always represent addition with "plus 4 2", but it is more
506
+ natural to read and write "4 + 2". We tell Coq to use this format
507
+ through [Notation] command.
508
+ *)
509
+
510
+ Notation "n + m" := (plus n m) : nat_scope.
511
+ Open Scope nat_scope.
512
+
513
+ (**
514
+ Now we can write.
515
+ *)
516
+
517
+ Compute 4 + 2.
518
+
519
+ (**
520
+ We've actually already been using a notation. The "->" operator is
521
+ defined as:
522
+ *)
523
+
524
+ Reserved Notation "x -> y" (at level 99, right associativity, y at level 200).
525
+ Notation "A -> B" := (forall (_ : A), B) : type_scope.
526
+
527
+ (**
528
+ Because [Notation]s could conflict, every [Notation] goes into a
529
+ scope. Here, the scopes are called "nat_scope" and "type_scope".
530
+ When a scope is opened, all of its notations become available to be
531
+ used. If two notations in open scopes conflict, the one opened more
532
+ recently is used. Here, "nat_scope" was opened by the command "Open
533
+ Scope nat_scope". The other, "type_scope", is special and is open
534
+ anywhere a type is expected.
535
+
536
+ If we ever wanted to stop using the plus [Notation], we could issue the
537
+ command "Close Scope nat_scope".
538
+
539
+
540
+ A more complex example is:
541
+ *)
542
+
543
+ Definition compose {A B C : Type} (g : B -> C) (f : A -> B) :=
544
+ fun x => g (f x).
545
+
546
+ Notation "g 'o' f" := (compose g f) (at level 40, left associativity).
547
+
548
+ (**
549
+ The single quotes are used to turn the letter "o" (small-oh) into an
550
+ operator.
551
+
552
+ "at level 40" indicates the precedence of the operator. A lower
553
+ precedence level means that an operator "binds more tightly". That
554
+ is, that a [Notation] is selected over another. Thus, for natural
555
+ numbers, multiplication is at level 40, while addition is at 50.
556
+ (Those operators have default precedences set by a "Reserved Notation"
557
+ command.)
558
+
559
+ "left associativity" is what you would expect.
560
+ *)
561
+
562
+ (**
563
+ That covers the basics of reading Coq theorems. The rest of this
564
+ document goes over the types, functions, and operators that are
565
+ commonly used in type theory and in HoTT.
566
+ *)
567
+
568
+ (** * Common Types of Type Theory *)
569
+ (**
570
+ After a short discussion about universe types in Coq, we go through
571
+ how each of the types that are commonly used in type theory are
572
+ implemented as inductive types.
573
+ *)
574
+
575
+ (** ** Universes *)
576
+ (**
577
+ The HoTT book describes an infinite hierarchy of universes U_0, U_1,
578
+ U_2, ... that are cumulative. That is, that every type in a universe
579
+ is also in every higher universe.
580
+
581
+ Coq's universes have a similar structure, except that the lowest
582
+ universe is split into two: "Prop" and "Set".
583
+
584
+ The "Prop" universe contains propositions - statements that can be
585
+ proven or disproven. In practice, that means types that are shown to
586
+ be either inhabited or uninhabited. Types in "Prop" must be "proof
587
+ irrelevant": it cannot matter which term inhabits the type, just that
588
+ it is inhabited.
589
+
590
+ The "Set" universe contains all other "small types". (Small types are
591
+ ones that do not contain references to a universe.) Since in homotopy
592
+ type theory every equality proof is relevant, all of our inductive
593
+ types will reside in the "Set" universe.
594
+
595
+ The infinite number of universes above "Prop" and "Set" are known as
596
+ "Type(1)", "Type(2)", "Type(3)", etc. However, the user only ever has
597
+ to enter "Type". Coq will, behind the scenes, assigned a numbered
598
+ universe to every usage of "Type", as long as there is no
599
+ impedicativity. (If you implicitly cause impredicativity, you'll see
600
+ an error message.)
601
+ *)
602
+
603
+ (** ** Dependent Function Types *)
604
+ (**
605
+ The most commonly used type in type theory is the function. This type
606
+ in Coq was covered in detail earlier. A summary of its usage is:
607
+
608
+ The dependent type:
609
+ - Book: #\Pi#$\Pi$ (<params>) <type>
610
+ - Coq: forall <params> , <type>
611
+
612
+ The non-dependent type:
613
+ - Book: <type> #->#$\to$ <type>
614
+ - Coq: <type> -> <type>
615
+
616
+ An unnamed function:
617
+ - Book: <param> #\mapsto#$\mapsto$ <term>
618
+ - Book: #\lambda#$\lambda$ <param> . <term>
619
+ - Coq: fun <params> => <term>
620
+
621
+ A function call (or "function application"):
622
+ - Book: <fun>(<arg1>, <arg2>)
623
+ - Coq: <fun> <arg1> <arg2>
624
+
625
+ Function composition:
626
+ - Book: <fun> #o#$\circ$ <fun>
627
+ - Coq: <fun> o <fun>
628
+
629
+ *)
630
+ (** ** Non-Dependent Pair Types *)
631
+ (**
632
+ In the HoTT book, the non-dependent pair type can be considered a
633
+ special case of a dependent pair. For example, the projection
634
+ functions work the same on both the non-dependent and dependent types.
635
+ In Coq, however, it is more convenient to have two separate types.
636
+
637
+ In the book, the non-dependent pair type, or cartesian product, requires
638
+ - a type A : U, and
639
+ - a type B : U
640
+ and is written
641
+ - A #\times# $\times$ B
642
+
643
+ In Coq, the inductive type is written:
644
+ *)
645
+
646
+ Inductive prod {A B:Type} : Type :=
647
+ pair : A -> B -> @prod A B.
648
+
649
+ (**
650
+ Here, "pair" is a constructor that takes two arguments, an element
651
+ of type "A" and an element of type "B", and produces an element of
652
+ type "prod A B". So, "prod A B" is the type of non-dependent pairs
653
+ and "pair a b" creates a pair.
654
+
655
+ This inductive type definition uses a shortcut. The types "A" and "B"
656
+ are used in the constructor "pair", but are not listed as parameters.
657
+ This is because any parameters listed immediately after the type name
658
+ ("prod") are treated as parameters to both the type of "prod" and to
659
+ all constructors.
660
+
661
+
662
+ An equivalent (but longer) definition of "prod" would be
663
+ *)
664
+
665
+ Inductive prod_long : Type -> Type -> Type :=
666
+ pair_long : forall {A B: Type}, A -> B -> prod_long A B.
667
+
668
+ (**
669
+ When Coq creates "prod", it also creates the induction function
670
+ "prod_rect". This is the inductive constant, similar to "nat_rect" we
671
+ mentioned earlier. What we didn't say earlier is that there are _two_
672
+ other induction functions: "prod_rec" and "prod_ind" (as well as
673
+ "nat_rec" and "nat_ind").
674
+
675
+ The reason for three induction constants is that there are three kinds
676
+ of universes: "Prop", "Set", and "Type". The function "prod_rect" and
677
+ "nat_rect" puts the types they create in the "Type" universe.
678
+ Likewise, "prod_rec" and "nat_rec" put the resulting type in "Set" and
679
+ "prod_ind" and "nat_ind" put it in "Prop". When doing HoTT, it is
680
+ usually safe to just use the "rect" function.
681
+
682
+ When we use a [match] expression for induction, Coq uses type
683
+ inferencing to chose the correct induction function.
684
+
685
+ Speaking of duplication, Coq has a second non-dependent pair type
686
+ called "and". This type takes arguments from the "Prop" universe and
687
+ puts the resulting type in "Prop". But, since we're not using "Prop",
688
+ we won't cover it here.
689
+ *)
690
+
691
+
692
+ (** *** Pair Notation *)
693
+ (**
694
+ From the definition of "pair_long", it is clear that the constructor
695
+ takes 4 parameters: two types and an element of each type. But given
696
+ the two elements, Coq can always infer their types. Thus, we can
697
+ create a pair using just the two elements. For example:
698
+ *)
699
+
700
+ Check (pair 4 2).
701
+
702
+ (**
703
+ In the book, we use "A #\times# $\times$ B" to denote the type and
704
+ "(a,b)" to denote a pair. Coq allows us to use a similar syntax by
705
+ using the [Notation] command.
706
+ *)
707
+
708
+ Notation "x * y" := (@prod x y) : type_scope.
709
+ Notation "( x , y , .. , z )" := (pair .. (pair x y) .. z) : core_scope.
710
+
711
+ (**
712
+ Now when Coq sees "nat * nat", it will translate it into "(prod nat
713
+ nat)" and, likewise, translate "(4, 2)" into "(pair 4 2)". The second
714
+ [Notation] command will also convert tuples of any length into
715
+ pairs-within-pairs.
716
+
717
+ Now, we can write the type and elements of dependent pairs like we're
718
+ accustomed.
719
+ *)
720
+
721
+ Check (nat * nat)%type.
722
+ Check (4,2).
723
+
724
+ (**
725
+ The "%%type" forces Coq to use the "type_scope" to interpret the
726
+ expression. It is needed because [Check] does not expecting a type.
727
+ *)
728
+
729
+ (** *** Projection functions *)
730
+ (**
731
+ The projection functions extract the first or second part of a pair.
732
+ For non-dependent pairs in Coq, these are called "fst" and "snd".
733
+ *)
734
+
735
+ Section projections.
736
+ Context {A : Type} {B : Type}.
737
+
738
+ Definition fst (p:A * B) :=
739
+ match p with
740
+ | (x, y) => x
741
+ end.
742
+
743
+ Definition snd (p:A * B) :=
744
+ match p with
745
+ | (x, y) => y
746
+ end.
747
+
748
+ End projections.
749
+
750
+ (**
751
+ The section feature is used here to simplify the list of parameters.
752
+ The section starts with "Section projections" and ends at "End
753
+ projections". The statement "Context ..." signals that "A" and "B"
754
+ are parameters to every subsequent definition that uses them inside
755
+ the section. Thus, both "fst" and "snd" have two type parameters and,
756
+ because curly braces ("{", "}") were used, those parameters are
757
+ implicit.
758
+
759
+ In the [match] expressions, the constructor function "pair" is written
760
+ using the notation "(x, y)".
761
+ *)
762
+
763
+ Compute fst (4,2).
764
+ Compute snd (4,2).
765
+
766
+
767
+ (** ** Dependent Pair Types *)
768
+ (**
769
+ In the HoTT book, the dependent pair type, also called #Sigma#$\Sigma$-type,
770
+ requires
771
+ - a type A : U, and
772
+ - a type family P : A -> U
773
+ and is written
774
+ - #\Sigma#$\Sigma$ (x:A) P(x)
775
+
776
+ In Coq, it is defined by:
777
+ *)
778
+
779
+ Inductive sigT {A:Type} (P:A -> Type) : Type :=
780
+ existT : forall x:A, P x -> sigT P.
781
+
782
+ (**
783
+ Here, "existT" is the constructor that takes two arguments, an element
784
+ "x" of type "A" and an element (unnamed) of type "P x", and produces
785
+ an element of "sigT A P". So, "sigT A P" is the type of pairs and
786
+ "existT x p" creates a pair (when "p" has type "P x").
787
+
788
+ If you read closely, you'll see that the type produced by "existT" is
789
+ "sigT P" not "sigT A P". The "A" can always be inferred from "P".
790
+
791
+ To repeat (for the last time), every time Coq creates a new inductive
792
+ type, like "sigT" here, Coq also creates three induction functions,
793
+ "sigT_ind", "sigT_rec" and "sigT_rect". These functions put their
794
+ results into the "Prop", "Set", and "Type" universes (respectively).
795
+ Most of the time, we don't care, since we'll use a [match] expression
796
+ that infers which induction function to use.
797
+
798
+ Like "prod" with "and", Coq has dependent pair types besides "sigT".
799
+ The types "ex" (short for "there exists") and "sig" both act as
800
+ dependent pairs, but use the "Prop" universe. Again, we're not using
801
+ "Prop", we won't cover them here.
802
+ *)
803
+
804
+ (** *** Pair Notation *)
805
+ (**
806
+ To create a dependent pair, we must supply a function taking an
807
+ element of the first type to a type for the second element. Since we
808
+ haven't defined propositional equality, we can't do much that is
809
+ interesting here. For now, we can create a pair of [nat]s by supplying
810
+ a function that always returns [nat].
811
+ *)
812
+
813
+ Check (existT (fun _:nat => nat) 4 2).
814
+
815
+ (**
816
+ Obviously, that expression is long to write and difficult to read and
817
+ we want to use a [Notation] for it. Since Coq already uses "(a,b)"
818
+ for non-dependent pairs, the HoTT Coq library uses the semicolon here.
819
+ *)
820
+
821
+ Notation "{ x : A & P }" := (sigT (fun x:A => P)) : type_scope.
822
+ Notation "( x ; y )" := (existT _ x y) : fibration_scope.
823
+ Open Scope fibration_scope.
824
+
825
+ (**
826
+ When Coq sees "(4;2)", it will translate that into "(existT _ 4 2)".
827
+ The underscore ("_") in a function application indicates that Coq
828
+ should try to infer the argument or ask for help from the user.
829
+
830
+ Here the dependent-pair [Notation] goes into the "fibration_scope".
831
+ Since that is a new scope, we must "Open" it to make the [Notation]
832
+ available.
833
+ *)
834
+
835
+ (**
836
+ Below is an example using the dependent pair "(4;2)". It is necessary
837
+ to say what its type is, so that Coq can infer the hidden argument to
838
+ "existT".
839
+ *)
840
+
841
+ Definition dep_pair_example_type :=
842
+ { x:nat & nat }.
843
+ Definition dep_pair_example : dep_pair_example_type :=
844
+ (4;2).
845
+ Check dep_pair_example.
846
+
847
+ (** *** Projection functions *)
848
+ (**
849
+ The projection functions extract the first or second part of a pair.
850
+ For dependent pairs in Coq, these are called "projT1" and "projT2".
851
+ *)
852
+
853
+ Section Projections.
854
+
855
+ Context {A : Type}.
856
+ Context {P : A -> Type}.
857
+
858
+ Definition projT1 (x:sigT P) : A :=
859
+ match x with
860
+ | (a; _) => a
861
+ end.
862
+
863
+ Definition projT2 (x:sigT P) : P (projT1 x) :=
864
+ match x return P (projT1 x) with
865
+ | (_; h) => h
866
+ end.
867
+
868
+ End Projections.
869
+
870
+ (**
871
+ These are pretty much as you'd expect. There are two items worth
872
+ commenting on.
873
+
874
+ The underscore ("_") in the constructor pattern is used to indicate an
875
+ unused parameter in the [match] expression. We've seen this before in
876
+ parameters to [fun] and [forall].
877
+
878
+ The other feature worth commenting on is the "return <type>" in the
879
+ [match] expression of "projT2". This syntax is used when the [match]
880
+ expression has a type that depends on the element of the inductive
881
+ type being matched on.
882
+
883
+ We will not go into all the details on the variations of the [match]
884
+ expression, because this document is about reading what has been
885
+ proven - that is, the _type_ of an expression - and not about
886
+ understanding the proof - which is the value of the expression.
887
+
888
+
889
+ The [Notation]s for the projectors are:
890
+ *)
891
+
892
+ Notation "x .1" := (projT1 x) (at level 3) : fibration_scope.
893
+ Notation "x .2" := (projT2 x) (at level 3) : fibration_scope.
894
+
895
+ (**
896
+ And some examples of it are:
897
+ *)
898
+
899
+ Check (dep_pair_example .1).
900
+ Check (dep_pair_example .2).
901
+
902
+
903
+ (** ** Disjoint Union Type*)
904
+ (**
905
+ In the HoTT book, the disjoint union type, also called coproduct,
906
+ requires
907
+ - a type A : U, and
908
+ - a type B : U
909
+ and is written
910
+ - A + B.
911
+
912
+ In Coq, it is defined by:
913
+ *)
914
+
915
+ Inductive sum (A B:Type) : Type :=
916
+ | inl : A -> sum A B
917
+ | inr : B -> sum A B.
918
+
919
+ Arguments inl {A B} _ , [A] B _.
920
+ Arguments inr {A B} _ , A [B] _.
921
+
922
+ Notation "x + y" := (sum x y) : type_scope.
923
+
924
+ (**
925
+ Ignoring the "Arguments" command, which we aren't covering in this
926
+ document, the rest should be familiar by now.
927
+
928
+ Since the type "sum" has two constructors, "inl" and "inr", we can
929
+ have two examples that build an element of a type.
930
+ *)
931
+
932
+ Definition dijoint_union_example_type :=
933
+ (nat + (nat * nat))%type.
934
+ Definition dijoint_union_example1 : dijoint_union_example_type :=
935
+ inl 4.
936
+ Definition dijoint_union_example2 : dijoint_union_example_type :=
937
+ inr (4,2).
938
+
939
+ (**
940
+ Likewise, any [match] expression needs to handle both constructors.
941
+ *)
942
+
943
+ Definition left_or_first (a : dijoint_union_example_type) : nat :=
944
+ match a with
945
+ | inl x => x
946
+ | inr p => fst p
947
+ end.
948
+
949
+ (** ** Zero, One, and Two Types *)
950
+ (**
951
+ The finite types with 0, 1, and 2 elements play special roles in type
952
+ theory. In standard Coq those types are:
953
+ *)
954
+
955
+ Inductive Empty_set : Set :=.
956
+
957
+ Inductive unit : Set :=
958
+ tt : unit.
959
+
960
+ Inductive bool : Set :=
961
+ | true : bool
962
+ | false : bool.
963
+
964
+ (**
965
+ The HoTT Coq library uses slightly different names for the types.
966
+ (Although the constructors have the same names.)
967
+ *)
968
+
969
+ Definition Empty := Empty_set.
970
+ Definition Unit := unit.
971
+ Definition Bool := bool.
972
+
973
+ (**
974
+ Standard Coq also has finite types that live in the "Prop" universe.
975
+ The type "True" has one constructor and the type "False" has zero.
976
+ *)
977
+ (** *** Not operator *)
978
+ (**
979
+ In HoTT, the not operator indicates that elements of a type can be
980
+ mapped to the elements of the empty (zero) type.
981
+ *)
982
+
983
+ Definition not (A:Type) : Type := A -> Empty.
984
+ Notation "~ x" := (not x) : type_scope.
985
+
986
+ (**
987
+ In Standard Coq, logic is usually done in the "Prop" universe, so this
988
+ operator maps to the type "False" that lives there (instead of "Empty"
989
+ which lives in "Set").
990
+ *)
991
+
992
+ (** *** Absurdity Implies Anything *)
993
+ (**
994
+ Obviously, a [match] expression for the [Unit] type handles one
995
+ constructor and the match expression for the [Bool] type handles two
996
+ constructors. But what about the [Empty] type? It has no
997
+ constructors, so its [match] expression is empty. In logic, this is the
998
+ equivalent of "ex falso quodlibet" or "from contradiction, anything".
999
+ *)
1000
+
1001
+ Definition contradiction_implies_anything (a:Empty) (C:Type) : C :=
1002
+ match a with
1003
+ end.
1004
+
1005
+ (**
1006
+ The induction constant for Empty is
1007
+ [[
1008
+ Empty_rect : forall (P : Empty -> Type) (e : Empty), P e
1009
+ ]]
1010
+ *)
1011
+
1012
+
1013
+ (** ** Identity Type *)
1014
+ (**
1015
+ The identity type is defined as:
1016
+ *)
1017
+
1018
+ Inductive paths {A : Type} (a : A) : A -> Type :=
1019
+ idpath : paths a a.
1020
+
1021
+ (**
1022
+ Where "paths" equates to "Id" in the HoTT book and "idpath" to "refl".
1023
+
1024
+ The standard Coq library defines equality using a type "eq" with
1025
+ constructor "refl". This type is different from "paths" because "eq"
1026
+ is in the "Prop" universe and its elements are _not_ proof-relevant.
1027
+ To do homotopy type theory, we need an equality that is proof-relevant
1028
+ and exists in the "Type" universe.
1029
+
1030
+ The operator for the identity type is the equal sign. There is also a
1031
+ [Notation] that allows the user to explicitly state the type.
1032
+ *)
1033
+
1034
+ Notation "x = y :> A" := (@paths A x y) : type_scope.
1035
+ Notation "x = y" := (x = y :>_) : type_scope.
1036
+
1037
+ Arguments idpath {A a} , [A] a.
1038
+ Arguments paths_ind [A] a P f y p.
1039
+ Arguments paths_rec [A] a P f y p.
1040
+ Arguments paths_rect [A] a P f y p.
1041
+
1042
+ Notation "1" := idpath : path_scope.
1043
+ Local Open Scope path_scope.
1044
+
1045
+
1046
+ (** * Homotopy Type Theory *)
1047
+ (**
1048
+ Now that we have seen the common types of type theory, we can use them
1049
+ to do homotopy type theory. This section will demonstrate some
1050
+ theorems of HoTT and introduce the types used to do HoTT in Coq.
1051
+ Because this file is using "standard" Coq, we cannot demonstrate
1052
+ higher inductive types.
1053
+ *)
1054
+
1055
+ (** ** Properties of Paths *)
1056
+ (**
1057
+ For every element of a type, there is a constant path. This is the
1058
+ same notion as equality being reflexive. This property is witnessed
1059
+ by "idpath", which has type:
1060
+ [[
1061
+ @idpath
1062
+ : forall {A : Type} (a : A), a = a
1063
+ ]]
1064
+
1065
+ The "theorem" of reflexivity can be stated "for every type and for
1066
+ every element of that type, there is an equality with that element
1067
+ equal to itself". In Coq, that theorem is "proven" by function that
1068
+ takes a type, an element of that type, and returns an element
1069
+ witnessing the equality.
1070
+
1071
+ For example, if we wanted to demonstrate that "4=4", we could do:
1072
+ *)
1073
+
1074
+ Check @idpath nat 4.
1075
+
1076
+ (**
1077
+ which is an element that has type "4=4". Obviously, with implicit
1078
+ arguments, we do not need "nat" and can use just "idpath 4". Not so
1079
+ obviously, we can go a step further. If type inferencing can determine
1080
+ the type returned by "idpath", such as "4=4" in our example, then
1081
+ implicit arguments can fill in the "4" as well! So most of the time
1082
+ you will just see "idpath" or its [Notation], "1" (in the "path_scope"
1083
+ scope).
1084
+ *)
1085
+
1086
+ Check idpath : 4 = 4.
1087
+ Check 1 : 4 = 4.
1088
+
1089
+ (**
1090
+ Next, we prove that every path has an inverse. (Or, "equality is
1091
+ symmetric".) In Coq, this proof looks like a function that takes any
1092
+ path and returns its inverse.
1093
+ *)
1094
+
1095
+ Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
1096
+ := match p with
1097
+ | idpath => idpath
1098
+ end.
1099
+
1100
+ Arguments inverse {A x y} p : simpl nomatch.
1101
+
1102
+ Notation "p ^" := (inverse p) (at level 3) : path_scope.
1103
+
1104
+ (**
1105
+ This [match] expression hides a number of type inferences and implicit
1106
+ arguments. The type of "p" is "paths A x y", which had to be
1107
+ constructed using "idpath A x" with "y" being the same as "x". The
1108
+ value returned by the match has type "paths A y x", so Coq can infer
1109
+ that the arguments to "idpath" are "A" and "x" and, because "y" is the
1110
+ same as "x", intrepret the resulting "A x x" as "A y x".
1111
+
1112
+ Notice how this proof is similar to the HoTT book's proof where "y"
1113
+ is assumed to be the same as "x" and "refl_x" is mapped to "refl_x".
1114
+
1115
+
1116
+ Next, we prove that paths concatenate. (Equality is transitive.)
1117
+ Like before, this is a function that takes any path from "x" to "y"
1118
+ and any path from "y" to "z" and returns a path from "x" to "z".
1119
+ *)
1120
+
1121
+ Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
1122
+ match p, q with
1123
+ | idpath, idpath => idpath
1124
+ end.
1125
+
1126
+ Arguments concat {A x y z} p q : simpl nomatch.
1127
+
1128
+ Notation "p @ q" := (concat p q) (at level 20) : path_scope.
1129
+
1130
+ (**
1131
+ The comma in the [match] expression is part of the [match] syntax. It
1132
+ is _not_ a non-dependent pair. It is a shortcut that allows two
1133
+ inductions to be done using a single [match] expression. When the
1134
+ [match] gets translated into two calls to "paths_rect", we don't care
1135
+ in which order the calls happen; the results are the same. As the
1136
+ HoTT book explains, this proof could be done with just one call to
1137
+ "path_rect", but the result from a single induction would not behave
1138
+ symmetrically.
1139
+
1140
+ The following proofs show the relationship of "idpath", "inverse" and
1141
+ "concat".
1142
+ *)
1143
+
1144
+ Definition concat_p1 {A : Type} {x y : A} (p : x = y) : p @ 1 = p :=
1145
+ match p with idpath => 1 end.
1146
+ Definition concat_1p {A : Type} {x y : A} (p : x = y) : 1 @ p = p :=
1147
+ match p with idpath => 1 end.
1148
+
1149
+ Definition concat_pV {A : Type} {x y : A} (p : x = y) : p @ p^ = 1 :=
1150
+ match p with idpath => 1 end.
1151
+ Definition concat_Vp {A : Type} {x y : A} (p : x = y) : p^ @ p = 1 :=
1152
+ match p with idpath => 1 end.
1153
+
1154
+ Definition inv_V {A : Type} {x y : A} (p : x = y) : p^^ = p :=
1155
+ match p with idpath => 1 end.
1156
+
1157
+ Definition concat_p_pp {A : Type} {x y z t : A} (p : x = y) (q : y = z) (r : z = t) :
1158
+ p @ (q @ r) = (p @ q) @ r :=
1159
+ match r with idpath =>
1160
+ match q with idpath =>
1161
+ match p with idpath => 1
1162
+ end end end.
1163
+ Definition concat_pp_p {A : Type} {x y z t : A} (p : x = y) (q : y = z) (r : z = t) :
1164
+ (p @ q) @ r = p @ (q @ r) :=
1165
+ match r with idpath =>
1166
+ match q with idpath =>
1167
+ match p with idpath => 1
1168
+ end end end.
1169
+
1170
+ (**
1171
+ All of those should be understandable. Some may have alternate
1172
+ proofs. It is worth noting that many of these proofs are shorter than
1173
+ even the "second proofs" of the HoTT book.
1174
+
1175
+ The names seem unusual at first, but they follow the naming scheme of
1176
+ the HoTT Coq library:
1177
+ - [1] means the identity path
1178
+ - [p] means 'the path'
1179
+ - [V] means 'the inverse path'
1180
+ - [A] means '[ap]'
1181
+ - [M] means the thing we are moving across equality
1182
+ - [x] means 'the point' which is not a path, e.g. in [transport p x]
1183
+ - [2] means relating to 2-dimensional paths
1184
+ - [3] means relating to 3-dimensional paths, and so on
1185
+
1186
+ We'll see more functions named in this style as we proceed.
1187
+ *)
1188
+
1189
+ (** ** Functions are functors *)
1190
+ (**
1191
+ Next, we define the function "transport" with its [Notation].
1192
+ *)
1193
+
1194
+ Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y :=
1195
+ match p with idpath => u end.
1196
+
1197
+ Notation "p # x" := (transport _ p x) (right associativity, at level 65, only parsing) : path_scope.
1198
+
1199
+ (**
1200
+ Next comes the non-dependent and dependent versions of "ap".
1201
+ ("application of a function to a path" or "action across paths"). The
1202
+ HoTT Coq library calls the dependent version "apD" rather than "apd".
1203
+ *)
1204
+
1205
+ Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
1206
+ := match p with idpath => idpath end.
1207
+
1208
+ Arguments ap {A B} f {x y} p : simpl nomatch.
1209
+
1210
+ Definition apD {A:Type} {B:A->Type} (f:forall a:A, B a) {x y:A} (p:x=y):
1211
+ p # (f x) = f y
1212
+ :=
1213
+ match p with idpath => idpath end.
1214
+
1215
+ Arguments apD {A B} f {x y} p : simpl nomatch.
1216
+
1217
+ (**
1218
+ In the HoTT book, the use of "ap" and "apd" is often implicit. The
1219
+ reader can determine when "f(p)" means "ap(f,p)" because "p" is a path
1220
+ and "f" called on a path just doesn't "fit" in the proof. In Coq, we
1221
+ have to be explicit about the use of "ap" and "apD".
1222
+ *)
1223
+
1224
+ (** ** Homotopy *)
1225
+ (**
1226
+ So far, we've been covering types and functions in the same sequence
1227
+ as the HoTT book. At this point in the book there is the definition
1228
+ of "homotopy". But, if you've read further in the book, you know that
1229
+ homotopy and identity are equivalent. Thus, the HoTT Coq library has
1230
+ no need to define "homotopy" and neither do we.
1231
+
1232
+ We go straight to equivalences.
1233
+ *)
1234
+
1235
+ (** ** Equivalences *)
1236
+ (**
1237
+ For equivalences, we need a definition of a "section" or the one-sided
1238
+ inverse to a function.
1239
+ *)
1240
+
1241
+ Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
1242
+ forall x : A, r (s x) = x.
1243
+
1244
+ (**
1245
+ The actual definition of equivalence requires some new commands.
1246
+ *)
1247
+
1248
+ Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
1249
+ equiv_inv : B -> A ;
1250
+ eisretr : Sect equiv_inv f;
1251
+ eissect : Sect f equiv_inv;
1252
+ eisadj : forall x : A, eisretr (f x) = ap f (eissect x)
1253
+ }.
1254
+
1255
+ Arguments eisretr {A B} f {_} _.
1256
+ Arguments eissect {A B} f {_} _.
1257
+ Arguments eisadj {A B} f {_} _.
1258
+
1259
+ Record Equiv A B := BuildEquiv {
1260
+ equiv_fun :> A -> B ;
1261
+ equiv_isequiv :> IsEquiv equiv_fun
1262
+ }.
1263
+
1264
+ (**
1265
+ I'm going to address these commands from easiest to hardest, not first
1266
+ to last.
1267
+
1268
+ The easiest is the "Arguments" commands. Ignore them. They just
1269
+ define implicit arguments and we aren't covering the "Arguments"
1270
+ command in this tutorial.
1271
+
1272
+ Next, the [Record] command creates an inductive type with a single
1273
+ constructor. So, the type "Equiv" is very close to the dependent pair
1274
+ type "sigT". The constructor for the new type is "BuildEquiv". The
1275
+ [Record] command also creates projection functions for extracting the
1276
+ two elements stored in an "Equiv". These are called "equiv_fun" and
1277
+ "equiv_isequiv" (and are very similar to "projT1" and "projT2").
1278
+
1279
+ Lastly, we come to the [Class] command. [Class] operates similar to a
1280
+ [Record], but it has special implicit argument rules. Thus, when Coq
1281
+ searches for an argument of type "IsEquiv f", it will look at all
1282
+ elements of that type declared with the "Instance" command. As a
1283
+ result, the second argument to "BuildEquiv" can often be left
1284
+ implicit.
1285
+
1286
+ The HoTT Coq library declares one default [Instance], which is the
1287
+ second part of the "Equiv" record.
1288
+ *)
1289
+
1290
+ Existing Instance equiv_isequiv.
1291
+
1292
+ (**
1293
+ And, of course, there is a [Notation] for equivalence. There is also
1294
+ one for the inverse function inside it.
1295
+ *)
1296
+
1297
+ Notation "A <~> B" := (Equiv A B) (at level 85) : equiv_scope.
1298
+ Notation "f ^-1" := (@equiv_inv _ _ f _) (at level 3) : equiv_scope.
1299
+ Local Open Scope equiv_scope.
1300
+
1301
+ (**
1302
+ The definition used by "Equiv" is the "Half Adjoint Equivalence" of
1303
+ the HoTT book.
1304
+
1305
+ In the book, the parts of "ishae(f)" are (using Coq's notation):
1306
+ - f : A -> B
1307
+ - g : B -> A
1308
+ - #\eta#$\eta$ : f o g ~~ idmap A
1309
+ - #\epsilon#$\epsilon$ : g o f ~~ idmap B
1310
+ - #\tau#$\tau$ : forall x:A, f (eta x) = epsilon (f x)
1311
+ where "~~" represents homotopy, which is never defined in Coq. (We
1312
+ used two tildes since the single tilde ("~") in Coq is the "not"
1313
+ operator.)
1314
+
1315
+ In Coq, if we have a variable "e" of type "A <~> B", the parts are:
1316
+ - equiv_fun e : A -> B
1317
+ - equiv_inv (equiv_isequiv e) : B -> A
1318
+ - Also written: (equiv_fun e) ^-1 : B -> A
1319
+ - eisretr (equiv_isequiv e): Sect equiv_inv f
1320
+ - eissect (equiv_isequiv e): Sect f equiv_inv
1321
+ - eisadj (equiv_isequiv e): forall x : A, eisretr (f x) = ap f (eissect x)
1322
+
1323
+ Notice that the final expression contains a call to "ap" that is
1324
+ implicit in the HoTT book's notation.
1325
+
1326
+ Now that we have a definition for equivalence, let's try to prove that
1327
+ it is an equivalence relation.
1328
+ *)
1329
+
1330
+
1331
+ (** *** Properties of Equivalences *)
1332
+
1333
+ (**
1334
+ Our first example is proving reflexivity: that for all types "A",
1335
+ "ismap A" creates an equivalence between "A" and itself. Creating an
1336
+ equivalence usually takes three parts:
1337
+ - creating an element of type Class "IsEquiv",
1338
+ - registering it as an Instance (for implicit arguments), and
1339
+ - creating the Record "Equiv".
1340
+
1341
+ The following command does the first two parts for reflexivity.
1342
+ "@BuildIsEquiv" creates the element of "IsEquiv" and the "Instance"
1343
+ command registers the element.
1344
+ *)
1345
+
1346
+ Instance isequiv_idmap (A : Type) : IsEquiv (idmap A) :=
1347
+ @BuildIsEquiv A A (idmap A) (idmap A) (fun _ => 1) (fun _ => 1) (fun _ => 1).
1348
+
1349
+ (**
1350
+ This next command creates the element of "Equiv" (written "A <~> A")
1351
+ by calling the constructor "BuildEquiv". As you can see, the final
1352
+ argument is inferred using the Instance registered by the previous
1353
+ command.
1354
+ *)
1355
+
1356
+ Definition equiv_idmap (A : Type) : A <~> A := @BuildEquiv A A (idmap A) _.
1357
+
1358
+ (**
1359
+ This looks like a lot of work to prove something that is obvious. And
1360
+ it is. However, the library is designed for proving more complex
1361
+ instances of equivalence. One aspect of that is once an "Instance" of
1362
+ "IsEquiv" is registered, it can be used as an inferred argument in
1363
+ many places. That won't happen for "isequiv_idmap", which is only use
1364
+ in a few places, but does happen.
1365
+
1366
+
1367
+ After proving that equivalences are reflexive, we should prove that
1368
+ every equivalence has an inverse. However, that proof is rather long
1369
+ and complicated. (That has to do with the choice of half-adjoint
1370
+ equivalences; the proof for bi-invertible maps is just 8 lines.)
1371
+ Since this document is about reading what has been proven, and not the
1372
+ proofs themselves, we will cheat. We'll skip the proof and use the
1373
+ "admit" command so that you can read what has been proven.
1374
+ *)
1375
+
1376
+ Definition equiv_inverse : forall {A B : Type} (e : A <~> B), (B <~> A).
1377
+ Admitted.
1378
+
1379
+ (**
1380
+ And here is what transitivity ("composition") looks like.
1381
+ *)
1382
+
1383
+ Definition equiv_compose' : forall {A B C : Type} (g : B <~> C) (f : A <~> B)
1384
+ , A <~> C.
1385
+ Admitted.
1386
+ (**
1387
+ It is called "equiv_compose"-prime, because there is a second function
1388
+ that instead takes functions from "A" to "B" and from "B" to "C" and
1389
+ uses the implicit arguments provided by [Instance] to build the
1390
+ equivalence.
1391
+ *)
1392
+ (** ** Univalence *)
1393
+ (**
1394
+
1395
+ Since we've decided to cheat and add theorems without proof, it seems
1396
+ like the opportune time to add an axiom. Homotopy type theory's
1397
+ univalence axiom states that there exists an equivalence between two
1398
+ types being equivalent and those same two types being equal.
1399
+
1400
+ *)
1401
+
1402
+ Definition equiv_path (A B : Type) (p : A = B) : A <~> B :=
1403
+ match p with
1404
+ | idpath => equiv_idmap A
1405
+ end.
1406
+ (*??? Why is my version of this so short compared to the library's?! *)
1407
+
1408
+ Class Univalence := {
1409
+ isequiv_equiv_path :> forall (A B : Type), IsEquiv (equiv_path A B)
1410
+ }.
1411
+
1412
+ Instance univalence_axiom : Univalence.
1413
+ Admitted.
1414
+
1415
+ (**
1416
+ The function "equiv_path" says that for every equality between types,
1417
+ there is an equivalence between them.
1418
+
1419
+ The [Class] "Univalence" says that for any two types, "equiv_path"
1420
+ determines an equivalence between the types. So, not only you can get
1421
+ a function that maps an equivalence to an equality, you know that that
1422
+ function is the inverse (with some qualifications) of "equiv_path".
1423
+ *)
1424
+ (* ??? How is "Class" functioning in this usage? It's not the usual one.*)
1425
+ (** *** Univalence Example *)
1426
+ (**
1427
+ To end this document, we'll do a small proof. We'll declare a type
1428
+ that is the duplicate of "nat", prove they're equivalent, and then use
1429
+ the Univalence Axiom to conclude that they are equal.
1430
+
1431
+ First, we define our new type of [nat]s.
1432
+ *)
1433
+
1434
+ Inductive nat2 : Set :=
1435
+ | O2 : nat2
1436
+ | S2 : nat2 -> nat2.
1437
+
1438
+ (**
1439
+ Next, we define invertible maps between them. This is easy: we match
1440
+ zero to zero and successor to successor.
1441
+ *)
1442
+
1443
+ Fixpoint nat_to_nat2 (n : nat) : nat2 :=
1444
+ match n with
1445
+ | O => O2
1446
+ | S n' => S2 (nat_to_nat2 n')
1447
+ end.
1448
+
1449
+ Fixpoint nat2_to_nat (n2 : nat2) : nat :=
1450
+ match n2 with
1451
+ | O2 => O
1452
+ | S2 n2' => S (nat2_to_nat n2')
1453
+ end.
1454
+
1455
+ (**
1456
+ Next, we must prove that are maps are left- and right- inverses of
1457
+ each other. We could have done each in a single function, if we used
1458
+ "nat_rect" and "nat2_rect", but it is easier to read with the [match]
1459
+ expression.
1460
+ *)
1461
+
1462
+ Fixpoint sect_nat2_helper (x : nat2) : (nat_to_nat2 (nat2_to_nat x)) = x :=
1463
+ match x return (nat_to_nat2 (nat2_to_nat x)) = x with
1464
+ | O2 => idpath O2
1465
+ | S2 x' => ap S2 (sect_nat2_helper x')
1466
+ end.
1467
+ Definition sect_nat2 : Sect nat2_to_nat nat_to_nat2 := sect_nat2_helper.
1468
+
1469
+ Fixpoint retr_nat2_helper (x : nat) : (nat2_to_nat (nat_to_nat2 x)) = x :=
1470
+ match x return (nat2_to_nat (nat_to_nat2 x)) = x with
1471
+ | O => idpath O
1472
+ | S x' => ap S (retr_nat2_helper x')
1473
+ end.
1474
+ Definition retr_nat2 : Sect nat_to_nat2 nat2_to_nat := retr_nat2_helper.
1475
+
1476
+ (**
1477
+ Then, since we're using the half-adjoint equivalence, we need one of
1478
+ the coherences.
1479
+
1480
+ Although this document is not trying to teach you how to prove, it is
1481
+ worth pointing out that the following theorem is proved differently
1482
+ than the other ones. It uses Coq's "tactic language". The tactic
1483
+ language a large vocabulary of commands and multiple forms of
1484
+ automation to help prove theorems.
1485
+ *)
1486
+
1487
+ Theorem adj_nat2 (x : nat) : sect_nat2 (nat_to_nat2 x) = ap nat_to_nat2 (retr_nat2 x).
1488
+ Proof.
1489
+ elim x.
1490
+ exact idpath.
1491
+
1492
+ intros x' inductive_hyp.
1493
+ simpl.
1494
+ rewrite inductive_hyp.
1495
+ case (retr_nat2 x').
1496
+ exact idpath.
1497
+ Qed.
1498
+
1499
+ (**
1500
+ Now that we have all 5 pieces needed for the equivalence, we make the
1501
+ "IsEquiv" element, register it as an [Instance], and then make the
1502
+ "Equiv" element that witness that "nat" and "nat2" are equivalent.
1503
+ *)
1504
+
1505
+ Instance isequiv_nat_nat2 : IsEquiv nat_to_nat2 :=
1506
+ BuildIsEquiv nat nat2 nat_to_nat2 nat2_to_nat sect_nat2 retr_nat2 adj_nat2.
1507
+
1508
+ Definition equiv_nat_nat2 : nat <~> nat2 := BuildEquiv nat nat2 nat_to_nat2 _.
1509
+
1510
+ (**
1511
+ Next, we use the univalence axiom to build an equivalence between the
1512
+ equality of [nat] and [nat2] and the equivalence of [nat] and [nat2].
1513
+ *)
1514
+
1515
+ Definition big_equiv : (nat = nat2 :> Type) <~> (nat <~> nat2) :=
1516
+ BuildEquiv (nat = nat2 :> Type) (nat <~> nat2) (equiv_path nat nat2) _.
1517
+
1518
+ (**
1519
+ With that equivalence, we can extract the inverse map, which takes the
1520
+ equivalence to the equality. Applying that function to the
1521
+ equivalence, gives us the equality. Thus, [nat] is equal to [nat2]!
1522
+ *)
1523
+
1524
+ Definition nat2_is_nat : (nat = nat2 :> Type) :=
1525
+ (big_equiv ^-1) equiv_nat_nat2.
1526
+
1527
+ (**
1528
+ With that type equality, we can take any theorem we've proved on [nat]
1529
+ and convert it into a theorem on [nat2]. In our final example, we'll
1530
+ convert the identity function on [nat]s into one on [nat2].
1531
+ *)
1532
+
1533
+ Definition idmap_nat2 : nat2 -> nat2 :=
1534
+ match nat2_is_nat in (_ = y) return (y -> y) with
1535
+ | 1 => idmap_nat
1536
+ end.
1537
+
1538
+ (** * Going Further *)
1539
+ (** ** Homotopy Type Theory in Coq *)
1540
+ (**
1541
+ The reference for HoTT in Coq is:
1542
+ - http://homotopytypetheory.org/coq/
1543
+
1544
+ It contains links to the HoTT Coq library and proofs that use it.
1545
+ Thanks to this document, you should now be able to read what has been
1546
+ proven.
1547
+
1548
+ Also, the site contains links to the version of Coq that supports
1549
+ higher inductive types and is necessary to use the HoTT Coq library
1550
+ and to write new proofs using it.
1551
+ *)
1552
+ (** ** General Coq references *)
1553
+ (**
1554
+ The website for Coq is:
1555
+ - http://coq.inria.fr/
1556
+ *)
1557
+ (** *** Installation *)
1558
+ (**
1559
+ The Coq website has links to compiled versions of standard Coq for
1560
+ Windows and OSX. If you're running Linux, many distributions have Coq
1561
+ available. Under Ubuntu and Debian, the command to install Coq and
1562
+ CoqIDE is "sudo apt-get install coq coqide".
1563
+
1564
+ CoqIDE is a graphical user interface for Coq. We strongly recommend
1565
+ using either CoqIDE or "Proof General", which lets you use Coq inside
1566
+ of the Emacs editor. (Available at http://proofgeneral.inf.ed.ac.uk/)
1567
+
1568
+ "ProofWeb" is a website that lets you interface to Coq by using a web
1569
+ browser. You will not need to install anything. It is available at
1570
+ http://prover.cs.ru.nl/
1571
+ n*)
1572
+ (** *** Documentation *)
1573
+ (**
1574
+ A good introduction to Coq is "Software Foundations". It is, however,
1575
+ aimed at students studying programming languages. It does not get
1576
+ quickly to "how to prove".
1577
+
1578
+ - http://www.cis.upenn.edu/~bcpierce/sf/
1579
+
1580
+ The following is a good cheatsheet. Most importantly, it has a list
1581
+ of "Basic Tactics" that guides new users on what command to use when
1582
+ working with the powerful tactics language. Additionally, it has many
1583
+ of the book-to-Coq translations that are in this document.
1584
+
1585
+ - http://andrej.com/coq/cheatsheet.pdf
1586
+
1587
+ The Coq Reference Manual, with its explanations of every feature in
1588
+ standard Coq, is available at:
1589
+
1590
+ - http://coq.inria.fr/documentation
1591
+ *)
1592
+
1593
+
1594
+ (* TODO:
1595
+ - "Require Import/Export"
1596
+ - "Contractibility"
1597
+ - Martin-Lof Rule vs. Paulin-Mohring Rule
1598
+ *)
1599
+
1600
+
1601
+
1602
+
cover-a4.tex ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % Cover for home-made copies. Print this with a color printer.
2
+ \input{opt-a4}
3
+ \input{opt-color}
4
+
5
+ \documentclass[\OPTfontsize]{article}
6
+
7
+ \usepackage[utf8]{inputenc}
8
+ \usepackage[dvips]{xcolor}
9
+ \usepackage{wallpaper}
10
+
11
+ \definecolor{covercolor}{cmyk}{\OPTcovercolor}
12
+ \definecolor{covertext}{cmyk}{\OPTcovertextcolor}
13
+ \pagecolor{covercolor}
14
+
15
+ %%% Set the fonts
16
+ \usepackage{mathpazo}
17
+ \usepackage[scaled=0.95]{helvet}
18
+ \usepackage{courier}
19
+ \linespread{1.05} % Palatino looks better with this
20
+
21
+ \usepackage{graphicx}
22
+ \DeclareGraphicsExtensions{.png}
23
+ \input{bmpsize-hack} % for bounding boxes in dvi mode
24
+
25
+ \newlength{\coverheight}
26
+ \setlength{\coverheight}{297mm} % Reported as total cover height
27
+
28
+ \newlength{\coverwidth}
29
+ \setlength{\coverwidth}{210mm} % Reported as "spine begins at"
30
+
31
+ \usepackage[margin=0pt,
32
+ papersize={\OPTpagesize},
33
+ noheadfoot]{geometry}
34
+ %\usepackage{layout}
35
+ \newcommand{\coverpage}[1]{\vbox to \coverheight{\hbox to \coverwidth{#1}}}
36
+
37
+ \parindent=0pt
38
+ \parskip=0pt
39
+
40
+ \input{frontpage}
41
+
42
+ \newcommand{\backpage}{
43
+ \begin{minipage}[b][\coverheight][t]{\coverwidth}
44
+ \begin{center}
45
+ \begin{minipage}[t]{0.80\coverwidth}
46
+ \color{covertext}
47
+ \vspace{\OPTtopskip}
48
+ \input{blurb.tex}
49
+ \end{minipage}
50
+ \end{center}
51
+ \end{minipage}
52
+ }
53
+
54
+ \begin{document}
55
+ %\layout
56
+ \ThisLRCornerWallPaper{1.1}{\OPThifrontimage}
57
+ \coverpage{\frontpage}
58
+ \newpage
59
+ \ThisLRCornerWallPaper{0.7}{\OPThibackimage}
60
+ \coverpage{\backpage}
61
+ \end{document}
cover-hires-back-bw.png ADDED

Git LFS Details

  • SHA256: 6927666a93f584c7b158afee42a99602e1243bf91b13f46f2098f46f567210b2
  • Pointer size: 132 Bytes
  • Size of remote file: 2.38 MB
cover-hires-back.png ADDED

Git LFS Details

  • SHA256: 19534427011ba88e96ba97de2f6189101783c7bce11d24af25e401fe2ff4c4e4
  • Pointer size: 132 Bytes
  • Size of remote file: 2.18 MB
cover-hires-bw.png ADDED

Git LFS Details

  • SHA256: 1eebc3f75f0869e8634a43710e02df398d2f9e79c97db69cd4c2656820917ada
  • Pointer size: 133 Bytes
  • Size of remote file: 13.4 MB
cover-hires-front-bw.png ADDED

Git LFS Details

  • SHA256: e5243ddef3f0ee211a24ea6f48e708f58c8b80ad649404854127c48ca3ebdbf9
  • Pointer size: 132 Bytes
  • Size of remote file: 5.68 MB
cover-hires-front.png ADDED

Git LFS Details

  • SHA256: 5b48756c15408393530c98acee6ad5cad05228cde2eb40ab28fd41f14982637b
  • Pointer size: 132 Bytes
  • Size of remote file: 5.57 MB
cover-hires.png ADDED

Git LFS Details

  • SHA256: 535364d6d7eef01925917d2f71fe1e8ec4201da47c6223b86c9f2e2344fb41ab
  • Pointer size: 133 Bytes
  • Size of remote file: 13.9 MB
cover-letter.tex ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % Cover for home-made copies. Print this with a color printer.
2
+ \input{opt-letter}
3
+ \input{opt-color}
4
+
5
+ \documentclass[\OPTfontsize]{article}
6
+
7
+ \usepackage[utf8]{inputenc}
8
+ \usepackage[dvips]{xcolor}
9
+ \usepackage{wallpaper}
10
+
11
+ \definecolor{covercolor}{cmyk}{\OPTcovercolor}
12
+ \definecolor{covertext}{cmyk}{\OPTcovertextcolor}
13
+ \pagecolor{covercolor}
14
+
15
+ %%% Set the fonts
16
+ \usepackage{mathpazo}
17
+ \usepackage[scaled=0.95]{helvet}
18
+ \usepackage{courier}
19
+ \linespread{1.05} % Palatino looks better with this
20
+
21
+ \usepackage{graphicx}
22
+ \DeclareGraphicsExtensions{.png}
23
+ \input{bmpsize-hack} % for bounding boxes in dvi mode
24
+
25
+ \newlength{\coverheight}
26
+ \setlength{\coverheight}{11in} % Reported as total cover height
27
+
28
+ \newlength{\coverwidth}
29
+ \setlength{\coverwidth}{8.5in} % Reported as "spine begins at"
30
+
31
+ \usepackage[margin=0pt,
32
+ papersize={\OPTpagesize},
33
+ noheadfoot]{geometry}
34
+ %\usepackage{layout}
35
+ \newcommand{\coverpage}[1]{\vbox to \coverheight{\hbox to \coverwidth{#1}}}
36
+
37
+ \parindent=0pt
38
+ \parskip=0pt
39
+
40
+ \input{frontpage}
41
+
42
+ \newcommand{\backpage}{
43
+ \begin{minipage}[b][\coverheight][t]{\coverwidth}
44
+ \begin{center}
45
+ \begin{minipage}[t]{0.80\coverwidth}
46
+ \color{covertext}
47
+ \vspace{\OPTtopskip}
48
+ \input{blurb.tex}
49
+ \end{minipage}
50
+ \end{center}
51
+ \end{minipage}
52
+ }
53
+
54
+ \begin{document}
55
+ %\layout
56
+ \ThisLRCornerWallPaper{1.1}{\OPThifrontimage}
57
+ \coverpage{\frontpage}
58
+ \newpage
59
+ \ThisLRCornerWallPaper{0.7}{\OPThibackimage}
60
+ \coverpage{\backpage}
61
+ \end{document}
cover-lores-back-bw.png ADDED

Git LFS Details

  • SHA256: deeedfe1c87c22bdaaead69c1b7b10b51dda8299ade16a688253ba120ad9d3a5
  • Pointer size: 131 Bytes
  • Size of remote file: 296 kB
cover-lores-back.png ADDED

Git LFS Details

  • SHA256: ad002afcea7f8cc9460287ef166dbf76047e8b79cc28aa8106723a42a6f5efd4
  • Pointer size: 131 Bytes
  • Size of remote file: 330 kB
cover-lores-front-bw.png ADDED

Git LFS Details

  • SHA256: 1266fcbfd72687d696a5c96debc6410bc39557eb313570b76812c3342bb9061a
  • Pointer size: 131 Bytes
  • Size of remote file: 622 kB
cover-lores-front.png ADDED

Git LFS Details

  • SHA256: 351d52be09490195fa053fee46b3fed7c353e3bf5239bc514f23febbd5367506
  • Pointer size: 131 Bytes
  • Size of remote file: 532 kB
cover-lores.png ADDED

Git LFS Details

  • SHA256: 1d774d8892e6c3e405638597db387352bcbb3d015f981a9e6d5f7352e26626c5
  • Pointer size: 131 Bytes
  • Size of remote file: 648 kB
cover-lulu-hardcover.png ADDED

Git LFS Details

  • SHA256: 0e433c896371e764e168b84c77aa24a59050c7a5f628ede8c63d56e2f71bb0b4
  • Pointer size: 132 Bytes
  • Size of remote file: 3.7 MB
cover-lulu-hardcover.tex ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % Cover for Lulu.com
2
+ \input{opt-ustrade}
3
+
4
+ \documentclass[\OPTfontsize]{article}
5
+ \input{opt-color}
6
+
7
+ \usepackage[utf8]{inputenc}
8
+ \usepackage{rotating}
9
+ \usepackage{xcolor}
10
+ \usepackage{wallpaper}
11
+
12
+ \definecolor{covercolor}{cmyk}{\OPTcovercolor}
13
+ \definecolor{covertext}{cmyk}{\OPTcovertextcolor}
14
+ \pagecolor{covercolor}
15
+
16
+ \usepackage{soul} % Inter-letter spacing
17
+ \sodef\ugg{}{0pt plus 1fill}{1em plus 1fill}{0pt}
18
+
19
+ %%% Set the fonts
20
+ \usepackage{mathpazo}
21
+ \usepackage[scaled=0.95]{helvet}
22
+ \usepackage{courier}
23
+ \linespread{1.05} % Palatino looks better with this
24
+
25
+ \usepackage{graphicx}
26
+ \DeclareGraphicsExtensions{.png}
27
+ \input{bmpsize-hack} % for bounding boxes in dvi mode
28
+
29
+ % Some of these dimensions are reported by Lulu.com *after* you
30
+ % upload the inner PDF file.
31
+ % For casewrap hardcover see http://static.lulu.com/static/images/help_casewrap_6x9.gif
32
+
33
+ % Dimensions as reported by Lulu.com (download cover template to see)
34
+
35
+ % Total document size
36
+ \newlength{\totalwidth}
37
+ \setlength{\totalwidth}{392.112mm} % width
38
+
39
+ \newlength{\totalheight}
40
+ \setlength{\totalheight}{273.05mm} % height
41
+
42
+ % Spine width
43
+ \newlength{\spinewidth}
44
+ \setlength{\spinewidth}{42.862mm}
45
+
46
+ % Book trim size (trade)
47
+ \newlength{\coverwidth}
48
+ \setlength{\coverwidth}{155.575mm} % width
49
+
50
+ \newlength{\coverheight}
51
+ \setlength{\coverheight}{234.95mm} % height
52
+
53
+ \usepackage[margin=0pt,
54
+ papersize={\totalwidth,\totalheight},
55
+ noheadfoot]{geometry}
56
+ %\usepackage{layout}
57
+ \newcommand{\coverpage}[1]{\vbox to \coverheight{\hbox to \coverwidth{#1}}}
58
+ \newcommand{\spine}[1]{\vbox to \coverheight{\hbox to \spinewidth{#1}}}
59
+
60
+ \parindent=0pt
61
+ \parskip=0pt
62
+
63
+ \input{frontpage}
64
+
65
+ \newcommand{\spinetext}{
66
+ \begin{minipage}[b][\coverheight][t]{\spinewidth}
67
+ \begin{center}
68
+ \begin{rotate}{270}
69
+ \color{covertext}
70
+ \hspace{\OPTtopskip}
71
+ \begin{minipage}{\coverheight}
72
+ {\fontsize{\OPTcoverspinefont}{\OPTcoverspinefont}\fontseries{b}\selectfont%
73
+ Homotopy Type Theory}
74
+ \end{minipage}
75
+ \end{rotate}
76
+ \end{center}
77
+ \end{minipage}
78
+ }
79
+
80
+ \newcommand{\backpage}{
81
+ \begin{minipage}[b][\coverheight][t]{\coverwidth}
82
+ \begin{center}
83
+ \begin{minipage}[t]{0.80\coverwidth}
84
+ \color{covertext}
85
+ \vspace{\OPTtopskip}
86
+ \input{blurb.tex}
87
+ \end{minipage}
88
+ \end{center}
89
+ \end{minipage}
90
+ }
91
+
92
+ \begin{document}
93
+ %\layout
94
+ \LRCornerWallPaper{1.0}{cover-lulu-hardcover}
95
+ \begin{center}
96
+ \vbox{}
97
+ \vfill
98
+ \mbox{\coverpage{\backpage}\spine{\spinetext}\coverpage{\frontpage}}
99
+ \vfill
100
+ \end{center}
101
+ \end{document}
cover-lulu-paperback.png ADDED

Git LFS Details

  • SHA256: 1710992c554b985e94284755334bd5a2851db9a7b314f63ff7fa4ee2de2d5bd6
  • Pointer size: 132 Bytes
  • Size of remote file: 3.72 MB
cover-lulu-paperback.tex ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % Cover for Lulu.com
2
+ \input{opt-ustrade}
3
+
4
+ \documentclass[\OPTfontsize]{article}
5
+ \input{opt-color}
6
+
7
+ \usepackage[utf8]{inputenc}
8
+ \usepackage{rotating}
9
+ \usepackage{xcolor}
10
+ \usepackage{wallpaper}
11
+
12
+ \definecolor{covercolor}{cmyk}{\OPTcovercolor}
13
+ \definecolor{covertext}{cmyk}{\OPTcovertextcolor}
14
+ \pagecolor{covercolor}
15
+
16
+ \usepackage{soul} % Inter-letter spacing
17
+ \sodef\ugg{}{0pt plus 1fill}{1em plus 1fill}{0pt}
18
+
19
+ %%% Set the fonts
20
+ \usepackage{mathpazo}
21
+ \usepackage[scaled=0.95]{helvet}
22
+ \usepackage{courier}
23
+ \linespread{1.05} % Palatino looks better with this
24
+
25
+ \usepackage{graphicx}
26
+ \DeclareGraphicsExtensions{.png}
27
+ \input{bmpsize-hack} % for bounding boxes in dvi mode
28
+
29
+ % Some of these dimensions are reported by Lulu.com *after* you
30
+ % upload the inner PDF file.
31
+ % For casewrap hardcover see http://static.lulu.com/static/images/help_casewrap_6x9.gif
32
+
33
+ % Dimensions as reported by Lulu.com (download cover template to see)
34
+
35
+ % Total document size
36
+ \newlength{\totalwidth}
37
+ \setlength{\totalwidth}{348.085mm} % width
38
+
39
+ \newlength{\totalheight}
40
+ \setlength{\totalheight}{234.95mm} % height
41
+
42
+ % Spine width
43
+ \newlength{\spinewidth}
44
+ \setlength{\spinewidth}{36.935mm}
45
+
46
+ % Book trim size (trade)
47
+ \newlength{\coverwidth}
48
+ \setlength{\coverwidth}{152.4mm} % width
49
+
50
+ \newlength{\coverheight}
51
+ \setlength{\coverheight}{228.6mm} % height
52
+
53
+
54
+ \usepackage[margin=0pt,
55
+ papersize={\totalwidth,\totalheight},
56
+ noheadfoot]{geometry}
57
+ %\usepackage{layout}
58
+ \newcommand{\coverpage}[1]{\vbox to \coverheight{\hbox to \coverwidth{#1}}}
59
+ \newcommand{\spine}[1]{\vbox to \coverheight{\hbox to \spinewidth{#1}}}
60
+
61
+ \parindent=0pt
62
+ \parskip=0pt
63
+
64
+ \input{frontpage}
65
+
66
+ \newcommand{\spinetext}{
67
+ \begin{minipage}[b][\coverheight][t]{\spinewidth}
68
+ \begin{center}
69
+ \begin{rotate}{270}
70
+ \color{covertext}
71
+ \hspace{\OPTtopskip}
72
+ \begin{minipage}{\coverheight}
73
+ {\fontsize{\OPTcoverspinefont}{\OPTcoverspinefont}\fontseries{b}\selectfont%
74
+ Homotopy Type Theory}
75
+ \end{minipage}
76
+ \end{rotate}
77
+ \end{center}
78
+ \end{minipage}
79
+ }
80
+
81
+ \newcommand{\backpage}{
82
+ \begin{minipage}[b][\coverheight][t]{\coverwidth}
83
+ \begin{center}
84
+ \begin{minipage}[t]{0.80\coverwidth}
85
+ \color{covertext}
86
+ \vspace{\OPTtopskip}
87
+ \input{blurb.tex}
88
+ \end{minipage}
89
+ \end{center}
90
+ \end{minipage}
91
+ }
92
+
93
+ \begin{document}
94
+ %\layout
95
+ \LRCornerWallPaper{1.0}{cover-lulu-paperback}%
96
+ \mbox{\coverpage{\backpage}\spine{\spinetext}\coverpage{\frontpage}}%
97
+ \end{document}
cover/torus/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The torus image on the front cover was generated with
2
+ scripts from this directory. Here is how:
3
+
4
+ 1. An image `torus.jpg` of torus is generated with Mathematica, see `Torus.nb`.
5
+ 2. Images of symbols are generated with `symbols.py`.
6
+ 3. Metapixel is used to create the torus image, maybe like this:
7
+
8
+ rm -rf srcimg/* dstimg/* && metapixel-prepare srcimg dstimg
9
+ metapixel -d 1 -s 3 -w 128 -h 128 -l dstimg --metapixel torus.jpg mosaic-torus.png
10
+
11
+ 4. The resulting mosaic-torus.png is then cropped and given color with Gimp.
cover/torus/Torus.nb ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (*CacheID: 234*)
2
+ (* Internal cache information:
3
+ NotebookFileLineBreakTest
4
+ NotebookFileLineBreakTest
5
+ NotebookDataPosition[ 0, 0]
6
+ NotebookDataLength[ 13170, 353]
7
+ NotebookOptionsPosition[ 12041, 310]
8
+ NotebookOutlinePosition[ 12475, 327]
9
+ CellTagsIndexPosition[ 12432, 324]
10
+ WindowFrame->Normal*)
11
+
12
+ (* Beginning of Notebook Content *)
13
+ Notebook[{
14
+ Cell[BoxData[{
15
+ RowBox[{"ClearAll", "[", "torus", "]"}], "\[IndentingNewLine]",
16
+ RowBox[{
17
+ RowBox[{"torus", "[",
18
+ RowBox[{"m_", ",", "t_", ",", "r_", ",", "q_"}], "]"}], ":=",
19
+ "\[IndentingNewLine]",
20
+ RowBox[{"Function", "[",
21
+ RowBox[{
22
+ RowBox[{"{",
23
+ RowBox[{"u", ",", "v"}], "}"}], ",",
24
+ RowBox[{"t", "+",
25
+ RowBox[{"m", ".",
26
+ RowBox[{"{",
27
+ RowBox[{
28
+ RowBox[{
29
+ RowBox[{"Cos", "[", "u", "]"}],
30
+ RowBox[{"(",
31
+ RowBox[{"r", "+",
32
+ RowBox[{"q", "*",
33
+ RowBox[{"Cos", "[", "v", "]"}]}]}], ")"}]}], ",",
34
+ RowBox[{
35
+ RowBox[{"Sin", "[", "u", "]"}], "*",
36
+ RowBox[{"(",
37
+ RowBox[{"r", "+",
38
+ RowBox[{"q", "*",
39
+ RowBox[{"Cos", "[", "v", "]"}]}]}], ")"}]}], ",",
40
+ RowBox[{"q", "*",
41
+ RowBox[{"Sin", "[", "v", "]"}]}]}], "}"}]}]}]}], "]"}]}]}], "Input",
42
+ CellChangeTimes->{{3.575007497914714*^9, 3.575007513979257*^9}, {
43
+ 3.5750075520216627`*^9, 3.575007597035688*^9}, {3.575007629355833*^9,
44
+ 3.575007658325391*^9}, {3.5750077008755217`*^9, 3.575007731479414*^9}, {
45
+ 3.5750077855906487`*^9, 3.5750077861611347`*^9}, {3.575007994438464*^9,
46
+ 3.575007998817588*^9}, {3.5750080778742123`*^9, 3.575008103454809*^9}, {
47
+ 3.575008174228361*^9, 3.5750081851282454`*^9}}],
48
+
49
+ Cell[BoxData[
50
+ RowBox[{"pic", "=",
51
+ RowBox[{"ParametricPlot3D", "[", "\[IndentingNewLine]",
52
+ RowBox[{
53
+ RowBox[{"{", "\[IndentingNewLine]",
54
+ RowBox[{
55
+ RowBox[{
56
+ RowBox[{"torus", "[",
57
+ RowBox[{
58
+ RowBox[{"RotationMatrix", "[",
59
+ RowBox[{"0", ",",
60
+ RowBox[{"{",
61
+ RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "]"}], ",",
62
+ RowBox[{"{",
63
+ RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",", "3", ",", "1"}],
64
+ "]"}], "[",
65
+ RowBox[{"u", ",", "v"}], "]"}], ",", "\[IndentingNewLine]",
66
+ RowBox[{
67
+ RowBox[{"torus", "[",
68
+ RowBox[{
69
+ RowBox[{"RotationMatrix", "[",
70
+ RowBox[{
71
+ RowBox[{"Pi", "/", "2"}], ",",
72
+ RowBox[{"{",
73
+ RowBox[{"1", ",", "1", ",", "0"}], "}"}]}], "]"}], ",",
74
+ RowBox[{"{",
75
+ RowBox[{
76
+ RowBox[{"Sqrt", "[", "3", "]"}], ",",
77
+ RowBox[{"Sqrt", "[", "3", "]"}], ",", "0"}], "}"}], ",", "3", ",",
78
+ "1"}], "]"}], "[",
79
+ RowBox[{"u", ",", "v"}], "]"}]}], "\[IndentingNewLine]", "}"}], ",",
80
+ "\[IndentingNewLine]",
81
+ RowBox[{"{",
82
+ RowBox[{"u", ",", "0", ",",
83
+ RowBox[{"2", "Pi"}]}], "}"}], ",",
84
+ RowBox[{"{",
85
+ RowBox[{"v", ",", "0", ",",
86
+ RowBox[{"2", "Pi"}]}], "}"}], ",", "\[IndentingNewLine]",
87
+ RowBox[{"Boxed", "\[Rule]", "False"}], ",",
88
+ RowBox[{"Axes", "\[Rule]", "False"}], ",",
89
+ RowBox[{"Mesh", "\[Rule]", "False"}], ",",
90
+ RowBox[{"Lighting", "\[Rule]",
91
+ RowBox[{"{",
92
+ RowBox[{
93
+ RowBox[{"{",
94
+ RowBox[{"\"\<Point\>\"", ",",
95
+ RowBox[{"GrayLevel", "[", "0.8", "]"}], ",",
96
+ RowBox[{"{",
97
+ RowBox[{"5", ",", "5", ",", "5"}], "}"}]}], "}"}], ",",
98
+ "\[IndentingNewLine]",
99
+ RowBox[{"{",
100
+ RowBox[{"\"\<Point\>\"", ",",
101
+ RowBox[{"GrayLevel", "[", "0.5", "]"}], ",",
102
+ RowBox[{"{",
103
+ RowBox[{"5", ",",
104
+ RowBox[{"-", "5"}], ",", "5"}], "}"}]}], "}"}]}], "}"}]}]}],
105
+ "]"}]}]], "Input",
106
+ CellChangeTimes->{{3.5750074603736773`*^9, 3.5750074766898947`*^9}, {
107
+ 3.575007734777616*^9, 3.575007759592752*^9}, {3.57500779709807*^9,
108
+ 3.57500784079035*^9}, {3.575007876454563*^9, 3.575008048438395*^9}, {
109
+ 3.5750081293708982`*^9, 3.5750081588892612`*^9}, {3.57500821320293*^9,
110
+ 3.575008270497423*^9}, {3.575008301621005*^9, 3.575008408265143*^9}, {
111
+ 3.5750084601523647`*^9, 3.575008463607183*^9}, {3.575008525986937*^9,
112
+ 3.575008733406006*^9}, {3.575008774951048*^9, 3.575008777059445*^9}, {
113
+ 3.575008828312248*^9, 3.575008828654634*^9}}],
114
+
115
+ Cell[CellGroupData[{
116
+
117
+ Cell[BoxData[
118
+ RowBox[{"Export", "[",
119
+ RowBox[{"\"\<tori.jpg\>\"", ",", "pic", ",",
120
+ RowBox[{"ImageResolution", "\[Rule]", "300"}]}], "]"}]], "Input",
121
+ CellChangeTimes->{{3.5750088552959757`*^9, 3.575008856332591*^9}, {
122
+ 3.5750101012422523`*^9, 3.575010109343607*^9}, {3.575010142918709*^9,
123
+ 3.575010144023197*^9}, {3.575024999760702*^9, 3.575025006137784*^9}}],
124
+
125
+ Cell[BoxData["\<\"tori.jpg\"\>"], "Output",
126
+ CellChangeTimes->{{3.575010110907318*^9, 3.57501014569147*^9},
127
+ 3.575024904160636*^9, 3.575049070535226*^9}]
128
+ }, Open ]],
129
+
130
+ Cell[BoxData[
131
+ RowBox[{"pic", "=",
132
+ RowBox[{"ParametricPlot3D", "[", "\[IndentingNewLine]",
133
+ RowBox[{
134
+ RowBox[{"{", "\[IndentingNewLine]",
135
+ RowBox[{
136
+ RowBox[{"torus", "[",
137
+ RowBox[{
138
+ RowBox[{"RotationMatrix", "[",
139
+ RowBox[{"0", ",",
140
+ RowBox[{"{",
141
+ RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "]"}], ",",
142
+ RowBox[{"{",
143
+ RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",", "3", ",", "1"}],
144
+ "]"}], "[",
145
+ RowBox[{"u", ",", "v"}], "]"}], "\[IndentingNewLine]", "}"}], ",",
146
+ "\[IndentingNewLine]",
147
+ RowBox[{"{",
148
+ RowBox[{"u", ",", "0", ",",
149
+ RowBox[{"2", "Pi"}]}], "}"}], ",",
150
+ RowBox[{"{",
151
+ RowBox[{"v", ",", "0", ",",
152
+ RowBox[{"2", "Pi"}]}], "}"}], ",", "\[IndentingNewLine]",
153
+ RowBox[{"Boxed", "\[Rule]", "False"}], ",",
154
+ RowBox[{"Axes", "\[Rule]", "False"}], ",",
155
+ RowBox[{"Mesh", "\[Rule]", "False"}], ",",
156
+ RowBox[{"Background", "\[Rule]",
157
+ RowBox[{"GrayLevel", "[", "0.98", "]"}]}], ",",
158
+ RowBox[{"Lighting", "\[Rule]", "\[IndentingNewLine]",
159
+ RowBox[{"{",
160
+ RowBox[{
161
+ RowBox[{"{",
162
+ RowBox[{"\"\<Point\>\"", ",",
163
+ RowBox[{"GrayLevel", "[", "0.6", "]"}], ",",
164
+ RowBox[{"{",
165
+ RowBox[{"5", ",", "5", ",", "5"}], "}"}]}], "}"}], ",",
166
+ "\[IndentingNewLine]",
167
+ RowBox[{"{",
168
+ RowBox[{"\"\<Ambient\>\"", ",",
169
+ RowBox[{"GrayLevel", "[", "0.3", "]"}]}], "}"}]}], "}"}]}]}],
170
+ "]"}]}]], "Input",
171
+ CellChangeTimes->{{3.575025285038136*^9, 3.5750252861185703`*^9}, {
172
+ 3.5750253543096848`*^9, 3.575025490287694*^9}, {3.575025559882556*^9,
173
+ 3.5750256024958982`*^9}, {3.575025649196397*^9, 3.575025684027916*^9}, {
174
+ 3.575025832499338*^9, 3.575025864236339*^9}, {3.5750266396533318`*^9,
175
+ 3.575026642525339*^9}, {3.5750267210806217`*^9, 3.575026751234239*^9}, {
176
+ 3.575026926171913*^9, 3.575026941428458*^9}, {3.575026979154292*^9,
177
+ 3.575027011530059*^9}, {3.575027069164358*^9, 3.575027070858553*^9}, {
178
+ 3.575027108620347*^9, 3.575027109296626*^9}, {3.575027948340992*^9,
179
+ 3.5750279702321167`*^9}}],
180
+
181
+ Cell[BoxData[""], "Input",
182
+ CellChangeTimes->{{3.575025437034926*^9, 3.575025438002881*^9}}],
183
+
184
+ Cell[CellGroupData[{
185
+
186
+ Cell[BoxData[
187
+ RowBox[{"Export", "[",
188
+ RowBox[{"\"\<torus.jpg\>\"", ",", " ", "pic", ",", " ",
189
+ RowBox[{"ImageResolution", "\[Rule]", "300"}]}], "]"}]], "Input",
190
+ CellChangeTimes->{{3.575025296296578*^9, 3.575025305455855*^9}, {
191
+ 3.575027986751356*^9, 3.5750279880097303`*^9}}],
192
+
193
+ Cell[BoxData["\<\"torus.jpg\"\>"], "Output",
194
+ CellChangeTimes->{
195
+ 3.5750253064427834`*^9, 3.5750255010662518`*^9, 3.57502560902934*^9,
196
+ 3.5750256926724033`*^9, 3.575025871884837*^9, 3.575026756781699*^9,
197
+ 3.575026947337076*^9, {3.5750270475830803`*^9, 3.5750270762412357`*^9},
198
+ 3.5750271178765087`*^9, 3.575027989420265*^9, 3.575049073357514*^9}]
199
+ }, Open ]],
200
+
201
+ Cell[BoxData[
202
+ RowBox[{"pic", "=",
203
+ RowBox[{"Graphics3D", "[",
204
+ RowBox[{
205
+ RowBox[{"Sphere", "[", "]"}], ",", "\[IndentingNewLine]",
206
+ RowBox[{"Boxed", "\[Rule]", "False"}], ",",
207
+ RowBox[{"Background", "\[Rule]",
208
+ RowBox[{"GrayLevel", "[", "0.98", "]"}]}], ",",
209
+ RowBox[{"Lighting", "\[Rule]", "\[IndentingNewLine]",
210
+ RowBox[{"{",
211
+ RowBox[{
212
+ RowBox[{"{",
213
+ RowBox[{"\"\<Point\>\"", ",",
214
+ RowBox[{"GrayLevel", "[", "0.6", "]"}], ",",
215
+ RowBox[{"{",
216
+ RowBox[{"0", ",",
217
+ RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "}"}], ",",
218
+ "\[IndentingNewLine]", "\[IndentingNewLine]",
219
+ RowBox[{"{",
220
+ RowBox[{"\"\<Ambient\>\"", ",",
221
+ RowBox[{"GrayLevel", "[", "0.3", "]"}]}], "}"}]}], "}"}]}]}],
222
+ "]"}]}]], "Input",
223
+ CellChangeTimes->{{3.5750273586505203`*^9, 3.575027553672594*^9}, {
224
+ 3.575027601822229*^9, 3.575027617537323*^9}, {3.575027695761964*^9,
225
+ 3.575027695945859*^9}}],
226
+
227
+ Cell[CellGroupData[{
228
+
229
+ Cell[BoxData[
230
+ RowBox[{"Export", "[",
231
+ RowBox[{"\"\<sphere.jpg\>\"", ",", " ", "pic", ",",
232
+ RowBox[{"ImageResolution", "\[Rule]", "300"}]}], "]"}]], "Input",
233
+ CellChangeTimes->{{3.5750275448969307`*^9, 3.5750275604751*^9}}],
234
+
235
+ Cell[BoxData["\<\"sphere.jpg\"\>"], "Output",
236
+ CellChangeTimes->{3.57502756152036*^9, 3.5750276239271603`*^9,
237
+ 3.575027700190448*^9, 3.575049074683049*^9}]
238
+ }, Open ]],
239
+
240
+ Cell[BoxData[
241
+ RowBox[{"pic", "=",
242
+ RowBox[{"ParametricPlot3D", "[", "\[IndentingNewLine]",
243
+ RowBox[{
244
+ RowBox[{"{",
245
+ RowBox[{
246
+ RowBox[{"torus", "[",
247
+ RowBox[{
248
+ RowBox[{"RotationMatrix", "[",
249
+ RowBox[{"0", ",",
250
+ RowBox[{"{",
251
+ RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "]"}], ",",
252
+ RowBox[{"{",
253
+ RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",", "9", ",", "4"}],
254
+ "]"}], "[",
255
+ RowBox[{"u", ",", "v"}], "]"}], "\[IndentingNewLine]", "}"}], ",",
256
+ "\[IndentingNewLine]",
257
+ RowBox[{"{",
258
+ RowBox[{"u", ",", "0", ",",
259
+ RowBox[{"2", "Pi"}]}], "}"}], ",",
260
+ RowBox[{"{",
261
+ RowBox[{"v", ",", "0", ",",
262
+ RowBox[{"2", "Pi"}]}], "}"}], ",", "\[IndentingNewLine]",
263
+ RowBox[{"Boxed", "\[Rule]", "False"}], ",",
264
+ RowBox[{"Axes", "\[Rule]", "False"}], ",",
265
+ RowBox[{"Mesh", "\[Rule]",
266
+ RowBox[{"{",
267
+ RowBox[{"20", ",", "20"}], "}"}]}], ",",
268
+ RowBox[{"MeshStyle", "\[Rule]",
269
+ RowBox[{"Thickness", "[", "0.006", "]"}]}], ",",
270
+ RowBox[{"Lighting", "\[Rule]", "\[IndentingNewLine]",
271
+ RowBox[{"{",
272
+ RowBox[{
273
+ RowBox[{"{",
274
+ RowBox[{"\"\<Point\>\"", ",",
275
+ RowBox[{"GrayLevel", "[", "0.6", "]"}], ",",
276
+ RowBox[{"{",
277
+ RowBox[{"5", ",", "5", ",", "5"}], "}"}]}], "}"}], ",",
278
+ "\[IndentingNewLine]",
279
+ RowBox[{"{",
280
+ RowBox[{"\"\<Ambient\>\"", ",",
281
+ RowBox[{"GrayLevel", "[", "1.0", "]"}]}], "}"}]}], "}"}]}]}],
282
+ "]"}]}]], "Input",
283
+ CellChangeTimes->{{3.5750280287621403`*^9, 3.5750280399278927`*^9}, {
284
+ 3.5750281206545887`*^9, 3.575028140262444*^9}, {3.5750282095211277`*^9,
285
+ 3.575028411340498*^9}, {3.575028513746626*^9, 3.5750285149808273`*^9}, {
286
+ 3.575028565153102*^9, 3.575028576435603*^9}, {3.575028614268888*^9,
287
+ 3.57502861663518*^9}, {3.5750286502604856`*^9, 3.575028667957321*^9}, {
288
+ 3.575028702423554*^9, 3.575028738837942*^9}, {3.575028775720426*^9,
289
+ 3.575028776057373*^9}, {3.575028869874096*^9, 3.575028873948093*^9}, {
290
+ 3.575049051550745*^9, 3.575049053326434*^9}, {3.575049095852672*^9,
291
+ 3.575049104580035*^9}}],
292
+
293
+ Cell[CellGroupData[{
294
+
295
+ Cell[BoxData[
296
+ RowBox[{"Export", "[",
297
+ RowBox[{"\"\<torus.png\>\"", ",", "pic", ",",
298
+ RowBox[{"ImageResolution", "\[Rule]", "900"}]}], "]"}]], "Input",
299
+ CellChangeTimes->{{3.5750284389216022`*^9, 3.575028451068201*^9}, {
300
+ 3.575028890584002*^9, 3.575028893093935*^9}, {3.575049114609*^9,
301
+ 3.575049115913175*^9}}],
302
+
303
+ Cell[BoxData["\<\"torus.png\"\>"], "Output",
304
+ CellChangeTimes->{
305
+ 3.575028453439415*^9, 3.575028526269167*^9, 3.575028584785966*^9,
306
+ 3.575028622186308*^9, 3.575028677156248*^9, 3.575028785220005*^9, {
307
+ 3.575028880042776*^9, 3.575028897213284*^9}, 3.5750490811049767`*^9,
308
+ 3.575049130061048*^9}]
309
+ }, Open ]]
310
+ },
311
+ WindowSize->{740, 855},
312
+ WindowMargins->{{170, Automatic}, {Automatic, 6}},
313
+ PrivateNotebookOptions->{"VersionedStylesheet"->{"Default.nb"[8.] -> False}},
314
+ FrontEndVersion->"9.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (January 25, \
315
+ 2013)",
316
+ StyleDefinitions->"Default.nb"
317
+ ]
318
+ (* End of Notebook Content *)
319
+
320
+ (* Internal cache information *)
321
+ (*CellTagsOutline
322
+ CellTagsIndex->{}
323
+ *)
324
+ (*CellTagsIndex
325
+ CellTagsIndex->{}
326
+ *)
327
+ (*NotebookFileOutline
328
+ Notebook[{
329
+ Cell[400, 13, 1324, 33, 63, "Input"],
330
+ Cell[1727, 48, 2616, 64, 165, "Input"],
331
+ Cell[CellGroupData[{
332
+ Cell[4368, 116, 369, 6, 28, "Input"],
333
+ Cell[4740, 124, 156, 2, 28, "Output"]
334
+ }, Open ]],
335
+ Cell[4911, 129, 2125, 49, 165, "Input"],
336
+ Cell[7039, 180, 92, 1, 28, "Input"],
337
+ Cell[CellGroupData[{
338
+ Cell[7156, 185, 283, 5, 28, "Input"],
339
+ Cell[7442, 192, 356, 5, 28, "Output"]
340
+ }, Open ]],
341
+ Cell[7813, 200, 982, 24, 97, "Input"],
342
+ Cell[CellGroupData[{
343
+ Cell[8820, 228, 228, 4, 28, "Input"],
344
+ Cell[9051, 234, 157, 2, 28, "Output"]
345
+ }, Open ]],
346
+ Cell[9223, 239, 2152, 51, 148, "Input"],
347
+ Cell[CellGroupData[{
348
+ Cell[11400, 294, 319, 6, 28, "Input"],
349
+ Cell[11722, 302, 303, 5, 28, "Output"]
350
+ }, Open ]]
351
+ }
352
+ ]
353
+ *)
354
+
cover/torus/mosaic-torus.png ADDED

Git LFS Details

  • SHA256: 457a237b3633633f5fac6895b8ccf238b189727de5ac302c69a847c6f3ea7a35
  • Pointer size: 132 Bytes
  • Size of remote file: 2.5 MB
cover/torus/symbols.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # This script generates symbol images from which the
4
+ # torus picture is then assembled.
5
+
6
+ import subprocess
7
+ import os
8
+ import os.path
9
+
10
+ symbols = [
11
+ r"$$\sum$$",
12
+ r"$$\prod$$",
13
+ r"$$\lambda$$",
14
+ r"$$\times$$",
15
+ r"$$\simeq$$"
16
+ ]
17
+
18
+ ncols = 1
19
+
20
+ colors = [("gray", str(float(i)/ncols)) for i in range(0, ncols+1)]
21
+
22
+ ## Generate LaTeX
23
+
24
+ template = r"""
25
+ \documentclass{article}
26
+ \usepackage{palatino}
27
+ \usepackage{amsmath,amssymb,amsfonts}
28
+ \usepackage{xcolor}
29
+ \pagestyle{empty}
30
+ \begin{document}
31
+ %s
32
+ \end{document}"""
33
+
34
+ tex = ""
35
+ for (i, s) in enumerate(symbols):
36
+ for (j, (m,c)) in enumerate(colors):
37
+ tex = tex + (r"\definecolor{mycolor}{%s}{%s}\textcolor{mycolor}{%s}\newpage" % (m, c, s)) + "\n"
38
+
39
+ # Write LaTeX to file
40
+
41
+ with open("temp.tex", "w") as f:
42
+ f.write(template % tex)
43
+
44
+ # Process LaTeX and generate png files
45
+
46
+ subprocess.call(["latex", "temp.tex"])
47
+ subprocess.call(["dvipng", "-D", "1200", "-o", "preimg/image_%02d.png", "-T", "tight", "temp.dvi"])
48
+
49
+ # Convert png files to jpg
50
+
51
+ filelist = [f for f in os.listdir('preimg') if f.endswith(".png")]
52
+ for f in filelist:
53
+ fin = os.path.join("preimg", f)
54
+ fout = os.path.join("srcimg", os.path.splitext(f)[0] + ".jpg")
55
+ subprocess.call(["convert", "-bordercolor", "white", "-border", "20x20", "-quality", "100", fin, fout])
56
+
57
+ # Remove auxiliary files
58
+
59
+ for f in filelist:
60
+ os.remove(os.path.join("preimg", f))
61
+
62
+ for f in [f for f in os.listdir('.') if f.startswith("temp.")]:
63
+ os.remove(f)
cover/torus/torus-clipped.xcf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af227261cd1a7295a2e4f6daea5cdc0f7fd61a41144785001205f53ad1157139
3
+ size 49466994
equivalences.tex ADDED
@@ -0,0 +1,1118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \chapter{Equivalences}
2
+ \label{cha:equivalences}
3
+
4
+ We now study in more detail the notion of \emph{equivalence of types} that was introduced briefly in \cref{sec:basics-equivalences}.
5
+ Specifically, we will give several different ways to define a type $\isequiv(f)$ having the properties mentioned there.
6
+ Recall that we wanted $\isequiv(f)$ to have the following properties, which we restate here:
7
+ \begin{enumerate}
8
+ \item $\qinv(f) \to \isequiv (f)$.\label{item:beb1}
9
+ \item $\isequiv (f) \to \qinv(f)$.\label{item:beb2}
10
+ \item $\isequiv(f)$ is a mere proposition.\label{item:beb3}
11
+ \end{enumerate}
12
+ Here $\qinv(f)$ denotes the type of quasi-inverses to $f$:
13
+ \begin{equation*}
14
+ \sm{g:B\to A} \big((f \circ g \htpy \idfunc[B]) \times (g\circ f \htpy \idfunc[A])\big).
15
+ \end{equation*}
16
+ By function extensionality, it follows that $\qinv(f)$ is equivalent to the type
17
+ \begin{equation*}
18
+ \sm{g:B\to A} \big((f \circ g = \idfunc[B]) \times (g\circ f = \idfunc[A])\big).
19
+ \end{equation*}
20
+ We will define three different types having properties~\ref{item:beb1}--\ref{item:beb3}, which we call
21
+ \begin{itemize}
22
+ \item half adjoint equivalences,
23
+ \item bi-invertible maps,
24
+ \index{function!bi-invertible}
25
+ and
26
+ \item contractible functions.
27
+ \end{itemize}
28
+ We will also show that all these types are equivalent.
29
+ These names are intentionally somewhat cumbersome, because after we know that they are all equivalent and have properties~\ref{item:beb1}--\ref{item:beb3}, we will revert to saying simply ``equivalence'' without needing to specify which particular definition we choose.
30
+ But for purposes of the comparisons in this chapter, we need different names for each definition.
31
+
32
+ Before we examine the different notions of equivalence, however, we give a little more explanation of why a different concept than quasi-invertibility is needed.
33
+
34
+ \section{Quasi-inverses}
35
+ \label{sec:quasi-inverses}
36
+
37
+ \index{quasi-inverse|(}%
38
+ We have said that $\qinv(f)$ is unsatisfactory because it is not a mere proposition, whereas we would rather that a given function could ``be an equivalence'' in at most one way.
39
+ However, we have given no evidence that $\qinv(f)$ is not a mere proposition.
40
+ In this section we exhibit a specific counterexample.
41
+
42
+ \begin{lem}\label{lem:qinv-autohtpy}
43
+ If $f:A\to B$ is such that $\qinv (f)$ is inhabited, then
44
+ \[\eqv{\qinv(f)}{\Parens{\prd{x:A}(x=x)}}.\]
45
+ \end{lem}
46
+ \begin{proof}
47
+ By assumption, $f$ is an equivalence; that is, we have $e:\isequiv(f)$ and so $(f,e):\eqv A B$.
48
+ By univalence, $\idtoeqv:(A=B) \to (\eqv A B)$ is an equivalence, so we may assume that $(f,e)$ is of the form $\idtoeqv(p)$ for some $p:A=B$.
49
+ Then by path induction, we may assume $p$ is $\refl{A}$, in which case $f$ is $\idfunc[A]$.
50
+ Thus we are reduced to proving $\eqv{\qinv(\idfunc[A])}{(\prd{x:A}(x=x))}$.
51
+ Now by definition we have
52
+ \[ \qinv(\idfunc[A]) \jdeq
53
+ \sm{g:A\to A} \big((g \htpy \idfunc[A]) \times (g \htpy \idfunc[A])\big).
54
+ \]
55
+ By function extensionality, this is equivalent to
56
+ \[ \sm{g:A\to A} \big((g = \idfunc[A]) \times (g = \idfunc[A])\big).
57
+ \]
58
+ And by \cref{ex:sigma-assoc}, this is equivalent to
59
+ \[ \sm{h:\sm{g:A\to A} (g = \idfunc[A])} (\proj1(h) = \idfunc[A])
60
+ \]
61
+ However, by \cref{thm:contr-paths}, $\sm{g:A\to A} (g = \idfunc[A])$ is contractible with center $(\idfunc[A],\refl{\idfunc[A]})$; therefore by \cref{thm:omit-contr} this type is equivalent to $\idfunc[A] = \idfunc[A]$.
62
+ And by function extensionality, $\idfunc[A] = \idfunc[A]$ is equivalent to $\prd{x:A} x=x$.
63
+ \end{proof}
64
+
65
+ \noindent
66
+ We remark that \cref{ex:qinv-autohtpy-no-univalence} asks for a proof of the above lemma which avoids univalence.
67
+
68
+ Thus, what we need is some $A$ which admits a nontrivial element of $\prd{x:A}(x=x)$.
69
+ Thinking of $A$ as a higher groupoid, an inhabitant of $\prd{x:A}(x=x)$ is a natural transformation\index{natural!transformation} from the identity functor of $A$ to itself.
70
+ Such transformations are said to form the \define{center of a category},
71
+ \index{center!of a category}%
72
+ \index{category!center of}%
73
+ since the naturality axiom requires that they commute with all morphisms.
74
+ Classically, if $A$ is simply a group regarded as a one-object groupoid, then this yields precisely its center in the usual group-theoretic sense.
75
+ This provides some motivation for the following.
76
+
77
+ \begin{lem}\label{lem:autohtpy}
78
+ Suppose we have a type $A$ with $a:A$ and $q:a=a$ such that
79
+ \begin{enumerate}
80
+ \item The type $a=a$ is a set.\label{item:autohtpy1}
81
+ \item For all $x:A$ we have $\brck{a=x}$.\label{item:autohtpy2}
82
+ \item For all $p:a=a$ we have $p\ct q = q \ct p$.\label{item:autohtpy3}
83
+ \end{enumerate}
84
+ Then there exists $f:\prd{x:A} (x=x)$ with $f(a)=q$.
85
+ \end{lem}
86
+ \begin{proof}
87
+ Let $g:\prd{x:A} \brck{a=x}$ be as given by~\ref{item:autohtpy2}. First we
88
+ observe that each type $\id[A]xy$ is a set. For since being a set is a mere
89
+ proposition, we may apply the induction principle of propositional truncation, and assume that $g(x)=\bproj
90
+ p$ and $g(y)=\bproj{p'}$ for $p:a=x$ and $p':a=y$. In this case, composing with
91
+ $p$ and $\opp{p'}$ yields an equivalence $\eqv{(x=y)}{(a=a)}$. But $(a=a)$ is
92
+ a set by~\ref{item:autohtpy1}, so $(x=y)$ is also a set.
93
+
94
+ Now, we would like to define $f$ by assigning to each $x$ the path $\opp{g(x)}
95
+ \ct q \ct g(x)$, but this does not work because $g(x)$ does not inhabit $a=x$
96
+ but rather $\brck{a=x}$, and the type $(x=x)$ may not be a mere proposition,
97
+ so we cannot use induction on propositional truncation. Instead we can apply
98
+ the technique mentioned in \cref{sec:unique-choice}: we characterize
99
+ uniquely the object we wish to construct. Let us define, for each $x:A$, the
100
+ type
101
+ \[ B(x) \defeq \sm{r:x=x} \prd{s:a=x} (r = \opp s \ct q\ct s).\]
102
+ We claim that $B(x)$ is a mere proposition for each $x:A$.
103
+ Since this claim is itself a mere proposition, we may again apply induction on
104
+ truncation and assume that $g(x) = \bproj p$ for some $p:a=x$.
105
+ Now suppose given $(r,h)$ and $(r',h')$ in $B(x)$; then we have
106
+ \[ h(p) \ct \opp{h'(p)} : r = r'. \]
107
+ It remains to show that $h$ is identified with $h'$ when transported along this equality, which by transport in identity types and function types (\cref{sec:compute-paths,sec:compute-pi}), reduces to showing
108
+ \[ h(s) = h(p) \ct \opp{h'(p)} \ct h'(s) \]
109
+ for any $s:a=x$.
110
+ But each side of this is an equality between elements of $(x=x)$, so it follows from our above observation that $(x=x)$ is a set.
111
+
112
+ Thus, each $B(x)$ is a mere proposition; we claim that $\prd{x:A} B(x)$.
113
+ Given $x:A$, we may now invoke the induction principle of propositional truncation to assume that $g(x) = \bproj p$ for $p:a=x$.
114
+ We define $r \defeq \opp p \ct q \ct p$; to inhabit $B(x)$ it remains to show that for any $s:a=x$ we have
115
+ $r = \opp s \ct q \ct s$.
116
+ Manipulating paths, this reduces to showing that $q\ct (p\ct \opp s) = (p\ct \opp s) \ct q$.
117
+ But this is just an instance of~\ref{item:autohtpy3}.
118
+ \end{proof}
119
+
120
+ \begin{thm}\label{thm:qinv-notprop}
121
+ There exist types $A$ and $B$ and a function $f:A\to B$ such that $\qinv(f)$ is not a mere proposition.
122
+ \end{thm}
123
+ \begin{proof}
124
+ It suffices to exhibit a type $X$ such that $\prd{x:X} (x=x)$ is not a mere proposition.
125
+ Define $X\defeq \sm{A:\type} \brck{\bool=A}$, as in the proof of \cref{thm:no-higher-ac}.
126
+ It will suffice to exhibit an $f:\prd{x:X} (x=x)$ which is unequal to $\lam{x} \refl{x}$.
127
+
128
+ Let $a \defeq (\bool,\bproj{\refl{\bool}}) : X$, and let $q:a=a$ be the path corresponding to the nonidentity equivalence $e:\eqv\bool\bool$ defined by $e(\bfalse)\defeq\btrue$ and $e(\btrue)\defeq\bfalse$.
129
+ We would like to apply \cref{lem:autohtpy} to build an $f$.
130
+ By definition of $X$, equalities in subset types (\cref{subsec:prop-subsets}), and univalence, we have $\eqv{(a=a)}{(\eqv{\bool}{\bool})}$, which is a set, so~\ref{item:autohtpy1} holds.
131
+ Similarly, by definition of $X$ and equalities in subset types we have~\ref{item:autohtpy2}.
132
+ Finally, \cref{ex:eqvboolbool} implies that every equivalence $\eqv\bool\bool$ is equal to either $\idfunc[\bool]$ or $e$, so we can show~\ref{item:autohtpy3} by a four-way case analysis.
133
+
134
+ Thus, we have $f:\prd{x:X} (x=x)$ such that $f(a) = q$.
135
+ Since $e$ is not equal to $\idfunc[\bool]$, $q$ is not equal to $\refl{a}$, and thus $f$ is not equal to $\lam{x} \refl{x}$.
136
+ Therefore, $\prd{x:X} (x=x)$ is not a mere proposition.
137
+ \end{proof}
138
+
139
+ More generally, \cref{lem:autohtpy} implies that any ``Eilenberg--Mac Lane space'' $K(G,1)$, where $G$ is a nontrivial abelian\index{group!abelian} group, will provide a counterexample; see \cref{cha:homotopy}.
140
+ The type $X$ we used turns out to be equivalent to $K(\mathbb{Z}_2,1)$.
141
+ In \cref{cha:hits} we will see that the circle $\Sn^1 = K(\mathbb{Z},1)$ is another easy-to-describe example.
142
+
143
+ We now move on to describing better notions of equivalence.
144
+
145
+ \index{quasi-inverse|)}%
146
+
147
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148
+ \section{Half adjoint equivalences}
149
+ \label{sec:hae}
150
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151
+
152
+ \index{equivalence!half adjoint|(defstyle}%
153
+ \index{half adjoint equivalence|(defstyle}%
154
+ \index{adjoint!equivalence!of types, half|(defstyle}%
155
+
156
+ In \cref{sec:quasi-inverses} we concluded that $\qinv(f)$ is equivalent to $\prd{x:A} (x=x)$ by discarding a contractible type.
157
+ Roughly, the type $\qinv(f)$ contains three data $g$, $\eta$, and $\epsilon$, of which two ($g$ and $\eta$) could together be seen to be contractible when $f$ is an equivalence.
158
+ The problem is that removing these data left one remaining ($\epsilon$).
159
+ In order to solve this problem, the idea is to add one \emph{additional} datum which, together with $\epsilon$, forms a contractible type.
160
+
161
+ \begin{defn}\label{defn:ishae}
162
+ A function $f:A\to B$ is a \define{half adjoint equivalence}
163
+ if there are $g:B\to A$ and homotopies $\eta: g \circ f \htpy \idfunc[A]$ and $\epsilon:f \circ g \htpy \idfunc[B]$ such that there exists a homotopy
164
+ \[\tau : \prd{x:A} \map{f}{\eta x} = \epsilon(fx).\]
165
+ \end{defn}
166
+
167
+ Thus we have a type $\ishae(f)$, defined to be
168
+ \begin{equation*}
169
+ \sm{g:B\to A}{\eta: g \circ f \htpy \idfunc[A]}{\epsilon:f \circ g \htpy \idfunc[B]} \prd{x:A} \map{f}{\eta x} = \epsilon(fx).
170
+ \end{equation*}
171
+ Note that in the above definition, the coherence\index{coherence} condition relating $\eta$ and $\epsilon$ only involves $f$.
172
+ We might consider instead an analogous coherence condition involving $g$:
173
+ \[\upsilon : \prd{y:B} \map{g}{\epsilon y} = \eta(gy)\]
174
+ and a resulting analogous definition $\ishae'(f)$.
175
+
176
+ Fortunately, it turns out each of the conditions implies the other one:
177
+
178
+ \begin{lem}\label{lem:coh-equiv}
179
+ For functions $f : A \to B$ and $g:B\to A$ and homotopies $\eta: g \circ f \htpy \idfunc[A]$ and $\epsilon:f \circ g \htpy \idfunc[B]$, the following conditions are logically equivalent:
180
+ \begin{itemize}
181
+ \item $\prd{x:A} \map{f}{\eta x} = \epsilon(fx)$
182
+ \item $\prd{y:B} \map{g}{\epsilon y} = \eta(gy)$
183
+ \end{itemize}
184
+ \end{lem}
185
+ \begin{proof}
186
+ It suffices to show one direction; the other one is obtained by replacing $A$, $f$, and $\eta$ by $B$, $g$, and $\epsilon$ respectively.
187
+ Let $\tau : \prd{x:A}\;\map{f}{\eta x} = \epsilon(fx)$.
188
+ Fix $y : B$.
189
+ Using naturality of $\epsilon$ and applying $g$, we get the following commuting diagram of paths:
190
+ \[\uppercurveobject{{ }}\lowercurveobject{{ }}\twocellhead{{ }}
191
+ \xymatrix@C=3pc{gfgfgy \ar@{=}^-{gfg(\epsilon y)}[r] \ar@{=}_{g(\epsilon (fgy))}[d] & gfgy \ar@{=}^{g(\epsilon y)}[d] \\ gfgy \ar@{=}_{g(\epsilon y)}[r] & gy
192
+ }\]
193
+ Using $\tau(gy)$ on the left side of the diagram gives us
194
+ \[\uppercurveobject{{ }}\lowercurveobject{{ }}\twocellhead{{ }}
195
+ \xymatrix@C=3pc{gfgfgy \ar@{=}^-{gfg(\epsilon y)}[r] \ar@{=}_{gf(\eta (gy))}[d] & gfgy \ar@{=}^{g(\epsilon y)}[d] \\ gfgy \ar@{=}_{g(\epsilon y)}[r] & gy
196
+ }\]
197
+ Using the commutativity of $\eta$ with $g \circ f$ (\cref{cor:hom-fg}), we have
198
+ \[\uppercurveobject{{ }}\lowercurveobject{{ }}\twocellhead{{ }}
199
+ \xymatrix@C=3pc{gfgfgy \ar@{=}^-{gfg(\epsilon y)}[r] \ar@{=}_{\eta (gfgy)}[d] & gfgy \ar@{=}^{g(\epsilon y)}[d] \\ gfgy \ar@{=}_{g(\epsilon y)}[r] & gy
200
+ }\]
201
+ However, by naturality of $\eta$ we also have
202
+ \[\uppercurveobject{{ }}\lowercurveobject{{ }}\twocellhead{{ }}
203
+ \xymatrix@C=3pc{gfgfgy \ar@{=}^-{gfg(\epsilon y)}[r] \ar@{=}_{\eta (gfgy)}[d] & gfgy \ar@{=}^{\eta(gy)}[d] \\ gfgy \ar@{=}_{g(\epsilon y)}[r] & gy
204
+ }\]
205
+ Thus, canceling all but the right-hand homotopy, we have $g(\epsilon y) = \eta(g y)$ as desired.
206
+ \end{proof}
207
+
208
+ However, it is important that we do not include \emph{both} $\tau$ and $\upsilon$ in the definition of $\ishae (f)$ (whence the name ``\emph{half} adjoint equivalence'').
209
+ If we did, then after canceling contractible types we would still have one remaining datum --- unless we added another higher coherence condition.
210
+ In general, we expect to get a well-behaved type if we cut off after an odd number of coherences.
211
+
212
+ Of course, it is obvious that $\ishae(f) \to\qinv(f)$: simply forget the coherence datum.
213
+ The other direction is a version of a standard argument from homotopy theory and category theory.
214
+
215
+ \begin{thm}\label{thm:equiv-iso-adj}
216
+ For any $f:A\to B$ we have $\qinv(f)\to\ishae(f)$.
217
+ \end{thm}
218
+ \begin{proof}
219
+ Suppose that $(g,\eta,\epsilon)$ is a quasi-inverse for $f$. We have to provide
220
+ a quadruple $(g',\eta',\epsilon',\tau)$ witnessing that $f$ is a half adjoint equivalence. To
221
+ define $g'$ and $\eta'$, we can just make the obvious choice by setting $g'
222
+ \defeq g$ and $\eta'\defeq \eta$. However, in the definition of $\epsilon'$ we
223
+ need start worrying about the construction of $\tau$, so we cannot just follow our nose
224
+ and take $\epsilon'$ to be $\epsilon$. Instead, we take
225
+ \begin{equation*}
226
+ \epsilon'(b) \defeq \opp{\epsilon(f(g(b)))}\ct (\ap{f}{\eta(g(b))}\ct \epsilon(b)).
227
+ \end{equation*}
228
+ Now we need to find
229
+ \begin{equation*}
230
+ \tau(a): \ap{f}{\eta(a)}=\opp{\epsilon(f(g(f(a))))}\ct (\ap{f}{\eta(g(f(a)))}\ct \epsilon(f(a))).
231
+ \end{equation*}
232
+ Note first that by \cref{cor:hom-fg}, we have
233
+ %$\eta(g(f(a)))\ct\eta(a)=\ap{g}{\ap{f}{\eta(a)}}\ct\eta(a)$ and hence it follows that
234
+ $\eta(g(f(a)))=\ap{g}{\ap{f}{\eta(a)}}$. Therefore, we can apply
235
+ \cref{lem:htpy-natural} to compute
236
+ \begin{align*}
237
+ \ap{f}{\eta(g(f(a)))}\ct \epsilon(f(a))
238
+ & = \ap{f}{\ap{g}{\ap{f}{\eta(a)}}}\ct \epsilon(f(a))\\
239
+ & = \epsilon(f(g(f(a))))\ct \ap{f}{\eta(a)}
240
+ \end{align*}
241
+ from which we get the desired path $\tau(a)$.
242
+ \end{proof}
243
+
244
+ Combining this with \cref{lem:coh-equiv} (or symmetrizing the proof), we also have $\qinv(f)\to\ishae'(f)$.
245
+
246
+ It remains to show that $\ishae(f)$ is a mere proposition.
247
+ For this, we will need to know that the fibers of an equivalence are contractible.
248
+
249
+ \begin{defn}\label{defn:homotopy-fiber}
250
+ The \define{fiber}
251
+ \indexdef{fiber}%
252
+ \indexsee{function!fiber of}{fiber}%
253
+ of a map $f:A\to B$ over a point $y:B$ is
254
+ \[ \hfib f y \defeq \sm{x:A} (f(x) = y).\]
255
+ \end{defn}
256
+
257
+ In homotopy theory, this is what would be called the \emph{homotopy fiber} of $f$.
258
+ The path lemmas in \cref{sec:computational} yield the following characterization of paths in fibers:
259
+
260
+ \begin{lem}\label{lem:hfib}
261
+ For any $f : A \to B$, $y : B$, and $(x,p),(x',p') : \hfib{f}{y}$, we have
262
+ \[ \big((x,p) = (x',p')\big) \eqvsym \Parens{\sm{\gamma : x = x'} f(\gamma) \ct p' = p} \qedhere\]
263
+ \end{lem}
264
+
265
+ \begin{thm}\label{thm:contr-hae}
266
+ If $f:A\to B$ is a half adjoint equivalence, then for any $y:B$ the fiber $\hfib f y$ is contractible.
267
+ \end{thm}
268
+ \begin{proof}
269
+ Let $(g,\eta,\epsilon,\tau) : \ishae(f)$, and fix $y : B$.
270
+ As our center of contraction for $\hfib{f}{y}$ we choose $(gy, \epsilon y)$.
271
+ Now take any $(x,p) : \hfib{f}{y}$; we want to construct a path from $(gy, \epsilon y)$ to $(x,p)$.
272
+ By \cref{lem:hfib}, it suffices to give a path $\gamma : \id{gy}{x}$ such that $\ap f\gamma \ct p = \epsilon y$.
273
+ We put $\gamma \defeq \opp{g(p)} \ct \eta x$.
274
+ Then we have
275
+ \begin{align*}
276
+ f(\gamma) \ct p & = \opp{fg(p)} \ct f (\eta x) \ct p \\
277
+ & = \opp{fg(p)} \ct \epsilon(fx) \ct p \\
278
+ & = \epsilon y
279
+ \end{align*}
280
+ where the second equality follows by $\tau x$ and the third equality is naturality of $\epsilon$.
281
+ \end{proof}
282
+
283
+ We now define the types which encapsulate contractible pairs of data.
284
+ The following types put together the quasi-inverse $g$ with one of the homotopies.
285
+
286
+ \begin{defn}\label{defn:linv-rinv}
287
+ Given a function $f:A\to B$, we define the types
288
+ \begin{align*}
289
+ \linv(f) &\defeq \sm{g:B\to A} (g\circ f\htpy \idfunc[A])\\
290
+ \rinv(f) &\defeq \sm{g:B\to A} (f\circ g\htpy \idfunc[B])
291
+ \end{align*}
292
+ of \define{left inverses}
293
+ \indexdef{left!inverse}%
294
+ \indexdef{inverse!left}%
295
+ and \define{right inverses}
296
+ \indexdef{right!inverse}%
297
+ \indexdef{inverse!right}%
298
+ to $f$, respectively.
299
+ We call $f$ \define{left invertible}
300
+ \indexdef{function!left invertible}%
301
+ \indexdef{function!right invertible}%
302
+ if $\linv(f)$ is inhabited, and similarly \define{right invertible}
303
+ \indexdef{left!invertible function}%
304
+ \indexdef{right!invertible function}%
305
+ if $\rinv(f)$ is inhabited.
306
+ \end{defn}
307
+
308
+ \begin{lem}\label{thm:equiv-compose-equiv}
309
+ If $f:A\to B$ has a quasi-inverse, then so do
310
+ \begin{align*}
311
+ (f\circ \blank) &: (C\to A) \to (C\to B)\\
312
+ (\blank\circ f) &: (B\to C) \to (A\to C).
313
+ \end{align*}
314
+ \end{lem}
315
+ \begin{proof}
316
+ If $g$ is a quasi-inverse of $f$, then $(g\circ \blank)$ and $(\blank\circ g)$ are quasi-inverses of $(f\circ \blank)$ and $(\blank\circ f)$ respectively.
317
+ \end{proof}
318
+
319
+ \begin{lem}\label{lem:inv-hprop}
320
+ If $f : A \to B$ has a quasi-inverse, then the types $\rinv(f)$ and $\linv(f)$ are contractible.
321
+ \end{lem}
322
+ \begin{proof}
323
+ By function extensionality, we have
324
+ \[\eqv{\linv(f)}{\sm{g:B\to A} (g\circ f = \idfunc[A])}.\]
325
+ But this is the fiber of $(\blank\circ f)$ over $\idfunc[A]$, and so
326
+ by \cref{thm:equiv-compose-equiv,thm:equiv-iso-adj,thm:contr-hae}, it is contractible.
327
+ Similarly, $\rinv(f)$ is equivalent to the fiber of $(f\circ \blank)$ over $\idfunc[B]$ and hence contractible.
328
+ \end{proof}
329
+
330
+ Next we define the types which put together the other homotopy with the additional coherence datum.\index{coherence}%
331
+
332
+ \begin{defn}\label{defn:lcoh-rcoh}
333
+ For $f : A \to B$, a left inverse $(g,\eta) : \linv(f)$, and a right inverse $(g,\epsilon) : \rinv(f)$, we denote
334
+ \begin{align*}
335
+ \lcoh{f}{g}{\eta} & \defeq \sm{\epsilon : f\circ g \htpy \idfunc[B]} \prd{y:B} g(\epsilon y) = \eta (gy), \\
336
+ \rcoh{f}{g}{\epsilon} & \defeq \sm{\eta : g\circ f \htpy \idfunc[A]} \prd{x:A} f(\eta x) = \epsilon (fx).
337
+ \end{align*}
338
+ \end{defn}
339
+
340
+ \begin{lem}\label{lem:coh-hfib}
341
+ For any $f,g,\epsilon,\eta$, we have
342
+ \begin{align*}
343
+ \lcoh{f}{g}{\eta} & \eqvsym {\prd{y:B} \id[\hfib{g}{gy}]{(fgy,\eta(gy))}{(y,\refl{gy})}}, \\
344
+ \rcoh{f}{g}{\epsilon} & \eqvsym {\prd{x:A} \id[\hfib{f}{fx}]{(gfx,\epsilon(fx))}{(x,\refl{fx})}}.
345
+ \end{align*}
346
+ \end{lem}
347
+ \begin{proof}
348
+ Using \cref{lem:hfib}.
349
+ \end{proof}
350
+
351
+ \begin{lem}\label{lem:coh-hprop}
352
+ If $f$ is a half adjoint equivalence, then for any $(g,\epsilon) : \rinv(f)$, the type $\rcoh{f}{g}{\epsilon}$ is contractible.
353
+ \end{lem}
354
+ \begin{proof}
355
+ By \cref{lem:coh-hfib} and the fact that dependent function types preserve contractible spaces, it suffices to show that for each $x:A$, the type $\id[\hfib{f}{fx}]{(gfx,\epsilon(fx))}{(x,\refl{fx})}$ is contractible.
356
+ But by \cref{thm:contr-hae}, $\hfib{f}{fx}$ is contractible, and any path space of a contractible space is itself contractible.
357
+ \end{proof}
358
+
359
+ \begin{thm}\label{thm:hae-hprop}
360
+ For any $f : A \to B$, the type $\ishae(f)$ is a mere proposition.
361
+ \end{thm}
362
+ \begin{proof}
363
+ By \cref{ex:prop-inhabcontr} it suffices to assume $f$ to be a half adjoint equivalence and show that $\ishae(f)$ is contractible.
364
+ Now by associativity of $\Sigma$ (\cref{ex:sigma-assoc}), the type $\ishae(f)$ is equivalent to
365
+ \[\sm{u : \rinv(f)} \rcoh{f}{\proj{1}(u)}{\proj{2}(u)}.\]
366
+ But by \cref{lem:inv-hprop,lem:coh-hprop} and the fact that $\Sigma$ preserves contractibility, the latter type is also contractible.
367
+ \end{proof}
368
+
369
+ Thus, we have shown that $\ishae(f)$ has all three desiderata for the type $\isequiv(f)$.
370
+ In the next two sections we consider a couple of other possibilities.
371
+
372
+ \index{equivalence!half adjoint|)}%
373
+ \index{half adjoint equivalence|)}%
374
+ \index{adjoint!equivalence!of types, half|)}%
375
+
376
+ \section{Bi-invertible maps}
377
+ \label{sec:biinv}
378
+
379
+ \index{function!bi-invertible|(defstyle}%
380
+ \index{bi-invertible function|(defstyle}%
381
+ \index{equivalence!as bi-invertible function|(defstyle}%
382
+
383
+ Using the language introduced in \cref{sec:hae}, we can restate the definition proposed in \cref{sec:basics-equivalences} as follows.
384
+
385
+ \begin{defn}\label{defn:biinv}
386
+ We say $f:A\to B$ is \define{bi-invertible}
387
+ if it has both a left inverse and a right inverse:
388
+ \[ \biinv (f) \defeq \linv(f) \times \rinv(f). \]
389
+ \end{defn}
390
+
391
+ In \cref{sec:basics-equivalences} we proved that $\qinv(f)\to\biinv(f)$ and $\biinv(f)\to\qinv(f)$.
392
+ What remains is the following.
393
+
394
+ \begin{thm}\label{thm:isprop-biinv}
395
+ For any $f:A\to B$, the type $\biinv(f)$ is a mere proposition.
396
+ \end{thm}
397
+ \begin{proof}
398
+ We may suppose $f$ to be bi-invertible and show that $\biinv(f)$ is contractible.
399
+ But since $\biinv(f)\to\qinv(f)$, by \cref{lem:inv-hprop} in this case both $\linv(f)$ and $\rinv(f)$ are contractible, and the product of contractible types is contractible.
400
+ \end{proof}
401
+
402
+ Note that this also fits the proposal made at the beginning of \cref{sec:hae}: we combine $g$ and $\eta$ into a contractible type and add an additional datum which combines with $\epsilon$ into a contractible type.
403
+ The difference is that instead of adding a \emph{higher} datum (a 2-dimensional path) to combine with $\epsilon$, we add a \emph{lower} one (a right inverse that is separate from the left inverse).
404
+
405
+ \begin{cor}\label{thm:equiv-biinv-isequiv}
406
+ For any $f:A\to B$ we have $\eqv{\biinv(f)}{\ishae(f)}$.
407
+ \end{cor}
408
+ \begin{proof}
409
+ We have $\biinv(f) \to \qinv(f) \to \ishae(f)$ and $\ishae(f) \to \qinv(f) \to \biinv(f)$.
410
+ Since both $\ishae(f)$ and $\biinv(f)$ are mere propositions, the equivalence follows from \cref{lem:equiv-iff-hprop}.
411
+ \end{proof}
412
+
413
+ \index{function!bi-invertible|)}%
414
+ \index{bi-invertible function|)}%
415
+ \index{equivalence!as bi-invertible function|)}%
416
+
417
+ \section{Contractible fibers}
418
+ \label{sec:contrf}
419
+
420
+ \index{function!contractible|(defstyle}%
421
+ \index{contractible!function|(defstyle}%
422
+ \index{equivalence!as contractible function|(defstyle}%
423
+
424
+ Note that our proofs about $\ishae(f)$ and $\biinv(f)$ made essential use of the fact that the fibers of an equivalence are contractible.
425
+ In fact, it turns out that this property is itself a sufficient definition of equivalence.
426
+
427
+ \begin{defn}[Contractible maps] \label{defn:equivalence}
428
+ A map $f:A\to B$ is \define{contractible}
429
+ if for all $y:B$, the fiber $\hfib f y$ is contractible.
430
+ \end{defn}
431
+
432
+ Thus, the type $\iscontr(f)$ is defined to be
433
+ \begin{align}
434
+ \iscontr(f) &\defeq \prd{y:B} \iscontr(\hfib f y)\label{eq:iscontrf}
435
+ % \\
436
+ % &\defeq \prd{y:B} \iscontr (\setof{x:A | f(x) = y}).
437
+ \end{align}
438
+ Note that in \cref{sec:contractibility} we defined what it means for a \emph{type} to be contractible.
439
+ Here we are defining what it means for a \emph{map} to be contractible.
440
+ Our terminology follows the general homotopy-theoretic practice of saying that a map has a certain property if all of its (homotopy) fibers have that property.
441
+ Thus, a type $A$ is contractible just when the map $A\to\unit$ is contractible.
442
+ From \cref{cha:hlevels} onwards we will also call contractible maps and types \emph{$(-2)$-truncated}.
443
+
444
+ We have already shown in \cref{thm:contr-hae} that $\ishae(f) \to \iscontr(f)$.
445
+ Conversely:
446
+
447
+ \begin{thm}\label{thm:lequiv-contr-hae}
448
+ For any $f:A\to B$ we have ${\iscontr(f)} \to {\ishae(f)}$.
449
+ \end{thm}
450
+ \begin{proof}
451
+ Let $P : \iscontr(f)$. We define an inverse mapping $g : B \to A$ by sending each $y : B$ to the center of contraction of the fiber at $y$:
452
+ \[ g(y) \defeq \proj{1}(\proj{1}(Py)). \]
453
+ We can thus define the homotopy $\epsilon$ by mapping $y$ to the witness that $g(y)$ indeed belongs to the fiber at $y$:
454
+ \[ \epsilon(y) \defeq \proj{2}(\proj{1}(P y)). \]
455
+ It remains to define $\eta$ and $\tau$. This of course amounts to giving an element of $\rcoh{f}{g}{\epsilon}$. By \cref{lem:coh-hfib}, this is the same as giving for each $x:A$ a path from $(gfx,\epsilon(fx))$ to $(x,\refl{fx})$ in the fiber of $f$ over $fx$. But this is easy: for any $x : A$, the type $\hfib{f}{fx}$
456
+ is contractible by assumption, hence such a path must exist. We can construct it explicitly as
457
+ \[\opp{\big(\proj{2}(P(fx))(gfx,\epsilon(fx))\big)} \ct \big(\proj{2}(P(fx)) (x,\refl{fx})\big). \qedhere \]
458
+ \end{proof}
459
+
460
+ It is also easy to see:
461
+
462
+ \begin{lem}\label{thm:contr-hprop}
463
+ For any $f$, the type $\iscontr(f)$ is a mere proposition.
464
+ \end{lem}
465
+ \begin{proof}
466
+ By \cref{thm:isprop-iscontr}, each type $\iscontr (\hfib f y)$ is a mere proposition.
467
+ Thus, by \cref{thm:isprop-forall}, so is~\eqref{eq:iscontrf}.
468
+ \end{proof}
469
+
470
+ \begin{thm}\label{thm:equiv-contr-hae}
471
+ For any $f:A\to B$ we have $\eqv{\iscontr(f)}{\ishae(f)}$.
472
+ \end{thm}
473
+ \begin{proof}
474
+ We have already established a logical equivalence ${\iscontr(f)} \Leftrightarrow {\ishae(f)}$, and both are mere propositions (\cref{thm:contr-hprop,thm:hae-hprop}).
475
+ Thus, \cref{lem:equiv-iff-hprop} applies.
476
+ \end{proof}
477
+
478
+ Usually, we prove that a function is an equivalence by exhibiting a quasi-inverse, but sometimes this definition is more convenient.
479
+ For instance, it implies that when proving a function to be an equivalence, we are free to assume that its codomain is inhabited.
480
+
481
+ \begin{cor}\label{thm:equiv-inhabcod}
482
+ If $f:A\to B$ is such that $B\to \isequiv(f)$, then $f$ is an equivalence.
483
+ \end{cor}
484
+ \begin{proof}
485
+ To show $f$ is an equivalence, it suffices to show that $\hfib f y$ is contractible for any $y:B$.
486
+ But if $e:B\to \isequiv(f)$, then given any such $y$ we have $e(y):\isequiv(f)$, so that $f$ is an equivalence and hence $\hfib f y$ is contractible, as desired.
487
+ \end{proof}
488
+
489
+ \index{function!contractible|)}%
490
+ \index{contractible!function|)}%
491
+ \index{equivalence!as contractible function|)}%
492
+
493
+ \section{On the definition of equivalences}
494
+ \label{sec:concluding-remarks}
495
+
496
+ \indexdef{equivalence}
497
+ We have shown that all three definitions of equivalence satisfy the three desirable properties and are pairwise equivalent:
498
+ \[ \iscontr(f) \eqvsym \ishae(f) \eqvsym \biinv(f). \]
499
+ (There are yet more possible definitions of equivalence, but we will stop with these three.
500
+ See \cref{ex:brck-qinv} and the exercises in this chapter for some more.)
501
+ Thus, we may choose any one of them as ``the'' definition of $\isequiv (f)$.
502
+ For definiteness, we choose to define
503
+ \[ \isequiv(f) \defeq \ishae(f).\]
504
+ \index{mathematics!formalized}%
505
+ This choice is advantageous for formalization, since $\ishae(f)$ contains the most directly useful data.
506
+ On the other hand, for other purposes, $\biinv(f)$ is often easier to deal with, since it contains no 2-dimensional paths and its two symmetrical halves can be treated independently.
507
+ However, for purposes of this book, the specific choice will make little difference.
508
+
509
+ In the rest of this chapter, we study some other properties and characterizations of equivalences.
510
+ \index{equivalence!properties of}%
511
+
512
+
513
+ \section{Surjections and embeddings}
514
+ \label{sec:mono-surj}
515
+
516
+ \index{set}
517
+ When $A$ and $B$ are sets and $f:A\to B$ is an equivalence, we also call it as \define{isomorphism}
518
+ \indexdef{isomorphism!of sets}%
519
+ or a \define{bijection}.
520
+ \indexdef{bijection}%
521
+ \indexsee{function!bijective}{bijection}%
522
+ (We avoid these words for types that are not sets, since in homotopy theory and higher category theory they often denote a stricter notion of ``sameness'' than homotopy equivalence.)
523
+ In set theory, a function is a bijection just when it is both injective and surjective.
524
+ The same is true in type theory, if we formulate these conditions appropriately.
525
+ For clarity, when dealing with types that are not sets, we will speak of \emph{embeddings} instead of injections.
526
+
527
+ \begin{defn}\label{defn:surj-emb}
528
+ Let $f:A\to B$.
529
+ \begin{enumerate}
530
+ \item We say $f$ is \define{surjective}
531
+ \indexsee{surjective!function}{function, surjective}%
532
+ \indexdef{function!surjective}%
533
+ (or a \define{surjection})
534
+ \indexsee{surjection}{function, surjective}%
535
+ if for every $b:B$ we have $\brck{\hfib f b}$.
536
+ \item We say $f$ is an \define{embedding}
537
+ \indexdef{function!embedding}%
538
+ \indexsee{embedding}{function, embedding}%
539
+ if for every $x,y:A$ the function $\apfunc f : (\id[A]xy) \to (\id[B]{f(x)}{f(y)})$ is an equivalence.
540
+ \end{enumerate}
541
+ \end{defn}
542
+
543
+ In other words, $f$ is surjective if every fiber of $f$ is merely inhabited, or equivalently if for all $b:B$ there merely exists an $a:A$ such that $f(a)=b$.
544
+ In traditional logical notation, $f$ is surjective if $\fall{b:B}\exis{a:A} (f(a)=b)$.
545
+ This must be distinguished from the stronger assertion that $\prd{b:B}\sm{a:A} (f(a)=b)$; if this holds we say that $f$ is a \define{split surjection}.
546
+ \indexsee{split!surjection}{function, split surjective}%
547
+ \indexsee{surjection!split}{function, split surjective}%
548
+ \indexsee{surjective!function!split}{function, split surjective}%
549
+ \indexdef{function!split surjective}%
550
+ (Since this latter type is equivalent to $\sm{g:B\to A}\prd{b:B} (f(g(b))=b)$, being a split surjection is the same as being a \emph{retraction} as defined in \cref{sec:contractibility}.)
551
+ \index{retraction}%
552
+ \index{function!retraction}%
553
+
554
+ The axiom of choice from \cref{sec:axiom-choice} says exactly that every surjection \emph{between sets} is split.
555
+ However, in the presence of the univalence axiom, it is simply false that \emph{all} surjections are split.
556
+ In \cref{thm:no-higher-ac} we constructed a type family $Y:X\to \type$ such that $\prd{x:X} \brck{Y(x)}$ but $\neg \prd{x:X} Y(x)$;
557
+ for any such family, the first projection $(\sm{x:X} Y(x)) \to X$ is a surjection that is not split.
558
+
559
+ If $A$ and $B$ are sets, then by \cref{lem:equiv-iff-hprop}, $f$ is an embedding just when
560
+ \begin{equation}
561
+ \prd{x,y:A} (\id[B]{f(x)}{f(y)}) \to (\id[A]xy).\label{eq:injective}
562
+ \end{equation}
563
+ In this case we say that $f$ is \define{injective},
564
+ \indexsee{injective function}{function, injective}%
565
+ \indexdef{function!injective}%
566
+ or an \define{injection}.
567
+ \indexsee{injection}{function, injective}%
568
+ We avoid these word for types that are not sets, because they might be interpreted as~\eqref{eq:injective}, which is an ill-behaved notion for non-sets.
569
+ It is also true that any function between sets is surjective if and only if it is an \emph{epimorphism} in a suitable sense, but this also fails for more general types, and surjectivity is generally the more important notion.
570
+
571
+ \begin{thm}\label{thm:mono-surj-equiv}
572
+ A function $f:A\to B$ is an equivalence if and only if it is both surjective and an embedding.
573
+ \end{thm}
574
+ \begin{proof}
575
+ If $f$ is an equivalence, then each $\hfib f b$ is contractible, hence so is $\brck{\hfib f b}$, so $f$ is surjective.
576
+ And we showed in \cref{thm:paths-respects-equiv} that any equivalence is an embedding.
577
+
578
+ Conversely, suppose $f$ is a surjective embedding.
579
+ Let $b:B$; we show that $\sm{x:A}(f(x)=b)$ is contractible.
580
+ Since $f$ is surjective, there merely exists an $a:A$ such that $f(a)=b$.
581
+ Thus, the fiber of $f$ over $b$ is inhabited; it remains to show it is a mere proposition.
582
+ For this, suppose given $x,y:A$ with $p:f(x)=b$ and $q:f(y)=b$.
583
+ Then since $\apfunc f$ is an equivalence, there exists $r:x=y$ with $\apfunc f (r) = p \ct \opp q$.
584
+ However, using the characterization of paths in $\Sigma$-types, the latter equality rearranges to $\trans{r}{p} = q$.
585
+ Thus, together with $r$ it exhibits $(x,p) = (y,q)$ in the fiber of $f$ over $b$.
586
+ \end{proof}
587
+
588
+ \begin{cor}
589
+ For any $f:A\to B$ we have
590
+ \[ \isequiv(f) \eqvsym (\mathsf{isEmbedding}(f) \times \mathsf{isSurjective}(f)).\]
591
+ \end{cor}
592
+ \begin{proof}
593
+ Being a surjection and an embedding are both mere propositions; now apply \cref{lem:equiv-iff-hprop}.
594
+ \end{proof}
595
+
596
+ Of course, this cannot be used as a definition of ``equivalence'', since the definition of embeddings refers to equivalences.
597
+ However, this characterization can still be useful; see \cref{sec:whitehead}.
598
+ We will generalize it in \cref{cha:hlevels}.
599
+
600
+
601
+ % \section{Fiberwise equivalences}
602
+ \section{Closure properties of equivalences}
603
+ \label{sec:equiv-closures}
604
+ \label{sec:fiberwise-equivalences}
605
+ \index{equivalence!properties of}%
606
+
607
+
608
+ % We end this chapter by observing some important closure properties of equivalences.
609
+ We have already seen in \cref{thm:equiv-eqrel} that equivalences are closed under composition.
610
+ Furthermore, we have:
611
+
612
+ \begin{thm}[The 2-out-of-3 property]\label{thm:two-out-of-three}
613
+ \index{2-out-of-3 property}%
614
+ Suppose $f:A\to B$ and $g:B\to C$.
615
+ If any two of $f$, $g$, and $g\circ f$ are equivalences, so is the third.
616
+ \end{thm}
617
+ \begin{proof}
618
+ If $g\circ f$ and $g$ are equivalences, then $\opp{(g\circ f)} \circ g$ is a quasi-inverse to $f$.
619
+ On the one hand, we have $\opp{(g\circ f)} \circ g \circ f \htpy \idfunc[A]$, while on the other we have
620
+ \begin{align*}
621
+ f \circ \opp{(g\circ f)} \circ g
622
+ &\htpy \opp g \circ g \circ f \circ \opp{(g\circ f)} \circ g\\
623
+ &\htpy \opp g \circ g\\
624
+ &\htpy \idfunc[B].
625
+ \end{align*}
626
+ Similarly, if $g\circ f$ and $f$ are equivalences, then $f\circ \opp{(g\circ f)}$ is a quasi-inverse to $g$.
627
+ \end{proof}
628
+
629
+ This is a standard closure condition on equivalences from homotopy theory.
630
+ Also well-known is that they are closed under retracts, in the following sense.
631
+
632
+ \index{retract!of a function|(defstyle}%
633
+
634
+ \begin{defn}\label{defn:retract}
635
+ A function $g:A\to B$ is said to be a \define{retract}
636
+ of a function $f:X\to Y$ if there is a diagram
637
+ \begin{equation*}
638
+ \xymatrix{
639
+ {A} \ar[r]^{s} \ar[d]_{g}
640
+ &
641
+ {X} \ar[r]^{r} \ar[d]_{f}
642
+ &
643
+ {A} \ar[d]^{g}
644
+ \\
645
+ {B} \ar[r]_{s'}
646
+ &
647
+ {Y} \ar[r]_{r'}
648
+ &
649
+ {B}
650
+ }
651
+ \end{equation*}
652
+ for which there are
653
+ \begin{enumerate}
654
+ \item a homotopy $R:r\circ s \htpy \idfunc[A]$.
655
+ \item a homotopy $R':r'\circ s' \htpy\idfunc[B]$.
656
+ \item a homotopy $L:f\circ s\htpy s'\circ g$.
657
+ \item a homotopy $K:g\circ r\htpy r'\circ f$.
658
+ \item for every $a:A$, a path $H(a)$ witnessing the commutativity of the square
659
+ \begin{equation*}
660
+ \xymatrix@C=3pc{
661
+ {g(r(s(a)))} \ar@{=}[r]^-{K(s(a))} \ar@{=}[d]_{\ap g{R(a)}}
662
+ &
663
+ {r'(f(s(a)))} \ar@{=}[d]^{\ap{r'}{L(a)}}
664
+ \\
665
+ {g(a)} \ar@{=}[r]_-{\opp{R'(g(a))}}
666
+ &
667
+ {r'(s'(g(a)))}
668
+ }
669
+ \end{equation*}
670
+ \end{enumerate}
671
+ \end{defn}
672
+
673
+ Recall that in \cref{sec:contractibility} we defined what it means for a type to be a retract of another.
674
+ This is a special case of the above definition where $B$ and $Y$ are $\unit$.
675
+ Conversely, just as with contractibility, retractions of maps induce retractions of their fibers.
676
+
677
+ \begin{lem}\label{lem:func_retract_to_fiber_retract}
678
+ If a function $g:A\to B$ is a retract of a function $f:X\to Y$, then $\hfib{g}b$ is a retract of $\hfib{f}{s'(b)}$
679
+ for every $b:B$, where $s':B\to Y$ is as in \cref{defn:retract}.
680
+ \end{lem}
681
+
682
+ \begin{proof}
683
+ Suppose that $g:A\to B$ is a retract of $f:X\to Y$. Then for any $b:B$ we have the functions
684
+ \begin{align*}
685
+ \varphi_b &:\hfiber{g}b\to\hfib{f}{s'(b)}, &
686
+ \varphi_b(a,p) & \defeq \pairr{s(a),L(a)\ct s'(p)},\\
687
+ \psi_b &:\hfib{f}{s'(b)}\to\hfib{g}b, &
688
+ \psi_b(x,q) &\defeq \pairr{r(x),K(x)\ct r'(q)\ct R'(b)}.
689
+ \end{align*}
690
+ Then we have $\psi_b(\varphi_b({a,p}))\equiv\pairr{r(s(a)),K(s(a))\ct r'(L(a)\ct s'(p))\ct R'(b)}$.
691
+ We claim $\psi_b$ is a retraction with section $\varphi_b$ for all $b:B$, which is to say that for all $(a,p):\hfib g b$ we have $\psi_b(\varphi_b({a,p}))= \pairr{a,p}$.
692
+ In other words, we want to show
693
+ \begin{equation*}
694
+ \prd{b:B}{a:A}{p:g(a)=b} \psi_b(\varphi_b({a,p}))= \pairr{a,p}.
695
+ \end{equation*}
696
+ By reordering the first two $\Pi$s and applying a version of \cref{thm:omit-contr}, this is equivalent to
697
+ \begin{equation*}
698
+ \prd{a:A}\psi_{g(a)}(\varphi_{g(a)}({a,\refl{g(a)}}))=\pairr{a,\refl{g(a)}}.
699
+ \end{equation*}
700
+ For any $a$, by \cref{thm:path-sigma}, this equality of pairs is equivalent to a pair of equalities. The first components are equal by $R(a):r(s(a))= a$, so we need only show
701
+ \begin{equation*}
702
+ \trans{R(a)}{K(s(a))\ct r'(L(a))\ct R'(g(a))} = \refl{g(a)}.
703
+ \end{equation*}
704
+ But this transportation computes as $\opp{g(R(a))}\ct K(s(a))\ct r'(L(a))\ct R'(g(a))$, so the required path is given by $H(a)$.
705
+ \end{proof}
706
+
707
+ \begin{thm}\label{thm:retract-equiv}
708
+ If $g$ is a retract of an equivalence $f$, then $g$ is also an equivalence.
709
+ \end{thm}
710
+ \begin{proof}
711
+ By \cref{lem:func_retract_to_fiber_retract}, every fiber of $g$ is a retract of a fiber of $f$.
712
+ Thus, by \cref{thm:retract-contr}, if the latter are all contractible, so are the former.
713
+ \end{proof}
714
+
715
+ \index{retract!of a function|)}%
716
+
717
+ \index{fibration}%
718
+ \index{total!space}%
719
+ Finally, we show that fiberwise equivalences can be characterized in terms of equivalences of total spaces.
720
+ To explain the terminology, recall from \cref{sec:fibrations} that a type family $P:A\to\type$ can be viewed as a fibration over $A$ with total space $\sm{x:A} P(x)$, the fibration being the projection $\proj1:\sm{x:A} P(x) \to A$.
721
+ From this point of view, given two type families $P,Q:A\to\type$, we may refer to a function $f:\prd{x:A} (P(x)\to Q(x))$ as a \define{fiberwise map} or a \define{fiberwise transformation}.
722
+ \indexsee{transformation!fiberwise}{fiberwise transformation}%
723
+ \indexsee{function!fiberwise}{fiberwise transformation}%
724
+ \index{fiberwise!transformation|(defstyle}%
725
+ \indexsee{fiberwise!map}{fiberwise transformation}%
726
+ \indexsee{map!fiberwise}{fiberwise transformation}
727
+ Such a map induces a function on total spaces:
728
+
729
+ \begin{defn}\label{defn:total-map}
730
+ Given type families $P,Q:A\to\type$ and a map $f:\prd{x:A} P(x)\to Q(x)$, we define
731
+ \begin{equation*}
732
+ \total f \defeq \lam{w}\pairr{\proj{1}w,f(\proj{1}w,\proj{2}w)} : \sm{x:A}P(x)\to\sm{x:A}Q(x).
733
+ \end{equation*}
734
+ \end{defn}
735
+
736
+ \begin{thm}\label{fibwise-fiber-total-fiber-equiv}
737
+ Suppose that $f$ is a fiberwise transformation between families $P$ and
738
+ $Q$ over a type $A$ and let $x:A$ and $v:Q(x)$. Then we have an equivalence
739
+ \begin{equation*}
740
+ \eqv{\hfib{\total{f}}{\pairr{x,v}}}{\hfib{f(x)}{v}}.
741
+ \end{equation*}
742
+ \end{thm}
743
+ \begin{proof}
744
+ We calculate:
745
+ \begin{align}
746
+ \hfib{\total{f}}{\pairr{x,v}}
747
+ & \jdeq \sm{w:\sm{x:A}P(x)}\pairr{\proj{1}w,f(\proj{1}w,\proj{2}w)}=\pairr{x,v}
748
+ \notag \\
749
+ & \eqv{}{} \sm{a:A}{u:P(a)}\pairr{a,f(a,u)}=\pairr{x,v}
750
+ \tag{by~\cref{ex:sigma-assoc}} \\
751
+ & \eqv{}{} \sm{a:A}{u:P(a)}{p:a=x}\trans{p}{f(a,u)}=v
752
+ \tag{by \cref{thm:path-sigma}} \\
753
+ & \eqv{}{} \sm{a:A}{p:a=x}{u:P(a)}\trans{p}{f(a,u)}=v
754
+ \notag \\
755
+ & \eqv{}{} \sm{u:P(x)}f(x,u)=v
756
+ \tag{$*$}\label{eq:uses-sum-over-paths} \\
757
+ & \jdeq \hfib{f(x)}{v}. \notag
758
+ \end{align}
759
+ The equivalence~\eqref{eq:uses-sum-over-paths} follows from \cref{thm:omit-contr,thm:contr-paths,ex:sigma-assoc}.
760
+ \end{proof}
761
+
762
+ We say that a fiberwise transformation $f:\prd{x:A} P(x)\to Q(x)$ is a \define{fiberwise equivalence}%
763
+ \indexdef{fiberwise!equivalence}%
764
+ \indexdef{equivalence!fiberwise}
765
+ if each $f(x):P(x) \to Q(x)$ is an equivalence.
766
+
767
+ \begin{thm}\label{thm:total-fiber-equiv}
768
+ Suppose that $f$ is a fiberwise transformation between families
769
+ $P$ and $Q$ over a type $A$.
770
+ Then $f$ is a fiberwise equivalence if and only if $\total{f}$ is an equivalence.
771
+ \end{thm}
772
+
773
+ \begin{proof}
774
+ Let $f$, $P$, $Q$ and $A$ be as in the statement of the theorem.
775
+ By \cref{fibwise-fiber-total-fiber-equiv} it follows for all
776
+ $x:A$ and $v:Q(x)$ that
777
+ $\hfib{\total{f}}{\pairr{x,v}}$ is contractible if and only if
778
+ $\hfib{f(x)}{v}$ is contractible.
779
+ Thus, $\hfib{\total{f}}{w}$ is contractible for all $w:\sm{x:A}Q(x)$ if and only if $\hfib{f(x)}{v}$ is contractible for all $x:A$ and $v:Q(x)$.
780
+ \end{proof}
781
+
782
+ \index{fiberwise!transformation|)}%
783
+
784
+
785
+ \section{The object classifier}
786
+ \label{sec:object-classification}
787
+
788
+ In type theory we have a basic notion of \emph{family of types}, namely a function $B:A\to\type$.
789
+ We have seen that such families behave somewhat like \emph{fibrations} in homotopy theory, with the fibration being the projection $\proj1:\sm{a:A} B(a) \to A$.
790
+ A basic fact in homotopy theory is that every map is equivalent to a fibration.
791
+ With univalence at our disposal, we can prove the same thing in type theory.
792
+
793
+ \begin{lem}\label{thm:fiber-of-a-fibration}
794
+ For any type family $B:A\to\type$, the fiber of $\proj1:\sm{x:A} B(x) \to A$ over $a:A$ is equivalent to $B(a)$:
795
+ \[ \eqv{\hfib{\proj1}{a}}{B(a)} \]
796
+ \end{lem}
797
+ \begin{proof}
798
+ We have
799
+ \begin{align*}
800
+ \hfib{\proj1}{a} &\defeq \sm{u:\sm{x:A} B(x)} \proj1(u)=a\\
801
+ &\eqvsym \sm{x:A}{b:B(x)} (x=a)\\
802
+ &\eqvsym \sm{x:A}{p:x=a} B(x)\\
803
+ &\eqvsym B(a)
804
+ \end{align*}
805
+ using the left universal property of identity types.
806
+ \end{proof}
807
+
808
+ \begin{lem}\label{thm:total-space-of-the-fibers}
809
+ For any function $f:A\to B$, we have $\eqv{A}{\sm{b:B}\hfib{f}{b}}$.
810
+ \end{lem}
811
+ \begin{proof}
812
+ We have
813
+ \begin{align*}
814
+ \sm{b:B}\hfib{f}{b} &\defeq \sm{b:B}{a:A} (f(a)=b)\\
815
+ &\eqvsym \sm{a:A}{b:B} (f(a)=b)\\
816
+ &\eqvsym A
817
+ \end{align*}
818
+ using the fact that $\sm{b:B} (f(a)=b)$ is contractible.
819
+ \end{proof}
820
+
821
+ \begin{thm}\label{thm:nobject-classifier-appetizer}
822
+ For any type $B$ there is an equivalence
823
+ \begin{equation*}
824
+ \chi:\Parens{\sm{A:\type} (A\to B)}\eqvsym (B\to\type).
825
+ \end{equation*}
826
+ \end{thm}
827
+ \begin{proof}
828
+ We have to construct quasi-inverses
829
+ \begin{align*}
830
+ \chi & : \Parens{\sm{A:\type} (A\to B)}\to B\to\type\\
831
+ \psi & : (B\to\type)\to\Parens{\sm{A:\type} (A\to B)}.
832
+ \end{align*}
833
+ We define $\chi$ by $\chi((A,f),b)\defeq\hfiber{f}b$, and $\psi$ by $\psi(P)\defeq\Pairr{(\sm{b:B} P(b)),\proj1}$.
834
+ Now we have to verify that $\chi\circ\psi\htpy\idfunc{}$ and that $\psi\circ\chi \htpy\idfunc{}$.
835
+ \begin{enumerate}
836
+ \item Let $P:B\to\type$.
837
+ By \cref{thm:fiber-of-a-fibration},
838
+ $\hfiber{\proj1}{b}\eqvsym P(b)$ for any $b:B$, so it follows immediately
839
+ that $P\htpy\chi(\psi(P))$.
840
+ \item Let $f:A\to B$ be a function. We have to find a path
841
+ \begin{equation*}
842
+ \Pairr{\tsm{b:B} \hfiber{f}b,\,\proj1}=\pairr{A,f}.
843
+ \end{equation*}
844
+ First note that by \cref{thm:total-space-of-the-fibers}, we have
845
+ $e:\sm{b:B} \hfiber{f}b\eqvsym A$ with $e(b,a,p)\defeq a$ and $e^{-1}(a)
846
+ \defeq(f(a),a,\refl{f(a)})$.
847
+ By \cref{thm:path-sigma}, it remains to show $\trans{(\ua(e))}{\proj1} = f$.
848
+ But by the computation rule for univalence and~\eqref{eq:transport-arrow}, we have $\trans{(\ua(e))}{\proj1} = \proj1\circ e^{-1}$, and the definition of $e^{-1}$ immediately yields $\proj1 \circ e^{-1} \jdeq f$.\qedhere
849
+ \end{enumerate}
850
+ \end{proof}
851
+
852
+ \noindent
853
+ \indexdef{object!classifier}%
854
+ \indexdef{classifier!object}%
855
+ \index{.infinity1-topos@$(\infty,1)$-topos}%
856
+ In particular, this implies that we have an \emph{object classifier} in the sense of higher topos theory.
857
+ Recall from \cref{def:pointedtype} that $\pointed\type$ denotes the type $\sm{A:\type} A$ of pointed types.
858
+
859
+ \begin{thm}\label{thm:object-classifier}
860
+ Let $f:A\to B$ be a function. Then the diagram
861
+ \begin{equation*}
862
+ \vcenter{\xymatrix{
863
+ A\ar[r]^-{\vartheta_f} \ar[d]_{f} &
864
+ \pointed{\type}\ar[d]^{\proj1}\\
865
+ B\ar[r]_{\chi_f} &
866
+ \type
867
+ }}
868
+ \end{equation*}
869
+ is a pullback\index{pullback} square (see \cref{ex:pullback}).
870
+ Here the function $\vartheta_f$ is defined by
871
+ \begin{equation*}
872
+ \lam{a} \pairr{\hfiber{f}{f(a)},\pairr{a,\refl{f(a)}}}.
873
+ \end{equation*}
874
+ \end{thm}
875
+ \begin{proof}
876
+ Note that we have the equivalences
877
+ \begin{align*}
878
+ A & \eqvsym \sm{b:B} \hfiber{f}b\\
879
+ & \eqvsym \sm{b:B}{X:\type}{p:\hfiber{f}b= X} X\\
880
+ & \eqvsym \sm{b:B}{X:\type}{x:X} \hfiber{f}b= X\\
881
+ & \eqvsym \sm{b:B}{Y:\pointed{\type}} \hfiber{f}b = \proj1 Y\\
882
+ & \jdeq B\times_{\type}\pointed{\type}
883
+ \end{align*}
884
+ which gives us a composite equivalence $e:A\eqvsym B\times_\type\pointed{\type}$.
885
+ We may display the action of this composite equivalence step by step by
886
+ \begin{align*}
887
+ a & \mapsto \pairr{f(a),\; \pairr{a,\refl{f(a)}}}\\
888
+ & \mapsto \pairr{f(a), \; \hfiber{f}{f(a)}, \; \refl{\hfiber{f}{f(a)}}, \; \pairr{a,\refl{f(a)}}}\\
889
+ & \mapsto \pairr{f(a), \; \hfiber{f}{f(a)}, \; \pairr{a,\refl{f(a)}}, \; \refl{\hfiber{f}{f(a)}}}\\
890
+ & \mapsto \pairr{f(a), \; \pairr{\hfiber{f}{f(a)}, \; \pairr{a,\refl{f(a)}}}, \; \refl{\hfiber{f}{f(a)}}}.
891
+ \end{align*}
892
+ Therefore, we get homotopies $f\htpy\proj1\circ e$ and $\vartheta_f\htpy \proj2\circ e$.
893
+ \end{proof}
894
+
895
+
896
+
897
+ \section{Univalence implies function extensionality}
898
+ \label{sec:univalence-implies-funext}
899
+
900
+ \index{function extensionality!proof from univalence}%
901
+ In the last section of this chapter we include a proof that the univalence axiom implies function
902
+ extensionality. Thus, in this section we work \emph{without} the function extensionality axiom.
903
+ The proof consists of two steps. First we show
904
+ in \cref{uatowfe} that the univalence
905
+ axiom implies a weak form of function extensionality, defined in \cref{weakfunext} below. The
906
+ principle of weak function extensionality in turn implies the usual function extensionality,
907
+ and it does so without the univalence axiom (\cref{wfetofe}).
908
+
909
+ \index{univalence axiom}%
910
+ Let $\type$ be a universe; we will explicitly indicate where we assume that it is univalent.
911
+
912
+ \begin{defn}\label{weakfunext}
913
+ The \define{weak function extensionality principle}
914
+ \indexdef{function extensionality!weak}%
915
+ asserts that there is a function
916
+ \begin{equation*}
917
+ \Parens{\prd{x:A}\iscontr(P(x))} \to\iscontr\Parens{\prd{x:A}P(x)}
918
+ \end{equation*}
919
+ for any family $P:A\to\type$ of types over any type $A$.
920
+ \end{defn}
921
+
922
+ The following lemma is easy to prove using function extensionality; the point here is that it also follows from univalence without assuming function extensionality separately.
923
+
924
+ \begin{lem} \label{UA-eqv-hom-eqv}
925
+ Assuming $\type$ is univalent, for any $A,B,X:\type$ and any $e:\eqv{A}{B}$, there is an equivalence
926
+ \begin{equation*}
927
+ \eqv{(X\to A)}{(X\to B)}
928
+ \end{equation*}
929
+ of which the underlying map is given by post-composition with the underlying function of $e$.
930
+ \end{lem}
931
+
932
+ \begin{proof}
933
+ % Immediate by induction on $\eqv{}{}$ (see \cref{thm:equiv-induction}).
934
+ As in the proof of \cref{lem:qinv-autohtpy}, we may assume that $e = \idtoeqv(p)$ for some $p:A=B$.
935
+ Then by path induction, we may assume $p$ is $\refl{A}$, so that $e = \idfunc[A]$.
936
+ But in this case, post-composition with $e$ is the identity, hence an equivalence.
937
+ \end{proof}
938
+
939
+ \begin{cor}\label{contrfamtotalpostcompequiv}
940
+ Let $P:A\to\type$ be a family of contractible types, i.e.\ \narrowequation{\prd{x:A}\iscontr(P(x)).}
941
+ Then the projection $\proj{1}:(\sm{x:A}P(x))\to A$ is an equivalence. Assuming $\type$ is univalent, it follows immediately that post-composition with $\proj{1}$ gives an equivalence
942
+ \begin{equation*}
943
+ \alpha : \eqv{\Parens{A\to\sm{x:A}P(x)}}{(A\to A)}.
944
+ \end{equation*}
945
+ \end{cor}
946
+
947
+ \begin{proof}
948
+ By \cref{thm:fiber-of-a-fibration}, for $\proj{1}:(\sm{x:A}P(x))\to A$ and $x:A$ we have an equivalence
949
+ \begin{equation*}
950
+ \eqv{\hfiber{\proj{1}}{x}}{P(x)}.
951
+ \end{equation*}
952
+ Therefore $\proj{1}$ is an equivalence whenever each $P(x)$ is contractible. The assertion is now a consequence of \cref{UA-eqv-hom-eqv}.
953
+ \end{proof}
954
+
955
+ In particular, the homotopy fiber of the above equivalence at $\idfunc[A]$ is contractible. Therefore, we can show that univalence implies weak function extensionality by showing that the dependent function type $\prd{x:A}P(x)$ is a retract of $\hfiber{\alpha}{\idfunc[A]}$.
956
+
957
+ \begin{thm}\label{uatowfe}
958
+ In a univalent universe $\type$, suppose that $P:A\to\type$ is a family of contractible types
959
+ and let $\alpha$ be the function of \cref{contrfamtotalpostcompequiv}.
960
+ Then $\prd{x:A}P(x)$ is a retract of $\hfiber{\alpha}{\idfunc[A]}$. As a consequence, $\prd{x:A}P(x)$ is contractible. In other words, the univalence axiom implies the weak function extensionality principle.
961
+ \end{thm}
962
+
963
+ \begin{proof}
964
+ Define the functions
965
+ \begin{align*}
966
+ \varphi &: (\tprd{x:A}P(x))\to\hfiber{\alpha}{\idfunc[A]},\\
967
+ \varphi(f) &\defeq (\lam{x} (x,f(x)),\refl{\idfunc[A]}),
968
+ \intertext{and}
969
+ \psi &: \hfiber{\alpha}{\idfunc[A]}\to \tprd{x:A}P(x), \\
970
+ \psi(g,p) &\defeq \lam{x} \trans {\happly (p,x)}{\proj{2} (g(x))}.
971
+ \end{align*}
972
+ Then $\psi(\varphi(f))=\lam{x} f(x)$, which is $f$, by the uniqueness principle for dependent function types.
973
+ \end{proof}
974
+
975
+ We now show that weak function extensionality implies the usual function extensionality.
976
+ Recall from~\eqref{eq:happly} the function $\happly (f,g) : (f = g)\to(f\htpy g)$ which
977
+ converts equality of functions to homotopy. In the proof that follows, the univalence
978
+ axiom is not used.
979
+
980
+ \begin{thm}\label{wfetofe}
981
+ \index{function extensionality}%
982
+ Weak function extensionality implies the function extensionality \cref{axiom:funext}.
983
+ \end{thm}
984
+
985
+ \begin{proof}
986
+ We want to show that
987
+ \begin{equation*}
988
+ \prd{A:\type}{P:A\to\type}{f,g:\prd{x:A}P(x)}\isequiv(\happly (f,g)).
989
+ \end{equation*}
990
+ Since a fiberwise map induces an equivalence on total spaces if and only if it is fiberwise an equivalence by \cref{thm:total-fiber-equiv}, it suffices to show that the function of type
991
+ \begin{equation*}
992
+ \Parens{\sm{g:\prd{x:A}P(x)}(f= g)} \to \sm{g:\prd{x:A}P(x)}(f\htpy g)
993
+ \end{equation*}
994
+ induced by $\lam{g:\prd{x:A}P(x)} \happly (f,g)$ is an equivalence.
995
+ Since the type on the left is contractible by \cref{thm:contr-paths}, it suffices to show that the type on the right:
996
+ \begin{equation}\label{eq:uatofesp}
997
+ \sm{g:\prd{x:A}P(x)}\prd{x:A}f(x)= g(x)
998
+ \end{equation}
999
+ is contractible.
1000
+ Now \cref{thm:ttac} says that this is equivalent to
1001
+ \begin{equation}\label{eq:uatofeps}
1002
+ \prd{x:A}\sm{u:P(x)}f(x)= u.
1003
+ \end{equation}
1004
+ The proof of \cref{thm:ttac} uses function extensionality, but only for one of the composites.
1005
+ Thus, without assuming function extensionality, we can conclude that~\eqref{eq:uatofesp} is a retract\index{retract!of a type} of~\eqref{eq:uatofeps}.
1006
+ And~\eqref{eq:uatofeps} is a product of contractible types, which is contractible by the weak function extensionality principle; hence~\eqref{eq:uatofesp} is also contractible.
1007
+ \end{proof}
1008
+
1009
+ \sectionNotes
1010
+
1011
+ The fact that the space of continuous maps equipped with quasi-inverses has the wrong homotopy type to be the ``space of homotopy equivalences'' is well-known in algebraic topology.
1012
+ In that context, the ``space of homotopy equivalences'' $(\eqv AB)$ is usually defined simply as the subspace of the function space $(A\to B)$ consisting of the functions that are homotopy equivalences.
1013
+ In type theory, this would correspond most closely to $\sm{f:A\to B} \brck{\qinv(f)}$; see \cref{ex:brck-qinv}.
1014
+
1015
+ The first definition of equivalence given in homotopy type theory was the one that we have called $\iscontr(f)$, which was due to Voevodsky.
1016
+ The possibility of the other definitions was subsequently observed by various people.
1017
+ The basic theorems about adjoint equivalences\index{adjoint!equivalence} such as \cref{lem:coh-equiv,thm:equiv-iso-adj} are adaptations of standard facts in higher category theory and homotopy theory.
1018
+ Using bi-invertibility as a definition of equivalences was suggested by Andr\'e Joyal.
1019
+
1020
+ The properties of equivalences discussed in \cref{sec:mono-surj,sec:equiv-closures} are well-known in homotopy theory.
1021
+ Most of them were first proven in type theory by Voevodsky.
1022
+
1023
+ The fact that every function is equivalent to a fibration is a standard fact in homotopy theory.
1024
+ The notion of object classifier
1025
+ \index{object!classifier}%
1026
+ \index{classifier!object}%
1027
+ in $(\infty,1)$-category
1028
+ \index{.infinity1-category@$(\infty,1)$-category}%
1029
+ theory (the categorical analogue of \cref{thm:nobject-classifier-appetizer}) is due to Rezk (see~\cite{Rezk05,lurie:higher-topoi}).
1030
+
1031
+ Finally, the fact that univalence implies function extensionality (\cref{sec:univalence-implies-funext}) is due to Voevodsky.
1032
+ Our proof is a simplification of his.
1033
+ \cref{ex:funext-from-nondep} is also due to Voevodsky.
1034
+
1035
+ \sectionExercises
1036
+
1037
+ \begin{ex}\label{ex:two-sided-adjoint-equivalences}
1038
+ Consider the type of ``two-sided adjoint equivalence\index{adjoint!equivalence} data'' for $f:A\to B$,
1039
+ \begin{narrowmultline*}
1040
+ \sm{g:B\to A}{\eta: g \circ f \htpy \idfunc[A]}{\epsilon:f \circ g \htpy \idfunc[B]}
1041
+ \narrowbreak
1042
+ \Parens{\prd{x:A} \map{f}{\eta x} = \epsilon(fx)} \times
1043
+ \Parens{\prd{y:B} \map{g}{\epsilon y} = \eta(gy) }.
1044
+ \end{narrowmultline*}
1045
+ By \cref{lem:coh-equiv}, we know that if $f$ is an equivalence, then this type is inhabited.
1046
+ Give a characterization of this type analogous to \cref{lem:qinv-autohtpy}.
1047
+
1048
+ Can you give an example showing that this type is not generally a mere proposition?
1049
+ (This will be easier after \cref{cha:hits}.)
1050
+ \end{ex}
1051
+
1052
+ \begin{ex}\label{ex:symmetric-equiv}
1053
+ Show that for any $A,B:\UU$, the following type is equivalent to $\eqv A B$.
1054
+ \begin{equation*}
1055
+ \sm{R:A\to B\to \type}
1056
+ \Parens{\prd{a:A} \iscontr\Parens{\sm{b:B} R(a,b)}} \times
1057
+ \Parens{\prd{b:B} \iscontr\Parens{\sm{a:A} R(a,b)}}.
1058
+ \end{equation*}
1059
+ Can you extract from this a definition of a type satisfying the three desiderata of $\isequiv(f)$?
1060
+ \end{ex}
1061
+
1062
+ \begin{ex} \label{ex:qinv-autohtpy-no-univalence}
1063
+ Reformulate the proof of \cref{lem:qinv-autohtpy} without using univalence.
1064
+ \end{ex}
1065
+
1066
+ \begin{ex}[The unstable octahedral axiom]\label{ex:unstable-octahedron}
1067
+ \index{axiom!unstable octahedral}%
1068
+ \index{octahedral axiom, unstable}%
1069
+ Suppose $f:A\to B$ and $g:B\to C$ and $b:B$.
1070
+ \begin{enumerate}
1071
+ \item Show that there is a natural map $\hfib{g\circ f}{g(b)} \to \hfib{g}{g(b)}$ whose fiber over $(b,\refl{g(b)})$ is equivalent to $\hfib f b$.
1072
+ \item Show that $\eqv{\hfib{g\circ f}{c}}{\sm{w:\hfib{g}{c}} \hfib f {\proj1 w}}$.
1073
+ \end{enumerate}
1074
+ \end{ex}
1075
+
1076
+ \begin{ex}\label{ex:2-out-of-6}
1077
+ \index{2-out-of-6 property}%
1078
+ Prove that equivalences satisfy the \emph{2-out-of-6 property}: given $f:A\to B$ and $g:B\to C$ and $h:C\to D$, if $g\circ f$ and $h\circ g$ are equivalences, so are $f$, $g$, $h$, and $h\circ g\circ f$.
1079
+ Use this to give a higher-level proof of \cref{thm:paths-respects-equiv}.
1080
+ \end{ex}
1081
+
1082
+ \begin{ex}\label{ex:qinv-univalence}
1083
+ For $A,B:\UU$, define
1084
+ \[ \mathsf{idtoqinv}_{A,B} :(A=B) \to \sm{f:A\to B}\qinv(f) \]
1085
+ by path induction in the obvious way.
1086
+ Let \textbf{\textsf{qinv}-univalence} denote the modified form of the univalence axiom which asserts that for all $A,B:\UU$ the function $\mathsf{idtoqinv}_{A,B}$ has a quasi-inverse.
1087
+ \begin{enumerate}
1088
+ \item Show that \qinv-univalence can be used instead of univalence in the proof of function extensionality in \cref{sec:univalence-implies-funext}.
1089
+ \item Show that \qinv-univalence can be used instead of univalence in the proof of \cref{thm:qinv-notprop}.
1090
+ \item Show that \qinv-univalence is inconsistent (i.e.\ allows construction of an inhabitant of $\emptyt$).
1091
+ Thus, the use of a ``good'' version of $\isequiv$ is essential in the statement of univalence.
1092
+ \end{enumerate}
1093
+ \end{ex}
1094
+
1095
+ \begin{ex}\label{ex:embedding-cancellable}
1096
+ Show that a function $f:A\to B$ is an embedding if and only if the following two conditions hold:
1097
+ \begin{enumerate}
1098
+ \item $f$ is \emph{left cancellable}, i.e.\ for any $x,y:A$, if $f(x)=f(y)$ then $x=y$.\label{item:ex:ec1}
1099
+ \item For any $x:A$, the map $\apfunc f: \Omega(A,x) \to \Omega(B,f(x))$ is an equivalence.\label{item:ex:ec2}
1100
+ \end{enumerate}
1101
+ (In particular, if $A$ is a set, then $f$ is an embedding if and only if it is left-cancellable and $\Omega(B,f(x))$ is contractible for all $x:A$.)
1102
+ Give examples to show that neither of~\ref{item:ex:ec1} or~\ref{item:ex:ec2} implies the other.
1103
+ \end{ex}
1104
+
1105
+ \begin{ex}\label{ex:cancellable-from-bool}
1106
+ Show that the type of left-cancellable functions $\bool\to B$ (see \cref{ex:embedding-cancellable}) is equivalent to $\sm{x,y:B}(x\neq y)$.
1107
+ Give a similar explicit characterization of the type of embeddings $\bool\to B$.
1108
+ \end{ex}
1109
+
1110
+ \begin{ex}\label{ex:funext-from-nondep}
1111
+ The \textbf{na\"{i}ve non-dependent function extensionality axiom} says that for $A,B:\type$ and $f,g:A\to B$ there is a function $(\prd{x:A} f(x)=g(x)) \to (f=g)$.
1112
+ \indexdef{function extensionality!non-dependent}%
1113
+ Modify the argument of \cref{sec:univalence-implies-funext} to show that this axiom implies the full function extensionality axiom (\cref{axiom:funext}).
1114
+ \end{ex}
1115
+
1116
+ % Local Variables:
1117
+ % TeX-master: "hott-online"
1118
+ % End:
errata.tex ADDED
@@ -0,0 +1,987 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % This is the errata document for the homotopy type theory book.
2
+
3
+ % This file supports two book sizes:
4
+ % - Letter size (8.5" x 11")
5
+ % - US Trade size (6" x 9")
6
+ %
7
+ % To activate one or the other, uncomment the appropriate font size in
8
+ % the documentclass below, and then one of the two page geometry incantations
9
+ %
10
+ % NOTE: The 6" x 9" format is only experimental. It will break the
11
+ % title page, for example.
12
+
13
+ \PassOptionsToPackage{table}{xcolor}
14
+
15
+ % DOCUMENT CLASS
16
+ \documentclass[
17
+ %
18
+ %10pt % for US Trade 6" x 9" book
19
+ %
20
+ 11pt % for Letter size book
21
+ ]{article}
22
+ \usepackage{etex} % We're running out of registers and dimensions, or some such
23
+
24
+ \newcounter{chapter} % So that macros.tex doesn't choke
25
+
26
+ % PAGE GEOMETRY
27
+ %
28
+ % Uncomment one of these
29
+
30
+ % We make the page 40pt taller than the standard LaTeX book.
31
+
32
+ % OPTION 1: Letter
33
+ \usepackage[papersize={8.5in,11in},
34
+ twoside,
35
+ includehead,
36
+ top=1in,
37
+ bottom=1in,
38
+ inner=0.75in,
39
+ outer=1.0in,
40
+ bindingoffset=0.35in]{geometry}
41
+
42
+ % OPTION 2: US Trade
43
+ % \usepackage[papersize={6in,9in},
44
+ % twoside,
45
+ % includehead,
46
+ % top=0.75in,
47
+ % bottom=0.75in,
48
+ % inner=0.5in,
49
+ % outer=0.75in,
50
+ % bindingoffset=0.35in]{geometry}
51
+
52
+ % HYPERLINKING AND PDF METADATA
53
+
54
+ \usepackage[pagebackref,
55
+ colorlinks,
56
+ citecolor=darkgreen,
57
+ linkcolor=darkgreen,
58
+ unicode,
59
+ pdfauthor={Univalent Foundations Program},
60
+ pdftitle={Homotopy Type Theory: Univalent Foundations of Mathematics},
61
+ pdfsubject={Mathematics},
62
+ pdfkeywords={type theory, homotopy theory, univalence axiom}]{hyperref}
63
+
64
+ % OTHER PACKAGES
65
+
66
+ % Use this package and stick \layout somewhere in the text to see
67
+ % page margins, text size and width etc. Useful for debugging page format.
68
+ %\usepackage{layout}
69
+
70
+ %%% Because Germans have umlauts and Slavs have even stranger ways of mangling letters
71
+ \usepackage[utf8]{inputenc}
72
+
73
+ %%% For table {tab:theorems}
74
+ \usepackage{pifont}
75
+
76
+ %%% Multi-Columns for long lists of names
77
+ \usepackage{multicol}
78
+
79
+ %%% Set the fonts
80
+ \usepackage{mathpazo}
81
+ \usepackage[scaled=0.95]{helvet}
82
+ \usepackage{courier}
83
+ \linespread{1.05} % Palatino looks better with this
84
+
85
+ \usepackage{graphicx}
86
+ \DeclareGraphicsExtensions{.png}
87
+ \input{bmpsize-hack} % for bounding boxes in dvi mode
88
+ \usepackage{comment}
89
+
90
+ \usepackage{wallpaper} % For the background image on the cover page
91
+
92
+ \usepackage{fancyhdr} % To set headers and footers
93
+
94
+ \usepackage{nextpage} % So we can jump to odd-numbered pages
95
+
96
+ \usepackage{amssymb,amsmath,amsthm,stmaryrd,mathrsfs,wasysym}
97
+ \usepackage{enumitem,mathtools,xspace}
98
+ \usepackage{xcolor} % For colored cells in tables we need \cellcolor
99
+ \usepackage{booktabs} % For nice tables
100
+ \usepackage{array} % For nice tables
101
+ \usepackage{supertabular} % For index of symbols
102
+ \definecolor{darkgreen}{rgb}{0,0.45,0}
103
+ \usepackage{aliascnt}
104
+ \usepackage[capitalize]{cleveref}
105
+ \usepackage[all,2cell]{xy}
106
+ \UseAllTwocells
107
+ \usepackage{braket} % used for \setof{ ... } macro
108
+ \usepackage{tikz}
109
+ \usetikzlibrary{decorations.pathmorphing}
110
+
111
+ \usepackage{etoolbox} % hacking commands for TOC
112
+
113
+ \usepackage{mathpartir} % for formal.tex appendix, section 3
114
+
115
+ \usepackage[numbered]{bookmark} % add chapter/section numbers to the toc in the pdf metadata
116
+
117
+ \input{macros}
118
+
119
+ %%%% Indexing
120
+ \usepackage{makeidx}
121
+ \makeindex
122
+
123
+ %%%% Header and footers
124
+ \pagestyle{fancyplain}
125
+ \setlength{\headheight}{15pt}
126
+ \renewcommand{\sectionmark}[1]{\markright{\textsc{\thesection\ #1}}}
127
+
128
+ \lhead[\fancyplain{}{{\thepage}}]%
129
+ {\fancyplain{}{\nouppercase{\rightmark}}}
130
+ \rhead[\fancyplain{}{\nouppercase{\leftmark}}]%
131
+ {\fancyplain{}{\thepage}}
132
+ \cfoot[]{}
133
+ \lfoot[]{}
134
+ \rfoot[]{}
135
+
136
+ %%%% Chapter & part style
137
+ \usepackage{titlesec}
138
+ \titleformat{\part}[display]{\fontsize{40}{40}\fontseries{m}\fontshape{sc}\selectfont}{\hfil\partname\ \Roman{part}}{20pt}{\fontsize{60}{60}\fontseries{b}\fontshape{sc}\selectfont\hfil}
139
+ \titleformat{\chapter}[display]{\fontsize{23}{25}\fontseries{m}\fontshape{it}\selectfont}{\chaptertitlename\ \thechapter}{20pt}{\fontsize{35}{35}\fontseries{b}\fontshape{n}\selectfont}
140
+
141
+ \input{main.labels}
142
+ \input{version.tex}
143
+
144
+ \usepackage{longtable}
145
+
146
+ \title{Errata for the HoTT Book, first edition%
147
+ %% VERSION MARKER
148
+ }
149
+
150
+ \begin{document}
151
+ \maketitle
152
+
153
+ For the benefit of all readers, the available PDF and printed copies of the book are being updated on a rolling basis with minor corrections and clarifications as we receive them. Every copy has a version marker that can be found on the title page and is of the form "first-edition-XX-gYYYYYYY", where XX is a natural number and YYYYYYY is the git commit hash that uniquely identifies the exact version. Higher values of XX indicate more recent copies.
154
+
155
+ Below is a list of corrections and clarifications that have been made
156
+ %% BEGIN STARTPOINT
157
+ so far
158
+ %% END STARTPOINT
159
+ (except for trivial formatting and spacing changes), along with the version marker in which they were first made.
160
+ This list is current as of \today\ and version marker ``\OPTversion''.
161
+
162
+ While the page numbering may differ between copies with different version markers (and indeed, already differs between the letter/A4 and printed/ebook copies with the same version marker), we promise that the numbering of chapters, sections, theorems, and equations will remain constant, and no new mathematical content will be added, unless and until there is a second edition.
163
+
164
+ \noindent
165
+ \begin{longtable}{llp{10.5cm}}
166
+ \textbf{Location} & \textbf{Fixed in} & \textbf{Change} \\ \hline \endhead
167
+ %% BEGIN ERRATA
168
+ %
169
+ % Chapter 1
170
+ %
171
+ \cref{sec:types-vs-sets}
172
+ & 182-gb29ea2f
173
+ & Change notation $a\jdeq_A b$ to $a\jdeq b : A$, to match that used in \cref{cha:rules}.
174
+ (Neither are used anywhere else in the book.)\\
175
+ %
176
+ \cref{sec:types-vs-sets}
177
+ & 154-g42698c2
178
+ & Clarify that algorithmic decidability of judgmental equality is only meta-theoretic.\\
179
+ %
180
+ \cref{sec:types-vs-sets}
181
+ & 154-gac9b226
182
+ & Mention notation $a=b=c=d$ to mean ``$a=b$ and $b=c$ and $c=d$, hence $a=d$'', possibly including judgmental equalities.\\
183
+ %
184
+ \cref{sec:universes}
185
+ & 42-g4bc5cc2
186
+ & Cumulativity means some elements do not have unique types, the index $i$ on $\UU_i$ is not an internal natural number, and typical ambiguity must be justified by reinserting indices.\\
187
+ %
188
+ \cref{sec:universes,sec:pi-types}
189
+ & 42-ga34b313
190
+ & Explain that we can't define $\Fin$ and $\fmax$ yet where we first mention them.\\
191
+ %
192
+ \cref{sec:pi-types}
193
+ & 165-g0ad2aba
194
+ & Add $\mathsf{swap}$ as another example of a polymorphic function, and discuss the use of subscripts and implicit arguments to dependent functions.\\
195
+ %
196
+ \cref{rmk:introducing-new-concepts}
197
+ & 80-g8f95fa5
198
+ & In the discussion of formation rules, the dependent function type example should be $\prd{x:A} B(x)$.\\
199
+ %
200
+ \cref{sec:finite-product-types}
201
+ & 51-g67e86db
202
+ & Better explanation of recursion on product types, why it is justified, and how it relates to the uniqueness principle.\\
203
+ %
204
+ \cref{sec:sigma-types}
205
+ & 2-gbe277a8
206
+ & In the types of $g$ and $\ind{\sm{x:A}B(x)}$, there is a $\prd{a:A}{b:B(x)}$ in which $x$ should be $a$.\\
207
+ %
208
+ \cref{sec:sigma-types}
209
+ & 27-gd0bfa0d
210
+ & At two places in the definition of $\ac$, $R(a,\fst(g(x)))$ should be $R(x,\fst(g(x)))$.\\
211
+ %
212
+ \cref{sec:sigma-types}
213
+ & 125-g7fdadbf
214
+ & When substituting $\lam{x} \fst(g(x))$ for $f$ while verifying that $\ac$ is well-typed, the left side of the judgmental equality should be $\tprd{x:A} R(x,\fst(g(x)))$, not $\tprd{x:A} R(x,\fst(f(x)))$.\\
215
+ %
216
+ \cref{sec:coproduct-types}
217
+ & 30-g264d934
218
+ & In two displayed equations, $f(\inl(b))$ should be $f(\inr(b))$.\\
219
+ %
220
+ Theorem \ref{thm:allbool-trueorfalse} % NB: We have to write out "Theorem" instead of using \cref here, since in the (post-erratum) version this label no longer denotes a Theorem.
221
+ & 391-g1ce619a
222
+ & This should not be called a ``Theorem'', since we have not yet introduced what that means.
223
+ Instead it should say ``We construct an element of\dots''.\\
224
+ %
225
+ \cref{sec:type-booleans}
226
+ & 125-g433f87e
227
+ & In the definition of binary products in terms of $\bool$, the definitions of $\fst(p)$ and $\snd(p)$ should be switched to match the order of arguments to $\rec\bool$ and $\ind\bool$.\\
228
+ \cref{sec:pat}
229
+ & 111-g1e868fa
230
+ & When translating English to type theory, ``unnamed variables'' are unnamed in English but must be named in type theory.\\
231
+ %
232
+ \cref{sec:identity-types}
233
+ & 154-g4ef49f7
234
+ & Emphasize that path induction, like all other induction principles, defines a \emph{specified} function.\\
235
+ %
236
+ \cref{sec:identity-types}
237
+ & 1373-g142de42
238
+ & In the second proof that based path induction implies path induction, the observation should be that $f$ can be obtained as an instance of $\indid{A}$, not $\indidb{A}$.\\
239
+ %
240
+ \cref{sec:identity-types}
241
+ & 244-gd58529d
242
+ & In proof that path induction implies based path induction, $D(x,y,p)$ should be written $\prd{C : \prd{z:A} (\id[A]{x}{z}) \to \UU} \left( \cdots \right)$ so the type of $C$ matches the premise of based path induction. \\
243
+ %
244
+ \cref{rmk:the-only-path-is-refl}
245
+ & 563-g3286941
246
+ & The facts that any $(x,y,p): \sm{x,y:A}(\id{x}{y})$ is equal to $(x,x,\refl{x})$, and that any $(y,p):\sm{y:A}(\id[A]{a}{y})$ is equal to $(a,\refl{a})$, can be proven by path induction and based path induction respectively.\\
247
+ %
248
+ \cref{ex:iterator}
249
+ & 78-gcce4dc0
250
+ & The second defining equation of $\ite$ should have right-hand side $c_s(\ite(C,c_0,c_s,n))$.\\
251
+ %
252
+ \cref{ex:iterator}
253
+ & 293-g4663bfe
254
+ & The defining equations of the recursor derived from the iterator only hold propositionally, and require the induction principle to prove.\\
255
+ %
256
+ \cref{ex:prod-via-bool}
257
+ & 229-ged891f3
258
+ & This exercise requires function extensionality (\cref{sec:compute-pi}).\\
259
+ %
260
+ \cref{ex:nat-semiring}
261
+ & 450-g7f38c9a
262
+ & This exercise requires symmetry and transitivity of equality, \cref{lem:opp,lem:concat}.\\
263
+ %
264
+ \cref{ex:ackermann}
265
+ & 110-gfe4641b
266
+ & To match the usual Ackermann--P\'eter function, the second displayed equation should be $\ack(\suc(m),0) \jdeq \ack(m,1)$.\\
267
+ %
268
+ % Chapter 2
269
+ %
270
+ \cref{cha:basics}
271
+ & 239-gaf3d682
272
+ & In the chapter introduction, clarify that topological homotopies between paths must be endpoint-preserving.\\
273
+ %
274
+ \cref{lem:opp}
275
+ & 166-g37b78ef
276
+ & Add remarks before and after the proof about how a theorem's statement and proof should be interpreted as exhibiting an element of some type.\\
277
+ %
278
+ \cref{lem:concat}
279
+ & 374-g0bc0908
280
+ & In the penultimate display in the first proof, $d(x,z,q)$ should be simply $d$.\\
281
+ %
282
+ \cref{thm:omg}
283
+ & 750-g91b7348
284
+ & In the first proofs of~\ref{item:omg1}--\ref{item:omg3}, $\indid{A}(D,d,p)$ should be $\indid{A}(D,d,x,y,p)$.\\
285
+ %
286
+ \cref{sec:equality}
287
+ & 435-gee0b28a
288
+ & In the third paragraph after \cref{lem:concat}, $p\ct\refl{x}\jdeq p$ should be $p\ct\refl{y}\jdeq p$.\\
289
+ %
290
+ \cref{sec:equality}
291
+ & 165-g18642ca
292
+ & Mention that the notation $a=b=c=d$, and its displayed variant, indicate concatenation of paths.\\
293
+ %
294
+ \cref{sec:equality}
295
+ & 253-gdd47c75
296
+ & \cref{thm:omg}\ref{item:omg4} justifies writing $p\ct q \ct r$ and so on.\\
297
+ %
298
+ \cref{thm:EckmannHilton}
299
+ & 253-gdd47c75
300
+ & The induction defining $\alpha\rightwhisker r$ has defining equation $\alpha \rightwhisker \refl{b} \jdeq \opp{\mathsf{ru}_p} \ct \alpha \ct \mathsf{ru}_q$, with $\mathsf{ru}_p$ the right unit law.
301
+ For $\alpha\hct\beta = \alpha\ct\beta$ to be well-typed, we assume $p\jdeq q \jdeq r \jdeq s\jdeq \refl{a}$ and use $\mathsf{ru}_{\refl{a}} = \refl{\refl{a}}$ and its dual.
302
+ Proving $\alpha\hct\beta = \alpha\hct'\beta$ requires induction not only on $\alpha$ and $\beta$ but then on the two remaining 1-paths.
303
+ After the proof, remark that we trust the reader to construct such operations from now on.\\
304
+ %
305
+ \cref{def:loopspace}
306
+ & 233-gc3fb777
307
+ & The three displays should be $\defeq$'s rather than $=$'s.\\
308
+ %
309
+ \cref{sec:functors}
310
+ & 336-g8ff8a7f
311
+ & In the type of $\apfunc{f}$ towards the end of the first proof of \cref{lem:map}, $g(x)$ should be $f(y)$.\\
312
+ %
313
+ \cref{sec:fibrations}
314
+ & 154-g4ef49f7
315
+ & Emphasize that unlike fibrations in classical homotopy theory, type families come with a \emph{specified} path-lifting function.\\
316
+ %
317
+ \cref{sec:fibrations}
318
+ & 343-g6efd724
319
+ & The functions \cref{eq:ap-to-apd} and \cref{eq:apd-to-ap} are obtained by concatenating with $\transconst Bp{f(x)}$ and its inverse, respectively.\\
320
+ %
321
+ \cref{cor:hom-fg}
322
+ & 253-gdd47c75
323
+ & Canceling $H(x)$ may be done by whiskering with $\opp{(H(x))}$.\\
324
+ %
325
+ \cref{sec:basics-equivalences}
326
+ & 1171-gab3c0aa
327
+ & In the proof that $\isequiv(f) \to \qinv (f)$, the definition of $\gamma$ should be $\gamma(x) \defeq \opp{\beta(g(x))} \ct \ap{h}{\alpha(x)}$.\\
328
+ %
329
+ \cref{sec:compute-cartprod}
330
+ & 74-g9896e32
331
+ & In the type of $\pairpath$ (just after the proof of \cref{thm:path-prod}), the second factor in the domain should be $\id{\proj{2}(x)}{\proj{2}(y)}$.\\
332
+ %
333
+ \cref{sec:compute-cartprod}
334
+ & 895-g96db894
335
+ & In the displayed equation just before \cref{thm:trans-prod}, $\pairct(p\ct q, r, p'\ct q', r)$ should be $\pairct(p\ct q, r, p'\ct q', r')$ and $\pairct(p, q\ct r, p', q'\ct r)$ should be $\pairct(p, q\ct r, p', q'\ct r')$ (two primes on $r$s are missing).\\
336
+ %
337
+ \cref{thm:trans-prod}
338
+ & 349-gc7fd9d8
339
+ & The path is in $A(w)\times B(w)$, not $A(y)\times B(y)$.\\
340
+ %
341
+ \cref{thm:trans-prod}
342
+ & 76-ga42354c
343
+ & The third displayed judgmental equality in the proof should be $\transfib{B}{p}{\proj{2}x} \jdeq \proj2x$.\\
344
+ %
345
+ \cref{thm:path-sigma}
346
+ & 507-g8f10eda
347
+ & In the proof, the equation $f(g(\refl{},\refl{}))=\refl{}$ should be $f (g(\refl{w_1},\refl{w_2})) = (\refl{w_1},\refl{w_2})$.\\
348
+ %
349
+ \cref{sec:compute-pi}
350
+ & 269-g3880fe2
351
+ & The paragraph preceding the definition of $\transfib{\Pi_A(B)}{p}{f}$ (before \cref{eq:transport-arrow-families}) misstated the (already given) type of $p$.\\
352
+ %
353
+ \cref{axiom:univalence}
354
+ & 992-gc4a5314
355
+ & The axiom should read ``For any $A,B:\type$, the function~\eqref{eq:uidtoeqv} is an equivalence. The display $\eqv{(\id[\type]{A}{B})}{(\eqv A B)}$ should be deduced afterwards, outside the axiom statement.\\
356
+ %
357
+ \cref{thm:paths-respects-equiv}
358
+ & 310-gd5fa240
359
+ & The second half of the proof is more involved than the first.
360
+ It follows abstractly using the 2-out-of-6 property (\cref{ex:2-out-of-6}), or more concretely by concatenating with $\opp{\alpha_{f(a)}} \ct {\alpha_{f(a)}}$ on each side and then repeatedly using naturality and functoriality.\\
361
+ %
362
+ \cref{sec:compute-paths}
363
+ & 236-g32be999
364
+ & The second display after the proof of \cref{thm:paths-respects-equiv} should be $\prd{x:A} (\id[f(x)=g(x)] {\happly(p)(x)}{\happly(q)(x)})$.\\
365
+ %
366
+ \cref{thm:transport-path}
367
+ & 628-g1bd8602
368
+ & The sentence preceding the theorem suggests that it follows from \cref{cor:transport-path-prepost,thm:transport-compose}, but actually it requires a separate path induction.\\
369
+ %
370
+ \cref{thm:transport-path}
371
+ & 704-g70c069e
372
+ & The sentence after the theorem should say that $\apfunc{(x \mapsto c)}$ is $p \mapsto\refl{c}$, not $\refl{c}$.\\
373
+ %
374
+ \cref{thm:transport-path2}
375
+ & 364-g3c47534
376
+ & The right-hand side of the displayed equality should be $\opp{(\apdfunc{f}(p))} \ct \apfunc{(\transfibf{B}{p})}(q) \ct \apdfunc{g}(p)$.\\
377
+ %
378
+ \cref{sec:compute-coprod}
379
+ & 101-g645f763
380
+ & In \cref{thm:path-coprod} and the preceding paragraph, in the equivalence $\eqv{(\inl(a)=x)}{\code(x)}$, the variable $a$ should be $a_0$. \\
381
+ %
382
+ \cref{sec:compute-coprod}
383
+ & 370-g114db82
384
+ & In the two displays after the proof of \cref{thm:path-coprod}, the terms should be $\encode(\inl(a), {\blank})$ and $\encode(\inr(b), {\blank})$.\\
385
+ %
386
+ \cref{sec:equality-semigroups}
387
+ & 261-g4ccda0a
388
+ & In the first displayed pair of equations, the type of $p_2$ should be $\transfib{\semigroupstrsym}{p_1}{(m,a)} = {(m',a')}$.\\
389
+ %
390
+ \cref{sec:equality-semigroups}
391
+ & 402-g2297ecb
392
+ & The right hand side of the last displayed equation should be $m'(e(x_1),e(x_2))$.\\
393
+ %
394
+ \cref{sec:universal-properties}
395
+ & 305-g64685f1
396
+ & In the discussion of universal properties for product types and $\Sigma$-types surrounding \cref{eq:sigma-lump}, the phrases ``left-to-right'' and ``right-to-left'' should be switched.\\
397
+ %
398
+ \cref{cha:basics} Notes
399
+ & 379-ga57eab2
400
+ & It should be mentioned that Hofmann and Streicher (1998) proposed an axiom similar to univalence, which is correct (and equivalent to univalence) for a universe of 1-types.\\
401
+ %
402
+ % Chapter 3
403
+ %
404
+ \cref{eq:english-ac}
405
+ & 1193-g54b20e3
406
+ & The domain of $g:\prd{x:A} A(x)$ should be $X$.\\
407
+ %
408
+ \cref{subsec:prop-subsets}
409
+ & 86-g39feab1
410
+ & The definition of subset containment should say $\prd{x:A}(P(x)\rightarrow Q(x))$, not $\fall{x:A}(P(x)\Rightarrow Q(x))$, as the latter notation has not been introduced yet.\\
411
+ %
412
+ \cref{subsec:logic-hprop}
413
+ & 37-g0bd66c8
414
+ & In the discussion for $\Sigma$-types in the last paragraph, $A$ is an arbitrary type.\\
415
+ %
416
+ \cref{thm:retract-contr}
417
+ & 95-gce0131f
418
+ & In the proof, $p$ should be $r$ to match the preceding definition of retraction.\\
419
+ %
420
+ \cref{ex:lem-brck}
421
+ & 1162-ga97cb70
422
+ & Should be to show that $\neg\neg A$ satisfies the recursion principle of $\brck{A}$ but with only a propositional computation rule.\\
423
+ %
424
+ % Chapter 4
425
+ %
426
+ \cref{lem:qinv-autohtpy}
427
+ & 87-g693e9b9
428
+ & At the end of the proof, \cref{thm:contr-paths} should be cited as the reason why $\sm{g:A\to A} (g = \idfunc[A])$ is contractible.\\
429
+ %
430
+ \cref{thm:equiv-iso-adj}
431
+ & 275-g8ea9f71
432
+ & In the proof, the path concatenations in the definitions of $\epsilon'$ and $\tau$ were written in reverse order.\\
433
+ %
434
+ \cref{thm:equiv-iso-adj}
435
+ & 1043-gcfce4d7
436
+ & In the proof, the type of $\tau(a)$ should be $\ap{f}{\eta(a)}=\opp{\epsilon(f(g(f(a))))}\ct (\ap{f}{\eta(g(f(a)))}\ct \epsilon(f(a)))$, instead of $\opp{\epsilon(f(g(f(a))))}\ct (\ap{f}{\eta(g(f(a)))}\ct \epsilon(f(a)))=\ap{f}{\eta(a)}$.\\
437
+ %
438
+ \cref{lem:coh-hprop}
439
+ & 296-ge3dc076
440
+ & In the proof, $\id[\hfib{f}{fx}]{(fgx,\epsilon(fx))}{(x,\refl{fx})}$ should be $\id[\hfib{f}{fx}]{(gfx,\epsilon(fx))}{(x,\refl{fx})}$.\\
441
+ %
442
+ \cref{thm:equiv-biinv-isequiv}
443
+ & 272-gfd47093
444
+ & At the end of the proof, the equivalence follows from the fact that $\ishae(f)$, not $\iscontr(f)$, is a mere proposition. \\
445
+ %
446
+ \cref{thm:lequiv-contr-hae}
447
+ & 299-g85b729b
448
+ & In the proof, $\lcoh{f}{g}{\epsilon}$ should be $\rcoh{f}{g}{\epsilon}$, and the final displayed equation should have $\proj{2}$ applied to both occurrences of $P(fx)$.\\
449
+ %
450
+ \cref{lem:func_retract_to_fiber_retract}
451
+ & 265-g64000fb
452
+ & The path concatenations in the definitions of $\varphi_b$ and $\psi_b$ (and subsequent equations) are reversed, and each $f(a)$ in the next two displayed equations should be $g(a)$.\\
453
+ %
454
+ \cref{fibwise-fiber-total-fiber-equiv}
455
+ & 275-g84ab032
456
+ & The first equivalence in the proof is not by~\eqref{eq:sigma-lump} but by \cref{ex:sigma-assoc}.\\
457
+ %
458
+ \cref{fibwise-fiber-total-fiber-equiv}
459
+ & 202-g775a3f0
460
+ & The last equivalence in the proof is not by~\eqref{eq:path-lump} but by \cref{thm:omit-contr,thm:contr-paths,ex:sigma-assoc}.\\
461
+ %
462
+ \cref{thm:nobject-classifier-appetizer}
463
+ & 205-gf9fe386
464
+ & In the proof, $e\cdot \proj1$ should be $\trans{(\ua(e))}{\proj1}$. Also, explain its computation better.\\
465
+ %
466
+ \cref{sec:univalence-implies-funext}
467
+ & 114-gaba76c8
468
+ & The point of \cref{UA-eqv-hom-eqv} is that it follows from univalence without assuming function extensionality separately.\\
469
+ %
470
+ \cref{contrfamtotalpostcompequiv}
471
+ & 484-g2ce1249
472
+ & In the statement, ``precomposition'' should be ``post-composition''.\\
473
+ %
474
+ \cref{uatowfe}
475
+ & 746-g4d540d6
476
+ & In the definition of $\psi$ in the proof, transport has to be along $\happly(p,x)$ instead of along $p$.\\
477
+ %
478
+ \cref{ex:symmetric-equiv}
479
+ & 358-g9543064
480
+ & The text should be ``Show that for any $A,B:\UU$, the following type is equivalent to $\eqv A B$. Can you extract from this a definition of a type satisfying the three desiderata of $\isequiv(f)$?''\\
481
+ %
482
+ \cref{thm:object-classifier}
483
+ & 44-g14eb86b
484
+ & To maintain consistency, one line was added at the end of the computation of the composite equivalence in the proof.\\
485
+ %
486
+ \cref{thm:fiber-of-a-fibration}
487
+ & 44-g14eb86b
488
+ & The type of $\proj{1}$ should be $(\sm{x:A}P(x))\to A$.\\
489
+ %
490
+ % Chapter 5
491
+ %
492
+ \cref{sec:appetizer-univalence}
493
+ & 706-ged2c765
494
+ & In the proof that $\eqv{\nat}{\natp}$, the definitions of $f$ and $g$ should be $\rec\nat(\natp, \; \zerop, \; \lamu{n:\nat} \sucp)$ and $\rec\natp(\nat, \; 0, \; \lamu{n:\natp} \suc)$ respectively.\\
495
+ %
496
+ \cref{sec:w-types}
497
+ & 125-g433f87e
498
+ & In the definition of $\natw$, use $\bfalse$ for $0$ and $\btrue$ for $\suc$, to match the ordering of $\bfalse$ and $\btrue$ in \cref{sec:type-booleans}.\\
499
+ %
500
+ \cref{sec:w-types}
501
+ & 551-g82b74bf
502
+ & The definitions of $\natw$ and $\lst A$ as $\w$-types should be $\wtype{b:\bool} \rec\bool(\bbU,\emptyt,\unit,b)$ and $\wtype{x: \unit + A} \rec{\unit + A}(\bbU, \emptyt, \lamu{a:A} \unit, x)$.\\
503
+ %
504
+ \cref{sec:w-types}
505
+ & 218-g42219cb
506
+ & In the description of the constructor $\supp$, its second argument is more clearly written as $f : B(a) \to \wtype{x:A} B(x)$.\\
507
+ %
508
+ \cref{sec:w-types}
509
+ & 525-gb1957b8
510
+ & In the computation rule, the recursive call to $\rec{}$ is missing an argument.
511
+ It should read $\rec{\wtype{x:A} B(x)}(E,e,\supp(a,f)) \jdeq e(a,f,\big(\lamu{b:B(a)} \rec{\wtype{x:A} B(x)}(E,e,f(b))\big))$.\\
512
+ %
513
+ \cref{sec:w-types}
514
+ & 570-g6ec04c3
515
+ & In the verification that $\dbl$ computes as expected, $e_t$ should be $e_0$ and $e_f$ should be $e_1$.\\
516
+ %
517
+ \cref{sec:initial-alg}
518
+ & 554-g9b2a34b
519
+ & The definition of the type of $\w$-homomorphisms (just before \cref{thm:w-hinit}) should read $\whom_{A,B}((C, s_C),(D,s_D)) \defeq \sm{f : C \to D} \prd{a:A}{h:B(a)\to C} \id{f(s_C(a,h))}{s_D(a, f\circ h)}$.\\
520
+ %
521
+ \cref{sec:htpy-inductive}
522
+ & 917-gd6960ad
523
+ & In the first paragraph, the definition of $\natw$ should be $\wtype{b:\bool} \rec\bool(\bbU,\emptyt,\unit,b)$.\\
524
+ %
525
+ \cref{sec:htpy-inductive}
526
+ & 608-g6af101f
527
+ & In the computation rule for homotopy $\w$-types, the left-hand side should be $\rec{\wtypeh{x:A} B(x)}(E,e,\supp(a,f))$.\\
528
+ %
529
+ \cref{sec:htpy-inductive}
530
+ & 1261-g4cdab82
531
+ & In the commutative diagram preceding the definition of $\w_s(A, B)$, all occurrences of $x$ should be replaced with $a$.\\
532
+ %
533
+ \cref{sec:htpy-inductive}
534
+ & 1261-g4cdab82
535
+ & In the definition of $\w_s(A,B)$, $\alpha(\supp(x,f))$ should be $\alpha(\supp(a,f))$, and $\prd{a,f}$ should be inserted after $\sm\alpha$.\\
536
+ %
537
+ \cref{eq:example-comp}
538
+ & 912-g04d3fb6
539
+ & In the preceding sentence, $\delta:d$ should be $\delta:D$.\\
540
+ %
541
+ \cref{sec:generalizations}
542
+ & 908-g4b2eb10
543
+ & The second two constructors of $\mathsf{paritynat}$ should be $\mathsf{esucc} : \mathsf{paritynat}(\btrue) \to \mathsf{paritynat}(\bfalse)$ and $\mathsf{osucc} : \mathsf{paritynat}(\bfalse) \to \mathsf{paritynat}(\btrue)$.\\
544
+ %
545
+ \cref{thm:identity-systems}
546
+ & 139-gd5c5d01
547
+ & In the proof of \ref{item:identity-systems4}$\Rightarrow$\ref{item:identity-systems1}, the type of $D'$ should be $(\sm{b:A} R(b)) \to \type$.\\
548
+ %
549
+ \cref{ex:same-recurrence-not-defeq}
550
+ & 622-ga0bd007
551
+ & The two functions should satisfy the same recurrence judgmentally.\\
552
+ %
553
+ \cref{ex:one-function-two-recurrences}
554
+ & 622-ga0bd007
555
+ & The function should satisfy both recurrences judgmentally.\\
556
+ %
557
+ \cref{sec:identity-systems}
558
+ & 171-gdc4966e
559
+ & The subscript of $\refl A : a=_A a$ should be $a$, i.e. $\refl a$.\\
560
+ %
561
+ % Chapter 6
562
+ %
563
+ \cref{sec:dependent-paths}
564
+ & 54-gd4a47c2
565
+ & Soon after \cref{rmk:defid}, the phrase ``An element $b:P(\base)$ in the fiber over the constructor $\base:\nat$'' should say $\base:\Sn^1$.\\
566
+ %
567
+ \cref{thm:uniqueness-for-functions-on-S1}
568
+ & 423-gf763ae1
569
+ & \cref{thm:transport-path,thm:dpath-path} are needed to put $q$ in the form required by the induction principle.\\
570
+ %
571
+ \cref{thm:interval-funext}
572
+ & 417-g4aa6a15
573
+ & Added \cref{ex:funext-from-interval}: the function constructed in \cref{thm:interval-funext} is actually an inverse to $\happly$, so that the full function extensionality axiom follows from an interval type.\\
574
+ %
575
+ \cref{thm:S1-autohtpy}
576
+ & 625-g950efa9
577
+ & In the second paragraph of the proof, the appeal to function extensionality should be omitted.\\
578
+ %
579
+ \cref{sec:circle}
580
+ & 327-g7cbe31c
581
+ & In the first sentence after the proof of \cref{thm:apd2}, ``$P:\Sn^2\to P$'' should be ``$P:\Sn^2\to\type$''.\\
582
+ %
583
+ \cref{sec:circle}
584
+ & 1039-g30da4c6
585
+ & In the sentence after the proof of \cref{thm:apd2}, the type family in which $s$ is a dependent path should be $\lam{p} \dpath P p b b$ instead of $P$.\\
586
+ %
587
+ \cref{sec:cell-complexes}
588
+ & 289-gdefeb8c
589
+ & In the induction principle for the torus, the types of $p'$ and $q'$ should be $\dpath P p {b'} {b'}$ and $\dpath P q b b$ respectively.\\
590
+ %
591
+ \cref{sec:hubs-spokes}
592
+ & 289-gdefeb8c
593
+ & In the induction principle for the torus, the types of $p'$ and $q'$ should be $\dpath P p {b'} {b'}$ and $\dpath P q b b$ respectively.\\
594
+ %
595
+ \cref{sec:hittruncations}
596
+ & 468-g5472874
597
+ & The induction principle for $\brck{A}$ should conclude $f(\bproj a)\jdeq g(a)$, not $f(\bproj a)\jdeq a$. And in the hypotheses of the induction principle for $\trunc0 A$ and in the proof of \cref{thm:trunc0-ind}, $v:\dpath{B}{u(x,y,p,q)}{p}{q}$ should instead be $v:\dpath{B}{u(x,y,p,q)}{r}{s}$.\\
598
+ %
599
+ \cref{sec:hittruncations}
600
+ & 860-gc7d862c
601
+ & In the penultimate paragraph, the ``unobjectionable'' constructor for $\trunc0 A$ should begin ``For every $f:S\to \trunc0 A$'', not ``For every $f:S\to A$''.\\
602
+ %
603
+ \cref{thm:quotient-ump}
604
+ & 961-gde36592
605
+ & The first sentence of the second paragraph of the proof should end with $g(x) = \overline{g\circ q}(x)$.\\
606
+ %
607
+ \cref{lem:quotient-when-canonical-representatives}
608
+ & 514-g18ade45
609
+ & Instead of ``is the set-quotient of $A$ by $\eqr$'', the statement should say ``satisfies the universal property of the set-quotient of $A$ by~$\eqr$, and hence is equivalent to it''.
610
+ In the proof, the second displayed equation should be $e'(g, s) (x,p) \defeq g(x)$.
611
+ The fourth displayed equation should be $e(e'(g, s)) \jdeq e(g \circ \proj{1}) \jdeq (g \circ \proj{1} \circ q, {\nameless})$, the fifth should be $g(\proj{1}(q(x))) \jdeq g(r(x)) = g(x)$, and the proof should conclude with ``$g$ respects $\eqr$ by the assumption $s$''.\\
612
+ %
613
+ \cref{thm:sign-induction}
614
+ & 535-g0a9abfe
615
+ & The ``computation rules'' satisfied by $f$ are only propositional equalities.
616
+ Also, the proof requires transport across a few unmentioned equivalences.\\
617
+ %
618
+ \cref{thm:looptothe}
619
+ & 535-g0a9abfe
620
+ & The defining clauses should use $\defid$ rather than $\defeq$ (see the erratum for \cref{thm:sign-induction}).
621
+ Also, the first clause should say $\refl{a}$ rather than $\refl{\base}$.\\
622
+ %
623
+ \cref{thm:transport-is-given}
624
+ & 682-g3af5dbe
625
+ & Three occurrences of $P$ in the statement should be $B$.\\
626
+ %
627
+ \cref{thm:flattening-cp}
628
+ & 457-g411ec6d
629
+ & The right-hand side of the displayed equation in the proof should be $(\cc(g(b)),D(b)(y))$.\\
630
+ %
631
+ \cref{thm:flattening-cp}
632
+ & 961-gde36592
633
+ & After the display we should have $\pp(b):\cc(f(b))=\cc(g(b))$.\\
634
+ %
635
+ \cref{sec:flattening}
636
+ & 519-gc99a54c
637
+ & $f$ denotes a map $B\to A$ in this section and should not be re-used for functions defined by induction on $\sm{w:W} P(w)$; we may use $k$ instead.
638
+ Thus $f$ should be $k$ in the last sentence of \cref{thm:flattening-rect}; the first sentence of its proof; the second and third sentences of the paragraph after its proof; the last sentence of \cref{thm:flattening-rectnd}; the first, second, and last sentences of its proof; throughout the statement and proof of \cref{thm:ap-sigma-rect-path-pair}; the statement of \cref{thm:flattening-rectnd-beta-ppt}; and the second sentence of its proof.\\
639
+ %
640
+ \cref{thm:flattening-rect}
641
+ & 537-gdf3b51d
642
+ & In the display after the definition of $q$, the transport in the first line should be with respect to $x\mapsto Q(\cct'(g(b),x))$, and in the second line the subscript of $\apfunc{}$ should be $x\mapsto \cct'(g(b),x)$.\\
643
+ %
644
+ \cref{thm:flattening-rect}
645
+ & 961-gde36592
646
+ & The subscript of $\apfunc{}$ should also be $x\mapsto \cct'(g(b),x)$ in the third, fourth, and fifth displays.
647
+ In the fourth and fifth displays, the path-concatenations should be in the other order.
648
+ And in the fifth display, $\refl{g(b)}$ should be $\refl{\cc(g(b))}$.\\
649
+ %
650
+ \cref{thm:flattening-rectnd-beta-ppt}
651
+ & 961-gde36592
652
+ & Both occurrence of the function $f$ should be replaced with $g$ in the
653
+ final two steps of the calculation within the proof.\\
654
+ %
655
+ \cref{thm:ap-sigma-rect-path-pair}
656
+ & 501-ge895f81
657
+ & Both occurrences of $P$ in the statement should be $Y$, and both occurrences of $Q$ in the proof should be $Z$.\\
658
+ %
659
+ % Chapter 7
660
+ %
661
+ \cref{thm:h-level-retracts}
662
+ & 180-gb672a4d
663
+ & In the last displayed equation of the proof, $q$ should be $r$.\\
664
+ %
665
+ \cref{thm:isaprop-isofhlevel}
666
+ & 101-g713f48c
667
+ & The base case in the proof is just \cref{thm:isprop-iscontr}.\\
668
+ %
669
+ \cref{sec:truncations}
670
+ & 480-gdc84050
671
+ & The third paragraph is wrong: in contrast to \cref{rmk:spokes-no-hub}, it \emph{would} actually work to define $\trunc nA$ omitting the hub point.\\
672
+ %
673
+ \cref{thm:h-set-refrel-in-paths-sets}
674
+ & 1131-gc1748fa
675
+ & In the second paragraph of the first proof, the codomain of the function $f(x,x)$ should be $\id[X]xx$, not $\id[X]xy$.\\
676
+ %
677
+ \cref{lem:hedberg-helper}
678
+ & 644-g627c0a8
679
+ & In the proof of the lemma, ``If $x$ is $\inr(f)$'' should be ``If $x$ is $\inr(t)$''.\\
680
+ %
681
+ \cref{thm:path-truncation}
682
+ & 412-gb9582fc
683
+ & In the proof, \encode and \decode should be switched.\\
684
+ %
685
+ \cref{lem:nconnected_postcomp_variation}
686
+ & 801-g01922a8
687
+ & The converse direction is false unless $Q$ is fiberwise merely inhabited. Also, the occurrences of $\ap f p$ and $\ap f {\proj 2 w}$ in the proof should be just $p$ and $\proj 2 w$, respectively.\\
688
+ %
689
+ \cref{lem:connected-map-equiv-truncation}
690
+ & 367-g1c8c07e
691
+ & In the proof that the first composite is the identity, all occurrences of $y$ should be $f(x)$.\\
692
+ %
693
+ \cref{thm:modal-char}
694
+ & 658-g016f3a4
695
+ & In the second paragraph of the proof, the first two occurrences of $\proj2$ (but not the third) should be $\proj1$.\\
696
+ %
697
+ \cref{ex:s2-colim-unit}
698
+ & 101-ga366be2
699
+ & ``entires'' should be ``entirely''.\\
700
+ %
701
+ \cref{ex:s2-colim-unit}
702
+ & 683-g8941e50
703
+ & This exercise needs more precise definitions of ``diagram'' and ``colimit''.\\
704
+ %
705
+ \cref{ex:acnm}
706
+ & 1074-gcd42187
707
+ & $\choice{\infty,\infty}$ is not \cref{thm:ttac}, but the identity function.\\
708
+ %
709
+ \cref{ex:acnm}
710
+ & 603-ge113e08
711
+ & The penultimate sentence should ask ``Is $\choice{n,m}$ consistent with univalence for any $m\ge 0$ and any $n$?''.\\
712
+ %
713
+ % Chapter 8
714
+ %
715
+ \cref{lem:s1-encode-decode}
716
+ & 535-g0a9abfe
717
+ & The proof by induction on $n:\Z$ is justified by \cref{thm:sign-induction}, not \cref{thm:looptothe}.\\
718
+ %
719
+ \cref{thm:iscontr-s1cover}
720
+ & 535-g0a9abfe
721
+ & The clauses defining $q_z$ should use $\defid$ rather than $\defeq$ (see the erratum for \cref{thm:sign-induction}).\\
722
+ %
723
+ \cref{thm:suspension-increases-connectedness}
724
+ & 1062-gf3bfeae
725
+ & In the proof, $E$ is not $(n + 1)$-connected but $(n + 1)$-truncated.\\
726
+ %
727
+ \cref{thm:fiber-of-the-fiber}
728
+ & 1181-g3e51973
729
+ & In the proof, $(x:A)$ should be $(x:X)$.\\
730
+ %
731
+ \cref{thm:les}
732
+ & 33-g628d81b
733
+ & In the proof, $\trunc0g\circ\trunc0f$ should be $\trunc0f\circ\trunc0g$, and similarly for $g\circ f$.
734
+ Also, $g(t)=w'$ should be $\tproj0{g(t)}=w'$.
735
+ Finally, $\tproj0{(w,p)}:\tproj0{\hfib{f}{z_0}}$ should be $\tproj0{(w,p)}:\trunc{0}{\hfib{f}{z_0}}$.\\
736
+ %
737
+ \cref{thm:conn-pik}
738
+ & 1023-gf188aeb
739
+ & The proof requires a separate argument for $k=0$.\\
740
+ %
741
+ \cref{thm:hopf-fibration}
742
+ & 256-g9e6fcb8
743
+ & The phrase ``whose fibers are $\Sn^1$'' should be ``whose fiber over the basepoint is $\Sn ^1$''.
744
+ The same change should be made in \cref{ex:HopfJr,ex:SuperHopf}.\\
745
+ %
746
+ \cref{lem:fibration-over-pushout}
747
+ & 1062-gf3bfeae
748
+ & In the definition of ${E^{\mathrm{tot}}}'$ in the proof, $e_C$ should be $e_X$.\\
749
+ %
750
+ \cref{thm:conn-trunc-variable-ind}
751
+ & 396-g868335b
752
+ & In the proof, the function $k$ should have type $\prd{a:A} P(f(a))$.
753
+ It should also be named $\ell$, to avoid confusion with the integer $k$.\\
754
+ %
755
+ \cref{thm:freudcode}
756
+ & 87-g3f977b2
757
+ & In the second displayed equation in the proof, $\merid(x_1)$ should be $\opp{\merid(x_1)}$.\\
758
+ %
759
+ \cref{thm:wedge-connectivity}
760
+ & 1203-g7464bf1
761
+ & The type family $P$ defined in the proof should instead be called $Q$, to avoid clashes with the type family $P$ assumed in the statement.\\
762
+ %
763
+ \cref{thm:wedge-connectivity}
764
+ & 399-g8897c94
765
+ & In the last sentence of the proof, ``$(n-1)$-connected'' should be ``$(n-1)$-truncated''.\\
766
+ %
767
+ \cref{thm:freudlemma}
768
+ & 88-g0c0be67
769
+ & The type of $m$ should be $a_1=a_2$, the second display should begin with $C(a_1,\transfib{B}{\opp m}{b})$, and the proof should say ``we may assume $a_2$ is $a_1$ and $m$ is $\refl{a_1}$''.\\
770
+ %
771
+ \cref{sec:freudenthal}
772
+ & 165-gd5584c6
773
+ & In~\eqref{eq:freudcompute1}, $r''$ should be $r'$, the end point of $r$ should be $\transfib{B}{\opp{\merid(x_0)}}{q}$, and obtaining $r'$ requires also identifying this with $q \ct \opp{\merid(x_0)}$.
774
+ Similarly, in~\eqref{eq:freudcompute2}, the end point of $r$ should be $\transfib{B}{\opp{\merid(x_1)}}{q}$.\\
775
+ %
776
+ \cref{sec:freudenthal}
777
+ & 474-g5289470
778
+ & $\pi_3(\Sn^2)=\Z$ should be stated as \cref{thm:pi3s2}, following from \cref{cor:pis2-hopf,thm:pinsn}.\\
779
+ %
780
+ \cref{thm:whiteheadn}
781
+ & 1092-ge3b8b71
782
+ & After applying the induction hypothesis, it additionally needs to be checked that for every path $p : a = a$ the map $\pi_k(\apfunc f):\pi_k(x = x,p) \to \pi_k(f(x) = f(x),\apfunc f(p))$ is a bijection. \\
783
+ %
784
+ \cref{sec:general-encode-decode}
785
+ & 1154-g301662b
786
+ & In the strengthening of condition (iii) from \cref{lem:encode-decode-loop}, the right side should read just ``$c$'' instead of ``$c.a$''.\\
787
+ %
788
+ % Chapter 9
789
+ %
790
+ \cref{ct:gaunt}
791
+ & 1307-gfe63517
792
+ & Stating that every isomorphism is an identity is not very accurate (consider the discrete category on the interval type): a more accurate statement is that every automorphism is an identity arrow. Notice that for precategories, this property must be combined with skeletality for the equivalence to hold.\\
793
+ %
794
+ \cref{ct:functor}
795
+ & 807-gebec78b
796
+ & In \cref{ct:functor:comp}, it should read ``$\hom_A(b,c)$'' instead of ``$\hom_B(b,c)$''.\\
797
+ %
798
+ \cref{sec:equivalences}
799
+ & 1218-gcb6ba30
800
+ & Just before \cref{ct:essentially-surjective}, it should say ``However, if $A$ is not a category'' instead of ``However, if $B$ is not a category''.\\
801
+ %
802
+ \cref{ct:yoneda}
803
+ & 971-g6096085
804
+ & The sequence of equations at the end of the proof should begin with $\alpha_{a'}(f) = \alpha_{a'} (\y a_{a,a'}(f)(1_a))$, and thereafter the subscripts should remain $a,a'$ rather than $a',a$.\\
805
+ %
806
+ \cref{ct:sig}
807
+ & 897-g94fb722
808
+ & In~\ref{item:sigcmp}, ``if $f:\hom_X(x,y)$'' should be ``if $f:\hom_X(x,y)$ and $g:\hom_X(y,z)$''.\\
809
+ %
810
+ \cref{sec:sip}
811
+ & 1111-g3332a31
812
+ & The type of objects $A_0$ of the precategory $A$ of $(P,H)$-structures should be defined as $\sm{x:X_0} Px$, not $\sm{x:X} Px$.\\
813
+ %
814
+ \cref{cha:category-theory}
815
+ & 966-g04374f5
816
+ & The first sentence after \cref{ct:cat-weq-eq} should begin ``Therefore, if a precategory $A$ admits a weak equivalence functor $A\to \widehat{A}$ \emph{into a category}\dots''.\\
817
+ %
818
+ \cref{thm:rezk-completion}
819
+ & 313-g8ee79db
820
+ & In the second proof, the third constructor of $\widehat A_0$ is unneeded; it follows from the fourth constructor and path induction.
821
+ In the fifth constructor, $j(g)\ct j(f)$ should be $j(f)\ct j(g)$, and similarly throughout the proof.
822
+ Finally, for consistency, the 1-truncation constructor should be included explicitly (this was intended to be implied by "higher inductive 1-type").\\
823
+ %
824
+ \cref{cha:category-theory} Notes
825
+ & 379-ga57eab2
826
+ & It should be mentioned that Hofmann and Streicher (1998) also considered this definition of category.\\
827
+ %
828
+ % Chapter 10
829
+ %
830
+ \cref{card:semiring}
831
+ & 1303-ga530d97
832
+ & The equation $\cd{B}\times\cd{A} \jdeq \cd{B\times A}$ in the proof should be $\cd{B}\cdot\cd{A} \jdeq \cd{B\times A}$.\\
833
+ %
834
+ \cref{thm:wfmin}
835
+ & 1290-g4101ad3
836
+ & In the proof, the second sentence of the second paragraph should have ``$s(a'):\acc(a')$'' rather than ``$s(a'):\acc(a)$''.\\
837
+ %
838
+ \cref{thm:ordord}
839
+ & 140-g55de417
840
+ & The second sentence of the proof should say ``By well-founded induction on $A$, suppose $\ordsl A b$ is accessible for all $b<a$''.\\
841
+ %
842
+ \cref{thm:ordunion}
843
+ & 140-gd7f8960
844
+ & The statement should say $X:\UU$ rather than $X:\UU_\UU$.\\
845
+ %
846
+ \cref{thm:wellorder}
847
+ & 140-gcca0bcf
848
+ & The penultimate sentence of the proof should say ``if $a<b$ and $b<c$'' rather than ``if $a<b$ and $a<c$''.\\
849
+ %
850
+ \cref{thm:wop}
851
+ & 871-g85bcd11
852
+ & The statement of~\ref{item:wop1} should end with $Y:\powerp X$, not $Y:\power X$.\\
853
+ %
854
+ \cref{sec:cumulative-hierarchy}
855
+ & 753-gc87ce23
856
+ & The second clause in the induction principle for $V$ should say ``Verify that if $f : A \to V$ and $g : B \to V$ satisfy~\eqref{eq:V-path}, then $\dpath{P}{q}{h(\vset(A,f))}{h(\vset(B,g))}$, where $q$ is the path arising from the second constructor of $V$ and~\eqref{eq:V-path}, assuming inductively that $\dpath{P}{p}{h(f(a))}{h(g(b))}$ whenever $p:f(a)=g(b)$.''\\
857
+ %
858
+ \cref{sec:cumulative-hierarchy}
859
+ & 706-ged2c765
860
+ & The proof that membership is well-defined should end with ``hence $x = g(b)$ and $x \in \vset(B,g)$.''\\
861
+ %
862
+ \cref{sec:cumulative-hierarchy}
863
+ & 1056-g4060c2b
864
+ & In the definition of $V$-set, the notation $v \in V$ should be $v:V$.\\
865
+ %
866
+ \cref{thm:VisCST}
867
+ & 708-g6f53189
868
+ & In the pairing axiom, the pair class should be denoted $\{u, v\}$, not $u\cup v$.\\
869
+ %
870
+ \cref{thm:VisCST}
871
+ & 723-g9cf5b44
872
+ & The replacement axiom should be given $x : V$ (not $a : V$) and the displayed class should be $\setof{ y | \exis{z : V} z \in x \land y = r(z)}$.
873
+ Its proof should begin ``let $C$ denote the class in question.''\\
874
+ %
875
+ \cref{thm:VisCST}
876
+ & 706-ged2c765
877
+ & In the proof of the function set axiom, ``the types of elements $[u] \mono V$ and $[u] \mono V$'' should be ``the types of members $[u] \mono V$ and $[v] \mono V$.''\\
878
+ %
879
+ \cref{ex:strong-collection}
880
+ & 1053-ge13dd65
881
+ & Extra parentheses around $\fall{x\in v}\exis{y} R(x,y)$ are needed to make the formula unambiguous.\\
882
+ %
883
+ \cref{ex:choice-cumulative-hierarchy-choice}
884
+ & 1053-ge13dd65
885
+ & Extra parentheses around $\fall{y\in x}\exis{z\in V} z\in y$ are needed to make the formula unambiguous.\\
886
+ %
887
+ \cref{ex:choice-cumulative-hierarchy-choice}
888
+ & 1056-g4060c2b
889
+ & The notation $\in V$ should be $:V$.\\
890
+ %
891
+ % Chapter 11
892
+ %
893
+ \cref{dedekind-in-cut-as-le}
894
+ & 165-gb002a64
895
+ & The statement should say ``For all $x : \RD$ and $q : \Q$, $L_x(q) \Leftrightarrow (q < x)$ and $U_x(q)
896
+ \Leftrightarrow (x < q)$''.\\
897
+ %
898
+ \cref{RD-inverse-apart-0}
899
+ & 165-g179b359
900
+ & In the proof, the sentence beginning ``From $0<ac$ it follows'' should be replaced by ``From $0 < a c$ and $0 < b c$ it follows
901
+ that $a$, $b$, and $c$ are either all positive or all negative.
902
+ Hence either $0 < a < x$ or $x < b < 0$, so that $x \apart 0$''.\\
903
+ %
904
+ \cref{RD-inverse-apart-0}
905
+ & 1384-gc9ada3f
906
+ & In the proof of the theorem, the definition of $x^{-1}$ should be changed as follows:
907
+ $L_{x^{-1}}(q) \defeq (q > 0) \Rightarrow \exis{r : \Q} U_x(r) \land (q r < 1)$ and $U_{x^{-1}}(q) \defeq (q > 0) \land \exis{r : \Q} L_x(r) \land (q r > 1)$ for positive $x$,
908
+ and $L_{x^{-1}}(q) \defeq (q < 0) \land \exis{r : \Q} U_x(r) \land (q r > 1)$ and $U_{x^{-1}}(q) \defeq (q < 0) \Rightarrow \exis{r : \Q} L_x(r) \land (q r < 1)$ for negative $x$. \\
909
+ %
910
+ \cref{sec:RD-cauchy-complete}
911
+ & 832-g0cb658e
912
+ & In the second paragraph, at ``From this we get'', the universal quantification should be over~$\delta$ as well.\\
913
+ %
914
+ \cref{sec:constr-cauchy-reals}
915
+ & 53-g7d3a5fa
916
+ & In the last paragraph of this section, ``$\rclim(\rcrat \circ x \circ m)$'' should be ``$\rclim(\rcrat \circ x \circ M)$''.\\
917
+ %
918
+ \cref{sec:induct-recurs-cauchy}
919
+ & 1209-g3e5ad94
920
+ & In the statement of $(\RC,\closesym)$-recursion, ``$f(x) : A$'' should be ``$f(\rclim(x)) : A$''.\\
921
+ %
922
+ \cref{defn:RC-approx}
923
+ & 1069-g3b333d5
924
+ & In the description of openness of $\approx$, ``$\exis{\epsilon : \Qp}$'' should be ``$\exis{\delta : \Qp}$''.\\
925
+ %
926
+ \cref{lem:untruncated-linearity-reals-coincide}
927
+ & 87-g82b27c3
928
+ & \eqref{eq:untruncated-linearity} should be $c:\prd{q, r : \Q} (q < r) \to (q < x) + (x < r)$, and therefore the use of $c$ in the proof should be $c(s,t)$ rather than $c(x,s,t)$.\\
929
+ %
930
+ \cref{analysis-interval-ctb}
931
+ & 1270-g3f17b85
932
+ & In the proof, $n : \N$ should be $k : \N$. And the range of $i$ should be $0 \leq i \leq k$. Also in the last equation, $r(\lim x) = \ell$ should be $\lim x = \ell$.\\
933
+ %
934
+ \cref{ctb-uniformly-continuous-sup}
935
+ & 61-gce4e391
936
+ & In the proof, $|f(x) - f(y_i) < \epsilon$ should be $|f(x) - f(y_i)| < \epsilon$.\\
937
+ %
938
+ \cref{defn:inductive-cover}
939
+ & 57-g671b000
940
+ & In (\cref{defn:inductive-cover-interval-1}), the order of $r$ and $s$ should be flipped on the right-hand side: $(r, s)$ should be $(s, r)$.\\
941
+ %
942
+ \cref{sec:surreals}
943
+ & 1189-ga9c35f0
944
+ & The inductive case of $\iota_{\Q_D}$ should be defined as $\iota_{\Q_D}(a/2^n) \defeq \surr{\iota_{\Q_D}(a/2^n - 1/2^n)}{\iota_{\Q_D}(a/2^n + 1/2^n)}$.\\
945
+ %
946
+ \cref{eg:surreal-addition}
947
+ & 636-g827e7ea
948
+ & In the first bullet point, to prove $x^L+z < x+z$ requires a $\NO$-induction on $z$, since only when $z$ is defined by a cut can we say that $x^L+z$ is a left option of $x+z$.\\
949
+ %
950
+ \cref{ex:mean-value-theorem}
951
+ & 222-g3453cf1
952
+ & This is the intermediate value theorem, not the mean value theorem.\\
953
+ %
954
+ \cref{eg:surreal-addition}
955
+ & 980-ge9d0398
956
+ & For the codomain of the outer recursion, the conditions should be $(x<y) \to (g(x)<g(y))$ and $(x\le y) \to (g(x)\le g(y))$. In the first bullet of the verification that inequalities are preserved, the outer inductive hypotheses give non-strict inequalities $x^L+y \le x^L+z$ and $x^R+ y \le x^R+z$, and no additional $\NO$-induction on $z$ is required (it is already known to be defined by a cut).\\
957
+ %
958
+ \cref{eg:surreal-addition}
959
+ & 980-ge9d0398
960
+ & The verification that Conway's definition of $x+y$ is a surreal number (i.e.\ all its left options are $<$ all its right options) was omitted. This requires turning the inner recursion into an inner induction with codomain a varying subset of $\NO$, as in \cref{defn:No-codes}.\\
961
+ %
962
+ % Appendix A
963
+ %
964
+ \cref{cha:rules}
965
+ & 165-g76db618
966
+ & After the introduction of the judgment ``$\wfctx{\Gamma}$'' in the Preliminaries, the sentence beginning ``Therefore, if $\oftp\Gamma aA$, \dots'' should say instead ``In particular, therefore, if $\oftp\Gamma aA$, \dots''.\\
967
+ %
968
+ \cref{subsec:contexts}
969
+ & 64-g7c2312e
970
+ & Clarify the distinction between typing judgments and context well-formedness judgments, and
971
+ remove the $\vdash$ from the notation for the latter.\\
972
+ %
973
+ \cref{sec:more-formal-sigma}
974
+ & 26-gcd691e8
975
+ & In $\Sigma$-\rcomp\ and the following paragraph, $y.C$ should be $z.C$, and ``we bind \dots $y$ in $C$'' should likewise say $z$.\\
976
+ %
977
+ \cref{sec:more-formal-unit}
978
+ & 338-g4e1c688
979
+ & The $c$ argument in the eliminator for $\unit$ (in the $\unit$-\relim\ and $\unit$-\rcomp\ rules) should not bind a variable of type $\unit$.\\
980
+ %
981
+ \cref{sec:more-formal-identity}
982
+ & 578-ga4b94a5
983
+ & The unbased eliminator for the identity type should be named $\indid{A}$, not $\indidb{A}$.\\
984
+ %% END ERRATA
985
+ \end{longtable}
986
+
987
+ \end{document}
exercise_solutions.tex ADDED
The diff for this file is too large to render. See raw diff
 
filter-errata ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python
2
+
3
+ import re
4
+ import sys
5
+
6
+ if len(sys.argv) != 2:
7
+ print "Usage: myerrata versionmarker"
8
+ exit(1)
9
+
10
+ # Version number we're being asked about
11
+ currentversion = sys.argv[1]
12
+ currentnumber = int(currentversion.split('-')[0])
13
+
14
+ print "Filtering errata for version marker " + currentversion + "..."
15
+
16
+ # Some regexps
17
+ commentre = re.compile('^\s*%')
18
+ versionre = re.compile('^\s*&\s*([0-9]+)-g[0-9a-f]{7}')
19
+
20
+ # Old and new errata files
21
+ errata = open("errata.tex",'r')
22
+ new = ""
23
+
24
+ # Move forward until the title
25
+ line = errata.readline()
26
+ while line != "%% VERSION MARKER\n":
27
+ new += line
28
+ line = errata.readline()
29
+
30
+ # Discard the comment
31
+ # Insert the version marker in the title
32
+ new += "\\\\since version " + currentversion + "\n"
33
+
34
+ # Move forward to the description
35
+ line = errata.readline()
36
+ while line != "%% BEGIN STARTPOINT\n":
37
+ new += line
38
+ line = errata.readline()
39
+
40
+ # Insert the version marker
41
+ new += "since version marker " + currentversion + "\n"
42
+
43
+ # Discard the "so far"
44
+ line = errata.readline()
45
+ while line != "%% END STARTPOINT\n":
46
+ line = errata.readline()
47
+
48
+ # Now get up to the actual errata
49
+ line = errata.readline()
50
+ while line != "%% BEGIN ERRATA\n":
51
+ new += line
52
+ line = errata.readline()
53
+
54
+ # Parse each erratum and decide whether to include it
55
+ while line != "%% END ERRATA\n":
56
+ # Skip comments
57
+ while commentre.search(line):
58
+ new += line
59
+ line = errata.readline()
60
+ # Now get the erratum, parsing the version number when we see it
61
+ ver = float('inf')
62
+ erratum = ''
63
+ while not commentre.search(line):
64
+ erratum += line
65
+ vmatch = versionre.search(line)
66
+ if vmatch:
67
+ ver = int(vmatch.group(1))
68
+ line = errata.readline()
69
+ # If it applies to us, put it in
70
+ if ver > currentnumber:
71
+ new += erratum
72
+
73
+ # Finally, put the rest in.
74
+ while line:
75
+ new += line
76
+ line = errata.readline()
77
+
78
+ errata.close()
79
+
80
+ # New errata file
81
+ newfilename = "errata-since-" + currentversion + ".tex"
82
+
83
+ print "Writing filtered errata to " + newfilename + "."
84
+
85
+ newfile = open(newfilename,'w')
86
+ newfile.write(new)
87
+ newfile.close()
formal.tex ADDED
@@ -0,0 +1,1259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % !TeX root = hott-online.tex
2
+
3
+ \titleformat{\chapter}[display]{\fontsize{23}{25}\fontseries{m}\fontshape{it}\selectfont}{\chaptertitlename}{20pt}{\fontsize{35}{35}\fontseries{b}\fontshape{n}\selectfont}
4
+ \chapter{Formal type theory}
5
+ \label{cha:rules}
6
+
7
+ \index{formal!type theory|(}%
8
+ \index{type theory!formal|(}%
9
+ \index{rules of type theory|(}%
10
+
11
+ Just as one can develop mathematics in set theory without explicitly using the axioms of Zermelo--Fraenkel set theory,
12
+ in this book we have developed mathematics in univalent foundations without explicitly referring to a formal
13
+ system of homotopy type theory. Nevertheless, it is important to \emph{have} a
14
+ precise description of homotopy type theory as a formal system in order to, for example,
15
+ %
16
+ \begin{itemize}
17
+ \item state and prove its metatheoretic properties, including logical
18
+ consistency,
19
+ \item construct models, e.g.\ in simplicial sets, model categories, higher toposes,
20
+ etc., and
21
+ \item implement it in proof assistants like \Coq or \Agda.
22
+ \index{proof!assistant}
23
+ \end{itemize}
24
+ %
25
+ Even the logical consistency\index{consistency} of homotopy type theory, namely that in the empty context there is no term $a:\emptyt$, is not obvious: if we had erroneously
26
+ chosen a definition of equivalence for which $\eqv{\emptyt}{\unit}$, then
27
+ univalence would imply that $\emptyt$ has an element, since $\unit$ does.
28
+ Nor is it obvious that, for example, our definition of $\Sn^1$ as a higher
29
+ inductive type yields a type which behaves like the ordinary circle.
30
+
31
+ There are two aspects of type theory which we must pin down before addressing
32
+ such questions. Recall from the Introduction that type theory
33
+ comprises a set of rules specifying when the judgments $a:A$ and $a\jdeq a':A$
34
+ hold --- for example, products are characterized by the rule that whenever $a:A$
35
+ and $b:B$, $(a,b):A\times B$. To make this precise, we must first define
36
+ precisely the syntax of terms --- the objects $a,a',A,\dots$ which these judgments
37
+ relate; then, we must define precisely the judgments and their rules of
38
+ inference --- the manner in which judgments can be derived from other judgments.
39
+
40
+ In this appendix, we present two formulations of Martin-L\"{o}f type
41
+ theory, and of the extensions that constitute homotopy type theory.
42
+ The first presentation (\cref{sec:syntax-informally}) describes the syntax of
43
+ terms and the forms of judgments as an extension of the untyped
44
+ $\lambda$-calculus, while leaving the rules of inference informal.
45
+ The second (\cref{sec:syntax-more-formally}) defines the terms, judgments,
46
+ and rules of inference inductively in the style of natural deduction, as
47
+ is customary in much type-theoretic literature.
48
+
49
+ \section*{Preliminaries}
50
+ \label{sec:formal-prelim}
51
+
52
+
53
+ In \cref{cha:typetheory}, we presented the two basic \define{judgments}
54
+ \index{judgment}
55
+ of type theory. The first, $a:A$, asserts that a term $a$ has type $A$. The second,
56
+ $a\jdeq b:A$, states that the two terms $a$ and $b$ are \define{judgmentally
57
+ equal}%
58
+ \index{equality!judgmental}
59
+ \index{judgmental equality}
60
+ at type $A$. These judgments are inductively defined by a set of
61
+ inference rules described in \cref{sec:syntax-more-formally}.
62
+
63
+ To construct an element $a$ of a type $A$ is to derive $a:A$; in the book, we
64
+ give informal arguments which describe the construction of $a$, but formally,
65
+ one must specify a precise term $a$ and a full derivation that $a:A$.
66
+
67
+ However, the main difference between the presentation of type theory in the book
68
+ and in this appendix is that here judgments are explicitly
69
+ formulated in an ambient \define{context},
70
+ \index{context}
71
+ or list of assumptions, of the form
72
+ \[
73
+ x_1:A_1, x_2:A_2,\dots,x_n:A_n.
74
+ \]
75
+ An element $x_i : A_i$ of the context expresses the assumption that the
76
+ variable
77
+ \index{variable}%
78
+ $x_i$ has type $A_i$. The variables $x_1, \ldots, x_n$ appearing in
79
+ the context must be distinct. We abbreviate contexts with the letters $\Gamma$
80
+ and $\Delta$.
81
+
82
+ The judgment $a:A$ in context $\Gamma$ is written
83
+ \[ \oftp\Gamma aA \]
84
+ and means that $a:A$ under the assumptions listed in $\Gamma$. When the list of
85
+ assumptions is empty, we write simply
86
+ \[ \oftp{}aA \]
87
+ or
88
+ \[ \oftp\emptyctx aA \]
89
+ where $\emptyctx$ denotes the empty context. The same applies to the equality
90
+ judgment
91
+ \[
92
+ \jdeqtp\Gamma{a}{b}{A}
93
+ \]
94
+
95
+ However, such judgments are sensible only for \define{well-formed} contexts,
96
+ \index{context!well-formed}%
97
+ a notion captured by our third and final judgment
98
+ \[
99
+ \wfctx{(x_1:A_1, x_2:A_2,\dots,x_n:A_n)}
100
+ \]
101
+ expressing that each $A_i$ is a type in the context $x_1:A_1,
102
+ x_2:A_2,\dots,x_{i-1}:A_{i-1}$. In particular, therefore, if $\oftp\Gamma aA$ and
103
+ $\wfctx\Gamma$, then we know that each $A_i$ contains only the variables
104
+ $x_1,\dots,x_{i-1}$, and that $a$ and $A$ contain only the variables
105
+ $x_1,\dots,x_n$.
106
+ \index{variable!in context}
107
+
108
+ In informal mathematical presentations, the context is
109
+ implicit. At each point in a proof, the mathematician knows which
110
+ variables are available and what types they have, either by historical
111
+ convention ($n$ is usually a number, $f$ is a function, etc.) or
112
+ because variables are explicitly introduced with sentences such as
113
+ ``let $x$ be a real number''. We discuss some benefits of using explicit
114
+ contexts in \cref{sec:more-formal-pi,sec:more-formal-sigma}.
115
+
116
+ We write $B[a/x]$ for the \define{substitution}
117
+ \index{substitution}%
118
+ of a term $a$ for free occurrences of
119
+ the variable~$x$ in the term $B$, with possible capture-avoiding
120
+ renaming of bound variables,
121
+ \index{variable!and substitution}%
122
+ as discussed in
123
+ \cref{sec:function-types}. The general form of substitution
124
+ %
125
+ \[
126
+ B[a_1,\dots,a_n/x_1,\dots,x_n]
127
+ \]
128
+ %
129
+ substitutes expressions $a_1,\dots,a_n$ for the variables
130
+ $x_1,\dots,x_n$ simultaneously.
131
+
132
+ To \define{bind a variable $x$ in an expression $B$}
133
+ \indexdef{variable!bound}%
134
+ means to incorporate both of them into a larger expression, called an \define{abstraction},
135
+ \indexdef{abstraction}%
136
+ whose purpose is to express the fact that $x$ is ``local'' to $B$, i.e., it
137
+ is not to be confused with other occurrences of $x$ appearing
138
+ elsewhere. Bound variables are familiar to programmers, but less so to mathematicians.
139
+ Various notations are used for binding, such as $x \mapsto B$,
140
+ $\lam x B$, and $x \,.\, B$, depending on the situation. We may write $C[a]$ for the
141
+ substitution of a term $a$ for the variable in the abstracted expression, i.e.,
142
+ we may define $(x.B)[a]$ to be $B[a/x]$. As discussed in
143
+ \cref{sec:function-types}, changing the name of a bound variable everywhere within an expression (``$\alpha$-conversion'')
144
+ \index{alpha-conversion@$\alpha $-conversion}%
145
+ does not change the expression. Thus, to be very
146
+ precise, an expression is an equivalence class of syntactic forms
147
+ which differ in names of bound variables.
148
+
149
+ One may also regard each variable $x_i$ of a judgment
150
+ \[
151
+ x_1:A_1, x_2:A_2,\dots,x_n:A_n \vdash a : A
152
+ \]
153
+ to be bound in its \define{scope},
154
+ \indexdef{variable!scope of}%
155
+ \index{scope}%
156
+ consisting of the expressions $A_{i+1},
157
+ \ldots, A_n$, $a$, and $A$.
158
+
159
+ \section{The first presentation}
160
+ \label{sec:syntax-informally}
161
+
162
+ The objects and types of our type theory may be written as terms using
163
+ the following syntax, which is an extension of $\lambda$-calculus with
164
+ \emph{variables} $x, x',\dots$,
165
+ \index{variable}%
166
+ \emph{primitive constants}
167
+ \index{primitive!constant}%
168
+ \index{constant!primitive}%
169
+ $c,c',\dots$, \emph{defined constants}\index{constant!defined} $f,f',\dots$, and term forming
170
+ operations
171
+ %
172
+ \[
173
+ t \production x \mid \lam{x} t \mid t(t') \mid c \mid f
174
+ \]
175
+ %
176
+ The notation used here means that a term $t$ is either a variable $x$, or it
177
+ has the form $\lam{x} t$ where $x$ is a variable and $t$ is a term, or it has
178
+ the form $t(t')$ where $t$ and $t'$ are terms, or it is a primitive constant
179
+ $c$, or it is a defined constant $f$. The syntactic markers '$\lambda$', '(',
180
+ ')', and '.' are punctuation for guiding the human eye.
181
+
182
+ We use $t(t_1,\dots,t_n)$ as an abbreviation for the repeated application
183
+ $t(t_1)(t_2)\dots (t_n)$. We may also use \emph{infix}\index{infix notation} notation, writing $t_1\;
184
+ \star\; t_2$ for $\star(t_1,t_2)$ when $\star$ is a primitive or defined
185
+ constant.
186
+
187
+ Each defined constant has zero, one or more \define{defining equations}.
188
+ \index{equation, defining}%
189
+ \index{defining equation}%
190
+ There are two kinds of defined constant. An \emph{explicit}
191
+ \index{constant!explicit}
192
+ defined constant $f$ has a single defining equation
193
+ \[ f(x_1,\dots,x_n)\defeq t,\]
194
+ where $t$ does not involve $f$.
195
+ %
196
+ For example, we might introduce the explicit defined constant $\circ$ with defining equation
197
+ \[ \circ (x,y)(z) \defeq x(y(z)),\]
198
+ and use infix notation $x\circ y$ for $\circ(x,y)$. This of course is just composition of functions.
199
+
200
+ The second kind of defined constant is used to specify a (parameterized) mapping
201
+ $f(x_1,\dots,x_n,x)$, where $x$ ranges over a type whose elements are generated
202
+ by zero or more primitive constants. For each such primitive constant $c$ there
203
+ is a defining equation of the form
204
+ \[
205
+ f(x_1,\dots,x_n,c(y_1,\dots,y_m)) \defeq t,
206
+ \]
207
+ where $f$ may occur in $t$, but only in such a way that it is clear that the
208
+ equations determine a totally defined function. The paradigm examples of such
209
+ defined functions are the functions defined by primitive recursion on the
210
+ natural numbers. We may call this kind of definition of a function a \emph{total
211
+ recursive definition}.
212
+ \index{total!recursive definition}%
213
+ In computer science and logic this kind of definition
214
+ of a function on a recursive data type has been called a \define{definition by
215
+ structural recursion}.
216
+ \index{definition!by structural recursion}%
217
+ \index{structural!recursion}%
218
+ \index{recursion!structural}%
219
+
220
+ \define{Convertibility}
221
+ \index{convertibility of terms}%
222
+ \index{term!convertibility of}%
223
+ $t \conv t'$ between terms $t$
224
+ and $t'$ is the equivalence relation generated by the defining equations for constants,
225
+ the computation rule\index{computation rule!for function types}
226
+ %
227
+ \[
228
+ (\lam{x} t)(u) \defeq t[u/x],
229
+ \]
230
+ %
231
+ and the rules which make it a \emph{congruence} with respect to application and $\lambda$-abstraction\index{lambda abstraction@$\lambda$-abstraction}:
232
+ %
233
+ \begin{itemize}
234
+ \item if $t \conv t'$ and $s \conv s'$ then $t(s) \conv t'(s')$, and
235
+ \item if $t \conv t'$ then $(\lam{x} t) \conv (\lam{x} t')$.
236
+ \end{itemize}
237
+ \noindent
238
+ The equality judgment $t \jdeq u : A$ is then derived by the following single rule:
239
+ %
240
+ \begin{itemize}
241
+ \item if $t:A$, $u:A$, and $t \conv u$, then $t \jdeq u : A$.
242
+ \end{itemize}
243
+ %
244
+ Judgmental equality is an equivalence relation.
245
+
246
+ Note that the type theory of this presentation diverges from that used in the main body of the text in not including the judgmental uniqueness principle $f \jdeq (\lam{x} f(x))$ for functions.
247
+ Such an equality requires that judgmental equality be sensitive to the type of the terms involved, as this equality only makes sense when $f$ is known to be a function, whereas in this presentation the convertibility relation is type-independent.
248
+ The second presentation in \cref{sec:syntax-more-formally} includes the uniqueness principle.
249
+
250
+
251
+ \subsection{Type universes}
252
+
253
+ We postulate a hierarchy of \define{universes} denoted by primitive constants
254
+ \index{type!universe}
255
+ %
256
+ \begin{equation*}
257
+ \UU_0, \quad \UU_1, \quad \UU_2, \quad \ldots
258
+ \end{equation*}
259
+ %
260
+ The first two rules for universes say that they form a cumulative hierarchy of types:
261
+ %
262
+ \begin{itemize}
263
+ \item $\UU_m : \UU_n$ for $m < n$,
264
+ \item if $A:\UU_m$ and $m \le n$, then $A:\UU_n$,
265
+ \end{itemize}
266
+ %
267
+ and the third expresses the idea that an object of a universe can serve as a type and stand to the
268
+ right of a colon in judgments:
269
+ %
270
+ \begin{itemize}
271
+ \item if $\Gamma \vdash A : \UU_n$, and $x$ is a new variable,%
272
+ \footnote{By ``new'' we mean that it does not appear in $\Gamma$ or $A$.}
273
+ then $\vdash (\Gamma, x:A)\; \ctx$.
274
+ \end{itemize}
275
+ %
276
+ In the body of the book, an equality judgment $A \jdeq B : \UU_n$ between types
277
+ $A$ and $B$ is usually abbreviated to $A \jdeq B$. This is an instance of
278
+ typical ambiguity\index{typical ambiguity}, as we can always switch to a larger universe, which however does not affect the validity of the judgment.
279
+
280
+ The following conversion rule allows us to replace a type by one equal to it in a typing judgment:
281
+ %
282
+ \begin{itemize}
283
+ \item if $a:A$ and $A \jdeq B$ then $a:B$.
284
+ \end{itemize}
285
+
286
+ \subsection{Dependent function types (\texorpdfstring{$\Pi$}{Π}-types)}
287
+
288
+ We introduce a primitive constant $c_\Pi$, but write
289
+ $c_\Pi(A,\lam{x} B)$ as $\tprd{x:A}B$. Judgments concerning
290
+ such expressions and expressions of the form $\lam{x} b$ are introduced by the following rules:
291
+ %
292
+ \begin{itemize}
293
+ \item if $\Gamma \vdash A:\UU_n$ and $\Gamma,x:A \vdash B:\UU_n$, then $\Gamma \vdash \tprd{x:A}B : \UU_n$
294
+ \item if $\Gamma, x:A \vdash b:B$ then $\Gamma \vdash (\lam{x} b) : (\tprd{x:A} B)$
295
+ \item if $\Gamma\vdash g:\tprd{x:A} B$ and $\Gamma\vdash t:A$ then $\Gamma\vdash g(t):B[t/x]$
296
+ \end{itemize}
297
+ %
298
+ If $x$ does not occur freely in $B$, we abbreviate $\tprd{x:A} B$ as the non-dependent function type
299
+ $A\rightarrow B$ and derive the following rule:
300
+ %
301
+ \begin{itemize}
302
+ \item if $\Gamma\vdash g:A \rightarrow B$ and $\Gamma\vdash t:A$ then $\Gamma\vdash g(t):B$
303
+ \end{itemize}
304
+ Using non-dependent function types and leaving implicit the context $\Gamma$, the rules above can be written in the following alternative style that we use in the rest of this section of the appendix:
305
+ %
306
+ \begin{itemize}
307
+ \item if $A:\UU_n$ and $B:A\to\UU_n$, then $\tprd{x:A}B(x) : \UU_n$
308
+ \item if $x:A \vdash b:B(x)$ then $ \lam{x} b : \tprd{x:A} B(x)$
309
+ \item if $g:\tprd{x:A} B(x)$ and $t:A$ then $g(t):B(t)$
310
+ \end{itemize}
311
+ %
312
+
313
+ \subsection{Dependent pair types (\texorpdfstring{$\Sigma$}{Σ}-types)}
314
+
315
+ We introduce primitive constants $c_\Sigma$ and $c_{\mathsf{pair}}$. An
316
+ expression of the form $c_\Sigma(A,\lam{a} B)$ is written as $\sm{a:A}B$,
317
+ and an expression of the form $c_{\mathsf{pair}}(a,b)$ is written as $\tup
318
+ a b$. We write $A\times B$ instead of $\sm{x:A} B$ if $x$ is not free in $B$.
319
+
320
+ Judgments concerning such expressions are introduced by the following
321
+ rules:
322
+ %
323
+ \begin{itemize}
324
+ \item if $A:\UU_n$ and $B: A \rightarrow \UU_n$, then $\sm{x:A}B(x) : \UU_n$
325
+ \item if, in addition, $a:A$ and $b:B(a)$, then $\tup a b:\sm{x:A}B(x)$
326
+ \end{itemize}
327
+ %
328
+ If we have $A$ and $B$ as above, $C : (\sm{x:A}B(x)) \rightarrow \UU_m$, and
329
+ \[
330
+ d:\tprd{x:A}{y:B(x)} C(\tup x y)
331
+ \]
332
+ we can introduce a defined constant
333
+ \[
334
+ f:\tprd{p:\sm{x:A}B(x)} C(p)
335
+ \]
336
+ with the defining equation
337
+ \[
338
+ f(\tup x y)\defeq d(x,y).
339
+ \]
340
+ %
341
+ Note that $C$, $d$, $x$, and $y$ may contain extra implicit parameters $x_1,\ldots,x_n$ if they were obtained in some non-empty context; therefore, the fully explicit recursion schema is
342
+ %
343
+ \begin{narrowmultline*}
344
+ f(x_1,\dots,x_n,\tup{x(x_1,\dots,x_n)}{y(x_1,\dots,x_n)}) \defeq
345
+ \narrowbreak
346
+ d(x_1,\dots,x_n,\tup{x(x_1,\dots,x_n)}{y(x_1,\dots,x_n)}).
347
+ \end{narrowmultline*}
348
+
349
+ \subsection{Coproduct types}
350
+
351
+ We introduce primitive constants $c_+$, $c_\inlsym$, and $c_\inrsym$.
352
+ We write $A+B$ instead of $c_+(A,B)$, $\inl(a)$ instead of
353
+ $c_\inlsym(a)$, and $\inr(a)$ instead of $c_\inrsym(a)$:
354
+ %
355
+ \begin{itemize}
356
+ \item if $A,B : \UU_n$ then $A + B : \UU_n$
357
+ \item moreover, $\inl: A \rightarrow A+B$ and $\inr: B \rightarrow A+B$
358
+ \end{itemize}
359
+ %
360
+ If we have $A$ and $B$ as above, $C : A+B \rightarrow \UU_m$,
361
+ $d:\tprd{x:A} C(\inl(x))$, and $e:\tprd{y:B} C(\inr(y))$,
362
+ then we can introduce a defined constant $f:\tprd{z:A+B}C(z)$ with the defining equations
363
+ %
364
+ \begin{equation*}
365
+ f(\inl(x)) \defeq d(x)
366
+ \qquad\text{and}\qquad
367
+ f(\inr(y)) \defeq e(y).
368
+ \end{equation*}
369
+
370
+ \subsection{The finite types}
371
+
372
+ We introduce primitive constants $\ttt$, $\emptyt$, $\unit$, satisfying the following rules:
373
+ %
374
+ \begin{itemize}
375
+ \item $\emptyt : \UU_0$, $\unit : \UU_0$
376
+ \item $\ttt:\unit$
377
+ \end{itemize}
378
+
379
+ Given $C : \emptyt \rightarrow \UU_n$ we can introduce a defined constant $f:\tprd{x:\emptyt} C(x)$, with no defining equations.
380
+
381
+ Given $C : \unit \rightarrow \UU_n$ and $d : C(\ttt)$ we can introduce a defined constant $f:\tprd{x:\unit} C(x)$, with defining equation $f(\ttt) \defeq d$.
382
+
383
+ \subsection{Natural numbers}
384
+
385
+ The type of natural numbers is obtained by introducing primitive constants
386
+ $\N$, $0$, and $\suc$ with the following rules:
387
+ %
388
+ \begin{itemize}
389
+ \item $\N : \UU_0$,
390
+ \item $0:\N$,
391
+ \item $\suc:\N\rightarrow \N$.
392
+ \end{itemize}
393
+ %
394
+ Furthermore, we can define functions by primitive recursion. If we have
395
+ $C : \N \rightarrow \UU_k $ we can introduce a defined constant $f:\tprd{x:\N}C(x)$ whenever we have
396
+ %
397
+ \begin{align*}
398
+ d & : C(0) \\
399
+ e & : \tprd{x:\N}(C(x)\rightarrow C(\suc (x)))
400
+ \end{align*}
401
+ %
402
+ with the defining equations
403
+ %
404
+ \begin{equation*}
405
+ f(0) \defeq d
406
+ \qquad\text{and}\qquad
407
+ f(\suc (x)) \defeq e(x,f(x)).
408
+ \end{equation*}
409
+
410
+ \subsection{\texorpdfstring{$W$}{W}-types}
411
+
412
+ For $W$-types we introduce primitive constants $c_\wtypesym$ and $c_\suppsym$.
413
+ An expression of the form $c_\wtypesym(A,\lam{x} B)$ is written as
414
+ $\wtype{x:A}B$, and an expression of the form $c_\suppsym(x,u)$ is written
415
+ as $\supp(x,u)$:
416
+ %
417
+ \begin{itemize}
418
+ \item if $A:\UU_n$ and $B: A \rightarrow \UU_n$, then $\wtype{x:A}B(x) : \UU_n$
419
+ \item if moreover, $a:A$ and $u:B(a)\rightarrow \wtype{x:A}B(x)$ then $\supp(a,u):\wtype{x:A}B(x)$.
420
+ \end{itemize}
421
+ %
422
+ Here also we can define functions by total recursion. If we have $A$ and $B$
423
+ as above and $C : (\wtype{x:A}B(x)) \rightarrow \UU_m$, then we can introduce a defined constant
424
+ $f:\tprd{z:\wtype{x:A}B(x)} C(z)$ whenever we have
425
+ \[
426
+ d:\tprd{a:A}{u:B(a) \rightarrow \wtype{x:A}B(x)}((\tprd{y:B(a)}C(u(y))) \rightarrow C(\supp(a,u)))
427
+ \]
428
+ with the defining equation
429
+ \[
430
+ f(\supp(a,u)) \defeq d(a,u,f\circ u).
431
+ \]
432
+
433
+ \subsection{Identity types}
434
+
435
+ We introduce primitive constants $c_\idsym$ and $c_{\refl{}}$. We write
436
+ $\id[A] a b$ for $c_\idsym(A,a,b)$ and $\refl a$ for $c_{\refl{}}(A,a)$, when
437
+ $a:A$ is understood:
438
+ %
439
+ \begin{itemize}
440
+ \item If $A : \UU_n$, $a:A$, and $b:A$ then $\id[A] a b : \UU_n$.
441
+ \item If $a:A$ then $\refl a :\id[A] a a $.
442
+ \end{itemize}
443
+ %
444
+ Given $a:A$, if $y:A, z:\id[A] a y \vdash C : \UU_m$ and
445
+ $\vdash d:C[a,\refl{a}/y,z]$ then we can introduce a defined constant
446
+ \[
447
+ f:\tprd{y:A}{z:\id[A] a y} C
448
+ \]
449
+ with defining equation
450
+ \[
451
+ f(a,\refl{a})\defeq d.
452
+ \]
453
+
454
+ \section{The second presentation}
455
+ \label{sec:syntax-more-formally}
456
+
457
+ In this section, there are three kinds of judgments
458
+ \begin{mathpar}
459
+ \wfctx\Gamma
460
+ \and
461
+ \oftp\Gamma{a}{A}
462
+ \and
463
+ \jdeqtp\Gamma{a}{a'}{A}
464
+ \end{mathpar}
465
+ which we specify by providing inference rules for deriving them. A typical \define{inference rule}
466
+ \indexsee{inference rule}{rule}%
467
+ \indexdef{rule}%
468
+ has the form
469
+ %
470
+ \begin{equation*}
471
+ \inferrule*[right=\textsc{Name}]
472
+ {\mathcal{J}_1 \\ \cdots \\ \mathcal{J}_k}
473
+ {\mathcal{J}}
474
+ \end{equation*}
475
+ %
476
+ It says that we may derive the \define{conclusion} $\mathcal{J}$, provided that we have
477
+ already derived the \define{hypotheses} $\mathcal{J}_1, \ldots, \mathcal{J}_k$.
478
+ (Note that, being judgments rather than types, these are not hypotheses \emph{internal} to the type theory in the sense of \cref{sec:types-vs-sets}; they are instead hypotheses in the deductive system, i.e.\ the metatheory.)
479
+ On the
480
+ right we write the \textsc{Name} of the rule, and there may be extra side conditions that
481
+ need to be checked before the rule is applicable.
482
+
483
+ A \define{derivation}
484
+ \index{derivation}%
485
+ of a judgment is a tree constructed from such inference
486
+ rules, with the judgment at the root of the tree. For example, with the rules given below, the following is a derivation of
487
+ $\oftp{\emptyctx}{\lamu{x:\unit} x}{\unit\to\unit}$.
488
+ %
489
+ \begin{mathpar}
490
+ \inferrule*[right=$\Pi$-\rintro]
491
+ {\inferrule*[right=$\Vble$]
492
+ {\inferrule*[right=\ctx-\textsc{ext}]
493
+ {\inferrule*[right=$\unit$-\rform]
494
+ {\inferrule*[right=\ctx-\textsc{emp}]
495
+ {\ }
496
+ {\wfctx {\emptyctx}}}
497
+ {\oftp{}{\unit}{\UU_0}}}
498
+ {\wfctx {\tmtp x\unit}}}
499
+ {\oftp{\tmtp x\unit}{x}{\unit}}}
500
+ {\oftp{\emptyctx}{\lamu{x:\unit} x}{\unit\to\unit}}
501
+ \end{mathpar}
502
+
503
+ \subsection{Contexts}
504
+ \label{subsec:contexts}
505
+
506
+ \index{context}%
507
+ A context is a list
508
+ %
509
+ \begin{equation*}
510
+ \tmtp{x_1}{A_1}, \tmtp{x_2}{A_2}, \ldots, \tmtp{x_n}{A_n}
511
+ \end{equation*}
512
+ %
513
+ which indicates that the distinct variables
514
+ \index{variable}%
515
+ $x_1, \ldots, x_n$ are assumed to have types $A_1, \ldots, A_n$, respectively. The list may be empty. We abbreviate contexts with the letters $\Gamma$ and $\Delta$, and we may juxtapose them to form larger contexts.
516
+
517
+ The judgment $\wfctx{\Gamma}$ formally expresses the fact that $\Gamma$ is a well-formed context, and is governed by the rules of inference
518
+ %
519
+ \begin{mathpar}
520
+ \inferrule*[right=\ctx-\textsc{emp}]
521
+ {\ }
522
+ {\wfctx\emptyctx}
523
+ \and
524
+ \inferrule*[right=\ctx-\textsc{ext}]
525
+ {\oftp{\tmtp{x_1}{A_1}, \ldots, \tmtp{x_{n-1}}{A_{n-1}}}{A_n}{\UU_i}}
526
+ {\wfctx{(\tmtp{x_1}{A_1}, \ldots, \tmtp{x_n}{A_n})}}
527
+ \end{mathpar}
528
+ %
529
+ with a side condition for the second rule: the variable $x_n$ must be distinct from the variables $x_1, \ldots, x_{n-1}$.
530
+ Note that the hypothesis and conclusion of $\ctx$-\textsc{ext} are judgments of different forms: the hypothesis says that in the context of variables $x_1, \ldots, x_{n-1}$, the expression $A_n$ has type $\UU_i$; while the conclusion says that the extended context $(\tmtp{x_1}{A_1}, \ldots, \tmtp{x_n}{A_n})$ is well-formed.
531
+
532
+ It is a meta-theoretic property of the system that if any judgment of the form $\oftp{\Gamma}{a}{A}$ or $\jdeqtp\Gamma{a}{a'}{A}$ is derivable, then so is the judgment $\wfctx\Gamma$ that the context $\Gamma$ is well-formed.
533
+ The premises of all the rules are chosen to include just enough well-formedness hypotheses to make this property provable, but no more.
534
+ For instance, it is not necessary for $\ctx$-\textsc{ext} to hypothesize well-formedness of $(\tmtp{x_1}{A_1}, \ldots, \tmtp{x_{n-1}}{A_{n-1}})$, as that will follow from the derivability of its premise; but it is necessary for the $\Vble$ rule in the next section to hypothesize well-formedness of its context.
535
+ This choice is only one of the many possible ways to formulate a type theory precisely, but a detailed investigation of such issues is beyond the scope of this appendix.
536
+
537
+ \subsection{Structural rules}
538
+
539
+ \index{structural!rules|(}%
540
+ \index{rule!structural|(}%
541
+
542
+ The fact that the context holds assumptions is expressed by the rule which says that we may derive those typing judgments which are listed in the context:
543
+ %
544
+ \begin{mathpar}
545
+ \inferrule*[right=$\Vble$]
546
+ {\wfctx {(\tmtp{x_1}{A_1}, \ldots, \tmtp{x_n}{A_n})} }
547
+ {\oftp{\tmtp{x_1}{A_1}, \ldots, \tmtp{x_n}{A_n}}{x_i}{A_i}}
548
+ \end{mathpar}
549
+ %
550
+ As with $\ctx$-\textsc{ext}, the hypothesis and conclusion of the rule $\Vble$ are judgments of different forms, only now they are reversed: we start with a well-formed context and derive a typing judgment.
551
+
552
+ The following important principles, called \define{substitution}
553
+ \indexdef{rule!of substitution}%
554
+ and
555
+ \define{weakening},
556
+ \indexdef{rule!of weakening}%
557
+ need not be explicitly assumed. Rather, it is possible to
558
+ show, by induction on the structure of all possible derivations, that whenever
559
+ the hypotheses of these rules are derivable, their conclusion is also
560
+ derivable.\footnote{Such rules are called \define{admissible}\indexdef{rule!admissible}\indexsee{admissible!rule}{rule, admissible}.}
561
+ For the typing judgments these principles are manifested as
562
+ %
563
+ \begin{mathpar}
564
+ \inferrule*[right=$\Subst_1$]
565
+ {\oftp\Gamma{a}{A} \\ \oftp{\Gamma,\tmtp xA,\Delta}{b}{B}}
566
+ {\oftp{\Gamma,\Delta[a/x]}{b[a/x]}{B[a/x]}}
567
+ \and
568
+ \inferrule*[right=$\Weak_1$]
569
+ {\oftp\Gamma{A}{\UU_i} \\ \oftp{\Gamma,\Delta}{b}{B}}
570
+ {\oftp{\Gamma,\tmtp xA,\Delta}{b}{B}}
571
+ \end{mathpar}
572
+ and for judgmental equalities they become
573
+ \begin{mathpar}
574
+ \inferrule*[right=$\Subst_2$]
575
+ {\oftp\Gamma{a}{A} \\ \jdeqtp{\Gamma,\tmtp xA,\Delta}{b}{c}{B}}
576
+ {\jdeqtp{\Gamma,\Delta[a/x]}{b[a/x]}{c[a/x]}{B[a/x]}}
577
+ \and
578
+ \inferrule*[right=$\Subst_3$]
579
+ {\jdeqtp\Gamma{a}{b}{A} \\ \oftp{\Gamma,\tmtp xA,\Delta}{c}{C}}
580
+ {\jdeqtp{\Gamma,\Delta[a/x]}{c[a/x]}{c[b/x]}{C[a/x]}}
581
+ \and
582
+ \inferrule*[right=$\Weak_2$]
583
+ {\oftp\Gamma{A}{\UU_i} \\ \jdeqtp{\Gamma,\Delta}{b}{c}{B}}
584
+ {\jdeqtp{\Gamma,\tmtp xA,\Delta}{b}{c}{B}}
585
+ \end{mathpar}
586
+ %
587
+ In addition to the judgmental equality rules given for each type former, we also
588
+ assume that judgmental equality is an equivalence relation respected by typing.
589
+ \begin{mathparpagebreakable}
590
+ \inferrule*{\oftp\Gamma{a}{A}}{\jdeqtp\Gamma{a}{a}{A}}
591
+ \and
592
+ \inferrule*{\jdeqtp\Gamma{a}{b}{A}}{\jdeqtp\Gamma{b}{a}{A}}
593
+ \and
594
+ \inferrule*{\jdeqtp\Gamma{a}{b}{A} \\ \jdeqtp\Gamma{b}{c}{A}}{\jdeqtp\Gamma{a}{c}{A}}
595
+ \and
596
+ \inferrule*{\oftp\Gamma{a}{A} \\ \jdeqtp\Gamma{A}{B}{\UU_i}}{\oftp\Gamma{a}{B}}
597
+ \and
598
+ \inferrule*{\jdeqtp\Gamma{a}{b}{A} \\ \jdeqtp\Gamma{A}{B}{\UU_i}}{\jdeqtp\Gamma{a}{b}{B}}
599
+ \end{mathparpagebreakable}
600
+ %
601
+ Finally, we assume that judgmental equality is a congruence respected by typing,
602
+ i.e., that each type and term-former preserves judgmental equality in each of
603
+ its arguments. For instance, along with the $\Pi$-\rintro\ rule, we assume the
604
+ rule
605
+ \[
606
+ \inferrule*[right=$\Pi$-\rintro-eq]
607
+ {\oftp\Gamma{A}{\UU_i} \\
608
+ \oftp{\Gamma,\tmtp xA}{B}{\UU_i} \\
609
+ \jdeqtp{\Gamma,\tmtp xA}{b}{b'}{B}}
610
+ {\jdeqtp\Gamma{\lamu{x:A} b}{\lamu{x:A'} b'}{\tprd{x:A} B}}
611
+ \]
612
+ Completing the case of dependent function types, two similar rules,
613
+ $\Pi$-\textsc{form-eq}\ and $\Pi$-\textsc{elim-eq}, are assumed.
614
+ Taken together, these local principles (at every type) imply the global congruence principles
615
+ $\Subst_2$ and $\Subst_3$ above. We will omit these local rules for brevity.
616
+
617
+ \index{rule!structural|)}%
618
+ \index{structural!rules|)}%
619
+
620
+ \subsection{Type universes}
621
+
622
+ \index{type!universe}%
623
+
624
+ We postulate an infinite hierarchy of type universes
625
+ %
626
+ \begin{equation*}
627
+ \UU_0, \quad \UU_1, \quad \UU_2, \quad \ldots
628
+ \end{equation*}
629
+ %
630
+ Each universe is contained in the next, and any type in $\UU_i$ is also in $\UU_{i+1}$:
631
+ %
632
+ \begin{mathpar}
633
+ \inferrule*[right=\UU-\textsc{intro}]
634
+ {\wfctx \Gamma }
635
+ {\oftp\Gamma{\UU_i}{\UU_{i+1}}}
636
+ \and
637
+ \inferrule*[right=\UU-\textsc{cumul}]
638
+ {\oftp\Gamma{A}{\UU_i}}
639
+ {\oftp\Gamma{A}{\UU_{i+1}}}
640
+ \end{mathpar}
641
+ %
642
+ We shall set up the rules of type theory in such a way that $\oftp\Gamma{a}{A}$
643
+ implies $\oftp\Gamma{A}{\UU_i}$ for some $i$. In other words, if $A$ plays the role of a type then it is in some universe. Another property of our type system is that $\jdeqtp\Gamma{a}{b}{A}$
644
+ implies $\oftp\Gamma{a}{A}$ and $\oftp\Gamma{b}{A}$.
645
+
646
+ \subsection{Dependent function types (\texorpdfstring{$\Pi$}{Π}-types)}
647
+ \label{sec:more-formal-pi}
648
+
649
+ \index{type!dependent function}%
650
+ \index{type!function}%
651
+
652
+ In \cref{sec:function-types}, we introduced non-dependent functions $A\to B$ in
653
+ order to define a family of types as a function $\lam{x:A} B:A\to\UU_i$, which
654
+ then gives rise to a type of dependent functions $\tprd{x:A} B$. But with explicit contexts
655
+ we may replace $\lam{x:A} B:A\to\UU_i$ with the judgment
656
+ %
657
+ \begin{equation*}
658
+ \oftp{\tmtp xA}{B}{\UU_i}.
659
+ \end{equation*}
660
+ %
661
+ Consequently, we may define dependent functions directly, without reference to non-dependent ones. This way we follow the general principle that each type former, with its constants and rules, should be introduced independently of all other type formers.
662
+ %
663
+ In fact, henceforth each type former is introduced systematically by:
664
+ \begin{itemize}
665
+ \item a \define{formation rule}, stating when the type former can be applied;\index{formation rule}\index{rule!formation}
666
+ \item some \define{introduction rules}, stating how to inhabit the type;\index{introduction rule}\index{rule!introduction}
667
+ \item \define{elimination rules}, or an induction principle, stating how to use an
668
+ element of the type;
669
+ \index{induction principle}\index{eliminator}
670
+ \item \define{computation rules}, which are judgmental equalities explaining what happens when elimination rules are applied to results of introduction rules;
671
+ \index{computation rule}
672
+ \indexsee{rule!computation}{computation rule}
673
+ \item optional \define{uniqueness principles}, which are judgmental equalities explaining how every element of the type is uniquely determined by the results of elimination rules applied to it.
674
+ \index{uniqueness!principle}
675
+ \indexsee{principle!uniqueness}{uniqueness principle}
676
+ \end{itemize}
677
+ (See also \cref{rmk:introducing-new-concepts}.)
678
+
679
+ For the dependent function type these rules are:
680
+ %
681
+ \begin{mathparpagebreakable}
682
+ \def\premise{\oftp{\Gamma}{A}{\UU_i} \and \oftp{\Gamma,\tmtp xA}{B}{\UU_i}}
683
+ \inferrule*[right=$\Pi$-\rform]
684
+ \premise
685
+ {\oftp\Gamma{\tprd{x:A}B}{\UU_i}}
686
+ \and
687
+ \inferrule*[right=$\Pi$-\rintro]
688
+ {\oftp{\Gamma,\tmtp xA}{b}{B}}
689
+ {\oftp\Gamma{\lam{x:A} b}{\tprd{x:A} B}}
690
+ \and
691
+ \inferrule*[right=$\Pi$-\relim]
692
+ {\oftp\Gamma{f}{\tprd{x:A} B} \\ \oftp\Gamma{a}{A}}
693
+ {\oftp\Gamma{f(a)}{B[a/x]}}
694
+ \and
695
+ \inferrule*[right=$\Pi$-\rcomp]
696
+ {\oftp{\Gamma,\tmtp xA}{b}{B} \\ \oftp\Gamma{a}{A}}
697
+ {\jdeqtp\Gamma{(\lam{x:A} b)(a)}{b[a/x]}{B[a/x]}}
698
+ \and
699
+ \inferrule*[right=$\Pi$-\runiq]
700
+ {\oftp\Gamma{f}{\tprd{x:A} B}}
701
+ {\jdeqtp\Gamma{f}{(\lamu{x:A}f(x))}{\tprd{x:A} B}}
702
+ \end{mathparpagebreakable}
703
+
704
+ The expression $\lam{x:A} b$ binds free occurrences of $x$ in $b$, as does $\tprd{x:A} B$ for
705
+ $B$.
706
+
707
+ When $x$ does not occur freely in $B$ so that $B$ does not depend on $A$, we obtain as a
708
+ special case the ordinary function type $A\to B \defeq \tprd{x:A} B$. We take this as the \emph{definition} of $\to$.
709
+
710
+ We may abbreviate an expression $\lam{x:A} b$ as $\lamu{x:A} b$, with the understanding
711
+ that the omitted type $A$ should be filled in appropriately before type-checking.
712
+
713
+ \subsection{Dependent pair types (\texorpdfstring{$\Sigma$}{Σ}-types)}
714
+ \label{sec:more-formal-sigma}
715
+
716
+ \index{type!dependent pair}%
717
+ \index{type!product}%
718
+
719
+ In \cref{sec:sigma-types}, we needed $\to$ and $\prdsym$ types in order to
720
+ define the introduction and elimination rules for $\smsym$; as with $\prdsym$, contexts allow us to state the rules for $\smsym$ independently.
721
+ Recall that the elimination rule for a positive type such as $\Sigma$ is called \emph{induction} and denoted by $\ind{}$.
722
+ %
723
+ \begin{mathparpagebreakable}
724
+ \def\premise{\oftp{\Gamma}{A}{\UU_i} \and \oftp{\Gamma,\tmtp xA}{B}{\UU_i}}
725
+ \inferrule*[right=$\Sigma$-\rform]
726
+ \premise
727
+ {\oftp\Gamma{\tsm{x:A} B}{\UU_i}}
728
+ \and
729
+ \inferrule*[right=$\Sigma$-\rintro]
730
+ {\oftp{\Gamma, \tmtp x A}{B}{\UU_i} \\
731
+ \oftp\Gamma{a}{A} \\ \oftp\Gamma{b}{B[a/x]}}
732
+ {\oftp\Gamma{\tup ab}{\tsm{x:A} B}}
733
+ \and
734
+ \inferrule*[right=$\Sigma$-\relim]
735
+ {\oftp{\Gamma, \tmtp z {\tsm{x:A} B}}{C}{\UU_i} \\
736
+ \oftp{\Gamma,\tmtp x A,\tmtp y B}{g}{C[\tup x y/z]} \\
737
+ \oftp\Gamma{p}{\tsm{x:A} B}}
738
+ {\oftp\Gamma{\ind{\tsm{x:A} B}(z.C,x.y.g,p)}{C[p/z]}}
739
+ \and
740
+ \inferrule*[right=$\Sigma$-\rcomp]
741
+ {\oftp{\Gamma, \tmtp z {\tsm{x:A} B}}{C}{\UU_i} \\
742
+ \oftp{\Gamma, \tmtp x A, \tmtp y B}{g}{C[\tup x y/z]} \\\\
743
+ \oftp\Gamma{a}{A} \\ \oftp\Gamma{b}{B[a/x]}}
744
+ {\jdeqtp\Gamma{\ind{\tsm{x:A} B}(z.C,x.y.g,\tup{a}{b})}{g[a,b/x,y]}{C[\tup {a} {b}/z]}}
745
+ \end{mathparpagebreakable}
746
+ %
747
+ The expression $\tsm{x:A} B$ binds free occurrences of $x$ in $B$. Furthermore, because
748
+ $\ind{\tsm{x:A} B}$ has some arguments with free variables beyond those in $\Gamma$,
749
+ we bind (following the variable names above) $z$ in $C$, and $x$ and $y$ in $g$.
750
+ These bindings are written as $z.C$ and $x.y.g$, to indicate the names of the bound
751
+ variables.
752
+ \index{variable!bound}%
753
+ In particular, we treat $\ind{\tsm{x:A} B}$ as a primitive,
754
+ two of whose arguments contain binders; this is superficially similar to, but
755
+ different from, $\ind{\tsm{x:A} B}$ being a function that takes functions as
756
+ arguments.
757
+
758
+ When $B$ does not contain free occurrences of $x$, we obtain as a special case
759
+ the cartesian product $A \times B \defeq \tsm{x:A} B$. We take this
760
+ as the \emph{definition} of the cartesian product.
761
+
762
+ Notice that we don't postulate a judgmental uniqueness principle for $\Sigma$-types, even
763
+ though we could have; see \cref{thm:eta-sigma} for a proof of the corresponding
764
+ propositional uniqueness principle.
765
+
766
+ \subsection{Coproduct types}
767
+
768
+ \index{type!coproduct}%
769
+
770
+ \begin{mathparpagebreakable}
771
+ \inferrule*[right=$+$-\rform]
772
+ {\oftp\Gamma{A}{\UU_i} \\ \oftp\Gamma{B}{\UU_i}}
773
+ {\oftp\Gamma{A+B}{\UU_i}}
774
+ \\
775
+ \inferrule*[right=$+$-\rintro${}_1$]
776
+ {\oftp\Gamma{A}{\UU_i} \\ \oftp\Gamma{B}{\UU_i} \\\\ \oftp\Gamma{a}{A}}
777
+ {\oftp\Gamma{\inl(a)}{A+B}}
778
+ \and
779
+ \inferrule*[right=$+$-\rintro${}_2$]
780
+ {\oftp\Gamma{A}{\UU_i} \\ \oftp\Gamma{B}{\UU_i} \\\\ \oftp\Gamma{b}{B}}
781
+ {\oftp\Gamma{\inr(b)}{A+B}}
782
+ \\
783
+ \inferrule*[right=$+$-\relim]
784
+ {\oftp{\Gamma,\tmtp z{(A+B)}}{C}{\UU_i} \\\\
785
+ \oftp{\Gamma,\tmtp xA}{c}{C[\inl(x)/z]} \\
786
+ \oftp{\Gamma,\tmtp yB}{d}{C[\inr(y)/z]} \\\\
787
+ \oftp\Gamma{e}{A+B}}
788
+ {\oftp\Gamma{\ind{A+B}(z.C,x.c,y.d,e)}{C[e/z]}}
789
+ \and
790
+ \inferrule*[right=$+$-\rcomp${}_1$]
791
+ {\oftp{\Gamma,\tmtp z{(A+B)}}{C}{\UU_i} \\
792
+ \oftp{\Gamma,\tmtp xA}{c}{C[\inl(x)/z]} \\
793
+ \oftp{\Gamma,\tmtp yB}{d}{C[\inr(y)/z]} \\\\
794
+ \oftp\Gamma{a}{A}}
795
+ {\jdeqtp\Gamma{\ind{A+B}(z.C,x.c,y.d,\inl(a))}{c[a/x]}{C[\inl(a)/z]}}
796
+ \and
797
+ \inferrule*[right=$+$-\rcomp${}_2$]
798
+ {\oftp{\Gamma,\tmtp z{(A+B)}}{C}{\UU_i} \\
799
+ \oftp{\Gamma,\tmtp xA}{c}{C[\inl(x)/z]} \\
800
+ \oftp{\Gamma,\tmtp yB}{d}{C[\inr(y)/z]} \\\\
801
+ \oftp\Gamma{b}{B}}
802
+ {\jdeqtp\Gamma{\ind{A+B}(z.C,x.c,y.d,\inr(b))}{d[b/y]}{C[\inr(b)/z]}}
803
+ \end{mathparpagebreakable}
804
+ %
805
+ In $\ind{A+B}$, $z$ is bound in $C$, $x$ is bound in $c$, and $y$ is bound in
806
+ $d$.
807
+
808
+ \subsection{The empty type \texorpdfstring{$\emptyt$}{0}}
809
+
810
+ \index{type!empty|(}%
811
+
812
+ \begin{mathparpagebreakable}
813
+ \inferrule*[right=$\emptyt$-\rform]
814
+ {\wfctx\Gamma}
815
+ {\oftp\Gamma\emptyt{\UU_i}}
816
+ \and
817
+ \inferrule*[right=$\emptyt$-\relim]
818
+ {\oftp{\Gamma,\tmtp x\emptyt}{C}{\UU_i} \\ \oftp\Gamma{a}{\emptyt}}
819
+ {\oftp\Gamma{\ind{\emptyt}(x.C,a)}{C[a/x]}}
820
+ \end{mathparpagebreakable}
821
+ %
822
+ In $\ind{\emptyt}$, $x$ is bound in $C$. The empty type has no introduction rule and no computation rule.
823
+
824
+ \index{type!empty|)}%
825
+
826
+ \subsection{The unit type \texorpdfstring{$\unit$}{1}}
827
+ \label{sec:more-formal-unit}
828
+
829
+ \index{type!unit|(}%
830
+
831
+ \begin{mathparpagebreakable}
832
+ \inferrule*[right=$\unit$-\rform]
833
+ {\wfctx\Gamma}
834
+ {\oftp\Gamma\unit{\UU_i}}
835
+ \and
836
+ \inferrule*[right=$\unit$-\rintro]
837
+ {\wfctx\Gamma}
838
+ {\oftp\Gamma{\ttt}{\unit}}
839
+ \and
840
+ \inferrule*[right=$\unit$-\relim]
841
+ {\oftp{\Gamma,\tmtp x\unit}{C}{\UU_i} \\
842
+ \oftp{\Gamma}{c}{C[\ttt/x]} \\
843
+ \oftp\Gamma{a}{\unit}}
844
+ {\oftp\Gamma{\ind{\unit}(x.C,c,a)}{C[a/x]}}
845
+ \and
846
+ \inferrule*[right=$\unit$-\rcomp]
847
+ {\oftp{\Gamma,\tmtp x\unit}{C}{\UU_i} \\
848
+ \oftp{\Gamma}{c}{C[\ttt/x]}}
849
+ {\jdeqtp\Gamma{\ind{\unit}(x.C,c,\ttt)}{c}{C[\ttt/x]}}
850
+ \end{mathparpagebreakable}
851
+ %
852
+ In $\ind{\unit}$ the variable $x$ is bound in $C$.
853
+
854
+ Notice that we do not postulate a judgmental uniqueness principle for the unit
855
+ type; see \cref{sec:finite-product-types} for a proof of the corresponding
856
+ propositional uniqueness statement.
857
+
858
+ \index{type!unit|)}%
859
+
860
+ \subsection{The natural number type}
861
+
862
+ \index{natural numbers|(}%
863
+
864
+ We give the rules for natural numbers, following \cref{sec:inductive-types}.
865
+
866
+ \begin{mathparpagebreakable}
867
+ \def\premise{
868
+ \oftp{\Gamma,\tmtp x{\N}}{C}{\UU_i} \\
869
+ \oftp\Gamma{c_0}{C[0/x]} \\
870
+ \oftp{\Gamma,\tmtp{x}\N,\tmtp y C}{c_s}{C[\suc(x)/x]}}
871
+ %
872
+ \inferrule*[right=$\N$-\rform]
873
+ {\wfctx\Gamma}
874
+ {\oftp\Gamma{\N}{\UU_i}}
875
+ \and
876
+ \inferrule*[right=$\N$-\rintro${}_1$]
877
+ {\wfctx\Gamma}
878
+ {\oftp\Gamma{0}{\N}}
879
+ \and
880
+ \inferrule*[right=$\N$-\rintro${}_2$]
881
+ {\oftp\Gamma{n}{\N}}
882
+ {\oftp\Gamma{\suc(n)}{\N}}
883
+ \and
884
+ \inferrule*[right=$\N$-\relim]
885
+ {\premise \\ \oftp\Gamma{n}{\N}}
886
+ {\oftp\Gamma{\ind{\N}(x.C,c_0,x.y.c_s,n)}{C[n/x]}}
887
+ \and
888
+ \inferrule*[right=$\N$-\rcomp${}_1$]
889
+ {\premise}
890
+ {\jdeqtp\Gamma{\ind{\N}(x.C,c_0,x.y.c_s,0)}{c_0}{C[0/x]}}
891
+ \and
892
+ \inferrule*[right=$\N$-\rcomp${}_2$]
893
+ {\premise \\ \oftp\Gamma{n}{\N}}
894
+ {\Gamma\vdash
895
+ {\begin{aligned}[t]
896
+ &\ind{\N}(x.C,c_0,x.y.c_s,\suc(n)) \\
897
+ &\quad \jdeq c_s[n,\ind{\N}(x.C,c_0,x.y.c_s,n)/x,y] : C[\suc(n)/x]
898
+ \end{aligned}}}
899
+ \end{mathparpagebreakable}
900
+ %
901
+ In $\ind{\N}$, $x$ is bound in $C$, and $x$ and $y$ are bound in $c_s$.
902
+
903
+ Other inductively defined types follow the same general scheme.
904
+
905
+ \index{natural numbers|)}%
906
+
907
+ \subsection{Identity types}
908
+
909
+ \label{sec:more-formal-identity}
910
+
911
+ \index{type!identity|(}%
912
+
913
+ The presentation here corresponds to the (unbased) path induction principle for identity types in
914
+ \cref{sec:identity-types}.
915
+
916
+ \begin{mathparpagebreakable}
917
+ \inferrule*[right=$\idsym$-\rform]
918
+ {\oftp\Gamma{A}{\UU_i} \\ \oftp\Gamma{a}{A} \\ \oftp\Gamma{b}{A}}
919
+ {\oftp\Gamma{\id[A]{a}{b}}{\UU_i}}
920
+ \and
921
+ \inferrule*[right=$\idsym$-\rintro]
922
+ {\oftp\Gamma{A}{\UU_i} \\ \oftp\Gamma{a}{A}}
923
+ {\oftp\Gamma{\refl a}{\id[A]aa}}
924
+ \and
925
+ \inferrule*[right=$\idsym$-\relim]
926
+ {\oftp{\Gamma,\tmtp xA,\tmtp yA,\tmtp p{\id[A]xy}}{C}{\UU_i} \\
927
+ \oftp{\Gamma,\tmtp zA}{c}{C[z,z,\refl z/x,y,p]} \\
928
+ \oftp\Gamma{a}{A} \\ \oftp\Gamma{b}{A} \\ \oftp\Gamma{p'}{\id[A]ab}}
929
+ {\oftp\Gamma{\indid{A}(x.y.p.C,z.c,a,b,p')}{C[a,b,p'/x,y,p]}}
930
+ \and
931
+ \inferrule*[right=$\idsym$-\rcomp]
932
+ {\oftp{\Gamma,\tmtp xA,\tmtp yA,\tmtp p{\id[A]xy}}{C}{\UU_i} \\
933
+ \oftp{\Gamma,\tmtp zA}{c}{C[z,z,\refl z/x,y,p]} \\
934
+ \oftp\Gamma{a}{A}}
935
+ {\jdeqtp\Gamma{\indid{A}(x.y.p.C,z.c,a,a,\refl a)}{c[a/z]}{C[a,a,\refl a/x,y,p]}}
936
+ \end{mathparpagebreakable}
937
+ %
938
+ In $\indid{A}$, $x$, $y$, and $p$ are bound in $C$, and $z$ is bound in
939
+ $c$.
940
+
941
+ \index{type!identity|)}%
942
+
943
+ \subsection{Definitions}
944
+
945
+ \index{definition}%
946
+
947
+ Although the rules we have listed so far allow us to construct everything we need directly, we
948
+ would still like to be able to use named constants, such as $\isequiv$, as a matter of
949
+ convenience. Informally, we can think of these constants simply as
950
+ abbreviations, but the situation is a bit subtler in the formalization.
951
+
952
+ For example, consider function composition, which takes $f:A\to B$ and
953
+ $g:B\to C$ to $g\circ f:A\to C$. Somewhat unexpectedly, to make this work formally, $\circ$ must take as arguments not only $f$ and $g$, but also their types $A$, $B$, $C$:
954
+ %
955
+ \begin{narrowmultline*}
956
+ {\circ} \defeq \lam{A:\UU_i}{B:\UU_i}{C:\UU_i}
957
+ \narrowbreak
958
+ \lam{g:B\to C}{f:A\to B}{x:A} g(f(x)).
959
+ \end{narrowmultline*}
960
+ %
961
+ From a practical perspective, we do not want to annotate each application of
962
+ $\circ$ with $A$, $B$ and $C$, as they are usually quite easily guessed from surrounding information. We would like to simply write $g\circ f$.
963
+ Then, strictly speaking, $g \circ f$ is not an abbreviation for $\lam{x : A} g(f(x))$,
964
+ because it involves additional \define{implicit arguments} which we want to suppress.
965
+ \index{implicit argument}
966
+
967
+ Inference of implicit arguments, typical ambiguity\index{typical ambiguity} (\cref{sec:universes}),
968
+ ensuring that symbols are only defined once, etc., are collectively called
969
+ \define{elaboration}. \index{elaboration, in type theory}
970
+ Elaboration must take place prior to checking a derivation, and is
971
+ thus not usually presented as part of the core type theory. However, it is
972
+ essentially impossible to use any implementation of type theory which does not
973
+ perform elaboration; see \cite{Coq,norell2007towards} for further discussion.
974
+
975
+ \section{Homotopy type theory}
976
+ \label{sec:hott-features}
977
+
978
+ In this section we state the additional axioms of homotopy type theory which distinguish it from standard Martin-L\"{o}f type theory: function extensionality, the
979
+ univalence axiom, and higher inductive types. We state them in the style
980
+ of the second presentation \cref{sec:syntax-more-formally}, although the first presentation \cref{sec:syntax-informally} could be used just as well.
981
+
982
+ \subsection{Function extensionality and univalence}
983
+
984
+ There are two basic ways of introducing axioms which do not introduce new syntax or judgmental equalities (function extensionality and univalence are of this form):
985
+ either add a primitive constant to inhabit the axiom, or prove all theorems which depend on the axiom by hypothesizing a variable that inhabits the axiom, cf.\ \cref{sec:axioms}.
986
+ While these are essentially equivalent, we opt for the former approach because we feel that the axioms of homotopy type theory are an essential part of the core theory.
987
+
988
+ \index{function extensionality}%
989
+ \cref{axiom:funext} is formalized by introduction of a constant $\funext$ which
990
+ asserts that $\happly$ is an equivalence:
991
+ %
992
+ \begin{mathparpagebreakable}
993
+ \inferrule*[right=$\Pi$-\textsc{ext}]
994
+ {\oftp\Gamma{f}{\tprd{x:A} B} \\
995
+ \oftp\Gamma{g}{\tprd{x:A} B}}
996
+ {\oftp\Gamma{\funext(f,g)}{\isequiv(\happly_{f,g})}}
997
+ \end{mathparpagebreakable}
998
+ %
999
+ The definitions of $\happly$ and $\isequiv$ can be found in~\eqref{eq:happly} and
1000
+ \cref{sec:concluding-remarks}, respectively.
1001
+
1002
+ \index{univalence axiom}%
1003
+ \cref{axiom:univalence} is formalized in a similar fashion, too:
1004
+ %
1005
+ \begin{mathparpagebreakable}
1006
+ \inferrule*[right=$\UU_i$-\textsc{univ}]
1007
+ {\oftp\Gamma{A}{\UU_i} \\
1008
+ \oftp\Gamma{B}{\UU_i}}
1009
+ {\oftp\Gamma{\univalence(A,B)}{\isequiv(\idtoeqv_{A,B})}}
1010
+ \end{mathparpagebreakable}
1011
+ %
1012
+ The definition of $\idtoeqv$ can be found in~\eqref{eq:uidtoeqv}.
1013
+
1014
+ \subsection{The circle}
1015
+
1016
+ \index{type!circle}%
1017
+
1018
+ Here we give an example of a basic higher inductive type; others follow the same
1019
+ general scheme, albeit with elaborations.
1020
+
1021
+ Note that the rules below do not precisely follow the pattern of the ordinary
1022
+ inductive types in \cref{sec:syntax-more-formally}: the rules refer to the
1023
+ notions of transport and functoriality of maps (\cref{sec:functors}), and the
1024
+ second computation rule is a propositional, not judgmental, equality. These
1025
+ differences are discussed in \cref{sec:dependent-paths}.
1026
+
1027
+ \begin{mathparpagebreakable}
1028
+ \inferrule*[right=$\Sn^1$-\rform]
1029
+ {\wfctx\Gamma}
1030
+ {\oftp\Gamma{\Sn^1}{\UU_i}}
1031
+ \and
1032
+ \inferrule*[right=$\Sn^1$-\rintro${}_1$]
1033
+ {\wfctx\Gamma}
1034
+ {\oftp\Gamma{\base}{\Sn^1}}
1035
+ \and
1036
+ \inferrule*[right=$\Sn^1$-\rintro${}_2$]
1037
+ {\wfctx\Gamma}
1038
+ {\oftp\Gamma{\lloop}{\id[\Sn^1]{\base}{\base}}}
1039
+ \and
1040
+ \inferrule*[right=$\Sn^1$-\relim]
1041
+ {\oftp{\Gamma,\tmtp x{\Sn^1}}{C}{\UU_i} \\
1042
+ \oftp{\Gamma}{b}{C[\base/x]} \\
1043
+ \oftp{\Gamma}{\ell}{\dpath C \lloop b b} \\
1044
+ \oftp\Gamma{p}{\Sn^1}}
1045
+ {\oftp\Gamma{\ind{\Sn^1}(x.C,b,\ell,p)}{C[p/x]}}
1046
+ \and
1047
+ \inferrule*[right=$\Sn^1$-\rcomp${}_1$]
1048
+ {\oftp{\Gamma,\tmtp x{\Sn^1}}{C}{\UU_i} \\
1049
+ \oftp{\Gamma}{b}{C[\base/x]} \\
1050
+ \oftp{\Gamma}{\ell}{\dpath C \lloop b b}}
1051
+ {\jdeqtp\Gamma{\ind{\Sn^1}(x.C,b,\ell,\base)}{b}{C[\base/x]}}
1052
+ \and
1053
+ \inferrule*[right=$\Sn^1$-\rcomp${}_2$]
1054
+ {\oftp{\Gamma,\tmtp x{\Sn^1}}{C}{\UU_i} \\
1055
+ \oftp{\Gamma}{b}{C[\base/x]} \\
1056
+ \oftp{\Gamma}{\ell}{\dpath C \lloop b b}}
1057
+ {\oftp\Gamma{\Sn^1\text{-}\mathsf{loopcomp}}
1058
+ {\id {\apd{(\lamu{y:\Sn^1} \ind{\Sn^1}(x.C,b,\ell,y))}{\lloop}} {\ell}}}
1059
+ \end{mathparpagebreakable}
1060
+ %
1061
+ In $\ind{\Sn^1}$, $x$ is bound in $C$. The notation ${\dpath C \lloop b b}$ for dependent paths was introduced in \cref{sec:dependent-paths}.
1062
+ \index{rules of type theory|)}%
1063
+
1064
+ \section{Basic metatheory}
1065
+ \index{metatheory|(}%
1066
+
1067
+ This section discusses the meta-theoretic properties of the type theory presented in
1068
+ \cref{sec:syntax-informally}, and similar results hold for \cref{sec:syntax-more-formally}. Figuring out which of these still hold when we add the features from \cref{sec:hott-features} quickly leads to open questions,\index{open!problem} as discussed at the end of this section.
1069
+
1070
+ Recall that \cref{sec:syntax-informally} defines the terms of type theory as
1071
+ an extension of the untyped $\lambda$-calculus. The $\lambda$-calculus
1072
+ has its own notion of computation, namely the computation rule\index{computation rule!for function types}:
1073
+ \[
1074
+ (\lam{x} t)(u) \defeq t[u/x].
1075
+ \]
1076
+ This rule, together with the defining equations for the defined constants form
1077
+ \emph{rewriting rules}\index{rewriting rule}\index{rule!rewriting} that determine reduction steps for a rewriting
1078
+ system. These steps yield a notion of computation in the sense that each rule
1079
+ has a natural direction: one simplifies $(\lam{x} t)(u)$ by evaluating the
1080
+ function at its argument.
1081
+
1082
+ Moreover, this system is \emph{confluent}\index{confluence}, that is, if $a$ simplifies in some
1083
+ number of steps to both $a'$ and $a''$, there is some $b$ to which both $a'$ and
1084
+ $a''$ eventually simplify. Thus we can define $t\conv u$ to mean that $t$ and
1085
+ $u$ simplify to the same term.
1086
+
1087
+ (The situation is similar in \cref{sec:syntax-more-formally}: Although there
1088
+ we presented the computation rules as undirected equalities $\jdeq$, we can give
1089
+ an operational semantics by saying that the application of an eliminator to an
1090
+ introductory form simplifies to its equal, not the other way around.)
1091
+
1092
+ Using standard techniques from type theory, it is possible to show that the system in \cref{sec:syntax-informally}
1093
+ has the following properties:
1094
+
1095
+ \begin{thm}\label{thm:conversion-preserves-typing}
1096
+ If $A : \UU$ and $A \conv A'$ then $A' : \UU$.
1097
+ If $t:A$ and $t \conv t'$ then $t':A$.
1098
+ \end{thm}
1099
+
1100
+ We say that a term is \define{normalizable}
1101
+ \indexdef{term!normalizable}%
1102
+ \index{normalization}%
1103
+ \indexdef{normalizable term}%
1104
+ (respectively, \define{strongly
1105
+ normalizable})
1106
+ \indexdef{term!strongly normalizable}%
1107
+ \index{normalization!strong}%
1108
+ \index{strong!normalization}%
1109
+ if some (respectively, every), sequence of rewriting steps from the term
1110
+ terminates.
1111
+
1112
+ \begin{thm}\label{thm:strong-normalization}
1113
+ If $A : \UU$ then $A$ is strongly normalizable.
1114
+ If $t:A$ then $A$ and $t$ are strongly normalizable.
1115
+ \end{thm}
1116
+
1117
+ We say that a term is in \define{normal form}
1118
+ \index{normal form}%
1119
+ \index{term!normal form of}%
1120
+ if it cannot be further
1121
+ simplified, and that a term is \define{closed}
1122
+ \index{closed!term}%
1123
+ \index{term!closed}%
1124
+ if no variable occurs freely in
1125
+ it. A closed normal type has to be a primitive type, i.e., of the form
1126
+ $c(\vec{v})$ for some primitive constant $c$ (where the list $\vec{v}$ of closed
1127
+ normal terms may be omitted if empty, for instance, as with $\N$). In fact, we
1128
+ can explicitly describe all normal forms:
1129
+
1130
+ \begin{lem}\label{lem:normal-forms}
1131
+ The terms in normal form can be described by the following syntax:
1132
+ %
1133
+ \begin{align*}
1134
+ v & \production k \mid \lam{x} v \mid c(\vec{v}) \mid f(\vec{v}), \\
1135
+ k &\production x \mid k(v) \mid f(\vec{v})(k),
1136
+ \end{align*}
1137
+ %
1138
+ where $f(\vec{v})$ represents a partial application of the defined function $f$.
1139
+ In particular, a type in normal form is of the form $k$ or $c(\vec{v})$.
1140
+ \end{lem}
1141
+
1142
+ \begin{thm}
1143
+ If $A$ is in normal form then the
1144
+ judgment $A : \UU$ is decidable. If $A : \UU$ and $t$ is in normal form then the judgment
1145
+ $t:A$ is decidable.
1146
+ \end{thm}
1147
+
1148
+ Logical consistency\index{consistency} (of the system in \cref{sec:syntax-informally}) follows
1149
+ immediately: if we had $a:\emptyt$ in the empty context, then by
1150
+ \cref{thm:conversion-preserves-typing,thm:strong-normalization}, $a$
1151
+ simplifies to a normal term $a':\emptyt$. But by
1152
+ \cref{lem:normal-forms} no such term exists.
1153
+
1154
+ \begin{cor}
1155
+ The system in \cref{sec:syntax-informally} is logically consistent.
1156
+ \end{cor}
1157
+
1158
+ Similarly, we have the \emph{canonicity}\indexdef{canonicity} property that if $a:\N$ in the empty
1159
+ context, then $a$ simplifies to a normal term $\suc^k(0)$ for some numeral $k$.
1160
+
1161
+ \begin{cor}
1162
+ The system in \cref{sec:syntax-informally} has the canonicity property.
1163
+ \end{cor}
1164
+
1165
+ Finally, if $a,A$ are in normal form, it is \emph{decidable} whether $a:A$; in
1166
+ other words, because type-checking amounts to verifying the correctness of a
1167
+ proof, this means we can always ``recognize a correct proof when we see one''.
1168
+
1169
+ \begin{cor}
1170
+ The property of being a proof in the system in \cref{sec:syntax-informally} is decidable.
1171
+ \end{cor}
1172
+
1173
+ \mentalpause
1174
+
1175
+ The above results do not apply to the extended system of homotopy type
1176
+ theory (i.e., the above system extended by \cref{sec:hott-features}), since
1177
+ occurrences of the univalence axiom and constructors of higher inductive types
1178
+ never simplify, breaking \cref{lem:normal-forms}. It is an open question\index{open!problem}
1179
+ whether one can simplify applications of these constants in order to restore
1180
+ canonicity. We also do not have a schema describing all permissible higher
1181
+ inductive types, nor are we certain how to correctly formulate their rules
1182
+ (e.g., whether the computation rules on higher constructors should be judgmental
1183
+ equalities).
1184
+
1185
+ The consistency\index{consistency} of Martin-L\"{o}f type theory extended with univalence and higher
1186
+ inductive types could be shown by inventing an appropriate normalization procedure, but currently
1187
+ the only proofs that these systems are consistent are via semantic models --- for
1188
+ univalence, a model in Kan\index{Kan complex} complexes due to Voevodsky \cite{klv:ssetmodel}, and
1189
+ for higher inductive types, a model due to Lumsdaine and Shulman \cite{ls:hits}.
1190
+
1191
+ Other metatheoretic issues, and a summary of our current results, are discussed
1192
+ in greater length in the ``Constructivity'' and ``Open problems'' sections of
1193
+ the introduction to this book.
1194
+
1195
+ \index{metatheory|)}%
1196
+
1197
+ \sectionNotes\label{subsec:general-remarks}
1198
+
1199
+ % This presentation is strongly inspired by two Martin-L\"of 1972 and 1973.
1200
+
1201
+ The system of rules with introduction (primitive constants) and elimination
1202
+ and computation rules (defined constant) is inspired by Gentzen natural
1203
+ deduction. The possibility of strengthening the elimination rule for
1204
+ existential quantification was indicated in \cite{howard:pat}. The
1205
+ strengthening of the axioms for disjunction appears in \cite{Martin-Lof-1972},
1206
+ and for absurdity elimination and identity type in \cite{Martin-Lof-1973}. The
1207
+ $W$-types were introduced in \cite{Martin-Lof-1979}. They generalize a notion
1208
+ of trees introduced by \cite{Tait-1968}.
1209
+ \index{Martin-L\"of}%
1210
+
1211
+ %inspired from unpublished work of Spector.
1212
+
1213
+ The generalized form of primitive recursion for natural numbers and ordinals
1214
+ appear in \cite{Hilbert-1925}. This motivated G\"odel's system $T$,
1215
+ \cite{Goedel-T-1958}, which was analyzed by \cite{Tait-1966}, who used,
1216
+ following \cite{Goedel-T-1958}, the terminology ``definitional equality'' for
1217
+ conversion: two terms are \emph{judgmentally equal} if they reduce to a
1218
+ common term by means of a sequence of applications of the reduction
1219
+ rules. This terminology was also used by de Bruijn \cite{deBruijn-1973} in his
1220
+ presentation of \emph{AUTOMATH}.\index{AUTOMATH}
1221
+
1222
+ Our second presentation comprises fairly standard presentation of
1223
+ intensional Martin-L\"{o}f type theory, with some additional features needed in
1224
+ homotopy type theory. Compared to a reference presentation of
1225
+ \cite{hofmann:syntax-and-semantics}, the type theory of this book has a few
1226
+ non-critical differences:
1227
+ %
1228
+ \begin{itemize}
1229
+ \item universes \`{a} la Russell, in the sense of
1230
+ \cite{martin-lof:bibliopolis}; and
1231
+ \item judgmental $\eta$ and function extensionality for $\Pi$ types;
1232
+ \end{itemize}
1233
+ and a few features essential for homotopy type theory:
1234
+ \begin{itemize}
1235
+ \item the univalence axiom; and
1236
+ \item higher inductive types.
1237
+ \end{itemize}
1238
+ %
1239
+ As a matter of convenience, the book primarily defines functions by induction
1240
+ using definition by \emph{pattern matching}.
1241
+ \index{pattern matching}%
1242
+ \index{definition!by pattern matching}%
1243
+ It is possible to formalize the
1244
+ notion of pattern matching, as done in \cref{sec:syntax-informally}. However, the
1245
+ standard type-theoretic presentation, adopted in \cref{sec:syntax-more-formally}, is to introduce a single \emph{dependent
1246
+ eliminator} for each type former, from which functions out of that type must be
1247
+ defined. This approach is easier to formalize both syntactically and
1248
+ semantically, as it amounts to the universal property of the type former.
1249
+ The two approaches are equivalent; see \cref{sec:pattern-matching} for a
1250
+ longer discussion.
1251
+
1252
+ \index{type theory!formal|)}%
1253
+ \index{formal!type theory|)}%
1254
+
1255
+
1256
+ %%% Local Variables:
1257
+ %%% mode: latex
1258
+ %%% TeX-master: "hott-online"
1259
+ %%% End:
front.tex ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %%%%%%%%%%%%%%%%%%%% Cover page %%%%%%%%%%%%%%%%%%%%
2
+
3
+ \newgeometry{noheadfoot,bindingoffset=-5pt,top=0pt,bottom=0pt,inner=0pt,outer=0pt}%
4
+ \ifOPTcover
5
+ \setcounter{page}{-1} % Otherwise we end up having two pages numbered 1
6
+ \newlength{\coverheight}
7
+ \setlength{\coverheight}{\OPTcoverheight}
8
+ \newlength{\coverwidth}
9
+ \setlength{\coverwidth}{\OPTcoverwidth}
10
+ \input{frontpage}
11
+ \ThisLLCornerWallPaper{1.1}{\OPTfrontimage}
12
+ \pagecolor{covercolor}
13
+ \frontpage
14
+ \newpage
15
+ % Reset page counter, cover page does not count
16
+ \ifpdf
17
+ \nopagecolor
18
+ \else
19
+ \pagecolor{white}
20
+ \fi
21
+ \cleartooddpage
22
+ \else
23
+ \fi
24
+
25
+ %%%%%%%%%%%%%%%%%%%% Bastard page %%%%%%%%%%%%%%%%%%%%
26
+ \ifOPTbastard
27
+ \cleartooddpage
28
+ \hbox{}
29
+ \vspace{0.2\textwidth}
30
+ {\centering
31
+ \makebox[\OPTbastardwidth][s]{
32
+ \fontsize{\OPTbastardtitlefont}{\OPTbastardtitlefont}\fontshape{n}\selectfont%
33
+ \textbf{Homotopy Type Theory}}\par
34
+ \vspace*{\OPTbastardtitleskip}
35
+ \makebox[\OPTbastardwidth][s]{
36
+ \fontsize{\OPTbastardsubtitlefont}{\OPTbastardsubtitlefont}\fontshape{n}\selectfont%
37
+ \textit{Univalent Foundations of Mathematics}}\par
38
+ }
39
+ \else
40
+ \fi
41
+
42
+ %%%%%%%%%%%%%%%%%%%% Title page %%%%%%%%%%%%%%%%%%%%
43
+ \cleartooddpage
44
+ \hbox{}\vfill
45
+ {\centering
46
+ \makebox[\OPTtitlewidth][s]{\fontsize{\OPTtitletitlefont}{\OPTtitletitlefont}\fontseries{b}\selectfont%
47
+ Homotopy Type Theory}\par
48
+ \vspace*{\OPTtitletitleskip}
49
+ \makebox[\OPTtitlewidth][s]{\fontsize{\OPTtitlesubtitlefont}{\OPTtitlesubtitlefont}\fontshape{it}\selectfont%
50
+ Univalent Foundations of Mathematics}\par
51
+ \vspace*{\OPTtitleskip}
52
+ {\fontsize{\OPTtitleauthorfont}{\OPTtitleauthorfont}\fontshape{n}\selectfont%
53
+ The Univalent Foundations Program\par
54
+ \vspace*{\OPTtitleauthorskip}
55
+ Institute for Advanced Study\par
56
+ }
57
+ \vspace*{\OPTtitleskip}
58
+ \vspace*{\OPTtitleskip}
59
+ \includegraphics[width=\OPTtitlewidth]{\OPThalftorus}\par
60
+ }
61
+
62
+ \vfill
63
+ \hbox{}
64
+
65
+ \clearpage
66
+ %%% Restore page style
67
+ \restoregeometry
68
+
69
+ %%%%%%%%%%%%%%%%%%%% Copyright page %%%%%%%%%%%%%%%%%%%%
70
+ \hbox{}
71
+ \vfill
72
+ \input{version.tex}
73
+ {\small
74
+ \noindent
75
+ \emph{``Homotopy Type Theory: Univalent Foundations of Mathematics''}\\
76
+ \copyright\ 2013 The Univalent Foundations Program
77
+
78
+ \medskip
79
+ \noindent
80
+ Book version: \texttt{\OPTversion}
81
+
82
+ \medskip
83
+ \noindent
84
+ MSC 2010 classification:
85
+ \texttt{03-02},
86
+ \texttt{55-02},
87
+ \texttt{03B15}
88
+
89
+ \bigskip
90
+ \footnotesize
91
+
92
+ \noindent
93
+ This work is licensed under the
94
+ \textbf{\emph{Creative Commons Attribution-ShareAlike 3.0 Unported License.}}
95
+ %
96
+ To view a copy of this license, visit
97
+ \url{http://creativecommons.org/licenses/by-sa/3.0/}.
98
+
99
+ \bigskip
100
+
101
+ \noindent
102
+ This book is freely available at \url{http://homotopytypetheory.org/book/}.
103
+
104
+ \bigskip
105
+
106
+ \noindent
107
+ \emph{\textbf{\small Acknowledgment}}
108
+
109
+ \medskip
110
+
111
+ \noindent
112
+ Apart from the generous support from the Institute for Advanced Study, some contributors
113
+ to the book were partially or fully supported by the following agencies and grants:
114
+ %
115
+ \begin{itemize}
116
+ \item Association of Members of the Institute for Advanced Study: a grant to the Institute for Advanced Study % Dan Grayson
117
+ % SLOVENIA
118
+ \item Agencija za raziskovalno dejavnost Republike Slovenije: % Andrej's Slovenian agency
119
+ \href{http://www.sicris.si/search/prg.aspx?id=6120}{P1--0294},
120
+ \href{http://www.sicris.si/search/prj.aspx?id=7109}{N1--0011}.
121
+
122
+ \item Air Force Office of Scientific Research:
123
+ FA9550-11-1-0143, and % Steve's ASFOR
124
+ FA9550-12-1-0370. % Bob's ASFOR
125
+ {
126
+ \setlength{\parskip}{0pt}
127
+ \begin{quote}
128
+ \noindent\scriptsize
129
+ This material is based in part upon work supported by the AFOSR under the above awards.
130
+ Any opinions, findings, and conclusions or recommendations expressed in this publication are those of the author(s) and do not necessarily reflect the views of the AFOSR.
131
+ \end{quote}
132
+ }
133
+
134
+ \item Engineering and Physical Sciences Research Council: % Thorsten and students
135
+ \href{http://gow.epsrc.ac.uk/NGBOViewGrant.aspx?GrantRef=EP/G034109/1}{EP/G034109/1}, % Reusability and dependent types
136
+ \href{http://gow.epsrc.ac.uk/NGBOViewGrant.aspx?GrantRef=EP/G03298X/1}{EP/G03298X/1}. % Theory and Application of Induction Recursion
137
+
138
+ \item European Union's 7th Framework Programme under grant agreement nr.\ 243847 (%
139
+ \href{http://wiki.portal.chalmers.se/cse/pmwiki.php/ForMath/ForMath/}{ForMath}). %% several Europeans, via Bas
140
+
141
+ \item National Science Foundation:
142
+ \href{http://www.nsf.gov/awardsearch/showAward.do?AwardNumber=1001191}{DMS-1001191}, %% Steve's NSF, including Chris and Kristina
143
+ \href{http://www.nsf.gov/awardsearch/showAward.do?AwardNumber=1100938}{DMS-1100938}, %% Vladimir's NSF
144
+ \href{http://www.nsf.gov/awardsearch/showAward.do?AwardNumber=1116703}{CCF-1116703}, %% Foundations and Applications of Higher-Dimensional Directed Type Theory
145
+ and
146
+ \href{http://www.nsf.gov/awardsearch/showAward.do?AwardNumber=1128155}{DMS-1128155}. %% IAS support for Mike Shulman, copied from our %% paper by Dan Licata
147
+ {
148
+ \setlength{\itemsep}{0pt}
149
+ \begin{quote}
150
+ \noindent\scriptsize
151
+ This material is based in part upon work supported by the
152
+ National Science Foundation under the above awards. Any opinions,
153
+ findings, and conclusions or recommendations expressed in this
154
+ material are those of the author(s) and do not necessarily reflect the
155
+ views of the National Science Foundation.
156
+ \end{quote}
157
+ }
158
+ \item The Simonyi Fund: a grant to the Institute for Advanced Study %% Dan Grayson
159
+ \end{itemize}
160
+
161
+
162
+ }
163
+ \cleartooddpage
164
+
165
+ %%% Local Variables:
166
+ %%% mode: latex
167
+ %%% TeX-master: "hott-online"
168
+ %%% End:
frontpage.tex ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \newcommand{\frontpage}{
2
+ \begin{minipage}[b][\coverheight][c]{\coverwidth}
3
+ \hbox{}\hfill
4
+ \begin{minipage}[b][\coverheight][t]{0.83\coverwidth}
5
+ \color{covertext}
6
+ \vspace{\OPTtopskip}
7
+ {\fontsize{\OPTcovertitlefont}{\OPTcovertitlefont}\fontseries{b}\selectfont%
8
+ \hfill Homotopy\par \hfill Type Theory}\par
9
+ \vspace*{\OPTcovertitleskip}
10
+ {\fontsize{\OPTcoversubtitlefont}{\OPTcoversubtitlefont}\fontshape{it}\selectfont
11
+ \hfill Univalent Foundations of Mathematics}
12
+
13
+ \vfill
14
+
15
+ {\fontsize{\OPTcoverauthorfont}{\OPTcoverauthorfont}\fontseries{b}\fontshape{sc}\selectfont
16
+
17
+ \hfill The Univalent Foundations Program
18
+ \par
19
+ \vspace*{\OPTcoverauthorskip}
20
+ \hfill Institute for Advanced Study\par
21
+
22
+ \vspace*{\OPTbotskip}
23
+ }
24
+
25
+ \end{minipage}\hfill\hbox{}
26
+ \end{minipage}
27
+ }
generate-nightlies ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ if [ $# -ne 2 ]; then
4
+ echo "Usage: ${0} www-dir wiki-dir"
5
+ exit 1
6
+ fi
7
+
8
+ WWW_DIR=$1
9
+ WIKI_DIR=$2
10
+
11
+ VERSION_MARKER="$(git describe --always --long)"
12
+ VERSION="${VERSION_MARKER#first-edition-}"
13
+ DATE="$(date +"%B %-d, %Y")"
14
+
15
+ function generate_www () {
16
+ rm -rf -- "${WWW_DIR}" && mkdir -p -- "${WWW_DIR}" || exit 1
17
+ PDF_TARGETS=(hott-online hott-ebook hott-letter hott-a4 errata)
18
+ for TARGET in "${PDF_TARGETS[@]}"; do
19
+ echo "::group::Generating ${WWW_DIR}/$TARGET-$VERSION.pdf"
20
+ if [ ! -f "$TARGET.pdf" ]; then
21
+ make "${TARGET}.pdf" || exit 1
22
+ fi
23
+ echo "Copying $TARGET.pdf to ${WWW_DIR}/$TARGET-$VERSION.pdf"
24
+ cp -f "$TARGET.pdf" "${WWW_DIR}/$TARGET-$VERSION.pdf" || exit 1
25
+ echo "::endgroup::"
26
+ echo "::group::Generating ${WWW_DIR}/${TARGET}.pdf.html"
27
+ tee "${WWW_DIR}/${TARGET}.pdf.html" <<EOF
28
+ <!doctype html><title>$TARGET-$VERSION.pdf</title><meta http-equiv=refresh content="0; url=$TARGET-$VERSION.pdf">
29
+ EOF
30
+ echo "::endgroup::"
31
+ done
32
+ }
33
+
34
+ function generate_wiki () {
35
+ rm -rf -- "${WIKI_DIR}" && mkdir -p -- "${WIKI_DIR}" || exit 1
36
+ echo "::group::Generating ${WIKI_DIR}/Home.md"
37
+ tee "${WIKI_DIR}/Home.md" <<EOF
38
+ This wiki is not in use, except that it hosts the [[Nightly builds]] page. There is a general wiki for homotopy type theory [here](http://ncatlab.org/homotopytypetheory).
39
+ EOF
40
+ echo "::endgroup::"
41
+ echo "::group::Generating ${WIKI_DIR}/Nightly-Builds.md"
42
+ tee "${WIKI_DIR}/Nightly-Builds.md" <<EOF
43
+ <!--- This page is auto-generated. To update this page; update the build-nightlies script. --->
44
+ Below are links to "nightly builds" of the book, incorporating fixes and improvements that have not yet been incorporated into the "released version" that can be found on the [official book web site](http://homotopytypetheory.org/book/). The nightly builds are updated automatically; their most recent update was on $DATE and their version marker is "$VERSION_MARKER".
45
+
46
+ * [PDF for on-screen viewing](//hott.github.io/book/hott-online-$VERSION.pdf)
47
+ * [PDF for e-book readers](//hott.github.io/book/hott-ebook-$VERSION.pdf)
48
+ * [PDF for printing on letter paper](//hott.github.io/book/hott-letter-$VERSION.pdf)
49
+ * [PDF for printing on A4 paper](//hott.github.io/book/hott-a4-$VERSION.pdf)
50
+ * [errata for previous versions](//hott.github.io/book/errata-$VERSION.pdf)
51
+ EOF
52
+ echo "::endgroup::"
53
+ }
54
+
55
+ generate_www
56
+ generate_wiki
halpha.bst ADDED
@@ -0,0 +1,1281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % halpha: adds eprint field (www-admin@xxx.lanl.gov)
2
+ % an extension of:
3
+ % BibTeX standard bibliography style `alpha'
4
+ % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
5
+ % Copyright (C) 1985, all rights reserved.
6
+ % Copying of this file is authorized only if either
7
+ % (1) you make absolutely no changes to your copy, including name, or
8
+ % (2) if you do make changes, you name it something other than
9
+ % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
10
+ % This restriction helps ensure that all standard styles are identical.
11
+ % The file btxbst.doc has the documentation for this style.
12
+
13
+ ENTRY
14
+ { address
15
+ author
16
+ booktitle
17
+ chapter
18
+ edition
19
+ editor
20
+ eprint
21
+ howpublished
22
+ institution
23
+ journal
24
+ key
25
+ month
26
+ note
27
+ number
28
+ organization
29
+ pages
30
+ publisher
31
+ school
32
+ series
33
+ title
34
+ type
35
+ volume
36
+ year
37
+ }
38
+ {}
39
+ { label extra.label sort.label }
40
+
41
+ INTEGERS { output.state before.all mid.sentence after.sentence after.block }
42
+
43
+ FUNCTION {init.state.consts}
44
+ { #0 'before.all :=
45
+ #1 'mid.sentence :=
46
+ #2 'after.sentence :=
47
+ #3 'after.block :=
48
+ }
49
+
50
+ STRINGS { s t }
51
+
52
+ FUNCTION {output.nonnull}
53
+ { 's :=
54
+ output.state mid.sentence =
55
+ { ", " * write$ }
56
+ { output.state after.block =
57
+ { add.period$ write$
58
+ newline$
59
+ "\newblock " write$
60
+ }
61
+ { output.state before.all =
62
+ 'write$
63
+ { add.period$ " " * write$ }
64
+ if$
65
+ }
66
+ if$
67
+ mid.sentence 'output.state :=
68
+ }
69
+ if$
70
+ s
71
+ }
72
+
73
+ FUNCTION {output}
74
+ { duplicate$ empty$
75
+ 'pop$
76
+ 'output.nonnull
77
+ if$
78
+ }
79
+
80
+ FUNCTION {output.check}
81
+ { 't :=
82
+ duplicate$ empty$
83
+ { pop$ "empty " t * " in " * cite$ * warning$ }
84
+ 'output.nonnull
85
+ if$
86
+ }
87
+
88
+ FUNCTION {output.bibitem}
89
+ { newline$
90
+ "\bibitem[" write$
91
+ label write$
92
+ "]{" write$
93
+ cite$ write$
94
+ "}" write$
95
+ newline$
96
+ ""
97
+ before.all 'output.state :=
98
+ }
99
+
100
+ FUNCTION {fin.entry}
101
+ { add.period$
102
+ write$
103
+ newline$
104
+ }
105
+
106
+ FUNCTION {new.block}
107
+ { output.state before.all =
108
+ 'skip$
109
+ { after.block 'output.state := }
110
+ if$
111
+ }
112
+
113
+ FUNCTION {new.sentence}
114
+ { output.state after.block =
115
+ 'skip$
116
+ { output.state before.all =
117
+ 'skip$
118
+ { after.sentence 'output.state := }
119
+ if$
120
+ }
121
+ if$
122
+ }
123
+
124
+ FUNCTION {not}
125
+ { { #0 }
126
+ { #1 }
127
+ if$
128
+ }
129
+
130
+ FUNCTION {and}
131
+ { 'skip$
132
+ { pop$ #0 }
133
+ if$
134
+ }
135
+
136
+ FUNCTION {or}
137
+ { { pop$ #1 }
138
+ 'skip$
139
+ if$
140
+ }
141
+
142
+ FUNCTION {new.block.checka}
143
+ { empty$
144
+ 'skip$
145
+ 'new.block
146
+ if$
147
+ }
148
+
149
+ FUNCTION {new.block.checkb}
150
+ { empty$
151
+ swap$ empty$
152
+ and
153
+ 'skip$
154
+ 'new.block
155
+ if$
156
+ }
157
+
158
+ FUNCTION {new.sentence.checka}
159
+ { empty$
160
+ 'skip$
161
+ 'new.sentence
162
+ if$
163
+ }
164
+
165
+ FUNCTION {new.sentence.checkb}
166
+ { empty$
167
+ swap$ empty$
168
+ and
169
+ 'skip$
170
+ 'new.sentence
171
+ if$
172
+ }
173
+
174
+ FUNCTION {field.or.null}
175
+ { duplicate$ empty$
176
+ { pop$ "" }
177
+ 'skip$
178
+ if$
179
+ }
180
+
181
+ FUNCTION {emphasize}
182
+ { duplicate$ empty$
183
+ { pop$ "" }
184
+ { "{\em " swap$ * "}" * }
185
+ if$
186
+ }
187
+
188
+ INTEGERS { nameptr namesleft numnames }
189
+
190
+ FUNCTION {format.names}
191
+ { 's :=
192
+ #1 'nameptr :=
193
+ s num.names$ 'numnames :=
194
+ numnames 'namesleft :=
195
+ { namesleft #0 > }
196
+ { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
197
+ nameptr #1 >
198
+ { namesleft #1 >
199
+ { ", " * t * }
200
+ { numnames #2 >
201
+ { "," * }
202
+ 'skip$
203
+ if$
204
+ t "others" =
205
+ { " et~al." * }
206
+ { " and " * t * }
207
+ if$
208
+ }
209
+ if$
210
+ }
211
+ 't
212
+ if$
213
+ nameptr #1 + 'nameptr :=
214
+ namesleft #1 - 'namesleft :=
215
+ }
216
+ while$
217
+ }
218
+
219
+ FUNCTION {format.authors}
220
+ { author empty$
221
+ { "" }
222
+ { author format.names }
223
+ if$
224
+ }
225
+
226
+ FUNCTION {format.editors}
227
+ { editor empty$
228
+ { "" }
229
+ { editor format.names
230
+ editor num.names$ #1 >
231
+ { ", editors" * }
232
+ { ", editor" * }
233
+ if$
234
+ }
235
+ if$
236
+ }
237
+
238
+ FUNCTION {format.title}
239
+ { title empty$
240
+ { "" }
241
+ { title "t" change.case$ }
242
+ if$
243
+ }
244
+
245
+ FUNCTION {format.eprint}
246
+ { eprint empty$
247
+ { "" }
248
+ { eprint }
249
+ if$
250
+ }
251
+
252
+
253
+ FUNCTION {n.dashify}
254
+ { 't :=
255
+ ""
256
+ { t empty$ not }
257
+ { t #1 #1 substring$ "-" =
258
+ { t #1 #2 substring$ "--" = not
259
+ { "--" *
260
+ t #2 global.max$ substring$ 't :=
261
+ }
262
+ { { t #1 #1 substring$ "-" = }
263
+ { "-" *
264
+ t #2 global.max$ substring$ 't :=
265
+ }
266
+ while$
267
+ }
268
+ if$
269
+ }
270
+ { t #1 #1 substring$ *
271
+ t #2 global.max$ substring$ 't :=
272
+ }
273
+ if$
274
+ }
275
+ while$
276
+ }
277
+
278
+ FUNCTION {format.date}
279
+ { year empty$
280
+ { month empty$
281
+ { "" }
282
+ { "there's a month but no year in " cite$ * warning$
283
+ month
284
+ }
285
+ if$
286
+ }
287
+ { month empty$
288
+ 'year
289
+ { month " " * year * }
290
+ if$
291
+ }
292
+ if$
293
+ }
294
+
295
+ FUNCTION {format.btitle}
296
+ { title emphasize
297
+ }
298
+
299
+ FUNCTION {tie.or.space.connect}
300
+ { duplicate$ text.length$ #3 <
301
+ { "~" }
302
+ { " " }
303
+ if$
304
+ swap$ * *
305
+ }
306
+
307
+ FUNCTION {either.or.check}
308
+ { empty$
309
+ 'pop$
310
+ { "can't use both " swap$ * " fields in " * cite$ * warning$ }
311
+ if$
312
+ }
313
+
314
+ FUNCTION {format.bvolume}
315
+ { volume empty$
316
+ { "" }
317
+ { "volume" volume tie.or.space.connect
318
+ series empty$
319
+ 'skip$
320
+ { " of " * series emphasize * }
321
+ if$
322
+ "volume and number" number either.or.check
323
+ }
324
+ if$
325
+ }
326
+
327
+ FUNCTION {format.number.series}
328
+ { volume empty$
329
+ { number empty$
330
+ { series field.or.null }
331
+ { output.state mid.sentence =
332
+ { "number" }
333
+ { "Number" }
334
+ if$
335
+ number tie.or.space.connect
336
+ series empty$
337
+ { "there's a number but no series in " cite$ * warning$ }
338
+ { " in " * series * }
339
+ if$
340
+ }
341
+ if$
342
+ }
343
+ { "" }
344
+ if$
345
+ }
346
+
347
+ FUNCTION {format.edition}
348
+ { edition empty$
349
+ { "" }
350
+ { output.state mid.sentence =
351
+ { edition "l" change.case$ " edition" * }
352
+ { edition "t" change.case$ " edition" * }
353
+ if$
354
+ }
355
+ if$
356
+ }
357
+
358
+ INTEGERS { multiresult }
359
+
360
+ FUNCTION {multi.page.check}
361
+ { 't :=
362
+ #0 'multiresult :=
363
+ { multiresult not
364
+ t empty$ not
365
+ and
366
+ }
367
+ { t #1 #1 substring$
368
+ duplicate$ "-" =
369
+ swap$ duplicate$ "," =
370
+ swap$ "+" =
371
+ or or
372
+ { #1 'multiresult := }
373
+ { t #2 global.max$ substring$ 't := }
374
+ if$
375
+ }
376
+ while$
377
+ multiresult
378
+ }
379
+
380
+ FUNCTION {format.pages}
381
+ { pages empty$
382
+ { "" }
383
+ { pages multi.page.check
384
+ { "pages" pages n.dashify tie.or.space.connect }
385
+ { "page" pages tie.or.space.connect }
386
+ if$
387
+ }
388
+ if$
389
+ }
390
+
391
+ FUNCTION {format.vol.num.pages}
392
+ { volume field.or.null
393
+ number empty$
394
+ 'skip$
395
+ { "(" number * ")" * *
396
+ volume empty$
397
+ { "there's a number but no volume in " cite$ * warning$ }
398
+ 'skip$
399
+ if$
400
+ }
401
+ if$
402
+ pages empty$
403
+ 'skip$
404
+ { duplicate$ empty$
405
+ { pop$ format.pages }
406
+ { ":" * pages n.dashify * }
407
+ if$
408
+ }
409
+ if$
410
+ }
411
+
412
+ FUNCTION {format.chapter.pages}
413
+ { chapter empty$
414
+ 'format.pages
415
+ { type empty$
416
+ { "chapter" }
417
+ { type "l" change.case$ }
418
+ if$
419
+ chapter tie.or.space.connect
420
+ pages empty$
421
+ 'skip$
422
+ { ", " * format.pages * }
423
+ if$
424
+ }
425
+ if$
426
+ }
427
+
428
+ FUNCTION {format.in.ed.booktitle}
429
+ { booktitle empty$
430
+ { "" }
431
+ { editor empty$
432
+ { "In " booktitle emphasize * }
433
+ { "In " format.editors * ", " * booktitle emphasize * }
434
+ if$
435
+ }
436
+ if$
437
+ }
438
+
439
+ FUNCTION {empty.misc.check}
440
+ { author empty$ title empty$ howpublished empty$
441
+ month empty$ year empty$ note empty$
442
+ and and and and and
443
+ key empty$ not and
444
+ { "all relevant fields are empty in " cite$ * warning$ }
445
+ 'skip$
446
+ if$
447
+ }
448
+
449
+ FUNCTION {format.thesis.type}
450
+ { type empty$
451
+ 'skip$
452
+ { pop$
453
+ type "t" change.case$
454
+ }
455
+ if$
456
+ }
457
+
458
+ FUNCTION {format.tr.number}
459
+ { type empty$
460
+ { "Technical Report" }
461
+ 'type
462
+ if$
463
+ number empty$
464
+ { "t" change.case$ }
465
+ { number tie.or.space.connect }
466
+ if$
467
+ }
468
+
469
+ FUNCTION {format.article.crossref}
470
+ { key empty$
471
+ { journal empty$
472
+ { "need key or journal for " cite$ * " to crossref " * crossref *
473
+ warning$
474
+ ""
475
+ }
476
+ { "In {\em " journal * "\/}" * }
477
+ if$
478
+ }
479
+ { "In " key * }
480
+ if$
481
+ " \cite{" * crossref * "}" *
482
+ }
483
+
484
+ FUNCTION {format.crossref.editor}
485
+ { editor #1 "{vv~}{ll}" format.name$
486
+ editor num.names$ duplicate$
487
+ #2 >
488
+ { pop$ " et~al." * }
489
+ { #2 <
490
+ 'skip$
491
+ { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
492
+ { " et~al." * }
493
+ { " and " * editor #2 "{vv~}{ll}" format.name$ * }
494
+ if$
495
+ }
496
+ if$
497
+ }
498
+ if$
499
+ }
500
+
501
+ FUNCTION {format.book.crossref}
502
+ { volume empty$
503
+ { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
504
+ "In "
505
+ }
506
+ { "Volume" volume tie.or.space.connect
507
+ " of " *
508
+ }
509
+ if$
510
+ editor empty$
511
+ editor field.or.null author field.or.null =
512
+ or
513
+ { key empty$
514
+ { series empty$
515
+ { "need editor, key, or series for " cite$ * " to crossref " *
516
+ crossref * warning$
517
+ "" *
518
+ }
519
+ { "{\em " * series * "\/}" * }
520
+ if$
521
+ }
522
+ { key * }
523
+ if$
524
+ }
525
+ { format.crossref.editor * }
526
+ if$
527
+ " \cite{" * crossref * "}" *
528
+ }
529
+
530
+ FUNCTION {format.incoll.inproc.crossref}
531
+ { editor empty$
532
+ editor field.or.null author field.or.null =
533
+ or
534
+ { key empty$
535
+ { booktitle empty$
536
+ { "need editor, key, or booktitle for " cite$ * " to crossref " *
537
+ crossref * warning$
538
+ ""
539
+ }
540
+ { "In {\em " booktitle * "\/}" * }
541
+ if$
542
+ }
543
+ { "In " key * }
544
+ if$
545
+ }
546
+ { "In " format.crossref.editor * }
547
+ if$
548
+ " \cite{" * crossref * "}" *
549
+ }
550
+
551
+ FUNCTION {article}
552
+ { output.bibitem
553
+ format.authors "author" output.check
554
+ new.block
555
+ format.title "title" output.check
556
+ new.block
557
+ crossref missing$
558
+ { journal emphasize "journal" output.check
559
+ format.vol.num.pages output
560
+ format.date "year" output.check
561
+ }
562
+ { format.article.crossref output.nonnull
563
+ format.pages output
564
+ }
565
+ if$
566
+ format.eprint output
567
+ new.block
568
+ note output
569
+ fin.entry
570
+ }
571
+
572
+ FUNCTION {book}
573
+ { output.bibitem
574
+ author empty$
575
+ { format.editors "author and editor" output.check }
576
+ { format.authors output.nonnull
577
+ crossref missing$
578
+ { "author and editor" editor either.or.check }
579
+ 'skip$
580
+ if$
581
+ }
582
+ if$
583
+ new.block
584
+ format.btitle "title" output.check
585
+ crossref missing$
586
+ { format.bvolume output
587
+ new.block
588
+ format.number.series output
589
+ new.sentence
590
+ publisher "publisher" output.check
591
+ address output
592
+ }
593
+ { new.block
594
+ format.book.crossref output.nonnull
595
+ }
596
+ if$
597
+ format.edition output
598
+ format.date "year" output.check
599
+ format.eprint output
600
+ new.block
601
+ note output
602
+ fin.entry
603
+ }
604
+
605
+ FUNCTION {booklet}
606
+ { output.bibitem
607
+ format.authors output
608
+ new.block
609
+ format.title "title" output.check
610
+ howpublished address new.block.checkb
611
+ howpublished output
612
+ address output
613
+ format.date output
614
+ format.eprint output
615
+ new.block
616
+ note output
617
+ fin.entry
618
+ }
619
+
620
+ FUNCTION {inbook}
621
+ { output.bibitem
622
+ author empty$
623
+ { format.editors "author and editor" output.check }
624
+ { format.authors output.nonnull
625
+ crossref missing$
626
+ { "author and editor" editor either.or.check }
627
+ 'skip$
628
+ if$
629
+ }
630
+ if$
631
+ new.block
632
+ format.btitle "title" output.check
633
+ crossref missing$
634
+ { format.bvolume output
635
+ format.chapter.pages "chapter and pages" output.check
636
+ new.block
637
+ format.number.series output
638
+ new.sentence
639
+ publisher "publisher" output.check
640
+ address output
641
+ }
642
+ { format.chapter.pages "chapter and pages" output.check
643
+ new.block
644
+ format.book.crossref output.nonnull
645
+ }
646
+ if$
647
+ format.edition output
648
+ format.date "year" output.check
649
+ format.eprint output
650
+ new.block
651
+ note output
652
+ fin.entry
653
+ }
654
+
655
+ FUNCTION {incollection}
656
+ { output.bibitem
657
+ format.authors "author" output.check
658
+ new.block
659
+ format.title "title" output.check
660
+ new.block
661
+ crossref missing$
662
+ { format.in.ed.booktitle "booktitle" output.check
663
+ format.bvolume output
664
+ format.number.series output
665
+ format.chapter.pages output
666
+ new.sentence
667
+ publisher "publisher" output.check
668
+ address output
669
+ format.edition output
670
+ format.date "year" output.check
671
+ }
672
+ { format.incoll.inproc.crossref output.nonnull
673
+ format.chapter.pages output
674
+ }
675
+ if$
676
+ format.eprint output
677
+ new.block
678
+ note output
679
+ fin.entry
680
+ }
681
+
682
+ FUNCTION {inproceedings}
683
+ { output.bibitem
684
+ format.authors "author" output.check
685
+ new.block
686
+ format.title "title" output.check
687
+ new.block
688
+ crossref missing$
689
+ { format.in.ed.booktitle "booktitle" output.check
690
+ format.bvolume output
691
+ format.number.series output
692
+ format.pages output
693
+ address empty$
694
+ { organization publisher new.sentence.checkb
695
+ organization output
696
+ publisher output
697
+ format.date "year" output.check
698
+ }
699
+ { address output.nonnull
700
+ format.date "year" output.check
701
+ new.sentence
702
+ organization output
703
+ publisher output
704
+ }
705
+ if$
706
+ }
707
+ { format.incoll.inproc.crossref output.nonnull
708
+ format.pages output
709
+ }
710
+ if$
711
+ format.eprint output
712
+ new.block
713
+ note output
714
+ fin.entry
715
+ }
716
+
717
+ FUNCTION {conference} { inproceedings }
718
+
719
+ FUNCTION {manual}
720
+ { output.bibitem
721
+ author empty$
722
+ { organization empty$
723
+ 'skip$
724
+ { organization output.nonnull
725
+ address output
726
+ }
727
+ if$
728
+ }
729
+ { format.authors output.nonnull }
730
+ if$
731
+ new.block
732
+ format.btitle "title" output.check
733
+ author empty$
734
+ { organization empty$
735
+ { address new.block.checka
736
+ address output
737
+ }
738
+ 'skip$
739
+ if$
740
+ }
741
+ { organization address new.block.checkb
742
+ organization output
743
+ address output
744
+ }
745
+ if$
746
+ format.edition output
747
+ format.date output
748
+ format.eprint output
749
+ new.block
750
+ note output
751
+ fin.entry
752
+ }
753
+
754
+ FUNCTION {mastersthesis}
755
+ { output.bibitem
756
+ format.authors "author" output.check
757
+ new.block
758
+ format.title "title" output.check
759
+ new.block
760
+ "Master's thesis" format.thesis.type output.nonnull
761
+ school "school" output.check
762
+ address output
763
+ format.date "year" output.check
764
+ format.eprint output
765
+ new.block
766
+ note output
767
+ fin.entry
768
+ }
769
+
770
+ FUNCTION {misc}
771
+ { output.bibitem
772
+ format.authors output
773
+ title howpublished new.block.checkb
774
+ format.title output
775
+ howpublished new.block.checka
776
+ howpublished output
777
+ format.date output
778
+ format.eprint output
779
+ new.block
780
+ note output
781
+ fin.entry
782
+ empty.misc.check
783
+ }
784
+
785
+ FUNCTION {phdthesis}
786
+ { output.bibitem
787
+ format.authors "author" output.check
788
+ new.block
789
+ format.btitle "title" output.check
790
+ new.block
791
+ "PhD thesis" format.thesis.type output.nonnull
792
+ school "school" output.check
793
+ address output
794
+ format.date "year" output.check
795
+ format.eprint output
796
+ new.block
797
+ note output
798
+ fin.entry
799
+ }
800
+
801
+ FUNCTION {proceedings}
802
+ { output.bibitem
803
+ editor empty$
804
+ { organization output }
805
+ { format.editors output.nonnull }
806
+ if$
807
+ new.block
808
+ format.btitle "title" output.check
809
+ format.bvolume output
810
+ format.number.series output
811
+ address empty$
812
+ { editor empty$
813
+ { publisher new.sentence.checka }
814
+ { organization publisher new.sentence.checkb
815
+ organization output
816
+ }
817
+ if$
818
+ publisher output
819
+ format.date "year" output.check
820
+ }
821
+ { address output.nonnull
822
+ format.date "year" output.check
823
+ new.sentence
824
+ editor empty$
825
+ 'skip$
826
+ { organization output }
827
+ if$
828
+ publisher output
829
+ }
830
+ if$
831
+ format.eprint output
832
+ new.block
833
+ note output
834
+ fin.entry
835
+ }
836
+
837
+ FUNCTION {techreport}
838
+ { output.bibitem
839
+ format.authors "author" output.check
840
+ new.block
841
+ format.title "title" output.check
842
+ new.block
843
+ format.tr.number output.nonnull
844
+ institution "institution" output.check
845
+ address output
846
+ format.date "year" output.check
847
+ format.eprint output
848
+ new.block
849
+ note output
850
+ fin.entry
851
+ }
852
+
853
+ FUNCTION {unpublished}
854
+ { output.bibitem
855
+ format.authors "author" output.check
856
+ new.block
857
+ format.title "title" output.check
858
+ new.block
859
+ note "note" output.check
860
+ format.date output
861
+ format.eprint output
862
+ fin.entry
863
+ }
864
+
865
+ FUNCTION {default.type} { misc }
866
+
867
+ MACRO {jan} {"January"}
868
+
869
+ MACRO {feb} {"February"}
870
+
871
+ MACRO {mar} {"March"}
872
+
873
+ MACRO {apr} {"April"}
874
+
875
+ MACRO {may} {"May"}
876
+
877
+ MACRO {jun} {"June"}
878
+
879
+ MACRO {jul} {"July"}
880
+
881
+ MACRO {aug} {"August"}
882
+
883
+ MACRO {sep} {"September"}
884
+
885
+ MACRO {oct} {"October"}
886
+
887
+ MACRO {nov} {"November"}
888
+
889
+ MACRO {dec} {"December"}
890
+
891
+ MACRO {acmcs} {"ACM Computing Surveys"}
892
+
893
+ MACRO {acta} {"Acta Informatica"}
894
+
895
+ MACRO {cacm} {"Communications of the ACM"}
896
+
897
+ MACRO {ibmjrd} {"IBM Journal of Research and Development"}
898
+
899
+ MACRO {ibmsj} {"IBM Systems Journal"}
900
+
901
+ MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
902
+
903
+ MACRO {ieeetc} {"IEEE Transactions on Computers"}
904
+
905
+ MACRO {ieeetcad}
906
+ {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
907
+
908
+ MACRO {ipl} {"Information Processing Letters"}
909
+
910
+ MACRO {jacm} {"Journal of the ACM"}
911
+
912
+ MACRO {jcss} {"Journal of Computer and System Sciences"}
913
+
914
+ MACRO {scp} {"Science of Computer Programming"}
915
+
916
+ MACRO {sicomp} {"SIAM Journal on Computing"}
917
+
918
+ MACRO {tocs} {"ACM Transactions on Computer Systems"}
919
+
920
+ MACRO {tods} {"ACM Transactions on Database Systems"}
921
+
922
+ MACRO {tog} {"ACM Transactions on Graphics"}
923
+
924
+ MACRO {toms} {"ACM Transactions on Mathematical Software"}
925
+
926
+ MACRO {toois} {"ACM Transactions on Office Information Systems"}
927
+
928
+ MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
929
+
930
+ MACRO {tcs} {"Theoretical Computer Science"}
931
+
932
+ READ
933
+
934
+ FUNCTION {sortify}
935
+ { purify$
936
+ "l" change.case$
937
+ }
938
+
939
+ INTEGERS { len }
940
+
941
+ FUNCTION {chop.word}
942
+ { 's :=
943
+ 'len :=
944
+ s #1 len substring$ =
945
+ { s len #1 + global.max$ substring$ }
946
+ 's
947
+ if$
948
+ }
949
+
950
+ INTEGERS { et.al.char.used }
951
+
952
+ FUNCTION {initialize.et.al.char.used}
953
+ { #0 'et.al.char.used :=
954
+ }
955
+
956
+ EXECUTE {initialize.et.al.char.used}
957
+
958
+ FUNCTION {format.lab.names}
959
+ { 's :=
960
+ s num.names$ 'numnames :=
961
+ numnames #1 >
962
+ { numnames #4 >
963
+ { #3 'namesleft := }
964
+ { numnames 'namesleft := }
965
+ if$
966
+ #1 'nameptr :=
967
+ ""
968
+ { namesleft #0 > }
969
+ { nameptr numnames =
970
+ { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
971
+ { "{\etalchar{+}}" *
972
+ #1 'et.al.char.used :=
973
+ }
974
+ { s nameptr "{v{}}{l{}}" format.name$ * }
975
+ if$
976
+ }
977
+ { s nameptr "{v{}}{l{}}" format.name$ * }
978
+ if$
979
+ nameptr #1 + 'nameptr :=
980
+ namesleft #1 - 'namesleft :=
981
+ }
982
+ while$
983
+ numnames #4 >
984
+ { "{\etalchar{+}}" *
985
+ #1 'et.al.char.used :=
986
+ }
987
+ 'skip$
988
+ if$
989
+ }
990
+ { s #1 "{v{}}{l{}}" format.name$
991
+ duplicate$ text.length$ #2 <
992
+ { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
993
+ 'skip$
994
+ if$
995
+ }
996
+ if$
997
+ }
998
+
999
+ FUNCTION {author.key.label}
1000
+ { author empty$
1001
+ { key empty$
1002
+ { cite$ #1 #3 substring$ }
1003
+ { key #3 text.prefix$ }
1004
+ if$
1005
+ }
1006
+ { author format.lab.names }
1007
+ if$
1008
+ }
1009
+
1010
+ FUNCTION {author.editor.key.label}
1011
+ { author empty$
1012
+ { editor empty$
1013
+ { key empty$
1014
+ { cite$ #1 #3 substring$ }
1015
+ { key #3 text.prefix$ }
1016
+ if$
1017
+ }
1018
+ { editor format.lab.names }
1019
+ if$
1020
+ }
1021
+ { author format.lab.names }
1022
+ if$
1023
+ }
1024
+
1025
+ FUNCTION {author.key.organization.label}
1026
+ { author empty$
1027
+ { key empty$
1028
+ { organization empty$
1029
+ { cite$ #1 #3 substring$ }
1030
+ { "The " #4 organization chop.word #3 text.prefix$ }
1031
+ if$
1032
+ }
1033
+ { key #3 text.prefix$ }
1034
+ if$
1035
+ }
1036
+ { author format.lab.names }
1037
+ if$
1038
+ }
1039
+
1040
+ FUNCTION {editor.key.organization.label}
1041
+ { editor empty$
1042
+ { key empty$
1043
+ { organization empty$
1044
+ { cite$ #1 #3 substring$ }
1045
+ { "The " #4 organization chop.word #3 text.prefix$ }
1046
+ if$
1047
+ }
1048
+ { key #3 text.prefix$ }
1049
+ if$
1050
+ }
1051
+ { editor format.lab.names }
1052
+ if$
1053
+ }
1054
+
1055
+ FUNCTION {calc.label}
1056
+ { type$ "book" =
1057
+ type$ "inbook" =
1058
+ or
1059
+ 'author.editor.key.label
1060
+ { type$ "proceedings" =
1061
+ 'editor.key.organization.label
1062
+ { type$ "manual" =
1063
+ 'author.key.organization.label
1064
+ 'author.key.label
1065
+ if$
1066
+ }
1067
+ if$
1068
+ }
1069
+ if$
1070
+ duplicate$
1071
+ year field.or.null purify$ #-1 #2 substring$
1072
+ *
1073
+ 'label :=
1074
+ year field.or.null purify$ #-1 #4 substring$
1075
+ *
1076
+ sortify 'sort.label :=
1077
+ }
1078
+
1079
+ FUNCTION {sort.format.names}
1080
+ { 's :=
1081
+ #1 'nameptr :=
1082
+ ""
1083
+ s num.names$ 'numnames :=
1084
+ numnames 'namesleft :=
1085
+ { namesleft #0 > }
1086
+ { nameptr #1 >
1087
+ { " " * }
1088
+ 'skip$
1089
+ if$
1090
+ s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1091
+ nameptr numnames = t "others" = and
1092
+ { "et al" * }
1093
+ { t sortify * }
1094
+ if$
1095
+ nameptr #1 + 'nameptr :=
1096
+ namesleft #1 - 'namesleft :=
1097
+ }
1098
+ while$
1099
+ }
1100
+
1101
+ FUNCTION {sort.format.title}
1102
+ { 't :=
1103
+ "A " #2
1104
+ "An " #3
1105
+ "The " #4 t chop.word
1106
+ chop.word
1107
+ chop.word
1108
+ sortify
1109
+ #1 global.max$ substring$
1110
+ }
1111
+
1112
+ FUNCTION {author.sort}
1113
+ { author empty$
1114
+ { key empty$
1115
+ { "to sort, need author or key in " cite$ * warning$
1116
+ ""
1117
+ }
1118
+ { key sortify }
1119
+ if$
1120
+ }
1121
+ { author sort.format.names }
1122
+ if$
1123
+ }
1124
+
1125
+ FUNCTION {author.editor.sort}
1126
+ { author empty$
1127
+ { editor empty$
1128
+ { key empty$
1129
+ { "to sort, need author, editor, or key in " cite$ * warning$
1130
+ ""
1131
+ }
1132
+ { key sortify }
1133
+ if$
1134
+ }
1135
+ { editor sort.format.names }
1136
+ if$
1137
+ }
1138
+ { author sort.format.names }
1139
+ if$
1140
+ }
1141
+
1142
+ FUNCTION {author.organization.sort}
1143
+ { author empty$
1144
+ { organization empty$
1145
+ { key empty$
1146
+ { "to sort, need author, organization, or key in " cite$ * warning$
1147
+ ""
1148
+ }
1149
+ { key sortify }
1150
+ if$
1151
+ }
1152
+ { "The " #4 organization chop.word sortify }
1153
+ if$
1154
+ }
1155
+ { author sort.format.names }
1156
+ if$
1157
+ }
1158
+
1159
+ FUNCTION {editor.organization.sort}
1160
+ { editor empty$
1161
+ { organization empty$
1162
+ { key empty$
1163
+ { "to sort, need editor, organization, or key in " cite$ * warning$
1164
+ ""
1165
+ }
1166
+ { key sortify }
1167
+ if$
1168
+ }
1169
+ { "The " #4 organization chop.word sortify }
1170
+ if$
1171
+ }
1172
+ { editor sort.format.names }
1173
+ if$
1174
+ }
1175
+
1176
+ FUNCTION {presort}
1177
+ { calc.label
1178
+ sort.label
1179
+ " "
1180
+ *
1181
+ type$ "book" =
1182
+ type$ "inbook" =
1183
+ or
1184
+ 'author.editor.sort
1185
+ { type$ "proceedings" =
1186
+ 'editor.organization.sort
1187
+ { type$ "manual" =
1188
+ 'author.organization.sort
1189
+ 'author.sort
1190
+ if$
1191
+ }
1192
+ if$
1193
+ }
1194
+ if$
1195
+ *
1196
+ " "
1197
+ *
1198
+ year field.or.null sortify
1199
+ *
1200
+ " "
1201
+ *
1202
+ title field.or.null
1203
+ sort.format.title
1204
+ *
1205
+ #1 entry.max$ substring$
1206
+ 'sort.key$ :=
1207
+ }
1208
+
1209
+ ITERATE {presort}
1210
+
1211
+ SORT
1212
+
1213
+ STRINGS { longest.label last.sort.label next.extra }
1214
+
1215
+ INTEGERS { longest.label.width last.extra.num }
1216
+
1217
+ FUNCTION {initialize.longest.label}
1218
+ { "" 'longest.label :=
1219
+ #0 int.to.chr$ 'last.sort.label :=
1220
+ "" 'next.extra :=
1221
+ #0 'longest.label.width :=
1222
+ #0 'last.extra.num :=
1223
+ }
1224
+
1225
+ FUNCTION {forward.pass}
1226
+ { last.sort.label sort.label =
1227
+ { last.extra.num #1 + 'last.extra.num :=
1228
+ last.extra.num int.to.chr$ 'extra.label :=
1229
+ }
1230
+ { "a" chr.to.int$ 'last.extra.num :=
1231
+ "" 'extra.label :=
1232
+ sort.label 'last.sort.label :=
1233
+ }
1234
+ if$
1235
+ }
1236
+
1237
+ FUNCTION {reverse.pass}
1238
+ { next.extra "b" =
1239
+ { "a" 'extra.label := }
1240
+ 'skip$
1241
+ if$
1242
+ label extra.label * 'label :=
1243
+ label width$ longest.label.width >
1244
+ { label 'longest.label :=
1245
+ label width$ 'longest.label.width :=
1246
+ }
1247
+ 'skip$
1248
+ if$
1249
+ extra.label 'next.extra :=
1250
+ }
1251
+
1252
+ EXECUTE {initialize.longest.label}
1253
+
1254
+ ITERATE {forward.pass}
1255
+
1256
+ REVERSE {reverse.pass}
1257
+
1258
+ FUNCTION {begin.bib}
1259
+ { et.al.char.used
1260
+ { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
1261
+ 'skip$
1262
+ if$
1263
+ preamble$ empty$
1264
+ 'skip$
1265
+ { preamble$ write$ newline$ }
1266
+ if$
1267
+ "\begin{thebibliography}{" longest.label * "}" * write$ newline$
1268
+ }
1269
+
1270
+ EXECUTE {begin.bib}
1271
+
1272
+ EXECUTE {init.state.consts}
1273
+
1274
+ ITERATE {call.type$}
1275
+
1276
+ FUNCTION {end.bib}
1277
+ { newline$
1278
+ "\end{thebibliography}" write$ newline$
1279
+ }
1280
+
1281
+ EXECUTE {end.bib}