Homework # 11
due Thursday, May 31st, 2:00 PM

Small-Step Semantics

A small-step semantics work by returning the program with one step of evaluation done. Function calls and let's work by substituting the value for the variable into the body. The output is always an AST. To evaluate fully, one applies the small-step rules until no other rule is possible, which happens when there is a type error, or we end up with a value such as const(42). There are two kinds of values for Language Three: constants and functions.

The small-step semantics for Language Three is as follows, where $e$ means any expression, and $v$ means the expression must be a value, and $n$ means the expression must be an integer constant. \begin{mathpar}
\inferrule{e_1 \to e'_1}{\texttt{$e_1$+$e_2$} \to \texttt{$e'_1$...
...v_1$+$e'_2$}}
\par
\inferrule{ }{\texttt{$n_1$+$n_2$}\to{n_1+n_2}}
\end{mathpar} \begin{mathpar}
\inferrule{e_1 \to e'_1}{\texttt{$e_1$*$e_2$} \to \texttt{$e'_1$...
...2}
\par
\inferrule{ }{\texttt{(fn $x$\ => $e$)}\,v \to e[x \to v]}
\end{mathpar} In lecture, we implemented these rules in Prolog. The solution will be made available on the web.

For this Homework, you will add conditionals and recursion.

Final Exam

The final exam will be Thursday, May 31st. Study.


About this document



John Boyland 2007-05-24