Reputation: 111
Compute the weakest precondition for each of the following assignment statements and postconditions:
a = a + 2 * b - 1 {a > 1}
attempt:
a is on both sides
0 = 2b -1
1/2 = b is the weakest precon
answer: b > 1 - a/2
how do you get this answer?
Upvotes: 1
Views: 5255
Reputation: 31
Here is answer :
a = a + 2 * b - 1 {a > 1}
We replace a in {a > 1}
by a + 2 * b - 1
a + 2 * b - 1 > 1
a + 2 * b > 2
2 * b > 2 - a
b > 1 - a / 2`
I think you found the answer since but for the people who might get here looking for this answer.
Upvotes: 3