Slide 10.5: The weakest precondition wp (cont.) Slide 10.7: General properties of wp Home |
wp
(Cont.)
C
as the function wp(C, _)
from assertions to assertions.
This function is a predicate transformer in that it takes a predicate as argument and returns a predicate result.
A predicate is explained as follows:
For instance, {It also appears to work backward, in that it computes the weakest precondition from any postcondition. Three examples of finding the weakest preconditionx
|x
is a positive integer less than 4} is the set {1, 2, 3}. Thus, an element of {x
|S(x)
} is an objectt
for which the statementS(t)
is true. Such a sentenceS(x)
is called a predicate.
wp
are as follows:
wp( x := 1/y, x = 1/y ) = ( y ≠ 0 )
x := x + 1
and the postcondition x > 0
:
wp( x := x + 1, x > 0 ) = ( x > -1 )In other words, for
x
to be greater than 0 after the execution of x := x + 1
, x
must be great than -1 just prior to execution.
x
but simply want to state its value, we have
wp( x := x + 1, x = A ) = ( x = A – 1 )