Mercurial > urweb
comparison doc/manual.tex @ 537:a4a7cd341a1b
Signature compatibility
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 29 Nov 2008 13:50:53 -0500 |
parents | e32d0f6a1e15 |
children | a9fba52dfce4 |
comparison
equal
deleted
inserted
replaced
536:e32d0f6a1e15 | 537:a4a7cd341a1b |
---|---|
242 \item $\Gamma \vdash c \sim c$ proves the disjointness of two record constructors; that is, that they share no field names. We overload the judgment to apply to pairs of field names as well. | 242 \item $\Gamma \vdash c \sim c$ proves the disjointness of two record constructors; that is, that they share no field names. We overload the judgment to apply to pairs of field names as well. |
243 \item $\Gamma \vdash c \hookrightarrow C$ proves that record constructor $c$ decomposes into set $C$ of field names and record constructors. | 243 \item $\Gamma \vdash c \hookrightarrow C$ proves that record constructor $c$ decomposes into set $C$ of field names and record constructors. |
244 \item $\Gamma \vdash c \equiv c$ proves the computational equivalence of two constructors. This is often called a \emph{definitional equality} in the world of type theory. | 244 \item $\Gamma \vdash c \equiv c$ proves the computational equivalence of two constructors. This is often called a \emph{definitional equality} in the world of type theory. |
245 \item $\Gamma \vdash e : \tau$ is a standard typing judgment. | 245 \item $\Gamma \vdash e : \tau$ is a standard typing judgment. |
246 \item $\Gamma \vdash p \leadsto \Gamma; \tau$ combines typing of patterns with calculation of which new variables they bind. | 246 \item $\Gamma \vdash p \leadsto \Gamma; \tau$ combines typing of patterns with calculation of which new variables they bind. |
247 \item $\Gamma \vdash d \leadsto \Gamma$ expresses how a declaration modifies a context. We overload this judgment to apply to sequences of declarations. | 247 \item $\Gamma \vdash d \leadsto \Gamma$ expresses how a declaration modifies a context. We overload this judgment to apply to sequences of declarations, as well as to signature items and sequences of signature items. |
248 \item $\Gamma \vdash S \equiv S$ is the signature equivalence judgment. | |
248 \item $\Gamma \vdash S \leq S$ is the signature compatibility judgment. We write $\Gamma \vdash S$ as shorthand for $\Gamma \vdash S \leq S$. | 249 \item $\Gamma \vdash S \leq S$ is the signature compatibility judgment. We write $\Gamma \vdash S$ as shorthand for $\Gamma \vdash S \leq S$. |
249 \item $\Gamma \vdash M : S$ is the module signature checking judgment. | 250 \item $\Gamma \vdash M : S$ is the module signature checking judgment. |
250 \item $\mt{proj}(M, S, V)$ is a partial function for projecting a signature item from a signature $S$, given the module $M$ that we project from. $V$ may be $\mt{con} \; x$, $\mt{datatype} \; x$, $\mt{val} \; x$, $\mt{signature} \; X$, or $\mt{structure} \; X$. The parameter $M$ is needed because the projected signature item may refer to other items of $S$. | 251 \item $\mt{proj}(M, \overline{s}, V)$ is a partial function for projecting a signature item from $\overline{s}$, given the module $M$ that we project from. $V$ may be $\mt{con} \; x$, $\mt{datatype} \; x$, $\mt{val} \; x$, $\mt{signature} \; X$, or $\mt{structure} \; X$. The parameter $M$ is needed because the projected signature item may refer to other items from $\overline{s}$. |
251 \end{itemize} | 252 \end{itemize} |
252 | 253 |
253 \subsection{Kinding} | 254 \subsection{Kinding} |
254 | 255 |
255 $$\infer{\Gamma \vdash (c) :: \kappa :: \kappa}{ | 256 $$\infer{\Gamma \vdash (c) :: \kappa :: \kappa}{ |
261 \quad \infer{\Gamma \vdash x :: \kappa}{ | 262 \quad \infer{\Gamma \vdash x :: \kappa}{ |
262 x :: \kappa = c \in \Gamma | 263 x :: \kappa = c \in \Gamma |
263 }$$ | 264 }$$ |
264 | 265 |
265 $$\infer{\Gamma \vdash M.x :: \kappa}{ | 266 $$\infer{\Gamma \vdash M.x :: \kappa}{ |
266 \Gamma \vdash M : S | 267 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
267 & \mt{proj}(M, S, \mt{con} \; x) = \kappa | 268 & \mt{proj}(M, \overline{s}, \mt{con} \; x) = \kappa |
268 } | 269 } |
269 \quad \infer{\Gamma \vdash M.x :: \kappa}{ | 270 \quad \infer{\Gamma \vdash M.x :: \kappa}{ |
270 \Gamma \vdash M : S | 271 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
271 & \mt{proj}(M, S, \mt{con} \; x) = (\kappa, c) | 272 & \mt{proj}(M, \overline{s}, \mt{con} \; x) = (\kappa, c) |
272 }$$ | 273 }$$ |
273 | 274 |
274 $$\infer{\Gamma \vdash \tau_1 \to \tau_2 :: \mt{Type}}{ | 275 $$\infer{\Gamma \vdash \tau_1 \to \tau_2 :: \mt{Type}}{ |
275 \Gamma \vdash \tau_1 :: \mt{Type} | 276 \Gamma \vdash \tau_1 :: \mt{Type} |
276 & \Gamma \vdash \tau_2 :: \mt{Type} | 277 & \Gamma \vdash \tau_2 :: \mt{Type} |
372 | 373 |
373 $$\infer{\Gamma \vdash x \equiv c}{ | 374 $$\infer{\Gamma \vdash x \equiv c}{ |
374 x :: \kappa = c \in \Gamma | 375 x :: \kappa = c \in \Gamma |
375 } | 376 } |
376 \quad \infer{\Gamma \vdash M.x \equiv c}{ | 377 \quad \infer{\Gamma \vdash M.x \equiv c}{ |
377 \Gamma \vdash M : S | 378 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
378 & \mt{proj}(M, S, \mt{con} \; x) = (\kappa, c) | 379 & \mt{proj}(M, \overline{s}, \mt{con} \; x) = (\kappa, c) |
379 } | 380 } |
380 \quad \infer{\Gamma \vdash (\overline c).i \equiv c_i}{}$$ | 381 \quad \infer{\Gamma \vdash (\overline c).i \equiv c_i}{}$$ |
381 | 382 |
382 $$\infer{\Gamma \vdash (\lambda x :: \kappa \Rightarrow c) \; c' \equiv [x \mapsto c'] c}{} | 383 $$\infer{\Gamma \vdash (\lambda x :: \kappa \Rightarrow c) \; c' \equiv [x \mapsto c'] c}{} |
383 \quad \infer{\Gamma \vdash c_1 \rc c_2 \equiv c_2 \rc c_1}{} | 384 \quad \infer{\Gamma \vdash c_1 \rc c_2 \equiv c_2 \rc c_1}{} |
415 | 416 |
416 $$\infer{\Gamma \vdash x : \mathcal I(\tau)}{ | 417 $$\infer{\Gamma \vdash x : \mathcal I(\tau)}{ |
417 x : \tau \in \Gamma | 418 x : \tau \in \Gamma |
418 } | 419 } |
419 \quad \infer{\Gamma \vdash M.x : \mathcal I(\tau)}{ | 420 \quad \infer{\Gamma \vdash M.x : \mathcal I(\tau)}{ |
420 \Gamma \vdash M : S | 421 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
421 & \mt{proj}(M, S, \mt{val} \; x) = \tau | 422 & \mt{proj}(M, \overline{s}, \mt{val} \; x) = \tau |
422 } | 423 } |
423 \quad \infer{\Gamma \vdash X : \mathcal I(\tau)}{ | 424 \quad \infer{\Gamma \vdash X : \mathcal I(\tau)}{ |
424 X : \tau \in \Gamma | 425 X : \tau \in \Gamma |
425 } | 426 } |
426 \quad \infer{\Gamma \vdash M.X : \mathcal I(\tau)}{ | 427 \quad \infer{\Gamma \vdash M.X : \mathcal I(\tau)}{ |
427 \Gamma \vdash M : S | 428 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
428 & \mt{proj}(M, S, \mt{val} \; X) = \tau | 429 & \mt{proj}(M, \overline{s}, \mt{val} \; X) = \tau |
429 }$$ | 430 }$$ |
430 | 431 |
431 $$\infer{\Gamma \vdash e_1 \; e_2 : \tau_2}{ | 432 $$\infer{\Gamma \vdash e_1 \; e_2 : \tau_2}{ |
432 \Gamma \vdash e_1 : \tau_1 \to \tau_2 | 433 \Gamma \vdash e_1 : \tau_1 \to \tau_2 |
433 & \Gamma \vdash e_2 : \tau_1 | 434 & \Gamma \vdash e_2 : \tau_1 |
500 X : \overline{x ::: \mt{Type}} \to \tau'' \to \tau \in \Gamma | 501 X : \overline{x ::: \mt{Type}} \to \tau'' \to \tau \in \Gamma |
501 & \Gamma \vdash p \leadsto \Gamma'; \overline{[x_i \mapsto \tau'_i]}\tau'' | 502 & \Gamma \vdash p \leadsto \Gamma'; \overline{[x_i \mapsto \tau'_i]}\tau'' |
502 }$$ | 503 }$$ |
503 | 504 |
504 $$\infer{\Gamma \vdash M.X \leadsto \Gamma; \overline{[x_i \mapsto \tau'_i]}\tau}{ | 505 $$\infer{\Gamma \vdash M.X \leadsto \Gamma; \overline{[x_i \mapsto \tau'_i]}\tau}{ |
505 \Gamma \vdash M : S | 506 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
506 & \mt{proj}(M, S, \mt{val} \; X) = \overline{x ::: \mt{Type}} \to \tau | 507 & \mt{proj}(M, \overline{s}, \mt{val} \; X) = \overline{x ::: \mt{Type}} \to \tau |
507 & \textrm{$\tau$ not a function type} | 508 & \textrm{$\tau$ not a function type} |
508 }$$ | 509 }$$ |
509 | 510 |
510 $$\infer{\Gamma \vdash M.X \; p \leadsto \Gamma'; \overline{[x_i \mapsto \tau'_i]}\tau}{ | 511 $$\infer{\Gamma \vdash M.X \; p \leadsto \Gamma'; \overline{[x_i \mapsto \tau'_i]}\tau}{ |
511 \Gamma \vdash M : S | 512 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
512 & \mt{proj}(M, S, \mt{val} \; X) = \overline{x ::: \mt{Type}} \to \tau'' \to \tau | 513 & \mt{proj}(M, \overline{s}, \mt{val} \; X) = \overline{x ::: \mt{Type}} \to \tau'' \to \tau |
513 & \Gamma \vdash p \leadsto \Gamma'; \overline{[x_i \mapsto \tau'_i]}\tau'' | 514 & \Gamma \vdash p \leadsto \Gamma'; \overline{[x_i \mapsto \tau'_i]}\tau'' |
514 }$$ | 515 }$$ |
515 | 516 |
516 $$\infer{\Gamma \vdash \{\overline{x = p}\} \leadsto \Gamma_n; \{\overline{x = \tau}\}}{ | 517 $$\infer{\Gamma \vdash \{\overline{x = p}\} \leadsto \Gamma_n; \{\overline{x = \tau}\}}{ |
517 \Gamma_0 = \Gamma | 518 \Gamma_0 = \Gamma |
526 | 527 |
527 We use an auxiliary judgment $\overline{y}; x; \Gamma \vdash \overline{dc} \leadsto \Gamma'$, expressing the enrichment of $\Gamma$ with the types of the datatype constructors $\overline{dc}$, when they are known to belong to datatype $x$ with type parameters $\overline{y}$. | 528 We use an auxiliary judgment $\overline{y}; x; \Gamma \vdash \overline{dc} \leadsto \Gamma'$, expressing the enrichment of $\Gamma$ with the types of the datatype constructors $\overline{dc}$, when they are known to belong to datatype $x$ with type parameters $\overline{y}$. |
528 | 529 |
529 This is the first judgment where we deal with type classes, for the $\mt{class}$ declaration form. We will omit their special handling in this formal specification. In the compiler, a set of available type classes and their instances is maintained, and these instances are used to fill in expression wildcards. | 530 This is the first judgment where we deal with type classes, for the $\mt{class}$ declaration form. We will omit their special handling in this formal specification. In the compiler, a set of available type classes and their instances is maintained, and these instances are used to fill in expression wildcards. |
530 | 531 |
531 We presuppose the existence of a function $\mathcal O$, where $\mathcal(M, S)$ implements the $\mt{open}$ declaration by producing a context with the appropriate entry for each available component of module $M$ with signature $S$. Where possible, $\mathcal O$ uses ``transparent'' entries (e.g., an abstract type $M.x$ is mapped to $x :: \mt{Type} = M.x$), so that the relationship with $M$ is maintained. A related function $\mathcal O_c$ builds a context containing the disjointness constraints found in $S$. | 532 We presuppose the existence of a function $\mathcal O$, where $\mathcal(M, \overline{s})$ implements the $\mt{open}$ declaration by producing a context with the appropriate entry for each available component of module $M$ with signature items $\overline{s}$. Where possible, $\mathcal O$ uses ``transparent'' entries (e.g., an abstract type $M.x$ is mapped to $x :: \mt{Type} = M.x$), so that the relationship with $M$ is maintained. A related function $\mathcal O_c$ builds a context containing the disjointness constraints found in $S$. |
533 | |
534 We write $\kappa_1^n \to \kappa$ as a shorthand, where $\kappa_1^0 \to \kappa = \kappa$ and $\kappa_1^{n+1} \to \kappa_2 = \kappa_1 \to (\kappa_1^n \to \kappa_2)$. We write $\mt{len}(\overline{y})$ for the length of vector $\overline{y}$ of variables. | |
532 | 535 |
533 $$\infer{\Gamma \vdash \cdot \leadsto \Gamma}{} | 536 $$\infer{\Gamma \vdash \cdot \leadsto \Gamma}{} |
534 \quad \infer{\Gamma \vdash d, \overline{d} \leadsto \Gamma''}{ | 537 \quad \infer{\Gamma \vdash d, \overline{d} \leadsto \Gamma''}{ |
535 \Gamma \vdash d \leadsto \Gamma' | 538 \Gamma \vdash d \leadsto \Gamma' |
536 & \Gamma' \vdash \overline{d} \leadsto \Gamma'' | 539 & \Gamma' \vdash \overline{d} \leadsto \Gamma'' |
542 \quad \infer{\Gamma \vdash \mt{datatype} \; x \; \overline{y} = \overline{dc} \leadsto \Gamma'}{ | 545 \quad \infer{\Gamma \vdash \mt{datatype} \; x \; \overline{y} = \overline{dc} \leadsto \Gamma'}{ |
543 \overline{y}; x; \Gamma, x :: \mt{Type}^{\mt{len}(\overline y)} \to \mt{Type} \vdash \overline{dc} \leadsto \Gamma' | 546 \overline{y}; x; \Gamma, x :: \mt{Type}^{\mt{len}(\overline y)} \to \mt{Type} \vdash \overline{dc} \leadsto \Gamma' |
544 }$$ | 547 }$$ |
545 | 548 |
546 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leadsto \Gamma'}{ | 549 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leadsto \Gamma'}{ |
547 \Gamma \vdash M : S | 550 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
548 & \mt{proj}(M, S, \mt{datatype} \; z) = (\overline{y}, \overline{dc}) | 551 & \mt{proj}(M, \overline{s}, \mt{datatype} \; z) = (\overline{y}, \overline{dc}) |
549 & \overline{y}; x; \Gamma, x :: \mt{Type}^{\mt{len}(\overline y)} \to \mt{Type} = M.z \vdash \overline{dc} \leadsto \Gamma' | 552 & \overline{y}; x; \Gamma, x :: \mt{Type}^{\mt{len}(\overline y)} \to \mt{Type} = M.z \vdash \overline{dc} \leadsto \Gamma' |
550 }$$ | 553 }$$ |
551 | 554 |
552 $$\infer{\Gamma \vdash \mt{val} \; x : \tau = e \leadsto \Gamma, x : \tau}{ | 555 $$\infer{\Gamma \vdash \mt{val} \; x : \tau = e \leadsto \Gamma, x : \tau}{ |
553 \Gamma \vdash e : \tau | 556 \Gamma \vdash e : \tau |
559 }$$ | 562 }$$ |
560 | 563 |
561 $$\infer{\Gamma \vdash \mt{structure} \; X : S = M \leadsto \Gamma, X : S}{ | 564 $$\infer{\Gamma \vdash \mt{structure} \; X : S = M \leadsto \Gamma, X : S}{ |
562 \Gamma \vdash M : S | 565 \Gamma \vdash M : S |
563 } | 566 } |
564 \quad \infer{\Gamma \vdash \mt{siganture} \; X = S \leadsto \Gamma, X = S}{ | 567 \quad \infer{\Gamma \vdash \mt{signature} \; X = S \leadsto \Gamma, X = S}{ |
565 \Gamma \vdash S | 568 \Gamma \vdash S |
566 }$$ | 569 }$$ |
567 | 570 |
568 $$\infer{\Gamma \vdash \mt{open} \; M \leadsto \Gamma, \mathcal O(M, S)}{ | 571 $$\infer{\Gamma \vdash \mt{open} \; M \leadsto \Gamma, \mathcal O(M, \overline{s})}{ |
569 \Gamma \vdash M : S | 572 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
570 }$$ | 573 }$$ |
571 | 574 |
572 $$\infer{\Gamma \vdash \mt{constraint} \; c_1 \sim c_2 \leadsto \Gamma}{ | 575 $$\infer{\Gamma \vdash \mt{constraint} \; c_1 \sim c_2 \leadsto \Gamma}{ |
573 \Gamma \vdash c_1 :: \{\kappa\} | 576 \Gamma \vdash c_1 :: \{\kappa\} |
574 & \Gamma \vdash c_2 :: \{\kappa\} | 577 & \Gamma \vdash c_2 :: \{\kappa\} |
575 & \Gamma \vdash c_1 \sim c_2 | 578 & \Gamma \vdash c_1 \sim c_2 |
576 } | 579 } |
577 \quad \infer{\Gamma \vdash \mt{open} \; \mt{constraints} \; M \leadsto \Gamma, \mathcal O_c(M, S)}{ | 580 \quad \infer{\Gamma \vdash \mt{open} \; \mt{constraints} \; M \leadsto \Gamma, \mathcal O_c(M, \overline{s})}{ |
578 \Gamma \vdash M : S | 581 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
579 }$$ | 582 }$$ |
580 | 583 |
581 $$\infer{\Gamma \vdash \mt{table} \; x : c \leadsto \Gamma, x : \mt{Basis}.\mt{sql\_table} \; c}{ | 584 $$\infer{\Gamma \vdash \mt{table} \; x : c \leadsto \Gamma, x : \mt{Basis}.\mt{sql\_table} \; c}{ |
582 \Gamma \vdash c :: \{\mt{Type}\} | 585 \Gamma \vdash c :: \{\mt{Type}\} |
583 } | 586 } |
597 } | 600 } |
598 \quad \infer{\overline{y}; x; \Gamma \vdash X \; \mt{of} \; \tau \mid \overline{dc} \leadsto \Gamma', X : \overline{y ::: \mt{Type}} \to \tau \to x \; \overline{y}}{ | 601 \quad \infer{\overline{y}; x; \Gamma \vdash X \; \mt{of} \; \tau \mid \overline{dc} \leadsto \Gamma', X : \overline{y ::: \mt{Type}} \to \tau \to x \; \overline{y}}{ |
599 \overline{y}; x; \Gamma \vdash \overline{dc} \leadsto \Gamma' | 602 \overline{y}; x; \Gamma \vdash \overline{dc} \leadsto \Gamma' |
600 }$$ | 603 }$$ |
601 | 604 |
605 \subsection{Signature Item Typing} | |
606 | |
607 We appeal to a signature item analogue of the $\mathcal O$ function from the last subsection. | |
608 | |
609 $$\infer{\Gamma \vdash \cdot \leadsto \Gamma}{} | |
610 \quad \infer{\Gamma \vdash s, \overline{s} \leadsto \Gamma''}{ | |
611 \Gamma \vdash s \leadsto \Gamma' | |
612 & \Gamma' \vdash \overline{s} \leadsto \Gamma'' | |
613 }$$ | |
614 | |
615 $$\infer{\Gamma \vdash \mt{con} \; x :: \kappa \leadsto \Gamma, x :: \kappa}{} | |
616 \quad \infer{\Gamma \vdash \mt{con} \; x :: \kappa = c \leadsto \Gamma, x :: \kappa = c}{ | |
617 \Gamma \vdash c :: \kappa | |
618 } | |
619 \quad \infer{\Gamma \vdash \mt{datatype} \; x \; \overline{y} = \overline{dc} \leadsto \Gamma'}{ | |
620 \overline{y}; x; \Gamma, x :: \mt{Type}^{\mt{len}(\overline y)} \to \mt{Type} \vdash \overline{dc} \leadsto \Gamma' | |
621 }$$ | |
622 | |
623 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leadsto \Gamma'}{ | |
624 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} | |
625 & \mt{proj}(M, \overline{s}, \mt{datatype} \; z) = (\overline{y}, \overline{dc}) | |
626 & \overline{y}; x; \Gamma, x :: \mt{Type}^{\mt{len}(\overline y)} \to \mt{Type} = M.z \vdash \overline{dc} \leadsto \Gamma' | |
627 }$$ | |
628 | |
629 $$\infer{\Gamma \vdash \mt{val} \; x : \tau \leadsto \Gamma, x : \tau}{ | |
630 \Gamma \vdash \tau :: \mt{Type} | |
631 }$$ | |
632 | |
633 $$\infer{\Gamma \vdash \mt{structure} \; X : S \leadsto \Gamma, X : S}{ | |
634 \Gamma \vdash S | |
635 } | |
636 \quad \infer{\Gamma \vdash \mt{signature} \; X = S \leadsto \Gamma, X = S}{ | |
637 \Gamma \vdash S | |
638 }$$ | |
639 | |
640 $$\infer{\Gamma \vdash \mt{include} \; S \leadsto \Gamma, \mathcal O(\overline{s})}{ | |
641 \Gamma \vdash S | |
642 & \Gamma \vdash S \equiv \mt{sig} \; \overline{s} \; \mt{end} | |
643 }$$ | |
644 | |
645 $$\infer{\Gamma \vdash \mt{constraint} \; c_1 \sim c_2 \leadsto \Gamma, c_1 \sim c_2}{ | |
646 \Gamma \vdash c_1 :: \{\kappa\} | |
647 & \Gamma \vdash c_2 :: \{\kappa\} | |
648 }$$ | |
649 | |
650 $$\infer{\Gamma \vdash \mt{class} \; x = c \leadsto \Gamma, x :: \mt{Type} \to \mt{Type} = c}{ | |
651 \Gamma \vdash c :: \mt{Type} \to \mt{Type} | |
652 } | |
653 \quad \infer{\Gamma \vdash \mt{class} \; x \leadsto \Gamma, x :: \mt{Type} \to \mt{Type}}{}$$ | |
654 | |
602 \subsection{Signature Compatibility} | 655 \subsection{Signature Compatibility} |
656 | |
657 To simplify the judgments in this section, we assume that all signatures are alpha-varied as necessary to avoid including mmultiple bindings for the same identifier. This is in addition to the usual alpha-variation of locally-bound variables. | |
658 | |
659 We rely on a judgment $\Gamma \vdash \overline{s} \leq s'$, which expresses the occurrence in signature items $\overline{s}$ of an item compatible with $s'$. We also use a judgment $\Gamma \vdash \overline{dc} \leq \overline{dc}$, which expresses compatibility of datatype definitions. | |
603 | 660 |
604 $$\infer{\Gamma \vdash S \equiv S}{} | 661 $$\infer{\Gamma \vdash S \equiv S}{} |
605 \quad \infer{\Gamma \vdash S_1 \equiv S_2}{ | 662 \quad \infer{\Gamma \vdash S_1 \equiv S_2}{ |
606 \Gamma \vdash S_2 \equiv S_1 | 663 \Gamma \vdash S_2 \equiv S_1 |
607 } | 664 } |
608 \quad \infer{\Gamma \vdash X \equiv S}{ | 665 \quad \infer{\Gamma \vdash X \equiv S}{ |
609 X = S \in \Gamma | 666 X = S \in \Gamma |
610 } | 667 } |
611 \quad \infer{\Gamma \vdash M.X \equiv S}{ | 668 \quad \infer{\Gamma \vdash M.X \equiv S}{ |
612 \Gamma \vdash M : S' | 669 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} |
613 & \mt{proj}(M, S', \mt{signature} \; X) = S | 670 & \mt{proj}(M, \overline{s}, \mt{signature} \; X) = S |
614 }$$ | 671 }$$ |
615 | 672 |
616 $$\infer{\Gamma \vdash S \; \mt{where} \; \mt{con} \; x = c \equiv \mt{sig} \; \overline{s^1} \; \mt{con} \; x :: \kappa = c \; \overline{s_2} \; \mt{end}}{ | 673 $$\infer{\Gamma \vdash S \; \mt{where} \; \mt{con} \; x = c \equiv \mt{sig} \; \overline{s^1} \; \mt{con} \; x :: \kappa = c \; \overline{s_2} \; \mt{end}}{ |
617 \Gamma \vdash S \equiv \mt{sig} \; \overline{s^1} \; \mt{con} \; x :: \kappa \; \overline{s_2} \; \mt{end} | 674 \Gamma \vdash S \equiv \mt{sig} \; \overline{s^1} \; \mt{con} \; x :: \kappa \; \overline{s_2} \; \mt{end} |
618 & \Gamma \vdash c :: \kappa | 675 & \Gamma \vdash c :: \kappa |
676 } | |
677 \quad \infer{\Gamma \vdash \mt{sig} \; \overline{s^1} \; \mt{include} \; S \; \overline{s^2} \; \mt{end} \equiv \mt{sig} \; \overline{s^1} \; \overline{s} \; \overline{s^2} \; \mt{end}}{ | |
678 \Gamma \vdash S \equiv \mt{sig} \; \overline{s} \; \mt{end} | |
619 }$$ | 679 }$$ |
620 | 680 |
621 $$\infer{\Gamma \vdash S_1 \leq S_2}{ | 681 $$\infer{\Gamma \vdash S_1 \leq S_2}{ |
622 \Gamma \vdash S_1 \equiv S_2 | 682 \Gamma \vdash S_1 \equiv S_2 |
623 } | 683 } |
624 \quad \infer{\Gamma \vdash \mt{sig} \; \overline{s} \; \mt{end} \leq \mt{sig} \; \mt{end}}{} | 684 \quad \infer{\Gamma \vdash \mt{sig} \; \overline{s} \; \mt{end} \leq \mt{sig} \; \mt{end}}{} |
625 \quad \infer{\Gamma \vdash \mt{sig} \; \overline{s^1} \; s \; \overline{s^2} \; \mt{end} \leq \mt{sig} \; s' \; \overline{s} \; \mt{end}}{ | 685 \quad \infer{\Gamma \vdash \mt{sig} \; \overline{s} \; \mt{end} \leq \mt{sig} \; s' \; \overline{s'} \; \mt{end}}{ |
626 \Gamma \vdash s \leq s'; \Gamma' | 686 \Gamma \vdash \overline{s} \leq s' |
627 & \Gamma' \vdash \mt{sig} \; \overline{s^1} \; s \; \overline{s^2} \; \mt{end} \leq \mt{sig} \; \overline{s} \; \mt{end} | 687 & \Gamma \vdash s' \leadsto \Gamma' |
688 & \Gamma' \vdash \mt{sig} \; \overline{s} \; \mt{end} \leq \mt{sig} \; \overline{s'} \; \mt{end} | |
689 }$$ | |
690 | |
691 $$\infer{\Gamma \vdash s \; \overline{s} \leq s'}{ | |
692 \Gamma \vdash s \leq s' | |
693 } | |
694 \quad \infer{\Gamma \vdash s \; \overline{s} \leq s'}{ | |
695 \Gamma \vdash s \leadsto \Gamma' | |
696 & \Gamma' \vdash \overline{s} \leq s' | |
628 }$$ | 697 }$$ |
629 | 698 |
630 $$\infer{\Gamma \vdash \mt{functor} (X : S_1) : S_2 \leq \mt{functor} (X : S'_1) : S'_2}{ | 699 $$\infer{\Gamma \vdash \mt{functor} (X : S_1) : S_2 \leq \mt{functor} (X : S'_1) : S'_2}{ |
631 \Gamma \vdash S'_1 \leq S_1 | 700 \Gamma \vdash S'_1 \leq S_1 |
632 & \Gamma, X : S'_1 \vdash S_2 \leq S'_2 | 701 & \Gamma, X : S'_1 \vdash S_2 \leq S'_2 |
633 }$$ | 702 }$$ |
634 | 703 |
704 $$\infer{\Gamma \vdash \mt{con} \; x :: \kappa \leq \mt{con} \; x :: \kappa}{} | |
705 \quad \infer{\Gamma \vdash \mt{con} \; x :: \kappa = c \leq \mt{con} \; x :: \kappa}{} | |
706 \quad \infer{\Gamma \vdash \mt{datatype} \; x \; \overline{y} = \overline{dc} \leq \mt{con} \; x :: \mt{Type}}{}$$ | |
707 | |
708 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leq \mt{con} \; x :: \mt{Type}^{\mt{len}(y)} \to \mt{Type}}{ | |
709 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} | |
710 & \mt{proj}(M, \overline{s}, \mt{datatype} \; z) = (\overline{y}, \overline{dc}) | |
711 }$$ | |
712 | |
713 $$\infer{\Gamma \vdash \mt{class} \; x \leq \mt{con} \; x :: \mt{Type} \to \mt{Type}}{} | |
714 \quad \infer{\Gamma \vdash \mt{class} \; x = c \leq \mt{con} \; x :: \mt{Type} \to \mt{Type}}{}$$ | |
715 | |
716 $$\infer{\Gamma \vdash \mt{con} \; x :: \kappa = c_1 \leq \mt{con} \; x :: \mt{\kappa} = c_2}{ | |
717 \Gamma \vdash c_1 \equiv c_2 | |
718 } | |
719 \quad \infer{\Gamma \vdash \mt{class} \; x = c_1 \leq \mt{con} \; x :: \mt{Type} \to \mt{Type} = c_2}{ | |
720 \Gamma \vdash c_1 \equiv c_2 | |
721 }$$ | |
722 | |
723 $$\infer{\Gamma \vdash \mt{datatype} \; x \; \overline{y} = \overline{dc} \leq \mt{datatype} \; x \; \overline{y} = \overline{dc'}}{ | |
724 \Gamma, \overline{y :: \mt{Type}} \vdash \overline{dc} \leq \overline{dc'} | |
725 }$$ | |
726 | |
727 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leq \mt{datatype} \; x \; \overline{y} = \overline{dc'}}{ | |
728 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} | |
729 & \mt{proj}(M, \overline{s}, \mt{datatype} \; z) = (\overline{y}, \overline{dc}) | |
730 & \Gamma, \overline{y :: \mt{Type}} \vdash \overline{dc} \leq \overline{dc'} | |
731 }$$ | |
732 | |
733 $$\infer{\Gamma \vdash \cdot \leq \cdot}{} | |
734 \quad \infer{\Gamma \vdash X; \overline{dc} \leq X; \overline{dc'}}{ | |
735 \Gamma \vdash \overline{dc} \leq \overline{dc'} | |
736 } | |
737 \quad \infer{\Gamma \vdash X \; \mt{of} \; \tau_1; \overline{dc} \leq X \; \mt{of} \; \tau_2; \overline{dc'}}{ | |
738 \Gamma \vdash \tau_1 \equiv \tau_2 | |
739 & \Gamma \vdash \overline{dc} \leq \overline{dc'} | |
740 }$$ | |
741 | |
742 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leq \mt{datatype} \; x = \mt{datatype} \; M'.z'}{ | |
743 \Gamma \vdash M.z \equiv M'.z' | |
744 }$$ | |
745 | |
746 $$\infer{\Gamma \vdash \mt{val} \; x : \tau_1 \leq \mt{val} \; x : \tau_2}{ | |
747 \Gamma \vdash \tau_1 \equiv \tau_2 | |
748 } | |
749 \quad \infer{\Gamma \vdash \mt{structure} \; X : S_1 \leq \mt{structure} \; X : S_2}{ | |
750 \Gamma \vdash S_1 \leq S_2 | |
751 } | |
752 \quad \infer{\Gamma \vdash \mt{signature} \; X = S_1 \leq \mt{signature} \; X = S_2}{ | |
753 \Gamma \vdash S_1 \leq S_2 | |
754 & \Gamma \vdash S_2 \leq S_1 | |
755 }$$ | |
756 | |
757 $$\infer{\Gamma \vdash \mt{constraint} \; c_1 \sim c_2 \leq \mt{constraint} \; c'_1 \sim c'_2}{ | |
758 \Gamma \vdash c_1 \equiv c'_1 | |
759 & \Gamma \vdash c_2 \equiv c'_2 | |
760 }$$ | |
761 | |
762 $$\infer{\Gamma \vdash \mt{class} \; x \leq \mt{class} \; x}{} | |
763 \quad \infer{\Gamma \vdash \mt{class} \; x = c \leq \mt{class} \; x}{} | |
764 \quad \infer{\Gamma \vdash \mt{class} \; x = c_1 \leq \mt{class} \; x = c_2}{ | |
765 \Gamma \vdash c_1 \equiv c_2 | |
766 }$$ | |
767 | |
635 \end{document} | 768 \end{document} |