Slide 9.4: Reduction rules of assignments (cont.)
Slide 9.6: An assignment example
Home

Reduction Rules of Assignments (Cont.)


The reduction of expressions within assignments proceeds via the folllowing rule:
  1.          <E|Env> ⇒ <E1|Env>         
    <I ':=' E | Env> ⇒ <I ':=' E1 | Env>
A statement sequence reduces to an environment formed by accumulating the effect of each assignment:
  1.          <S|Env> ⇒ Env1         
    <S ';' L | Env> ⇒ <L | Env1>
Finally, a program is a statement sequence that has no prior environment; it reduces to the effect it has on the empty starting environment:
  1. L ⇒ <L|Env0>
(recall that Env0 = undef for all identifiers I). The reduction rules are not yet completed. For example, the rules for reducing identifier expressions are skipped.

An Assignment Example
The example shows how to use these rules to reduce the following sample program to an environment; i.e., finding the semantics of the program:
     a := 2 + 3;
     b := a * 4;
     a := b – 5
The first step is to set up the reductions:
    a:=2+3;  b:=a*4;  a:=b-5
 ⇒ <a ':=' '2' '+' '3';  b ':=' a '*' '4';
      a ':=' b '-' '5' | Env0>                 (Rule 19)