typing: put typing rules in figures

This commit is contained in:
regnat 2017-04-25 09:45:54 +02:00
parent 2c83cb0d5c
commit 91f34b029a
3 changed files with 112 additions and 103 deletions

56
typing/lambdaCalculus.tex Normal file
View File

@ -0,0 +1,56 @@
\begin{mathpar}
\inferrule{ }{\Gamma; x:\tau \vdash x:\tau}(Var)
\and
\inferrule{ }{\Gamma \vdash c:\mathcal{B}(c)}(Const)
\and
\inferrule{%
\Gamma \vdash e_1 : \tau_1 \\ \Gamma \vdash e_2 : \tau_2 \\
\tau_1 \subtype \zero \rightarrow \one \\
\tau_2 \subtype \dom(\tau_1)
}{%
\Gamma \vdash e_1 e_2 : \tau_1 \tau_2
}
(App)
\and
\inferrule{%
\forall i \in \discrete{1}{n}, \\
\Gamma; \ofTypeP{p}{\sigma_i} \vdash e: \tau_i \\
}{%
\lambda \left(p:{\bigvee\limits_{i=1}^n\σ}\right).e :
\bigwedge\limits_{i=1}^n \left(\σ \rightarrow \right)
}
(Abs)
\and
\inferrule{%
\Gamma \vdash e : \tau \\
; x : \wedge t \vdash e_1 : \sigma_1 \\
; x : \wedge \lnot t \vdash e_2 : \sigma_2
}{%
\Gamma \vdash ((x := e \in t) ? e_1 : e_2) : \sigma_1 \vee \sigma_2
}
(Tcase)
\and
\inferrule{%
\forall i \in \discrete{1}{n}, \vdash e_i : _i \\
; x_1 : _1; \ldots; x_n : _n \vdash e :
}{%
\Gamma \vdash \text{let } x_1 = e_1; \ldots{}; x_n = e_n
\text{ in } e :
}
(Let)
\and
\inferrule{%
\forall i \in \discrete{0}{n},
; x_1 : _1; \ldots; x_n : _n \vdash e_i : _i
}{%
\Gamma \vdash \text{let rec } x_1 : _1 = e_1; \ldots{}; x_n : _n = e_n
\text{ in } e_0 : _0
}
(LetRec)
\end{mathpar}

View File

