Rewrite pattern typing operators with \eqdefa

This commit is contained in:
regnat 2017-04-27 08:29:04 +02:00
parent 11b4947f07
commit ee998adb40

View File

@ -13,34 +13,59 @@ $p$ (in figure~\pref{typing::pattern-ty-match}).
The typing rules are given by the figures~\pref{typing::lambda-calculus},~\pref{typing::records} and~\pref{typing::operators}.
\begin{figure}
\begin{align*}
\matchType{x} &= \any \\
\matchType{q@x} &= \matchType{q} \\
\matchType{\{ f_1, \cdots, f_n \}} &= \{ \matchType{f_1}; \cdots \matchType{f_n}; \} \\
\matchType{l} &= l : \any \\
\matchType{l ? e} &= l : \any \vee \undef \\
\matchType{\text{Cons}(x_1, x_2)} &= \text{Cons}(\any, \any)
\end{align*}
\begin{center}
\begin{tabular}{rl}
\eqdefa{$\matchType{x}$}{$\any$}{}
\eqdefa{$\matchType{q@x}$}{$\matchType{q}$}{}
\eqdefa{$\matchType{\{ f_1, \cdots, f_n \}}$}%
{$\{ \matchType{f_1}; \cdots \matchType{f_n}; \}$}{}
\eqdefa{$\matchType{l}$}{$l = \any$}{}
\eqdefa{$\matchType{l ? e}$}{$l = \any \vee \undef$}{}
\eqdefa{$\matchType{\text{Cons}(x_1, x_2)}$}{$\text{Cons}(\any, \any)$}{}
\end{tabular}
\end{center}
\caption{Semantics of the $\matchType{\_}$ operator%
\label{typing::pattern-accept}}
\end{figure}
ii\begin{figure}
\begin{align*}
\ofTypeP{x}{} &= \sfrac{x}{} &\\
\ofTypeP{q@x}{} &= \sfrac{x}{}; \ofTypeP{q}{x} &\\
\ofTypeP{\{\}}{\{ x_1 ? c_1, \cdots, x_n ? c_n \}} &=%
\sfrac{x_1}{\mathcal{B}(c_1)}; \cdots; \sfrac{x_n}{\mathcal{B}(c_n)} &\\
\ofTypeP{\{ s_1 = _1; \cdots; s_m = _m; \}}{\{x_1 ? c_1, \cdots, x_n ? c_n, \textbf{\ldots}\}} &=%
\sfrac{x_1}{\mathcal{B}(c_1)}; \cdots; \sfrac{x_n}{\mathcal{B}(c_n)} &%
\text{ if } \forall (i,j) \in \discrete{1}{m} \times \discrete{1}{n}, s_i \neq s_j\\
\ofTypeP{\{ s = ;\}}{\{ x \}} &= \sfrac{x}{}; &\text{ if $s$ = $x$} \\
\ofTypeP{\{ s = ;\}}{\{ x ? c \}} &= \sfrac{x}{}; &\text{ if $s$ = $x$} \\
\ofTypeP{\{ s_1 = _1; \cdots; s_n = _n \}}{\{ x, f_1, \cdots, f_m \}} &=%
\sfrac{x}{}; \ofTypeP{\{ s_2 = _2; \cdots; s_n = _n \}}{\{ f_1, \cdots, f_m \}} &\text{ if $s_1$ = $x$} \\
\ofTypeP{\{ s_1 = _1; \cdots; s_n = _n \}}{\{ x ? c, f_1 \cdots, f_m \}} &=%
\sfrac{x}{}; \ofTypeP{\{ s_2 = _2; \cdots; s_n = _n \}}{\{ f_1, \cdots, f_m \}} &\text{ if $s_1$ = $x$} \\
\ofTypeP{\text{Cons}(_1, _2)}{\text{Cons}(x_1, x_2)} &= \sfrac{x_1}{_1}; \sfrac{x_2}{_2} &\\
\end{align*}
\begin{tabular}{rl}
\eqdefa{$\ofTypeP{x}{}$}{$\sfrac{x}{}$}{}
\eqdefa{$\ofTypeP{q@x}{}$}{$\sfrac{x}{}; \ofTypeP{q}{x}$}{}
\eqdefa{$\ofTypeP{\{\}}{\{ x_1 ? c_1, \cdots, x_n ? c_n \}}$}{%
$\sfrac{x_1}{\mathcal{B}(c_1)}; \cdots; \sfrac{x_n}{\mathcal{B}(c_n)}$}{}
\eqdefa{%
$\ofTypeP{%
\{ s_1 = _1; \cdots; s_m = _m; \}%
}{%
\{x_1 ? c_1, \cdots, x_n ? c_n, \textbf{\ldots}\}%
}$%
}{%
$\sfrac{x_1}{\mathcal{B}(c_1)}; \cdots; \sfrac{x_n}{\mathcal{B}(c_n)}$%
}{%
if %
$\forall (i,j) \in \discrete{1}{m} \times \discrete{1}{n}, s_i \neq s_j$%
}
\eqdefa{$\ofTypeP{\{ s = ;\}}{\{ x \}}$}{$\sfrac{x}{}$}{if $s = x$}
\eqdefa{$\ofTypeP{\{ s = ;\}}{\{ x ? c \}}$}{$\sfrac{x}{}$}{if $s = x$}
\eqdefa{$%
\ofTypeP{\{ s_1 = _1; \cdots; s_n = _n \}}{\{ x, f_1, \cdots, f_m \}}%
$}{$%
\sfrac{x}{};%
\ofTypeP{\{ s_2 = _2; \cdots; s_n = _n \}}{\{ f_1, \cdots, f_m \}}%
$}{if $s_1 = x$}
\eqdefa{
$\ofTypeP{%
\{ s_1 = _1; \cdots; s_n = _n \}}%
{\{ x ? c, f_1 \cdots, f_m \}}$%
}{%
$\sfrac{x}{};%
\ofTypeP{\{ s_2 = _2; \cdots; s_n = _n \}}%
{\{ f_1, \cdots, f_m \}}$%
}{if $s_1 = x$}
\eqdefa{%
$\ofTypeP{\text{Cons}(_1, _2)}{\text{Cons}(x_1, x_2)}$%
}{$\sfrac{x_1}{_1}; \sfrac{x_2}{_2}$}{}
\end{tabular}
\caption{Semantics of $\ofTypeP{p}{}$%
\label{typing::pattern-ty-match}}
\end{figure}