1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is...
-
Upload
kenneth-stafford -
Category
Documents
-
view
219 -
download
2
Transcript of 1.Determine the following weakest pre-conditions. a. wp(paint the living room ceiling, the house is...
1. Determine the following weakest pre-conditions.
a. wp(paint the living room ceiling, the house is all painted)
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.
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.
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!)
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.”)
b. wp(i := j-1, A[i] is the smallest element in A[1], A[2], ..., A[i])
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]
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)
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)
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)
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)
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)
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)
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
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)
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)
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)
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.
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).
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))
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))
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))
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)
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)] ?
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)] }
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)] }
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 }
√