-
Notifications
You must be signed in to change notification settings - Fork 0
/
appendix.tex
11701 lines (11121 loc) · 586 KB
/
appendix.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
% !TEX root = omar-thesis.tex
\ificfp\else \part*{Appendix} \fi
\appendix
\chapter{Conventions}
\section{Typographic Conventions}\label{appendix:typographic-conventions}
We adopt \emph{PFPL}'s typographic conventions for operational forms throughout the paper \cite{pfpl}. In particular, the names of operators and indexed families of operators are written in $\texttt{typewriter font}$, indexed families of operators specify indices within $[\text{braces}]$, and term arguments are grouped arbitrarily (roughly, by sort) using \texttt{\{}curly braces\texttt{\}} and \texttt{(}rounded braces\texttt{)}. We write $p.e$ for expressions binding the variables that appear in the pattern $p$.
We write $\mapschema{\tau}{i}{\labelset}$ for a sequence of arguments $\tau_i$, one for each $i\in \labelset$, and similarly for arguments of other valences. Operations that are parameterized by label sets, e.g. $\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}$, are identified up to mutual reordering of the label set and the corresponding argument sequence. Similarly, we write $\mapschema{J}{i}{\labelset}$ for the finite set of derivations $J_i$ for each $i \in \labelset$.
We write $\seqschemaX{r}$ for sequences of $n \geq 0$ rule arguments, and similarly for other finite sequences.
Empty finite sets and finite functions are written $\emptyset$, or omitted entirely within judgements, and non-empty finite sets and finite functions are written as comma-separated sequences identified up to exchange and contraction.
\ificfp
\chapter{\texorpdfstring{A Calculus of Simple TLMs}{A Calculus of Simple TLMs}}
\else
\chapter{\texorpdfstring{$\miniVerseUE$ and $\miniVersePat$}{miniVerseSE and miniVerseS}}
\fi
\label{appendix:miniVerseSES}
\ificfp
This section defines $\miniVersePat$, the calculus of simple expression and pattern TLMs. For some readers, it might be useful to snip out pattern matching to get a language strictly of expression TLMs. To support that, one can omit the segments typeset in gray backgrounds below to recover $\miniVerseUE$, a calculus of simple expression TLMs. We have included the necessary eliminators below (they are technically redundant with pattern matching, but don't hurt things so they're left in white.)
\else
This section defines $\miniVersePat$, the language of Chapter \ref{chap:uptsms}. The language of Chapter \ref{chap:uetsms}, $\miniVerseUE$, can be recovered by omitting the segments typeset in a gray backgrounds below.
\fi
\clearpage
\section{Expanded Language (XL)}\label{appendix:SES-XL}
\subsection{Syntax}
% \begin{figure}[h!]
\[\begin{array}{lllllll}
\textbf{Sort} & &
& \textbf{Operational Form}
% & \textbf{Stylized Form}
& \textbf{Description}\\
\mathsf{Typ} & \tau & ::= & t
%& t
& \text{variable}\\
&&& \aparr{\tau}{\tau}
%& \parr{\tau}{\tau}
& \text{partial function}\\
&&& \aall{t}{\tau}
%& \forallt{t}{\tau}
& \text{polymorphic}\\
&&& \arec{t}{\tau}
%& \rect{t}{\tau}
& \text{recursive}\\
&&& \aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}
%& \prodt{\mapschema{\tau}{i}{\labelset}}
& \text{labeled product}\\
&&& \asum{\labelset}{\mapschema{\tau}{i}{\labelset}}
%& \sumt{\mapschema{\tau}{i}{\labelset}}
& \text{labeled sum}\\
\mathsf{Exp} & e & ::= & x
%& x
& \text{variable}\\
&&& \aelam{\tau}{x}{e}
%& \lam{x}{\tau}{e}
& \text{abstraction}\\
&&& \aeap{e}{e}
%& \ap{e}{e}
& \text{application}\\
&&& \aetlam{t}{e}
%& \Lam{t}{e}
& \text{type abstraction}\\
&&& \aetap{e}{\tau}
%& \App{e}{\tau}
& \text{type application}\\
&&& \aefold{e}
%& \fold{e} : \tau
& \text{fold}\\
&&& \aeunfold{e}
%& \unfold{e}
& \text{unfold}\\
&&& \aetpl{\labelset}{\mapschema{e}{i}{\labelset}}
%& \tpl{\mapschema{e}{i}{\labelset}}
& \text{labeled tuple}\\
&&& \aepr{\ell}{e}
%& \prj{e}{\ell}
& \text{projection}\\
&&& \aein{\ell}{e}
%& \inj{\ell}{e}
& \text{injection}\\
&&& \aecase{\labelset}{e}{\mapschemab{x}{e}{i}{\labelset}}
%& \caseof{e}{\mapschemab{x}{e}{i}{\labelset}}
& \text{case analysis}\\
\LCC \color{light-gray} & \color{light-gray} & \color{light-gray}
% & \color{light-gray}
& \color{light-gray} & \color{light-gray} \\
&&
& \aematchwith{n}{e}{\seqschemaX{r}}
% & \matchwith{e}{\seqschemaX{r}}
& \text{match}\\
\mathsf{Rule} & r & ::=
& \aematchrule{p}{e}
%& \matchrule{p}{e}
& \text{rule}\\
\mathsf{Pat} & p & ::=
& x
%& x
& \text{variable pattern}\\
&&& \aewildp
%& \wildp
& \text{wildcard pattern}\\
&&& \aefoldp{p}
%& \foldp{p}
& \text{fold pattern}\\
&&& \aetplp{\labelset}{\mapschema{p}{i}{\labelset}}
%& \tplp{\mapschema{p}{i}{\labelset}}
& \text{labeled tuple pattern}\\
&&& \aeinjp{\ell}{p}
%& \injp{\ell}{p}
& \text{injection pattern} \ECC
\end{array}\]
% \caption{Syntax of the $\miniVersePat$ expanded language (XL).}
% \end{figure}
\subsection{Statics}
\emph{Type formation contexts}, $\Delta$, are finite sets of hypotheses of the form $\Dhyp{t}$. We write $\Delta, \Dhyp{t}$ when $\Dhyp{t} \notin \Delta$ for $\Delta$ extended with the hypothesis $\Dhyp{t}$. %Finite sets are written as finite sequences identified up to exchange.% We write $\Dcons{\Delta}{\Delta'}$ for the union of $\Delta$ and $\Delta'$.
\emph{Typing contexts}, $\Gamma$, are finite functions that map each variable $x \in \domof{\Gamma}$, where $\domof{\Gamma}$ is a finite set of variables, to the hypothesis $\Ghyp{x}{\tau}$, for some $\tau$. We write $\Gamma, \Ghyp{x}{\tau}$, when $x \notin \domof{\Gamma}$, for the extension of $\Gamma$ with a mapping from $x$ to $\Ghyp{x}{\tau}$, and $\Gcons{\Gamma}{\Gamma'}$ when $\domof{\Gamma} \cap \domof{\Gamma'} = \emptyset$ for the typing context mapping each $x \in \domof{\Gamma} \cup \domof{\Gamma'}$ to $x : \tau$ if $x : \tau \in \Gamma$ or $x : \tau \in \Gamma'$. We write $\isctxU{\Delta}{\Gamma}$ if every type in $\Gamma$ is well-formed relative to $\Delta$.
\begin{definition}[Typing Context Formation] \label{def:isctxU}
$\isctxU{\Delta}{\Gamma}$ iff for each hypothesis $x : \tau \in \Gamma$, we have $\istypeU{\Delta}{\tau}$.
\end{definition}
\noindent\fbox{\strut$\istypeU{\Delta}{\tau}$}~~$\tau$ is a well-formed type
\begin{subequations}\label{rules:istypeU}
\begin{equation}\label{rule:istypeU-var}
\inferrule{ }{\istypeU{\Delta, \Dhyp{t}}{t}}
\end{equation}
\begin{equation}\label{rule:istypeU-parr}
\inferrule{
\istypeU{\Delta}{\tau_1}\\
\istypeU{\Delta}{\tau_2}
}{\istypeU{\Delta}{\aparr{\tau_1}{\tau_2}}}
\end{equation}
\begin{equation}\label{rule:istypeU-all}
\inferrule{
\istypeU{\Delta, \Dhyp{t}}{\tau}
}{
\istypeU{\Delta}{\aall{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:istypeU-rec}
\inferrule{
\istypeU{\Delta, \Dhyp{t}}{\tau}
}{
\istypeU{\Delta}{\arec{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:istypeU-prod}
\inferrule{
\{\istypeU{\Delta}{\tau_i}\}_{i \in \labelset}
}{
\istypeU{\Delta}{\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}}
}
\end{equation}
\begin{equation}\label{rule:istypeU-sum}
\inferrule{
\{\istypeU{\Delta}{\tau_i}\}_{i \in \labelset}
}{
\istypeU{\Delta}{\asum{\labelset}{\mapschema{\tau}{i}{\labelset}}}
}
\end{equation}
\end{subequations}
\noindent\fbox{\strut$\hastypeU{\Delta}{\Gamma}{e}{\tau}$}~~$e$ is assigned type $\tau$
\begin{subequations}\label{rules:hastypeU}\label{rules:hastypeUP}
\begin{equation}\label{rule:hastypeU-var}
\inferrule{ }{
\hastypeU{\Delta}{\Gamma, \Ghyp{x}{\tau}}{x}{\tau}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-lam}
\inferrule{
\istypeU{\Delta}{\tau}\\
\hastypeU{\Delta}{\Gamma, \Ghyp{x}{\tau}}{e}{\tau'}
}{
\hastypeU{\Delta}{\Gamma}{\aelam{\tau}{x}{e}}{\aparr{\tau}{\tau'}}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-ap}
\inferrule{
\hastypeU{\Delta}{\Gamma}{e_1}{\aparr{\tau}{\tau'}}\\
\hastypeU{\Delta}{\Gamma}{e_2}{\tau}
}{
\hastypeU{\Delta}{\Gamma}{\aeap{e_1}{e_2}}{\tau'}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-tlam}
\inferrule{
\hastypeU{\Delta, \Dhyp{t}}{\Gamma}{e}{\tau}
}{
\hastypeU{\Delta}{\Gamma}{\aetlam{t}{e}}{\aall{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-tap}
\inferrule{
\hastypeU{\Delta}{\Gamma}{e}{\aall{t}{\tau}}\\
\istypeU{\Delta}{\tau'}
}{
\hastypeU{\Delta}{\Gamma}{\aetap{e}{\tau'}}{[\tau'/t]\tau}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-fold}
\inferrule{\
% \istypeU{\Delta, \Dhyp{t}}{\tau}\\
\hastypeU{\Delta}{\Gamma}{e}{[\arec{t}{\tau}/t]\tau}
}{
\hastypeU{\Delta}{\Gamma}{\aefold{e}}{\arec{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-unfold}
\inferrule{
\hastypeU{\Delta}{\Gamma}{e}{\arec{t}{\tau}}
}{
\hastypeU{\Delta}{\Gamma}{\aeunfold{e}}{[\arec{t}{\tau}/t]\tau}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-tpl}
\inferrule{
\{\hastypeU{\Delta}{\Gamma}{e_i}{\tau_i}\}_{i \in \labelset}
}{
\hastypeU{\Delta}{\Gamma}{\aetpl{\labelset}{\mapschema{e}{i}{\labelset}}}{\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-pr}
\inferrule{
\hastypeU{\Delta}{\Gamma}{e}{\aprod{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \ell \hookrightarrow \tau}}
}{
\hastypeU{\Delta}{\Gamma}{\aepr{\ell}{e}}{\tau}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-in}
\inferrule{
% \{\istypeU{\Delta}{\tau_i}\}_{i \in \labelset}\\
% \istypeU{\Delta}{\tau}\\
\hastypeU{\Delta}{\Gamma}{e}{\tau}
}{
\hastypeU{\Delta}{\Gamma}{\aein{\ell}{e}}{\asum{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \ell \hookrightarrow \tau}}
}
\end{equation}
\begin{equation}\label{rule:hastypeU-case}
\inferrule{
\hastypeU{\Delta}{\Gamma}{e}{\asum{\labelset}{\mapschema{\tau}{i}{\labelset}}}\\
% \istypeU{\Delta}{\tau}\\
\{\hastypeU{\Delta}{\Gamma, x_i : \tau_i}{e_i}{\tau}\}_{i \in \labelset}
}{
\hastypeU{\Delta}{\Gamma}{\aecase{\labelset}{e}{\mapschemab{x}{e}{i}{\labelset}}}{\tau}
}
\end{equation}
\begin{grayparbox}
\begin{equation}\label{rule:hastypeUP-match}
\graybox{\inferrule{
\hastypeU{\Delta}{\Gamma}{e}{\tau}\\
% \istypeU{\Delta}{\tau'}\\
\{\ruleType{\Delta}{\Gamma}{r_i}{\tau}{\tau'}\}_{1 \leq i \leq n}\\
}{\hastypeU{\Delta}{\Gamma}{\aematchwith{n}{e}{\seqschemaX{r}}}{\tau'}}}
\end{equation}
\end{grayparbox}
\end{subequations}
\vspace{-5px}\begin{grayparbox}
\vspace{5px}\noindent\fcolorbox{black}{light-gray}{\strut$\ruleType{\Delta}{\Gamma}{r}{\tau}{\tau'}$}~~$r$ takes values of type $\tau$ to values of type $\tau'$
\begin{equation}\label{rule:ruleType}
\graybox{\inferrule{
\patType{\pctx'}{p}{\tau}\\
\hastypeU{\Delta}{\Gcons{\Gamma}{\pctx'}}{e}{\tau'}
}{\ruleType{\Delta}{\Gamma}{\aematchrule{p}{e}}{\tau}{\tau'}}}
\end{equation}
Rule (\ref{rule:ruleType}) is defined mutually inductively with Rules (\ref{rules:hastypeUP}).
\noindent\fcolorbox{black}{light-gray}{\strut$\patType{\Gamma}{p}{\tau}$}~~$p$ matches values of type $\tau$ and generates hypotheses $\pctx$
\begin{subequations}\label{rules:patType}
\begin{equation}\label{rule:patType-var}
\graybox{\inferrule{ }{\patType{\Ghyp{x}{\tau}}{x}{\tau}}}
\end{equation}
\begin{equation}\label{rule:patType-wild}
\graybox{\inferrule{ }{\patType{\emptyset}{\aewildp}{\tau}}}
\end{equation}
\begin{equation}\label{rule:patType-fold}
\graybox{\inferrule{
\patType{\pctx}{p}{[\arec{t}{\tau}/t]\tau}
}{
\patType{\pctx}{\aefoldp{p}}{\arec{t}{\tau}}
}}
\end{equation}
\begin{equation}\label{rule:patType-tpl}
\graybox{\inferrule{
\{\patType{\pctx_i}{p_i}{\tau_i}\}_{i \in \labelset}
}{
\patType{\Gconsi{i \in \labelset}{\pctx_i}}{\aetplp{\labelset}{\mapschema{p}{i}{\labelset}}}{\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}}
}}
\end{equation}
\begin{equation}\label{rule:patType-inj}
\graybox{\inferrule{
\patType{\pctx}{p}{\tau}
}{
\patType{\pctx}{\aeinjp{\ell}{p}}{\asum{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \mapitem{\ell}{\tau}}}
}}
\end{equation}
\end{subequations}
\end{grayparbox}
\subsubsection{Metatheory}
The rules above are syntax-directed, so we assume an inversion lemma for each rule as needed without stating it separately or proving it explicitly. The following standard lemmas also hold.
The Weakening Lemma establishes that extending the context with unnecessary hypotheses preserves well-formedness and typing.
\begin{lemma}[Weakening]\label{lemma:weakening-UP}\label{lemma:weakening-U} ~
\begin{enumerate}
\item If $\istypeU{\Delta}{\tau}$ then $\istypeU{\Delta, \Dhyp{t}}{\tau}$.
%\item If $\isctxU{\Delta}{\Gamma}$ then $\isctxU{\Delta, \Dhyp{t}}{\Gamma}$.
\item \begin{enumerate}
\item If $\hastypeU{\Delta}{\Gamma}{e}{\tau}$ then $\hastypeU{\Delta, \Dhyp{t}}{\Gamma}{e}{\tau}$.
\item \graytxtbox{If $\ruleType{\Delta}{\Gamma}{r}{\tau}{\tau'}$ then $\ruleType{\Delta, \Dhyp{t}}{\Gamma}{r}{\tau}{\tau'}$.}
\end{enumerate}
\item \begin{enumerate}
\item If $\hastypeU{\Delta}{\Gamma}{e}{\tau}$ and $\istypeU{\Delta}{\tau''}$ then $\hastypeU{\Delta}{\Gamma, \Ghyp{x}{\tau''}}{e}{\tau}$.
\item \graytxtbox{If $\ruleType{\Delta}{\Gamma}{r}{\tau}{\tau'}$ and $\istypeU{\Delta}{\tau''}$ then $\ruleType{\Delta}{\Gamma, \Ghyp{x}{\tau''}}{r}{\tau}{\tau'}$.}
\end{enumerate}
\item \graytxtbox{If $\patType{\pctx}{p}{\tau}$ then $\patTypeD{\Delta, \Dhyp{t}}{\pctx}{p}{\tau}$.}
\end{enumerate}
\end{lemma}
\begin{proof-sketch} ~
\begin{enumerate}
\item By rule induction over Rules (\ref{rules:istypeU}).
%\item By rule induction over Rules (\ref{rules:isctxU}).
\item By \graytxtbox{mutual} rule induction over Rules (\ref{rules:hastypeUP}) \graytxtbox{and Rule (\ref{rule:ruleType})}, and part 1.
\item By \graytxtbox{mutual} rule induction over Rules (\ref{rules:hastypeUP}) \graytxtbox{and Rule (\ref{rule:ruleType})}, and part 1.
\item \graytxtbox{By rule induction over Rules (\ref{rules:patType}).}
\end{enumerate}
\end{proof-sketch}
\begin{grayparbox}
The {pattern typing judgement} is \emph{linear} in the pattern typing context, i.e. it does \emph{not} obey weakening of the pattern typing context. This is to ensure that the pattern typing context captures exactly those hypotheses generated by a pattern, and no others.
\end{grayparbox}
The Substitution Lemma establishes that substitution of a well-formed type for a type variable, or an expanded expression of the appropriate type for an expanded expression variable, preserves well-formedness and typing.
\begin{lemma}[Substitution]\label{lemma:substitution-UP} ~
\begin{enumerate}
\item If $\istypeU{\Delta, \Dhyp{t}}{\tau}$ and $\istypeU{\Delta}{\tau'}$ then $\istypeU{\Delta}{[\tau'/t]\tau}$.
%\item If $\isctxU{\Delta, \Dhyp{t}}{\Gamma}$ and $\istypeU{\Delta}{\tau'}$ then $\isctxU{\Delta}{[\tau'/t]\Gamma}$.
\item \begin{enumerate}
\item If $\hastypeU{\Delta, \Dhyp{t}}{\Gamma}{e}{\tau}$ and $\istypeU{\Delta}{\tau'}$ then $\hastypeU{\Delta}{[\tau'/t]\Gamma}{[\tau'/t]e}{[\tau'/t]\tau}$.
\item \begin{grayparbox}
{If} $\ruleType{\Delta, \Dhyp{t}}{\Gamma}{r}{\tau}{\tau''}$ and $\istypeU{\Delta}{\tau'}$ then $\ruleType{\Delta}{[\tau'/t]\Gamma}{[\tau'/t]r}{[\tau'/t]\tau}{[\tau'/t]\tau''}$.
\end{grayparbox}
\end{enumerate}
\item \begin{enumerate}
\item If $\hastypeU{\Delta}{\Gamma, \Ghyp{x}{\tau'}}{e}{\tau}$ and $\hastypeU{\Delta}{\Gamma}{e'}{\tau'}$ then $\hastypeU{\Delta}{\Gamma}{[e'/x]e}{\tau}$.
\item \graytxtbox{
If $\ruleType{\Delta}{\Gamma, \Ghyp{x}{\tau'}}{r}{\tau}{\tau''}$ and $\hastypeU{\Delta}{\Gamma}{e'}{\tau''}$ then $\ruleType{\Delta}{\Gamma}{[e'/x]r}{\tau}{\tau''}$.}
\end{enumerate}
\end{enumerate}\end{lemma}
\begin{proof-sketch} ~
\begin{enumerate}
\item By rule induction over Rules (\ref{rules:istypeU}).
\item By \graytxtbox{mutual} rule induction over Rules (\ref{rules:hastypeUP}) \graytxtbox{and Rule (\ref{rule:ruleType})}.
\item By \graytxtbox{mutual} rule induction over Rules (\ref{rules:hastypeUP}) \graytxtbox{and Rule (\ref{rule:ruleType})}.
\end{enumerate}
\end{proof-sketch}
The Decomposition Lemma is the converse of the Substitution Lemma.
\begin{lemma}[Decomposition]\label{lemma:decomposition-UP} ~
\begin{enumerate}
\item If $\istypeU{\Delta}{[\tau'/t]\tau}$ and $\istypeU{\Delta}{\tau'}$ then $\istypeU{\Delta, \Dhyp{t}}{\tau}$.
%\item If $\isctxU{\Delta}{[\tau'/t]\Gamma}$ and $\istypeU{\Delta}{\tau'}$ then $\isctxU{\Delta, \Dhyp{t}}{\Gamma}$.
\item \begin{enumerate}
\item If $\hastypeU{\Delta}{[\tau'/t]\Gamma}{[\tau'/t]e}{[\tau'/t]\tau}$ and $\istypeU{\Delta}{\tau'}$ then $\hastypeU{\Delta, \Dhyp{t}}{\Gamma}{e}{\tau}$.
\item \begin{grayparbox}
If $\ruleType{\Delta}{[\tau'/t]\Gamma}{[\tau'/t]r}{[\tau'/t]\tau}{[\tau'/t]\tau''}$ and $\istypeU{\Delta}{\tau'}$ then $\ruleType{\Delta, \Dhyp{t}}{\Gamma}{r}{\tau}{\tau''}$.
\end{grayparbox}
\end{enumerate}
\item \begin{enumerate}
\item If $\hastypeU{\Delta}{\Gamma}{[e'/x]e}{\tau}$ and $\hastypeU{\Delta}{\Gamma}{e'}{\tau'}$ then $\hastypeU{\Delta}{\Gamma, \Ghyp{x}{\tau'}}{e}{\tau}$.
\item \graytxtbox{If $\ruleType{\Delta}{\Gamma}{[e'/x]r}{\tau}{\tau''}$ and $\hastypeU{\Delta}{\Gamma}{e'}{\tau'}$ then $\ruleType{\Delta}{\Gamma, \Ghyp{x}{\tau'}}{r}{\tau}{\tau''}$.}
\end{enumerate}
\end{enumerate}\end{lemma}
\begin{proof-sketch} ~
\begin{enumerate}
\item By rule induction over Rules (\ref{rules:istypeU}) and case analysis over the definition of substitution. In all cases, the derivation of $\istypeU{\Delta}{[\tau'/t]\tau}$ does not depend on the form of $\tau'$.
%\item Context formation of $[\tau'/t]\Gamma$ does not depend on the structure of $\tau'$.
\item By \graytxtbox{mutual} rule induction over Rules (\ref{rules:hastypeUP}) \graytxtbox{and Rule (\ref{rule:ruleType})} and case analysis over the definition of substitution. In all cases, the derivation of $\hastypeU{\Delta}{[\tau'/t]\Gamma}{[\tau'/t]e}{[\tau'/t]\tau}$ \graytxtbox{or $\ruleType{\Delta}{[\tau'/t]\Gamma}{[\tau'/t]r}{[\tau'/t]\tau}{[\tau'/t]\tau''}$} does not depend on the form of $\tau'$.
\item By \graytxtbox{mutual} rule induction over Rules (\ref{rules:hastypeUP}) \graytxtbox{and Rule (\ref{rule:ruleType})} and case analysis over the definition of substitution. In all cases, the derivation of $\hastypeU{\Delta}{\Gamma}{[e'/x]e}{\tau}$ \graytxtbox{or $\ruleType{\Delta}{\Gamma}{[e'/x]r}{\tau}{\tau''}$} does not depend on the form of $e'$.
\end{enumerate}
\end{proof-sketch}
\begin{grayparbox}
% The Pattern Regularity Lemma establishes that the hypotheses generated by checking a pattern against a well-formed type involve only well-formed types.
\begin{lemma}[Pattern Regularity]\label{lemma:pattern-regularity-UP}
If $\patType{\pctx}{p}{\tau}$ and $\istypeU{\Delta}{\tau}$ then $\isctxU{\Delta}{\pctx}$ and $\mathsf{patvars}({p}) = \domof{\pctx}$.
\end{lemma}
\begin{proof} By rule induction over Rules (\ref{rules:patType}).
\begin{byCases}
\item[\text{(\ref{rule:patType-var})}] ~
\begin{pfsteps*}
\item $p=x$ \BY{assumption}
\item $\pctx=x : \tau$ \BY{assumption}
\item $\istypeU{\Delta}{\tau}$ \BY{assumption}\pflabel{istypeU}
\item $\isctxU{\Delta}{\Ghyp{x}{\tau}}$ \BY{Definition \ref{def:isctxU} on \pfref{istypeU}}
\item $\fvof{p} = \domof{\Gamma} = \{x\}$ \BY{definition}
\end{pfsteps*}
\resetpfcounter
\item[\text{(\ref{rule:patType-wild})}] ~
\begin{pfsteps}
\item p = \aewildp \BY{assumption}
\item \pctx=\emptyset \BY{assumption}
\item \isctxU{\Delta}{\emptyset} \BY{Definition \ref{def:isctxU}}
\item \mathsf{patvars}({p}) = \domof{\Gamma} = \emptyset \BY{definition}
\end{pfsteps}
\resetpfcounter
\item[\text{(\ref{rule:patType-tpl})}] ~
\begin{pfsteps*}
\item $p=\aetplp{\labelset}{\mapschema{p}{i}{\labelset}}$ \BY{assumption}
\item $\tau=\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}$ \BY{assumption}
\item $\pctx=\cup_{i \in \labelset} \pctx_i$ \BY{assumption}
\item $\{\patType{\pctx_i}{p_i}{\tau_i}\}_{i \in \labelset}$ \BY{assumption}\pflabel{patType}
\item $\istypeU{\Delta}{\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}}$ \BY{assumption} \pflabel{istypeU}
\item $\{\istypeU{\Delta}{\tau_i}\}_{i \in \labelset}$ \BY{Inversion of Rule (\ref{rule:istypeU-prod}) on \pfref{istypeU}}\pflabel{istypeU-each}
\item $\{\isctxU{\Delta}{\pctx_i}\}_{i \in \labelset}$ \BY{IH over \pfref{patType} and \pfref{istypeU-each}} \pflabel{biggy}
\item $\{\mathsf{patvars}({p_i}) = \domof{\pctx_i}\}_{i \in \labelset}$ \BY{IH over \pfref{patType} and \pfref{istypeU-each}} \pflabel{biggy2}
\item $\isctxU{\Delta}{\cup_{i \in \labelset} \pctx_i}$ \BY{Definition \ref{def:isctxU} over \pfref{biggy}, then Definition \ref{def:isctxU} iteratively}
\item $\mathsf{patvars}({p}) = \domof{\Gamma} = \emptyset$ \BY{definition and \pfref{biggy2}}
\end{pfsteps*}
\resetpfcounter
\item[\text{(\ref{rule:patType-inj})}] ~
\begin{pfsteps*}
\item $p=\aeinjp{\ell}{p'}$ \BY{assumption}
\item $\tau=\asum{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \mapitem{\ell}{\tau'}}$ \BY{assumption}
\item $\istypeU{\Delta}{\asum{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \mapitem{\ell}{\tau'}}}$ \BY{assumption} \pflabel{istype}
\item $\patType{\pctx}{p'}{\tau'}$ \BY{assumption} \pflabel{patType}
\item $\istypeU{\Delta}{\tau'}$ \BY{Inversion of Rule (\ref{rule:istypeU-sum}) on \pfref{istype}} \pflabel{istypeTwo}
\item $\isctxU{\Delta}{\pctx}$ \BY{IH on \pfref{patType} and \pfref{istypeTwo}}
\item $\mathsf{patvars}({p'}) = \domof{\pctx}$
\BY{IH on \pfref{patType} and \pfref{istypeTwo}} \pflabel{fv1}
\item $\mathsf{patvars}({p}) = \domof{\pctx}$ \BY{definition and \pfref{fv1}}
\end{pfsteps*}
\resetpfcounter
\end{byCases}
\end{proof}
\end{grayparbox}
% Finally, the Regularity Lemma establishes that the type assigned to an expression under a well-formed typing context is well-formed.
% \begin{lemma}[Regularity]\label{lemma:regularity-UP} ~
% \begin{enumerate}
% \item If $\hastypeU{\Delta}{\Gamma}{e}{\tau}$ and $\isctxU{\Delta}{\Gamma}$ then $\istypeU{\Delta}{\tau}$.
% \item \graytxtbox{If $\ruleType{\Delta}{\Gamma}{r}{\tau}{\tau'}$ and $\isctxU{\Delta}{\Gamma}$ then $\istypeU{\Delta}{\tau'}$.}
% \end{enumerate}
% \end{lemma}
% \begin{proof-sketch} By \graytxtbox{mutual} rule induction over Rules (\ref{rules:hastypeUP}) \graytxtbox{and Rule (\ref{rule:ruleType})}, and Lemma \ref{lemma:substitution-UP} \graytxtbox{and Lemma \ref{lemma:pattern-regularity-UP}}.
% \end{proof-sketch}
\subsection{Structural Dynamics}\vspace{-4px}
The \emph{structural dynamics} is specified as a transition system, and is organized around judgements of the following form:
\vspace{-4px}\[\begin{array}{ll}
\textbf{Judgement Form} & \textbf{Description}\\
\stepsU{e}{e'} & \text{$e$ transitions to $e'$}\\
\isvalU{e} & \text{$e$ is a value}\\
\LCC \color{light-gray} & \color{light-gray} \\
\matchfail{e} & \text{$e$ raises match failure} \ECC
\end{array}\]\vspace{-4px}
We also define auxiliary judgements for \emph{iterated transition}, $\multistepU{e}{e'}$, and \emph{evaluation}, $\evalU{e}{e'}$.
\begin{definition}[Iterated Transition]\label{defn:iterated-transition-UP} Iterated transition, $\multistepU{e}{e'}$, is the reflexive, transitive closure of the transition judgement, $\stepsU{e}{e'}$.\end{definition}
\begin{definition}[Evaluation]\label{defn:evaluation-UP} $\evalU{e}{e'}$ iff $\multistepU{e}{e'}$ and $\isvalU{e'}$. \end{definition}
Our subsequent developments do not make mention of particular rules in the dynamics, nor do they make mention of other judgements, not listed above, that are used only for defining the dynamics of the match operator, so we do not produce these details here. Instead, it suffices to state the following conditions.
\begin{condition}[Canonical Forms]\label{condition:canonical-forms-UP} If $\hastypeUC{e}{\tau}$ and $\isvalU{e}$ then:
\begin{enumerate}
\item If $\tau=\aparr{\tau_1}{\tau_2}$ then $e=\aelam{\tau_1}{x}{e'}$ and $\hastypeUCO{\Ghyp{x}{\tau_1}}{e'}{\tau_2}$.
\item If $\tau=\aall{t}{\tau'}$ then $e=\aetlam{t}{e'}$ and $\hastypeUCO{\Dhyp{t}}{e'}{\tau'}$.
\item If $\tau=\arec{t}{\tau'}$ then $e=\aefold{e'}$ and $\hastypeUC{e'}{[\abop{rec}{t.\tau'}/t]\tau'}$ and $\isvalU{e'}$.
\item If $\tau=\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}$ then $e=\aetpl{\labelset}{\mapschema{e}{i}{\labelset}}$ and $\hastypeUC{e_i}{\tau_i}$ and $\isvalU{e_i}$ for each $i \in \labelset$.
\item If $\tau=\asum{\labelset}{\mapschema{\tau}{i}{\labelset}}$ then for some label set $L'$ and label $\ell$ and type $\tau'$, we have that $\labelset=\labelset', \ell$ and $\tau=\asum{\labelset', \ell}{\mapschema{\tau}{i}{\labelset'}; \mapitem{\ell}{\tau'}}$ and $e=\aein{\ell}{e'}$ and $\hastypeUC{e'}{\tau'}$ and $\isvalU{e'}$.
\end{enumerate}\end{condition}
\begin{condition}[Preservation]\label{condition:preservation-UP} If $\hastypeUC{e}{\tau}$ and $\stepsU{e}{e'}$ then $\hastypeUC{e'}{\tau}$. \end{condition}
\begin{condition}[Progress]\label{condition:progress-UP} If $\hastypeUC{e}{\tau}$ then either $\isvalU{e}$ \graytxtbox{or $\matchfail{e}$} or there exists an $e'$ such that $\stepsU{e}{e'}$. \end{condition}
\section{Unexpanded Language (UL)}\label{appendix:SES-uexps}
\subsection{Syntax}\label{appendix:SES-syntax}\label{appendix:SES-shared-forms}
\subsubsection{Stylized Syntax}
\[\begin{array}{lllllll}
\textbf{Sort} & &
%&\textbf{Operational Form}
& \textbf{Stylized Form} & \textbf{Description}\\
\mathsf{UTyp} & \utau & ::=
% &\ut
& \ut & \text{identifier}\\
&&
%& \auparr{\utau}{\utau}
& \parr{\utau}{\utau} & \text{partial function}\\
&&
%& \auall{\ut}{\utau}
& \forallt{\ut}{\utau} & \text{polymorphic}\\
&&
%& \aurec{\ut}{\utau}
& \rect{\ut}{\utau} & \text{recursive}\\
&&
%& \auprod{\labelset}{\mapschema{\utau}{i}{\labelset}}
& \prodt{\mapschema{\utau}{i}{\labelset}} & \text{labeled product}\\
&&
%& \ausum{\labelset}{\mapschema{\utau}{i}{\labelset}}
& \sumt{\mapschema{\utau}{i}{\labelset}} & \text{labeled sum}\\
\mathsf{UExp} & \ue & ::=
%& \ux
& \ux & \text{identifier}\\
&&
%
& \asc{\ue}{\utau} & \text{ascription}\\
&&
%
& \letsyn{\ux}{\ue}{\ue} & \text{value binding}\\
&&
%& \aulam{\utau}{\ux}{\ue}
& \lam{\ux}{\utau}{\ue} & \text{abstraction}\\
&&
%& \auap{\ue}{\ue}
& \ap{\ue}{\ue} & \text{application}\\
&&
%& \autlam{\ut}{\ue}
& \Lam{\ut}{\ue} & \text{type abstraction}\\
&&
%& \autap{\ue}{\utau}
& \App{\ue}{\utau} & \text{type application}\\
&&
%& \aufold{\ut}{\utau}{\ue}
& \fold{\ue} & \text{fold}\\
&&
%& \auunfold{\ue}
& \unfold{\ue} & \text{unfold}\\
&&
%& \autpl{\labelset}{\mapschema{\ue}{i}{\labelset}}
& \tpl{\mapschema{\ue}{i}{\labelset}} & \text{labeled tuple}\\
&&
%& \aupr{\ell}{\ue}
& \prj{\ue}{\ell} & \text{projection}\\
&&
%& \auin{\labelset}{\ell}{\mapschema{\utau}{i}{\labelset}}{\ue}
& \inj{\ell}{\ue} & \text{injection}\\
&&
%& \aucase{\labelset}{\utau}{\ue}{\mapschemab{\ux}{\ue}{i}{\labelset}}
& \caseof{\ue}{\mapschemab{\ux}{\ue}{i}{\labelset}} & \text{case analysis}\\
&&
%& \audefuetsm{\utau}{e}{\tsmv}{\ue}
& \uesyntax{\tsmv}{\utau}{e}{\ue} & \text{seTLM definition}\\
&&
%& \autsmap{b}{\tsmv}
& \utsmap{\tsmv}{b} & \text{seTLM application}\\%\ECC
\LCC \color{light-gray} & \color{light-gray} & \color{light-gray}
& \color{light-gray}
& \color{light-gray} & \color{light-gray} \\
&&
%& \aumatchwith{n}{\utau}{\ue}{\seqschemaX{\urv}}
& \matchwith{\ue}{\seqschemaX{\urv}} & \text{match}\\
&&
%& \audefuptsm{\utau}{e}{\tsmv}{\ue}
& \usyntaxup{\tsmv}{\utau}{e}{\ue}
& \text{spTLM definition}\\
\mathsf{URule} & \urv & ::=
%& \aumatchrule{\upv}{\ue}
& \matchrule{\upv}{\ue} & \text{match rule}\\
\mathsf{UPat} & \upv & ::=
%& \ux
& \ux & \text{identifier pattern}\\
&&
%& \auwildp
& \wildp & \text{wildcard pattern}\\
&&
%& \aufoldp{\upv}
& \foldp{\upv} & \text{fold pattern}\\
&&
%& \autplp{\labelset}{\mapschema{\upv}{i}{\labelset}}
& \tplp{\mapschema{\upv}{i}{\labelset}} & \text{labeled tuple pattern}\\
&&
%& \auinjp{\ell}{\upv}
& \injp{\ell}{\upv} & \text{injection pattern}\\
% \LCC &&& \color{light-gray} & \color{light-gray} & \color{light-gray}\\
&&
%& \auapuptsm{b}{\tsmv}
& \utsmap{\tsmv}{b} & \text{spTLM application}\ECC
\end{array}\]
\clearpage
\paragraph{Body Lengths}\label{appendix:SES-body-lengths}
We write $\sizeof{b}$ for the length of $b$. The metafunction $\sizeof{\ue}$ computes the sum of the lengths of expression literal bodies in $\ue$:
\[
\begin{array}{ll}
\sizeof{\ux} & = 0\\
\sizeof{\asc{\ue}{\utau}} & = \sizeof{\ue}\\
\sizeof{\letsyn{\ux}{\ue_1}{\ue_2}} & = \sizeof{\ue_1} + \sizeof{\ue_2}\\
\sizeof{\lam{\ux}{\utau}{\ue}} &= \sizeof{\ue}\\
\sizeof{\ap{\ue_1}{\ue_2}} & = \sizeof{\ue_1} + \sizeof{\ue_2}\\
\sizeof{\Lam{\ut}{\ue}} & = \sizeof{\ue}\\
\sizeof{\App{\ue}{\utau}} & = \sizeof{\ue}\\
\sizeof{\fold{\ue}} & = \sizeof{\ue}\\
\sizeof{\unfold{\ue}} & = \sizeof{\ue}\\
%\end{align*}
%\begin{align*}
\sizeof{\tpl{\mapschema{\ue}{i}{\labelset}}} & = \sum_{i \in \labelset} \sizeof{\ue_i}\\
\sizeof{\prj{\ell}{\ue}} & = \sizeof{\ue}\\
\sizeof{\inj{\ell}{\ue}} & = \sizeof{\ue}\\
\sizeof{\caseof{\ue}{\mapschemab{\ux}{\ue}{i}{\labelset}}} & = \sizeof{\ue} + \sum_{i \in \labelset} \sizeof{\ue_i}\\
\sizeof{\uesyntax{\tsmv}{\utau}{\eparse}{\ue}} & = \sizeof{\ue}\\
\sizeof{\utsmap{\tsmv}{b}} & = \sizeof{b}\\
\LCC \color{light-gray} & \color{light-gray}\\
\sizeof{\matchwith{\ue}{\seqschemaX{\urv}}} & = \sizeof{\ue} + \sum_{1 \leq i \leq n} \sizeof{r_i}\\
\sizeof{\usyntaxup{\tsmv}{\utau}{\eparse}{\ue}} & = \sizeof{\ue}\ECC
\end{array}
\]
\vspace{-3px}\begin{grayparbox}\vspace{3px}and $\sizeof{\urv}$ computes the sum of the lengths of expression literal bodies in $\urv$:
\begin{align*}
\sizeof{\matchrule{\upv}{\ue}} & = \sizeof{\ue}
\end{align*}
Similarly, the metafunction $\sizeof{\upv}$ computes the sum of the lengths of the pattern literal bodies in $\upv$:
\begin{align*}
\sizeof{\ux} & = 0\\
\sizeof{\foldp{\upv}} & = \sizeof{\upv}\\
\sizeof{\tplp{\mapschema{\upv}{i}{\labelset}}} & = \sum_{i \in \labelset} \sizeof{\upv_i}\\
\sizeof{\injp{\ell}{\upv}} & = \sizeof{\upv}\\
\sizeof{\utsmap{\tsmv}{b}} & = \sizeof{b}
\end{align*}
\end{grayparbox}
\paragraph{Common Unexpanded Forms} Each expanded form maps onto an unexpanded form. We refer to these as the \emph{common forms}. In particular:
\begin{itemize}
\item Each type variable, $t$, maps onto a unique {type identifier}, written $\sigilof{t}$.
\item Each type, $\tau$, maps onto an unexpanded type, $\Uof{\tau}$, as follows:
\begin{align*}
\Uof{t} &= \sigilof{t}\\
\Uof{\aparr{\tau_1}{\tau_2}} & = \parr{\Uof{\tau_1}}{\Uof{\tau_2}}\\
\Uof{\aall{t}{\tau}} & = \forallt{\sigilof{t}}{\Uof{\tau}}\\
\Uof{\arec{t}{\tau}} & = \rect{\sigilof{t}}{\Uof{\tau}}\\
\Uof{\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}} & = \prodt{\mapschemax{\Uofv}{\tau}{i}{\labelset}}\\
\Uof{\asum{\labelset}{\mapschema{\tau}{i}{\labelset}}} & = \sumt{\mapschemax{\Uofv}{\tau}{i}{\labelset}}
\end{align*}
\item Each expression variable, $x$, maps onto a unique expression identifier, written $\sigilof{x}$.
\item Each expanded expression, $e$, maps onto an unexpanded expression, $\Uof{e}$, as follows:
\[\arraycolsep=1pt\begin{array}{rl}
\Uof{x} & = \sigilof{x}\\
\Uof{\aelam{\tau}{x}{e}} & = \lam{\sigilof{x}}{\Uof{\tau}}{\Uof{e}}\\
\Uof{\aeap{e_1}{e_2}} & = \ap{\Uof{e_1}}{\Uof{e_2}}\\
\Uof{\aetlam{t}{e}} & = \Lam{\sigilof{t}}{\Uof{e}}\\
\Uof{\aetap{e}{\tau}} & = \App{\Uof{e}}{\Uof{\tau}}\\
\Uof{\aefold{e}} & = \fold{\Uof e}\\
\Uof{\aeunfold{e}} & = \unfold{\Uof{e}}\\
\Uof{\aetpl{\labelset}{\mapschema{e}{i}{\labelset}}} & = \tpl{\mapschemax{\Uofv}{e}{i}{\labelset}}\\
\Uof{\aepr{\ell}{e}} & = \prj{\Uof{e}}{\ell}\\
\Uof{\aein{\ell}{e}} &= \inj{\ell}{\Uof{e}}\\
\LCC \color{light-gray} & \color{light-gray} \\
\Uof{\aematchwith{n}{e}{\seqschemaX{r}}} & = \matchwith{\Uof{e}}{\seqschemaXx{\Uofv}{r}}\ECC
\end{array}\]
\end{itemize}
\begin{grayparbox}
\begin{itemize}
\item Each expanded rule, $r$, maps onto an unexpanded rule, $\Uof{r}$, as follows:
\[\arraycolsep=1pt\begin{array}{rl}
\LCC \color{light-gray} & \color{light-gray} \\
\Uof{\aematchrule{p}{e}} & = \aumatchrule{\Uof{p}}{\Uof{e}}\ECC
\end{array}\]
\item Each expanded pattern, $p$, maps onto the unexpanded pattern, $\Uof{p}$, as follows:
\[\arraycolsep=1pt\begin{array}{rl}
\LCC \color{light-gray} & \color{light-gray} \\
\Uof{x} & = \sigilof{x}\\
\Uof{\aewildp} &= \auwildp\\
\Uof{\aefoldp{p}} &= \aufoldp{\Uof{p}}\\
\Uof{\aetplp{\labelset}{\mapschema{p}{i}{\labelset}}} & = \autplp{\labelset}{\mapschemax{\Uofv}{p}{i}{\labelset}}\\
\Uof{\aeinjp{\ell}{p}} & = \auinjp{\ell}{\Uof{p}}\ECC
\end{array}\]
\end{itemize}
\end{grayparbox}
\vspace{-10px}
\subsubsection{Textual Syntax}\vspace{-3px} In addition to the stylized syntax, there is also a context-free textual syntax for the UL. For our purposes, we need only posit the existence of partial metafunctions $\parseUTypF{b}$ and $\parseUExpF{b}$\graytxtbox{~and $\parseUPatF{b}$}.
\begin{condition}[Textual Representability]\label{condition:textual-representability-SES} ~
\begin{enumerate}
\item For each $\utau$, there exists $b$ such that $\parseUTyp{b}{\utau}$.
\item For each $\ue$, there exists $b$ such that $\parseUExp{b}{\ue}$.
% \item For each $\urv$, there exists $b$ such that $\parseURule{b}{\urv}$.
\item \graytxtbox{For each $\upv$, there exists $b$ such that $\parseUPat{b}{\upv}$.}
\end{enumerate}
\end{condition}
We also impose the following technical condition\graytxtbox{s}.
\begin{condition}[Expression Parsing Monotonicity]\label{condition:body-parsing} If $\parseUExp{b}{\ue}$ then $\sizeof{\ue} < \sizeof{b}$.\end{condition}
\begin{grayparbox}\begin{condition}[Pattern Parsing Monotonicity]\label{condition:pattern-parsing} If $\parseUPat{b}{\upv}$ then $\sizeof{\upv} < \sizeof{b}$.\end{condition}\end{grayparbox}
\subsection{Type Expansion}
\emph{Unexpanded type formation contexts}, $\uDelta$, are of the form $\uDD{\uD}{\Delta}$, i.e. they consist of a \emph{type identifier expansion context}, $\uD$, paired with a type formation context, $\Delta$.
A \emph{type identifier expansion context}, $\uD$, is a finite function that maps each type identifier $\ut \in \domof{\uD}$ to the hypothesis $\vExpands{\ut}{t}$, for some type variable $t$. We write $\ctxUpdate{\uD}{\ut}{t}$ for the type identifier expansion context that maps $\ut$ to $\vExpands{\ut}{t}$ and defers to $\uD$ for all other type identifiers (i.e. the previous mapping is \emph{updated}.)
We define $\uDelta, \uDhyp{\ut}{t}$ when $\uDelta=\uDD{\uD}{\Delta}$ as an abbreviation of \[\uDD{\ctxUpdate{\uD}{\ut}{t}}{\Delta, \Dhyp{t}}\]%type identifier expansion context is always extended/updated together with
\begin{definition}[Unexpanded Type Formation Context Formation] $\uDOK{\uDD{\uD}{\Delta}}$ iff for each $\uDhyp{\ut}{t} \in \uD$ we have $\Dhyp{t} \in \Delta$. \end{definition}
\vspace{10px}\noindent\fbox{\strut$\expandsTU{\uDelta}{\utau}{\tau}$}~~$\utau$ has well-formed expansion $\tau$
\begin{subequations}\label{rules:expandsTU}
\begin{equation}\label{rule:expandsTU-var}
\inferrule{ }{\expandsTU{\uDelta, \uDhyp{\ut}{t}}{\ut}{t}}
\end{equation}
\begin{equation}\label{rule:expandsTU-parr}
\inferrule{
\expandsTU{\uDelta}{\utau_1}{\tau_1}\\
\expandsTU{\uDelta}{\utau_2}{\tau_2}
}{\expandsTU{\uDelta}{\auparr{\utau_1}{\utau_2}}{\aparr{\tau_1}{\tau_2}}}
\end{equation}
\begin{equation}\label{rule:expandsTU-all}
\inferrule{
\expandsTU{\uDelta, \uDhyp{\ut}{t}}{\utau}{\tau}
}{
\expandsTU{\uDelta}{\auall{\ut}{\utau}}{\aall{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:expandsTU-rec}
\inferrule{
\expandsTU{\uDelta, \uDhyp{\ut}{t}}{\utau}{\tau}
}{
\expandsTU{\uDelta}{\aurec{\ut}{\utau}}{\arec{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:expandsTU-prod}
\inferrule{
\{\expandsTU{\uDelta}{\utau_i}{\tau_i}\}_{i \in \labelset}
}{
\expandsTU{\uDelta}{\auprod{\labelset}{\mapschema{\utau}{i}{\labelset}}}{\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}}
}
\end{equation}
\begin{equation}\label{rule:expandsTU-sum}
\inferrule{
\{\expandsTU{\uDelta}{\utau_i}{\tau_i}\}_{i \in \labelset}
}{
\expandsTU{\uDelta}{\ausum{\labelset}{\mapschema{\utau}{i}{\labelset}}}{\asum{\labelset}{\mapschema{\tau}{i}{\labelset}}}
}
\end{equation}
\end{subequations}
% \emph{Unexpanded type formation contexts}, $\uDelta$, are of the form $\uDD{\uD}{\Delta}$, where $\uD$ is a \emph{type identifier expansion context}, and $\Delta$ is a type formation context. A type identifier expansion context, $\uD$, is a finite function that maps each type identifier $\ut \in \domof{\uD}$ to the hypothesis $\vExpands{\ut}{t}$, for some type variable $t$. We write $\ctxUpdate{\uD}{\ut}{t}$ for the type identifier expansion context that maps $\ut$ to $\vExpands{\ut}{t}$ and defers to $\uD$ for all other type identifiers (i.e. the previous mapping, if it exists, is updated).
% We define $\uDelta, \uDhyp{\ut}{t}$ when $\uDelta=\uDD{\uD}{\Delta}$ as an abbreviation of \[\uDD{\ctxUpdate{\uD}{\ut}{t}}{\Delta, \Dhyp{t}}\]%type identifier expansion context is always extended/updated together with
% %We write $\uDeltaOK{\uDelta}$ when $\uDelta=\uDD{\uD}{\Delta}$ and each type variable in $\uD$ also appears in $\Delta$.
% %\begin{definition}\label{def:uDeltaOK} $\uDeltaOK{\uDD{\uD}{\Delta}}$ iff for each $\vExpands{\ut}{t} \in \uD$, we have $\Dhyp{t} \in \Delta$.\end{definition}
\subsection{Typed Expression Expansion}\label{appendix:typed-expression-expansion-S}
\subsubsection{Contexts}
\emph{Unexpanded typing contexts}, $\uGamma$, are, similarly, of the form $\uGG{\uG}{\Gamma}$, where $\uG$ is an \emph{expression identifier expansion context}, and $\Gamma$ is a typing context. An expression identifier expansion context, $\uG$, is a finite function that maps each expression identifier $\ux \in \domof{\uG}$ to the hypothesis $\vExpands{\ux}{x}$, for some expression variable, $x$. We write $\ctxUpdate{\uG}{\ux}{x}$ for the expression identifier expansion context that maps $\ux$ to $\vExpands{\ux}{x}$ and defers to $\uG$ for all other expression identifiers (i.e. the previous mapping is updated.)
%We write $\uGammaOK{\uGamma}$ when $\uGamma=\uGG{\uG}{\Gamma}$ and each expression variable in $\uG$ is assigned a type by $\Gamma$.
%\noindent
We define $\uGamma, \uGhyp{\ux}{x}{\tau}$ when $\uGamma = \uGG{\uG}{\Gamma}$ as an abbreviation of \[\uGG{\ctxUpdate{\uG}{\ux}{x}}{\Gamma, \Ghyp{x}{\tau}}\]
\begin{definition}[Unexpanded Typing Context Formation] $\uGammaOK{\uGG{\uG}{\Gamma}}$ iff $\isctxU{\Delta}{\Gamma}$ and for each $\vExpands{\ux}{x} \in \uG$, we have $x \in \domof{\Gamma}$.\end{definition}
\subsubsection{Body Encoding and Decoding}
An assumed type abbreviated $\tBody$ classifies encodings of literal bodies, $b$. The mapping from literal bodies to values of type $\tBody$ is defined by the \emph{body encoding judgement} $\encodeBody{b}{\ebody}$. An inverse mapping is defined by the \emph{body decoding judgement} $\decodeBody{\ebody}{b}$.
\[\begin{array}{ll}
\textbf{Judgement Form} & \textbf{Description}\\
\encodeBody{b}{e} & \text{$b$ has encoding $e$}\\
\decodeBody{e}{b} & \text{$e$ has decoding $b$}
\end{array}\]
The following condition establishes an isomorphism between literal bodies and values of type $\tBody$ mediated by the judgements above.
\begin{condition}[Body Isomorphism]\label{condition:body-isomorphism} ~
\begin{enumerate}
\item For every literal body $b$, we have that $\encodeBody{b}{\ebody}$ for some $\ebody$ such that $\hastypeUC{\ebody}{\tBody}$ and $\isvalU{\ebody}$.
\item If $\hastypeUC{\ebody}{\tBody}$ and $\isvalU{\ebody}$ then $\decodeBody{\ebody}{b}$ for some $b$.
\item If $\encodeBody{b}{\ebody}$ then $\decodeBody{\ebody}{b}$.
\item If $\hastypeUC{\ebody}{\tBody}$ and $\isvalU{\ebody}$ and $\decodeBody{\ebody}{b}$ then $\encodeBody{b}{\ebody}$.
\item If $\encodeBody{b}{\ebody}$ and $\encodeBody{b}{\ebody'}$ then $\ebody = \ebody'$.
\item If $\hastypeUC{\ebody}{\tBody}$ and $\isvalU{\ebody}$ and $\decodeBody{\ebody}{b}$ and $\decodeBody{\ebody}{b'}$ then $b=b'$.
\end{enumerate}
\end{condition}
We also assume a partial metafunction, $\bsubseq{b}{m}{n}$, which extracts a subsequence of $b$ starting at position $m$ and ending at position $n$, inclusive, where $m$ and $n$ are natural numbers. The following condition is technically necessary.
\begin{condition}[Body Subsequencing]\label{condition:body-subsequences} If $\bsubseq{b}{m}{n}=b'$ then $\sizeof{b'} \leq \sizeof{b}$. \end{condition}
\subsubsection{Parse Results}
The type abbreviated $\tParseResultExp$, and an auxiliary abbreviation used below, is defined as follows:
\begin{align*}
L_\mathtt{SE} & \defeq \lbltxt{ParseError}, \lbltxt{SuccessE}\\
\tParseResultExp & \defeq \asum{L_\mathtt{SE}}{
\mapitem{\lbltxt{ParseError}}{\prodt{}},
\mapitem{\lbltxt{SuccessE}}{\tCEExp}
}\\
\end{align*} %[\mapitem{\lbltxt{ParseError}}{\prodt{}}, \mapitem{\lbltxt{SuccessE}}{\tCEExp}]
\begin{grayparbox}
The type abbreviated $\tParseResultPat$, and an auxiliary abbreviation used below, is defined as follows:
\begin{align*}
L_\mathtt{SP} & \defeq \lbltxt{ParseError}, \lbltxt{SuccessP}\\
\tParseResultExp & \defeq \asum{L_\mathtt{SP}}{
\mapitem{\lbltxt{ParseError}}{\prodt{}},
\mapitem{\lbltxt{SuccessP}}{\tCEPat}
}\\
\end{align*} %[\mapitem{\lbltxt{ParseError}}{\prodt{}}, \mapitem{\lbltxt{SuccessE}}{\tCEExp}]
\end{grayparbox}
\subsubsection{seTLM Contexts}
\emph{seTLM contexts}, $\uPsi$, are of the form $\uAS{\uA}{\Psi}$, where $\uA$ is a \emph{TLM identifier expansion context} and $\Psi$ is a \emph{seTLM definition context}.
A \emph{TLM identifier expansion context}, $\uA$, is a finite function mapping each TLM identifier $\tsmv \in \domof{\uA}$ to the \emph{TLM identifier expansion}, $\vExpands{\tsmv}{a}$, for some \emph{TLM name}, $a$. We write $\ctxUpdate{\uA}{\tsmv}{a}$ for the TLM identifier expansion context that maps $\tsmv$ to $\vExpands{\tsmv}{a}$, and defers to $\uA$ for all other TLM identifiers (i.e. the previous mapping is \emph{updated}.)
An \emph{seTLM definition context}, $\Psi$, is a finite function mapping each TLM name $a \in \domof{\Psi}$ to an \emph{expanded seTLM definition}, $\xuetsmbnd{a}{\tau}{\eparse}$, where $\tau$ is the seTLM's type annotation, and $\eparse$ is its parse function. We write $\Psi, \xuetsmbnd{a}{\tau}{\eparse}$ when $a \notin \domof{\Psi}$ for the extension of $\Psi$ that maps $a$ to $\xuetsmbnd{a}{\tau}{\eparse}$. We write $\uetsmenv{\Delta}{\Psi}$ when all the type annotations in $\Psi$ are well-formed assuming $\Delta$, and the parse functions in $\Psi$ are closed and of the appropriate type.
\begin{definition}[seTLM Definition Context Formation]\label{def:seTLM-def-ctx-formation} $\uetsmenv{\Delta}{\Psi}$ iff for each $\xuetsmbnd{a}{\tau}{\eparse} \in \Psi$, we have $\istypeU{\Delta}{\tau}$ and $\hastypeU{\emptyset}{\emptyset}{\eparse}{\aparr{\tBody}{\tParseResultExp}}$.\end{definition}
\begin{definition}[seTLM Context Formation] $\uetsmctx{\Delta}{\uAS{\uA}{\Psi}}$ iff $\uetsmenv{\Delta}{\Psi}$ and for each $\vExpands{\tsmv}{a} \in \uA$ we have $a \in \domof{\Psi}$.
\end{definition}
We define $\uPsi, \uShyp{\tsmv}{a}{\tau}{\eparse}$, when $\uPsi=\uAS{\uA}{\Phi}$, as an abbreviation of \[\uAS{\ctxUpdate{\uA}{\tsmv}{a}}{\Psi, \xuetsmbnd{a}{\tau}{\eparse}}\]
%\vspace{10px}
\begin{grayparbox}\vspace{-15px}\subsubsection{spTLM Contexts}
\emph{spTLM contexts}, $\uPhi$, are of the form $\uAS{\uA}{\Phi}$, where $\uA$ is a {TLM identifier expansion context}, defined above, and $\Phi$ is a \emph{spTLM definition context}.
An \emph{spTLM definition context}, $\Phi$, is a finite function mapping each TLM name $a \in \domof{\Phi}$ to an \emph{expanded seTLM definition}, $\xuptsmbnd{a}{\tau}{\eparse}$, where $\tau$ is the spTLM's type annotation, and $\eparse$ is its parse function. We write $\Phi, \xuptsmbnd{a}{\tau}{\eparse}$ when $a \notin \domof{\Phi}$ for the extension of $\Phi$ that maps $a$ to $\xuptsmbnd{a}{\tau}{\eparse}$. We write $\uptsmenv{\Delta}{\Phi}$ when all the type annotations in $\Phi$ are well-formed assuming $\Delta$, and the parse functions in $\Phi$ are closed and of the appropriate type.
\begin{definition}[spTLM Definition Context Formation]\label{def:spTLM-def-ctx-formation} $\uptsmenv{\Delta}{\Phi}$ iff for each $\xuptsmbnd{a}{\tau}{\eparse} \in \Phi$, we have $\istypeU{\Delta}{\tau}$ and $\hastypeU{\emptyset}{\emptyset}{\eparse}{\aparr{\tBody}{\tParseResultPat}}$.\end{definition}
\begin{definition}[spTLM Context Formation] $\uptsmctx{\Delta}{\uAS{\uA}{\Phi}}$ iff $\uptsmenv{\Delta}{\Phi}$ and for each $\vExpands{\tsmv}{a} \in \uA$ we have $a \in \domof{\Phi}$.
\end{definition}
We define $\uPhi, \uPhyp{\tsmv}{a}{\tau}{\eparse}$, when $\uPhi=\uAS{\uA}{\Phi}$, as an abbreviation of \[\uAS{\ctxUpdate{\uA}{\tsmv}{a}}{\Phi, \xuptsmbnd{a}{\tau}{\eparse}}\]
\end{grayparbox}
\subsubsection{Typed Expression Expansion}\label{appendix:typed-expression-expansion-SES}
\vspace{8px}\noindent\fbox{\strut$\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\tau}$}~~$\ue$ has expansion $e$ of type $\tau$
\begin{subequations}\label{rules:expandsU}
\begin{equation}\label{rule:expandsU-var}
\inferrule{ }{
\expandsSG{\uDelta}{\uGamma, \uGhyp{\ux}{x}{\tau}}{\uPsi}{\uPhi}{\ux}{x}{\tau}
}
\end{equation}
\begin{equation}\label{rule:expandsU-asc}
\inferrule{
\expandsTU{\uDelta}{\utau}{\tau}\\
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\tau}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\asc{\ue}{\utau}}{e}{\tau}
}
\end{equation}
\begin{equation}\label{rule:expandsU-letsyn}
\inferrule{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue_1}{e_1}{\tau_1}\\
\expandsSG{\uDelta}{\uGamma, \uGhyp{\ux}{x}{\tau_1}}{\uPsi}{\uPhi}{\ue_2}{e_2}{\tau_2}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\letsyn{\ux}{\ue_1}{\ue_2}}{
\aeap{\aelam{\tau_1}{x}{e_2}}{e_1}
}{\tau_2}
}
\end{equation}
\begin{equation}\label{rule:expandsU-lam}
\inferrule{
\expandsTU{\uDelta}{\utau}{\tau}\\
\expandsSG{\uDelta}{\uGamma, \uGhyp{\ux}{x}{\tau}}{\uPsi}{\uPhi}{\ue}{e}{\tau'}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\lam{\ux}{\utau}{\ue}}{\aelam{\tau}{x}{e}}{\aparr{\tau}{\tau'}}
}
\end{equation}
\begin{equation}\label{rule:expandsU-ap}
\inferrule{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue_1}{e_1}{\aparr{\tau}{\tau'}}\\
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue_2}{e_2}{\tau}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ap{\ue_1}{\ue_2}}{\aeap{e_1}{e_2}}{\tau'}
}
\end{equation}
\begin{equation}\label{rule:expandsU-tlam}
\inferrule{
\expandsSG{\uDelta, \uDhyp{\ut}{t}}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\tau}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\Lam{\ut}{\ue}}{\aetlam{t}{e}}{\aall{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:expandsU-tap}
\inferrule{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\aall{t}{\tau}}\\
\expandsTU{\uDelta}{\utau'}{\tau'}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\App{\ue}{\utau'}}{\aetap{e}{\tau'}}{[\tau'/t]\tau}
}
\end{equation}
\begin{equation}\label{rule:expandsU-fold}
\inferrule{
% \istypeU{\Delta, \Dhyp{t}}{\tau}\\
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{[\arec{t}{\tau}/t]\tau}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\fold{\ue}}{\aefold{e}}{\arec{t}{\tau}}
}
\end{equation}
\begin{equation}\label{rule:expandsU-unfold}
\inferrule{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\arec{t}{\tau}}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\unfold{\ue}}{\aeunfold{e}}{[\arec{t}{\tau}/t]\tau}
}
\end{equation}
\begin{equation}\label{rule:expandsU-tpl}
\inferrule{
\{\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue_i}{e_i}{\tau_i}\}_{i \in \labelset}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\tpl{\mapschema{\ue}{i}{\labelset}}}{\aetpl{\labelset}{\mapschema{e}{i}{\labelset}}}{\aprod{\labelset}{\mapschema{\tau}{i}{\labelset}}}
}
\end{equation}
\begin{equation}\label{rule:expandsU-pr}
\inferrule{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\aprod{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \ell \hookrightarrow \tau}}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\prj{\ue}{\ell}}{\aepr{\ell}{e}}{\tau}
}
\end{equation}
\begin{equation}\label{rule:expandsU-in}
\inferrule{
% \{\istypeU{\Delta}{\tau_i}\}_{i \in \labelset}\\
% \istypeU{\Delta}{\tau'}\\
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\tau'}
}{
% \left(\shortstack{
% $\uDelta~\uGamma~{\vdash_{\uPhi}}{\setlength{\fboxsep}{0px}\colorbox{light-gray}{$_{\mathstrut; \uPsi}$}}~ \inj{\ell}{\ue}$\\
% $\leadsto$\\
% $\aein{\ell}{e} : \asum{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \ell \hookrightarrow \tau}$\vspace{-1.2em}}\right)
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\inj{\ell}{\ue}}{\aein{\ell}{e}}{\asum{\labelset, \ell}{\mapschema{\tau}{i}{\labelset}; \ell \hookrightarrow \tau'}}
}
\end{equation}
\begin{equation}\label{rule:expandsU-case}
\inferrule{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\asum{\labelset}{\mapschema{\tau}{i}{\labelset}}}\\
% \istypeU{\Delta}{\tau}\\
\{\expandsSG{\uDelta}{\uGamma, \uGhyp{\ux_i}{x_i}{\tau_i}}{\uPsi}{\uPhi}{\ue_i}{e_i}{\tau}\}_{i \in \labelset}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\caseof{\ue}{\mapschemab{\ux}{\ue}{i}{\labelset}}}{\aecase{\labelset}{e}{\mapschemab{x}{e}{i}{\labelset}}}{\tau}
}
\end{equation}
\begin{equation}\label{rule:expandsU-syntax}
\inferrule{
\expandsTU{\uDelta}{\utau}{\tau}\\
\hastypeU{\emptyset}{\emptyset}{\eparse}{\aparr{\tBody}{\tParseResultExp}}\\\\
\evalU{\eparse}{\eparse'}\\
\expandsU{\uDelta}{\uGamma}{\uPsi, \uShyp{\tsmv}{a}{\tau}{\eparse'}}{\ue}{e}{\tau'}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\uesyntax{\tsmv}{\utau}{\eparse}{\ue}}{e}{\tau'}
}
\end{equation}
\begin{equation}\label{rule:expandsU-tsmap}
\inferrule{
\uPsi = \uPsi', \uShyp{\tsmv}{a}{\tau}{\eparse}\\\\
\encodeBody{b}{\ebody}\\
\evalU{\ap{\eparse}{\ebody}}{\aein{\mathtt{SuccessE}}{\ecand}}\\
\decodeCondE{\ecand}{\ce}\\\\
\segOK{\segof{\ce}}{b}\\
\cvalidE{\emptyset}{\emptyset}{\esceneSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{b}}{\ce}{e}{\tau}
}{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\utsmap{\tsmv}{b}}{e}{\tau}
}
\end{equation}
\begin{grayparbox}
\begin{equation}\label{rule:expandsU-match}
\inferrule{
\expandsSG{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\ue}{e}{\tau}\\
% \istypeU{\Delta}{\tau'}\\
\{\ruleExpands{\uDelta}{\uGamma}{\uPsi}{\uPhi}{\urv_i}{r_i}{\tau}{\tau'}\}_{1 \leq i \leq n}\\
}{
\expandsSG
{\uDelta}{\uGamma}{\uPsi}{\uPhi}
{\matchwith
{\ue}
{\seqschemaX{\urv}}
}{\aematchwith
{n}
{e}
{\seqschemaX{r}}
}{\tau'}
}
\end{equation}
\begin{equation}\label{rule:expandsU-defuptsm}
\graybox{\inferrule{
\expandsTU{\uDelta}{\utau}{\tau}\\
\hastypeU{\emptyset}{\emptyset}{\eparse}{\aparr{\tBody}{\tParseResultPat}}\\\\
\evalU{\eparse}{\eparse'}\\
\expandsUP{\uDelta}{\uGamma}{\uPsi}{\uPhi, \uPhyp{\tsmv}{a}{\tau}{\eparse'}}{\ue}{e}{\tau'}
}{
\expandsUPX{\usyntaxup{\tsmv}{\utau}{\eparse}{\ue}}{e}{\tau'}
}}
\end{equation}
\end{grayparbox}
\end{subequations}