1

Is this correct, for weakest pre-condition respectively strongest post-condition?

{P} x = x-x; {x'=x}
P: x = 0

{true} y = y-y; {Q}
Q: y = 0

Edit:

I started by applying this as follows:

{true} y = y - y {Q} ==> sp(y = y-y; true) = ∃x,y = x-x ∧ true

Now I'm not sure what to do with this; In my mind "y = 0" would make most sense, but that doesn't seem correct.

user452306
  • 139
  • 4
  • 9

1 Answers1

1

The stronger is the precondition, the stronger is the postcondition. For example,

{y = 5} x := 8 {x = 8; y = 5}

If the precondition is the weakest one instead, i.e. true, there are no valid assumptions about the value of y in the postcondition.

Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35
  • I'm not sure I follow; does that mean we can't define a valid strongest post-condition? Because I'm pretty sure there *is* a valid answer to find. – user452306 Jan 29 '18 at 10:56
  • The strongest postcondition for the weakest precondition `true` is `x = 8`. However, if the precondition is stronger, e.g. `y = 5`, the postcondition is stronger as well. – Alexander Kogtenkov Jan 29 '18 at 14:32