\caption{Big-step operational semantics for statements}
\label{bs_stmt}
\end{figure}
\section{Stack Machine}
Stack machine is a simple abstract computational device, which can be used as a convenient model to constructively describe
the compilation process.
In short, stack machine operates on the same configurations, as the language of statements, plus a stack of integers. The
computation, performed by the stack machine, is controlled by a program, which is described as follows:
\[
\begin{array}{rcl}
\mathscr I & = &\llang{BINOP $\;\otimes$}\\
&&\llang{CONST $\;\mathbb N$}\\
&&\llang{READ}\\
&&\llang{WRITE}\\
&&\llang{LD $\;\mathscr X$}\\
&&\llang{ST $\;\mathscr X$}\\
\mathscr P & = &\epsilon\\
&&\mathscr I\mathscr P
\end{array}
\]
Here the syntax category $\mathscr I$ stands for \emph{instructions}, $\mathscr P$~--- for \emph{programs}; thus, a program is a finite
string of instructions.
The semantics of stack machine program can be described, again, in the form of big-step operational semantics. This time the set of
stack machine configurations is
\[
\mathscr C_{SM} = \mathbb Z^* \times\mathscr C
\]
where the first component is a stack, and the second~--- a configuration as in the semantics of statement language. The rules are shown on Fig.~\ref{bs_sm}; note,
now we have one axiom and six inference rules (one per instruction).
As for the statement, with the aid of the relation ``$\Rightarrow$'' we can define the surface semantics of stack machine:
\[\trule{\trans{\inbr{z\llang{::}st, \inbr{s, i, o}}}{p}{c^\prime}}{\trans{\inbr{st, \inbr{s, z\llang{::}i, o}}}{(\llang{READ})p}{c^\prime}}\ruleno{Read$_{SM}$}\]
\[\trule{\trans{\inbr{st, \inbr{s, i, o\llang{@}z}}}{p}{c^\prime}}{\trans{\inbr{z\llang{::}st, \inbr{s, i, o}}}{(\llang{WRITE})p}{c^\prime}}\ruleno{Write$_{SM}$}\]
\[\trule{\trans{\inbr{(s\;x)\llang{::}st, \inbr{s, i, o}}}{p}{c^\prime}}{\trans{\inbr{st, \inbr{s, i, o}}}{(\llang{LD $\;x$})p}{c^\prime}}\ruleno{LD$_{SM}$}\]
\[\trule{\trans{\inbr{st, \inbr{s[x\gets z], i, o}}}{p}{c^\prime}}{\trans{\inbr{z\llang{::}st, \inbr{s, i, o}}}{(\llang{ST $\;x$})p}{c^\prime}}\ruleno{ST$_{SM}$}\]
\caption{Big-step operational semantics for stack machine}
A compiler of the statement language into the stack machine is a total mapping
\[
\sembr{\bullet}_{comp} : \mathscr S \mapsto\mathscr P
\]
We can describe the compiler in the form of denotational semantics for the source language. In fact, we can treat the compiler as a \emph{static} semantics, which
maps each program into its stack machine equivalent.
As the source language consists of two syntactic categories (expressions and statments), the compiler has to be ``bootstrapped'' from the compiler for expressions