EXERCISE 4 (PROGRAMMING OF DYNAMIC SEMANTICS)
Consider the "Bit Evaluation Engine" (aka. The BEE Language) with two syntactic categories
Bsq, bit sequences (ranged over by "B"), and Exp, expressions (ranged over by "E"):
- Syntax: Let the syntax of the BEE language be given by:
B : 0 | 1 | B 0 | B 1 // Bsq: bit sequences
E : [ B ] | E + E | out E | ( E , E ) | z // Exp: expressions
Where the z (for a mathematical number in Z) in Exp is intermediate syntax for fully evaluated
bit sequences (used in the semantics below).
- Semantics (Bsq): Let the structural operational semantics (SOS) for Bsq (bit sequences) be given by:
| Bsq signature |
 |
| Bsq structural operational semantics (SOS) |
 |
- Semantics (Exp): Let the small-step structural operational semantics (SOS) for Exp (expressions) be given by:
| Exp configurations |
 |
| Exp small-step structural operational semantics (SOS) |
 |
- Fill-in-the-blanks-implementation: Here is a complete implementation of the BEE language containing everything except the implementation
of the semantic rules [ONE], [B-ZERO], and [B-ONE] (for Bsq) and [BITS], [PLUS3], [OUT1], [OUT2], [SEQ1], and [SEQ2] (for Exp);
these rules just raise exceptions in their present form.
- Note: The "fill-in-the-blanks-implementation" can be downloaded here:
[ http://www.daimi.au.dk/semantics/BEE.sml ]
...and the implementation contains: [ overview ].
- a) Complete the implementation by implementing rules [ONE], [B-ZERO], and [B-ONE] (for Bsq)
and [BITS], [PLUS3], [OUT1], [OUT2], [SEQ1], and [SEQ2] (for Exp);
and explain the rules informally (i.e., what are the consequences of the the rules as they are defined for Bee programs).
Submit along with the report, your completed implementation; i.e., the file: "BEE.sml".
- b) Run and submit the stepwise output trace for the following BEE program, BP (and briefly explain what happens);
submit along with the report, the output trace as a file: "trace.bee.txt":
BP = out (out ([00] + [01]), (out [10]) + (out [11]))
- c) Write the SOS rules for a semantic variant of the language (known as "Bit Evaluation Engine Reversed"; aka. The BEER Language) in which
the addition, "E+E'", and sequence, "(E,E')", operators evaluate their expressions right-to-left (i.e., both are to evaluate E' before E).
You only have to give the SOS rules for the changed parts (the actually modified SOS rules).
- d) Now make a copy of your BEE implementation and change it according to your SOS rules (in assignment "c") above to
obtain an implementation for the BEER language variant. Submit along with the report, the file: "BEER.sml".
- e) Re-run and submit the stepwise output trace on the above BP program, but now interpreted as a BEER program
(and briefly explain what happens in comparison with assignment "b" above). Submit along with the report, the output trace as a file: "trace.beer.txt".
| [ 25% ] |