@ -1,51 +1,53 @@
\inferrule{%
\vdash e' : \\
\begin{mathpar}
\inferrule{%
\vdash e' : \\
\vdash e : \bigvee\limits_{i=1}^n s_i
}{%
\vdash \left\{ e = e'; \right\} :
}{%
\vdash \left\{ e = e'; \right\} :
\bigvee\limits_{i=1}^n \left\{ s_i: \right\}
}
\irlabel{RFinite}
\and
\inferrule{%
\vdash e' : \\
}
\irlabel{RFinite}
\and
\inferrule{%
\vdash e' : \\
\vdash e : \σ \\
\σ \subtype \ty{string}
}{%
\vdash \left\{ e = e'; \right\} :
}{%
\vdash \left\{ e = e'; \right\} :
\left\{ \_: \vee \undef \right\}
}
\irlabel{RInfinite}
\and
\inferrule{%
\vdash e_1 : \tau \\ \vdash e_2 : \σ \\
}
\irlabel{RInfinite}
\and
\inferrule{%
\vdash e_1 : \tau \\ \vdash e_2 : \σ \\
\tau \subtype \onerec{} \\
\sigma \subtype \onerec{} \\
\dom_\undef(\tau) \wedge \dom_\undef(\sigma) = \varnothing
}{%
\vdash e_1 \orthplus e_2 : \tau \orthplus \sigma
}
\irlabel{ROrthMerge}
\and
\inferrule{%
\vdash e_1 : \tau \\ \vdash e_2 : \σ \\
}{%
\vdash e_1 \orthplus e_2 : \tau \orthplus \sigma
}
\irlabel{ROrthMerge}
\and
\inferrule{%
\vdash e_1 : \tau \\ \vdash e_2 : \σ \\
\tau \subtype \onerec{} \\
\sigma \subtype \onerec{}
}{%
\vdash e_1 + e_2 : \tau + \sigma
}
\irlabel{RMerge}
\and
\inferrule{%
\vdash e_1 : \\ \vdash e_2 : \bigvee\limits_{i=1}^n s_i
}{%
\vdash e_1 . e_2 : \left( \bigvee\limits_{i=1}^n (s_i) \right) \backslash \undef
}
\irlabel{RAccessFinite}
\and
\inferrule{%
\vdash e_1 : \\ \vdash e_2 : \σ \\ \σ \subtype \ty{string}
}{%
\vdash e_1 . e_2 : \left( \deff() \vee \bigvee\limits_{s \in \dom()} (s) \right) \backslash \undef
}
\irlabel{RAccessInfinite}
}{%
\vdash e_1 + e_2 : \tau + \sigma
}
\irlabel{RMerge}
\and
\inferrule{%
\vdash e_1 : \\ \vdash e_2 : \bigvee\limits_{i=1}^n s_i
}{%
\vdash e_1 . e_2 : \left( \bigvee\limits_{i=1}^n (s_i) \right) \backslash \undef
}
\irlabel{RAccessFinite}
\and
\inferrule{%
\vdash e_1 : \\ \vdash e_2 : \σ \\ \σ \subtype \ty{string}
}{%
\vdash e_1 . e_2 : \left( \deff() \vee \bigvee\limits_{s \in \dom()} (s) \right) \backslash \undef
}
\irlabel{RAccessInfinite}
\end{mathpar}

View File

@ -1,64 +1,15 @@
\subsection{$\lambda\&$-calculus}
\begin{mathpar}
\inferrule{ }{\Gamma; x:\tau \vdash x:\tau}(Var)
The typing rules are given by the figures~\pref{typing::lambda-calculus},~\pref{typing::records} and~\pref{typing::operators}.
\and
\inferrule{ }{\Gamma \vdash c:\mathcal{B}(c)}(Const)
\begin{figure}
\input{typing/lambdaCalculus}
\caption{Typing rules for the $\&-calculus$\label{typing::lambda-calculus}}
\end{figure}
\begin{figure}
\input{typing/recordTypingRules}
\caption{Typing rules for records\label{typing::records}}
\end{figure}
\and
\inferrule{%
\Gamma \vdash e_1 : \tau_1 \\ \Gamma \vdash e_2 : \tau_2 \\
\tau_1 \subtype \zero \rightarrow \one \\
\tau_2 \subtype \dom(\tau_1)
}{%
\Gamma \vdash e_1 e_2 : \tau_1 \tau_2
}
(App)
\and
\inferrule{%
\forall i \in \discrete{1}{n}, \\
\Gamma; \ofTypeP{p}{\sigma_i} \vdash e: \tau_i \\
}{%
\lambda \left(p:{\bigvee\limits_{i=1}^n\σ}\right).e :
\bigwedge\limits_{i=1}^n \left(\σ \rightarrow \right)
}
(Abs)
\and
\inferrule{%
\Gamma \vdash e : \tau \\
; x : \wedge t \vdash e_1 : \sigma_1 \\
; x : \wedge \lnot t \vdash e_2 : \sigma_2
}{%
\Gamma \vdash ((x := e \in t) ? e_1 : e_2) : \sigma_1 \vee \sigma_2
}
(Tcase)
\and
\inferrule{%
\forall i \in \discrete{1}{n}, \vdash e_i : _i \\
; x_1 : _1; \ldots; x_n : _n \vdash e :
}{%
\Gamma \vdash \text{let } x_1 = e_1; \ldots{}; x_n = e_n
\text{ in } e :
}
(Let)
\and
\inferrule{%
\forall i \in \discrete{0}{n},
; x_1 : _1; \ldots; x_n : _n \vdash e_i : _i
}{%
\Gamma \vdash \text{let rec } x_1 : _1 = e_1; \ldots{}; x_n : _n = e_n
\text{ in } e_0 : _0
}
(LetRec)
\end{mathpar}
\subsection{Records}
\begin{mathpar}
\input{typing/recordTypingRules}
\end{mathpar}
\subsection{Other builtin operators}
\todo{add rules for operators}
\begin{figure}
\todo{add rules for operators}
\caption{Typing rules for builtins operators\label{typing::operators}}
\end{figure}