Course Info
Course Work
Resources

# Exercises

This section contains exercises assigned in class plus additional ones for you to practice with.
Some of these exercises may appear in the exams.

1. Let XLoc, σ ∈ Σ such that σ(X) = 4.
Prove that    <(X+5)-(2+1), σ> --> 6    by showing that it is derivable.

2. Let w ≡ while b do c and let w' ≡ if b then c;w else skip.
Show that for all σ,σ'∈Σ,
if    <w', σ> --> σ'    then    <w, σ> --> σ'

3. Do Exercise 3.5 in Winskel.

4. Prove that    while ¬(X = X) do c   ∼   skip.

5. Prove that each program transformation rule in Question 2.5 of Homework 2 is equivalence preserving.

6. Do exercise 4.3 in Winskel.

7. Complete the proof of Proposition 4.7 in Winskel.

8. Complete the proof of Lemma 5.6 in Winskel.

9. Using the Hoare rules, derive the following partial correctness assertions:
1. {X = i ∧ Y = j} R := X; X := Y; Y := R {X = j ∧ Y = i}
2. {X = 3 ∨ Y = -2} Y := X*X - X + 6 {Y = 0}
3. {true} if 0 &le X then skip else X := 0 - X {0 &le X}
4. {1 &le N &and P = 0 &and C = 0} while C &le N - 1 do P := P + M; C := C + 1 {P = M * N}
(Suggested invariant: 1 &le N &and P = M * C &and C &le N)

10. It can be shown that for any assertion A and IMP command c, the partial correctness assertion {A}c{true} is derivable by the Hoare rules.
Using this fact prove that for any A,B and c, the partial correctness assertion {A}while true do c {B} is also derivable.

Last Updated: Oct 17, 2006