- Our running example of the assignment can now be restated as follows:
wp( x := 1/y, x = 1/y ) = ( y ≠ 0 )
- As another example, consider the assignment
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.
- On the other hand, if we have no condition on
x
but simply want to state its value, we have
wp( x := x + 1, x = A ) = ( x = A – 1 )
Again, this may seem backward, but a little reflection should convince you of its correctness.