-
Notifications
You must be signed in to change notification settings - Fork 13
/
statmod.tex
1409 lines (1318 loc) · 55.4 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}
\adhocreplacementl{\thenostrsharing}{0mm}{
\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\\
\end{array}
\end{displaymath}}{\begin{displaymath}
\begin{array}{rcl}
\sig\ {\rm or}\ \newlongsig{}
& \in & \Sig = \TyNameSets\times\Env \\
\funsig\ {\rm or}\ \newlongfunsig{}
& \in & \FunSig = \TyNameSets\times
(\Env\times\Sig)\\
\G & \in & \SigEnv = \finfun{\SigId}{\Sig} \\
\F & \in & \FunEnv = \finfun{\FunId}{\FunSig} \\
\B\ {\rm or}\ \T,\F,\G,\E
& \in & \Basis = \TyNameSets\times
\FunEnv\times\SigEnv\times\Env\\
\end{array}
\end{displaymath}}
\caption{Further Compound Semantic Objects}
\label{module-objects}
%\vspace{3pt}
\end{figure}
%
\replacement{\thenostrsharing}{
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
prefix $(\T)$, in signatures and functor signatures, binds type names.}
\deletion{\thenostrsharing}{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$.}
Certain operations require a change of bound names in semantic objects;
see for example \replacement{\thenostrsharing}{Section~\ref{realisation-sec}}{Section~\ref{tyrea.sec}}. When bound type names are
changed, we demand that all of their attributes (i.e. \deletion{\thenoimptypes}{imperative, }equality
and arity) are preserved.\index{34.2}
\deletion{\thenotypexplication}{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 \replacement{\thenostrsharing}{$\of{\N}{\B}$}{$\of{\T}{\B}$} to include the type names
\deletion{\thenostrsharing}{and
structure names }of $\E$ (or of $\SE$ say).
We therefore define $\B\oplus\SE$, for example, to mean
\replacement{\thenostrsharing}{$\B+(\NamesFcn\SE,\SE)$}{$\B+(\TyNamesFcn\SE,\SE)$}.
\index{34.3}
\insertion{\thenostrsharing}{
There is no separate kind of semantic object to represent structures:
structure expressions elaborate to environments, just as structure-level
declarations do. Thus, notions which are commonly associated with structures
(for example the notion of matching a structure against a signature) are defined
in terms of environments.}
\deletion{\thenostrsharing}{
\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.
}
\deletion{\thenostrsharing}{
\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.}
\deletion{\thenostrsharing}{\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}$.
}
\deletion{\thenostrsharing}{
\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.
}
\subsection{Type Realisation}
\label{tyrea.sec}
\replacement{\thenostrsharing}{
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$.}{A
{\sl (type) realisation}\index{36.2} is a map
$\rea:\TyNames\to\TypeFcn$
such that
$\t$ and $\rea(\t)$ have the same arity, and
if $t$ admits equality then so does $\rea(\t)$.
The {\sl support} $\Supp\rea$ of a type realisation $\rea$ is the set of
type names $\t$ for which $\rea(\t)\ne\t$.}
%
\deletion{\thenostrsharing}{\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$.}\replacement{\thenostrsharing}{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$.}{The
{\sl yield} $\Yield\rea$ of a realisation $\rea$ is the set of
type names which occur in some $\rea(\t)$ for which $\t\in\Supp\rea$.}
Realisations $\rea$ are extended to apply to all semantic objects; their
effect is to
replace each name \replacement{\thenostrsharing}{$n$ by $\rea(\n)$}{$\t$ by $\rea(\t)$}. In applying $\rea$ to an object with
bound names, such as a signature \replacement{\thenostrsharing}{$\longsig{}$}{$\newlongsig{}$}, first bound names must be
changed so that, for each binding prefix \replacement{\thenostrsharing}{$(\N)$}{$(\T)$},
\replacement{\thenostrsharing}{
\[\N\cap(\Supp\rea\cup\Yield\rea)=\emptyset\ .\]}{\[\T\cap(\Supp\rea\cup\Yield\rea)=\emptyset\ .\]}
%
\deletion{\thenotypexplication}{
\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$.}
%
\subsection{Signature Instantiation}
\replacement{\thenostrsharing}{
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$.}{An\index{36.4} environment $\E_2$ {\sl is an instance of} a signature
$\sig_1=\newlongsig{1}$,
written $\siginst{\sig_1}{}{\E_2}$, if there exists a realisation
$\rea$
such that $\rea(\E_1)=\E_2$ and $\Supp\rea\subseteq\T_1$.}
\deletion{\thenotypexplication}{(Note that if $\sig_1$ is type-explicit then there is at most one
such $\rea$.)}\
\deletion{\thenostrsharing}{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{Functor Signature Instantiation}
\replacement{\thenostrsharing}{
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$.}{
A\index{36.5} pair $(\E,(\T')\E')$ is called a {\sl functor instance}.
Given $\funsig=\newlongfunsig{1}$,
a functor instance $(\E_2,(\T_2')\E_2')$ is an {\sl instance} of
$\funsig$,
written $\funsiginst{\funsig}{}{(\E_2,(\T_2')\E_2')}$,
if there exists a realisation $\rea$
such that
$\rea(\E_1,(\T_1')\E_1')=(\E_2,(\T_2')\E_2')$ and
$\Supp\rea\subseteq\T_1$.}
%
\subsection{Enrichment}
\label{enrichment-sec}
In\index{37.1} matching \replacement{\thenostrsharing}{a structure}{an environment} to a signature, the \replacement{\thenostrsharing}{structure}{environment} will be allowed both to
have more components, and to be more polymorphic, than (an instance of) the
signature. Precisely, we define enrichment of \deletion{\thenostrsharing}{structures, }environments and
type structures \replacement{\thenostrsharing}{by mutual recursion}{recursively} as follows.
\deletion{\thenostrsharing}{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 \replacement{\theidstatus}{$\E_1=\longE{1}$}{$\E_1=\newlongE{1}$}
{\sl enriches} another environment \replacement{\theidstatus}{$\E_2=$ $\longE{2}$}{$\E_2=
( \SE_2,$\linebreak$\TE_2,\VE_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 \replacement{\theidstatus}{$\Dom\VE_1\supseteq\Dom\VE_2$, and $\VE_1(\id)\succ\VE_2(\id)$
for all $\id\in\Dom\VE_2$}{$\Dom\VE_1\supseteq\Dom\VE_2$, and $\VE_1(\vid)\succ\VE_2(\vid)$
for all $\vid\in\Dom\VE_2$,
where $(\sigma_1,\is_1)\succ(\sigma_2,\is_2)$ means $\sigma_1\succ\sigma_2$ and
$$\is_1 = \is_2\quad\hbox{or}\quad \is_2 = \isv$$}
\deletion{\theidstatus}{
\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,\adhocreplacementl{\thece}{6cm}{\CE}{\VE}_1)$
{\sl enriches} another type structure $(\theta_2,\adhocreplacementl{\thece}{-4cm}{\CE}{\VE}_2)$,
written $(\theta_1,\adhocreplacementl{\thece}{10mm}{\CE}{\VE}_1)\succ(\theta_2,\adhocreplacementl{\thece}{-12cm}{\CE}{\VE}_2)$,
if
\begin{enumerate}
\item $\theta_1=\theta_2$
\item Either $\adhocreplacementl{\thece}{3cm}{\CE}{\VE}_1=\adhocreplacementl{\thece}{-8cm}{\CE}{\VE}_2$ or $\adhocreplacementl{\thece}{-11cm}{\CE}{\VE}_2=\emptymap$
\end{enumerate}
\oldpagebreak
\subsection{Signature Matching}
\label{sigmatch-sec}
\replacement{\thenostrsharing}{
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$.}{An\index{37.2} environment $\E$ {\sl matches} a signature $\sig_1$ if there exists
an environment $\E^-$ such that $\sig_1\geq\E^-\prec\E$. Thus matching
is a combination of instantiation and enrichment. There is at most
one such $\E^-$, given $\sig_1$ and $\E$.} \deletion{\thenotypexplication}{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$.)}
\deletion{\thenostrsharing}{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$.}
\deletion{\thenostrsharing}{\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.
%
\oldpagebreak
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\neq\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.
\bigskip}
%
%\clearpage
% Inference Rules
%
\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
\replacement{\thenostrsharing}{$\B=\N,\F,\G,\E$}{$\B=\T,\F,\G,\E$} in which a $\topdec$ is elaborated has the property
that
\replacement{\thenostrsharing}{$\NamesFcn\F\ \cup\NamesFcn\G\cup\NamesFcn\E\subseteq\N$}{$\TyNamesFcn\F
\ \cup\TyNamesFcn\G\cup\TyNamesFcn\E\subseteq\T$}.
\replacement{\thenostrsharing}{
This is not
the case for bases in which signature expressions and specifications are
elaborated, but the following Theorem can be proved:}{
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.
\replacement{\thenostrsharing}{
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.}{
Moreover, if S$'$ is a sentence of the form
$\B''\ts\phrase\ra A$ occurring in a proof of S, where $\phrase$ is
any Modules phrase, then $\B''$ also satisfies the condition.}
\replacement{\thenostrsharing}{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$.}{Finally, if $\T,\U,\E\ts\phrase\ra A$ occurs
in a proof of S, where $\phrase$ is a phrase of Modules or of the Core, then
$\TyNamesFcn\E\subseteq\T$.}
\end{quote}
% SEMANTICS
%
% Structure Expressions
%
\replacement{\thenostrsharing}{
\rulesec{Structure Expressions}{\B\ts\strexp\ra \S}}
{\rulesec{Structure Expressions}{\B\ts\strexp\ra \E}}
\replacement{\thenostrsharing}{\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} % generative strexp
\label{generative-strexp-rule}
\frac{\B\ts\strdec\ra\E}
{\B\ts\encstrexp\ra \E }\index{39.2}
\end{equation}}
\replacement{\thenostrsharing}{
\begin{equation} % longstrid
%\label{longstrid-strexp-rule}
\frac{\B(\longstrid)=\S}
{\B\ts\longstrid\ra\S}
\end{equation}}{\begin{equation} % longstrid
%\label{longstrid-strexp-rule}
\frac{\B(\longstrid)=\E}
{\B\ts\longstrid\ra\E}
\end{equation}}
\insertion{\thenostrsharing}{
\begin{equation}
\label{transparent-constraint-rule}
\frac{B\ts\strexp\ra\E\quad\B\ts\sigexp\ra\Sigma\quad\Sigma\geq\E'\prec\E}
{\B\ts\transpconstraint\ra\E'}
\end{equation}
}
\insertion{\thenostrsharing}{
\begin{equation}
\label{opaque-constraint-rule}
\frac{\begin{array}{c}
B\ts\strexp\ra\E\quad\B\ts\sigexp\ra(\T')\E'\\
(\T')\E'\geq\E''\prec\E\quad \T' \cap(\of{\T}{\B}) = \emptyset
\end{array}}
{\B\ts\opaqueconstraint\ra\E'}
\end{equation}
}
\vspace{6pt}
\replacement{\thenostrsharing}{
\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}}{\begin{equation} % functor application
\label{functor-application-rule}
\frac{ \begin{array}{c}
\B\ts\strexp\ra\E\\
\funsiginst{\B(\funid)}{}{(\E'',(\T')\E')}\ ,
\ \E\succ\E''\\
(\TyNamesFcn \E\; \cup\; \of{\T}{\B})\cap\T'=\emptyset
\end{array}
}
{\B\ts\funappstr\ra\E'}
\end{equation}}
\vspace{6pt}
\replacement{\thenostrsharing}{
\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}}{\begin{equation} % let strexp
\label{letstrexp-rule}
\frac{\B\ts\strdec\ra\E_1\qquad\B\oplus\E_1\ts\strexp\ra\E_2}
{\B\ts\letstrexp\ra\E_2}
\end{equation}}
\comments
\begin{description}
\deletion{\thenostrsharing}{
\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.}
%
\oldpagebreak
\item{(\ref{functor-application-rule})}
The side condition
\replacement{\thenostrsharing}{$ (\of{\N}{\B})\cap\N'=\emptyset$}{$(\TyNamesFcn\E \cup \of{\T}{\B})\cap\T'=\emptyset$}
can always
be satisfied by renaming bound names in \replacement{\thenostrsharing}{$(\N')S'$}{$(\T')E'$}; it ensures that the
generated \replacement{\thenostrsharing}{structures}{datatypes} receive new names.\index{40.1}
\replacement{\thenostrsharing}{Let $\B(\funid)=(N)(\S_f,(N')\S_f')$.}{Let $\B(\funid)=(\T)(\E_f,(T')\E_f')$.}
\replacement{\thenotypexplication}{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.\par}{Let $\rea$ be a realisation such that\linebreak
$\rea(\E_f,(T')\E_f')=(\E'',(\T')\E')$.}
\replacement{\thenostrsharing}{
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.}{
Sharing between argument and result specified in the declaration of
the functor $\funid$ is represented by the occurrence of the same name
in both $\E_f$ and $\E_f'$, and this repeated occurrence is preserved
by $\rea$, yielding sharing between the argument structure $\E$ and
the result structure $\E'$ of this functor application.}
%
\item{(\ref{letstrexp-rule})}
The use of $\oplus$, here and elsewhere, ensures that \deletion{\thenostrsharing}{structure
and }type names generated by
the first sub-phrase
are distinct from names generated by the second
sub-phrase.
\end{description}
% declarations
\rulesec{Structure-level Declarations}{\B\ts\strdec\ra\E}
\replacement{\thenostrsharing}{
\begin{equation} % core declaration
\label{dec-rule}
\frac{ \of{\C}{\B}\ts\dec\ra\E
\quad\E\ {\rm principal\ for\ \dec\ in\ } (\of{\C}{\B})
}
{ \B\ts\dec\ra\E }\index{40.2}
\end{equation}}{\begin{equation} % core declaration
\label{dec-rule}
\frac{ \of{\C}{\B}\ts\dec\ra\E
}
{ \B\ts\dec\ra\E }\index{40.2}
\end{equation}}
\vspace{6pt}
\begin{equation} % structure declaration
%\label{structure-decl-rule}
\frac{ \B\ts\strbind\ra\SE }
{ \B\ts\singstrdec\ra\SE\ \In\ \Env }
\end{equation}
\vspace{6pt}
\begin{equation} % local structure-level declaration
%\label{local structure-level declaration}
\frac{ \B\ts\strdec_1\ra\E_1\qquad
\B\oplus\E_1\ts\strdec_2\ra\E_2 }
{ \B\ts\localstrdec\ra\E_2 }
\end{equation}
\vspace{6pt}
\begin{equation} % empty declaration
%\label{empty-strdec-rule}
\frac{}
{\B\ts\emptystrdec\ra \emptymap{\rm\ in}\ \Env}
\end{equation}
\vspace{6pt}
\begin{equation} % sequential declaration
%\label{sequential-strdec-rule}
\frac{ \B\ts\strdec_1\ra\E_1\qquad
\B\oplus\E_1\ts\strdec_2\ra\E_2 }
{ \B\ts\seqstrdec\ra\plusmap{\E_1}{\E_2} }
\end{equation}
\deletion{\thenostrsharing}{
\comments
\begin{description}
\item{(\ref{dec-rule})}
The side condition ensures that all type schemes in $\E$ are as
general as possible.
% and that no imperative type variables occur
%free in $\E$.
%from version 1:
% The side condition ensures that all type schemes in $\E$ are as
%general as possible and that all new type names in $\E$ admit
%equality, if possible.
\end{description}}
\oldpagebreak
\rulesec{Structure Bindings}{\B\ts\strbind\ra\SE}
\replacement{\thenostrsharing}{
\begin{equation} % structure binding
\label{structure-binding-rule}
\frac{ \begin{array}{cl}
\B\ts\strexp\ra\S\qquad\langle\B\ts\sigexp\ra\sig\ ,
\ \sig\geq\S'\prec\S\rangle\\
\langle\langle\plusmap{\B}{\TyNamesFcn\S}\ts
\strbind\ra\SE\rangle\rangle
\end{array}
}
{ \B\ts\strbinder\ra\{\strid\mapsto\S\langle'\rangle\}
\ \langle\langle +\ \SE\rangle\rangle }\index{41.1}
\end{equation}}{\begin{equation} % structure binding
\label{structure-binding-rule}
\frac{
\B\ts\strexp\ra\E\quad
\langle\plusmap{\B}{\TyNamesFcn\E}\ts
\strbind\ra\SE\rangle
}
{ \B\ts\barestrbindera\ra\{\strid\mapsto\E\}
\ \langle +\ \SE\rangle}\index{41.1}
\end{equation}}
\deletion{\thenostrsharing}{
\comment If present, $\sigexp$ has the effect of restricting the
view which $\strid$ provides of $\S$ while retaining sharing of names.
The notation $\S\langle'\rangle$ means $\S'$, if the first option is present,
and $\S$ if not.}
%
% Signature Rules
%
\replacement{\thenostrsharing}{
\rulesec{Signature Expressions}{\B\ts\sigexp\ra\S}
\begin{equation} % encapsulation sigexp
\label{encapsulating-sigexp-rule}
\frac{\B\ts\spec\ra\E }
{\B\ts\encsigexp\ra (\m,\E) }\index{41.2}
\end{equation}}{\rulesec{Signature Expressions}{\B\ts\sigexp\ra\E}
\begin{equation} % encapsulation sigexp
\label{encapsulating-sigexp-rule}
\frac{\B\ts\spec\ra\E }
{\B\ts\encsigexp\ra \E }\index{41.2}
\end{equation}}
\replacement{\thenostrsharing}{\begin{equation} % signature identifier
\label{signature-identifier-rule}
\frac{ \sigord{\B(\sigid)}{}{\S} }
{ \B\ts\sigid\ra\S }
\end{equation}}{\begin{equation} % signature identifier
\label{signature-identifier-rule}
\frac{ \B(\sigid) = (\T)\E \quad \T\cap (\of{\T}{\B}) = \emptyset}
{ \B\ts\sigid\ra\E }
\end{equation}}
\insertion{\thenostrsharing}{
\begin{equation}
\label{wheretype-rule}
\frac{
\begin{array}{c}
\B\ts\sigexp\ra \E\quad \tyvarseq = \alphak\quad \of{\C}{\B}\ts\ty\ra \tau\\
\E(\longtycon) = (\t, \VE)\quad t\notin\of{\T}{\B}\\
\rea = \{\t\mapsto \Lambda\alphak.\tau\}\quad
\hbox{$\Lambda\alphak.\tau$ admits equality, if $\t$ does\quad $\rea(\E)$ well-formed}
\end{array}
}
{\B\ts\wheretypesigexp\ra\rea(\E)}
\end{equation}}
\comments
\begin{description}
\deletion{\thenostrsharing}{
\item{(\ref{encapsulating-sigexp-rule})}
In contrast to rule~\ref{generative-strexp-rule}, $m$ is not here
required to be new.
The name $m$ may be chosen to achieve the sharing required
in rule~\ref{strshareq-rule}, or to achieve the enrichment side conditions
of rule~\ref{structure-binding-rule} or \ref{funbind-rule}.
The choice of $m$ must result in an admissible object.}
\item{(\ref{signature-identifier-rule})}
\replacement{\thenostrsharing}{The instance $\S$ of $\B(\sigid)$ is not determined by this rule,
but -- as in rule~\ref{encapsulating-sigexp-rule} -- the instance
may be chosen to achieve sharing properties or enrichment
conditions.}{The bound names of $\B(\sigid)$ can always be renamed to satisfy $\T\cap(\of{\T}{\B}) = \emptyset$,
if necessary.}
\end{description}
\rulesec{}{\B\ts\sigexp\ra\sig}
\replacement{\thenostrsharing}{\begin{equation} % any sigexp
\label{topmost-sigexp-rule}
\frac{\begin{array}{c}
\B\ts\sigexp\ra\S\quad\mbox{$(\N)\S$ equality-principal for $\sigexp$ in $\B$}\\
\mbox{$(\N)\S$ type-explicit}
\end{array}}
{\B\ts\sigexp\ra (\N)\S}\index{41.25}
\end{equation}}{\begin{equation} % any sigexp
\label{topmost-sigexp-rule}
\frac{
\B\ts\sigexp\ra\E\quad\T= \TyNamesFcn\E\setminus(\of{\T}{\B})
}
{\B\ts\sigexp\ra (\T)\E}\index{41.25}
\end{equation}}\noindent\comment
A signature expression $\sigexp$ which is an immediate constituent of
\deletion{\thenostrsharing}{a structure binding, } a signature binding\replacement{\thenostrsharing}{, a
functor binding or a
functor signature}{, a signature constraint, or a
functor binding }is elaborated to \replacement{\thenostrsharing}{an equality-principal and type-explicit }{a }signature,
see rules~\replacement{\thenostrsharing}{\ref{structure-binding-rule}, }{
\ref{transparent-constraint-rule}, \ref{opaque-constraint-rule}, }\ref{sigbind-rule}\deletion{\thenostrsharing}{,
\ref{funsigexp-rule}} and \ref{funbind-rule}. \deletion{\thenostrsharing}{By contrast, signature
expressions occurring in structure descriptions are elaborated to
structures using the liberal rules
\ref{encapsulating-sigexp-rule} and \ref{signature-identifier-rule},
see rule~\ref{strdesc-rule}, so that names can be chosen to achieve
sharing, when necessary.}
\oldpagebreak
\rulesec{Signature Declarations}{\B\ts\sigdec\ra\G}
\begin{equation} % single signature declaration
\label{single-sigdec-rule}
\frac{ \B\ts\sigbind\ra\G }
{ \B\ts\singsigdec\ra\G }\index{41.3}
\end{equation}
\deletion{\thenostrsharing}{
\begin{equation} % empty signature declaration
%\label{empty-sigdec-rule}
\frac{}
{ \B\ts\emptysigdec\ra\emptymap }
\end{equation}
\begin{equation} % sequential signature declaration
\label{sequence-sigdec-rule}
\frac{ \B\ts\sigdec_1\ra\G_1 \qquad \plusmap{\B}{\G_1}\ts\sigdec_2\ra\G_2 }
{ \B\ts\seqsigdec\ra\plusmap{\G_1}{\G_2} }
\end{equation}}
\deletion{\thenostrsharing}{\comments
\begin{description}
%
\item{(\ref{single-sigdec-rule})}
The first closure restriction of Section~\ref{closure-restr-sec}
can be enforced by replacing the $\B$ in the premise by $\B_0+\of{\G}{\B}$.
\item{(\ref{sequence-sigdec-rule})}
A signature declaration does not create any new structures
or types; hence the use of $+$ instead of $\oplus$.
\end{description}
}
\rulesec{Signature Bindings}{\B\ts\sigbind\ra\G}
\begin{equation} % signature binding
\label{sigbind-rule}
\frac{ \B\ts\sigexp\ra\sig
\qquad\langle\B\ts\sigbind\ra\G\rangle }
{ \B\ts\sigbinder\ra\{\sigid\mapsto\sig\}
\ \langle +\ \G\rangle }\index{42.1}
\end{equation}
\deletion{\thenostrsharing}{\comment The condition that $\sig$ be equality-principal,
implicit in the first premise, ensures that the
signature found is as general as possible given the sharing
constraints present in $\sigexp$.}
%
% Specifications
\rulesec{Specifications}{\B\ts\spec\ra\E}
\begin{equation} % value specification
\label{valspec-rule}
\frac{ \of{\C}{\B}\ts\valdesc\ra\VE }
{ \B\ts\valspec\ra\cl{}{\VE}\ \In\ \Env }\index{42.2}
\end{equation}
\replacement{\thenostrsharing}{
\begin{equation} % type specification
\label{typespec-rule}
\frac{ \of{\C}{\B}\ts\typdesc\ra\TE }
{ \B\ts\typespec\ra\TE\ \In\ \Env }
\end{equation}}{\begin{equation} % type specification
\label{typespec-rule}
\frac{
\of{\C}{\B}\ts\typdesc\ra\TE \quad
\forall(\t,\VE)\in\Ran\TE,\hbox{\ $t$ does not admit equality}
}
{ \B\ts\typespec\ra\TE\ \In\ \Env }
\end{equation}}
\replacement{\thenostrsharing}{
\begin{equation} % eqtype specification
\label{eqtypspec-rule}
\frac{ \of{\C}{\B}\ts\typdesc\ra\TE \qquad
\forall(\theta,\CE)\in \Ran\TE,\ \theta {\rm\ admits\ equality} }
{ \B\ts\eqtypespec\ra\TE\ \In\ \Env }
\end{equation}}{\begin{equation} % eqtype specification
\label{eqtypspec-rule}
\frac{ \of{\C}{\B}\ts\typdesc\ra\TE \qquad
\forall(\t,\VE)\in \Ran\TE,\ \t {\rm\ admits\ equality} }
{ \B\ts\eqtypespec\ra\TE\ \In\ \Env }
\end{equation}}
\replacement{\thenostrsharing}{
\begin{equation} % data specification
\label{datatypespec-rule}
\frac{ \plusmap{\of{\C}{\B}}{\TE}\ts\datdesc\ra\VE,\TE }
{ \B\ts\datatypespec\ra(\VE,\TE)\ \In\ \Env }
\end{equation}}{
\begin{equation} % data specification
\label{datatypespec-rule}
\frac{ \begin{array}{c}
\of{\C}{\B}\oplus\TE\ts\datdesc\ra\VE,\TE
\quad \forall(\t,\VE')\in\Ran\TE, \t\notin\of{\T}{\B}\\
\hbox{$\TE$ maximises equality}
\end{array}}
{ \B\ts\datatypespec\ra(\VE,\TE)\ \In\ \Env }
\end{equation}}
\insertion{\thedatatyperepl}{\begin{equation}
\label{datatypereplspec-rule}
\frac{ \B(\longtycon) = (\typefcn,\VE)\qquad
\TE = \{\tycon\mapsto(\typefcn,\VE)\}
}
{\B\ts\datatypereplspec\ra (\VE,\TE)\ \In\ \Env}
\end{equation}}
\replacement{\theidstatus}{
\begin{equation} % exception specification
\label{exceptionspec-rule}
\frac{ \of{\C}{\B}\ts\exndesc\ra\EE\quad\VE=\EE }
{ \B\ts\exceptionspec\ra(\VE,\EE)\ \In\ \Env }
\end{equation}}{\begin{equation} % exception specification
\label{exceptionspec-rule}
\frac{ \of{\C}{\B}\ts\exndesc\ra\VE }
{ \B\ts\exceptionspec\ra\VE\ \In\ \Env }
\end{equation}}
\begin{equation} % structure specification
%\label{structurespec-rule}
\frac{ \B\ts\strdesc\ra\SE }
{ \B\ts\structurespec\ra\SE\ \In\ \Env }
\end{equation}
\oldpagebreak
\deletion{\thetypabbr}{
\begin{equation} % sharing specification
%\label{sharingspec-rule}
\frac{ \B\ts\shareq\ra\emptymap }
{ \B\ts\sharingspec\ra\emptymap\ \In\ \Env }\index{42.3}
\end{equation}}
\deletion{\thenolocalspec}{\begin{equation} % local specification
%\label{localspec-rule}
\frac{ \B\ts\spec_1\ra\E_1 \qquad \plusmap{\B}{\E_1}\ts\spec_2\ra\E_2 }
{ \B\ts\localspec\ra\E_2 }
\end{equation}}
\deletion{\thenoopenspec}{\begin{equation} % open specification
%\label{openspec-rule}
\frac{ \B(\longstrid_1)=(\m_1,\E_1)\quad\cdots\quad
\B(\longstrid_n)=(\m_n,\E_n) }
{ \B\ts\openspec\ra\E_1 + \cdots +\E_n }
\end{equation}}
\replacement{\thesingleincludespec}{\begin{equation} % include signature specification
\label{inclspec-rule}
\frac{ \sigord{\B(\sigid_1)}{}{(\m_1,\E_1)} \quad\cdots\quad
\sigord{\B(\sigid_n)}{}{(\m_n,\E_n)} }
{ \B\ts\inclspec\ra\E_1 + \cdots +\E_n }
\end{equation}}{\begin{equation} % include signature specification
\label{inclspec-rule}
\frac{ \B\ts\sigexp\ra\E}
{ \B\ts\singleinclspec\ra\E }
\end{equation}}
\begin{equation} % empty specification
%\label{emptyspec-rule}
\frac{}
{ \B\ts\emptyspec\ra\emptymap{\rm\ in}\ \Env }
\end{equation}
\replacement{\thenostrsharing}{
\begin{equation} % sequential specification
%\label{seqspec-rule}
\frac{ \B\ts\spec_1\ra\E_1 \qquad \plusmap{\B}{\E_1}\ts\spec_2\ra\E_2 }
{ \B\ts\seqspec\ra\plusmap{\E_1}{\E_2} }
\end{equation}}{\begin{equation} % sequential specification
\label{seqspec-rule}
\frac{ \B\ts\spec_1\ra\E_1 \qquad \B\oplus\E_1\ts\spec_2\ra\E_2\qquad\Dom(\E_1)\cap\Dom(\E_2) = \emptyset }
{ \B\ts\seqspec\ra\plusmap{\E_1}{\E_2} }
\end{equation}}
\insertion{\thetypabbr}{
\begin{equation}
\label{sharspec-rule}
\frac{\begin{array}{c}
\B\ts \spec \ra \E\quad \E(\longtycon_i) = (\t_i,\VE_i), \;i = 1..n\\
t\in\{\t_1,\ldots,\t_n\}\quad\hbox{$\t$ admits equality, if some $\t_i$ does}\\
\{\t_1,\ldots,\t_n\}\cap\of{\T}{\B} = \emptyset\quad
\rea = \{\t_1\mapsto\t,\ldots,\t_n\mapsto \t\}
\end{array}
}
{\B\ts \newsharingspec\ra \rea(\E)}
\end{equation}}
\comments
\begin{description}
\item{(\ref{valspec-rule})}
$\VE$ is determined by $\B$ and $\valdesc$.
\item{(\ref{typespec-rule})--(\ref{datatypespec-rule})}
\replacement{\thenostrsharing}{The type functions in $\TE$ may be chosen to achieve the sharing hypothesis
of rule~\ref{typshareq-rule} or the enrichment conditions of
rules~\ref{structure-binding-rule} and~\ref{funbind-rule}. In particular, the type
names in $\TE$ in rule~\ref{datatypespec-rule} need not be new.
Also, in rule~\ref{typespec-rule} the type functions in $\TE$ may admit
equality.}{The type
names in $\TE$ are new.}
%
\item{(\ref{exceptionspec-rule})}
\replacement{\theidstatus}{$\EE$}{$\VE$} is determined by $\B$ and $\exndesc$ and contains monotypes only.
\deletion{\thenostrsharing}{\item{(\ref{inclspec-rule})}
The names $\m_i$ in the instances may be chosen to achieve sharing or
enrichment conditions.\index{43.0}}
\insertion{\thenostrsharing}{\item{(\ref{seqspec-rule})}
Note that no sequential specification is allowed to specify the
same identifier twice.}
\end{description}
% Descriptions
\rulesec{Value Descriptions}{\C\ts\valdesc\ra\VE}
\replacement{\theidstatus}{
\begin{equation} % value description
%\label{valdesc-rule}
\frac{ \C\ts\ty\ra\tau\qquad
\langle\C\ts\valdesc\ra\VE\rangle }
{ \C\ts\valdescription\ra\{\var\mapsto\tau\}
\ \langle +\ \VE\rangle }\index{43.1}
\end{equation}}{\begin{equation} % value description
%\label{valdesc-rule}
\frac{ \C\ts\ty\ra\tau\qquad
\langle\C\ts\valdesc\ra\VE\rangle }
{ \C\ts\valviddescription\ra\{\vid\mapsto(\tau,\isv)\}
\ \langle +\ \VE\rangle }\index{43.1}
\end{equation}}
\rulesec{Type Descriptions}{\C\ts\typdesc\ra\TE}
\replacement{\thenostrsharing}{
\begin{equation} % type description
\label{typdesc-rule}
\frac{ \tyvarseq = \alphak
\qquad\langle \C\ts\typdesc\ra\TE\rangle\qquad\arity\theta=k }
{ \C\ts\typdescription\ra\{\tycon\mapsto(\theta,\emptymap)\}
\ \langle +\ \TE\rangle }\index{43.2}
\end{equation}}{\begin{equation} % type description
\label{typdesc-rule}
\frac{ \begin{array}{c}
\tyvarseq = \alphak\quad\t\notin\of{\T}{\C}\quad\arity\t=k \\
\langle \C\ts\typdesc\ra\TE\qquad\t\notin\TyNamesFcn\TE\rangle
\end{array}}
{ \C\ts\typdescription\ra\{\tycon\mapsto(\t,\emptymap)\}
\ \langle +\ \TE\rangle }\index{43.2}
\end{equation}}
\comment Note that \deletion{\thenostrsharing}{any $\theta$ of arity $k$ may be chosen but that}