
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Prove the assertion below using the predicate transform based approach. {Z=B} if A>B then Z := A {Z=Max(A,B)} Idea: Show P => wp(S, Q) o Step 1: compute wp(S,Q) o Step 2: show P is stronger (implies this) Step 1: wp ( if A>B then Z := A, Z=Max(A,B)) = (A>B Л wp(Z := A, Z=Max(A,B) )) V (A≤B Л Z=Max(A,B)) = (A>B Л A=Max(A,B))) V (A≤B Л Z=Max(A,B) ) = (A>B Л A≥B )) V (A≤B Л Z=Max(A,B)) = (A>B) V (A≤B Л Z=Max(A,B)) Step 2: Does Z=B => (A>B) V (A≤B Л Z=Max(A,B))? Note that either A>B or A≤B MUST be true. Case 1: Suppose A>B. Then the question above reduces to: Does (Z=B Л A>B) => (A>B) V (A≤B Л Z=Max(A,B))? Yes, Mon! Case 2: Suppose A≤B. Then the question above reduces to: Does (Z=B Л A≤B) => (A>B) V (A≤B Л Z=Max(A,B))? = (A≤B Л Z=Max(A,B)) = (A≤B Л Z=B) Yes, Mon! Therefore, Does Z=B => (A>B) V (A≤B Л Z=Max(A,B))