Change proofs to the ebproof package

This commit is contained in:
Jip J. Dekker 2021-03-26 13:30:23 +11:00
parent afe132845c
commit 3a3e249b9e
No known key found for this signature in database
GPG Key ID: 517DF4A00618C9C3
3 changed files with 96 additions and 135 deletions

View File

@ -1,4 +1,5 @@
# Exclude these environments from syntax checking # Exclude these environments from syntax checking
VerbEnvir { pgfpicture tikzpicture mzn nzn grammar proof } VerbEnvir { pgfpicture tikzpicture mzn nzn grammar proof }
MathCmd { hypo infer1 infer2 infer3 }
WipeArg { \mzninline:{} \nzninline:{} \Sem:{} \texttt:{} } WipeArg { \mzninline:{} \nzninline:{} \Sem:{} \texttt:{} }

View File

@ -84,7 +84,7 @@ style=apa,
% Proof Tree % Proof Tree
\usepackage[nounderscore]{syntax} \usepackage[nounderscore]{syntax}
\usepackage{bussproofs} \usepackage{ebproof}
% Half Reif packages (maybe we should get rid of these) % Half Reif packages (maybe we should get rid of these)
\usepackage[all]{xy} \usepackage[all]{xy}

View File

@ -308,57 +308,35 @@ suitable alpha renaming.
\begin{figure*} \begin{figure*}
\centering \centering
\begin{prooftree} \begin{prooftree}
\AxiomC{\(\ptinline{F(\(p_1, \ldots, p_k\)) = E;} \in \Prog\) where the \(p_i\) \hypo{\ptinline{F(\(p_1, \ldots, p_k\)) = E;} \in \Prog \text{~where the~} p_i \text{~are fresh}}
are fresh} \infer[no rule]1{\Sem{\(a_i\)}{\Prog, \Env_{i-1}} \Rightarrow \tuple{v_i,
\noLine{} \Env_i'}, \ \Env_0=\Env, \Env_i=\Env_i'\cup\{p_i\mapsto v_i\sep[]\}, \forall 1 \leq i \leq k}
\UnaryInfC{\Sem{\(a_i\)}{\Prog, \Env_{i-1}} \(\Rightarrow~ \tuple{v_i, \infer[no rule]1{\Sem{E}{\Prog, \Env_k} \Rightarrow \tuple{v, \Env'}}
\Env_i'}, \ \Env_0=\Env, \Env_i=\Env_i'\cup\{p_i\mapsto v_i\sep[]\} \infer1[(Call)]{\Sem{F(\(a_1, \ldots, a_k\))}{\Prog, \Env_{0}} \Rightarrow \tuple{v, \Env'}}
\quad \forall \end{prooftree} \\
1 \leq \medskip
i \leq k\)}
\noLine{}
\UnaryInfC{\Sem{E}{\Prog, \Env_k}
\(\Rightarrow ~ \tuple{v, \Env'}\)}
\RightLabel{(Call)}
\UnaryInfC{\Sem{F(\(a_1, \ldots, a_k\))}{\Prog, \Env} \(\Rightarrow\)
\(\tuple{v, \Env'}\)}
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\(\ptinline{F} \in\) Builtins} \hypo{\ptinline{F} \in \text{Builtins}}
% \noLine \hypo{\Sem{\(a_i\)}{\Prog, \Env} \Rightarrow \tuple{v_i, \Env}, \forall{} 1 \leq{} i \leq{} k}
\AxiomC{\Sem{\(a_i\)}{\Prog, \Env} \(\Rightarrow~ \tuple{v_i, \Env}, \infer2[(CallBuiltin)]{\Sem{F(\(a_1, \ldots, a_k\))}{\Prog, \Env} \Rightarrow \tuple{ \mathit{eval}(\ptinline{F}(v_1,\ldots, v_k)), \Env}}
\forall \end{prooftree} \\
1 \leq \medskip
i \leq k\)}
% \(\ldots\), \Sem{\(a_k\)}{\Prog, \Env} \(\Rightarrow~\tuple{\Ctx_k,v_k}\)}
\RightLabel{(CallBuiltin)}
\BinaryInfC{\Sem{F(\(a_1, \ldots, a_k\))}{\Prog, \Env} \(\Rightarrow\)
\(\tuple{ \mathit{eval}(\ptinline{F}(v_1,\ldots, v_k)), \Env}\)}
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\(\ptinline{F(\(p_1, \ldots, p_k\));} \in \Prog\)} \hypo{\ptinline{F(\(p_1, \ldots, p_k\));} \in \Prog}
% \noLine \hypo{\Sem{\(a_i\)}{\Prog, \Env_{i-1}} \Rightarrow \tuple{v_i, \Env_i}, \forall 1 \leq i \leq k}
\AxiomC{\Sem{\(a_i\)}{\Prog, \Env_{i-1}} \(\Rightarrow~ \tuple{v_i, \Env_i}, \infer2[(CallPrimitive)]{\Sem{F(\(a_1, \ldots, a_k\))}{\Prog, \Env_0} \Rightarrow
~\forall \tuple{ x, \{ x \mapsto \ptinline{F}(v_1,\ldots, v_k) \sep [] \} \cup \Env_k}}
1 \leq
i \leq k\)}
% \(\ldots\), \Sem{\(a_k\)}{\Prog, \Env} \(\Rightarrow~\tuple{\Ctx_k,v_k}\)}
\RightLabel{(CallPrimitive)}
\BinaryInfC{\Sem{F(\(a_1, \ldots, a_k\))}{\Prog, \Env_0} \(\Rightarrow\)
\(\tuple{ x, \{ x \mapsto \ptinline{F}(v_1,\ldots, v_k) \sep [] \} \cup \Env_k}\)}
\end{prooftree} \end{prooftree}
\caption{\label{fig:4-rewrite-to-nzn-calls} Rewriting rules for partial evaluation \caption{\label{fig:4-rewrite-to-nzn-calls} Rewriting rules for partial evaluation
of \microzinc\ calls to \nanozinc.} of \microzinc\ calls to \nanozinc.}
\end{figure*} \end{figure*}
The rules in \cref{fig:4-rewrite-to-nzn-calls} handle function calls. The rules in \cref{fig:4-rewrite-to-nzn-calls} handle function calls. The first
rule (Call) evaluates a function call expression in the context of a \microzinc\
The first rule (Call) evaluates a function call expression in the context of a program \(\Prog\) and \nanozinc\ program \(\Env\). The rule first evaluates all
\microzinc\ program \(\Prog\) and \nanozinc\ program \(\Env\). The rule first actual parameter expressions \(a_i\), creating new contexts where the evaluation
evaluates all actual parameter expressions \(a_i\), creating new contexts where results are bound to the formal parameters \(p_i\). It then evaluates the
the evaluation results are bound to the formal parameters \(p_i\). It then function body \(\ptinline{E}\) on this context, and returns the result.
evaluates the function body \(\ptinline{E}\) on this context, and returns the
result.
The (CallBuiltin) rule applies to ``built-in'' functions that can be evaluated The (CallBuiltin) rule applies to ``built-in'' functions that can be evaluated
directly, such as arithmetic and Boolean operations on fixed values. The rule directly, such as arithmetic and Boolean operations on fixed values. The rule
@ -374,52 +352,41 @@ simply the function applied to the evaluated parameters.
\begin{figure*} \begin{figure*}
\centering \centering
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{\(\mathbf{I}\)}{\Prog, \Env} \(\Rightarrow (\Ctx, \Env')\)} \hypo{\Sem{\(\mathbf{I}\)}{\Prog, \Env} \Rightarrow (\Ctx, \Env')}
\AxiomC{\Sem{\(E\)}{\Prog, \Env'} \(\Rightarrow \tuple{v, \Env''}\)} \hypo{\Sem{\(E\)}{\Prog, \Env'} \Rightarrow \tuple{v, \Env''}}
\AxiomC{\(x\) fresh} \hypo{x \text{~fresh}}
\RightLabel{(LetC)} \infer3[(LetC)]{\Sem{let \{ \(\mathbf{I}\) \} in \(E\)}{\Prog, \Env} \Rightarrow
\TrinaryInfC{\Sem{let \{ \(\mathbf{I}\) \} in \(E\)}{\Prog, \Env} \(\Rightarrow \tuple{x, \{ x \mapsto v \sep \Ctx \} \cup \Env''}}
\tuple{x, \{ x \mapsto v \sep \Ctx \} \cup \Env''}\)} \end{prooftree} \\
\end{prooftree} \medskip
% \begin{prooftree}
% \AxiomC{\Sem{\(E_1\)}{\Prog, \Env} \(\Rightarrow \Ctx_1, r_1\)}
% \AxiomC{\Sem{\(E_2\)}{\Prog, \Env} \(\Rightarrow \Ctx_2, r_2\)}
% \RightLabel{(Rel)}
% \BinaryInfC{\Sem{\(E_1 \bowtie E_2\)}{\Prog, \Env} \(\Rightarrow \Ctx_1 \wedge \Ctx_2 \wedge (r_1 \bowtie r_2)\)}
% \end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{} \hypo{}
\RightLabel{(Item0)} \infer1[(Item0)]{\Sem{\(\epsilon\)}{\Prog, \Env} \Rightarrow \tuple{\ptinline{true}, \Env}}
\UnaryInfC{\Sem{\(\epsilon\)}{\Prog, \Env} \(\Rightarrow \end{prooftree} \\
(\ptinline{true}, \Env\))} \medskip
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{\(\mathbf{I}\)}{\Prog, \Env\ \cup\ \{x \mapsto\ \texttt{mkvar()} \sep\ []\}} \(\Rightarrow (\Ctx, \Env')\)} \hypo{\Sem{\(\mathbf{I}\)}{\Prog, \Env\ \cup\ \{x \mapsto\ \texttt{mkvar()} \sep\ []\}} \Rightarrow \tuple{\Ctx, \Env'}}
\RightLabel{(ItemT)} \infer1[(ItemT)]{\Sem{\(t:x, \mathbf{I}\)}{\Prog, \Env} \Rightarrow \tuple{\Ctx, \Env'}}
\UnaryInfC{\Sem{\(t:x, \mathbf{I}\)}{\Prog, \Env} \(\Rightarrow \end{prooftree} \\
(\Ctx, \Env')\)} \medskip
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{\(E\)}{\Prog, \Env} \(\Rightarrow \tuple{v, \Env'}\)} \hypo{\Sem{\(E\)}{\Prog, \Env} \Rightarrow \tuple{v, \Env'}}
\AxiomC{\Sem{\(\mathbf{I}\)}{\Prog, \Env' \cup\ \{x \mapsto\ v \sep\ [] \}} \(\Rightarrow (\Ctx, \Env'')\)} \hypo{\Sem{\(\mathbf{I}\)}{\Prog, \Env' \cup\ \{x \mapsto\ v \sep\ [] \}} \Rightarrow \tuple{\Ctx, \Env''}}
\RightLabel{(ItemTE)} \infer2[(ItemTE)]{\Sem{\(t:x = E, \mathbf{I}\)}{\Prog, \Env} \Rightarrow \tuple{\Ctx, \Env''}}
\BinaryInfC{\Sem{\(t:x = E, \mathbf{I}\)}{\Prog, \Env} \(\Rightarrow \end{prooftree} \\
(\Ctx, \Env'')\)} \medskip
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{\(E\)}{\Prog, \Env} \(\Rightarrow \tuple{\left(v_{1}, \ldots, v_{n}\right), \Env'}\)} \hypo{\Sem{\(E\)}{\Prog, \Env} \Rightarrow \tuple{\left(v_{1}, \ldots, v_{n}\right), \Env'}}
\noLine{} \infer[no rule]1{\Sem{\(\mathbf{I}\)}{\Prog, \Env' \cup\ \{x_{1} \mapsto\ v_{1} \sep\ [] \} \cup\ \ldots\ \cup\ \{x_{n} \mapsto\ v_{n} \sep\ [] \}} \Rightarrow \tuple{\Ctx, \Env''}}
\UnaryInfC{\Sem{\(\mathbf{I}\)}{\Prog, \Env' \cup\ \{x_{1} \mapsto\ v_{1} \sep\ [] \} \cup\ \ldots\ \cup\ \{x_{n} \mapsto\ v_{n} \sep\ [] \}} \(\Rightarrow (\Ctx, \Env'')\)} \infer1[(ItemTD)]{\Sem{\(\left(t_{1}: x_{1}, \ldots, t_{n}: x_{n}\right) = E, \mathbf{I}\)}{\Prog, \Env} \Rightarrow
\RightLabel{(ItemTD)} \tuple{\Ctx, \Env''}}
\UnaryInfC{\Sem{\(\left(t_{1}: x_{1}, \ldots, t_{n}: x_{n}\right) = E, \mathbf{I}\)}{\Prog, \Env} \(\Rightarrow \end{prooftree} \\
(\Ctx, \Env'')\)} \medskip
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{\(C\)}{\Prog, \Env} \(\Rightarrow \tuple{v, \Env'}\)} \hypo{\Sem{\(C\)}{\Prog, \Env} \Rightarrow \tuple{v, \Env'}}
\AxiomC{\Sem{\(\mathbf{I}\)}{\Prog, \Env'} \(\Rightarrow (\Ctx, \Env'')\)} \hypo{\Sem{\(\mathbf{I}\)}{\Prog, \Env'} \Rightarrow \tuple{\Ctx, \Env''}}
\RightLabel{(ItemC)} \infer2[(ItemC)]{\Sem{\(\mbox{constraint~} C, \mathbf{I}\)}{\Prog, \Env} \Rightarrow
\BinaryInfC{\Sem{\(\mbox{constraint~} C, \mathbf{I}\)}{\Prog, \Env} \(\Rightarrow \tuple{\{v\}\cup\Ctx, \Env''}}
(\{v\}\cup\Ctx, \Env'')\)}
\end{prooftree} \end{prooftree}
\caption{\label{fig:4-rewrite-to-nzn-let} Rewriting rules for partial evaluation \caption{\label{fig:4-rewrite-to-nzn-let} Rewriting rules for partial evaluation
of \microzinc\ let expressions to \nanozinc.} of \microzinc\ let expressions to \nanozinc.}
@ -439,64 +406,57 @@ is the base case for a list of let items.
\begin{figure*} \begin{figure*}
\centering \centering
\begin{prooftree} \begin{prooftree}
\RightLabel{(IdC)} \hypo{x \in \syntax{<ident>}}
\AxiomC{\(x \in \langle ident \rangle\)} \hypo{v \in \syntax{<literal>}}
\AxiomC{\(v \in \langle literal \rangle\)} \infer2[(IdC)]{\Sem{\(x\)}{\Prog, \{x \mapsto\ v \sep\ []\} \cup\ \Env} \Rightarrow \tuple{v, \{x \mapsto v \sep [] \} \cup \Env}}
\BinaryInfC{\Sem{\(x\)}{\Prog, \{x \mapsto\ v \sep\ []\} \cup\ \Env} \(\Rightarrow \tuple{v, \{x \mapsto v \sep [] \} \cup \Env}\)} \end{prooftree} \\
\end{prooftree} \medskip
\begin{prooftree} \begin{prooftree}
\RightLabel{(IdX)} \hypo{x \in \syntax{<ident>}}
\AxiomC{\(x \in \langle ident \rangle\)} \hypo{v}
\AxiomC{\(v\)} \hypo{\phi \text{~otherwise}}
\AxiomC{\(\phi\) otherwise} \infer3[(IdX)]{\Sem{\(x\)}{\Prog, \{x \mapsto\ v \sep\ \phi\ \} \cup\ \Env} \Rightarrow \tuple{x, \{x \mapsto v \sep \phi \} \cup \Env}}
\TrinaryInfC{\Sem{\(x\)}{\Prog, \{x \mapsto\ v \sep\ \phi\ \} \cup\ \Env} \(\Rightarrow \tuple{x, \{x \mapsto v \sep \phi \} \cup \Env}\)} \end{prooftree} \\
\end{prooftree} \medskip
\begin{prooftree} \begin{prooftree}
\RightLabel{(Const)} \hypo{c \text{~constant}}
\AxiomC{\(c\) constant} \infer1[(Const)]{\Sem{c}{\Prog, \Env} \Rightarrow \tuple{c, \Env}}
\UnaryInfC{\Sem{c}{\Prog, \Env} \(\Rightarrow \tuple{c, \Env}\)} \end{prooftree} \\
\end{prooftree} \medskip
\begin{prooftree} \begin{prooftree}
\RightLabel{(Tuple)} \hypo{\Sem{\(E_{i}\)}{\Prog,\Env^{i-1}} \Rightarrow \tuple{v_{i}, \Env^{i}}, \forall{} 1 \leq{} i \leq{} k}
\AxiomC{\Sem{\(E_{1}\)}{\Prog,\Env} \(\Rightarrow \tuple{v_{1}, \Env^{1}}\)} \infer1[(Tuple)]{\Sem{\(\left(E_{1}, \ldots, E_{k}\right)\)}{\Prog, \Env^{0}} \Rightarrow \tuple{x, \{x \mapsto \left(v_{1}, \ldots, v_{n}\right) \sep [] \} \cup \Env^{k}}}
\AxiomC{\ldots} \end{prooftree} \\
\AxiomC{\Sem{\(E_{n}\)}{\Prog,\Env^{n-1}} \(\Rightarrow \tuple{v_{n}, \Env^{n}}\)} \medskip
\TrinaryInfC{\Sem{\(\left(E_{1}, \ldots, E_{n}\right)\)}{\Prog, \Env} \(\Rightarrow \tuple{x, \{x \mapsto \left(v_{1}, \ldots, v_{n}\right) \sep [] \} \cup \Env^{n})}\)}
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\RightLabel{(If\(_T\))} \hypo{\Sem{\(C\)}{\Prog, \Env} \Rightarrow \tuple{\ptinline{true}, \_}}
\AxiomC{\Sem{\(C\)}{\Prog, \Env} \(\Rightarrow\) \(\tuple{\ptinline{true}, \_}\)} \infer1[(If\(_T\))]{\Sem{if \(C\) then \(E_t\) else \(E_e\) endif}{\Prog, \Env} \Rightarrow \Sem{\(E_t\)}{\Prog, \Env}}
\UnaryInfC{\Sem{if \(C\) then \(E_t\) else \(E_e\) endif}{\Prog, \Env} \(\Rightarrow\) \Sem{\(E_t\)}{\Prog, \Env}} \end{prooftree} \\
\end{prooftree} \medskip
\begin{prooftree} \begin{prooftree}
\RightLabel{(If\(_F\))} \hypo{\Sem{\(C\)}{\Prog, \Env} \Rightarrow \tuple{\ptinline{false}, \_}}
\AxiomC{\Sem{\(C\)}{\Prog, \Env} \(\Rightarrow\) \(\tuple{\ptinline{false}, \_}\)} \infer1[(If\(_F\))]{\Sem{if \(C\) then \(E_t\) else \(E_e\) endif}{\Prog, \Env} \Rightarrow \Sem{\(E_e\)}{\Prog, \Env}}
\UnaryInfC{\Sem{if \(C\) then \(E_t\) else \(E_e\) endif}{\Prog, \Env} \(\Rightarrow\) \Sem{\(E_e\)}{\Prog, \Env}} \end{prooftree} \\
\end{prooftree} \medskip
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{G}{\Prog,\Env} \(\Rightarrow \tuple{ \ptinline{true}, \_}\)} \hypo{\Sem{G}{\Prog,\Env} \Rightarrow \tuple{ \ptinline{true}, \_}}
\AxiomC{\Sem{\(E\)}{\Prog, \Env} \(\Rightarrow \tuple {v, \Env'}\)} \hypo{\Sem{\(E\)}{\Prog, \Env} \Rightarrow \tuple {v, \Env'}}
\RightLabel{(WhereT)} \infer2[(WhereT)]{\Sem{\([E ~|~ \mbox{where~} G]\)}{\Prog, \Env} \Rightarrow \tuple{[v], \Env'}}
\BinaryInfC{\Sem{\([E ~|~ \mbox{where~} G]\)}{\Prog, \Env} \(\Rightarrow \end{prooftree} \\
\tuple{[v], \Env'}\)} \medskip
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{G}{\Prog,\Env} \(\Rightarrow \tuple{ \ptinline{false}, \_}\)} \hypo{\Sem{G}{\Prog,\Env} \Rightarrow \tuple{\ptinline{false}, \_}}
\RightLabel{(WhereF)} \infer1[(WhereF)]{\Sem{\([E ~|~ \mbox{where~} G]\)}{\Prog, \Env} \Rightarrow \tuple{[], \Env}}
\UnaryInfC{\Sem{\([E ~|~ \mbox{where~} G]\)}{\Prog, \Env} \(\Rightarrow \end{prooftree} \\
\tuple{[], \Env}\)} \medskip
\end{prooftree}
\begin{prooftree} \begin{prooftree}
\AxiomC{\Sem{\(\mathit{PE}\)}{\Prog,\Env} \(\Rightarrow \tuple{S, \_}\)} \hypo{\Sem{\(\mathit{PE}\)}{\Prog,\Env} \Rightarrow \tuple{S, \_}}
\noLine\ \infer[no rule]1{\Sem{\([E ~|~ \mathit{GE} \mbox{~where~} G]\)}{\Prog, \Env\ \cup\ \{ x\mapsto\
\UnaryInfC{\Sem{\([E ~|~ \mathit{GE} \mbox{~where~} G]\)}{\Prog, \Env\ \cup\ \{ x\mapsto\
v \sep\ []\}}} v \sep\ []\}}}
\noLine\ \infer[no rule]1{\hspace{8em} \Rightarrow \tuple{A_v, \Env \cup \{x \mapsto v \sep []\} \cup \Env_v}, \forall
\UnaryInfC{\hspace{8em} \(\Rightarrow \tuple{A_v, \Env \cup \{x \mapsto v \sep []\} \cup \Env_v}, \forall v \in S }
v \in S \)} \infer1[(ListG)]{\Sem{\([E~|~ x \mbox{~in~} \mathit{PE}, \mathit{GE} \mbox{~where~} G]\)}{\Prog, \Env} \Rightarrow
\RightLabel{(ListG)} \tuple{\mbox{concat} [ A_v ~|~ v \in S ], \Env \cup \bigcup_{v \in S} \Env_v}}
\UnaryInfC{\Sem{\([E~|~ x \mbox{~in~} \mathit{PE}, \mathit{GE} \mbox{~where~} G]\)}{\Prog, \Env} \(\Rightarrow
\tuple{\mbox{concat} [ A_v ~|~ v \in S ], \Env \cup \bigcup_{v \in S} \Env_v}\)}
\end{prooftree} \end{prooftree}
\caption{\label{fig:4-rewrite-to-nzn-other} Rewriting rules for partial evaluation \caption{\label{fig:4-rewrite-to-nzn-other} Rewriting rules for partial evaluation
of other \microzinc\ expressions to \nanozinc.} of other \microzinc\ expressions to \nanozinc.}