Presentation is loading. Please wait.

Presentation is loading. Please wait.

1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted)

Similar presentations


Presentation on theme: "1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted)"— Presentation transcript:

1 1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted)

2 1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted) = The whole house, except for the living room ceiling, is all painted.

3 1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted) = The whole house, except for the living room ceiling, is all painted.

4 1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted) = The whole house, except POSSIBLY for the living room ceiling, is all painted. (The living room ceiling may or may not be all painted!)

5 1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted) = The whole house, except POSSIBLY for the living room ceiling, is all painted. (The living room ceiling may or may not be all painted!) (Compare this with: wp(A := true, A Л B Л C Л D ) = true Л B Л C Л D = B Л C Л D (A may be true or false) where “parts of the house” are A, B, C, and D, and (X = true)  “part X is painted.”)

6 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i])

7 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1]

8 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x)

9 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x)

10 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x)

11 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x)

12 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x) = wp(k := 5, w(2y-4) = z+2y)

13 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x) = wp(k := 5, w(2y-4) = z+2y)

14 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x) = wp(k := 5, w(2y-4) = z+2y) = w(2y-4) = z+2y

15 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x) = wp(k := 5, w(2y-4) = z+2y) = w(2y-4) = z+2y d. wp(if x is even then x := x+1, x = 9)

16 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x) = wp(k := 5, w(2y-4) = z+2y) = w(2y-4) = z+2y d. wp(if x is even then x := x+1, x = 9) = (x is even Л x=8) V (x is odd Л x=9)

17 b. wp(i := j-1, A[i] is the smallest element in A[1], A[2],..., A[i]) = A[j-1] is the smallest element in A[1], A[2],..., A[j-1] c. wp(k := 5; x := 2*y; y := x-4, wy = z+x) = wp(k := 5; x := 2*y, w(x-4) = z+x) = wp(k := 5, w(2y-4) = z+2y) = w(2y-4) = z+2y d. wp(if x is even then x := x+1, x = 9) = (x is even Л x=8) V (x is odd Л x=9) = (x=8 V x=9)

18 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps.

19 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. We need to show P => wp(S,Q).

20 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. We need to show P => wp(S,Q). wp(S,Q) = wp(if A>B then Z := A end_if, Z=Max(A,B))

21 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. We need to show P => wp(S,Q). wp(S,Q) = wp(if A>B then Z := A end_if, Z=Max(A,B)) = (A>B Л wp(Z := A, Z=Max(A,B)) V (A≤B Л Z=Max(A,B))

22 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. We need to show P => wp(S,Q). wp(S,Q) = wp(if A>B then Z := A end_if, 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))

23 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. We need to show P => wp(S,Q). wp(S,Q) = wp(if A>B then Z := A end_if, 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) V (A≤B Л Z=B)

24 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. Does Z=B => [(A>B) V (A≤B Л Z=B)] ?

25 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. Does Z=B => [(A>B) V (A≤B Л Z=B)] ? Z=B => { [(A>B) V (A≤B Л Z=B)] = [(A>B) V (A≤B Л true)] }

26 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. Does Z=B => [(A>B) V (A≤B Л Z=B)] ? Z=B => { [(A>B) V (A≤B Л Z=B)] = [(A>B) V (A≤B Л true)] = [(A>B) V (A≤B)] }

27 2. Consider the assertion: {Z=B} if A>B then Z := A end_if {Z=Max(A,B)} Use the WEAKEST PRECONDITION-BASED METHOD to prove the assertion. Show all steps. Does Z=B => [(A>B) V (A≤B Л Z=B)] ? Z=B => { [(A>B) V (A≤B Л Z=B)] = [(A>B) V (A≤B Л true)] = [(A>B) V (A≤B)] = true } √


Download ppt "1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is all painted)"

Similar presentations


Ads by Google