(a) This solution assumes that if none of the Ei is true, then an "error occurs" (Louden, p. 270) and the statement doesn't complete. Since we are only interested in giving so-called "partial correctness" rules, we don't care about the behavior of non-completed statements. {P ^ E1 } S1 {Q} {P ^ E2} S2 {Q} ... {P ^ En} Sn {Q} ----------------------------------------------------------- (GIF) {P} gif E1 -> S1 [] E2 ->S2 [] ... [] En -> Sn end {Q} If we prefer a semantics in which the statement "falls through" if none of the Ei is true, then we can add an additional hypothesis "above the line," namely ... (P ^ ~E1 ^ ~E2 ^ ... ^ ~En) -> Q --------------------------------------- (b) Here's the tree: ----------------(ASSIGN) {z < 0 ^ -x >= 0} y := -x {z < 0 & y >= 0} ------------------(CONSEQ) -----------------(ASSIGN) {z < 0 ^ x <= 0} {z < 0 ^ x >= 0} y := -x y := x ------------(ASSIGN) {z < 0 ^ y >= 0} {z < 0 ^ y >= 0} {z - y < 0} --------------------------------------------(GIF) z := z - y {z < 0} {z < 0} gif x <= 0 -> y := -x -----------------(CONSEQ) [] x >= 0 -> y := x {z < 0 ^ y >= 0} end z := z - y {z < 0 ^ y >= 0} {z < 0} ----------------------------------------------------------------------------(COMP) {z < 0} gif x <= 0 -> y := -x [] x >= 0 -> y := x end; z := z - y {z < 0} -------------------------------------------------------------- (CONSEQ) {z < 0 ^ x > - 5} gif x <= 0 -> y := -x [] x >= 0 -> y := x end; z := z - y {z < 0} -------------------------------------------------------------- (WHILE) { z < 0 } while (x > -5) do gif x <= 0 -> y := -x [] x >= 0 -> y := x end; z := z - y end { z < 0 ^ x <= -5 } -------------------------------------------------------------- (CONSEQ) { z < 0 } while (x > -5) do gif x <= 0 -> y := -x [] x >= 0 -> y := x end; z := z - y end { z < 0 }