-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiny.tex
More file actions
2640 lines (2413 loc) · 129 KB
/
tiny.tex
File metadata and controls
2640 lines (2413 loc) · 129 KB
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
\pdfoutput=1
\documentclass[10pt]{article}
\usepackage{fullpage}
\usepackage{authblk}
\thickmuskip=5mu plus 3mu minus 1mu
\medmuskip=4mu plus 2mu minus 3mu
\makeatletter
% Remove the * from the \thanks footnote
\def\thanks#1{\protected@xdef\@thanks{\@thanks\protect\footnotetext{#1}}}
\makeatother
\usepackage{microtype}
\usepackage{amssymb,amsthm}
% \usepackage{thmtools}
\usepackage{amsmath}
\usepackage{stmaryrd}
% \usepackage{wasysym}
\usepackage{mathpartir}
\usepackage{tikz-cd}
\usepackage{enumitem} % For enumerating cases
\newlist{casesp}{enumerate}{1}
\setlist[casesp]{align=left, %% alignment of labels
listparindent=\parindent, %% same indentation as in normal text
parsep=\parskip, %% same parskip as in normal text
font=\normalfont\it, %% font used for labels
leftmargin=10pt, %% total amount by which text is indented
labelwidth=10pt, %% width of labels (=how much they stick out on the left because align=left)
itemindent=.4em,
itemsep = 3\itemsep,
labelsep=.4em,
partopsep=0pt, %% extra vertical space above and below if separate paragraph
}
\setlist[casesp,1]{label=Case:,ref=\arabic*}
\usepackage{graphicx}
\usepackage{scalerel}
\usepackage{fontawesome}
\usepackage{xcolor}
\usepackage[status=draft,inline,nomargin]{fixme}
\FXRegisterAuthor{mvr}{anmvr}{\color{blue}MVR}
\usepackage[style=alphabetic, maxbibnames=99, maxalphanames=99, mincrossrefs=99]{biblatex}
\addbibresource{types.bib}
\usepackage{hyperref}
\usepackage[capitalise,noabbrev]{cleveref}
\hypersetup{colorlinks,allcolors=[rgb]{0.1,0.1,0.4}}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{example}[theorem]{Example}
\newtheorem{question}{Question}
\let\oldequiv\equiv%
\renewcommand{\equiv}{\simeq}
\newcommand{\defeq}{\oldequiv}
\newcommand{\ndefeq}{\not\defeq}
\newcommand{\rulen}[1]{\textsc{#1}}
\newcommand{\yields}{\vdash}
% \newcommand{\qyields}{\Vdash}
\newcommand{\cbar}{\, | \,}
\newcommand{\judge}{\mathcal{J}}
% \newcommand{\freshfor}{\mathbin{\#}}
\newcommand{\ctx}{\,\,\mathsf{ctx}}
\newcommand{\type}{\,\,\mathsf{type}}
\newcommand{\tele}{\,\,\mathsf{tele}}
\newcommand{\rawterm}{\,\,\mathsf{rawterm}}
% Ordinary HoTT notation
\newcommand{\Idsym}{\mathsf{Id}}
\newcommand{\Id}{\mathsf{Id}}
% \newcommand{\Id}[3]{\mathsf{Id}_{{#1}}(#2,#3)}
% \newcommand*{\trunc}[2]{\mathopen{}\left\Vert #2\right\Vert_{#1}\mathclose{}}
% \newcommand*{\strunc}[2]{\mathopen{}\left\Vert #2\right\Vert_{#1}^s\mathclose{}}
\newcommand*{\univ}{\mathcal{U}}
\newcommand*{\NN}{\mathbb{N}}
\newcommand*{\ZZ}{\mathbb{Z}}
\newcommand*{\RR}{\mathbb{R}}
% \newcommand*{\true}{\star}
\newcommand*{\id}{\mathsf{id}}
\newcommand*{\proj}{\mathsf{pr}}
% \newcommand*{\pushpr}{\mathbin{\wasysquare}}
% \newcommand*{\join}{\ast}
\newcommand*{\ap}{\mathsf{ap}}
\newcommand*{\transp}{\mathsf{tr}}
\newcommand*{\isContr}{\mathsf{isContr}}
\newcommand*{\isEquiv}{\mathsf{isEquiv}}
% \newcommand*{\isSpace}{\mathsf{isSpace}}
% \newcommand*{\isModal}{\mathsf{isModal}}
\newcommand*{\inl}{\mathsf{inl}}
\newcommand*{\inr}{\mathsf{inr}}
% \newcommand*{\glue}{\mathsf{glue}}
% \newcommand*{\code}{\mathsf{code}}
% \newcommand*{\encode}{\mathsf{encode}}
% \newcommand*{\decode}{\mathsf{decode}}
\newcommand*{\const}{\mathsf{const}}
\newcommand*{\fib}{\mathsf{fib}}
\newcommand*{\case}{\mathsf{case}}
\newcommand*{\refl}[1]{\mathsf{refl}_{#1}}
\newcommand*{\pathind}[3]{\mathsf{let} \; \refl{#2} = {#1} \,
\mathsf{in} \, {#3}}
% \newcommand*{\cupann}[2]{\mathbin{\tensor*[_{#1}]{\cup}{_{#2}}}}
\newcommand{\bang}{\mathord{!}}
\newcommand{\ind}[3]{\mathsf{let} \; {#2} = {#1} \, \mathsf{in} \, {#3}}
% \makeatletter
% \newcommand{\@thesum}[1]{(#1) \times}
% \newcommand{\sm}[1]{\@ifnextchar\bgroup{\@thesum{#1}\sm}{\@thesum{#1}}}
% \newcommand{\@theprd}[1]{(#1) \to}
% \newcommand{\prd}[1]{\@ifnextchar\bgroup{\@theprd{#1}\prd}{\@theprd{#1}}}
% \makeatother
\makeatletter \def\smsym{\sum}
\newcommand{\@thesum}[1]{\smsym_{(#1)}}
\newcommand{\sm}[1]{\@ifnextchar\bgroup{\@sm{#1}\sm}{\@sm{#1}}}
\newcommand{\@sm}[1]{\mathchoice{{\textstyle\@thesum{#1}}}{\@thesum{#1}}{\@thesum{#1}}{\@thesum{#1}}}
\def\prdsym{\prod}
\newcommand{\@theprd}[1]{\prdsym_{(#1)}}
\newcommand{\prd}[1]{\@ifnextchar\bgroup{\@prd{#1}\prd}{\@prd{#1}}}
\newcommand{\@prd}[1]{\mathchoice{{\textstyle\@theprd{#1}}}{\@theprd{#1}}{\@theprd{#1}}{\@theprd{#1}}}
\makeatother
\newcommand*{\lolli}{\multimap}
% \newcommand{\lock}{\text{\faLock}}
\newcommand{\lock}{\mathchoice {\scalebox{0.8}{\text{\faLock}}}
{\scalebox{0.8}{\text{\faLock}}} {\scalebox{0.5}{\text{\faLock}}}
{\scalebox{0.4}{\text{\faLock}}} }
\newcommand{\unlock}{\text{\faUnlock}}
\newcommand{\key}{\mathchoice
{\scalebox{0.8}{\text{\faKey}}} {\scalebox{0.8}{\text{\faKey}}}
{\scalebox{0.5}{\text{\faKey}}} {\scalebox{0.4}{\text{\faKey}}} }
\newcommand{\rbindsym}{%
\mathchoice
{\reflectbox{\rotatebox[origin=c]{185}{$\lambda$}}} % display
{\reflectbox{\rotatebox[origin=c]{185}{$\lambda$}}} % text
{\reflectbox{\rotatebox[origin=c]{185}{$\scriptstyle\lambda$}}} % script
{\reflectbox{\rotatebox[origin=c]{185}{$\scriptscriptstyle\lambda$}}} % scriptscript
}
\newcommand{\rbind}[1]{\rbindsym{} #1.}
% lol
% \newcommand{\rbind}[1]{. #1 \rbindsym{}}
\newcommand{\Tiny}{\mathbb{T}}
\newcommand{\lockn}[1]{\mathcal{#1}}
\newcommand{\locksin}[1]{\mathsf{locks}(#1)}
\newcommand{\varkeye}[2]{\key_{#1}^{#2}}
\newcommand{\varkey}[2]{\varkeye{\lockn{#1}}{#2}}
\newcommand{\admkeye}[2]{\overrightarrow{\key}_{#1}^{#2}}
\newcommand{\admkey}[2]{\admkeye{\lockn{#1}}{#2}}
\newcommand{\ctxlocke}[1]{\lock_{#1}}
\newcommand{\ctxlock}[1]{\ctxlocke{\lockn{#1}}}
% \newcommand{\ctxopen}[2]{\unlock_{\lockn{#1}}^{\,#2}}
% \newcommand{\stubra}[1]{\llbracket #1 \rrbracket}
% \newcommand{\stubra}[1]{\lfloor #1 \rfloor}
\newcommand{\stubra}[1]{\{\!\!\{ #1 \}\!\!\}}
% \newcommand{\admbra}[1]{[ #1 ]}
\newcommand{\admbra}[1]{\{\mkern-1mu #1 \mkern-0.5mu\}}
% \newcommand{\subkeyoe}[2]{#1/\key_{#2}}
\newcommand{\subkeysep}[2]{#1/#2}
\newcommand{\subkeyo}[2]{\subkeysep{#1}{\lockn{#2}}}
\newcommand{\subkey}[2]{\admbra{\subkeyo{#1}{#2}}}
% \newcommand{\substucke}[2]{\stubra{#1/\key_{#2}}}
\newcommand{\substuck}[2]{\stubra{#1/\lockn{#2}}}
% \newcommand{\sublock}[2]{\admbra{\lock_{\lockn{#1}}/#2}}
% \newcommand{\sublock}[2]{\admbra{\rbindsym{} #1. /\lock_{\lockn{#2}} }}
\newcommand{\sublock}[2]{\admbra{\rbindsym{} #1. /\lockn{#2} }}
% \newcommand{\sublock}[2]{\admbra{ .#2 \rbindsym{} /\lock_{\lockn{#1}} }}
\newcommand{\rformsym}{\surd}
\newcommand{\rformslicesym}[1]{\surd_{\mkern-6mu/#1}}
\newcommand{\rforme}[2]{\ThisStyle{\raisebox{0.07em}{$\SavedStyle \rformsym_{\hspace{-0.25em}#1}$}} #2}
\newcommand{\rform}[2]{\rforme{\lockn{#1}}{#2}}
\newcommand{\rformu}[1]{\ThisStyle{\raisebox{0.07em}{$\SavedStyle \rformsym$}} #1}
% \newcommand{\rintroe}[2]{\mathsf{root}_{#1}(#2)}
\newcommand{\rintroe}[2]{\lock_{#1}. #2}
\newcommand{\rintro}[2]{\rintroe{\lockn{#1}}{#2}}
% \newcommand{\relim}[1]{\mathsf{unroot}(#1)}
% \newcommand{\rbindsym}{\rotatebox[origin=c]{180}{$\lambda$}}
\newcommand{\relim}[1]{\rbindsym #1}
% \newcommand{\rdepform}[2]{{\between^{#1}}#2}
\newcommand{\rdepform}[2]{{#2}^{1/#1}}
\newcommand{\rget}[1]{{#1}_{\downharpoonleft}}
\newcommand{\unit}[3]{\mathsf{unit}_{#1, #2, \lockn{#3}}}
\newcommand{\counit}[3]{\mathsf{counit}_{#1, \lockn{#2}, #3}}
\newcommand{\extract}{\mathsf{e}}
% Cubical stuff
\newcommand{\PSh}{\mathsf{PSh}}
\newcommand{\op}{\mathsf{op}}
\newcommand{\yo}{\mathsf{y}}
\newcommand{\Set}{\mathsf{Set}}
\newcommand{\C}{\mathcal{C}}
\newcommand{\El}{\mathsf{El}}
\newcommand{\univfib}{\mathsf{U}}
\newcommand{\Int}{\mathbb{I}}
\DeclareMathOperator{\isFib}{\mathsf{isFib}}
\DeclareMathOperator{\Fib}{\mathsf{Fib}}
\DeclareMathOperator{\isAFib}{\mathsf{isAFib}}
\DeclareMathOperator{\AFib}{\mathsf{AFib}}
\newcommand{\Compstr}{\mathsf{C}}
\title{A Type Theory with a Tiny Object}
\author{Mitchell Riley\thanks{The author is grateful for the support of Tamkeen under the
NYU Abu Dhabi Research Institute grant CG008.}}
\affil{\small New York University Abu Dhabi \\ \href{mailto:mitchell.v.riley@nyu.edu}{mitchell.v.riley@nyu.edu}}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
We present an extension of Martin-Löf Type Theory that contains a
tiny object; a type for which there is a \emph{right} adjoint to the
formation of function types as well as the expected left adjoint.
We demonstrate the practicality of this type theory by proving
various properties related to tininess internally and suggest a few
potential applications.
\end{abstract}
\tableofcontents
\section{Introduction}
Tiny objects are central to Lawvere's account of differential forms in
synthetic differential geometry~\cite{lawvere:towards}; a tiny object $\Tiny$ in a
category $\C$ is one with the amazing property that the internal hom
functor ${(\Tiny \to -) : \C \to \C}$ has a right adjoint
${\rformu - : \C \to \C}$. In synthetic differential geometry, the
\emph{infinitesimal interval} defined by
${D :\defeq \{ x : \mathbb{R} \mid x^2 = 0 \}}$ is one such object. This
object corepresents tangent spaces so that $D \to X$ is the tangent
space of $X$, and elements of $(D \to X) \to \RR$ are therefore
(not-necessarily linear) 1-forms on $X$. By tininess, such a form
corresponds to an element of $X \to \rformu \RR$, that is, 1-forms are
simply functions on $X$ valued in a highly non-standard space.
Additional properties like linearity, closedness, etc.\ may be imposed
by carving out an appropriate subobject of $\rformu \RR$. The notion
of tininess was anticipated by~\cite{kock-reyes:manifolds,
lawvere:categorical-dynamics} but its utility was first made
explicit in~\cite[\S 3]{lawvere:towards}, and it appears in much of
the ensuing work on synthetic differential
geometry~\cite{lawvere:laws-of-motion, lawvere:outline-sdg,
lawvere:microphysics, lawvere:adjoints, lawvere:euler-vindicated,
kock-reyes:differential-equations, kock-reyes:fractional, kock:sdg}.
Tininess is simultaneously unusual and abundant. Unusual because, in
the category of sets, only the singletons are tiny. This is easy to
check: $(\Tiny \to -)$ can only preserve coproducts when $\Tiny \cong 1$.
% \[(X \to Y) \cong (X \to \sqcup_Y 1) \cong \sqcup_Y (X \to 1) \cong
% \sqcup_Y 1 \cong Y,\] and so $X \cong 1$.
And abundant because, for any category $\C$ with finite products, the
representable presheaves on $\C$ are all tiny. An explicit formula for
the right adjoint to $(\Tiny \to -)$ with $\Tiny$ representable is
$\rformu{Y}(c) :\defeq \PSh(\C)(\Tiny \to \yo c, Y)$, as may be
verified by a little (co)end calculus. In favourable cases
representable sheaves are also tiny~\cite[Appendix
4]{moerdijk-reyes:book}, but this is less common.
% \begin{align*}
% \PSh(\C)(X^{\yo{c}}, Y)
% &\cong \int_{c':\C} \Set(X^{\yo{c}}(c'), Y(c')) \\
% &\cong \int_{c':\C} \Set(\PSh(\C)(\yo c' \times \yo c, X), Y(c')) \\
% &\cong \int_{c':\C} \Set(\PSh(\C)(\yo (c' \times c), X), Y(c')) \\
% &\cong \int_{c':\C} \Set(X(c' \times c), Y(c')) \\
% &\cong \int_{c':\C} \Set(X(c' \times c), Y(c')) \\
% &\cong \int_{c':\C} \Set(\int^{d:\C} X(d) \times \C(c' \times c, d), Y(c')) \\
% &\cong \int_{d:\C} \int_{c':\C} \Set(X(d) \times \C(c' \times c, d), Y(c')) \\
% &\cong \int_{d:\C} \int_{c':\C} \Set(X(d), \Set(\C(c' \times c, d), Y(c')) \\
% &\cong \int_{d:\C} \Set(X(d), \int_{c':\C} \Set(\C(c' \times c, d), Y(c')) \\
% &\cong \int_{d:\C} \Set(X(d), \PSh(\C)(\C(-\times c, d), Y)) \\
% \end{align*}
In this paper we tackle a challenge set by Lawvere, to produce a
formal system for working with tiny objects: ``This possibility does
not seem to have been contemplated by combinatory logic; the formalism
should be extended to enable treatment of so basic a
situation''~\cite[Section 3]{lawvere:adjoints}. We describe an
extension of Martin-Löf Type Theory that makes a fixed type $\Tiny$
tiny by introducing a type former $\rformu$ for the amazing right
adjoint to $(\Tiny \to -)$. The situation is a little subtle. Freyd
proves that for any tiny object $\Tiny$ in a topos, the pullback of
$\Tiny$ to any slice is also tiny~\cite[Theorem 1.4]{yetter:tiny}. But
the right adjoint witnessing this tininess is \emph{not} stable under
base-change. We therefore have to add to the context structure of type
theory in order to support this operation.
We add $\rformu$ as a `Fitch style'
modality~\cite{clouston:fitch-style, drats}, where the type former
$\rformu$ is made right adjoint to an operation on contexts. Such
modalities are particularly nice when they are a \emph{double}
right adjoint, and \textsf{FitchTT}~\cite{fitchtt} is designed for adding
modalities of this kind to MLTT\@. We are in such a situation, of
course, because
\[{(- \times \Tiny) \dashv (\Tiny \to -) \dashv \rformu -},\] and so
we could use~\cite{fitchtt} directly to produce a type theory.
But there is a special feature of $\rformu$ which impels us to create
a specialised theory for it. Specifically, the leftmost adjoint
$(- \times \Tiny)$ already exists as an operation on contexts: it is
simply context extension with $i : \Tiny$. We allow $\Tiny$ to be an
\emph{ordinary type}, rather than a pre-type or special piece of
syntax. This flexibility is essential for applications in synthetic
differential geometry where many important tiny objects may be
constructed internally as ordinary types. The only new context former
needed is something corresponding to $(\Tiny \to -)$, which we write
as context extension with a $\ctxlock{}$.
To make $(-,i:\Tiny) \dashv (-,\lock)$ on contexts, we need unit
$\Gamma \to (\Gamma,i : \Tiny, \lock)$ and counit
$(\Gamma,\lock,i : \Tiny) \to \Gamma$ substitutions. In~\cite{fitchtt}
these are added axiomatically, and the type theory is presented in a
variable-free CwF style where these explicit substitutions are pushed
around manually. The downside of the approach is that figuring out how
to use a variable could be potentially challenging: one may have to
devise by hand an explicit substitution that extracts the variable
from the context. One of our aims is to give a fully explicit variable
rule which builds in the normal forms of these `stuck substitutions'.
The reason this gets interesting is that, because $\Tiny$ is an
ordinary type, we can substitute \emph{any} term $t : \Tiny$ for $i$
in the counit substitution. And so, the admissible counit rule is
parameterised by a genuine term $t : \Tiny$. The counit rule commutes
with all type and term formers and becomes stuck on the ordinary
variable rule, so every use of a variable in this theory will have
(possibly many) attached terms of $\Tiny$ corresponding to these stuck
counits.
\paragraph{Related Work.}
In~\cite{lops}, a tiny interval $\mathbb{I}$ is used to construct,
internal to a 1-topos, a universe that classifies fibrations. This is
performed in `crisp type theory', a fragment of Shulman's spatial type
theory~\cite{mike:real-cohesive-hott}. The $\rformu$ type former is
described by a collection of axioms, and the fact that the adjunction
is external is enforced by requiring the inputs to these axioms to be
`crisp', roughly, protected by a use of the global sections/discrete
inclusion modality $\flat$. Internally, this manifests as an
equivalence
${\flat(A \to \rformu B) \equiv \flat((\Tiny \to A) \to B)}$. An
alternative axiomatisation that is coherent for higher types is given
in~\cite[Appendix A]{jaz:microlinear}, by instead asserting for each
crisp type $B$ a counit map $(\Tiny \to \rformu B) \to B$ such that
the induced map
${\flat(A \to \rformu B) \to \flat((\Tiny \to A) \to B)}$ is an
equivalence.
These equivalences guarded by $\flat$ are more restrictive than
necessary: we will prove an equivalence
${(A \to \rformu B) \equiv \rformu ((\Tiny \to A) \to B)}$, where $A$
and $B$ do not have to be `global types' (but the dependency of $B$ is
still somewhat restricted).
The most comparable type theory to ours is presented
in~\cite{transpension}. The authors give rules for a right adjoint to
the \emph{dependent product}
$\Pi_\Tiny : \mathcal{E}/\Tiny \to \mathcal{E}$ rather than the
non-dependent function type, an operation which they call
\emph{transpension}. It is a theorem of Freyd~\cite[Proposition
1.2]{yetter:tiny} that this is equivalent to the apparently weaker
notion of tininess. Because we target the non-dependent function type,
our new judgemental structures and rules are much simpler than those
for transpension, and let us maintain admissibility of substitution
and (conjecturally) normalisation; for transpension it is unclear
whether these are achievable.
The context extension with the tiny type is also treated specially,
similar to accounts of internal
parametricity~\cite{cavallo-harper:parametricity-for-ctt,
cavallo:thesis}~\cite[Section 5]{fitchtt} where the
$\Gamma, i : \Tiny$ context extension is a special piece of syntax,
and so only special `terms' may be substituted for it.
A benefit of these previous systems is that the precise notion of
tininess is easier to tweak. For example, whenever $\C$ is monoidal,
representable presheaves on $\C$ are \emph{monoidally tiny} in that
$(\Tiny \lolli -)$ has a right adjoint, where $\lolli$ denotes the Day
internal hom. This non-cartesian tininess is central to Higher
Observational Type Theory~\cite{mike:observational-day3}, whose
intended semantics are in a non-cartesian cubical category.
\paragraph{Contributions.}
\begin{itemize}
\item In~\cref{sec:contexts}, we introduce the new context structure
required to support the type former and in~\cref{sec:type} the
type-former itself.
\item In~\cref{sec:constructions}, we give a couple of useful
constructions that are definable internally. \cref{sec:induction}
shows that we can derive induction principles for functions out of
$\Tiny$, and \cref{sec:transpension} recovers the transpension
operation from our non-dependent right adjoint, providing a new
construction that applies in the univalent setting.
\item In~\cref{sec:applications}, we discuss some potential
applications of the type theory and a prototype type-checker
utilising an extension of the usual normalisation by evaluation
algorithm.
\end{itemize}
\paragraph{Terminology.} There is a constellation of terminology
around tininess and similar notions, with ``amazingly tiny'',
``atomic'', ``infinitesimal'', ``satisfying the ATOM property'',
``internally/externally projective'' and ``small-projective'' all used
to refer to one of $\C(\Tiny, -) : \C \to \Set$ or
$(\Tiny \to -) : \C \to \C$ preserving epimorphisms, finite colimits,
colimits or having a right adjoint. With additional assumptions many
of these notions coincide, but we follow~\cite{yetter:tiny} in
settling on simply ``tiny'' as the name for objects whose internal hom
has a right adjoint. The other properties play no role in this work.
There are also various notations for the right adjoint, including
$(-)_\Tiny$~\cite{yetter:tiny} and
$(-)^{1/\Tiny}$~\cite{lawvere:laws-of-motion}, and even
$\nabla_\Tiny$~\cite{yetter:tiny} and ${\between}-$ for
transpension~\cite{transpension}. We follow~\cite{lops} in using
$\rformu -$.
\paragraph{Acknowledgements.}
Thank you to David Jaz Myers, Andreas Nuyts and Jon Sterling for
helpful comments and suggestions. The author is grateful for the
support of Tamkeen under the NYU Abu Dhabi Research Institute grant
CG008.
% \mvrnote{\cite{gsb:implementing} work with MLTT as a substitution calculus}
\section{Contexts and Variables}\label{sec:contexts}
We take as our starting point the bare judgements of Martin-Löf Type
Theory. When using our theory we will also assume dependent sums,
products, intensional identity types and an infinite hierarchy of
universes, but the extension of type theory with a tiny object does
not require the presence of any other type-formers.
The $\rformu$ type-former will be added by making it right adjoint to
a judgemental version of ``$\Tiny \to \Gamma$'' which we write as
$\Gamma, \ctxlock{L}$. Here, so that we may refer to it, the lock is
annotated with a `lock name' $\lockn{L}$. This first section will be
spent adding the necessary rules for the context $\Gamma, \ctxlock{L}$
to behave like functions into $\Gamma$.
A simple way to achieve this would be to assert axiomatic unit and
counit substitutions for the $(- \times \Tiny) \dashv (\Tiny \to -)$
adjunction as in the following:
\begin{mathpar}
\inferrule*[left=unit-sub]
{\Gamma \ctx}
{\Gamma \yields \unit{\Gamma}{i}{L} : \Gamma, i : \Tiny, \ctxlock{L}}
\and
\inferrule*[left=counit-sub]
{\Gamma \ctx}
{\Gamma, \ctxlock{L}, i : \Tiny \yields \counit{\Gamma}{L}{i} : \Gamma}
\end{mathpar}
together with equations that explain how these explicit substitutions
are pushed around and annihilated.
We can do better, however, and give normal forms for the placement of
these explicit substitutions. The examples in later sections show that
it is quite feasible to work in the resulting type theory by hand.
Besides the context lock, we only need one additional base rule: a
modified version of the variable rule that builds in stuck instances
of the counit substitution. The rule is completely structural and
independent of the rules for types (besides the existence of $\Tiny$).
There are two new admissible rules, corresponding to precomposition
with the counit or unit substitutions.
We now describe the additions to MLTT one rule at a time.
\paragraph{The Tiny Type.} There is a closed type $\Tiny$.
\begin{mathpar}
\inferrule*[left=tiny-form]{~}{\Gamma \yields \Tiny \type}
\end{mathpar}
For applications in synthetic mathematics, this will often be an
internally definable closed type rather than a new one asserted
axiomatically.
\paragraph{Context Locks.} There is a special context extension,
\begin{mathpar}
\inferrule*[left=ctx-lock]{\Gamma \ctx}{\Gamma, \ctxlock{L} \ctx}
\and
\end{mathpar}
to be thought of as $\Tiny \to \Gamma$. We call $\lockn{L}$ a `lock
name', all lock names in a context are unique.
\paragraph{The Counit.} Because a locked context represents functions
into what comes before the lock, we can use variables to the left of
a lock if we can provide an argument to the function: this
corresponds to precomposition with the counit substitution, with a
substitution for $\Tiny$ and some contractions built-in.
The simplest situation we can encounter is
\begin{mathpar}
\inferrule*[left=counit?,fraction={-{\,-\,}-}]
{\Gamma \yields a : A \and \Gamma, \ctxlock{L}, \Gamma' \yields t : \Tiny \and \lock \notin \Gamma'}
{\Gamma, \ctxlock{L}, \Gamma' \yields a\subkey{t}{L} : A\subkey{t}{L}}
\end{mathpar}
corresponding (non-dependently) to the composite
\begin{align*}
(\Tiny \to \Gamma) \times \Gamma'
\xrightarrow{[\id, t]} (\Tiny \to \Gamma) \times \Gamma' \times
\Tiny
\xrightarrow{\proj} (\Tiny \to \Gamma) \times \Tiny
\xrightarrow{\varepsilon} \Gamma
\xrightarrow{a} A
\end{align*}
The new piece of term syntax is a stuck instance of this
$\subkey{t}{L}$ rule which we build into the variable rule below.
To distinguish the admissible rule from the stuck rule, we will
write the admissible rule as $\subkey{t}{L}$ and the actual stuck
syntax as $\substuck{t}{L}$. Roughly, the admissible $\subkey{t}{L}$
will add a $\substuck{t}{L}$ to every \emph{free} variable usage in
$a$, much like the underlining operation in the type theory for
$\natural$~\cite{rfl:spec-note}.
We need to generalise this rule in a couple of ways. First, we need
to allow an additional telescope to be carried along, so that we may
go under binders in the term $a : A$.
Additionally, we may need to apply the counit to multiple locks
simultaneously. To facilitate this, for a context
$\Gamma, \Gamma' \ctx$ let $\locksin{\Gamma'}$ denote the (ordered)
list of context locks
$\ctxlocke{\lockn{L}_1}, \dots, \ctxlocke{\lockn{L}_n}$ that appear
in the telescope $\Gamma'$.
The generalised rule is then:
\begin{mathpar}
\inferrule*[left=counit-tele,fraction={-{\,-\,}-}]
{\Gamma \yields \Gamma'' \tele \and \Gamma, \Gamma' \yields t_i : \Tiny
\text{ for } \lockn{L}_i \in \locksin{\Gamma'} }
{\Gamma, \Gamma' \yields \Gamma'' \admbra{\subkeysep{t_1}{\lockn{L}_1}, \dots, \subkeysep{t_n}{\lockn{L}_n}} \tele} \and
\inferrule*[left=counit,fraction={-{\,-\,}-}]
{\Gamma, \Gamma'' \yields a : A \and \Gamma, \Gamma' \yields t_i : \Tiny
\text{ for } \lockn{L}_i \in \locksin{\Gamma'} }
{\Gamma, \Gamma', \Gamma'' \admbra{\subkeysep{t_1}{\lockn{L}_1}, \dots, \subkeysep{t_n}{\lockn{L}_n}} \yields a \admbra{\subkeysep{t_1}{\lockn{L}_1}, \dots, \subkeysep{t_n}{\lockn{L}_n}} : A \admbra{\subkeysep{t_1}{\lockn{L}_1}, \dots, \subkeysep{t_n}{\lockn{L}_n}} }
\end{mathpar}
Because we will so often be working with a sequence of terms and
locks, we will abbreviate
$\admbra{\subkeysep{t_1}{\lockn{L}_1}, \dots,
\subkeysep{t_n}{\lockn{L}_n}}$ to simply
$\subkey{\vec{t}}{L}$.
Formally, the telescope $\Gamma''$ should be annotated in the syntax
of the operation, as it is not inferable from the raw syntax.
\paragraph{Variable Usage.} To use a variable $x : A$ that is
behind some context locks, we must provide a term $t_i : \Tiny$
for each lock between that variable and the front of the context.
\begin{mathpar}
\inferrule*[left=var]
{\Gamma, x : A, \Gamma' \yields \vec{t} : \Tiny
\text{ for } \lockn{L} \in \locksin{\Gamma'} }
{\Gamma, x : A, \Gamma' \yields x \substuck{\vec{t}}{L} : A\subkey{\vec{t}}{L}}
\end{mathpar}
The type of the variable usage has the admissible counit rule
applied to it: typically these counits will not be stuck on the type
unless $A$ is itself a variable.
\paragraph{Substitution.} Ordinary substitution into a variable
continues into the keys associated with the variable. When we find
the variable we are substituting for, the `stuck' counits are turned
back into admissible ones, which then proceed into the substituted
term:
\begin{align*}
\Gamma, \Gamma'[a/x]
&\yields (y \substuck{\vec{t}}{L})[a/x] :\defeq y\substuck{\vec{t}[a/x]}{L} \\
\Gamma, \Gamma'[a/x]
&\yields (x \substuck{\vec{t}}{L})[a/x] :\defeq a\subkey{\vec{t}[a/x]}{L}
\end{align*}
% \begin{align*}
% \Gamma, \Gamma'[a/x]
% &\yields y \stubra{\subkeysep{t_1}{\lockn{L}_1}, \dots, \subkeysep{t_n}{\lockn{L}_n}}[a/x] \\
% &:\defeq y \stubra{\subkeysep{t_1[a/x]}{\lockn{L}_1}, \dots, \subkeysep{t_n[a/x]}{\lockn{L}_n}} \\
% \Gamma, \Gamma'[a/x]
% &\yields x \stubra{\subkeysep{t_1}{\lockn{L}_1}, \dots, \subkeysep{t_n}{\lockn{L}_n}}[a/x] \\
% &:\defeq a\admbra{\subkeysep{t_1[a/x]}{\lockn{L}_1}, \dots, \subkeysep{t_n[a/x]}{\lockn{L}_n}}
% \end{align*}
\paragraph{Computing the Counit.} We will now explain how the
counit operation is actually computed on syntax. We begin with the
simplest possible instance: the addition a single additional key with using a
closed term of $\Tiny$:
\begin{mathpar}
\inferrule*[left=counit,fraction={-{\,-\,}-}]
{\Gamma, \Gamma'' \yields b : B \and \cdot \yields t : \Tiny}
{\Gamma, \ctxlock{L}, \Gamma''\subkey{t}{L}\yields b\subkey{t}{L} : B\subkey{t}{L}}
\end{mathpar}
This is calculated by induction on $b$ until we reach an instance of
the variable rule, say for a variable $x : A$.
As in the definition of single-variable substitution, there are
cases depending on where in the context $x$ lies. The typical case
is when $x : A$ is in $\Gamma$, so the variable usage looks like
\begin{align*}
\Gamma_1, x : A, \Gamma_2, \Gamma''
&\yields x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{\vec{k}}{K}} : A \admbra{\subkeyo{\vec{j}}{J}, \subkeyo{\vec{k}}{K}}
\end{align*}
% \begin{align*}
% \Gamma_1, x : A, \Gamma_2, \Gamma''
% &\yields x \stubra{\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}} \\
% &: A \admbra{\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}}
% \end{align*}
where $\lockn{J}$ are the locks in $\Gamma_2$
and $\lockn{K}$ are the locks in $\Gamma''$. The new $\subkey{t}{L}$ is slot into place, and left stuck:
\begin{align*}
\Gamma_1, x : A, \Gamma_2, \ctxlock{L}, \Gamma''\subkey{t}{L} \yields
&x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{\vec{k}}{K}} \subkey{t}{L}
:\defeq x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{t}{L}, \subkeyo{\vec{k}}{K}}
\end{align*}
% \begin{align*}
% \Gamma_1, x : A, \Gamma_2, \ctxlock{L}, \Gamma''\subkey{t}{L} \yields
% &x \stubra{\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}} \subkey{t}{L} \\
% :\defeq {}
% &x \stubra{\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeyo{t}{L},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}}
% \end{align*}
When working informally, this means counting how many
$\ctxlocke{\lockn{K}}$ are created between the application of
$\subkey{t}{L}$ and the variable usage (by the use of some of the
typing rules to be introduced later), and placing $\subkeyo{t}{L}$
to the left of all these freshly created $\ctxlocke{\lockn{K}_i}$.
If instead $x : A$ is in $\Gamma''$, the variable usage looks like
\begin{align*}
\Gamma, \Gamma_1'', x : A, \Gamma_2''
&\yields x \stubra{\subkeyo{\vec{k}}{K}} : A\subkey{\vec{k}}{K}
\end{align*}
where $\lockn{K}_{1}, \dots, \lockn{K}_n$ are the locks in
$\Gamma_2''$. Access to $x$ is not affected by the addition of the
lock $\ctxlock{L}$ (which is placed to the left of it), so the
variable usage is left unchanged:
\begin{align*}
\Gamma, \ctxlock{L}, \Gamma_1''\subkey{t}{L}, x : A\subkey{t}{L}, \Gamma_2''\subkey{t}{L}
&\yields x\stubra{\subkeyo{\vec{k}}{K}} \subkey{t}{L}
:\defeq x\stubra{\subkeyo{\vec{k}}{K}}
\end{align*}
The counit is more complex to evaluate when arbitrary open terms of
$\Tiny$ are involved. Two complications can arise:
\begin{itemize}
\item First, $t : \Tiny$ may not be closed, so that in
$\Gamma_1, x : A, \Gamma_2, \Gamma' \yields t : \Tiny$, the
variables used in the term $t$ are now locked behind the fresh locks
in $\Gamma''$ by the time we reach the variable $x$. We therefore
apply $\admbra{\subkeyo{\vec{k}}{K}}$ to the term $t$, so:
\begin{align*}
x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{\vec{k}}{K}} \subkey{t}{L}
:\defeq
x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{t\subkey{\vec{k}}{K}}{L}, \subkeyo{\vec{k}}{K}}
\end{align*}
\item Instead, the terms $\vec{j}$ and $\vec{k}$ may not be closed,
and so some of the the variables used in them might now lie behind
the new lock $\ctxlock{L}$. The term $t$ is used to unlock them:
\begin{align*}
x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{\vec{k}}{K}} \subkey{t}{L}
:\defeq
x \stubra{\subkeyo{\vec{j}\subkey{t}{L}}{J}, \subkeyo{t}{L}, \subkeyo{\vec{k}\subkey{t}{L}}{K}}
\end{align*}
% \begin{alignat*}{2}
% &x \stubra{&&\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}} \subkey{t}{L} \\
% :\defeq {}
% &x
% \stubra{&& \subkeysep{j_1\subkey{t}{L}}{\lockn{J}_1}, \\
% &&& \dots, \\
% &&& \subkeysep{j_{m}\subkey{t}{L}}{\lockn{J}_{m}}, \\
% &&& \subkeyo{t}{L}, \\
% &&& \subkeysep{k_{1}\subkey{t}{L}}{\lockn{K}_{1}}, \\
% &&& \dots, \\
% &&& \subkeysep{k_n\subkey{t}{L}}{\lockn{K}_n}
% }
% \end{alignat*}
\item Finally, and slightly horrifyingly, the two complications can happen
at the same time, yielding the final, general definition:
\begin{align*}
x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{\vec{k}}{K}} \subkey{t}{L}
:\defeq
x \stubra{\subkeyo{\vec{j}\subkey{t}{L}}{J}, \subkeyo{t\subkey{\vec{k}\subkey{t}{L}}{K}}{L}, \subkeyo{\vec{k}\subkey{t}{L}}{K}}
\end{align*}
% \begin{alignat*}{2}
% &x \stubra{&&\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}} \subkey{t}{L} \\
% :\defeq {}
% &x
% \stubra{&& \subkeysep{j_1\subkey{t}{L}}{\lockn{J}_1}, \\
% &&& \dots, \\
% &&& \subkeysep{j_{m}\subkey{t}{L}}{\lockn{J}_{m}}, \\
% &&& \subkeyo{t\admbra{\subkeysep{k_1\subkey{t}{L}}{\lockn{K}_{1}}, \dots, \subkeysep{k_n\subkey{t}{L}}{\lockn{K}_n}}}{L}, \\
% &&& \subkeysep{k_{1}\subkey{t}{L}}{\lockn{K}_{1}}, \\
% &&& \dots, \\
% &&& \subkeysep{k_n\subkey{t}{L}}{\lockn{K}_n}
% }
% \end{alignat*}
% \mvrnote{It's not so obvious to me that this terminates!}
\end{itemize}
\paragraph{Examples of the Counit.} The fully general rule is the
worst-case scenario; the vast majority of cases encountered in
practice are simpler. First, the counit commutes with ordinary
term-formers such as pairing:
\begin{alignat*}{3}
&x : \NN, y : \NN
&&\yields (x, y) &&: \NN \times \NN \\
&x : \NN, y : \NN, \ctxlock{L}, i : \Tiny
&&\yields (x, y)\subkey{i}{L} \\
&&&\defeq (x\substuck{i}{L}, y\substuck{i}{L}) &&: \NN \times \NN
\end{alignat*}
Any variables which are bound in a term do not get annotated with the new counit:
\begin{alignat*}{3}
&x : \NN
&&\yields (\lambda y. x + y) &&: \NN \to \NN \\
&x : \NN,\ctxlock{L}, i : \Tiny
&&\yields (\lambda y. x + y)\subkey{i}{L} \\
&&&\defeq (\lambda y. x\substuck{i}{L} + y) &&: \NN \to \NN
\end{alignat*}
When the variable $y : \NN$ is bound, it is added to the context
\emph{after} the lock $\ctxlock{L}$, the variable usage therefore
needs no annotation to be well-formed. In particular, the rule has no
effect on closed terms:
\begin{alignat*}{3}
&\cdot
&&\yields 2 &&: \NN \\
&\ctxlock{L}, i : \Tiny
&&\yields 2\subkey{i}{L} \\
&&&\defeq 2 &&: \NN
\end{alignat*}
The counit is also applied to the type of a term, and is computed in a
similar way.
\begin{alignat*}{3}
&A : \univ, B : A \to \univ, f : \prd{x : A} B(x)
&&\yields f &&: \prd{x : A} B(x) \\
&A : \univ, B : A \to \univ, f : \prd{x : A} B(x), \ctxlock{L}, i : \Tiny
&&\yields f\subkey{i}{L} &&: \left(\prd{x : A} B(x)\right)\subkey{i}{L} \\
&&&\defeq f\substuck{i}{L} &&: \prd{x : A\subkey{i}{L}} (B(x))\subkey{i}{L} \\
&&&\defeq f\substuck{i}{L} &&: \prd{x : A\substuck{i}{L}} B\substuck{i}{L}(x)
\end{alignat*}
Because $x$ is bound in the $\Pi$ type-former, its usage is not
annotated in the codomain $B\substuck{i}{L}(x)$. The type-family
$B\substuck{i}{L}$ has type
$(A \to \univ)\substuck{i}{L} \defeq (A\substuck{i}{L} \to \univ)$, so
applying it to $x\substuck{i}{L}$ is well-formed.
When a variable already has a stuck counit attached, the result of
applying an additional counit will depend on the relative position of
the two locks. For the simplest possible case, the variable usage
\[x : A,\ctxlock{K}, k : \Tiny \yields x\substuck{k}{K} : A,\] there are
already a few possibilities.
\begin{itemize}
\item If the new lock is placed at the end of the context, the terms
used on the existing lock will also end up with the stuck counit on
their variables.
\begin{alignat*}{3}
&x : A,\ctxlock{K}, k : \Tiny
&&\yields x\substuck{k}{K} &&: A \\
&x : A,\ctxlock{K}, k : \Tiny, \ctxlock{L}, i : \Tiny
&&\yields x\substuck{k}{K} \subkey{i}{L} \\
&&&\defeq x\stubra{\subkeyo{k\subkey{i}{L}}{K}, \subkeyo{i}{L}} \\
&&&\defeq x\stubra{\subkeyo{k\substuck{i}{L}}{K}, \subkeyo{i}{L}} &&: A
\end{alignat*}
\item Moving one step to the left, we may place the new lock in
between $\ctxlock{K}$ and $k : \Tiny$. In this case neither of the
variables $i$ or $k$ are locked, and so do not need stuck counit of
their own to be used.
\begin{alignat*}{3}
&x : A, \ctxlock{K}, k : \Tiny
&&\yields x\substuck{k}{K} &&: A \\
&x : A, \ctxlock{K}, \ctxlock{L}, i : \Tiny, k : \Tiny
&&\yields x\substuck{k}{K} \subkey{i}{L} \\
&&&\defeq x\stubra{\subkeyo{k\subkey{i}{L}}{K}, \subkeyo{i}{L}} \\
&&&\defeq x\stubra{\subkeyo{k}{K}, \subkeyo{i}{L}} &&: A
\end{alignat*}
\item One step further, we may place the new lock \emph{before} an
existing one, in which case the term $i$ is the one which gains a
stuck counit in order to be used:
\begin{alignat*}{3}
&x : A, \ctxlock{K}, k : \Tiny
&&\yields x\substuck{k}{K} &&: A \\
&x : A, \ctxlock{L}, i : \Tiny, \ctxlock{K}, k : \Tiny
&&\yields x\substuck{k}{K} \subkey{i}{L} \\
&&&\defeq x\stubra{\subkeyo{i\subkey{k\subkey{i}{L}}{K}}{L}, \subkeyo{k}{K}} \\
&&&\defeq x\stubra{\subkeyo{i\subkey{k}{K}}{L}, \subkeyo{k}{K}} \\
&&&\defeq x\stubra{\subkeyo{i\substuck{k}{K}}{L}, \subkeyo{k}{K}} &&: A
\end{alignat*}
\item Finally, we may place the new lock at the start of the context,
in which case the variable usage is not changed at all:
\begin{alignat*}{3}
&x : A, \ctxlock{K}, k : \Tiny
&&\yields x\substuck{k}{K} &&: A \\
&\ctxlock{L}, i : \Tiny, x : A, \ctxlock{K}, k : \Tiny
&&\yields x\substuck{k}{K} \subkey{i}{L} \\
&&&\defeq x\substuck{k}{K} &&: A
\end{alignat*}
\end{itemize}
\paragraph{Unit.} To complete the implementation of the adjunction,
we have an admissible rule representing the unit map. The following
rule is precomposition with the substitution
$\Gamma \to (\Gamma,i : \Tiny, \ctxlock{L})$, suitably generalised
with a telescope $\Gamma'$:
\begin{mathpar}
\inferrule*[left=unit-tele,fraction={-{\,-\,}-}]
{\Gamma, i : \Tiny, \ctxlock{L} \yields \Gamma' \tele}
{\Gamma \yields \Gamma'\sublock{i}{L} \tele} \and
\inferrule*[left=unit,fraction={-{\,-\,}-}]
{\Gamma, i : \Tiny, \ctxlock{L}, \Gamma' \yields a : A}
{\Gamma, \Gamma'\sublock{i}{L} \yields a\sublock{i}{L} : A\sublock{i}{L}}
\end{mathpar}
As with the $\subkey{t}{L}$ operation, we use substitution-like
syntax for the unit map because, like substitution, it commutes past
everything until it reaches a variable. The $\rbind{i}$ notation is
chosen to match the syntax that is used for the type-former later.
The lock and key then `click together', yielding an ordinary
substitution. In the simplest case, when $t : \Tiny$ is closed and
$x$ has a single matching stuck \rulen{counit}.
\begin{align*}
x \substuck{t}{L}\sublock{i}{L} :\defeq x[t/i]
\end{align*}
If $t$ is an open term, the unit rule must continue into $t$:
\begin{align*}
x \substuck{t}{L}\sublock{i}{L} :\defeq x[t\sublock{i}{L}/i]
\end{align*}
Of course, because $x$ is already a variable there are only two
possibilities: either it is equal to the variable $i$ bound in the
unit rule or it is not.
\begin{align*}
i \substuck{t}{L}\sublock{i}{L} &:\defeq t\sublock{i}{L} \\
x \substuck{t}{L}\sublock{i}{L} &:\defeq x \qquad \text{otherwise}
\end{align*}
If $x$ has several stuck counits, the operation needs to continue
into the other stuck counits.
\begin{align*}
i \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{t}{L}, \subkeyo{\vec{k}}{K}}\sublock{i}{L}
&:\defeq {} t\sublock{i}{L} \\
x \stubra{\subkeyo{\vec{j}}{J}, \subkeyo{t}{L}, \subkeyo{\vec{k}}{K}}\sublock{i}{L}
&:\defeq {} x \stubra{\subkeyo{\vec{j}\sublock{i}{L}}{J}, \subkeyo{\vec{k}\sublock{i}{L}}{K}}
\end{align*}
% \begin{align*}
% &i \stubra{\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeyo{t}{L},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}}\sublock{i}{L} \\
% :\defeq {}
% &t\sublock{i}{L} \\
% &x \stubra{\subkeysep{j_1}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}}{\lockn{J}_{m}},
% \subkeyo{t}{L},
% \subkeysep{k_1}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n}{\lockn{K}_n}} \\
% :\defeq {}
% &x\stubra{\subkeysep{j_1\sublock{i}{L}}{\lockn{J}_1}, \dots,
% \subkeysep{j_{m}\sublock{i}{L}}{\lockn{J}_{m}},
% \subkeysep{k_1\sublock{i}{L}}{\lockn{K}_{1}},
% \dots, \subkeysep{k_n\sublock{i}{L}}{\lockn{K}_n}}
% \end{align*}
% \begin{align*}
% &x \stubra{\subkeye{s_1}{\lockn{K}_1}, \dots,
% \subkeye{s_{i}}{\lockn{K}_{i}}, \subkey{t}{L}, \subkeye{s_{i+1}}{\lockn{K}_{i+1}},
% \dots, \subkeye{s_n}{\lockn{K}_n}}\sublock{i}{L} \\
% :\defeq {}
% &x[t\sublock{i}{L}/i]\admbra{\subkeye{s_1\sublock{i}{L}}{\lockn{K}_1}, \dots,
% \subkeye{s_{i}\sublock{i}{L}}{\lockn{K}_{i}}, \subkeye{s_{i+1}\sublock{i}{L}}{\lockn{K}_{i+1}},
% \dots, \subkeye{s_n\sublock{i}{L}}{\lockn{K}_n}}
% \end{align*}
% \begin{align*}
% (\varkey{L'}{t'} \varkeye{\lockn{K}_n}{s_n} \dots \varkeye{\lockn{K}_1}{s_1} x)[\sublock{i}{L}] &:\defeq \admkey{L'}{t'[\sublock{i}{L}]}(\varkeye{\lockn{K}_n}{s_n} \dots \varkeye{\lockn{K}_1}{s_1} x)[\sublock{i}{L}] \\
% (\varkey{L}{t} \varkeye{\lockn{K}_n}{s_n} \dots \varkeye{\lockn{K}_1}{s_1} x)[\sublock{i}{L}] &:\defeq (\varkeye{\lockn{K}_n}{s_n} \dots \varkeye{\lockn{K}_1}{s_1} x)[t[\sublock{i}{L}]/i] \\
% x[\sublock{i}{L}] &:\defeq x
% % (\admkey{L}{t} c) [a/x] &:\defeq \admkey{L}{t[a/x]} c[a/x] \\
% % (\varkey{L}{t} c)[\sublock{i}{L}] &:\defeq c[t[\sublock{i}{L}]/i] %\\
% % (\admkey{K}{t} c)[\sublock{i}{L}] &:\defeq
% % \admkey{K}{t[\sublock{i}{L}]} c[\sublock{i}{L}] &&\lockn{L}
% % \not\defeq \lockn{K}
% \end{align*}
In contrast to the counit, this rule is never stuck. After any
application of $\sublock{i}{L}$, the lock $\lockn{L}$ and the
variable $i$ no longer appear in the resulting term
$a\sublock{i}{L}$.
\paragraph{Examples of the Unit.}
Now, applying the unit rule. Similar to the counit, the unit commutes
with ordinary type formers (in these cases having no effect, because
the variables used come after the lock).
\begin{alignat*}{3}
&i : \Tiny, \ctxlock{L},x : \NN, y : \NN
&&\yields (x, y) &&: \NN \times \NN \\
&x : \NN, y : \NN
&&\yields (x, y)\sublock{i}{L} \\
&&&\defeq (x\sublock{i}{L}, y\sublock{i}{L})\\
&&&\defeq (x, y) &&: \NN \times \NN \\
&i : \Tiny, \ctxlock{L}, x : \NN
&&\yields (\lambda y. x + y) &&: \NN \to \NN \\
&x : \NN
&&\yields (\lambda y. x + y)\sublock{i}{L} \\
&&&\defeq (\lambda y. x\sublock{i}{L} + y) \\
&&&\defeq (\lambda y. x + y) &&: \NN \to \NN
\end{alignat*}
If the variable used is not the one that the unit is being applied to
then it remains unchanged:
\begin{alignat*}{2}
&x : A, i : \Tiny,\ctxlock{L}, k : \Tiny
&&\yields x\substuck{k}{L} : A \\
&x : A, k : \Tiny
&&\yields (x\substuck{k}{L})\sublock{i}{L} \\
&&&\defeq x[k/i] \\
&&&\defeq x : A
\end{alignat*}
The simplest interesting case is a variable usage that matches the
variable that the unit is being applied to.
\begin{alignat*}{2}
&i : \Tiny,\ctxlock{L}, k : \Tiny
&&\yields i\substuck{k}{L} : \Tiny \\
&k : \Tiny
&&\yields (i\substuck{k}{L})\sublock{i}{L} \\
&&&\defeq i[k\sublock{i}{L}/i] \\
&&&\defeq k\sublock{i}{L} \\
&&&\defeq k : \Tiny
\end{alignat*}
That is not the only way we could have gained access to $i$. We can
use the term of $\Tiny$ just constructed to gain access to $i$ a
second time:
\begin{alignat*}{2}
&i : \Tiny, \ctxlock{L}, k : \Tiny
&&\yields i\substuck{i\substuck{k}{L}}{L} : \Tiny \\
&k : \Tiny
&&\yields \left( i\substuck{i\substuck{k}{L}}{L} \right)\sublock{i}{L} \\
&&&\defeq i\substuck{k}{L}\sublock{i}{L} \\
&&&\defeq k\sublock{i}{L} \\
&&&\defeq k : \Tiny
\end{alignat*}
Nothing stops us from iterating this forever:
\begin{alignat*}{2}
&i : \Tiny, \ctxlock{L}, k : \Tiny
&&\yields
i\substuck{i\substuck{i\substuck{k}{L}}{L}}{L} : \Tiny
\end{alignat*}
Semantically, the context corresponds to $i : \Tiny \to \Tiny$ and
$k : \Tiny$, and the term is an incarnation of the iterated
application $i(i(\dots i(k)))$. The unit $\sublock{i}{L}$ replaces $i$
with the identity, and so the entire term reduces to $k$ regardless of
how many iterations we do.
The result of applying the counit may be different for each variable,
depending on what terms are used in the attached counit: