

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A homework assignment for the computer science course cmsc 631, offered in the fall 2006 semester. The assignment includes three problems related to derivations and semantics for a programming language with extended features, such as boolean expressions, lists, and pattern matching. Students are asked to establish the legality of certain evaluations, prove a theorem about the language, and define small and big-step semantics for the extended language.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


(a) ((1 ∗ 2) + (3 ∗ x), s) →∗^ (8, s) and likewise ((1 ∗ 2) + (3 ∗ x), s) ⇓ (8, s) where s(x) = 2. (b) (x := 1; while x do (x := x + (−1)), s) →∗^ s′^ where s′^ = s[x 7 → 0] and likewise for ⇓.
(Recall that → is the small-step relation, ⇓ is the big-step relation. Also, the syntax s[x 7 → i] defines a new map s′^ such that s′(x) = i and s′(y) = s(y) for all y 6 = x.)
vars(x) = {x} vars(i) = ∅ vars(e 1 + e 2 ) = vars(e 1 ) ∪ vars(e 2 ) vars(e 1 ∗ e 2 ) = vars(e 1 ) ∪ vars(e 2 )
You should prove this by induction on the height of the derivation (e, s) → (e′, s).
variables x, y, z ∈ V integers i, j, k ∈ Z expressions e ::= x | i | e 1 + e 2 | e 1 ∗ e 2
Figure 1: Language of arithmetic expressions
commands c, d ::= skip | x := e | if e then c 1 else c 2 | while e do c
Figure 2: Language of commands (includes language of expressions)
variables x, y, z ∈ V integers i, j, k ∈ Z lists l, m ::= nil | i, l bool .expressions a, b ::= true | false | b 1 ∧ b 2 | b 1 ∨ b 2 | !b | e 1 = e 2 expressions e ::= x | i | e 1 + e 2 | e 1 ∗ e 2 | e 1 , e 2 | nil values v ::= i | l commands c, d ::= skip | x := e | if b then c 1 else c 2 | while b do c | c 1 ; c 2 | case e of nil ⇒ c 1 or (x :: y) ⇒ c 2
Figure 3: Extended language of commands