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.
-
Let X ∈ Loc, σ ∈ Σ such that σ(X) = 4.
Prove that <(X+5)-(2+1), σ> --> 6 by showing that it is derivable.
-
Let w ≡ while b do c and
let w' ≡ if b then c;w else skip.
Show that for all σ,σ'∈Σ,if <w', σ> --> σ' then <w, σ> --> σ'
-
Do Exercise 3.5 in Winskel.
-
Prove that
while ¬(X = X) do c ∼ skip.
-
Prove that
each program transformation rule in Question 2.5 of Homework 2 is equivalence preserving.
-
Do exercise 4.3 in Winskel.
-
Complete the proof of Proposition 4.7 in Winskel.
-
Complete the proof of Lemma 5.6 in Winskel.
-
Using the Hoare rules, derive the following partial correctness assertions:
- {X = i ∧ Y = j} R := X; X := Y; Y := R {X = j ∧ Y = i}
- {X = 3 ∨ Y = -2} Y := X*X - X + 6 {Y = 0}
- {true} if 0 &le X then skip else X := 0 - X {0 &le X}
-
{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)
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