+\hrule
+\end{table}
+
+\begin{table}
+\caption{\label{tab:wfl2} Well-formedness rules for level 2 patterns.\strut}
+\hrule
+\[
+\renewcommand{\arraystretch}{3.5}
+\begin{array}{@{}c@{}}
+ \inference[\sc Constr]
+ {P_i :: D_i}
+ {\BLOB[P_1,\dots,P_n] :: D_i \oplus \cdots \oplus D_j} \\
+ \inference[\sc TermVar]
+ {}
+ {\mathtt{term}~x :: x : \mathtt{Term}}
+ \quad
+ \inference[\sc NumVar]
+ {}
+ {\mathtt{number}~x :: x : \mathtt{Number}}
+ \\
+ \inference[\sc IdentVar]
+ {}
+ {\mathtt{ident}~x :: x : \mathtt{String}}
+ \quad
+ \inference[\sc FreshVar]
+ {}
+ {\mathtt{fresh}~x :: x : \mathtt{String}}
+ \\
+ \inference[\sc Success]
+ {}
+ {\mathtt{anonymous} :: \emptyset}
+ \\
+ \inference[\sc Fold]
+ {P_1 :: D_1 & P_2 :: D_2 \oplus (x : \mathtt{Term}) & \DOMAIN(D_2)\ne\emptyset & \DOMAIN(D_1)\cap\DOMAIN(D_2)=\emptyset}
+ {\mathtt{fold}~P_1~\mathtt{rec}~x~P_2 :: D_1 \oplus D_2~\mathtt{List}}
+ \\
+ \inference[\sc Default]
+ {P_1 :: D \oplus D_1 & P_2 :: D & \DOMAIN(D_1) \ne \emptyset & \DOMAIN(D) \cap \DOMAIN(D_1) = \emptyset}
+ {\mathtt{default}~P_1~P_2 :: D \oplus D_1~\mathtt{Option}}
+ \\
+ \inference[\sc If]
+ {P_1 :: \emptyset & P_2 :: D & P_3 :: D }
+ {\mathtt{if}~P_1~\mathtt{then}~P_2~\mathtt{else}~P_3 :: D}
+ \qquad
+ \inference[\sc Fail]
+ {}
+ {\mathtt{fail} :: \emptyset}
+%% & | & \verb+if+~\NT{meta}~\verb+then+~\NT{meta}~\verb+else+~\NT{meta} \\
+%% & | & \verb+fail+
+\end{array}
+\]
+\hrule
+\end{table}
+
+\begin{table}
+\caption{...}
+\hrule
+\[
+\begin{array}{rcll}
+\IOT{C[t_1,\dots,t_n]}{E} & = & C[\IOT{t_1}{E},\dots,\IOT{t_n}{E}] \\
+\IOT{\mathtt{term}~x}{E} & = & t & \mathcal{E}(x) = \mathtt{Term}~t \\
+\IOT{\mathtt{number}~x}{E} & = & n & \mathcal{E}(x) = \mathtt{Number}~n \\
+\IOT{\mathtt{ident}~x}{E} & = & y & \mathcal{E}(x) = \mathtt{String}~y \\
+\IOT{\mathtt{fresh}~x}{E} & = & y & \mathcal{E}(x) = \mathtt{String}~y \\
+\IOT{\mathtt{default}~P_1~P_2}{E} & = & \IOT{P_2}{E'} & \mathcal{E}(\NAMES(P_1)\setminus\NAMES(P_2)))=\{\mathtt{None}\} \\
+& & & \mathcal{E}'(x) =
+ \left\{
+ \begin{array}{@{}ll}
+ \bot & x \in \NAMES(P_1)\setminus\NAMES(P_2) \\
+ \mathcal{E}(x) & \mbox{otherwise} \\
+ \end{array}
+ \right. \\
+\IOT{\mathtt{default}~P_1~P_2}{E} & = & \IOT{P_2}{E'} & \mathcal{E}(\NAMES(P_1)\setminus\NAMES(P_2)))=\{\mathtt{Some}~v_1,\dots,\mathtt{Some}~v_n\} \\
+& & & \mathcal{E}'(x) =
+ \left\{
+ \begin{array}{@{}ll}
+ v & x \in \NAMES(P_1)\setminus\NAMES(P_2) \wedge \mathcal{E}(x) = \mathtt{Some}~v\\
+ \mathcal{E}(x) & \mbox{otherwise}
+ \end{array}
+ \right. \\
+\IOT{\mathtt{fold}~d~P_1~\mathtt{rec}~x~P_2}{E}
+& =
+& \IOT{P_2}{E'}
+& \mathcal{E}(\NAMES(P_2)\setminus\{x\}) = \{[]\} \\
+& & & \mathcal{E}'(y) =
+ \left\{
+ \begin{array}{@{}ll}
+ \bot & y \in \NAMES(P_2)\setminus\{x\} \\
+ \mathcal{E}(y) & \mbox{otherwise} \\
+ \end{array}
+ \right. \\
+\IOT{\mathtt{fold}~d~P_1~\mathtt{rec}~x~P_2}{E}
+& =
+& \IOT{P_2}{E'}
+& \mathcal{E}(\NAMES(P_2)\setminus\{x\}) = \{[v_{11},\dots,v_{1n}],\dots,[v_{m1},\dots,v_{mn}]\} \\
+& & & \mathcal{E}'(y) =
+ \left\{
+ \begin{array}{@{}ll}
+ \IOT{\mathtt{fold}~d~P_1~\mathtt{rec}~x~P_e}{E''} & y = x \\
+ v_1 & y\in\NAMES(P_2)\setminus\{x\} \wedge \mathcal{E}(y)=[v_1;\dots;v_n] \\
+ \mathcal{E}(y) & \mbox{otherwise} \\
+ \end{array}
+ \right. \\
+& & & \mathcal{E}''(y) =
+ \left\{
+ \begin{array}{@{}ll}
+ [v_2;\dots;v_n] & y\in\NAMES(P_2)\setminus\{x\} \wedge \mathcal{E}(y)=[v_1;\dots;v_n] \\
+ \mathcal{E}(y) & \mbox{otherwise} \\
+ \end{array}
+ \right. \\
+\end{array} \\
+\]
+\end{table}
+
+\begin{table}
+\caption{\label{tab:l2match} Pattern matching of level 2 terms.\strut}
+\hrule
+\[
+\renewcommand{\arraystretch}{3.5}
+\begin{array}{@{}c@{}}
+ \inference[\sc Constr]
+ {t_i \in P_i ~> \mathcal E_i & i\ne j => \DOMAIN(\mathcal E_i)\cap\DOMAIN(\mathcal E_j)=\emptyset}
+ {C[t_1,\dots,t_n] \in C[P_1,\dots,P_n] ~> \mathcal E_1 \oplus \cdots \oplus \mathcal E_n}
+ \\
+ \inference[\sc TermVar]
+ {}
+ {t \in [\mathtt{term}]~x ~> [x |-> \mathtt{Term}~t]}
+ \quad
+ \inference[\sc NumVar]
+ {}
+ {n \in \mathtt{number}~x ~> [x |-> \mathtt{Number}~n]}
+ \\
+ \inference[\sc IdentVar]
+ {}
+ {x \in \mathtt{ident}~x ~> [x |-> \mathtt{String}~x]}
+ \quad
+ \inference[\sc FreshVar]
+ {}
+ {x \in \mathtt{fresh}~x ~> [x |-> \mathtt{String}~x]}
+ \\
+ \inference[\sc Success]
+ {}
+ {t \in \mathtt{anonymous} ~> \emptyset}
+ \\
+ \inference[\sc DefaultT]
+ {t \in P_1 ~> \mathcal E}
+ {t \in \mathtt{default}~P_1~P_2 ~> \mathcal E'}
+ \quad
+ \mathcal E'(x) = \left\{
+ \renewcommand{\arraystretch}{1}
+ \begin{array}{ll}
+ \mathtt{Some}~\mathcal{E}(x) & x \in \NAMES(P_1) \setminus \NAMES(P_2) \\
+ \mathcal{E}(x) & \mbox{otherwise}
+ \end{array}
+ \right.
+ \\
+ \inference[\sc DefaultF]
+ {t \not\in P_1 & t \in P_2 ~> \mathcal E}
+ {t \in \mathtt{default}~P_1~P_2 ~> \mathcal E'}
+ \quad
+ \mathcal E'(x) = \left\{
+ \renewcommand{\arraystretch}{1}
+ \begin{array}{ll}
+ \mathtt{None} & x \in \NAMES(P_1) \setminus \NAMES(P_2) \\
+ \mathcal{E}(x) & \mbox{otherwise}
+ \end{array}
+ \right.
+ \\
+ \inference[\sc IfT]
+ {t \in P_1 ~> \mathcal E' & t \in P_2 ~> \mathcal E}
+ {t \in \mathtt{if}~P_1~\mathtt{then}~P_2~\mathtt{else}~P_3 ~> \mathcal E}
+ \quad
+ \inference[\sc IfF]
+ {t \not\in P_1 & t \in P_3 ~> \mathcal E}
+ {t \in \mathtt{if}~P_1~\mathtt{then}~P_2~\mathtt{else}~P_3 ~> \mathcal E}
+ \\
+ \inference[\sc FoldRec]
+ {t \in P_2 ~> \mathcal E & \mathcal{E}(x) \in \mathtt{fold}~d~P_1~\mathtt{rec}~x~P_2 ~> \mathcal E'}
+ {t \in \mathtt{fold}~d~P_1~\mathtt{rec}~x~P_2 ~> \mathcal E''}
+ \\
+ \mbox{where}~\mathcal{E}''(y) = \left\{
+ \renewcommand{\arraystretch}{1}
+ \begin{array}{ll}
+ \mathcal{E}(y)::\mathcal{E}'(y) & y \in \NAMES(P_2) \setminus \{x\} \wedge d = \mathtt{right} \\
+ \mathcal{E}'(y)@[\mathcal{E}(y)] & y \in \NAMES(P_2) \setminus \{x\} \wedge d = \mathtt{left} \\
+ \mathcal{E}'(y) & \mbox{otherwise}
+ \end{array}
+ \right.
+ \\
+ \inference[\sc FoldBase]
+ {t \not\in P_2 & t \in P_1 ~> \mathcal E}
+ {t \in \mathtt{fold}~P_1~\mathtt{rec}~x~P_2 ~> \mathcal E'}
+ \quad
+ \mathcal E'(y) = \left\{
+ \renewcommand{\arraystretch}{1}
+ \begin{array}{ll}
+ [] & y \in \NAMES(P_2) \setminus \{x\} \\
+ \mathcal{E}(y) & \mbox{otherwise}
+ \end{array}
+ \right.
+\end{array}
+\]
+\hrule