Homework # 13
due Monday, May 4th, 11:00 AM

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 implement these rules in Prolog.

For this Homework, you will add conditionals and recursion.

Put all your Prolog in homework13.pl in your AFS volume.


About this document



John Tang Boyland 2009-04-27