How do I solve this? The answer is the well-formed formula is incorrect when $x = -1$ and $y = -1$. Can someone explain to me why that is the answer?
{True} If x < y then y:= y - x {y>0}
How do I solve this? The answer is the well-formed formula is incorrect when $x = -1$ and $y = -1$. Can someone explain to me why that is the answer?
{True} If x < y then y:= y - x {y>0}
{True} If x < y then y:= y - x {y>0} is a Hoare triple, in which {True} is the precondition, {y>0} is the postcondition, and If x < y then y:= y - x is the command. The question is whether assuming the precondition holds before the command is carried out, the postcondition is then guaranteed to hold.
Since the precondition is unconditionally satisfied, nothing is assumed about the values of x and y. In particular, as suggested by the solution key, it may be that x = y = -1. If that's the case the guard x < y is false, and the assignment y := y - x does not take place. Hence, x and y keep their values, which violate the postcondition y > 0.