0
if x < 15:
    x = x+1
else:
    x = 0

the post condition is: Q = {0 <= x <= 15}

is the correct pre condition P1 = {-1 <= x} or P2 = {0 <= x <= 15}

And how can I calculate it?

A. Ano
  • 31
  • 2

1 Answers1

0

Both are valid preconditions for the code fragment and postcondition, so you want to choose the weaker one, which in this case is P1. (P2 specifies a narrower range of values for x, all of which are present in the range specified by P1.)

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880