-
Notifications
You must be signed in to change notification settings - Fork 6
/
statmod.tex
2425 lines (2159 loc) · 89.8 KB
/
statmod.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
\section{Static Semantics for Modules}
\label{statmod-sec}
\subsection{Semantic Objects}
\label{statmod-sem-obj-sec}
The\index{34.1} simple
objects for Modules static semantics are exactly as for the Core.
The compound objects are those for the Core,
augmented by those in Figure~\ref{module-objects}.
\begin{figure}[h]
%\vspace{2pt}
\begin{displaymath}
\begin{array}{rcl}
% \M & \in & \StrNameSets = \Fin(\StrNames)\\
% \N\ {\rm or}\ (\M,\T)
% & \in & \NameSets = \StrNameSets\times\TyNameSets\\
% \sig\ {\rm or}\ \longsig{}
% & \in & \Sig = \NameSets\times\Str \\
% \funsig\ {\rm or}\ \longfunsig{}
% & \in & \FunSig = \NameSets\times
% (\Str\times\Sig)\\
% \G & \in & \SigEnv = \finfun{\SigId}{\Sig} \\
% \F & \in & \FunEnv = \finfun{\FunId}{\FunSig} \\
% \B\ {\rm or}\ \N,\F,\G,\E
% & \in & \Basis = \NameSets\times
% \FunEnv\times\SigEnv\times\Env\\
\S\ {\rm or}\ \longstr\ & \in & \Str = \FunEnv\times\StrEnv\times\TyEnv\times\ValEnv \\
\RS\ {\rm or}\ \S\ {\rm or}\ \longrecstr{1}{2}\
& \in & \RecStr = \Str\ \cup (\RecStr\times\RecStr) \\
\M\ {\rm or}\ \RS\ {\rm or}\ \F
& \in & \Mod = \RecStr\ \cup \Fun \\
\F\ {\rm or}\ \longfun\ & \in & \Fun = \TyNameSets \times \Mod \times \ExMod \\
\XM\ {\rm or}\ \longexmod\ & \in & \ExMod = \EXISTENTIAL{\Mod} = \TyNameSets \times \Mod \\
\G\ {\rm or}\ \longsig\ & \in & \Sig = \PARAMETERISED{\Mod} = \TyNameSets \times \Mod \\
\GE & \in & \SigEnv = \finfun{\SigId}{\Sig} \\
\FE & \in & \FunEnv = \finfun{\FunId}{\Fun} \\
\SE & \in & \StrEnv = \finfun{\StrId}{\RecStr}
\end{array}
\end{displaymath}
\caption{Further Compound Semantic Objects}
\label{module-objects}
%\vspace{3pt}
\end{figure}
% (cvr)
% The prefix $(\N)$, in signatures and functor signatures, binds both type names
% and structure names. We shall always consider a set $\N$ of names as
% partitioned into a pair $(\M,\T)$ of sets of the two kinds of name.
The prefixes \sig{T}{\_}, \exmod{\T,\_} and \fun{\T}{\_}{\_}\
in parameterised objects, existential objects and
functors bind type names.
Certain operations require a change of bound names in semantic objects;
see for example Section~\ref{type-realisation-sec}.
When bound type names are changed, we demand that all of their attributes (i.e.\ equality and kind) are preserved.
The operations of projection, injection and modification are as for the Core, with the following additions:
For a recursive structure \RS, we define $(\of{\S}{\RS})=\S$ if $\RS = \S$ and $(\of{\S}{\RS})=(\of{\S}{\RS_2})$ if $\RS = \longrecstr{1}{2}$.
The operation projects the type of the body of a recursive structure.
We overload the notation for environment modification $\C+\{\modid\mapsto\M\}$ to mean
$\C+\{\strid\mapsto\RS\}$ if $\M = \RS$ and where $\strid=\modid$;
and $\C+\{\funid\mapsto\RS\}$ if $\M = \F$ and where $\funid=\modid$. The former extends the structure environment of \C, interpreting the module identifier as a structure identifier, the latter extends
the functor environment of \C, interpreting the module
identifier as a functor identifier. Which interpretation to apply is uniquely determined by the form of \M.
% It is sometimes convenient to work with an arbitrary semantic object $A$, or
% assembly $A$ of such objects.
% As with the function $\TyNamesFcn$,
% $\StrNamesFcn(A)$ and $\NamesFcn(A)$ denote respectively the set of structure names
% and the set of names occurring free in $A$.
% %We shall often need to change bound names in semantic objects.
% %For example, we sometimes require that
% %$\N\cap\N'=\emptyset$ in a functor signature. More generally,
% %for arbitrary $A$
% %it is sometimes convenient to assume that {\sl all}
% %nameset prefixes $\N$ occurring in $A$ are disjoint. In that
% %case we say that we are {\sl disjoining bound names} in $A$.
% Certain operations require a change of bound names in semantic objects;
% see for example Section~\ref{realisation-sec}. When bound type names are
% changed, we demand that all of their attributes (i.e. imperative, equality
% and arity) are preserved.\index{34.2}
% For any structure $\S=\longS{}$ we call $m$ the {\sl structure name} or
% {\sl name} of $\S$; also, the {\sl proper substructures} of $\S$ are
% the members of $\Ran\SE$ and their proper substructures. The
% {\sl substructures} of
% $\S$ are $\S$ itself and its proper substructures. The structures
% {\sl occurring in}
% an object or assembly $A$ are the structures and
% substructures from which it is built.
% The operations of projection, injection and modification are as for the
% Core. Moreover, we define $\of{\C}{\B}$ to be the context
% $(\of{\T}{\B},\emptyset,\of{\E}{\B})$, i.e.~with an empty set of
% explicit type variables.
% Also,
% we frequently need to modify a basis $\B$ by an environment $\E$
% (or a structure environment $\SE$ say),
% at the same time extending $\of{\N}{\B}$ to include the type names and
% structure names of $\E$ (or of $\SE$ say).
% We therefore define $\B\oplus\SE$, for example, to mean
% $\B+(\NamesFcn\SE,\SE)$.\index{34.3}
% \subsection{Consistency}
% \label{consistency-sec}
% A\index{35.1} set of type structures is said to be {\sl consistent} if, for all
% $(\theta_1,\CE_1)$ and $(\theta_2,\CE_2)$ in the set, if $\theta_1 = \theta_2$
% then
% \[\CE_1=\emptymap\ {\rm or}\ \CE_2=\emptymap\ {\rm or}\ \Dom\CE_1=\Dom\CE_2\]
% A semantic object $A$ or assembly $A$ of objects is said to be
% {\sl consistent} if (after changing bound names to make all nameset prefixes
% in $A$ disjoint) for all $\S_1$ and
% $\S_2$ occurring in $A$ and for every $\longstrid$ and every $\longtycon$
% \begin{enumerate}
% \item If $\of{\m}{\S_1}=\of{\m}{\S_2}$, and both
% $\S_1(\longstrid)$ and $\S_2(\longstrid)$ exist, then
% \[ \of{\m}{\S_1(\longstrid)}\ =\ \of{\m}{\S_2(\longstrid)}\]
% \item If $\of{\m}{\S_1}=\of{\m}{\S_2}$, and both
% $\S_1(\longtycon)$ and $\S_2(\longtycon)$ exist, then
% \[ \of{\theta}{\S_1(\longtycon)}\ =\ \of{\theta}{\S_2(\longtycon)}\]
% \item The set of all type structures in $A$ is consistent
% \end{enumerate}
% As an example, a functor signature $\longfunsig{}$ is
% consistent if, assuming first that $\N\cap\N'=\emptyset$,
% the assembly $A=\{\S,\S'\}$ is consistent.
% We may loosely say that two structures $\S_1$ and $\S_2$ are consistent if
% $\{\S_1,\S_2\}$ is consistent, but must remember that this is stronger than
% the assertion that $\S_1$ is consistent and $\S_2$ is consistent.
% Note that if $A$ is a consistent assembly and $A'\subset A$ then $A'$ is
% also a consistent assembly.
% \subsection{Well-formedness}
% A signature\index{35.2} $\longsig{}$ is {\sl well-formed}
% if $\N\subseteq\NamesFcn\S$,
% and also, whenever $(\m,\E)$ is a
% substructure of $\S$ and $\m\notin\N$, then $\N\cap(\NamesFcn\E)=\emptyset$.
% A functor signature $\longfunsig{}$ is {\sl well-formed} if
% $\longsig{}$ and $(\N')\S'$ are well-formed, and also, whenever
% $(\m',\E')$ is a substructure of $\S'$ and $\m'\notin\N\cup\N'$,
% then $(\N\cup\N')\cap(\NamesFcn\E')=\emptyset$.
% An object or assembly $A$ is {\sl well-formed} if every type environment,
% signature and functor signature occurring in $A$ is well-formed.
% \subsection{Cycle-freedom}
% An\index{35.3} object or assembly $A$ is {\sl cycle-free} if it contains no
% cycle of structure names; that is, there is no sequence
% \[\m_0,\cdots,\m_{k-1},\m_k=m_0\ \ (k>0)\]
% of structure names such that, for each $i\ (0\leq i<k)$ some structure
% with name $m_i$ occurring in $A$ has a proper substructure with name
% $m_{i+1}$.
% \subsection{Admissibility}
% \label{admis-sec}
% An\index{36.1} object or assembly $A$ is {\sl admissible} if it is
% consistent, well-formed and cycle-free. Henceforth it is assumed that
% all objects mentioned are admissible. We also require that
% \begin{enumerate}
% \item In every sentence $A\ts\phrase\ra A'$ inferred by the rules
% given in Section~\ref{statmod-rules-sec}, the assembly $\{A,A'\}$ is
% admissible.
% \item In the special case of a sentence $\B\ts\sigexp\ra\S$,
% we further require that the assembly consisting of all semantic
% objects occurring in the entire inference of this sentence be
% admissible. This is important for the definition of principal
% signatures in Section~\ref{prinsig-sec}.
% \end{enumerate}
% In our semantic definition we have not undertaken to
% indicate how admissibility should be checked in an implementation.
% cvr)
% (cvr
% \subsection{Type Realisation}
% %
% A {\sl type realisation}\index{36.2} is a map
% $\tyrea:\TyNames\to\TypeFcn$
% such that
% $\t$ and $\tyrea(\t)$ have the same arity, and
% if $t$ admits equality then so does $\tyrea(\t)$.
% The {\sl support} $\Supp\tyrea$ of a type realisation $\tyrea$ is the set of
% type names $\t$ for which $\tyrea(\t)\ne\t$.
% %
% \subsection{Realisation}
% \label{realisation-sec}
% A {\sl realisation}\index{36.3} is a function $\rea$ of names,
% partitioned into a type realisation $\tyrea:\TyNames\to\TypeFcn$
% and a function $\strrea : \StrNames\to\StrNames$.
% The {\sl support} $\Supp\rea$
% of a realisation $\rea$ is the set of
% names $\n$ for which $\rea(\n)\ne\n$.
% The {\sl yield} $\Yield\rea$ of a realisation $\rea$ is the set of
% names which occur in some $\rea(\n)$ for which $\n\in\Supp\rea$.
% Realisations $\rea$ are extended to apply to all semantic objects; their
% effect is to
% replace each name $n$ by $\rea(\n)$. In applying $\rea$ to an object with
% bound names, such as a signature $\longsig{}$, first bound names must be
% changed so that, for each binding prefix $(\N)$,
% \[\N\cap(\Supp\rea\cup\Yield\rea)=\emptyset\ .\]
% %
\subsection{Type Realisation}
\label{type-realisation-sec}
A {\sl (type) realisation}\index{36.2} is a map
$\tyrea:\TyName\to\TypeFnc$
such that
$\t$ and $\tyrea(\t)$ have the same kind; in particular, if
$t$ admits equality then so does $\tyrea(\t)$.
The {\sl support} $\Supp\tyrea$ of a type realisation $\tyrea$ is the set of
type names $\t$ for which $\tyrea(\t)\ne\t$.
The {\sl yield} $\Yield\tyrea$ of a realisation $\tyrea$ is the set of
type names which occur in some $\tyrea(\t)$ for which $\t\in\Supp\tyrea$.
%
Realisations $\tyrea$ are extended to apply to all semantic objects; their
effect is to
replace each name $\t$ by $\tyrea(\t)$
(performing $\beta$-reductions as necessary to preserve the structure
of constructed types, type applications and type functions).
In applying $\tyrea$
to an object with
bound names, such as a signature $\longsig$, first bound names must be
changed so that, for each binding prefix (\sig{T}{\_}, \exmod{\T}{\_}\ and
\fun{\T}{\_}{\_}),
\[\T\cap(\Supp\tyrea\cup\Yield\tyrea)=\emptyset\ .\]
% cvr)
% (cvr
% \subsection{Type Explication}
% \label{type-explication-sec}
% A\index{36.35} signature $(\N)\S$ is {\sl type-explicit\/} if,
% whenever $\t\in\N$ and occurs free in $\S$, then some substructure of
% $\S$ contains a type environment $\TE$ such that
% $\TE(\tycon)=(\t,\CE)$ for some $\tycon$ and some $\CE$.
% %
% cvr)
% (cvr
% \subsection{Signature Instantiation}
% A\index{36.4} structure $\S_2$ {\sl is an instance of} a signature
% $\sig_1=\longsig{1}$,
% written $\siginst{\sig_1}{}{\S_2}$, if there exists a realisation
% $\rea$
% such that $\rea(\S_1)=\S_2$ and $\Supp\rea\subseteq\N_1$.
% (Note that if $\sig_1$ is type-explicit then there is at most one
% such $\rea$.)\
% A signature
% $\sig_2=\longsig{2}$ {\sl is an instance of}
% $\sig_1 =\longsig{1}$,
% written $\siginst{\sig_1}{}{\sig_2}$, if
% $\siginst{\sig_1}{}{\S_2}$ and $\N_2\cap(\NamesFcn\sig_1)=\emptyset$.
% It can be shown that $\siginst{\sig_1}{}{\sig_2}$ iff, for all $\S$,
% whenever $\siginst{\sig_2}{}{\S}$ then $\siginst{\sig_1}{}{\S}$.
\subsection{Signature Instantiation}
A\index{36.4} module $\M$ {\sl is an instance of} a signature
$\G=\sig{\T}{\M'}$,
written $\siginstantiates{\G}{\M}$, if there exists a realisation
$\tyrea$
such that $\tyrea(\M')=\M$ and $\Supp\tyrea\subseteq\T$.
% cvr)
% (cvr
% \subsection{Functor Instantiation}
% A\index{36.5} pair $(\S,(\N')\S')$ is called a {\sl functor instance}.
% Given $\funsig=\longfunsig{1}$,
% a functor instance $(\S_2,(\N_2')\S_2')$ is an {\sl instance} of
% $\funsig$,
% written $\funsiginst{\funsig}{}{(\S_2,(\N_2')\S_2')}$,
% if there exists a realisation $\rea$
% such that
% $\rea(\S_1,(\N_1')\S_1')=(\S_2,(\N_2')\S_2')$ and
% $\Supp\rea\subseteq\N_1$.
% %
\subsection{Functor Instantiation}
An\index{36.5} object $\funinst{\M}{\XM}$ is called a {\sl functor instance}.
Given $\F=\longfun[1]$,
a functor instance \funinst{\M_2}{\XM_2}\
is an {\sl instance} of
\F,
written \funinstantiates{\F}{\funinst{\M_2}{\XM_2}},
if there exists a realisation $\tyrea$
such that
$\tyrea(\funinst{\M_1}{\XM_1})= \funinst{\M_2}{\XM_2}$ and
$\Supp\tyrea\subseteq\T_1$.
% An\index{36.5} object $\appfuninst{\M}{\M'}$ is called an {\sl applicative functor instance}.
% Given $\F=\longappfun[1]$,
% a functor instance \appfuninst{\M_2}{\M'_2}\
% is an {\sl instance} of
% \F,
% written \genfuninstantiates{\F}{\appfuninst{\M_2}{\M'_2}}
% if there exists a realisation $\tyrea$
% such that
% $\tyrea(\appfuninst{\M_1}{\M'_1})= \appfuninst{\M_2}{\M'_2}$ and
% $\Supp\tyrea\subseteq\T_1$.
% cvr)
% (cvr
% \subsection{Enrichment}
% \label{enrichment-sec}
% In\index{37.1} matching a structure to a signature, the structure will be allowed both to
% have more components, and to be more polymorphic, than (an instance of) the
% signature. Precisely, we define enrichment of structures, environments and
% type structures by mutual recursion as follows.
% A structure $\S_1=(\m_1,\E_1)$
% {\sl enriches} another structure
% $\S_2=(\m_2,\E_2)$, written $\S_1\succ\S_2$, if
% \begin{enumerate}
% \item $\m_1=\m_2$
% \item $\E_1\succ\E_2$
% \end{enumerate}
% An environment $\E_1=\longE{1}$
% {\sl enriches} another environment $\E_2=$ $\longE{2}$,
% written $\E_1\succ\E_2$,
% if
% \begin{enumerate}
% \item $\Dom\SE_1\supseteq\Dom\SE_2$, and $\SE_1(\strid)\succ\SE_2(\strid)$
% for all $\strid\in\Dom\SE_2$
% \item $\Dom\TE_1\supseteq\Dom\TE_2$, and $\TE_1(\tycon)\succ\TE_2(\tycon)$
% for all $\tycon\in\Dom\TE_2$
% \item $\Dom\VE_1\supseteq\Dom\VE_2$, and $\VE_1(\id)\succ\VE_2(\id)$
% for all $\id\in\Dom\VE_2$
% \item $\Dom\EE_1\supseteq\Dom\EE_2$, and $\EE_1(\exn)=\EE_2(\exn)$
% for all $\exn\in\Dom\EE_2$
% \end{enumerate}
% Finally, a type structure $(\theta_1,\CE_1)$
% {\sl enriches} another type structure $(\theta_2,\CE_2)$,
% written $(\theta_1,\CE_1)\succ(\theta_2,\CE_2)$,
% if
% \begin{enumerate}
% \item $\theta_1=\theta_2$
% \item Either $\CE_1=\CE_2$ or $\CE_2=\emptymap$
% \end{enumerate}
\subsection{Enrichment}
\label{enrichment-sec}
In\index{37.1} matching a (recursive) structure to a signature, the structure will be allowed both to
have more components, and to be more polymorphic, than (an instance of) the
signature.
In\index{37.1} matching an functor to a signature, the functor
will be allowed to be more polymorphic,
have a less rich domain, and have a richer range than (an instance of) the
signature.
Precisely, we define enrichment of structures, recursive structures,
functors, modules, existential modules, and type structures by mutual recursion as follows.
\begin{itemize}
\item A structure $\S_1=\longstr[1]$
{\sl enriches} another structure
$\S_2=\longstr[2]$, written $\S_1\succ\S_2$, if
\begin{enumerate}
\item $\Dom\FE_1\supseteq\Dom\FE_2$, and $\FE_1(\funid)\succ\FE_2(\funid)$
for all $\funid\in\Dom\FE_2$,
\item $\Dom\SE_1\supseteq\Dom\SE_2$, and $\SE_1(\strid)\succ\SE_2(\strid)$
for all $\strid\in\Dom\SE_2$,
\item $\Dom\TE_1\supseteq\Dom\TE_2$, and $\TE_1(\tycon)\succ\TE_2(\tycon)$
for all $\tycon\in\Dom\TE_2$, and
\item $\Dom\VE_1\supseteq\Dom\VE_2$, and $\VE_1(\vid)\succ\VE_2(\vid)$
for all $\vid\in\Dom\VE_2$.
\end{enumerate}
\item A recursive structure $\RS_1$
{\sl enriches} another recursive structure
$\RS_2$, written $\RS_1\succ\RS_2$, if
\begin{enumerate}
\item $\RS_2=\S_2$ and $(\of{\S}{\RS_1})\succ\S_2$ for some (non-recursive) structure $\S_2$, or
\item $\RS_2=\longrecstr{3}{4}$ and
$(\of{\S}{\RS_1})\succ\RS_3$ and $(\of{\S}{\RS_1})\succ\RS_4$ for some recursive structures $\RS_3$ and $\RS_4$.
\end{enumerate}
\item A functor $\F_1=\longfun[1]$
{\sl enriches} another functor
$\F_2=\longfun[2]$, written $\F_1\succ\F_2$, if
there exists a realisation \tyrea\ such that:
\begin{enumerate}
\item $\T_2\cap\TyNamesFcn(\F_1) = \emptyset$,
\item $\M_2 \succ \tyrea(M_1)$,
\item $\tyrea(\XM_1)\succ \XM_2$, and
\item $\Supp \tyrea \subseteq \T_1$.
\end{enumerate}
\item A module $\M_1$
{\sl enriches} another module
$\M_2$, written $\M_1\succ\M_2$, if:
\begin{enumerate}
\item $\M_1=\RS_1$, $\M_2=\RS_2$ and $\RS_1\succ\RS_2$ for some recursive structures
$\RS_1$ and $\RS_2$, or
\item $\M_1=\F_1$, $\M_2=\F_2$ and $\F_1\succ\F_2$ for some functors
$\F_1$ and $\F_2$.
\end{enumerate}
\item An existential module $\XM_1=\longexmod[1]$
{\sl enriches} another existential module
$\XM_2=\longexmod[2]$, written $\XM_1\succ\XM_2$, if:
\begin{enumerate}
\item $\T_1\cap\TyNamesFcn{(\XM_2)} = \emptyset$ and
$\M_1\succ\tyrea_2(\M_2)$ for some realisation $\tyrea_2$ with $\Supp \tyrea_2 \subseteq \T_2$.
\end{enumerate}
\item Finally, a type structure $(\typefnc_1,\VE_1)$
{\sl enriches} another type structure $(\typefnc_2,\VE_2)$,
written $(\typefnc_1,\VE_1)\succ(\typefnc_2,\VE_2)$,
if
\begin{enumerate}
\item $\typefnc_1$ and $\typefnc_2$ have the same kind,
\item $\typefnc_1=\typefnc_2$, and
\item Either $\VE_1=\VE_2$ or $\VE_2=\emptymap$.
\end{enumerate}
\end{itemize}
% cvr)
% (cvr
% \subsection{Signature Matching}
% \label{sigmatch-sec}
% A\index{37.2} structure $\S$ {\sl matches} a signature $\sig_1$ if there exists
% a structure $\S^-$ such that $\sig_1\geq\S^-\prec\S$. Thus matching
% is a combination of instantiation and enrichment. There is at most
% one such $\S^-$, given $\sig_1$ and $\S$. Moreover, writing $\sig_1=
% \longsig{1}$, if $\sig_1\geq\S^-$ then there exists a realisation $\rea$
% with $\Supp\rea\subseteq\N_1$ and $\rea(\S_1)=\S^-$.
% We shall then say that $\S$ matches $\sig_1$ {\em via} $\rea$.
% (Note that if $\sig_1$ is type-explicit
% then $\rea$ is uniquely determined by $\sig_1$ and $\S$.)
% A\index{37.2.5} signature $\sig_2$ {\em matches} a signature $\sig_1$
% if for all structures $\S$, if $\S$ matches $\sig_2$ then $\S$
% matches $\sig_1$. It can be shown that $\sig_2=\longsig{2}$ matches
% $\sig_1=\longsig{1}$ if and only if there exists a realisation
% $\rea$ with $\Supp\rea\subseteq\N_1$ and $\rea(\S_1)\prec\S_2$
% and $\N_2\cap\NamesFcn\sig_1=\emptyset$.
\subsection{Signature Matching}
\label{sigmatch-sec}
A\index{37.2} module $\M$ {\sl matches} a signature $\G$ if there exists
a module $\M^-$ such that $\G\geq\M^-\prec\M$. Thus matching
is a combination of instantiation and enrichment. For any $\G$
and \M\ that must be matched
during elaboration from the initial context, there
will be at most one such $\M^-$.
% cvr)
\subsection{Equivalence of Package Types}
\label{packagetype-equivalence}
We identify package types $\packagetype{\XM} \in\PackType$ that
differ only in a kind and attribute preserving renaming of bound
type names.
Moreover, since we do not want to distinguish between package types
that differ merely in a reordering of components, we
identify package types that are equivalent according to the following
definition.
\label{packagetype-equivalence}
Two package types \packagetype{\XM_1}\ and
\packagetype{\XM_2} are {\sl equivalent} if, and only if,
$\XM_1\succ\XM_2$ and $\XM_2\succ\XM_1$ (each enriches the other).
%
% Two package types \packagetype{\exmod{\T_1}{\M_1}}\ and
% \packagetype{\exmod{\T_2}{\M_2}} are {\sl equivalent} if, and only if:
% \begin{itemize}
% \item $\T_2\cap\TyNamesFcn{(\exmod{\T_1}{\M_1})} = \emptyset$ and
% $\M_2\succ\tyrea_1(\M_1)$ for some realisation $\tyrea_1$ with $\Supp \tyrea_1 \subseteq \T_1$; and
% \item $\T_1\cap\TyNamesFcn{(\exmod{\T_2}{\M_2})} = \emptyset$ and
% $\M_1\succ\tyrea_2(\M_2)$ for some realisation $\tyrea_2$ with $\Supp \tyrea_2 \subseteq \T_2$.
% \end{itemize}
% (cvr
% \subsection{Principal Signatures}
% \label{prinsig-sec}
% The definitions in this section concern the elaboration of signature
% expressions; more precisely they concern inferences of sentences of the
% form $\B\ts\sigexp\ra\S$, where $\S$ is a structure and $\B$ is a basis.
% Recall, from Section~\ref{admis-sec}, that the assembly of all semantic
% objects in such an inference must be admissible.
% For any basis $\B$ and any structure $\S$,
% we say that $\B$ {\sl covers} $\S$
% if for every substructure $(m,E)$ of $\S$ such that
% $m\in\of{\N}{\B}$:
% \begin{enumerate}
% \item
% For every structure identifier $\strid\in\Dom\E$,
% $\B$ contains a substructure $(m,\E')$ with $m$
% free and $\strid\in\Dom\E'$
% \item
% For every type constructor $\tycon\in\Dom\E$,
% $\B$ contains a substructure $(m,\E')$ with $m$ free
% and $\tycon\in\Dom\E'$
% \end{enumerate}
% (This condition is not a consequence of consistency of $\{\B,\S\}$;
% informally, it states that if $\S$ shares a substructure with $\B$,
% then $\S$ mentions no more components of the substructure than
% $\B$ does.)
% We\index{38.1} say that a signature
% $\longsig{}$ is {\sl principal for $\sigexp$ in $\B$} if, choosing $\N$
% so that $(\of{\N}{\B})\cap\N=\emptyset$,
% \begin{enumerate}
% \item $\B$ covers $\S$
% \item $\B\vdash\sigexp\ra\S$
% \item Whenever $\B\vdash\sigexp\ra\S'$, then $\sigord{\longsig{}}{}{\S'}$
% \end{enumerate}
% We claim that if $\sigexp$ elaborates in $\B$ to some structure covered
% by $\B$, then it possesses a principal signature in $\B$.
% Analogous to the definition given for type environments in
% Section~\ref{typeenv-wf-sec}, we say that a semantic object $A$
% {\sl respects equality} if every type environment occurring in
% $A$ respects equality.
% %
% %
% %Further, let $T$ be the set of type names
% %$\t$ such that $(\t,\CE)$ occurs in $A$ for some
% %$\CE\neq\emptymap$. Then $A$ is said to {\sl maximise equality}
% %if (a) $A$ respects equality, and also (b) if any larger subset of
% %$T$ were to admit equality (without any change in the equality
% %attribute of any type names not in $T$) then $A$ would cease to
% %respect equality.
% %
% Now\index{38.5} let us assume that $\sigexp$ possesses a principal signature
% $\sig_0=\longsig{0}$ in $B$. We wish to
% define, in terms of $\sig_0$, another signature $\sig$ which provides more
% information about the equality attributes of structures which will
% match $\sig_0$. To this end, let $\T_0$ be the set of type names $\t\in\N_0$
% which do not admit equality, and such that $(\t,\CE)$ occurs in $\S_0$
% for some $\CE\ne\emptymap$. Then we say $\sig$ is
% {\sl equality-principal for $\sigexp$ in $\B$} if
% \begin{enumerate}
% \item
% $\sig$ respects equality
% \item
% $\sig$ is obtained from $\sig_0$ just by making as many
% members of $\T_0$ admit equality as possible, subject to 1.~above
% \end{enumerate}
% It is easy to show that, if any such $\sig$ exists, it is determined
% uniquely by $\sig_0$; moreover, $\sig$ exists if $\sig_0$ itself
% respects equality.
% %
% (cvr
%\clearpage
% Inference Rules
%
% (cvr
% \subsection{Inference Rules}
% \label{statmod-rules-sec}
% As\index{39.1} for the Core, the rules of the Modules static semantics allow
% sentences of the form
% \[ A\ts\phrase\ra A'\]
% to be inferred, where in this case $A$ is either a basis, a context or
% an environment and $A'$ is a semantic object. The convention for options
% is as in the Core semantics.
% Although not assumed in our definitions, it is intended that every basis
% $\B=\N,\F,\G,\E$ in which a $\topdec$ is elaborated has the property
% that $\NamesFcn\F\ \cup$\linebreak$\NamesFcn\G\cup\NamesFcn\E\subseteq\N$. This is not
% the case for bases in which signature expressions and specifications are
% elaborated, but the following Theorem can be proved:
% \begin{quote}
% Let S be an inferred sentence $\B\ts\topdec\ra\B'$ in which $\B$ satisfies
% the above condition. Then $\B'$ also satisfies the condition.
% Moreover, if S$'$ is a sentence of the form
% $\B''\ts\phrase\ra A$ occurring in a proof of S, where $\phrase$ is
% either a structure expression or a structure-level declaration, then $\B''$
% also satisfies the condition.
% Finally, if $\T,\U,\E\ts\phrase\ra A$ occurs
% in a proof of S, where $\phrase$ is a phrase of the Core, then
% $\TyNamesFcn\E\subseteq\T$.
% \end{quote}
\subsection{Applicative Module Expressions}
To preserve the type soundness property in the presence of both
applicative functors and first-class modules
(Core expressions of package type),
the set {\rm ModExp} of module expressions is divided into a further subclass, the set of {\sl applicative} module expressions.
Informally, a module expression \modexp\ is applicative only if it contains no structure or functor binding of the form \asstrbind\ or \asfunbind, unless that binding occurs within the declaration \dec\ of a Core sub-expression of the form \letexp.
Formally, a module expression is {\sl applicative} if, after replacing
derived forms by their equivalent forms, it can be generated by the following
grammar from the non-terminal $\amodexp$ in Figure \ref{appmodexp-syn}:
\begin{figure}[tp]
\vspace{4pt}
\makeatletter{}
\tabskip\@centering
\halign to\textwidth
{#\hfil\tabskip1em&\hfil$#$\hfil&#\hfil\tabskip\@centering\cr
\adec & ::= & \valdec \cr
& & \typedec \cr
& & \datatypedec \cr
& & \datatyperepdec \cr
& & \aabstypedec \cr
& & \exceptiondec \cr
& & \alocaldec \cr
& & \opendec \cr
& & \astructuredec \cr
& & \afunctordec \cr
& & \signaturedec \cr
& & \emptydec \cr
& & \aseqdec \cr
& & \longinfix \cr
& & \longinfixr \cr
& & \longnonfix \cr
\astrbind
& ::= & \astrbinder \cr
\afunbind
& ::= & \afunbinder \cr
\aatmodexp & ::= & \adecatmodexp \cr
& & \opp\longmodid \cr
& & \aletatmodexp \cr
& & \aparatmodexp \cr
\amodexp & ::= & \aatmodexp \cr
& & \aappmodexp \cr
& & \aconmodexp \cr
& & \aabsmodexp \cr
& & \agenfunctormodexp \cr
& & \aappfunctormodexp \cr
& & \arecmodexp \cr
}
\makeatother
\vspace{-2mm}
\caption{Applicative Module Expressions}
\label{appmodexp-syn}
\end{figure}
% Type soundness is preserved by the inference rules by ensuring that if \dec\ occurs as a subphrase of a module expression of the form
% \[ \LET\ \dec\ \IN\ \modexp\ \END \]
% or
% \[ \STRUCT\ \dec\ \END \]
% then \dec\ must be applicative.
% This restriction does {\sl not} apply to top-level
% declarations, nor to declarations occurring within Core expressions of
% the form \letexp.
Type soundness is preserved by the inference rules by ensuring that if
\modexp\ occurs as the body of a functor, i.e.\ a phrases of the form
\[ \appfunctormodexp \]
or
\[ \genfunctormodexp, \]
then \modexp\ must be applicative.
This restriction applies only to functor bodies; in particular, it
does {\sl not} preclude declarations
of the form \asstrbind\ or \asfunbind\ from occurring
in top-level declarations or structures,
nor does it preclude them from occurring within Core expressions of
the form \letexp.
\subsection{Resolution of Long Module Identifiers}
Although \StrId\ and \FunId\ are regarded as disjoint by the semantics,
in the sense that structures and functors reside in separate name-spaces,
the syntax of structure and functor identifiers is, in fact,
shared. {\sl A priori}, the module expression \opp\longmodid\
may refer to a either a functor or a structure so the
semantics must dictate how to resolve this ambiguity. Fortunately,
the context of the phrase often rules out one
alternative, on the grounds that choosing that alternative
would force elaboration to fail. In particular,
if \opp\longmodid\ occurs as the right hand side of a structure
(functor) binding, then \longmodid\ must be interpreted as an element
of \LongStrId\ (\LongFunId); if
\opp\longmodid\ occurs in the functor position of an application, then
\longmodid\ must be interpreted as an element of \LongFunId; if
\opp\longmodid\ is constrained by a signature
then the signature
forces a unique interpretation
on \longmodid\ (depending on whether the signature specificies a structure or functor).
Similarly, if \opp\longmodid\ occurs as the argument of a functor application,
then the functor's domain forces a unique interpretation
on \longmodid.
Indeed, the only ambiguity that remains occurs when \opp\longmodid\ is the body of a functor. In this case, the optional prefix \opp\ is used to resolve
the ambiguity: the {\sl absence} of \OP\ signals
that \longmodid\ refers to structure; the {\sl presence} of \OP\ signals that
\OP~\longmodid\ refers to a functor.
When the interpretation of \opp\longmodid\ is already
determined by the context, the optional prefix \opp\ has {\sl no} effect.
Since this method of disambiguation relies on type informatifon
it is formalised within the static semantic rules.
In the rules for elaborating module expressions,
the context of the current phrase
is summarized by an {\sl expectation}:
\begin{displaymath}
\begin{array}{rcl}
\expect & \in & $\Expectation = \{\expectstr, \expectfun, \expectmod\} $
\end{array}
\end{displaymath}
Of the three values: \expectstr\ indicates that a structure is expected;
\expectfun\ indicates that a functor is expected; finally,
\expectmod\ indicates that a structure or a functor is expected,
so that the status of \opp\longmodid\ must be resolved by \opp.
The inference rules rely on two auxilliary functions that determine the
expectation for a subderivation depending on the form of a signature
or the domain of a functor:
\begin{displaymath}
\begin{array}{rcl}
\expectofsig{\_} & \in & \Sig \rightarrow \Expectation \\
%\vspace{3pt}\\
\expectofsig{\G} &=& \left\{\begin{array}{l}
\expectstr\quad \mbox{if $\G=\sig{\T}{\RS}$}\\
\expectfun\quad \mbox{if $\G=\sig{\T}{\F}$}
\end{array}
\right. \\
\vspace{6pt}\\
\expectoffun{\_} & \in & \Fun \rightarrow \Expectation \\
%\vspace{3pt}\\
\expectoffun{\F} &=& \left\{\begin{array}{l}
\expectstr
\quad \mbox{if $\F=\fun{\T}{\RS}{\XM}$}\\
\expectfun
\quad\mbox{if $\F=\fun{\T}{\F'}{\XM}$}
\end{array}
\right. \\
\end{array}
\end{displaymath}
% \[\expectofsig{\G} = \expectstr\quad \mbox{if $\G=\sig{\T}{\RS}$} \]
% \[\expectofsig{\G} = \expectfun\quad \mbox{if $\G=\sig{\T}{\F}$} \]
% \[\expectoffun{\F} = \expectstr\quad \mbox{if $\F=\fun{\T}{\RS}{\XM}$}\]
% \[\expectoffun{\F} = \expectfun\quad \mbox{if $\F=\fun{\T}{\F'}{\XM}$}\]
\subsection{Inference Rules}
\label{statmod-rules-sec}
As\index{39.1} for the Core, the rules of the Modules static semantics allow
sentences of the form
\[ A\ts\phrase\ra A'\]
to be inferred, where $A$ is typically a context, {\it phrase} is a phrase of
the Modules language,
and $A'$ is a semantic object. The convention for options
is as in the Core semantics.
% cvr)
% SEMANTICS
% % Structure Expressions
% %
% \rulesec{Structure Expressions}{\B\ts\strexp\ra \S}
% \begin{equation} % generative strexp
% \label{generative-strexp-rule}
% \frac{\B\ts\strdec\ra\E\qquad\m\notin(\of{\N}{\B})\cup\NamesFcn\E}
% {\B\ts\encstrexp\ra(\m,\E)}\index{39.2}
% \end{equation}
% \begin{equation} % longstrid
% %\label{longstrid-strexp-rule}
% \frac{\B(\longstrid)=\S}
% {\B\ts\longstrid\ra\S}
% \end{equation}
% \vspace{6pt}
% \begin{equation} % functor application
% \label{functor-application-rule}
% \frac{ \begin{array}{c}
% \B\ts\strexp\ra\S\\
% \funsiginst{\B(\funid)}{}{(\S'',(\N')\S')}\ ,
% \ \S\succ\S''\\
% (\of{\N}{\B})\cap\N'=\emptyset
% \end{array}
% }
% {\B\ts\funappstr\ra\S'}
% \end{equation}
% \vspace{6pt}
% \begin{equation} % let strexp
% \label{letstrexp-rule}
% \frac{\B\ts\strdec\ra\E\qquad\B\oplus\E\ts\strexp\ra\S}
% {\B\ts\letstrexp\ra\S}
% \end{equation}
% \comments
% \begin{description}
% \item{(\ref{generative-strexp-rule})}
% The side condition ensures that each generative structure
% expression receives a new name. If the expression occurs in
% a functor body the structure name will be bound by $(\N')$ in
% rule~\ref{funbind-rule}; this will ensure that for each application of the
% functor, by rule~\ref{functor-application-rule}, a new distinct name
% will be chosen for the structure generated.
% %
% \item{(\ref{functor-application-rule})}
% The side condition $ (\of{\N}{\B})\cap\N'=\emptyset$ can always
% be satisfied by renaming bound names in $(\N')S'$ thus ensuring that the
% generated structures receive new names.\index{40.1}
% Let $\B(\funid)=(N)(\S_f,(N')\S_f')$. Assuming that $(\N)\S_f$ is
% type-explicit, the realisation $\rea$ for which
% $\rea(\S_f,(N')\S_f')=(\S'',(\N')\S')$ is uniquely determined by $\S$,
% since $\S\succ\S''$ can only hold if the type names and structure
% names in $\S$ and $\S''$ agree. Recall that enrichment $\succ$ allows
% more components and more polymorphism, while instantiation $\geq$ does
% not.
% Sharing between argument and result specified in the declaration of
% the functor $\funid$ is represented by the occurrence of the same name
% in both $\S_f$ and $\S_f'$, and this repeated occurrence is preserved
% by $\rea$, yielding sharing between the argument structure $\S$ and
% the result structure $\S'$ of this functor application.
% %
% \item{(\ref{letstrexp-rule})}
% The use of $\oplus$, here and elsewhere, ensures that structure
% and type names generated by
% the first sub-phrase
% are distinct from names generated by the second
% sub-phrase.
% \end{description}
% Structure Expressions
%
\rulesec{Long Structure Identifiers}{\C\ts\longstrid\ra\RS}
\begin{equation} % idlongstrid
\label{idlongstrid-rule}
\frac{\begin{array}{lr}
\strid\in\Dom \C
\end{array}}
{\C\ts\idlongid{\strid}\ra\C(\strid)}
\end{equation}
\begin{equation} % dotlongstrid
\label{dotlongstrid-rule}
\frac{\begin{array}{lcr}
\C\ts\longstrid\ra\RS &
\SE = \of{\SE}{(\of{\S}{\RS})} &
\strid\in\Dom\SE
\end{array}
}
{\C\ts\dotlongid{\longstrid}{\strid}\ra\SE(\strid)}
\end{equation}
\rulesec{Long Functor Identifiers}{\C\ts\longfunid\ra\F}
\begin{equation} % idlongfunid
\label{idlongfunid-rule}
\frac{\funid\in\Dom \C}
{\C\ts\idlongid{\funid}\ra\C(\funid)}
\end{equation}
\begin{equation} % dotlongfunid
\label{dotlongfunid-rule}
\frac{\begin{array}{lcr}
\C\ts\longstrid\ra\RS &
\FE = \of{\FE}{(\of{\S}{\RS})} &
\funid\in\Dom\FE
\end{array}
}
{\C\ts\dotlongid{\longstrid}{\funid}\ra\FE(\funid)}
\end{equation}
\rulesec{Long Module Identifiers}{\C\ts^\expect\opp\ \longmodid\ra\M}
\begin{equation} % strlongmodid
\label{strlongmodid-rule}
\frac{\begin{array}{lr}
\C\ts\longstrid\ra\RS & \longstrid=\longmodid
\end{array}}
{\C\ts^\expectstr\opp\ \longmodid\ra\RS}
\end{equation}
\begin{equation} % funlongmodid
\label{funlongmodid-rule}
\frac{\begin{array}{lr}
\C\ts\longfunid\ra\F & \longfunid=\longmodid
\end{array}}
{\C\ts^\expectfun\opp\ \longmodid\ra\F}
\end{equation}
\begin{equation} % longmodid
\label{longmodid-rule}
\frac{\begin{array}{lr}
\C\ts\longstrid\ra\RS & \longstrid=\longmodid
\end{array}}
{\C\ts^\expectmod\longmodid\ra\RS}
\end{equation}
\begin{equation} % oplongmodid
%\label{oplongmodid-rule}
\frac{\begin{array}{lr}
\C\ts\longfunid\ra\F & \longfunid=\longmodid
\end{array}}
{\C\ts^\expectmod\OP\ \longmodid\ra\F}
\end{equation}
\rulesec{Atomic Module Expressions}{\C\ts^\expect\atmodexp\ra\XM}
\begin{equation} % decatmodexp
\label{decatmodexp-rule}
\frac{\C\ts\dec\ra\EXISTS{\T}{\E}}
{\C\ts^\expect\decatmodexp\ra\exmod{\T}{(\of{\FE}{\E},\of{\SE}{\E},\of{\TE}{\E},\of{\VE}{\E})}}\index{39.2}
\end{equation}
\begin{equation} % longmodidatexp
\label{longmodid-rule}
\frac{\C\ts^\expect\opp\ \longmodid\ra\M}
{\C\ts^\expect\opp\ \longmodid\ra\exmod{\emptyset}{\M}}
\end{equation}
% \begin{equation} % dotlongmodid
% \label{anonatmodexp-rule}
% \frac{\begin{array}{l}
% \C\ts^\expectstr\modexp\ra\exmod{\T}{RS} \\
% \C+\{\strid\mapsto\RS\}\ts^\expect\opp\ \longmodid\ra\M\\
% \T\cap(\TyNamesFcn(\C))\\
% \end{array}
% }
% {\C\ts^\expect\anonatmodexp\ra\exmod{\T}{M}}
% \end{equation}
\begin{equation} % letatmodexp
\label{letatmodexp-rule}
\frac{\begin{array}{lr}
\C\ts\dec\ra\EXISTS{\T_1}{\E} &
\T_1 \cap \TyNamesFcn \C = \emptyset \\
\C+\E\ts^\expect\modexp\ra\exmod{\T_2}{\M} &
\T_2 \cap T_1 = \emptyset
\end{array}}
{\C\ts^\expect\letatmodexp\ra\exmod{\T_1 \cup \T_2}{\M}}
\end{equation}
\begin{equation} % paratmodexp
\label{paratmodexp}
\frac{\C\ts^\expect\modexp\ra\XM}
{\C\ts^\expect\paratmodexp\ra\XM}
\end{equation}
\comments \begin{description}
\item{(\ref{decatmodexp-rule})} The
resulting structure contains the functor, structure, type and value
components of \E. Signatures declared in
\dec\ are local to \dec\ and not visible from outside the structure.
% \item{(\ref{anonatmodexp-rule})} Here,
% \longmodid\ may refer to a component of the anonymous structure
% expression \modexp, whose type
% involves the existentially quantified type names \T. The
% rule must ensure that the type of the phrase
% does not cause these hypothetical type names
% to escape their scope. Existentially quantifying over \T\ in the
% result \exmod{\T}{\M}\ is sufficient.
% % This approach allows
% %access to deeply nested type or value components even though the
% %intermediate sub-modules might contain existentially quantified
% %type names.
% %: the side-conditions of rules \ref{anonvidpath-rule} and
% %\ref{anontyconpath-rule} will prevent these names from escaping
% %their scope.
\item{(\ref{letatmodexp-rule})}
The side condition $\T_{1}\cap
\TyNamesFcn \C$, here and elsewhere, ensures that eliminating the
first existential quantifier does not capture type names occurring
free in the context.
The side condition can always