1

Exercise 3.5.18 is the following

Suppose we want to change th evaluation strategy of our language so that the then and else branches of an if expression are evaluated (in that order) before teh guard is evaluated. Show how the evaluation rules need to change to achieve this effect.

but it has no solution.

Is the solution to change these 3 existing rules

\begin{equation} {if\;true\;then\;t_2\;else\;t_3\;\rightarrow\;t_2}\quad(E-IFTRUE) \end{equation} \begin{equation} {if\;false\;then\;t_2\;else\;t_3\;\rightarrow\;t_3}\quad(E-IFFALSE) \end{equation} \begin{equation} \frac {t_1\rightarrow\;t_1'} {if\;t_1\;then\;t_2\;else\;t_3\;\rightarrow\;if\;t_1'\;then\;t_2\;else\;t_3}\quad(E-IF) \end{equation}

to the following alternative rules?

\begin{equation} {if\;true\;then\;v_2\;else\;v_3\;\rightarrow\;v_2}\quad(E-IFTRUE) \end{equation} \begin{equation} {if\;false\;then\;v_2\;else\;v_3\;\rightarrow\;v_3}\quad(E-IFFALSE) \end{equation} \begin{equation} \frac {t_1\rightarrow\;t_1'} {if\;t_1\;then\;v_2\;else\;v_3\;\rightarrow\;if\;t_1'\;then\;v_2\;else\;v_3}\quad(E-IF) \end{equation} \begin{equation} \frac {t_2\rightarrow\;t_2'} {if\;t_1\;then\;t_2\;else\;t_3\;\rightarrow\;if\;t_1\;then\;t_2'\;else\;t_3}\quad(E-IFTHEN) \end{equation} \begin{equation} \frac {t_3\rightarrow\;t_3'} {if\;t_1\;then\;v_2\;else\;t_3\;\rightarrow\;if\;t_1\;then\;v_2\;else\;t_3'}\quad(E-IFELSE) \end{equation}

My intention is to express the idea that E-IFTRUE, E-IFFALSE, and E-IF are similar to before, but they can only be applied when the 2nd and 3rd terms are not general terms, but values; the two additional rules are to allow an evaluation step on the 2nd and 3rd term respectively, with the further requirements that the 3rd term is only evaluated when the 2nd is already in normal form.

Is the above correct? If not, why, and what is the actual solution?

Enlico
  • 127
  • 9

0 Answers0