-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialogue.tex
More file actions
2487 lines (2311 loc) · 155 KB
/
dialogue.tex
File metadata and controls
2487 lines (2311 loc) · 155 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
% Continuity of Gödel's system T definable functionals
% via effectful forcing
%
% Martin Escardo
%
% 24-31 July 2012, updated 3 August 2012, 21 and 28 Feb 2013 and 6 Mar 2013.
%
% This file proof-checks in Agda version 2.3.2.
%
% (NB. With earlier versions of Agda this file has unsolved metas
% arising from the definition B = D ℕ ℕ.)
%
% This is a literate Agda file that generates latex, pdf and html.
% Search for "code" to find the agda code.
%
% This is best viewed as http://www.cs.bham.ac.uk/~mhe/dialogue/dialogue.pdf
% in the form of an article.
%
% The source file is http://www.cs.bham.ac.uk/~mhe/dialogue/dialogue.lagda
% You are probably browsing http://www.cs.bham.ac.uk/~mhe/dialogue/dialogue.html
\documentclass{entcs} \usepackage{prentcsmacro}
\usepackage{graphicx}
\sloppy
% The following is enclosed to allow easy detection of differences in
% ascii coding.
% Upper-case A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
% Lower-case a b c d e f g h i j k l m n o p q r s t u v w x y z
% Digits 0 1 2 3 4 5 6 7 8 9
% Exclamation ! Double quote " Hash (number) #
% Dollar $ Percent % Ampersand &
% Acute accent ' Left paren ( Right paren )
% Asterisk * Plus + Comma ,
% Minus - Point . Solidus /
% Colon : Semicolon ; Less than <
% Equals = Greater than > Question mark ?
% At @ Left bracket [ Backslash \
% Right bracket ] Circumflex ^ Underscore _
% Grave accent ` Left brace { Vertical bar |
% Right brace } Tilde ~
% ----------------------------------------------------------------------
% Some useful commands when doing highlightning of Agda code in LaTeX.
% ----------------------------------------------------------------------
%
% This is actually agda.sty provided by the agda distribution,
% suitably modified an extended for our purposes, and included here to
% avoid hassle for the editors of the MFPS proceedings.
\newcommand{\AgdaC}[1]{\mbox{#1}}
\usepackage{ifxetex, xcolor, polytable}
% XeLaTeX
\ifxetex
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage[]{unicode-math}
% pdfLaTeX
\else
\usepackage{bbm, ucs, amsfonts, amssymb, stmaryrd} % mhe
\usepackage[safe]{tipa} % See page 12 of the tipa manual for what
% safe does.
% FIX: This doesn't seem to help solve the pipe problem?
% http://tex.stackexchange.com/questions/1774/how-to-insert-pipe-symbol-in-latex
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
% FIX: Complete the list and send it upstream to the ucs package devs.
\DeclareUnicodeCharacter{951}{$\eta$} % mhe
\DeclareUnicodeCharacter{937}{$\Omega$} % mhe
\DeclareUnicodeCharacter{931}{$\Sigma$} % mhe
\DeclareUnicodeCharacter{928}{$\Pi$} % mhe
\DeclareUnicodeCharacter{945}{$\alpha$} % mhe
\DeclareUnicodeCharacter{960}{$\pi$} % mhe
\DeclareUnicodeCharacter{963}{$\sigma$} % mhe
\DeclareUnicodeCharacter{964}{$\tau$} % mhe
\DeclareUnicodeCharacter{961}{$\rho$} % mhe
\DeclareUnicodeCharacter{10214}{$\llbracket$} % mhe (stmaryrd)
\DeclareUnicodeCharacter{10215}{$\rrbracket$} % mhe (stmaryrd)
\DeclareUnicodeCharacter{9657}{$\triangleright$}
\DeclareUnicodeCharacter{8759}{::}
\DeclareUnicodeCharacter{8263}{$?\!?$}
\DeclareUnicodeCharacter{737} {$^l$} % FIX: Ugly, apparently ^r is
% defined, I can't find the
% definition though.
\DeclareUnicodeCharacter{8718}{$\blacksquare$}
\DeclareUnicodeCharacter{8255}{$\_$} % FIX: Couldn't find \undertie.
\DeclareUnicodeCharacter{9667}{$\triangleleft$}
\DeclareUnicodeCharacter{10218}{$\langle\!\langle$}
\DeclareUnicodeCharacter{10219}{$\rangle\!\rangle$}
\fi
% ----------------------------------------------------------------------
% Font styles.
% Default font style.
\newcommand{\AgdaFontStyle}[1]{\textsf{#1}}
% String font style.
\newcommand{\AgdaStringFontStyle}[1]{\texttt{#1}}
% Comment font style.
\newcommand{\AgdaCommentFontStyle}[1]{\texttt{#1}}
% Bounded variables font style.
\newcommand{\AgdaBoundFontStyle}[1]{\textit{#1}}
% ----------------------------------------------------------------------
% Colours.
% Aspect colours.
\definecolor{AgdaComment} {HTML}{B22222}
\definecolor{AgdaKeyword} {HTML}{CD6600}
\definecolor{AgdaString} {HTML}{B22222}
\definecolor{AgdaNumber} {HTML}{A020F0}
\definecolor{AgdaSymbol} {HTML}{181818} % was {404040} % mhe
\definecolor{AgdaPrimitiveType}{HTML}{0000CD}
\definecolor{AgdaOperator} {HTML}{000000}
% NameKind colours.
\definecolor{AgdaBound} {HTML}{000000}
\definecolor{AgdaInductiveConstructor} {HTML}{008B00}
\definecolor{AgdaCoinductiveConstructor}{HTML}{8B7500}
\definecolor{AgdaDatatype} {HTML}{0000CD}
\definecolor{AgdaField} {HTML}{EE1289}
\definecolor{AgdaFunction} {HTML}{0000CD}
\definecolor{AgdaModule} {HTML}{A020F0}
\definecolor{AgdaPostulate} {HTML}{0000CD}
\definecolor{AgdaPrimitive} {HTML}{0000CD}
\definecolor{AgdaRecord} {HTML}{0000CD}
% Other aspect colours.
\definecolor{AgdaDottedPattern} {HTML}{000000}
\definecolor{AgdaUnsolvedMeta} {HTML}{FFFF00}
\definecolor{AgdaTerminationProblem}{HTML}{FFA07A}
\definecolor{AgdaIncompletePattern} {HTML}{F5DEB3}
\definecolor{AgdaError} {HTML}{FF0000}
% Misc.
\definecolor{AgdaHole} {HTML}{9DFF9D}
% ----------------------------------------------------------------------
% Commands.
% Aspect commands.
\newcommand{\AgdaComment} [1]
{\AgdaCommentFontStyle{\textcolor{AgdaComment}{#1}}}
\newcommand{\AgdaKeyword} [1]
{\AgdaFontStyle{\textcolor{AgdaKeyword}{#1}}}
\newcommand{\AgdaString} [1]{\AgdaStringFontStyle{\textcolor{AgdaString}{#1}}}
\newcommand{\AgdaNumber} [1]{\textcolor{AgdaNumber}{#1}}
\newcommand{\AgdaSymbol} [1]{\textcolor{AgdaSymbol}{#1}}
\newcommand{\AgdaPrimitiveType}[1]
{\AgdaFontStyle{\textcolor{AgdaPrimitiveType}{#1}}}
\newcommand{\AgdaOperator} [1]{\textcolor{AgdaOperator}{#1}}
% NameKind commands.
\newcommand{\AgdaBound} [1]{\AgdaBoundFontStyle{\textcolor{AgdaBound}{#1}}}
\newcommand{\AgdaInductiveConstructor}[1]
{\AgdaFontStyle{\textcolor{AgdaInductiveConstructor}{#1}}}
\newcommand{\AgdaCoinductiveConstructor}[1]
{\AgdaFontStyle{\textcolor{AgdaCoinductiveConstructor}{#1}}}
\newcommand{\AgdaDatatype} [1]{\AgdaFontStyle{\textcolor{AgdaDatatype}{#1}}}
\newcommand{\AgdaField} [1]{\AgdaFontStyle{\textcolor{AgdaField}{#1}}}
\newcommand{\AgdaFunction} [1]{\AgdaFontStyle{\textcolor{AgdaFunction}{#1}}}
\newcommand{\AgdaModule} [1]{\AgdaFontStyle{\textcolor{AgdaModule}{#1}}}
\newcommand{\AgdaPostulate}[1]{\AgdaFontStyle{\textcolor{AgdaPostulate}{#1}}}
\newcommand{\AgdaPrimitive}[1]{\AgdaFontStyle{\textcolor{AgdaPrimitive}{#1}}}
\newcommand{\AgdaRecord} [1]{\AgdaFontStyle{\textcolor{AgdaRecord}{#1}}}
% Other aspect commands.
\newcommand{\AgdaDottedPattern} [1]{\textcolor{AgdaDottedPattern}{#1}}
\newcommand{\AgdaUnsolvedMeta} [1]
{\AgdaFontStyle{\colorbox{AgdaUnsolvedMeta}{#1}}}
\newcommand{\AgdaTerminationProblem}[1]
{\AgdaFontStyle{\colorbox{AgdaTerminationProblem}{#1}}}
\newcommand{\AgdaIncompletePattern} [1]{\colorbox{AgdaIncompletePattern}{#1}}
\newcommand{\AgdaError} [1]
{\AgdaFontStyle{\textcolor{AgdaError}{\underline{#1}}}}
% Misc.
\newcommand{\AgdaHole}[1]{\colorbox{AgdaHole}{#1}}
\long\def\AgdaHide#1{} % Used to hide code from LaTeX.
\newcommand{\AgdaIndent}[1]{\quad}
% ----------------------------------------------------------------------
% The code environment.
% \newcommand{\AgdaCodeStyle}{}
\newcommand{\AgdaCodeStyle}{\small}
\ifdefined\mathindent
{}
\else
\newdimen\mathindent\mathindent\leftmargini
\fi
\newenvironment{code}% modified by mhe
{\noindent\AgdaCodeStyle\pboxed}%
{\endpboxed\par\noindent%
\ignorespacesafterend}
% Default column for polytable.
\defaultcolumn{l}
% End of Agda.sty.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{url}
\usepackage[english]{babel}
\usepackage{diagrams}
\def\lastname{Escardo} % should be Escard\'o but this generates "Escard" in the pdf (entcs style's fault).
\begin{document}
\begin{frontmatter}
\title{Continuity of G\"odel's system T definable functionals via effectful forcing}
\author{Mart\'\i{n} Escard\'o\thanksref{myemail}}
\address{School of Computer Science\\ University of Birmingham \\
Birmingham, England} \thanks[myemail]{Email: \href{mailto:m.escardo@cs.bham.ac.uk} {\texttt{\normalshape m.escardo@cs.bham.ac.uk}}}
\begin{abstract}
It is well-known that the Gödel's system T definable functions
\AgdaC{(ℕ → ℕ) → ℕ} are continuous, and that their restrictions
from the Baire type \AgdaC{(ℕ → ℕ)} to the Cantor type \AgdaC{(ℕ →
2)} are uniformly continuous. We offer a new, relatively short and
self-contained proof. The main technical idea is a concrete notion
of generic element that doesn't rely on forcing, Kripke semantics
or sheaves, which seems to be related to generic effects in
programming. The proof uses standard techniques from programming
language semantics, such as dialogues, monads, and logical
relations. We write this proof in intensional Martin-Löf type
theory (MLTT) from scratch, in Agda notation. Because MLTT has a
computational interpretation and Agda can be seen as a programming
language, we can run our proof to compute moduli of (uniform)
continuity of T-definable functions.
\end{abstract}
\begin{keyword}
Gödel's system T, continuity, uniform continuity, Baire space,
Cantor space, intensional Martin-Löf theory, Agda, dialogue,
semantics, logical relation.
\end{keyword}
\end{frontmatter}
\section{Introduction} \label{formulation}
This is a relatively short, and self-contained, proof of the
well-known fact that any function \AgdaC{$f$ : (ℕ → ℕ) → ℕ} that is
definable in Gödel's system T is continuous, and that its restriction
from the Baire type \AgdaC{(ℕ → ℕ)} to the Cantor type \AgdaC{(ℕ → 2)}
is uniformly continuous~\cite{MR0325352,beeson}. We believe the proof
is new, although it is related to previous work discussed below. The
main technical idea is a concrete notion of generic element that
doesn't rely on forcing, Kripke semantics or sheaves, which seems to
be related to generic effects in
programming~\cite{Plotkin03algebraicoperations}. Several well-known
ideas from logic, computation, constructive mathematics and
programming-language semantics naturally appear here, in a relatively
simple, self-contained, and hopefully appealing, development.
The idea is to represent a function \AgdaC{$f$ : (ℕ → ℕ) → ℕ} by a
well-founded dialogue tree, and extract continuity information about
$f$ from this tree. To calculate such a tree from a system T term
\AgdaC{$t$: (ι ⇒ ι) ⇒ ι} denoting $f$, we work with an auxiliary
interpretation of system T, which gives a function \AgdaC{$\tilde{f}$
: $(\tilde{\mathbb{N}}$ → $\tilde{\mathbb{N}})$ →
$\tilde{\mathbb{N}}$}, where $\tilde{\mathbb{N}}$ is the set of
dialogue trees. Applying $\tilde{f}$ to a certain \emph{generic
sequence} $\tilde{\mathbb{N}}$ → $\tilde{\mathbb{N}}$, the desired
dialogue tree is obtained. We now explain this idea in more detail.
In the set-theoretical model of system T, the ground type ι is
interpreted as the set ℕ of natural numbers, and if the types σ and τ
are interpreted as sets~$X$ and $Y$, then the type σ ⇒ τ is
interpreted as the set of all functions \AgdaC{$X$ → $Y$}. We consider
an auxiliary model that replaces the interpretation of the ground
type by the set $\tilde{\mathbb{N}}$, but keeps the interpretation of
⇒ as the formation of the set of all functions. In this
model, the zero constant is interpreted by a suitable element
$\tilde{0}$ of $\tilde{\mathbb{N}}$, the successor constant is
interpreted by a function $\tilde{\mathbb{N}}$ → $\tilde{\mathbb{N}}$,
and each iteration combinator is interpreted by a function
($X$ → $X$) → $X$ → $\tilde{\mathbb{N}}$ → $X$. An element of the set
$\tilde{\mathbb{N}}$ is a well-founded dialogue tree that describes
the computation of a natural number relative to an unspecified oracle
\AgdaC{α : ℕ → ℕ}. An internal node is labeled by a natural number
representing a query to the oracle, and has countably many branches
corresponding to the possible answers. Each leaf is labeled by a
natural number and represents a possible outcome of the computation.
These dialogues represent computations in the sense of
Kleene~\cite{KleeneSC:rfqftI}.
If a particular oracle \AgdaC{α : ℕ → ℕ} is given, we get a natural
number from any \AgdaC{$d \in \tilde{\mathbb{N}}$} via a
decodification function
\begin{quote}
decode : (ℕ → ℕ) → $\tilde{\mathbb{N}}$ → ℕ.
\end{quote}
It turns out that there is a function
\begin{quote}
generic : $\tilde{\mathbb{N}}$ → $\tilde{\mathbb{N}}$
\end{quote}
that can be regarded as a \emph{generic sequence} in the sense that,
for any particular sequence \AgdaC{α : ℕ → ℕ},
\begin{small}
\begin{diagram}[small]
\tilde{\mathbb{N}} & \rTo^{\text{generic}} & \tilde{\mathbb{N}} \\
\dTo^{\text{decode α}} & & \dTo_{\text{decode α}} \\
\text{ℕ} & \rTo_{\text{α}} & \text{ℕ}.
\end{diagram}
\end{small}
\noindent That is, the generic sequence codes any concrete sequence
\AgdaC{α}, provided the sequence α itself is used as the concrete
oracle for decodification. The idea is that the application of the
function \AgdaC{generic} to a dialogue tree adds a new layer of
choices at its leaves.
Next we show that for any given term \AgdaC{$t$ : (ι ⇒ ι) ⇒ ι} denoting a
function \AgdaC{$f$ : (ℕ → ℕ) → ℕ} in the standard interpretation and
\AgdaC{$\tilde{f}$ : $(\tilde{\mathbb{N}}$ → $\tilde{\mathbb{N}})$ →
$\tilde{\mathbb{N}}$} in the dialogue interpretation, we have that
\begin{quote} \AgdaC{$f$ α = decode α ($\tilde{f}$ generic).} \end{quote}
This is proved by establishing a logical
relation between the set-theoretic and dialogue models.
Thus we can compute a dialogue tree of $f$ by applying $\tilde{f}$ to
the generic sequence.
The set $\tilde{\mathbb{N}}$ is constructed as \AgdaC{B ℕ} for a
suitable dialogue monad B. Then the interpretation of the constant
zero is η 0 where η is the unit of the monad, the interpretation of
the successor constant is given by functoriality as \AgdaC{B succ},
and the interpretation of the primitive recursion constant is given by
the Kleisli extension of its standard interpretation. The object part
\AgdaC{B $X$} of the monad is inductively defined by the constructors
\begin{quote} η : $X$ → B $X$, \\ β : (ℕ → B $X$) → ℕ → B $X$,
\end{quote} where η constructs leaves and β constructs a tree β φ $n$
given countably many trees φ and a label~$n$. With $X$ = ℕ, we have β
η : ℕ → B ℕ, and the generic sequence is the Kleisli extension of β η.
Thus, the generic sequence seems to be a sort of \emph{generic effect}
in the sense of~\cite{Plotkin03algebraicoperations}. Notice that our
interpretation is a call-by-name version of Moggi's
semantics.
Using this, it follows that if a function \AgdaC{$f$ : (ℕ → ℕ) → ℕ} is
the set-theoretical interpretation of some system T term \AgdaC{$t$ :
(ι ⇒ ι) ⇒ ι}, then it is continuous and its restriction to \AgdaC{ℕ →
2} is uniformly continuous, where $2$ is the set with elements $0$ and
$1$. The reason is that a dialogue produces an answer after finitely
many queries, because it is well-founded, and that a dialogue tree for
a function \AgdaC{$(ℕ → 2) → ℕ$} is finite, because it is finitely
branching. Recall that continuity means that, for any sequence of
integers \AgdaC{α : ℕ → ℕ}, there is \AgdaC{$m$ : ℕ}, called a modulus
of continuity of $f$ at the point~α, such that any sequence
\AgdaC{α$'$} that agrees with α at the first $m$ positions gives the
same result, that is, \AgdaC{$f$ α = $f$ α$'$}. Uniform continuity
means that there is \AgdaC{$m$ : ℕ}, called a modulus of uniform
continuity of $f$ on \AgdaC{ℕ → 2}, such that any two binary sequences
α and α$'$ that agree at the first $m$ positions give the same result.
Our arguments are constructive, and we write the full proof from
scratch in intensional Martin-Löf type theory (MLTT), in Agda
notation~\cite{bove:dybjer}, without the use of libraries. We don't
assume previous familiarity with Agda, but we do require rudimentary
knowledge of MLTT. The Agda source file for this
program/proof~\cite{escardo:dialogue} is written in Knuth's
\emph{literate} style, which automatically generates the \LaTeX\ file
that produces this article. Agda both checks proofs and can run them.
Notice that MLTT or Agda cannot prove or disprove that all functions
\AgdaC{(ℕ → ℕ) → ℕ} are continuous, as they are compatible with both
classical and constructive mathematics, like Bishop
mathematics~\cite{bishop:foundations}. The theorem here is that
certain functions \AgdaC{(ℕ → ℕ) → ℕ} are continuous: those that can
be defined in system~T.
\noindent{\itshape\bfseries Related work.}
The idea of computing continuity information by applying a function
to effectful arguments goes back to Longley~\cite{Longley99whenis},
who passes exceptions to the function. A similar approach is
described in an example given by Bauer and Pretnar~\cite{bauer:pretnar}.
The idea of working with computation trees is of course very old,
going back to Brouwer~\cite{beeson} in intuitionistic mathematics, and
to Kleene~\cite{KleeneSC:rfqftI} in computability theory in the form
of dialogues, where the input is referred to as an
oracle. Howard~\cite{Howard(80)} derives computation trees for system
T, by operational methods, by successively reducing a term so that
each time an oracle given by a free variable of type ι ⇒ ι is
queried, countably many branches of the computation are created,
corresponding to the possible answers given by the oracle.
Hancock and Setzer use variations of dialogue trees to describe
interactive computation in type
theory~\cite{DBLP:conf/csl/HancockS00} (see also~\cite{Hancock_representationsof}).
Our work is directly inspired by Coquand and Jaber's work on forcing
in type
theory~\cite{Coquand:2010:NFT:1839560.1839564,DBLP:series/leus/CoquandJ12}. Like
Howard, they derive computation trees by operational methods. They
extend dependent type theory with a constant for a generic element,
and then decorate judgements with subscripts that keep track of
approximation information about the generic element as the
computations proceed (similarly to \cite{MR0325352}).
In this way they extract continuity information.
They prove the termination and soundness of this
modification of type theory using Tait's computability method, which
here is manifested as a logical relation between our two models. They
also provide a Haskell implementation for the system~T case as an
appendix, which uses a monad that is the composition of the list monad
(for nondeterminism) and of the state monad. Their Haskell program
implements a normalization procedure with bookkeeping information,
tracked by the monad, that produces computation trees. Because they
only account for uniform continuity in their Haskell implementation,
such trees are finite. They describe their work as a computational
interpretation of forcing and continuity as presented in
Beeson~\cite{beeson}.
The difference is that
their approach is syntactical whereas ours is semantical,
and the reader may sense an analogy with normalization by
evaluation. Notice that these arguments only show that the
\emph{definable} functions are continuous. To get a constructive model
in which \emph{all} functions are continuous, they work with iterated
forcing, which is related to our recent work~\cite{escardo:xu}, but
this is another story.
\noindent {\itshape\bfseries Organization.}
(\ref{section:formal})~Formal proof in Agda.
(\ref{section:informal})~Informal, rigorous proof.
\noindent {\itshape\bfseries Acknowledgements.} I benefitted from remarks on a
previous version of this paper by Thierry Coquand, Dan Ghica, Achim Jung,
Chuangjie~Xu, and the anonymous referees.
\section{Proof in Martin-L\"of type theory in Agda notation}
\label{section:formal}
\subsection{Agda preliminaries} \label{section:preliminaries}
The purpose of this subsection is two-fold: (1) To develop a tiny Agda
library for use in the following sections, and (2) to briefly explain
Agda notation~\cite{bove:dybjer} for MLTT. We assume rudimentary
knowledge of (intensional) Martin-L\"of type theory and the BHK
interpretation of the quantifiers as products Π and sums~Σ. We don't
use any feature of Agda that goes beyond standard MLTT. If we were
trying to be purist, we would use W-types rather than some of our
inductive definitions using the Agda keyword \emph{data}. Notice that
the coloured text in the electronic version of this paper is the Agda
code.
The universe of all types is denoted by Set, and types are called
sets (this is a universe \`a la Russell). Products \AgdaC{Π} are
denoted by \AgdaC{∀} in Agda.
% Any Agda file, has to be a named module:
\AgdaHide{ % I don't think I am hiding anything else.
\begin{code}\>\<%
\\
\>\AgdaKeyword{module} \AgdaModule{dialogue} \AgdaKeyword{where}\<%
\\
\>\<\end{code}
}
Consider the definition of the (interpretation of) the standard
combinators:
\begin{code}\>\<%
\\
\>\AgdaFunction{Ķ} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaBound{Y} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y} \AgdaSymbol{→} \AgdaBound{X}\<%
\\
\>\AgdaFunction{Ķ} \AgdaBound{x} \AgdaBound{y} \AgdaSymbol{=} \AgdaBound{x}\<%
\\
\>\AgdaFunction{Ş} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y} \AgdaSymbol{→} \AgdaBound{Z}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Z}\<%
\\
\>\AgdaFunction{Ş} \AgdaBound{f} \AgdaBound{g} \AgdaBound{x} \AgdaSymbol{=} \AgdaBound{f} \AgdaBound{x} \AgdaSymbol{(}\AgdaBound{g} \AgdaBound{x}\AgdaSymbol{)}\<%
\\
\>\<\end{code}
The curly braces around the set variables indicate that these are
implicit parameters, to be inferred by Agda whenever \AgdaC{Ķ} and \AgdaC{Ş} are
used. If Agda fails to uniquely infer the missing arguments, one has
to write e.g.\ \AgdaC{$Ķ$ \{$X$\} \{$Y$\} $x$ $y$} rather than the
abbreviated form \AgdaC{$Ķ$ $x$ $y$}. The following should be
self-explanatory:
\begin{code}\>\<%
\\
\>\AgdaFunction{\_∘\_} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaBound{Y} \AgdaSymbol{→} \AgdaBound{Z}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Z}\AgdaSymbol{)}\<%
\\
\>\AgdaBound{g} \AgdaFunction{∘} \AgdaBound{f} \AgdaSymbol{=} \AgdaSymbol{λ} \AgdaBound{x} \AgdaSymbol{→} \AgdaBound{g}\AgdaSymbol{(}\AgdaBound{f} \AgdaBound{x}\AgdaSymbol{)}\<%
\\
%
\\
\>\AgdaKeyword{data} \AgdaDatatype{ℕ} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaKeyword{where} \<[19]%
\>[19]\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{zero} \AgdaSymbol{:} \AgdaDatatype{ℕ} \<[24]%
\>[24]\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{succ} \AgdaSymbol{:} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaDatatype{ℕ} \<[21]%
\>[21]\<%
\\
\>\AgdaFunction{rec} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{X} \AgdaSymbol{→} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\<%
\\
\>\AgdaFunction{rec} \AgdaBound{f} \AgdaBound{x} \<[9]%
\>[9]\AgdaInductiveConstructor{zero} \<[17]%
\>[17]\AgdaSymbol{=} \AgdaBound{x}\<%
\\
\>\AgdaFunction{rec} \AgdaBound{f} \AgdaBound{x} \AgdaSymbol{(}\AgdaInductiveConstructor{succ} \AgdaBound{n}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaBound{f}\AgdaSymbol{(}\AgdaFunction{rec} \AgdaBound{f} \AgdaBound{x} \AgdaBound{n}\AgdaSymbol{)}\<%
\\
\>\<\end{code}
Agda has a termination checker that verifies that recursions are
well-founded, and hence all functions are total. We also need types of
binary digits, finite lists, and finite binary trees:
\begin{code}\>\<%
\\
\>\AgdaKeyword{data} \AgdaDatatype{ℕ₂} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{₀} \AgdaInductiveConstructor{₁} \AgdaSymbol{:} \AgdaDatatype{ℕ₂}\<%
\\
%
\\
\>\AgdaKeyword{data} \AgdaDatatype{List} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{)} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{[]} \<[12]%
\>[12]\AgdaSymbol{:} \AgdaDatatype{List} \AgdaBound{X}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{\_∷\_} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaDatatype{List} \AgdaBound{X} \AgdaSymbol{→} \AgdaDatatype{List} \AgdaBound{X}\<%
\\
%
\\
\>\AgdaKeyword{data} \AgdaDatatype{Tree} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{)} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{empty} \AgdaSymbol{:} \AgdaDatatype{Tree} \AgdaBound{X}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{branch} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaDatatype{ℕ₂} \AgdaSymbol{→} \AgdaDatatype{Tree} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaDatatype{Tree} \AgdaBound{X}\<%
\\
\>\<\end{code}
Sums are not built-in and hence need to be defined:
\begin{code}\>\<%
\\
\>\AgdaKeyword{data} \AgdaDatatype{Σ} \AgdaSymbol{\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{(}\AgdaBound{Y} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\AgdaSymbol{)} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{\_,\_} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{x} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{)(}\AgdaBound{y} \AgdaSymbol{:} \AgdaBound{Y} \AgdaBound{x}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaDatatype{Σ} \AgdaSymbol{\{}\AgdaBound{X}\AgdaSymbol{\}} \AgdaBound{Y}\<%
\\
\>\<\end{code}
The definition says that an element of \AgdaC{Σ \{$X$\} $Y$} is a pair
\AgdaC{($x$,$y$)} with \AgdaC{$x$ : $X$} and \AgdaC{$y$ : $Y$ $x$}.
Notice that comma is not a reserved symbol: we define it as a binary
operator to construct dependent pairs. Because \AgdaC{$Y$ = λ($x$ : $X$) →
$Y$ $x$} if one assumes the η-law, and because the first argument is
implicit, we can write \AgdaC{Σ $\{X\}$ $Y$} as \AgdaC{Σ Y} or \AgdaC{Σ
\char`\\($x$ : $X$) → $Y$ $x$}, where backslash is the same thing as
lambda. We will use backslash exclusively for sums.
% (And hope it will be as invisible as possible.)
\begin{code}\>\<%
\\
\>\AgdaFunction{π₀} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{\{}\AgdaBound{Y} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaDatatype{Σ} \AgdaSymbol{ \textbackslash(}\AgdaBound{x} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{Y} \AgdaBound{x}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{X}\<%
\\
\>\AgdaFunction{π₀}\AgdaSymbol{(}\AgdaBound{x} \AgdaInductiveConstructor{,} \AgdaBound{y}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaBound{x}\<%
\\
\>\AgdaFunction{π₁} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{\{}\AgdaBound{Y} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{∀(}\AgdaBound{t} \AgdaSymbol{:} \AgdaDatatype{Σ} \AgdaSymbol{ \textbackslash(}\AgdaBound{x} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{Y} \AgdaBound{x}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{Y}\AgdaSymbol{(}\AgdaFunction{π₀} \AgdaBound{t}\AgdaSymbol{)}\<%
\\
\>\AgdaFunction{π₁}\AgdaSymbol{(}\AgdaBound{x} \AgdaInductiveConstructor{,} \AgdaBound{y}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaBound{y}\<%
\\
\>\<\end{code}
The identity type \AgdaC{Id $X$ $x$ $y$} is written
\AgdaC{$x$ ≡ $y$} with \AgdaC{$X$} implicit, and is inductively
defined as ``the least reflexive relation'':
\begin{code}\>\<%
\\
\>\AgdaKeyword{data} \AgdaDatatype{\_≡\_} \AgdaSymbol{\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaBound{X} \AgdaSymbol{→} \AgdaPrimitiveType{Set} \AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{refl} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{x} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{x} \AgdaDatatype{≡} \AgdaBound{x}\<%
\\
%
\\
\>\AgdaFunction{sym} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{∀\{}\AgdaBound{x} \AgdaBound{y} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{x} \AgdaDatatype{≡} \AgdaBound{y} \AgdaSymbol{→} \AgdaBound{y} \AgdaDatatype{≡} \AgdaBound{x}\<%
\\
\>\AgdaFunction{sym} \AgdaInductiveConstructor{refl} \AgdaSymbol{=} \AgdaInductiveConstructor{refl}\<%
\\
\>\AgdaFunction{trans} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{∀\{}\AgdaBound{x} \AgdaBound{y} \AgdaBound{z} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{x} \AgdaDatatype{≡} \AgdaBound{y} \AgdaSymbol{→} \AgdaBound{y} \AgdaDatatype{≡} \AgdaBound{z} \AgdaSymbol{→} \AgdaBound{x} \AgdaDatatype{≡} \AgdaBound{z}\<%
\\
\>\AgdaFunction{trans} \AgdaInductiveConstructor{refl} \AgdaInductiveConstructor{refl} \AgdaSymbol{=} \AgdaInductiveConstructor{refl}\<%
\\
\>\AgdaFunction{cong} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaBound{Y} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{∀(}\AgdaBound{f} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{∀\{}\AgdaBound{x₀} \AgdaBound{x₁} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{x₀} \AgdaDatatype{≡} \AgdaBound{x₁} \AgdaSymbol{→} \AgdaBound{f} \AgdaBound{x₀} \AgdaDatatype{≡} \AgdaBound{f} \AgdaBound{x₁}\<%
\\
\>\AgdaFunction{cong} \AgdaBound{f} \AgdaInductiveConstructor{refl} \AgdaSymbol{=} \AgdaInductiveConstructor{refl}\<%
\\
\>\AgdaFunction{cong₂} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{∀(}\AgdaBound{f} \AgdaSymbol{:} \AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y} \AgdaSymbol{→} \AgdaBound{Z}\AgdaSymbol{)} \<[42]%
\>[42]\<%
\\
\>[2]\AgdaIndent{6}{}\<[6]%
\>[6]\AgdaSymbol{→} \AgdaSymbol{∀\{}\AgdaBound{x₀} \AgdaBound{x₁} \AgdaSymbol{:} \AgdaBound{X}\AgdaSymbol{\}\{}\AgdaBound{y₀} \AgdaBound{y₁} \AgdaSymbol{:} \AgdaBound{Y}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{x₀} \AgdaDatatype{≡} \AgdaBound{x₁} \AgdaSymbol{→} \AgdaBound{y₀} \AgdaDatatype{≡} \AgdaBound{y₁} \AgdaSymbol{→} \AgdaBound{f} \AgdaBound{x₀} \AgdaBound{y₀} \AgdaDatatype{≡} \AgdaBound{f} \AgdaBound{x₁} \AgdaBound{y₁}\<%
\\
\>\AgdaFunction{cong₂} \AgdaBound{f} \AgdaInductiveConstructor{refl} \AgdaInductiveConstructor{refl} \AgdaSymbol{=} \AgdaInductiveConstructor{refl}\<%
\\
\>\<\end{code}
\subsection{Dialogues and continuity} \label{section:dialogues:continuity}
We consider the computation of functionals \AgdaC{($X$ → $Y$) → $Z$}
with dialogue trees. We work with the following inductively defined
type of (well founded) dialogue trees indexed by three types $X$, $Y$
and $Z$. These are $Y$-branching trees with $X$-labeled internal nodes
and $Z$-labeled leaves:
\begin{code}\>\<%
\\
\>\AgdaKeyword{data} \AgdaDatatype{D} \AgdaSymbol{(}\AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{)} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaKeyword{where} \<[33]%
\>[33]\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{η} \AgdaSymbol{:} \AgdaBound{Z} \AgdaSymbol{→} \AgdaDatatype{D} \AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{β} \AgdaSymbol{:} \AgdaSymbol{(}\AgdaBound{Y} \AgdaSymbol{→} \AgdaDatatype{D} \AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{X} \AgdaSymbol{→} \AgdaDatatype{D} \AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z}\<%
\\
\>\<\end{code}
A leaf is written \AgdaC{η $z$}, and it gives the final answer $z$ (η will
be the unit of a monad). A forest is a $Y$-indexed family φ of
trees. Given such a forest \AgdaC{φ} and \AgdaC{$x$ : $X$}, we can build a
new tree \AgdaC{β φ $x$} whose root is labeled by $x$, which has a subtree
\AgdaC{φ $y$} for each \AgdaC{$y$ : $Y$}. We can imagine \AgdaC{$x$ : $X$} as
query, for which an oracle α gives some intermediate answer
\AgdaC{$y$ = α $x$ : Y}. After this answer~\AgdaC{$y$}, we move to the
subtree \AgdaC{φ $y$}, and the dialogue proceeds in this way, until a
leaf with the final answer is reached:
\begin{code}\>\<%
\\
\>\AgdaFunction{dialogue} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaDatatype{D} \AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{Z}\<%
\\
\>\AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaInductiveConstructor{η} \AgdaBound{z}\AgdaSymbol{)} \<[17]%
\>[17]\AgdaBound{α} \AgdaSymbol{=} \AgdaBound{z}\<%
\\
\>\AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaInductiveConstructor{β} \AgdaBound{φ} \AgdaBound{x}\AgdaSymbol{)} \AgdaBound{α} \AgdaSymbol{=} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ}\AgdaSymbol{(}\AgdaBound{α} \AgdaBound{x}\AgdaSymbol{))} \AgdaBound{α}\<%
\\
\>\<\end{code}
We say that a function \AgdaC{($X$ → $Y$) → $Z$} is \emph{eloquent} if
it is computed by some dialogue:
\begin{code}\>\<%
\\
\>\AgdaFunction{eloquent} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{X} \AgdaBound{Y} \AgdaBound{Z} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaSymbol{((}\AgdaBound{X} \AgdaSymbol{→} \AgdaBound{Y}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{Z}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\<%
\\
\>\AgdaFunction{eloquent} \AgdaBound{f} \AgdaSymbol{=} \AgdaDatatype{Σ} \AgdaSymbol{ \textbackslash}\AgdaBound{d} \AgdaSymbol{→} \AgdaSymbol{∀} \AgdaBound{α} \AgdaSymbol{→} \AgdaFunction{dialogue} \AgdaBound{d} \AgdaBound{α} \AgdaDatatype{≡} \AgdaBound{f} \AgdaBound{α}\<%
\\
\>\<\end{code}
Here we are interested in the case \AgdaC{$X$=$Y$=$Z$=ℕ}.
Think of functions \AgdaC{α : ℕ → ℕ} as sequences of natural
numbers. The set of such sequences is called the Baire space:
\begin{code}\>\<%
\\
\>\AgdaFunction{Baire} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\<%
\\
\>\AgdaFunction{Baire} \AgdaSymbol{=} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaDatatype{ℕ}\<%
\\
\>\<\end{code}
Functions \AgdaC{Baire → ℕ} are coded by a particular kind of dialogue trees,
namely \AgdaC{B ℕ} where B is defined as follows:
\begin{code}\>\<%
\\
\>\AgdaFunction{B} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\<%
\\
\>\AgdaFunction{B} \AgdaSymbol{=} \AgdaDatatype{D} \AgdaDatatype{ℕ} \AgdaDatatype{ℕ}\<%
\\
\>\<\end{code}
We work with a refined version of continuity, which gives more
information than the traditional notion introduced in
Section~\ref{formulation}, where the modulus of continuity is a finite
list of indices rather than an upper bound for the indices. The
agreement relation determined by a list of indices is inductively
defined as follows, where \AgdaC{\AgdaC{α ≡[ $s$ ] α$'$}} says that
the sequences \AgdaC{α} and \AgdaC{α$'$} agree at the indices
collected in the list \AgdaC{$s$}:
\begin{enumerate}
\item \AgdaC{α ≡[ [] ] α$'$},
\item \AgdaC{α $i$ ≡ α$'$ $i$ → α ≡[ $s$ ] α$'$ → α ≡[ $i$ ∷ $s$ ] α$'$}.
\end{enumerate}
We write this inductive definition as follows in Agda, where we give
the name~[] to the proof of the first clause and the name ∷ to the
proof of the second clause, that is, using the same constructor names
as for the inductively defined type of lists:
\begin{code}\>\<%
\\
\>\AgdaKeyword{data} \AgdaDatatype{\_≡[\_]\_} \AgdaSymbol{\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{:} \AgdaSymbol{(}\AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaDatatype{List} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaPrimitiveType{Set} \AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{[]} \<[6]%
\>[6]\AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{:} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[} \AgdaInductiveConstructor{[]} \AgdaDatatype{]} \AgdaBound{α'} \<[39]%
\>[39]\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{\_∷\_} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{:} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{\}\{}\AgdaBound{i} \AgdaSymbol{:} \AgdaDatatype{ℕ}\AgdaSymbol{\}\{}\AgdaBound{s} \AgdaSymbol{:} \AgdaDatatype{List} \AgdaDatatype{ℕ}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{α} \AgdaBound{i} \AgdaDatatype{≡} \AgdaBound{α'} \AgdaBound{i} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[} \AgdaBound{s} \AgdaDatatype{]} \AgdaBound{α'} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[} \AgdaBound{i} \AgdaInductiveConstructor{∷} \AgdaBound{s} \AgdaDatatype{]} \AgdaBound{α'}\<%
\\
%
\\
\>\AgdaFunction{continuous} \AgdaSymbol{:} \AgdaSymbol{(}\AgdaFunction{Baire} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\<%
\\
\>\AgdaFunction{continuous} \AgdaBound{f} \AgdaSymbol{=} \AgdaSymbol{∀(}\AgdaBound{α} \AgdaSymbol{:} \AgdaFunction{Baire}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaDatatype{Σ} \AgdaSymbol{ \textbackslash(}\AgdaBound{s} \AgdaSymbol{:} \AgdaDatatype{List} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{∀(}\AgdaBound{α'} \AgdaSymbol{:} \AgdaFunction{Baire}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[} \AgdaBound{s} \AgdaDatatype{]} \AgdaBound{α'} \AgdaSymbol{→} \AgdaBound{f} \AgdaBound{α} \AgdaDatatype{≡} \AgdaBound{f} \AgdaBound{α'}\<%
\\
\>\<\end{code}
It is an easy exercise, left to the reader, to produce an Agda proof
that this refined notion of continuity implies the traditional notion
of continuity, by taking the maximum value of the list~$s$.
Functions defined by dialogues are continuous, because a dialogue
produces an answer after finitely many queries:
\begin{code}\>\<%
\\
\>\AgdaFunction{dialogue-continuity} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{d} \AgdaSymbol{:} \AgdaFunction{B} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaFunction{continuous}\AgdaSymbol{(}\AgdaFunction{dialogue} \AgdaBound{d}\AgdaSymbol{)}\<%
\\
\>\AgdaFunction{dialogue-continuity} \AgdaSymbol{(}\AgdaInductiveConstructor{η} \AgdaBound{n}\AgdaSymbol{)} \AgdaBound{α} \AgdaSymbol{=} \AgdaSymbol{(}\AgdaInductiveConstructor{[]} \AgdaInductiveConstructor{,} \AgdaFunction{lemma}\AgdaSymbol{)}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaKeyword{where}\<%
\\
\>[2]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{lemma} \AgdaSymbol{:} \AgdaSymbol{∀} \AgdaBound{α'} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[} \AgdaInductiveConstructor{[]} \AgdaDatatype{]} \AgdaBound{α'} \AgdaSymbol{→} \AgdaBound{n} \AgdaDatatype{≡} \AgdaBound{n} \<[40]%
\>[40]\<%
\\
\>[2]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{lemma} \AgdaBound{α'} \AgdaBound{r} \AgdaSymbol{=} \AgdaInductiveConstructor{refl}\<%
\\
\>\AgdaFunction{dialogue-continuity} \AgdaSymbol{(}\AgdaInductiveConstructor{β} \AgdaBound{φ} \AgdaBound{i}\AgdaSymbol{)} \AgdaBound{α} \AgdaSymbol{=} \AgdaSymbol{((}\AgdaBound{i} \AgdaInductiveConstructor{∷} \AgdaFunction{s}\AgdaSymbol{)} \AgdaInductiveConstructor{,} \AgdaFunction{lemma}\AgdaSymbol{)} \<[50]%
\>[50]\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{IH} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{i} \AgdaSymbol{:} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaFunction{continuous}\AgdaSymbol{(}\AgdaFunction{dialogue}\AgdaSymbol{(}\AgdaBound{φ}\AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{)))}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{IH} \AgdaBound{i} \AgdaSymbol{=} \AgdaFunction{dialogue-continuity} \AgdaSymbol{(}\AgdaBound{φ}\AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{))}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{s} \AgdaSymbol{:} \AgdaDatatype{List} \AgdaDatatype{ℕ}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{s} \AgdaSymbol{=} \AgdaFunction{π₀}\AgdaSymbol{(}\AgdaFunction{IH} \AgdaBound{i} \AgdaBound{α}\AgdaSymbol{)}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{claim₀} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{α'} \AgdaSymbol{:} \AgdaFunction{Baire}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[} \AgdaFunction{s} \AgdaDatatype{]} \AgdaBound{α'} \AgdaSymbol{→} \AgdaFunction{dialogue}\AgdaSymbol{(}\AgdaBound{φ}\AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α} \AgdaDatatype{≡} \AgdaFunction{dialogue}\AgdaSymbol{(}\AgdaBound{φ}\AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α'}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{claim₀} \AgdaSymbol{=} \AgdaFunction{π₁}\AgdaSymbol{(}\AgdaFunction{IH} \AgdaBound{i} \AgdaBound{α}\AgdaSymbol{)}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{claim₁} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{α'} \AgdaSymbol{:} \AgdaFunction{Baire}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{α} \AgdaBound{i} \AgdaDatatype{≡} \AgdaBound{α'} \AgdaBound{i} \AgdaSymbol{→} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α'} \AgdaDatatype{≡} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α'}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{claim₁} \AgdaBound{α'} \AgdaBound{r} \AgdaSymbol{=} \AgdaFunction{cong} \AgdaSymbol{(λ} \AgdaBound{n} \AgdaSymbol{→} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaBound{n}\AgdaSymbol{)} \AgdaBound{α'}\AgdaSymbol{)} \AgdaBound{r}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{lemma} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{α'} \AgdaSymbol{:} \AgdaFunction{Baire}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[} \AgdaBound{i} \AgdaInductiveConstructor{∷} \AgdaFunction{s} \AgdaDatatype{]} \AgdaBound{α'} \<[45]%
\>[45]\AgdaSymbol{→} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ}\AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α} \AgdaDatatype{≡} \AgdaFunction{dialogue}\AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α'}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{lemma} \AgdaBound{α'} \AgdaSymbol{(}\AgdaBound{r} \AgdaInductiveConstructor{∷} \AgdaBound{rs}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaFunction{trans} \AgdaSymbol{(}\AgdaFunction{claim₀} \AgdaBound{α'} \AgdaBound{rs}\AgdaSymbol{)} \AgdaSymbol{(}\AgdaFunction{claim₁} \AgdaBound{α'} \AgdaBound{r}\AgdaSymbol{)}\<%
\\
\>\<\end{code}
\noindent This formal proof is informally explained as follows. We show that
\begin{quote}
∀($d$ : B ℕ) → continuous(dialogue $d$)
\end{quote}
by induction on $d$. Expanding the definition,
this amounts to, using Agda notation,
\begin{quote}
∀ $d$ → ∀ α → Σ \char`\\$s$ → ∀ α$'$ → α ≡[ $s$ ] α$'$ → dialogue $d$ α ≡ dialogue $d$ α$'$.
\end{quote}
For the base case $d$ = η $n$, the definition of the function dialogue gives \AgdaC{dialogue $d$ α = $n$}, and so we must show that, for any α,
\begin{quote}
Σ \char`\\$s$ → ∀ α$'$ → α ≡[ $s$ ] α$'$ → $n$ ≡ $n$.
\end{quote}
We can take $s = []$ and then we are done, because $n$ ≡ $n$ by reflexivity.
This is what the first equation of the formal proof says.
Thus notice that Agda, in accordance with MLTT, silently expands definitions by reduction to normal form.
For the induction step $d$ = β φ $i$, expanding the definition of the dialogue function, what we need to prove is that, for an arbitrary α,
\begin{quote}
Σ \char`\\$s'$ → ∀ α$'$ → α ≡[ $s'$ ] α$'$ → dialogue (φ(α $i$)) α ≡ dialogue (φ α$'$ $i$) α$'$.
\end{quote}
The induction hypothesis is \AgdaC{∀($i$ : ℕ) → continuous(dialogue(φ(α $i$)))},
which gives, for any $i$ and our arbitrary α,
\begin{quote}
Σ \char`\\$s$ → ∀ α$'$ → α ≡[ $s$ ] α$'$ → dialogue(φ(α $i$)) α = dialogue(φ(α $i$)) α$'$.
\end{quote}
Using the two projections π₀ and π₁ we get $s$ and a proof that
\begin{quote}
∀ α$'$ → α ≡[ $s$ ] α$'$ → dialogue(φ(α $i$)) α = dialogue(φ(α $i$)) α$'$.
\end{quote}
Hence we can take $s'$ = $i$ ∷ $s$, and the desired conclusion holds
substituting equals for equals (with cong) using transitivity and the
definition α $i$ ≡ α$'$ $i$ → α ≡[ $s$ ] α$'$ → α ≡[ $i$ ∷ $s$ ]
α$'$. This amounts to the second equation of the proof, where in the
pattern of the proof of the lemma we have $r$ : α $i$ ≡ α$'$ $i$ and
$rs$ : α ≡[ $s$ ] α$'$.
~
We need the following technical lemma because it is not provable in
intensional MLTT that any two functions are equal if they are
pointwise equal. The proof is admitedly written in a rather
laconic form. The point is that the notion of continuity depends only
on the values of the function, and the hypothesis says that the two
functions have the same values. Notice that the axiom of function
extensionality (any two pointwise equal functions are equal) is not
false but rather not provable or disprovable, and is consistent~\cite{HoTTbook}.
\begin{code}\>\<%
\\
\>\AgdaFunction{continuity-extensional} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{f} \AgdaBound{g} \AgdaSymbol{:} \AgdaFunction{Baire} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{(∀} \AgdaBound{α} \AgdaSymbol{→} \AgdaBound{f} \AgdaBound{α} \AgdaDatatype{≡} \AgdaBound{g} \AgdaBound{α}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaFunction{continuous} \AgdaBound{f} \AgdaSymbol{→} \AgdaFunction{continuous} \AgdaBound{g}\<%
\\
\>\AgdaFunction{continuity-extensional} \AgdaBound{f} \AgdaBound{g} \AgdaBound{t} \AgdaBound{c} \AgdaBound{α} \AgdaSymbol{=} \AgdaSymbol{(}\AgdaFunction{π₀}\AgdaSymbol{(}\AgdaBound{c} \AgdaBound{α}\AgdaSymbol{)} \AgdaInductiveConstructor{,} \AgdaSymbol{(λ} \AgdaBound{α'} \AgdaBound{r} \AgdaSymbol{→} \AgdaFunction{trans} \AgdaSymbol{(}\AgdaFunction{sym} \AgdaSymbol{(}\AgdaBound{t} \AgdaBound{α}\AgdaSymbol{))} \AgdaSymbol{(}\AgdaFunction{trans} \AgdaSymbol{(}\AgdaFunction{π₁}\AgdaSymbol{(}\AgdaBound{c} \AgdaBound{α}\AgdaSymbol{)} \AgdaBound{α'} \AgdaBound{r}\AgdaSymbol{)} \AgdaSymbol{(}\AgdaBound{t} \AgdaBound{α'}\AgdaSymbol{))))}\<%
\\
\>\AgdaFunction{eloquent-is-continuous} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{f} \AgdaSymbol{:} \AgdaFunction{Baire} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaFunction{eloquent} \AgdaBound{f} \AgdaSymbol{→} \AgdaFunction{continuous} \AgdaBound{f}\<%
\\
\>\AgdaFunction{eloquent-is-continuous} \AgdaBound{f} \AgdaSymbol{(}\AgdaBound{d} \AgdaInductiveConstructor{,} \AgdaBound{e}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaFunction{continuity-extensional} \AgdaSymbol{(}\AgdaFunction{dialogue} \AgdaBound{d}\AgdaSymbol{)} \AgdaBound{f} \AgdaBound{e} \AgdaSymbol{(}\AgdaFunction{dialogue-continuity} \AgdaBound{d}\AgdaSymbol{)}\<%
\\
\>\<\end{code}
The development for uniform continuity is similar to the above, with
the crucial difference that a dialogue tree in C ℕ is finite:
\begin{code}\>\<%
\\
\>\AgdaFunction{Cantor} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\<%
\\
\>\AgdaFunction{Cantor} \AgdaSymbol{=} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaDatatype{ℕ₂}\<%
\\
\>\AgdaFunction{C} \AgdaSymbol{:} \AgdaPrimitiveType{Set} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\<%
\\
\>\AgdaFunction{C} \AgdaSymbol{=} \AgdaDatatype{D} \AgdaDatatype{ℕ} \AgdaDatatype{ℕ₂}\<%
\\
\>\<\end{code}
We work with a refined version of uniform continuity (cf.\
Section~\ref{formulation}), where the modulus is a finite binary tree
\AgdaC{$s$} of indices rather than an upper bound of the indices. We
could have worked with a list of indices, but the proofs are shorter
and more direct using trees. The agreement relation defined by a tree
of indices is inductively defined as follows, where α ≡[[ $s$ ]] α$'$
says that α and~α$'$ agree at the positions collected in the tree~$s$:
\begin{code}\>\<%
\\
\>\AgdaKeyword{data} \AgdaDatatype{\_≡[[\_]]\_} \AgdaSymbol{\{}\AgdaBound{X} \AgdaSymbol{:} \AgdaPrimitiveType{Set}\AgdaSymbol{\}} \AgdaSymbol{:} \AgdaSymbol{(}\AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaDatatype{Tree} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaPrimitiveType{Set} \AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{empty} \AgdaSymbol{:} \AgdaSymbol{∀\{}\AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{:} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{\}} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[[} \AgdaInductiveConstructor{empty} \AgdaDatatype{]]} \AgdaBound{α'} \<[46]%
\>[46]\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaInductiveConstructor{branch} \AgdaSymbol{:} \<[11]%
\>[11]\<%
\\
\>[2]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaSymbol{∀\{}\AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{:} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaBound{X}\AgdaSymbol{\}\{}\AgdaBound{i} \AgdaSymbol{:} \AgdaDatatype{ℕ}\AgdaSymbol{\}\{}\AgdaBound{s} \AgdaSymbol{:} \AgdaDatatype{ℕ₂} \AgdaSymbol{→} \AgdaDatatype{Tree} \AgdaDatatype{ℕ}\AgdaSymbol{\}} \<[44]%
\>[44]\<%
\\
\>[2]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaSymbol{→} \AgdaBound{α} \AgdaBound{i} \AgdaDatatype{≡} \AgdaBound{α'} \AgdaBound{i} \AgdaSymbol{→} \AgdaSymbol{(∀(}\AgdaBound{j} \AgdaSymbol{:} \AgdaDatatype{ℕ₂}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[[} \AgdaBound{s} \AgdaBound{j} \AgdaDatatype{]]} \AgdaBound{α'}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[[} \AgdaInductiveConstructor{branch} \AgdaBound{i} \AgdaBound{s} \AgdaDatatype{]]} \AgdaBound{α'}\<%
\\
\>\<\end{code}
Again we are using the same constructor names as for the type of trees.
\begin{code}\>\<%
\\
\>\AgdaFunction{uniformly-continuous} \AgdaSymbol{:} \AgdaSymbol{(}\AgdaFunction{Cantor} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaPrimitiveType{Set}\<%
\\
\>\AgdaFunction{uniformly-continuous} \AgdaBound{f} \AgdaSymbol{=} \AgdaDatatype{Σ} \AgdaSymbol{ \textbackslash(}\AgdaBound{s} \AgdaSymbol{:} \AgdaDatatype{Tree} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{∀(}\AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{:} \AgdaFunction{Cantor}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[[} \AgdaBound{s} \AgdaDatatype{]]} \AgdaBound{α'} \AgdaSymbol{→} \AgdaBound{f} \AgdaBound{α} \AgdaDatatype{≡} \AgdaBound{f} \AgdaBound{α'}\<%
\\
%
\\
\>\AgdaFunction{dialogue-UC} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{d} \AgdaSymbol{:} \AgdaFunction{C} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaFunction{uniformly-continuous}\AgdaSymbol{(}\AgdaFunction{dialogue} \AgdaBound{d}\AgdaSymbol{)}\<%
\\
\>\AgdaFunction{dialogue-UC} \AgdaSymbol{(}\AgdaInductiveConstructor{η} \AgdaBound{n}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaSymbol{(}\AgdaInductiveConstructor{empty} \AgdaInductiveConstructor{,} \AgdaSymbol{λ} \AgdaBound{α} \AgdaBound{α'} \AgdaBound{n} \AgdaSymbol{→} \AgdaInductiveConstructor{refl}\AgdaSymbol{)}\<%
\\
\>\AgdaFunction{dialogue-UC} \AgdaSymbol{(}\AgdaInductiveConstructor{β} \AgdaBound{φ} \AgdaBound{i}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaSymbol{(}\AgdaInductiveConstructor{branch} \AgdaBound{i} \AgdaFunction{s} \AgdaInductiveConstructor{,} \AgdaFunction{lemma}\AgdaSymbol{)}\<%
\\
\>[0]\AgdaIndent{2}{}\<[2]%
\>[2]\AgdaKeyword{where}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{IH} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{j} \AgdaSymbol{:} \AgdaDatatype{ℕ₂}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaFunction{uniformly-continuous}\AgdaSymbol{(}\AgdaFunction{dialogue}\AgdaSymbol{(}\AgdaBound{φ} \AgdaBound{j}\AgdaSymbol{))}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{IH} \AgdaBound{j} \AgdaSymbol{=} \AgdaFunction{dialogue-UC} \AgdaSymbol{(}\AgdaBound{φ} \AgdaBound{j}\AgdaSymbol{)}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{s} \AgdaSymbol{:} \AgdaDatatype{ℕ₂} \AgdaSymbol{→} \AgdaDatatype{Tree} \AgdaDatatype{ℕ}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{s} \AgdaBound{j} \AgdaSymbol{=} \AgdaFunction{π₀}\AgdaSymbol{(}\AgdaFunction{IH} \AgdaBound{j}\AgdaSymbol{)}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{claim} \AgdaSymbol{:} \AgdaSymbol{∀} \AgdaBound{j} \AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[[} \AgdaFunction{s} \AgdaBound{j} \AgdaDatatype{]]} \AgdaBound{α'} \AgdaSymbol{→} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaBound{j}\AgdaSymbol{)} \AgdaBound{α} \AgdaDatatype{≡} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaBound{j}\AgdaSymbol{)} \AgdaBound{α'}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{claim} \AgdaBound{j} \AgdaSymbol{=} \AgdaFunction{π₁}\AgdaSymbol{(}\AgdaFunction{IH} \AgdaBound{j}\AgdaSymbol{)}\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{lemma} \AgdaSymbol{:} \AgdaSymbol{∀} \AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{→} \AgdaBound{α} \AgdaDatatype{≡[[} \AgdaInductiveConstructor{branch} \AgdaBound{i} \AgdaFunction{s} \AgdaDatatype{]]} \AgdaBound{α'} \AgdaSymbol{→} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α} \AgdaDatatype{≡} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α'} \<[92]%
\>[92]\<%
\\
\>[0]\AgdaIndent{4}{}\<[4]%
\>[4]\AgdaFunction{lemma} \AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{(}\AgdaInductiveConstructor{branch} \AgdaBound{r} \AgdaBound{l}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaFunction{trans} \AgdaFunction{fact₀} \AgdaFunction{fact₁} \<[48]%
\>[48]\<%
\\
\>[4]\AgdaIndent{6}{}\<[6]%
\>[6]\AgdaKeyword{where}\<%
\\
\>[6]\AgdaIndent{8}{}\<[8]%
\>[8]\AgdaFunction{fact₀} \AgdaSymbol{:} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α} \AgdaDatatype{≡} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α} \<[61]%
\>[61]\<%
\\
\>[6]\AgdaIndent{8}{}\<[8]%
\>[8]\AgdaFunction{fact₀} \AgdaSymbol{=} \AgdaFunction{cong} \AgdaSymbol{(λ} \AgdaBound{j} \AgdaSymbol{→} \AgdaFunction{dialogue}\AgdaSymbol{(}\AgdaBound{φ} \AgdaBound{j}\AgdaSymbol{)} \AgdaBound{α}\AgdaSymbol{)} \AgdaBound{r}\<%
\\
\>[6]\AgdaIndent{8}{}\<[8]%
\>[8]\AgdaFunction{fact₁} \AgdaSymbol{:} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α} \AgdaDatatype{≡} \AgdaFunction{dialogue} \AgdaSymbol{(}\AgdaBound{φ} \AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{))} \AgdaBound{α'}\<%
\\
\>[6]\AgdaIndent{8}{}\<[8]%
\>[8]\AgdaFunction{fact₁} \AgdaSymbol{=} \AgdaFunction{claim} \AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{)} \AgdaBound{α} \AgdaBound{α'} \AgdaSymbol{(}\AgdaBound{l}\AgdaSymbol{(}\AgdaBound{α'} \AgdaBound{i}\AgdaSymbol{))}\<%
\\
%
\\
\>\AgdaFunction{UC-extensional} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{f} \AgdaBound{g} \AgdaSymbol{:} \AgdaFunction{Cantor} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{(∀(}\AgdaBound{α} \AgdaSymbol{:} \AgdaFunction{Cantor}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaBound{f} \AgdaBound{α} \AgdaDatatype{≡} \AgdaBound{g} \AgdaBound{α}\AgdaSymbol{)} \<[67]%
\>[67]\<%
\\
\>[8]\AgdaIndent{14}{}\<[14]%
\>[14]\AgdaSymbol{→} \AgdaFunction{uniformly-continuous} \AgdaBound{f} \AgdaSymbol{→} \AgdaFunction{uniformly-continuous} \AgdaBound{g}\<%
\\
\>\AgdaFunction{UC-extensional} \AgdaBound{f} \AgdaBound{g} \AgdaBound{t} \AgdaSymbol{(}\AgdaBound{u} \AgdaInductiveConstructor{,} \AgdaBound{c}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaSymbol{(}\AgdaBound{u} \AgdaInductiveConstructor{,} \AgdaSymbol{(λ} \AgdaBound{α} \AgdaBound{α'} \AgdaBound{r} \AgdaSymbol{→} \AgdaFunction{trans} \AgdaSymbol{(}\AgdaFunction{sym} \AgdaSymbol{(}\AgdaBound{t} \AgdaBound{α}\AgdaSymbol{))} \AgdaSymbol{(}\AgdaFunction{trans} \AgdaSymbol{(}\AgdaBound{c} \AgdaBound{α} \AgdaBound{α'} \AgdaBound{r}\AgdaSymbol{)} \AgdaSymbol{(}\AgdaBound{t} \AgdaBound{α'}\AgdaSymbol{))))}\<%
\\
%
\\
\>\AgdaFunction{eloquent-is-UC} \AgdaSymbol{:} \AgdaSymbol{∀(}\AgdaBound{f} \AgdaSymbol{:} \AgdaFunction{Cantor} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaFunction{eloquent} \AgdaBound{f} \AgdaSymbol{→} \AgdaFunction{uniformly-continuous} \AgdaBound{f}\<%
\\
\>\AgdaFunction{eloquent-is-UC} \AgdaBound{f} \AgdaSymbol{(}\AgdaBound{d} \AgdaInductiveConstructor{,} \AgdaBound{e}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaFunction{UC-extensional} \AgdaSymbol{(}\AgdaFunction{dialogue} \AgdaBound{d}\AgdaSymbol{)} \AgdaBound{f} \AgdaBound{e} \AgdaSymbol{(}\AgdaFunction{dialogue-UC} \AgdaBound{d}\AgdaSymbol{)}\<%
\\
\>\<\end{code}
We finish this section by showing that the restriction of an eloquent
function \AgdaC{$f$ : Baire → ℕ} to the Cantor type is also eloquent. We first
define a pruning function from \AgdaC{B ℕ} to \AgdaC{C ℕ} that implements restriction:
\begin{code}\>\<%
\\
\>\AgdaFunction{embed-ℕ₂-ℕ} \AgdaSymbol{:} \AgdaDatatype{ℕ₂} \AgdaSymbol{→} \AgdaDatatype{ℕ}\<%
\\
\>\AgdaFunction{embed-ℕ₂-ℕ} \AgdaInductiveConstructor{₀} \AgdaSymbol{=} \AgdaInductiveConstructor{zero}\<%
\\
\>\AgdaFunction{embed-ℕ₂-ℕ} \AgdaInductiveConstructor{₁} \AgdaSymbol{=} \AgdaInductiveConstructor{succ} \AgdaInductiveConstructor{zero}\<%
\\
%
\\
\>\AgdaFunction{embed-C-B} \AgdaSymbol{:} \AgdaFunction{Cantor} \AgdaSymbol{→} \AgdaFunction{Baire}\<%
\\
\>\AgdaFunction{embed-C-B} \AgdaBound{α} \AgdaSymbol{=} \AgdaFunction{embed-ℕ₂-ℕ} \AgdaFunction{∘} \AgdaBound{α} \<[29]%
\>[29]\<%
\\
\>[5]\AgdaIndent{1}{}\<[1]%
\>[1]\<%
\\
\>\AgdaFunction{C-restriction} \AgdaSymbol{:} \AgdaSymbol{(}\AgdaFunction{Baire} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)} \AgdaSymbol{→} \AgdaSymbol{(}\AgdaFunction{Cantor} \AgdaSymbol{→} \AgdaDatatype{ℕ}\AgdaSymbol{)}\<%
\\
\>\AgdaFunction{C-restriction} \AgdaBound{f} \AgdaSymbol{=} \AgdaBound{f} \AgdaFunction{∘} \AgdaFunction{embed-C-B}\<%
\\
%
\\
\>\AgdaFunction{prune} \AgdaSymbol{:} \AgdaFunction{B} \AgdaDatatype{ℕ} \AgdaSymbol{→} \AgdaFunction{C} \AgdaDatatype{ℕ}\<%
\\
\>\AgdaFunction{prune} \AgdaSymbol{(}\AgdaInductiveConstructor{η} \AgdaBound{n}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaInductiveConstructor{η} \AgdaBound{n}\<%
\\
\>\AgdaFunction{prune} \AgdaSymbol{(}\AgdaInductiveConstructor{β} \AgdaBound{φ} \AgdaBound{i}\AgdaSymbol{)} \AgdaSymbol{=} \AgdaInductiveConstructor{β} \AgdaSymbol{(λ} \AgdaBound{j} \AgdaSymbol{→} \AgdaFunction{prune}\AgdaSymbol{(}\AgdaBound{φ}\AgdaSymbol{(}\AgdaFunction{embed-ℕ₂-ℕ} \AgdaBound{j}\AgdaSymbol{)))} \AgdaBound{i}\<%
\\
%
\\