1

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?

Smit Shah
  • 111
  • 1
  • 6

1 Answers1

3

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.

Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53
Archor
  • 31
  • 3