-
Notifications
You must be signed in to change notification settings - Fork 2
/
f.tex
2047 lines (1761 loc) · 89.3 KB
/
f.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{tikz}
\usepackage{url}
\usepackage{stmaryrd}
\usepackage{amssymb}
\usepackage[sans]{dsfont}
\usepackage{color, colortbl}
\usepackage{courier}
\usepackage{graphicx}
\usepackage[all]{xy}
\xyoption{line}
\newcommand{\amr}[1]{\fbox{Amr says:} \textbf{#1}}
% ----------------------------------------------------------------------
% XY-Pic definitions for making ``wire charts''
\def\wirechart#1#2{\let\labelstyle\objectstyle\xy*[*1.0]\xybox{\small%
\xymatrix@C=10mm@R=4mm#1{#2}}\endxy}
\def\wire#1#2{\ar@{-}[#1]^<>(.5){#2}}
\def\wireright#1#2{\wire{#1}{#2}\ar@{}[#1]|<>(.5)/.6ex/{\dir2{>}}}
\def\wireleft#1#2{\wire{#1}{#2}\ar@{}[#1]|<>(.5)/-.6ex/{\dir2{<}}}
\def\wwblank#1{*=<#1,0mm>{~}}
\def\wblank{\wwblank{11mm}}
\def\blank{\wwblank{8mm}}
\def\vublank{*=<0mm,2.3mm>!D{}}
\def\vdblank{*=<0mm,2.3mm>!U{}}
\def\vsblank{*=<0mm,5.6mm>{}}
\def\wirecross#1{\save[]!L;[#1]!R**@{-}\restore}
\def\wirebraid#1#2{\save[]!L;[#1]!R**{}?(#2)**@{-}\restore\save[#1]!R;[]!L**{}?(#2)**@{-}\restore}
\def\wireopen#1{\save[]!R;[#1]!R**\crv{[]!C&[#1]!C}\restore}
\def\wireclose#1{\save[]!L;[#1]!L**\crv{[]!C&[#1]!C}\restore}
\def\wireopenlabel#1#2{\save[]!R;[#1]!R**\crv{[]!C&[#1]!C}?<>(.5)*^+!R{#2}\restore}
\def\wirecloselabel#1#2{\save[]!L;[#1]!L**\crv{[]!C&[#1]!C}?<>(.5)*^+!L{#2}\restore}
\def\wireid{\blank\save[]!L*{};[]!R*{}**@{-}\restore}
\def\wwireid{\wblank\save[]!L*{};[]!R*{}**@{-}\restore}
\def\wwwireid#1{\wwblank{#1}\save[]!L*{};[]!R*{}**@{-}\restore}
\newcommand{\corner}{\rule{2.5mm}{2.5mm}}
\def\minheight{8mm}
\def\addheight{8mm}
\def\cornerbox#1#2#3{ % draw a box with a marked corner around
% the object #1. #2=label
% usage: \ulbox{[ll].[].[ul]}{f}
\save#1="box";
"box"!C*+<0mm,\addheight>+=<0mm,\minheight>[|(5)]\frm{-}="box1";
"box1"*{#2};
={"box1"!LU*!LU[]{\corner}}"ul";
={"box1"!RU*!RU[]{\corner}}"ur";
={"box1"!LD*!LD[]{\corner}}"dl";
={"box1"!RD*!RD[]{\corner}}"dr";
#3
\restore
}
\def\nnbox#1#2{\cornerbox{#1}{#2}{}}
\def\ulbox#1#2{\cornerbox{#1}{#2}{"ul"}}
\def\urbox#1#2{\cornerbox{#1}{#2}{"ur"}}
\def\dlbox#1#2{\cornerbox{#1}{#2}{"dl"}}
\def\drbox#1#2{\cornerbox{#1}{#2}{"dr"}}
\def\ubox#1#2{\cornerbox{#1}{#2}{"ul","ur"}}
\def\dbox#1#2{\cornerbox{#1}{#2}{"dl","dr"}}
\def\lbox#1#2{\cornerbox{#1}{#2}{"ul","dl"}}
\def\rbox#1#2{\cornerbox{#1}{#2}{"ur","dr"}}
\def\circbox#1{*+[o][F-]{#1}}
\newtheorem{definition}{Definition}
\newtheorem{n-lemma}{Lemma}[section]
\newtheorem{n-example}[n-lemma]{Example}
\newenvironment{example}{\begin{n-example}}{\end{n-example}}
\newcommand{\br}{\mathit{Br}}
\newcommand{\ssep}{\hspace{1em}}
\newcommand{\sym}{c} % braid: could be \sigma or c or \gamma
\newcommand{\cp}{\circ} % composition
\newcommand{\pc}{\fatsemi} % path composition
\newcommand{\symi}{\sym\inv}
\newcommand{\inv}{^{-1}}
\newcommand{\lolli}{\multimap}
\newcommand{\id}{\textrm{\rm id}} % identity
\newcommand{\x}{\otimes}
\newcommand{\boolt}{\mathit{bool}}
\newcommand{\ffv}{\mathit{false}}
\newcommand{\ttv}{\mathit{true}}
\newcommand{\notb}{\mathit{not}}
\newcommand{\union}{\cup}
\newcommand{\transport}[2]{\overline{#1}(#2)}
\newcommand{\refl}{\mathit{refl}}
\renewcommand{\path}{\leadsto}
\newcommand{\paths}[1]{\mathds{P}(#1)}
%% \renewcommand{\circ}{\circlearrowleft}
\newcommand{\alt}{~|~}
\newcommand{\dt}[1]{\llbracket #1 \rrbracket}
\newcommand{\leftv}[1]{\textsf{left}~#1}
\newcommand{\rightv}[1]{\textsf{right}~#1}
\newcommand{\iso}{\leftrightarrow}
\newcommand{\identlp}{\mathit{identl}_+}
\newcommand{\identrp}{\mathit{identr}_+}
\newcommand{\swapp}{\mathit{swap}_+}
\newcommand{\assoclp}{\mathit{assocl}_+}
\newcommand{\assocrp}{\mathit{assocr}_+}
\newcommand{\identlt}{\mathit{identl}_*}
\newcommand{\identrt}{\mathit{identr}_*}
\newcommand{\swapt}{\mathit{swap}_*}
\newcommand{\assoclt}{\mathit{assocl}_*}
\newcommand{\assocrt}{\mathit{assocr}_*}
\newcommand{\distz}{\mathit{dist}_0}
\newcommand{\factorz}{\mathit{factor}_0}
\newcommand{\dist}{\mathit{dist}}
\newcommand{\factor}{\mathit{factor}}
\newcommand{\idc}{\mathit{id}}
\newcommand{\wedgesum}{\vee}
\newcommand{\smashproduct}{\wedge}
\newcommand{\symc}[1]{\mathit{sym}~#1}
\newcommand{\proves}{\vdash}
\newcommand{\ap}[2]{\mathit{ap}~#1~#2}
\newcommand{\Rule}[4]{
\makebox{{\rm #1}
$\displaystyle
\frac{\begin{array}{l}#2\\\end{array}}
{\begin{array}{l}#3\\\end{array}}$
#4}}
\newcommand{\jdg}[3]{#2 \proves_{#1} #3}
\newcommand{\adjoint}[1]{#1^{\dagger}}
\begin{document}
\begin{titlepage}
\begin{center}
\vfill
{\LARGE Isomorphisms as Groupoids: \\
Homotopy Type Theory and Fractional Types} \\[1.5cm]
\vfill
\end{center}
\vfill
\noindent\textbf{Abstract.}
\vfill
\vfill
\end{titlepage}
\title{Isomorphisms as Groupoids: \\
Homotopy Type Theory and Fractional Types}
\author{?}
\date{\today}
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
HoTT cannot really deal with functions. The starting point is that paths
explain and witness identities. This works for all the usual types but not
for functions or universes. For functions, the HoTT treatment is to allow
arbitrary functions, single out the isos via classical extensional methods,
and then assert via an axiom that the class of singled out functions is
equivalent to paths. This is a convoluted way. Why not start with functions
that are, by construction, isos. This was the programme we started earlier,
inspired by physical considerations. Because physics requires various
conservation principles (including conservation of information) and because
computation is fundamentally a physical process, the argument (originally due
to Feynman etc.) was that computation should be based on reversible
processes, or in abstract terms, on isomorphisms. That fits very well with
the HoTT philosophy that makes isos first-class. Except that HoTT does not
deal exclusively with isos, the functions are generally not isos. So let's
investigate the radical idea that all functions are isos in the HoTT
framework. What we get is a notion of first-class functions that by
construction are isos and obey the usual path rules etc. The technical device
is the notion of fractional types which are dual to products. A function
(iso) $A \rightarrow B$ is represented as an element of the type
$(\frac{1}{A} \times B)$. The construction shows the essential nature of the
$\infty$-groupoid structure. The more higher-order functions we have the
higher we have to go in the groupoid structure. We also have something
significant in the realm of reversible computing. We finally have
higher-order functions. Of course we need to show that we have constructed a
monoidal closed category (a concrete one) and then we can inherit all the
fancy constructions. Finally we have a very interesting operational
interpretation of paths and we outline various applications.
Need a clear explanation of why we can't deal with the usual functions that
are not isomorphisms. Regular function spaces obey $1^A = 1$ for all $A$. In
terms of fractionals this gives $\frac{1}{A} = 1$ for all $A$ which is not
true. However if we restrict to isomorphisms then the only functions we can
write are $A \rightarrow B$ where $A$ and $B$ are isomorphic types and hence
the only functions we can write in the space $1^A$ are to types $A$ that are
isomorphic to 1 and in that case we do indeed get that $\frac{1}{A} =
1$. See~\cite{fiore-remarks} for more details. The benefit is that we fit
squarely in the physically motivated notion that isomorphisms are the
foundational computational mechanism as well as the HoTT approach that is
essentially all about isomorphisms. Of course we don't lose anything by
restricting our attention to isomorphisms because we know that general
(irreversible) functions can be obtained from isomorphisms via
\emph{information effects}~\cite{James:2012:IE:2103656.2103667}.
We are witnessing a convergence of ideas from several distinct research
communities (physics, mathematics, and computer science) towards replacing
\emph{equalities} by \emph{isomorphisms}. The combined programme has sparked
a significant amount of research that unveiled new and surprising connections
between geometry, algebra, logic, and computation (see~\cite{baez2011physics}
for an overview of some of the connections).
In the physics community, Landauer~\cite{Landauer:1961,Landauer},
Feynman~\cite{springerlink:10.1007/BF02650179}, and others have interpreted
the laws of physics as fundamentally related to computation. The great
majority of these laws are formulated as equalities between different
physical observables which is unsatisfying: \emph{different} physical
observables should not be related by an \emph{equality}. It is more
appropriate to relate them by an \emph{isomorphism} that witnesses, explains,
and models the process of transforming one observable to the other.
In the mathematics and logic community, Martin-L\"of developed an extension
of the simply typed $\lambda$-calculus originally intended to provide a
rigorous framework for constructive
mathematics~\cite{citeulike:7374951}. This theory has been further extended
with \emph{identity types} representing the proposition that two terms are
``equal.'' (See~\cite{streicher,warren} for a survey.) Briefly speaking,
given two terms $a$ and $b$ of the same type $A$, one forms the type
$\texttt{Id}_A(a,b)$ representing the proposition that~$a$ and~$b$ are equal:
in other words, a term of type $\texttt{Id}_A(a,b)$ witnesses, explains, and
models the process of transforming $a$ to $b$ and vice-versa.
In the computer science community, the theory and practice of type
isomorphisms is well-established. Originally, such type isomorphisms were
motivated by the pragmatic concern of searching large libraries of functions
by providing one of the many possible isomorphic types for the desired
function~\cite{Rittri:1989:UTS:99370.99384}. More recently, type isomorphisms
have taken a more central role as \emph{the} fundamental computational
mechanism from which more conventional, i.e., irreversible computation, is
derived. In our own previous
work~\cite{James:2012:IE:2103656.2103667,rc2011,rc2012} we started with the
notion of type isomorphism and developed from it a family of programming
languages, $\Pi$ with various superscripts, in which computation is an
isomorphism preserving the information-theoretic entropy.
A major open problem remains, however: a higher-order extension of
$\Pi$. This extension is of fundamental importance in all the originating
research areas. In physics, it allows for quantum states to be viewed as
processes and processes to be viewed as states, such as with the
Choi-Jamiolkowski
isomorphism~\cite{choi1975completely,jamiolkowski1972linear}. In mathematics
and logic, it allows the equivalence between different proofs of type
$\texttt{Id}_A(a,b)$ to itself be expressed as an isomorphism (of a higher
type) $\texttt{Id}_{\texttt{Id}_A(a,b)}(p,q)$. Finally, in computer science,
higher-order types allow code to abstract over other code fragments as well
as the manipulation of code as data and data as code.
Technically speaking, obtaining a higher-order extension requires the
construction of a \emph{closed category} from the underlying monoidal
category for~$\Pi$. Although the general idea of such a construction is
well-understood, the details of adapting it to an actual programming language
are subtle. Our main novel technical device to achieving the higher-order
extension is a \emph{fractional type} which represents \emph{negative
information} and which is so named because of its duality with conventional
product types.
From the wikipedia page on homeomorphism:
\begin{quote}
The intuitive criterion of stretching, bending, cutting and gluing back
together takes a certain amount of practice to apply correctly—it may not be
obvious from the description above that deforming a line segment to a point
is impermissible, for instance. It is thus important to realize that it is
the formal definition given above that counts.
This characterization of a homeomorphism often leads to confusion with the
concept of homotopy, which is actually defined as a continuous deformation,
but from one function to another, rather than one space to another. In the
case of a homeomorphism, envisioning a continuous deformation is a mental
tool for keeping track of which points on space X correspond to which points
on Y—one just follows them as X deforms. In the case of homotopy, the
continuous deformation from one map to the other is of the essence, and it is
also less restrictive, since none of the maps involved need to be one-to-one
or onto. Homotopy does lead to a relation on spaces: homotopy equivalence.
There is a name for the kind of deformation involved in visualizing a
homeomorphism. It is (except when cutting and regluing are required) an
isotopy between the identity map on X and the homeomorphism from X to Y.
\end{quote}
It is strange for homotopy type theory to be all about isomorphisms and then
not insist on isomorphisms between spaces.
If we focus on homeomorphisms, the higher-order space is a \emph{torsor}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Intuitive Ideas and Examples}
\label{sec:intuition}
%% the next figures are taken from Selinger's paper on graphical languages
%% for monoidal categories; if we use them make sure it's ok with him and
%% acknowledge him
Univalence says:
\[
(A \simeq B) \quad\simeq\quad (A \equiv B)
\]
where $\simeq$ is a strong form of isomorphism witnessed by functions from
$A$ to $B$ and vice versa that are inverses and $\equiv$ is the propositional
equality in type theoretic terms or a path (homotopy) in topological
terms. The axiom relates two notions that are a priori different: functions
and paths. However if we define functions from the outset as paths then there
is no need for this axiom.
So what would it take to have each function correspond to a path and
higher-order functions correspond to paths between paths etc.? Since paths
form an equivalence relation, the first immediate observation is that all
functions must be reversible. Formally we need the following properties of
paths to be satisfied by functions. (We write $\path$ for paths instead of
$\equiv$.)
\begin{itemize}
\item For each $A$, there is function $\id : A \path A$,
\item for each function $f: A \path B$, there exists a function $\adjoint{f}
: B \path A$, and
\item for each functions $f : A \path B$ and $g : B \path C$, there exists a
function $g \cp f : A \path C$, such that:
\begin{itemize}
\item $f \path f \cp \id$;
\item $f \path \id \cp f$;
\item $\adjoint{f} \cp f \path \id$;
\item $f \cp \, \adjoint{f} \path \id$;
\item $\adjoint{(\adjoint{f})} \path f$;
\item $f \cp (g \cp h) \path (f \cp g) \cp h$
\end{itemize}
\end{itemize}
Similar equivalences hold are higher-levels. A good starting point for this
notion of functions are the $\Pi$-combinators we previously developed. Each
combinator in that setting had an \emph{adjoint} going in the other direction
that acts as the inverse. Moreover if $f : A \path B$ then $A$ must be
isomorphic to $B$ and $f$ is permutation. We use $!p$ for the inverse of a
path.
But first, let's examine the structure of a path $f : A \path B$. A natural
representation for a path representing a function is a collection of paths
(called \emph{fibers}) one for each $a : A$. So for example, if $A$ is the
set $\{ x , y , z \}$ and $B$ is the set $\{ a , b , c \}$ (remember that $A$
and $B$ must be isomorphic), and $f$ is the function mapping $x$ to $a$, $y$
to $b$, and $z$ to $c$, then $f : A \path B$ is the collection of paths $f_x
: x \path a$, $f_y : y \path b$, and $f_z : z \path c$.
Assuming this representation of functions, let's see what properties are
induced for these functions.
The first property is that functions should preserve paths, i.e., if there is
a path between $x$ and~$y$ then there should be a path between $f(x)$
and~$f(y)$. From the figure below it is clear that:
\[
\ap{f}{p} = \, !f_x \pc p \pc f_y
\]
\begin{center}
\begin{tikzpicture}
\draw (-3,0) ellipse (1.5cm and 3cm);
\draw (3,0) ellipse (1.5cm and 3cm);
\draw[fill] (-3,1.5) circle [radius=0.025];
\draw[fill] (-3,-1.5) circle [radius=0.025];
\node[above] at (-3,1.5) {$x$};
\node[below] at (-3,-1.5) {$y$};
\draw[fill] (3,1.5) circle [radius=0.025];
\draw[fill] (3,-1.5) circle [radius=0.025];
\node[above] at (3,1.5) {$f(x)$};
\node[below] at (3,-1.5) {$f(y)$};
\draw[->,cyan,thick] (-3,1.5) -- (-3,-1.5);
\node[left,cyan] at (-3,0) {$p$};
\draw[->,dashed,cyan,thick] (3,1.5) -- (3,-1.5);
\node[right,cyan] at (3,0) {$\mathit{ap}~f~p$};
\draw[->,red,thick] (-3,1.5) -- (3,1.5);
\draw[->,red,thick] (-3,-1.5) -- (3,-1.5);
\node[red,below] at (0,1.5) {$f_x$};
\node[red,below] at (0,-1.5) {$f_y$};
\end{tikzpicture}
\end{center}
Let $p : x \path y$ and $q : y \path z$, then the following properties
hold:
\begin{itemize}
\item $\ap{f}{(p \pc q)} \path \ap{f}{p} \pc \ap{f}{q}$:
\[\begin{array}{rcl}
LHS &=& \, !f_x \pc (p \pc q) \pc f_z \\
&\path& ! f_x \pc p \pc f_y \pc \, ! f_y \pc q \pc f_z \\
&\path& (! f_x \pc p \pc f_y) \pc (! f_y \pc q \pc f_z) \\
&=& RHS
\end{array}\]
\item $\ap{f}{!p} \path \, !(\ap{f}{p})$
\[\begin{array}{rcl}
LHS &=& \, !f_y \pc (!p) \pc f_x \\
&\path& \, !(!f_x \pc p \pc f_y) \\
&=& RHS
\end{array}\]
\item $\ap{g}{(\ap{f}{p})} \path \ap{(g \cp f)}{p}$
\[\begin{array}{rcl}
LHS &=& \, !g_{f_x} \pc !f_x \pc p \pc f_y \pc g_{f_y} \\
&\path& \, ! (f_x \pc g_{f_x}) \pc p \pc (f_y \pc g_{f_y}) \\
&=& RHS
\end{array}\]
\item $\ap{\id}{p} \path p$
\[\begin{array}{rcl}
LHS &=& \, !\id_x \pc p \pc \id_y \\
&\path& p \\
&=& RHS
\end{array}\]
\end{itemize}
A homotopy between functions $f$ and $g$ is a 2-path between each pair of
fibers $f_x$ and $g_x$. These 2-paths are induced by the following diagram:
\begin{center}
\begin{tikzpicture}
\draw[fill] (-3,0) circle [radius=0.025];
\node[below] at (-3,0) {$x$};
\draw[fill] (3,1.5) circle [radius=0.025];
\node[above] at (3,1.5) {$a$};
\draw[fill] (3,-1.5) circle [radius=0.025];
\node[below] at (3,-1.5) {$b$};
\draw[->,cyan,thick] (-3,0) -- (3,1.5);
\draw[->,cyan,thick] (-3,0) -- (3,-1.5);
\draw[->,red,thick] (3,1.5) -- (3,-1.5);
\node[red,above] at (0,0.5) {$f_x$};
\node[red,below] at (0,-0.5) {$f_y$};
\draw[->,double,dashed,blue,thick] (1.5,1) to [out=225, in=135] (1.5,-1);
\node[blue,right] at (1.5,0) {$H_x$};
\end{tikzpicture}
\end{center}
Here is something more interesting. Let $p : y \path z$ in $A$. Let $f$ and
$g$ be functions from $A$ to $B$. Let $H$ be a 2-path between $f_y$ and
$g_y$. If we are given a path $f(y) \path g(y)$ in B, then we can construct a
2-path between $f_z$ and $g_z$. (This is Thm 2.11.3 in the book.) We do this
going backwards along $f_z$, backwards along $p$, then follow $f_y$ and the
path to $g(y)$, and backwards along $g_y$, forwards along $p$, and finally
forwards along $g_z$:
\begin{center}
\begin{tikzpicture}
\draw[fill] (-3,0) circle [radius=0.025];
\node[below] at (-3,0) {$x$};
\draw[fill] (3,1.5) circle [radius=0.025];
\node[above] at (3,1.5) {$a$};
\draw[fill] (3,-1.5) circle [radius=0.025];
\node[below] at (3,-1.5) {$b$};
\draw[->,cyan,thick] (-3,0) -- (3,1.5);
\draw[->,cyan,thick] (-3,0) -- (3,-1.5);
\draw[->,red,thick] (3,1.5) -- (3,-1.5);
\node[red,above] at (0,0.5) {$f_x$};
\node[red,below] at (0,-0.5) {$f_y$};
\draw[->,double,dashed,blue,thick] (1.5,1) to [out=225, in=135] (1.5,-1);
\node[blue,right] at (1.5,0) {$H_x$};
\draw[fill] (-3,-5) circle [radius=0.025];
\node[below] at (-3,-5) {$x$};
\draw[fill] (3,-3.5) circle [radius=0.025];
\node[above] at (3,-3.5) {$a$};
\draw[fill] (3,-6.5) circle [radius=0.025];
\node[below] at (3,-6.5) {$b$};
\draw[->,cyan,thick] (-3,-5) -- (3,-3.5);
\draw[->,cyan,thick] (-3,-5) -- (3,-6.5);
\draw[->,red,thick] (3,-3.5) -- (3,-6.5);
\node[red,above] at (0,-4.5) {$f_x$};
\node[red,below] at (0,-5.5) {$f_y$};
\end{tikzpicture}
\end{center}
Now the most interesting question is whether we can internalize functions as
objects. Given $f$ a function from $A$ to $B$, what we can do below is to
represent each fiber $f_x$ as an element of the type $(\frac{1}{A} \times
B)$. As an example, let $A$ be the set $\{x,y,z\}$ and let $B$ be
$\{a,b,c\}$, the type $\frac{1}{A}$ has one element $\frac{1}{3}$ which is
one point that has three self loops labeled $x \path$, $y \path$, and $z
\path$. A value $(\frac{1}{3},a)$ is a fiber of the function that produces
$a$ as the second component indicates. The first component states that the
$a$ could have come from $x$ along the path $x \path$, or from $y$ along the
path $y \path$ or from $z$ along the path $z \path$.
\newpage
What can we say in pi about these two combinators:
\begin{verbatim}
Let f : A -> C and G : B -> D
(id x g) o (f x id) : A x B -> C x D
(f x id) o (id x g) : A x B -> C x D
\end{verbatim}
Are they the ``same''? We can reason extensionally to check that for all
inputs these two combinators produce the same results. In other words, we
reason from the axioms of category theory which includes things like
\verb|f o id = f| which are extensional equalities. (If we had weak
$n$-categories here what would happen, perhaps this is where we are leading
with the next sentence.) Better is to reason topologically exploiting the
original connections established by Joyal and
Street~\cite{planardiagrams,geometrytensor}. One can in this case show the
equivalence of these combinators by using the graphical language and noticing
that there is a \emph{planar isotopy} between the two diagrams, that moves
things around without crossing, cutting, or gluing any wires.
More formally, we view each type as a topological space and each function as
a deformation of the space expressed as a (sequential, parallel, etc.)
composition of primitive deformations (id, swap, unit, assoc, distribute,
factor, etc.). If we have a planar monoidal category, then there isn't much
you can do: the types are collections of lines grouped in bundles. The only
deformations that functions can do are to re-associate the bundles and get
rid of unit wires. (If the ambient space is a plane, i.e., if we restrict our
``hardware model'' to be a 2D model in which wires can't cross over each
other, then we can't even equate the functions that apply id to different
bundles. If the ambient space is 3D then we can. Eq. 3.2 in Selinger's survey
of graphical languages for monoidal categories.) An example of two functions
we can show to be the same in the planar model is the one above in the
verbatim block. An isotopy exists between the two combinators because we can
move things around in the plane as long as we don't cross or cut any wires.
If we allow braiding (i.e, commutativity) we must move to ambient isotopies
in 3D. In particular, the two versions of not that cross true over false or
vice versa are not isotopic.
If we also want, the composition of not and not to be expressible directly as
a twist, we must move to \emph{framed} isotopies in 3 dimensions, where the
lines are represented as flat ribbons.
A symmetric monoidal category requires ambient isotopy in 4 dimensions so
we're not going to consider it.
If we are going to have higher-order functions, we need to move up, i.e., we
need to build a space in which the types are the functions of the lower
level, and in which the functions are the isotopies of the lower level. In
other words, we need to be able to express the lower level functions as
topological spaces and we need to be able to express the lower level
isotopies as functions.
Think of a function as a map connecting points from one space to points in
the other space (respecting paths etc.). This map gives a geometric shape. We
will think of one line in that shape as solid with all the other lines dashed.
Another unrelated observation is that Pi gives us an inductive
characterization of functions! If that whole thing with fractionals
works out we will have an inductive characterization of higher-order
functions!
In homotopy type theory, there is a focus on isomorphisms: for most of the
spaces an isomorphism between $A$ and $B$ is represented by a path denoting a
particular proof of the identify $A \equiv B$. Different proofs yield
different paths and these proofs can be related by 2-paths to reason about
proof equivalence and so on. Yet in the middle of all these identities and
isomorphisms, conventional homotopy type theory deals with arbitrary
functions, then defines what it means \emph{extensionally} for functions to
be isomorphic, and \emph{then} postulates an axiom that extensionally
equivalent functions are identical in the sense of having a path between
them. This treatment gives no insight about the nature paths between
functions and is undesirable for many reasons.
We propose to just consider functions that are isomorphisms by
construction. This doesn't lose anything in terms of computability because we
know that we could do everything with reversible functions if we wanted
to. There are actually many advantages of doing so as we and others have
argued at length before. Anyway, the point is that if we have
isomorphisms-by-construction functions then the function itself becomes
naturally a collection of paths. We illustrate this point with examples.
Consider the function $\notb$ from the space $\boolt$ to itself. We can
represent this function as a pair of paths. Since we are in a topological
world, we should care about how the paths cross over each other. In the
diagram below, we chose for the top path to cross over the bottom one:
\begin{center}
\begin{tabular}{@{}llc@{}}
$\notb : \boolt \rightarrow \boolt$ & &
$\vcenter{\wirechart{@C=1.5cm@R=0.8cm}{
*{}\wireright{r}{\ffv}&\blank\wirecross{d}\wireright{r}{\ffv}&\\
*{}\wireright{r}{\ttv}&\blank\wirebraid{u}{.3}\wireright{r}{\ttv}&
}}$
\end{tabular}
\end{center}
It is important to note that the two paths must be taken together
because there is a constraint between them. If the top path takes $\ffv$ to
$\ttv$ then the bottom path cannot take $\ttv$ to $\ttv$: it \emph{has} to
lead to $\ffv$. In other words, it is incorrect to focus only on the top path
and conclude that there is an identity between $\ffv$ and $\ttv$. What is
correct is that, collectively, there is an identity between $\boolt$ and
$\boolt$ that permutes the elements of $\boolt$. Technically we have a
\emph{braid}.
We will return to this point later. But for now, consider the functions:
\[\begin{array}{rcl}
\idc^1 &=& \lambda x.x \\
\idc^2 &=& \lambda x. \notb~(\notb~x)
\end{array}\]
These two functions are evidently extensionally equivalent and hence in the
conventional treatment of homotopy type theory, they are also treated as
propositionally equivalent by the function extensionality axiom. When the
functions themselves are represented as paths, however, we get the following
situation for the second function:
\[
\idc^2 = \lambda x.\notb~(\notb~x) \qquad
\vcenter{\wirechart{@C=1.5cm@R=0.8cm}{
*{}\wireright{r}{\ffv}&
\blank\wirecross{d}\wireright{r}{\ffv}&
\blank\wirecross{d}\wireright{r}{\ffv}&
\\
*{}\wireright{r}{\ttv}&
\blank\wirebraid{u}{.3}\wireright{r}{\ttv}&
\blank\wirebraid{u}{.3}\wireright{r}{\ttv}&
\\
}}
\]
Repeating the $\notb$ operation results in a twisted braid that extensionally
behaves like the trivial braid but that is evidently not identical to
it. Formally to find a (2-)path between the functions requires us to find an
\emph{isotopy} between the two braids, where loosely speaking an isotopy is
essentially homotopy in the case of bijections. The two braids for $\idc^1$
and $\idc^2$ are \emph{not} isotopic so there is no path between them in our
world. What is interesting is that the braid isotopy problem has efficient
solutions and hence we are in a situation where function equivalence has
efficient algorithms.
Note that one can define another version of boolean negation $\notb'$ in
which the bottom path is the one that crosses over the top one. Using this
version, the function $\idc^3 = \lambda x.\notb'~(\notb~x)$ would look like:
\[
\idc^3 = \lambda x.\notb'~(\notb~x) \qquad
\vcenter{\wirechart{@C=1.5cm@R=0.8cm}{
*{}\wireright{r}{\ffv}&
\blank\wirecross{d}\wireright{r}{\ffv}&
\blank\wirebraid{d}{.3}\wireright{r}{\ffv}&
\\
*{}\wireright{r}{\ttv}&
\blank\wirebraid{u}{.3}\wireright{r}{\ttv}&
\blank\wirecross{u}\wireright{r}{\ttv}&
\\
}}
\]
And this version is isotopic to the trivial braid, and hence we would have a
(2-)path between $\idc^1$ and $\idc^3$.
To summarize, if we restrict our attention to a certain class of functions,
these functions are naturally described as braids and function equivalence
(i.e, paths between functions) are generated by braid isotopy. This is
already quite neat but note that we have only talked about functions
\emph{between} spaces and modeled these as braids. What we have not done yet
is describe the space of functions itself. In our running example, we need to
describe some space $\boolt \lolli \boolt$ that represents the various
functions we discussed from $\boolt$ to $\boolt$.
%%%%%%%%%%%%%%%%%
\subsection{Pointed Spaces}
We will construct this in steps. First we note that a function is a ``large''
object that can be applied to many possible arguments. Each application is
however associated with exactly one argument. Thus, in this first step, we do
not model functions in their entirety; we only model functions \emph{at one
particular point}. We will return to the issue of modeling the entire
function object later. For now, we have technically moved from \emph{spaces}
to \emph{pointed spaces}. Let's revisit our previous discussion from the
perspective of pointed spaces.
The type $\boolt$ is now split in two types: the type $(\boolt,\ffv)$ with
$\ffv$ as the distinguished point and $(\boolt,\ttv)$ with $\ttv$ as the
distinguished point. We now have two copies of the function $\notb$, a
version $\notb_{\ffv} : (\boolt,\ffv) \rightarrow (\boolt,\ttv)$ and a
version $\notb_{\ttv} : (\boolt,\ttv) \rightarrow (\boolt,\ffv)$ depending on
the starting basepoint. Indeed functions must respect the basepoints, i.e.,
map basepoints to basepoints. The function is still a braid on the complete
$\boolt$ space but in the first case, the distinguished point $\ffv$ tells us
that the function is ``applied'' to $\ffv$ and hence that the top branch is
the one in focus.
Concretely then we want spaces (i.e., groupoids) $(\boolt,\ffv) \lolli
(\boolt,\ffv)$, $(\boolt,\ffv) \lolli (\boolt,\ttv)$, $(\boolt,\ttv) \lolli
(\boolt,\ffv)$, and $(\boolt,\ttv) \lolli (\boolt,\ttv)$. As examples, the
first space will contain $\idc^1_{\ffv}$ and $\idc^3{\ffv}$; the second space
will contain $\notb_{\ffv}$ and $\notb'_{\ffv}$; the third space will contain
$\notb_{\ttv}$, and the last space will contain $\idc^1_{\ttv}$. In the first
space, there will be a path between $\idc^1_{\ffv}$ and $\idc^3{\ffv}$ as
there is an isotopy between them etc. To describe these spaces fully, we need
introduction rules, elimination rules, computation rules, and induction
principles, etc. It should be clear that we can't just use
$\lambda$-expressions as introduction rules: they are not refined enough to
capture all the invariants we want.
Let's start with some basic observations. How many points (i.e., functions or
braids) are there in the space $(\boolt,\ffv) \lolli (\boolt,\ffv)$. These
are all the twists on two elements with the paths starting and ending at
$\ffv$ highlighted: by giving a twist in one direction the value $+1$ and a
twist in the other direction the value $-1$, we see that this is isomorphic
to the integers under addition. We would like to argue that this space has
groupoid cardinality 1 and if we succeed then it is natural to think of it as
the product of a space with fractional cardinality $\frac{1}{2}$ and the
space $\boolt$ with cardinality 2. Think of all the words over the alphabet
$\{ 0, 1, -1\}$ with rules $0x\rightarrow x$, $x0\rightarrow x$,
$1(-1)\rightarrow\epsilon$ and $(-1)1\rightarrow\epsilon$. This produces
equivalence classes which describe the connected components (isotopy
equivalences) of the space $\boolt\lolli\boolt$. Let's denote by $V_n$ the
size of the equivalence class of words whose value is $n$ where the value is
the sum of the elements. The groupoid cardinality of the space is therefore
$\Sigma_{n\in\mathbb{Z}} \frac{1}{A_n}$. Does this thing have value 1???
Plausible. Assume yes for now and proceed under the assumption that it is 1
and hence that it makes sense to decompose the space into the product of
something of cardinality $\frac{1}{2}$ and something of cardinality $2$. So
what kind of groupoid would have cardinality $\frac{1}{2}$. This actually is
something well studied. Talk about groupoid cardinality and give an example
of how the cardinality of a group of order $n$ is $\frac{1}{n}$. Some
intuition about the paths reducing the number of elements and the Euler
characteristic.
%%%%%%%%%%%%%%%%%
\subsection{Fractionals}
As an example, let's focus now on building the type
$\frac{1}{(\boolt,\ffv)}$: it will correspond to the braid group $\br_2$ on
two strands. This type will have an infinite number of points each
representing one element of the braid group $\br_2$. Mathematically, for $n$
strands, the braid group $\br_n$ is generated by $\sigma_1, \ldots,
\sigma_{n-1}$ and the following relations:
\begin{itemize}
\item $\sigma_i\sigma_{i+1}\sigma_i = \sigma_{i+1}\sigma_{i}\sigma_{i+1}$,
\item $\sigma_i\sigma_j = \sigma_j\sigma_i$ if $|i-j| \geq 2$.
\end{itemize}
So for the particular case of $\br_2$, we have one generator $\sigma$ and no
relations. The generator corresponds to one non-trivial twist in one
direction. The group elements (i.e., the elements of
$\frac{1}{(\boolt,\ffv)}$) are the trivial braid, the $n$-fold compositions
of $\sigma$ for all $n$, and the $n$-fold compositions of $\sigma^{-1}$ for
all $n$.
So generally speaking $\eta_n$ will produce a product of $\br_n$ and $n$ and
$\epsilon_n$ will be the group action of the group on $\br_n$ on the
particular strand $n$. A function will have a particular wiring; this wiring
is reflected as a first class value using the group generators. For booleans,
the group generators can be represented as id, not, and not'; every wiring is
a sequence of these. So values of type $1/bool$ are (id), (not o not'), (not'
o not'), (not o not o not), etc. or in other words the code for the circuits
becomes represented as a value. (Is that related to the encode/decode method
in the HoTT book?) How about functions: T1 -> T2. The types T1 and T2 must be
connected by paths so we might as well think about T1 -> T1.
So B has value f and t
1/B has values id; not; not'; and their compositions (semantically
represented as elements of the group Br2.
eta : (1,()) -> ((B,1/B),(f,id))
eta () = (f , id)
eta : (1,()) -> ((B,1/B),(f,not))
eta () = (t , not)
...
epsilon : ((B,1/B),(f,not)) -> (1,())
epsilon (t , not) = ()
...
%%%%%%%%%%%%%%%%%
\subsection{Negatives?}
Need operations to change the basepoint. Would these be the negatives?
%% \begin{center}
%% \begin{tabular}{@{}llc@{}}
%% Braiding & $\sym_{A,B}$ &
%% $\vcenter{\wirechart{@C=1.5cm@R=0.8cm}{
%% *{}\wireright{r}{B}&\blank\wirecross{d}\wireright{r}{A}&\\
%% *{}\wireright{r}{A}&\blank\wirebraid{u}{.3}\wireright{r}{B}&
%% }}$ \\
%% \end{tabular}
%% \end{center}
%% Note that the braiding satisfies
%% $\sym_{A,B}\cp\symi_{A,B}=\id_{A\x B}$, but not
%% $\sym_{A,B}\cp\sym_{B,A}=\id_{A\x B}$. Graphically:
%% \[\vcenter{\wirechart{@C=1.5cm@R=0.8cm}{
%% *{}\wireright{r}{B}&
%% \blank\wirecross{d}\wireright{r}{A}&
%% \blank\wirebraid{d}{.3}\wireright{r}{B}&
%% \\
%% *{}\wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{B}&
%% \blank\wirecross{u}\wireright{r}{A}&
%% \\
%% }}
%% = \id_{A\x B},
%% \]
%% \[\vcenter{\wirechart{@C=1.5cm@R=0.8cm}{
%% *{}\wireright{r}{B}&
%% \blank\wirecross{d}\wireright{r}{A}&
%% \blank\wirecross{d}\wireright{r}{B}&
%% \\
%% *{}\wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{B}&
%% \blank\wirebraid{u}{.3}\wireright{r}{A}&
%% \\
%% }}
%% \neq \id_{A\x B}.
%% \]
%% \begin{example}
%% The hexagon axiom translates into the following in the graphical
%% language:
%% \[ (\id_B\x\sym_{A,C}) \cp \alpha_{B,A,C} \cp (\sym_{A,B}\x\id_C)
%% = \alpha_{B,C,A} \cp (\sym_{B,C\x A}) \cp \alpha_{A,B,C}
%% \]
%% \[\vcenter{\wirechart{@R=6mm}{
%% \wireright{r}{C}&
%% \wireid\wireright{r}{C}&
%% \blank\wirecross{d}{.3}\wireright{r}{A}&
%% \\
%% \wireright{r}{B}&
%% \blank\wirecross{d}{.3}\wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{C}&
%% \\
%% \wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{B}&
%% \wireid\wireright{r}{B}&
%% \\
%% }}
%% \ssep=\ssep
%% \vcenter{\wirechart{@R=6mm}{
%% \wireright{r}{C}&
%% \blank\wirecross{d}{.3}\wireright{r}{A}&
%% \\
%% \wireright{r}{B}&
%% \blank\wirecross{d}{.3}\wireright{r}{C}&
%% \\
%% \wireright{r}{A}&
%% \blank\wirebraid{uu}{.2}\wireright{r}{B}&
%% \\
%% }}
%% \]
%% \end{example}
%% \begin{example}
%% The {\em Yang-Baxter equation} is the following equation, which is a
%% consequence of the hexagon axiom and naturality:
%% \[ (\sym_{B,C}\x\id_A)\cp(\id_B\x\sym_{A,C})\cp(\sym_{A,B}\x\id_C) =
%% (\id_C\x\sym_{A,B})\cp(\sym_{A,C}\x\id_B)\cp(\id_A\x\sym_{B,C}).
%% \]
%% In the graphical language, it becomes:
%% \[\vcenter{\wirechart{@C-4mm@R=6mm}{
%% \wireright{r}{C}&
%% \wireid\wireright{r}{C}&
%% \blank\wirecross{d}{.3}\wireright{r}{A}&
%% \wireid\wireright{r}{A}&
%% \\
%% \wireright{r}{B}&
%% \blank\wirecross{d}{.3}\wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{C}&
%% \blank\wirecross{d}{.3}\wireright{r}{B}&
%% \\
%% \wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{B}&
%% \wireid\wireright{r}{B}&
%% \blank\wirebraid{u}{.3}\wireright{r}{C}&
%% \\
%% }}
%% \ssep=\ssep
%% \vcenter{\wirechart{@C-4mm@R=6mm}{
%% \wireright{r}{C}&
%% \blank\wirecross{d}{.3}\wireright{r}{B}&
%% \wireid\wireright{r}{B}&
%% \blank\wirecross{d}{.3}\wireright{r}{A}&
%% \\
%% \wireright{r}{B}&
%% \blank\wirebraid{u}{.3}\wireright{r}{C}&
%% \blank\wirecross{d}{.3}\wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{B}&
%% \\
%% \wireright{r}{A}&
%% \wireid\wireright{r}{A}&
%% \blank\wirebraid{u}{.3}\wireright{r}{C}&
%% \wireid\wireright{r}{C}&
%% \\
%% }}
%% \]
%% \end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{The Category of Pointed Groupoids}
%%%%%%%%%%%%%%%%%
\subsection{Paths}
\begin{definition}[Path]
A \emph{path} $p : x \path y$ between two points $x$ and $y$ in some space
$A$ is a directed edge $p$ from $x$ to $y$. We denote the set of paths of the
space $A$ as $\paths{A}$.
\end{definition}
\begin{definition}[Disjoint union of paths]
Given $\paths{A}$ and $\paths{B}$ in spaces $A$ and $B$ respectively, we
construct $\paths{A} \uplus^p \paths{B}$ in space $A \uplus B$, the disjoint
union of $A$ and $B$, as follows:
\[
\{ \leftv{p} : \leftv{x} \path \leftv{y} ~|~
(p : x \path y) \in \paths{A} \}
\union
\{ \rightv{q} : \rightv{x} \path \rightv{y} ~|~
(q : x \path y) \in \paths{B} \}
\]
\end{definition}
We will sometimes write this as $\leftv{(\paths{A})} \union
\rightv{(\paths{B})}$.
\begin{definition}[Product of paths]
Given $\paths{A}$ and $\paths{B}$ in spaces $A$ and $B$
respectively, we construct $\paths{A} \times^p \paths{B}$ in
space $A \times B$, the cartesian product of $A$ and $B$, as follows:
\[
\{ (p,q) : (x,z) \path (y,w) ~|~ (p : x \path y) \in \paths{A},
(q : z \path w) \in \paths{B} \}
\]
\end{definition}
We will sometimes write this as $(\paths{A},\paths{B})$.
%%%%%%%%%%%%%%%%%
\subsection{Pointed Groupoids}
\begin{definition}[Groupoid]
A \emph{groupoid} $G = (G_0, \paths{G_0})$ is a set $G_0$ together
with a collection of paths $x \path y$, between elements $x$ and $y$ of $G_0$
that satisfies the following conditions:
\begin{itemize}
\item for every $x \in G_0$, there is a path $\refl_x : x \path x$,
\item every path $p : x \path y$, there is an inverse path $! p : y \path x$,
\item for every paths $p : x \path y$ and $q : y \path z$ there is a path $p
\circ q : x \path z$, and
\item for every paths $p : x \path y$, $q : y \path z$, and $r : z \path w$,
we have:
\begin{itemize}
\item $\refl_x \circ p = p$;
\item $p \circ \refl_y = p$;
\item $(p \circ q) \circ r = (p \circ (q \circ r))$;
\item $p \,\circ\, !p = \refl_x$;
\item $!p \,\circ\, p = \refl_y$.
\end{itemize}
\end{itemize}
\end{definition}
When introducing a groupoid, we only explicitly mention a collection of
non-trivial ``generating'' paths. The equivalence closure under $\refl$, $!$,
and $\circ$ with the appropriate conditions is implicitly
assumed.\footnote{For higher groupoids, the five equivalences in the last
condition will be witnessed by paths between paths and not by the
extensional equivalence relation $=$.}
\begin{definition}[Pointed groupoid]
A pointed groupoid $G_{\bullet} = (G_0, \bot_{G_0}, \paths{G_0})$ is
a groupoid $(G_0, \paths{G_0})$ with a distinguished element
$\bot_{G_0} \in G_0$.
\end{definition}
\begin{definition}[Wedge sum]
The \emph{wedge sum} of two pointed groupoids $G_\bullet$ and $H_\bullet$,
written $G_\bullet \wedgesum H_\bullet$ is defined as follows:
\[\begin{array}{l}
(G_0, \bot_{G_0}, \paths{G_0}) \wedgesum
(H_0, \bot_{H_0}, \paths{H_0}) = \\
((G_0 \uplus H_0) \union \{ \bot \},
\bot,
(\paths{G_0} \uplus^p \paths{H_0}) \union
\{ L: \leftv{\bot_{G_0}} \path \bot,
R: \rightv{\bot_{H_0}} \path \bot \})
\end{array}\]
where $\uplus$ is the disjoint union operation on sets and $\bot$ is a new
distinguished element that is related by new paths to the distinguished
elements of $G_\bullet$ and $H_\bullet$.
\end{definition}
\begin{definition}[Smash product]
The \emph{smash product} of two pointed groupoids $G_\bullet$ and
$H_\bullet$, written $G_\bullet \smashproduct H_\bullet$ is defined as
follows:
\[\begin{array}{l}
(G_0, \bot_{G_0}, \paths{G_0}) \smashproduct
(H_0, \bot_{H_0}, \paths{H_0}) = \\
((G_0 \times H_0) \union \{ \bot \},
\bot,
(\paths{G_0} \times^p \paths{H_0}) \union
\{ F_h: (\bot_{G_0},h) \path \bot \} \union
\{ S_g: (g,\bot_{H_0}) \path \bot \}
\end{array}\]
where $\times$ is the cartesian product operation on sets and $\bot$ is a new
distinguished element that is related by new paths to every pair of elements
that includes either $\bot_{G_0}$ or $\bot_{H_0}$.
\end{definition}
\begin{definition}[Denotation of types]
Each type $b$ is mapped to a \emph{pointed groupoid} $(\dt{b}, \bot_b,
\paths{b})$ as follows:
\[\begin{array}{rcl@{\qquad}l}
\dt{0} &=& (\{ \bot_0 \}, \bot_0, \{ \mathit{loop}_0 : \bot_0 \path \bot_0 \}) &
(\mbox{circle}) \\
\dt{1} &=& (\{ \bullet, \bot_1 \}, \bot_1,
\{ \mathit{loop}_1 : \bot_1 \path \bot_1 \}) &\\
\dt{(b_1 + b_2)} &=& \dt{b_1} \wedgesum \dt{b_2} &
(\mbox{wedge~sum}) \\
\dt{(b_1 * b_2)} &=& \dt{b_1} \smashproduct \dt{b_2} &
(\mbox{smash~product})
\end{array}\]