|Problem Set 1: Operational Semantics||
Out: 25 January 2000
Due: Thursday, 3 February in class
Problem set answers may be hand-written. Please make sure your answers are clearly marked and neat enough to be read and understood.
Collaboration Policy Reminder: You are permitted (and encouraged) to discuss these problems with your classmates and sketch out your proposed solutions. What you turn in should be your own work, and you should cite the people you worked with on it.
STOREBLOCK Loc_1 Loc_2 Loc_3(a) Is the informal semantics for STOREBLOCK sufficiently clear? If not, clarify them (with an English description).
Store the value in Loc_3 in every location between Loc_1 and Loc_2.
(b) Show the operational semantics for STOREBLOCK using the RVM from Lecture 2. See http://www.cs.virginia.edu/~cs655/problem-sets/ps1-rvm.html for a review of the RVM.
Without defining the semantics, argue that it must be possible to define an operational semantics for PostFix using the RVM.
2. Initial Configuration
The operational semantics requires a mapping from the program to an initial configuration. Describe how you will model a PostFix execution using the RVM. You shouldn't change C (the set of configurations), although you may use a different notation to describe a configuration if you want.
You may assume there are two functions:
Encode: Postfix Command ==> Integer
Decode: Integer ==> Postfix Command
such that Decode (Encode (command)) = command. As an exercise, convince yourself that these functions could be defined (you don't need to turn anything in for this). Recall that registers in the RVM can store infinitely large values.
Show explicitly how a PostFix program is mapped to an initial configuration. If you've thought about this for a while, and are stuck, you may consult the hint at http://www.cs.virginia.edu/~cs655/problem-sets/ps1-hint.html.
3. Final Configuration
Define the set of final configurations, and the output function from a final configuration to an answer.
4. Transition Rules
(a) Show the transition rule for < N . Q, S >.
(b) Show the transition rule for < add . Q, V1 . V2 . S >.
(c) Show the transition rule for < swap . Q, V1 . V2 . S >.
(d) (Challenge) Show the transition rule for <exec . Qrest, Qexec . S>.
Note: Problems marked Challenge are meant to be especially challenging. It isn't necessary to solve them to get a good grade on a problem set. You should attempt them, and write down your thoughts, but only spend an inordinate amount of time on them for your own enjoyment.5. Termination
Hint: You may use Instruction[-1] ... Instruction[-infinity].
(a) Construct a proof that all PostFix programs terminate using the operational semantics you defined in questions 2-4. For this problem, assume a simplified PostFix with three commands (corresponding to the transition rules you defined in question 4a-c): N, add and swap.
(b) (Grand Challenge!) Using your RVM operational semantics, show the termination property is true for PostFix with the exec command also.
Note: Problems marked Grand Challenge! are meant to be extremely difficult. The course staff doesn't necessarily know the answer to them, or even if they are possible to solve. A good solution to a Grand Challenge! problem (or a proof that no solution exists) should impress the staff and your classmates greatly.
University of Virginia
CS 655: Programming Languages
Last modified: Mon Feb 26 12:48:15 2001