
% Template for a simple journal or conference style article

\documentstyle[11pt,fullpage]{article}
\oddsidemargin 5.5mm\evensidemargin 20pt
\marginparwidth 48pt\marginparsep 10pt
\topmargin -18pt\headheight 0pt\headsep 25pt
\footheight 0pt\footskip 0pt
\textheight 9in \textwidth 7.0in
\begin{document}

%\title{\bf CIS 624 Assignment \#2}
%\author{Harold Hersey, Nate Bernstein, Sameer Shende, Michael Curry, Andrew Parkes, Bin Yu}
%\maketitle

\begin{description}
\begin{enumerate}

{\bf \item Problem 2.8}

$for \; x := a_{1} \; to \; a_{2} \; do \; S $ 
 construct in natural semantics is defined as 

\[
[for^{tt}_{ns}] \; \; \frac {<x:=a_{1}; S; for \; x := x + 1 \;to \; a_{2} \;do \; S, s> \rightarrow s^{'}} 
	{<for \; x:=a_{1} \; to \; a_{2} \;  do \; S, s> \rightarrow s^{'} }
\; \; \;B[x \le a_{2}]s = tt
\]

\[
[for^{ff}_{ns}] \; \; \frac {<x:=a_{1};s> \rightarrow s^{'}} 
{<for \; x:=a_{1} \; to \; a_{2} \; do \; S, s> \rightarrow s^{'}} 
\; \; \; B[x \le a_{2}]s = ff
\]

The statement $y:=1; for \; z:= 1 \; to \; x \; do \; (y:=y*x; x:= x -1) $ is
evaluated as 


\[ if  B[ \kern 0.1 em [ z \le x] \kern 0.1 em] s = tt \]
\[
\-
\frac {<y:=1,s> \rightarrow s^{'} \; <z := 1;  y:= y* x;  x:= x -1; \; for \; 
z := z+1 \; to \; x \; do \; (y:=y*x; x:= x-1), s^{'}> \rightarrow s^{''}}
{<y:=1; \; for \; z:= 1 \; to \; x\; do \; (y:= y*x;  x:= x-1), s> \rightarrow s^{''}}
\]

\[ if  B[ \kern 0.1 em [ z \le x] \kern 0.1 em] s = tt \]
\[
\frac {<y:=1,s> \rightarrow s^{'} \; <z:=1, s^{'}> \rightarrow s^{''}}
{<y:=1; \; for \; z:= 1 \; to \; x\; do \; (y:= y*x;  x:= x-1), s> \rightarrow s^{''}}
\]
So, here we notice that the limit ($a_{2}$) is evaluated each time in the
for iteration and its value is updated to reflect the new upper limit of the 
for construct as in the example.

{\bf \item Problem 2.17}     


The repeat contruct can be specified in the structural operational semantics as follows :

$<$repeat S until b,s$> \Rightarrow  <$ S; if b then skip else (repeat S until b,s)$>$

\end{enumerate}
\end{description}
\end{document}

% ------------ end of document ----------------------

% here are some templates of different environments you can cut and paste:

\frac {<x:=a_{1}; S; for \; x := x + 1 \;to \; a_{2} \;do \; S, s> \rightarrow s^{'}} 
	{<for \; x:=a_{1} \; to \; a_{2} \;  do \; S, s> \rightarrow s^{'} }
\begin{figure}
\vspace{3in}
\caption{}
\end{figure}

\begin{itemize}
\item
...
\end{itemize}

\begin{enumerate}
\item
...
\end{enumerate}

