-
Notifications
You must be signed in to change notification settings - Fork 0
/
uniform-lr.tex
2470 lines (2168 loc) · 108 KB
/
uniform-lr.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%% define an if for whether we are compiling as a tech-report
\newif\iftechreport
\techreportfalse
%\techreporttrue
%%% define the document class / layout for the tech report version... %%%
\iftechreport
\setlength{\itemsep}{0pt}
\documentclass{article}
%% margins
\setlength{\oddsidemargin}{0in}
\setlength{\textwidth}{6.5in}
%% paragraph layout
% \setlength{\parindent}{0pt}
% \addtolength{\parskip}{\baselineskip}
%% set list spacing parameters
\usepackage{tweaklist}
\renewcommand{\descripthook}{\setlength{\topsep}{10pt}%
\setlength{\itemsep}{0pt}\setlength{\labelsep}{0pt}}
%%% and the non-tech-report version %%%
\else
\documentclass[conference,compsoc]{IEEEtran}
%\documentclass[a4paper,USenglish]{lipics}
\fi
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{stmaryrd}
\usepackage{proof}
\begin{document}
%%% my commands %%%
\input{definitions.tex}
\title{Uniform Logical Relations}
\iftechreport
\author{Edwin Westbrook\\
Department of Computer Science\\
Rice University\\
Houston, TX 77005\\
Email: \texttt{[email protected]}}
\else
% \author[1]{Edwin Westbrook}
% \affil[1]{Department of Computer Science\\
% Rice University\\
% Houston, TX 77005\\
% Email: \texttt{[email protected]}}
\author{\IEEEauthorblockN{Edwin Westbrook}
\IEEEauthorblockA{Department of Computer Science\\
Rice University\\
Houston, TX 77005\\
Email: [email protected]}}
\fi
\maketitle
\begin{abstract}
Strong Normalization (SN) is an important property for intensional
constructive type theories such as the Calculus of Inductive
Constructions (CiC), the basis for the Coq theorem prover. Not only
does SN imply consistency, but it also ensures that type-checking is
decidable, and further, it provides a straightforward model, the
term model, for a theory. Unfortunately, although SN has been proved
for fragments of CiC, it is not known how to prove SN for CiC in its
entirety, including eliminations for large inductive types as well
as higher predicative universes. In this work, we show how to prove
SN for full CiC. They key insight given here is that terms must be
interpreted in a \emph{uniform} manner, meaning that the form of the
interpretation of a term must not depend on whether the term is a
type. We introduce a new technique called Uniform Logical Relations,
With uniformity as a guiding principle, and we show that this
technique can then be used to prove SN for CiC. An important
property of our technique is that it does not rely on Confluence,
and thus it could potentially be used for extensions of CiC with
added computation rules, such as Extensionality, for which
Confluence relies on SN.
\end{abstract}
%\IEEEpeerreviewmaketitle
%%%%%%%%%%%%%%%%%%%
%%%%% Section %%%%%
%%%%%%%%%%%%%%%%%%%
\section{Introduction}
Intensional constructive type theory (ICTT), as first introduced by
Martin-L\"{o}f \cite{martinlof72}, is compelling because it gives a
combined programming language and mathematical theory. This allows
users to write programs and proofs about those programs in the same
language (see e.g.~\cite{nps90}). Further, theories based on ICTT are
defined entirely syntactically. This makes them foundational, in the
sense that they can be defined with little or no appeal to models
or set theory.
An important consideration for such theories is Strong Normalization
(SN), which states that no well-typed term of the theory has an
infinite reduction path. Stated differently, SN says that the programs
of a theory have no infinite loops. SN is useful for a number of
reasons. First, it ensures the consistency of a theory, as it implies
that every proof has a cut-free version. Second, it ensures that
type-checking is decidable. Finally, SN also gives a simple model of
the theory, namely, the normal forms of that theory.
Unfortunately, it is not known how to prove SN for more powerful
extensions of ICTT such as the Calculus of Inductive Constructions
(CiC), the basis of the Coq theorem prover \cite{coq}. Although there
have been numerous proofs of SN for fragments of CiC
\cite{geuvers94,goguen94,altenkirch93,geuvers91,luo90,coquand90}, none
of these approaches has been generalized to the entirety of CiC. This
has lead to research into other approaches to proving the consistency
of CiC by providing set-theoretic models
\cite{barras10,werner08,miquel02,miquel00,werner97,stefanova96}.
The key difficulty is in combining two features: an impredicative
universe $\Prop$, and a cumulative type hierarchy of universes
$\Type_i$ for $i\geq 0$. To handle impredicativity requires the
Logical Relations technique introduced by Girard for System F
\cite{girard-proofs-types}, in which each type is interpreted as a
logically defined set of terms, also called a logical relation. With
a cumulative type hierarchy, however, we do not know whether a type is
a sort or not unless we normalize it, and thus, under the standard
approach to Logical Relations, it is unknown how to even interpret a
type without normalizing it. This seems to require SN to prove SN! The
problem is especially difficult in the presence of inductive types (as
pointed out by e.g.~\cite{geuvers94}), since the form of a type can
depend on whether a natural number term evaluates to 0 or to
1. Although Luo showed how to break this cycle in the case of ECC
using a difficult and complex quasi-normalization theorem
\cite{luo90}, ECC contains only products, not inductive types, and it
is not clear that this approach generalizes to theories that do
contain inductive types.
In this paper, we show how to solve this problem by using an
interpretation that is \emph{uniform}, meaning that the interpretation
does not need to know whether a type is a sort.\footnote{This approach
came out of the author's dissertation, which gave an interpretation
of a nominal extension of CiC into CiC \cite{westbrook-thesis}; the
interpretation for CiC in set theory given here is actually much
simpler because we do not have to worry things like intensional
equality and type universes in set theory.} We call this approach
Uniform Logical Relations. The key technical development that ensures
uniformity is to interpret types as sets of triples of context, terms, and
interpretations, i.e., sets of the form
$\setcompr{\triple{\Gamma}{M}{I}}{\phi(\Gamma,M,I)}$ where $M$ is a term
that is well-typed with respect to $\Gamma$,
and $\phi$ is
a logical formula which states that $I$ is a valid interpretation of
$M$. This is as opposed to the usual approach of interpreting types as
sets of terms $\setcompr{M}{\phi(M)}$.
% (Technically, both our
% approach and many prior approach consider not just terms but ``terms
% in context''; i.e., each term in a set is also bundled with a context
% $\Gamma$ relative to which it is well-typed.)
Under
the usual approach, the interpretation of the function type
$\pitype{x}{A}{B}$ depends on the form of $A$: this interpretation
must quantify over terms of type $A$ and
reducibility candidates when $A$ is a sort; over terms of type $A$ and
functions on reducibility candidates when $A$ is a kind-level
$\Pi$-type; and over just terms of type $A$ when $A$ is a type. This
information about $A$ requires the normal form of $A$ in general.
Under Uniform Logical Relations, in contrast, the interpretation of
$\pitype{x}{A}{B}$ always quantifies over triples
$\triple{\Gamma}{N}{X}\in\interpnod{A}$. This uniformity means we do not require
the normal form of $A$.
From a different viewpoint, uniformity means the interpretation
captures ``deep'' information about every term in the theory, instead
of just the types. For example, the interpretation of a constructor
application such as $c\;M_1\;M_2$ is the tuple $\triple{c}{I_1}{I_2}$,
where each $I_i$ is the interpretation of $M_i$. Intuitively, this
deep information is needed because even ``simple'' objects, like
natural numbers, can influence the interpretation of a type built
using elimination forms, such as the type
\[
\caseof{x}{\pcnoctxt{\z}{\nat} \;|\; \pcnoctxt{\s\;y}{\nat\to\nat}}
\]
A central concern with deep interpretations inside ZF set theory is
the Axiom of Regularity, which states that the set membership relation
$\in$ is well-founded. On the positive side, Regularity immediately
justifies primitive recursion on inductive types, because recursive
calls in CiC are guaranteed to follow the transitive closure of the
$\in$ relation. More subtly, Regularity explains why Uniform Logical
Relations does not work for potentially non-terminating terms like
$\lamabsnot{x}{x\;x}$, where a term is applied to itself, since no
function can be in its own domain or range without creating a cycle in
the $\in$ relation.
On the negative side, however, Regularity makes it difficult to
interpret proofs because of impredicativity, as proofs can quantify
over domains that contain themselves. To break the ``vicious cycle''
of impredicativity, all proofs are given a ``dummy'' interpretation,
written $\dummy$, which intuitively contains no information. (The
empty set $\emptyset$ could be used here, but we use a separate
notation $\dummy$ for clarity.) This works because it is not possible
in CiC to perform eliminations of proofs except when either the input
type intuitively contains no information, like the empty type
$\False$, or the output is another proof, whose interpretation
is also a dummy and does not need any information from the input.
This technique also means that Uniform Logical Relations construction
satisfies the Proof Irrelevance property (see, e.g., \cite{miquel02}),
since all proofs have the same interpretation.
The remainder of this document is organized as follows. Section
\ref{sec:cic} reviews the syntax and semantics of the Calculus of
Inductive Constructions (CiC). Section \ref{sec:cic-sn} then proves
Strong Normalization for CiC using Uniform Logical Relations.
% \footnote{Although it is widely believed that CiC has
% equivalent proof-theoretic strength as ZF with inaccessible
% cardinals, and thus that a proof of SN inside ZF would violate
% G\"{o}del's Second Incompleteness theorem, this is in fact only true
% for \emph{constructive} ZF; we discuss this more in Section
% \ref{sec:conclusion}.}
% Section \ref{sec:cnic} describes the Calculus of Nominal
% Inductive Constructions (CNIC), an extension of CiC with support for
% nominal features and higher-order encodings. Section
% \ref{sec:cnic-sn} then shows how Uniform Logical Relations can be
% adapted for CNIC.
Finally, Section \ref{sec:related-work} relates Uniform Logical
Relations to previous approaches, and Section \ref{sec:conclusion}
concludes.
% FIXME: cite tech report...?
% \iftechreport\else
% Proofs of most theorems are omitted for space reasons, but can be
% found in the companion technical report \cite{westbrook-techreport}.
% \fi
%%%%%%%%%%%%%%%%%%%
%%%%% Section %%%%%
%%%%%%%%%%%%%%%%%%%
\section{The Calculus of Inductive Constructions}
\label{sec:cic}
In this section, we give a brief overview of the Calculus of Inductive
Constructions. The version we give here has some small modifications
relative to the theory as presented in, for example, the Coq manual
\cite{coq}. These modifications are for increased conciseness, but do
not change the theory in a material way.
\textbf{A Note on Syntax:} Here and in the below we use particular
letters to stand for elements of particular syntactic classes; e.g.,
$M$ is always used for a term. These can appear with subscripts or
primes, as in $M_2'$ or $\Mfun$. We also use an arrow over a syntactic
construct to indicate a sequence of zero or more of those constructs.
For example, $\vec{x}$ denotes a sequence of variables. We use
subscripts $i$ and $j$ to denote the $i$th and $j$th elements of this
sequence, e.g., $x_i$, and we use vertical bars $|\vec{x}|$ to denote
the length of this sequence. If the letter under the arrow has a
prime, then so do the elements of the sequence, so for instance the
elements of $\vec{M'}$ are referred to as $M'_i$. We also use the
following compound notations: $M\;\vec{M}$ denotes the multi-arity
application $M\;M_1\ldots M_{|\vec{M}|}$; $[\vec{M}/\Gamma]$ denotes
the multi-arity substitution
$[M_1/x_1,\ldots,M_{|\vec{M}|}/x_{|\vec{M}|}]$, where $\vec{x}$ are
the variables on the left in $\Gamma$; and
$\pc{\vec{c}}{\vec{\Gamma}}{\vec{M}}$ denotes the sequence of pattern
cases $\pc{c_1}{\Gamma_1}{M_1}\;|\ldots|\;\pc{c_1}{\Gamma_1}{M_1}$
We assume mutually disjoint sets of constructors $c$, type
constructors $a$, variables $x$, and recursive variables $u$, where
the latter are used for recursive calls in primitive recursive
pattern-matching functions and the sets of variables and recursive
variables are infinite. We also use $y$ and $z$ for variables.
Figure \ref{fig:syntax} gives the syntax of CiC. The signatures
$\Sigma$ associate types with constructors $c$ and type constructors
$a$, while the contexts $\Gamma$ map variables $x$ and recursive
variables $u$ to types. We also use $\Delta$ for contexts below.
Recursive variables $u$ are also associated
with a number $n$ and a sequence of variables $\vec{x}$, which specify
that all occurrences of $u$ should have the form $u\;\vec{M}\;x_i$ for
some $i$ where $|\vec{M}|=n$, to ensure termination of primitive
recursion. In the below we write $|\Gamma|$ for the length of
$\Gamma$, i.e., the number of commas.
%%% syntax figure %%%
\begin{figure}
\centering
\iftechreport\else\begin{small}\fi
\begin{math}
\begin{array}{@{}lrl@{}}
\Sigma & ::= & \cdot \bor \Sigma,c:M \bor \Sigma,a:M\\
\Gamma & ::= & \cdot \bor \Gamma,\gxform{M} \bor \Gamma,\guform{n}{\vec{x}}{M}\\
M & ::= & \Prop \bor \Type_i \bor \pitype{x}{M}{M}
\bor \ctorapp{a}{\vec{M}}{\vec{M}}\\
& \borstar & x \bor M\;M \bor \lamabs{x}{M}{M} \bor \ctorapp{c}{\vec{M}}{\vec{M}}\\
& \borstar & u \bor \pmfun[ip]{u}{\Gamma}{\pc{c}{\Gamma}{M}\;|\;\ldots\;|\;\pc{c}{\Gamma}{M}}
\end{array}
\end{math}
\iftechreport\else\end{small}\fi
\caption{Syntax of CiC}
\label{fig:syntax}
\end{figure}
The remainder of Figure \ref{fig:syntax} defines the terms $M$. We
also use $N$, $Q$, and $R$ for terms, as well as $A$ and $B$ for terms
that are meant to denote types. The terms include the impredicative
universe $\Prop$ and the predicative universes $\Type_i$ for all
$i\geq 0$. These are the \emph{sorts}, written $s$. We also sometimes
use $ip$ for meta-variable that varies over $\{\pred,\impred\}$. In
addition, $\Type_{-1}$ is also used to denote $\Prop$. Terms also
include the function types $\pitype{x}{A}{B}$ and the inductive types
$\ctorapp{a}{\vec{M}}{\vec{N}}$, where the latter distinguishes
between the \emph{parameters} $\vec{M}$ and the \emph{arguments}
$\vec{N}$. Next are the variables $x$, the applications $M\;N$, the
$\lambda$-abstractions $\lamabs{x}{A}{M}$, and the constructor
applications $\ctorapp{c}{\vec{M}}{\vec{N}}$, which again
distinguish between parameters and arguments.
The final line lists the recursive variables $u$ and the
pattern-matching functions, where the latter have the form
$\pmfun[ip]{u}{\Gammaarg}{\pc{\vec{c}}{\vec{\Gamma}}{\vec{M}}}$.
Pattern-matching functions combine the \texttt{Fix} and \texttt{case}
terms of Coq. Each compound form $\pc{c_i}{\Gamma_i}{M_i}$ is called a
\emph{pattern case} with \emph{pattern context} $\Gamma_i$ and
\emph{body} $M_i$. Pattern-matching functions of this form take in
$|\Gammaarg|+1$ arguments and pattern-match on the last argument. The
last argument is called the \emph{scrutinee} and the earlier arguments
are called the \emph{parameters}. If the scrutinee has the form
$\ctorapp{c_i}{\vec{N}}{\vec{Q}}$ then the pattern-matching function
returns $M_i$, substituting the parameters for the variables of
$\Gammaarg$ and substituting the arguments $\vec{Q}$ for the pattern
variables listed in $\Gamma_i$. Pattern-matching functions are also
annotated with either $\pred$ or $\impred$, indicating whether they
eliminate a predicative or impredicative inductive type.
The operational semantics of CiC is given as a higher-order rewrite
system $\rrto$ in Figure \ref{fig:opsem}. This means that $M_1\rrto
M_2$ iff $M_2$ can be obtained by replacing a subterm of $M_1$ that
matches the left-hand side of a rule listed in Figure \ref{fig:opsem}
be the corresponding right-hand side of the rule. The first rule
performs the usual $\beta$-reduction, while the second performs the
pattern-matching reduction described in the previous paragraph. In
the below, we write $\rrtostar$ and $\conv$ respectively
for the reflexive-transitive closure
and the reflexive-symmetric-transitive closure of $\rrto$.
%%% Operational Semantics %%%
\begin{figure}
\centering
\iftechreport\else\begin{small}\fi
\begin{math}
\begin{array}{@{}rcl@{}}
\hspace{20pt}(\lamabs{x}{A}{M})\;N & \rrto & [N/x]M
\\[5pt]
\multicolumn{3}{l}{
(\Mfun=\pmfun{u}{\Gammaarg}{\pc{\vec{c}}{\vec{\Gamma}}{\vec{M}}})\;
\vec{N}\;\ctorapp{c_i}{\vec{Q}}{\vec{R}}
%\hspace{47pt}
} \\
& \rrto &
[\vec{N}/\Gammaarg,\vec{R}/\Gamma_i,\Mfun/u]M_i
\end{array}
\end{math}
\iftechreport\else\end{small}\fi
\caption{Operational Semantics of CiC}
\label{fig:opsem}
\end{figure}
% \begin{lemma}[Confluence]
% \label{lemma:confluence}
% If $M\conv N$ then there exists $Q$ such that $M\rrtostar Q$ and
% $N\rrtostar Q$.
% \end{lemma}
% \begin{myproof}
% The relation $\rrto$ is defined by an orthogonal, higher-order
% rewrite system and so is confluent by known techniques (see, e.g.,
% \cite{baader-nipkow98}).
% \end{myproof}
\iftechreport\else
In the below we also make use of call-by-name (CBN) reduction.
Intuitively, $M$ CBN reduces to $N$, written $M\rrtocbn N$, iff $N$
can be reached from $M$ by only reducing a redex that is either to the
left of zero or more applications in $M$ or is in the scrutinee of a
pattern-matching function at the top level of $M$. When $M\rrtocbn
M'$ holds by contracting a redex $R$ in $M$, we call the immediate
subterms of $R$ the \emph{constituents} of the reduction, and we
further say that $M$ call-by-name reduces to $M'$ \emph{with
normalizing constituents}, written $M\rrtocbnnc M'$, if all these
constituents are strongly normalizing. If there is no $M'$ such that
$M\rrtocbn M'$ then $M$ is called a \emph{weak head normal form}
(WHNF). These notions will be useful in Section \ref{subsec:interp}
below.
\fi
We do not give the well-formedness rules for signatures $\Sigma$;
these may be found in the Coq manual \cite{coq}. At a high level,
however, these require that $\Sigma$ contain sequences that define a
type constructor $a$ and its constructors $c_i$ of the following form:
\[
a:(\pigamma{\Gammap}{\pigamma{\Gammaa}{s}}),
c_1:(\pigamma{\Gammap}{\pigamma{\Gammaci[1]}{\ctorapp{a}{\Gammap}{\vec{M_c}}}}),
\ldots
\]
The context $\Gammap$ lists the \emph{parameters} of the inductive
type $a$, which must be the same for for all of the constructors. The
contexts $\Gammaa$ and $\Gammaci[i]$ list the \emph{arguments} of $a$
and $c_i$, respectively. All of the types must be well-typed for the
prefix of $\Sigma$ before $a$, except that the $\Gammaci[i]$ may
contain $a$ \emph{strictly positively}, meaning that types of the form
$\ctorapp{a}{\vec{N}}{\vec{Q}}$ can only occur as the return type
of zero or more $\Pi$-abstractions directly to the right
of a colon in $\Gammaci[i]$. The signature $\Sigma$ and its
well-formedness are left implicit in the below.
We also implicitly assume that any contexts $\Gamma$ are well-formed,
meaning that all listed types are well-typed.
% Well-formedness for contexts is given by the judgment $\wfctxtj{\Gamma}$,
% defined as follows:\\
% \[
% \figfill
% \infer{\wfctxtj{\cdot}}{}
% \figfill
% \infer{\wfctxtj{\Gamma,\gxform{A}}}{\wfctxtj{\Gamma} & \typej{A}{s}}
% \figfill
% \infer{\wfctxtj{\Gamma,\guform{n}{\vec{x}}{A}}}{\wfctxtj{\Gamma} & \typej{A}{s}}
% \figfill
% \hspace{30pt}
% \]
% These rules require that each type $A$ listed in $\Gamma$ is
% well-typed at some sort $s$ in the prefix of $\Gamma$ before $A$. We
% implicitly assume well-formedness of all contexts used in the typing
% rules below.
The typing rules are given in Figure \ref{fig:typing}. The first rule
is the conversion rule, which states that equal types have the same
elements. Note that this only allows a single step of conversion;
although the rule may be used multiple times, each use requires the
destination type $A'$ to be well-typed, ensuring that only conversions
that use well-typed types can be used. The second rule is the
subtyping rule, which states that if $M$ has type $A$ for $A$ a
\emph{subtype} of $A'$, written $A\subtype A'$, then $M$ has type
$A'$. Subtyping is the reflexive-transitive closure of the following
three cases: $\Prop\subtype\Type_0$; $\Type_i\subtype\Type_{i+1}$; and
if $B_1\subtype B_2$ then
$\pitype{x}{A}{B_1}\subtype\pitype{x}{A}{B_2}$. Note that subtyping
is guaranteed to preserve well-typedness of types. The next two rules
state that $\Prop:\Type_0$ and $\Type_i:\Type_{i+1}$. The next two
rules type $\Pi$-types $\pitype{x}{A}{B}$ by requiring the types of
both $A$ and $B$ to be sorts. Also, if $B$ is impredicative, meaning
it has type $\Prop$, then the type of $\pitype{x}{A}{B}$ is $\Prop$,
and otherwise the type of $\pitype{x}{A}{B}$ is the maximum universe
of that of both $A$ and $B$.
%%% Typing %%%
\begin{figure*}
\centering
\iftechreport\else\begin{footnotesize}\fi
\begin{tabular}{@{\hspace{-0pt}}c@{\hspace{-0pt}}}
\infer{\typej{M}{A'}}{\typej{M}{A} & A\conv A' & \typej{A'}{s}}
\figfill
\infer{\typej{M}{A'}}{\typej{M}{A} & A\subtype A'}
\figfill
\infer{\typej{\Prop}{\Type_0}}{}
\figfill
\infer{\typej{\Type_i}{\Type_{i+1}}}{}
\\ \\
\infer{\typej{\pitype{x}{A}{B}}{\Type_i}}{\typej{A}{\Type_i} & \typej[\Gamma,x:A]{B}{\Type_i}}
\figfill
\infer{\typej{\pitype{x}{A}{B}}{\Prop}}{\typej{A}{s} & \typej[\Gamma,x:A]{B}{\Prop}}
\figfill
\infer{\typej{\lamabs{x}{A}{M}}{\pitype{x}{A}{B}}}{\typej{A}{s} & \typej[\Gamma,x:A]{M}{B}}
\figfill
\infer{\typej{x}{A}}{x:A\in\Gamma}
\\ \\
\infer{\typej{M\;N}{[N/x]B}}{\typej{M}{\pitype{x}{A}{B}} & \typej{N}{A}}
\figfill
\infer{\typej{\ctorapp{a}{\vec{M}}{\vec{N}}}{s}}{
a:\pigamma{\Gammap}{\pigamma{\Gammaa}{s}}\in\Sigma
& \typej{(\vec{M};\vec{N})}{\Gammap;\Gammaa}
}
\\ \\
\infer{
\typej{\ctorapp{c}{\vec{M}}{\vec{N}}}{\ctorapp{a}{\vec{M}}{[\vec{M}/\Gammap,\vec{N}/\Gammac]\vec{Q}}}
}{
c:\pigamma{\Gammap}{\pigamma{\Gammac}{\ctorapp{a}{\Gammap}{\vec{Q}}}} \in\Sigma
&
\typej{(\vec{M};\vec{N})}{\Gammap;\Gammac}
}
\figfill[4pt]
\infer{\typej{u\;\vec{M}\;(x_i\;\vec{N})}{[(\vec{M},(x_i\;\vec{N}))/\Gamma_u]B}}{
(\guform{|\vec{M}|}{\vec{x}}{\pigamma{\Gamma_u}{B}})\in\Gamma &
\typej{(\vec{M},(x_i\;\vec{N}))}{\Gamma_u}
}
\\ \\
\infer{
\typej{
\pmfun[ip]{u}{\Gammaarg}{\pc{\vec{c}}{\vec{\Gamma}}{\vec{M}}}
}{
(\Afun = \pigamma{\Gammaarg}{\pitype{x}{\ctorapp{a}{\vec{N}}{\vec{Q}}}{B}})
}
}{
\begin{array}{@{}c@{}}
\typej{\Afun}{s}
\figfill
a:\pigamma{\Gammap}{\pigamma{\Gammaa}{s_a^{ip}}}\in\Sigma
\figfill
\elimok{a}{s}
\figfill
\vec{c} = \ctors{a}
\figfill
\forall i. (\wfj[\Gamma,\Gammaarg]{\Gamma_i})
\\
\forall i. (\typej[\Gamma,\Gammaarg,\Gamma_i]{\ctorapp{c_i}{\vec{N}}{\Gamma_i}}{\ctorapp{a}{\vec{N}}{\vec{Q}}})
\figfill
\forall i. (\typej[\Gamma,\Gammaarg,\Gamma_i,\guform{|\Gammaarg|}{\Gamma_i}{}]{M_i}{[\ctorapp{c_i}{\vec{N}}{\Gamma_i}/x]B})
\end{array}
}
\end{tabular}
\iftechreport\else\end{footnotesize}\fi
\caption{Typing Rules of CiC}
\label{fig:typing}
\end{figure*}
For inductive types $\ctorapp{a}{\vec{M}}{\vec{N}}$, the parameters
$\vec{M}$ and the arguments $\vec{N}$ must have the types given by the
contexts $\Gammap$ and $\Gammaa$ in $\Sigma$. This is stated with the
judgment $\typej{(\vec{M};\vec{N})}{\Gammap;\Gammaa}$ which states
that $|\vec{M}|=|\Gammap|$, $|\vec{N}|=|\Gammaa|$, and that, for each
term $Q$ in $\vec{M},\vec{N}$ with type $A$ occurring at the same
position in $\Gammap,\Gammaa$, we have
$\typej{Q}{[\vec{M}/\Gammap,\vec{N}/\Gammaa]A}$.
For variables, we look the type up in the context. For applications
$M\;N$, we require $M$ to have function type $\pitype{x}{A}{B}$ and
$N$ to have type $A$, returning type $[N/x]B$. For
$\lambda$-abstractions, we require the domain type $A$ to be
well-formed, the body $M$ to have type $B$ under the context extended
with variable $x$, and we return function type $\pitype{x}{A}{B}$.
For constructor applications $\ctorapp{c}{\vec{M}}{\vec{N}}$, we again
require the parameters $\vec{M}$ and arguments $\vec{N}$ to have the
appropriate types given in $\Gammap$ and $\Gammac$, yielding the
return type of $c$ with the parameters and arguments substituted in.
For recursive calls to $u$, we require the term to be of the form
$u\;\vec{M}\;x_i$ where $x_i$ is one of the variables to which $u$ may
be applied, where $|\vec{M}|$ is the number of arguments before $x_i$
to which $u$ must be applied, and where all of $\vec{M}$ and $x_i$
have the types required by the type of $u$.
To type a pattern-matching function, we first require that its type
$\Afun$ (which includes the parameter types $\Gammaarg$) has type $s$
for some $s$. We then require that $a$ can be eliminated at sort
$s$, written $\elimok{a}{s}$; this states that, if $a$ is
impredicative then $s=\Prop$, except for the special case that $a$ has
at most one constructor, all of whose arguments are proofs (i.e., have
a type which has type $\Prop$), when $s$ is allowed to be
predicative. Next, we require that the patterns exactly match
the constructors of $a$ in $\Sigma$, written
$\ctors{a}$. Next, we require that the pattern contexts $\Gamma_i$ are
all well-formed. Finally, we require that each $c_i$ applied to the
given parameters and the variables listed in $\Gamma_i$ has same type
as the input type, and that each body $M_i$ has as its type the result
of substituting this application of $c_i$ into the return type $B$.
\begin{lemma}
\label{lemma:type-typing}
If $\typej{M}{A}$ then $\exists s.\typej{A}{s}$.
\end{lemma}
\iftechreport
%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Sub-Section %%%%%
%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Call-by-Name Reduction}
\label{subsec:cbn}
In order to prove reducibility of $\lamabs{x}{A}{M}$ below, we will
need to prove that $(\lamabs{x}{A}{M})\;N$ is reducible for all
reducible $N$. Since reducibility is proved by induction on the
structure of terms, we get by assumption that $[N/x]M$ is reducible;
to proceed, we need to ``undo'' a step of reduction.\footnote{This
``undoing'' is used in a similar manner as the condition \CRthree\
in Girard's original proof \cite{girard-proofs-types}, and also has
a counterpart in approaches based on saturated sets, such as that of
Altenkirch \cite{altenkirch93}.} For pattern-matching functions,
however, the situation is more complex: if $\Mfun$ is a
pattern-matching function with cases $M_i$, and if we have by the
inductive hypothesis that $[\vec{N}/\Gammaarg,\vec{Q}/\Gamma_i]M_i$ is
reducible for all reducible $\vec{N}$ and $\vec{Q}$, then undoing a
step of reduction only yields that $\Mfun\;\vec{N}\;N$ is reducible
for $N$ of the form $\ctorapp{c}{\vec{R}}{\vec{Q}}$. In other words,
we might need to undo multiple reductions on the scrutinee argument
$N$. We only need to undo reductions on the path to a weak head normal
form of $N$, however. Call-by-name (CBN) reduction gives a disciplined
way to talk about exactly these sorts of reductions.
In the remainder of this section, we introduce CBN reduction and
prove some properties of CBN that will be used below. More
specifically, we deal with the reduction relation $\rrtocbnnc$ which
only performs CBN reductions when the immediate subterms of the redex
involved are all strongly normalizing; otherwise we could have
$M\rrtocbn N$ via a redex that ``throws away'' a subterm of $M$, so
$\SN(N)$ does not imply $\SN(M)$. We then prove that undoing
$\rrtocbnnc$ preserves SN (Lemma \ref{lemma:cbn-nc-whnf}), and also
that $\rrtocbnnc$ satisfies a weak Standardization property for
reduction to weak head normal forms (Lemma \ref{lemma:cbn-nc-whnf}).
These both follow from Lemma \ref{lemma:cbn-diamond}, which shows that
$\rrtocbnnc$ weakly commutes with standard reduction. Note that none
of this material should be considered surprising or novel; Lemma
\ref{lemma:cbn-diamond}, for example, is proved as Lemma 3.5.2 by
Altenkirch \cite{altenkirch93}, where CBN reduction is called weak
head reduction.
%% CBN reduction
\begin{definition}[CBN Reduction]
\label{def:cbn}
We say that $M$ \emph{call-by-name (CBN) reduces} to $M'$, written
$M\rrtocbn M'$, iff the following hold:
\begin{enumerate}
\item If $M$ is a redex, then $M'$ is the result of contracting $M$;
\item If $M\equiv\Mfun\;\vec{N}\;N$ such that $M$ is not a redex and
$\Mfun$ is a pattern-matching function with $|\vec{N}|$
parameters, and if $N\rrtocbn N'$, then
$M'\equiv\Mfun\;\vec{N}\;N'$; and
\item If $M\equiv M_1\;M_2$ for $M$ not of one of the above forms,
and if $M_1\rrtocbn M_1'$, then $M'\equiv M_1'\;M_2$.
\end{enumerate}
If none of these apply, then there is no $M'$ such that
$M\rrtocbn M'$, and $M$ is called a \emph{weak head normal form}
(WHNF). When $M\rrtocbn M'$ holds, by contracting a redex $R$ in
$M$, we call the immediate subterms of $R$ the \emph{constituents}
of the reduction, and we further say that $M$ call-by-name reduces
to $M'$ \emph{with normalizing constituents}, written $M\rrtocbnnc
M'$, if all these constituents are strongly normalizing.
\end{definition}
%% CBN-NC closed under application
\begin{lemma}
\label{lemma:cbn-nc-app}
If $M\rrtocbnnc M'$ then $M\;N\rrtocbnnc M'\;N$.
\end{lemma}
\iftechreport
\begin{myproof}
If $M\rrtocbnnc M'$ then $M$ must be of the form $Q\;\vec{R}$ where
$Q$ is either a redex or matches case 2 of Definition \ref{def:cbn}.
In either case, $M\;N$ cannot be a redex, nor can it match case 2 of
Definition \ref{def:cbn}, and so by case 3 of Definition
\ref{def:cbn} we have that $M\;N\rrtocbn M'\;N$. In addition, this
reduction has the same normalizing constituents as the original CBN
reduction, so $M\;N\rrtocbnnc M'\;N$.
\end{myproof}
\fi
%% Diamond-y property of CBN
\begin{lemma}
\label{lemma:cbn-diamond}
If $M\rrtocbnnc N$ and $M\rrto M'$, then either $M'\equiv N$ or
there exists $N'$ such that $M'\rrtocbnnc N'$ and $N\rrtostar N'$,
where the latter can be strengthened to $N\rrto N'$ when the
reduction $M\rrto M'$ contracts a redex of $M$ that is not a subterm
of a constituent of the reduction $M\rrtocbnnc N$.
\end{lemma}
\iftechreport
\begin{myproof}
Let $R$ be the redex contracted by the reduction $M\rrtocbnnc N$ and
$R'$ be that contracted by the reduction $M\rrto M'$. We now
consider four cases. If $R$ and $R'$ are the same redex, then
$M'\equiv N$. If neither $R$ nor $R'$ is a subterm of the other,
meaning that $R'$ is not a constituent of $M\rrtocbnnc N$, then
immediately we have that $R$ exists in $M'$ and $R'$ exists as a CBN
redex in $N$, and reducing either yields an $N'$ such that
$M'\rrtocbnnc N'$ and $N\rrto N'$. It is not possible for $R$ to be
a strict subterm of $R'$, since by definition call-by-name reduction
does not contract strict subterms of redexes.
In the final case, $R'$ is a strict subterm of $R$. Let $Q'$ be the
result of contracting $R'$, and let $Q$ be the result of replacing
the subterm $R'$ of $R$ with $Q'$. By contracting $Q$ in $M'$ we get
an $N'$ such that $M'\rrtocbn N'$. Further, since reductions inside
a constituent cannot cause it to no longer be strongly normalizing,
we see that $M'\rrtocbnnc N'$. In addition, by straightforward
structural reasoning it is possible to conclude that the reduction
$M\rrtocbnnc N$ replaces zero or more copies of $R'$ exactly where
the reduction $M'\rrtocbnnc N'$ places zero or more copies of $Q'$,
and that otherwise $N$ and $N'$ are the same, whereby we get that
$N\rrtostar N'$.
% FIXME: tighten up the above using a lemma about M\rrto M' and
% N_i\rrto N_i' implies [\vec{N}/\vec{x}]M \rrto [\vec{N'}/\vec{x}]M'
\end{myproof}
\fi
%% backwards preservation of SN under CBN-NC reduction
\begin{lemma}
\label{lemma:cbn-nc-sn}
If $M\rrtocbnnc N$ and $\SN(N)$ then $\SN(M)$.
\end{lemma}
\iftechreport
\begin{myproof}
We prove that $\SN(M')$ for all $M'$ such that $M\rrto M'$, whereby
the result immediately follows, and we proceed by induction on the
sum of $\size{N}$ and of $\size{Q_i}$ for the constituents of the
reduction $M\rrtocbnnc N$. Using Lemma \ref{lemma:cbn-diamond}, we
have three cases: $M'\equiv N$, where the result is immediate; $M'$
results from reduction in a constituent of the reduction
$M\rrtocbnnc N$, where the result follows by the induction
hypothesis on $\size{Q_i}$ for the constituent $Q_i$ of the
reduction; or $M'$ results from reduction not in a constituent,
where the result follows by the induction hypothesis on $\size{N}$.
For the latter two cases, it is straightforward to see that the
reduction $M\rrto M'$ cannot increase $\size{N}$ or $\size{Q_i}$
for any $Q_i$, and that both cases reduce at least one of these.
\end{myproof}
\fi
%% Standardization-y property of CBN-NC reduction
\begin{lemma}
\label{lemma:cbn-nc-whnf}
If $M\rrtocbnnc N$ and if $M\rrtostar Q$ for weak head normal form
$Q$, then $N\rrtostar Q$.
\end{lemma}
\iftechreport
\begin{myproof}
We use the weaker assumption that $M\rrtocbn N$, and proceed by
induction on the number of steps in $M\rrtostar Q$. There is no base
case for $M\equiv Q$, since $M\rrtocbn N$ precludes the possibility
that $M$ is a WHNF. Thus we have $M\rrto M'\rrtostar Q$ for some
$M'$. By Lemma \ref{lemma:cbn-diamond} we either have $M'\equiv N$,
and the result is immediate, or $M'\rrtocbn N'$ and $N\rrtostar N'$
for some $N'$. By the inductive hypothesis we then have that
$N'\rrtostar Q$, and so $N\rrtostar Q$ by transitivity of
$\rrtostar$.
\end{myproof}
\fi
\else
\fi
% %%%%%%%%%%%%%%%%%%%
% %%%%% Section %%%%%
% %%%%%%%%%%%%%%%%%%%
% \section{A Cumulative Universe Hierarchy inside ZF}
% \label{sec:model}
% In order to ensure that our interpretation is well-formed
% set-theoretically, we first define a basic ``backbone'' of our model
% by defining interpretations \Ui\ for the universes. Each \Ui\
% intuitively gives the allowed interpretations for types of sort
% $\Type_{i-1}$, or of sort \Prop\ for $i=0$. Thus each \Ui\ will
% contain triples $\triple{\Gamma}{M}{I}$ of contexts $\Gamma$, terms
% $M$ that are well-typed with respect to $\Gamma$, and valid
% interpretations $I$ of those terms. To interpret proof terms, we
% include the ``dummy'' interpretation $\dummy$, as discussed in the
% Introduction. The dummy interpretation $\dummy$ is also used for
% ``stuck'' terms with free variables, as discussed below in Section
% \ref{subsec:interp}.
% To define the \Ui, we use transfinite recursion on ordinals. Ordinals
% and transfinite recursion are briefly reviewed here, but see any
% standard reference (e.g., Enderton \cite{enderton77}) for more
% details. The first ordinal is 0. Each ordinal $\alpha$ has a
% successor, written $\alpha+1$, which is the least ordinal greater than
% $\alpha$. Such ordinals are called \emph{successor ordinals}.
% Finally, any infinite increasing sequence of ordinals also has a least
% ordinal greater than all ordinals in the sequence. Such ordinals are
% called \emph{limit ordinals}. Following convention, we write $\lambda$
% for limit ordinals in this section. We use the natural numbers
% $1,2,\ldots$ to denote the first, second, etc.\ successors of 0; these
% are called the \emph{finite ordinals}. The first infinite ordinal,
% written $\omega$, is a limit ordinal that is greater than all finite
% ordinals. Finally, we write $\Omega$ for the first \emph{uncountable}
% ordinal, which is an ordinal that is greater than an uncountable
% number of other ordinals. A key property of $\Omega$ is that it is
% \emph{regular}, which here means that any countable sequence of
% countable ordinals will have an upper bound which is also countable,
% i.e., less than $\Omega$.
% The \Ui\ are defined in Figure \ref{fig:universes}, using a number of
% helper definitions. The first of these, $\F(S)$, intuitively performs
% one step of constructing a universe \Ui. It takes a set $S$ and adds
% all tuples of the form $\pair{c}{I_1,\ldots, I_n}$ where each $I_i$ is
% already in $S$, as well as all countable functions on $S$, i.e., all
% functions whose domain and range are countable subsets of $S$. The set
% of countable functions on $S$ is written $\countablefun{S}{S}$.
% \begin{figure}
% \centering
% %\iftechreport\else\begin{small}\fi
% \begin{math}
% \begin{array}{@{}lcl@{}}
% \F(S) & = &
% S \;
% %\begin{array}[t]{@{}l@{}}
% %\cup\;\{\emptyset,\dummy\}
% \cup\;\setcompr{\pair{c}{\vec{I}}}{ \forall i.I_i\in S }%\\
% \;\cup\;(\countablefun{S}{S})
% %\end{array}
% \\
% \liftset{i}{S} & = &
% \setcomprlong{\triple{\Gamma}{A}{I \subseteq (\Ctxt\times\Term\times S)}}{
% \SN(A) \mywedge \typej[\Gamma]{A}{\Type_{i-1}} \mywedge \CR{\Gamma}{A}{I}}
% \\[18pt]
% \Sii{0} & = & \Ii \;\cup\; \setcompr{S}{\exists\Gamma.\exists A.\;\triple{\Gamma}{A}{S}\in\Ui} \\
% \Sii{\alpha+1} & = & \F(\Sii{\alpha})\\
% \Sii{\lambda} & = & \bigcup_{\alpha<\lambda} \Sii{\alpha}
% \\[7pt]
% \Ii[0] & = & \{\dummy\}\\
% \Ii[i+1] & = & \Sii{\Omega}
% \\[5pt]
% \Ui & = & \liftset{i}{\Ii}
% \end{array}
% \end{math}
% %\iftechreport\else\end{small}\fi
% \caption{The Cumulative Universe Hierarchy in ZF}
% \label{fig:universes}
% \end{figure}
% The next definition in Figure \ref{fig:universes} is $\liftset{i}{S}$,
% which intuitively forms a universe from a set of allowed
% interpretations of types. This function forms the set of all triples
% $\triple{\Gamma}{A}{I}$ such that: $I$ itself is a set of triples
% $\triple{\Gamma'}{M}{I'}$ for $I'\in S$; $A$ is strongly normalizing;
% $A$ has type $\Type_{i-1}$ (where $\Type{-1}$ denotes $\Prop$); and
% $I$ is a \emph{reducibility candidtate} for $\Gamma$ and $A$, written
% $\CR{\Gamma}{A}{I}$. The reducibility candidates are defined below in
% Section \ref{subsec:interp}, but all we need to know here is that they
% are a definable class of sets.
% The remainder of Figure \ref{fig:universes} defines the $\Ui$ using
% the sets $\Sii{\alpha}$, defined by transfinite recursion, along with
% the sets $\Ii$. Intuitively, $\Ii$ defines the set of all possible
% interpretations that could be used in $\Ui$, though some of these are
% removed by the $\liftset{i}{\cdot}$ function, while $\Sii{\alpha}$ is
% the set of all interpretations that can be used in $\Ui[i+1]$ after
% $\alpha$ many steps of construction. The first line defines the base
% case for $\Sii{\alpha}$ where $\alpha=0$, by combining the set $\Ii$
% of all interpretations allowed in the previous universe and the set
% of all interpretations of types in the previous universe. The
% case for successor ordinals $\alpha+1$ applies $\F$ to the previous
% step. The case for limit ordinals $\lambda$ takes the union of all
% $\Sii{\alpha}$ for $\alpha<\lambda$. The sets $\Ii[i+1]$ are then
% defined as $\Sii{\Omega}$, i.e., as the union of all $\Sii{\alpha}$
% for countable $\alpha$. For $i=0$, we take $\Ii[0]=\{\dummy\}$, which
% intuitively restricts the interpretations of proofs (since $\Ii[0]$ is
% used for the $\Prop$ universe) to $\dummy$. Finally, $\Ui$ is defined
% as $\liftset{i}{\Ii}$. In the below, we also use the shorthands
% $\Ui[s]$ and $\Ii[s]$, which denote $\Ui[i+1]$ and $\Ii[i+1]$,
% respectively, when $s=\Type_i$ and denote $\Ui[0]$ and $\Ii[0]$,
% respectively, when $s=\Prop$.
% In order to better understand the above definitions, we now briefly
% consider, at a high level, how a number of constructs are interpreted
% into the \Ui. As discussed above, a type $A$ is interpreted as a
% set $S$ of triples $\triple{\Gamma}{M}{I}$ where $\typej{M}{A}$. If
% $A$ has sort $s$, then the $I$ are all in $\Ii[s]$, and further, for
% any particular $M$, the actual interpretation of $M$ is guaranteed to
% be one of the $I$ associated with $M$ in the interpretation of $A$. We
% can take this ``one level up'' and get that the interpretation of $s$
% itself, which is $\Ui[s]$, will contain $\triple{\Gamma}{A}{S}$.
% These properties follow from the Reducibility Theorem, which
% is not proved until Section \ref{subsec:reducibility}, but it is
% useful here to understand the intent.
% Constructor applications $\ctorapp{c}{\vec{M}}{\vec{N}}$ are
% interpreted as tuples $\pair{c}{\vec{I}}$, where $\vec{I}$ are the
% interpretations of the arguments $\vec{N}$, while functions are
% interpreted as functions from the interpretations of the inputs to the
% interpretations of the corresponding outputs. Note that this
% interpretation of functions does not cause problems for functions of
% dependent types $\pitype{x}{A}{B}$, since the types $[M/x]B$ for
% different $M$ are not differentiated in the $\Ii$. The different
% $[M/x]B$ types are only differentiated when we form $\Ui[s]$. Stated
% differently, if $A$ and $B$ both have sort $s$ (the maximum of the
% sorts of each of $A$ and $B$), then the interpretations of all $M$ of
% type $A$ and all $N$ of type $[M/x]B$ are in $\Ii[s]$. Thus we can
% show that any function $f$ from interpretations of terms $M$ of type
% $A$ to terms $N$ of type $[M/x]B$ will also be in $\Ii[s]$, since $f$
% will be added to $\Ii[s]$ by some application of the $\F$
% operator. This requires $f$ to be countable, as $\F$ only adds
% countable functions, but this holds because there are only countably
% many terms $M$ of type $A$. Our argument also requires that all
% interpretations of inputs $M$ and outputs $N$ be in $\Sii{\alpha_f}$
% for some fixed ordinal $\alpha_f<\Omega$, so that $f$ can be in
% $\Sii{\alpha_f+1}$. The latter condition follows by regularity of
% $\Omega$ (not to be confused with the Axiom of Regularity), since each
% of countably many terms $M$ or $N$ is in $\Sii{\alpha_j}$ for some
% countable ordinal $\alpha_j$.
% The use of the regularity of $\Omega$ here essentially means that we
% are relying on the fact that $\Omega$ is ``big enough'' to ensure that
% the necessary $\alpha_f<\Omega$ exists for any countable function
% $f$. (Note that this explains why use only countable functions in
% $\F$, as the regularity argument only works for countable functions.)
% At first glance, it might seem that using $\Omega$ is overkill, and
% that we might get away with a smaller ordinal. All of the natural
% numbers, of type $\nat$ (built with constructors \z\ and \s), for
% exapmle, exist in $\Sii[0]{\omega}$. Thus all functions over \nat\
% exist in $\Sii[0]{\omega+1}$, and all functions of any higher-order
% type built from $\nat$ and $\to$ (but not polymorphism) exist in
% $\Sii[0]{\omega+\omega}$. The key difficulty is in interpreting
% inductive types with constructors that can take functions that
% quantify over the inductive type itself.
% For example, the following inductive type, introduced by Coquand et
% al.\ \cite{coquand97}, captures the countable ordinals definable
% inside CiC itself:
% \[
% \begin{array}{lcl}
% \ordz & :: & \ord\\
% \ords & :: & \ord\to\ord\\
% \ordlim & :: & (\nat\to\ord)\to\ord
% \end{array}
% \]
% The constructors \ordz\ and \ords\ are used to represent zero and
% successor ordinals, respectively, while \ordlim\ forms a limit ordinal
% from an infinite sequence of ordinals, here represented as a function
% from \nat\ to \ord. Intuitively, the interpretation $\interpnod{\ord}$
% of \ord\ is the least fixed point of the set-theoretic function
% \[
% F_{\ord}(S) =
% \begin{array}[t]{@{}l@{}}
% {\;\langle\ordz\rangle\;} \;\cup\; \setcompr{\pair{\ords}{x}}{x\in S}\\
% \;\cup\; \setcompr{\pair{\ordlim}{f}}{f\in \interpnod{\nat}\to S}
% \end{array}
% \]
% where $\interpnod{\nat}$ is the interpretation of \nat, containing
% $\langle\z\rangle$ and closed under forming $\pair{\s}{x}$ for all $x$
% in $\interpnod{\nat}$.
% As mentioned above, it is straightforward to see that all of
% $\interpnod{\nat}$ is contained in $\Sii[0]{\omega}$. The same is
% true for elements of \ord\ built from \ordz\ and \ords. Any function
% from (the interpretations of) \nat\ to \ord\ will not occur until
% $\Sii[0]{\omega+1}$, though, since not all of $\interpnod{\nat}$, the
% domain, occurs until $\Sii[0]{\omega}$. Thus the first \ordlim\
% interpretations will occur in $\Sii[0]{\omega+2}$. However, these
% first \ordlim\ interpretations can only use functions $f$ whose ranges
% contain only interpretations built with \ordz\ and \ords. Whenever we
% add more \ord\ interpretations to $\Sii{\alpha}$, the next step,
% $\Sii[0]{\alpha+1}$, will contain more functions from (the
% interpretations of) \nat\ to \ord\ with the new ordinals in their
% ranges, so there will be more \ordlim\ ordinals in