Incorrect Answer.


The program P:
x = y;
if (x < z) { x = z; }

satisfies the Hoare triple x = y P x = y with respect to the partial correctness relation par, if at any state satisfying "x = y", if the program P terminates, then the resulting store satisfies "x = y". While the first assignment statement "x = y;" maintains the property that the values of x and y are equal, the if-statement may change that, provided that the value of x is less than the value of z. For then x will obtain the value of z which is different from the value of y (since x and y have the same value in the current store in which x is less than z). For example, consider the initial store in which the values of x, y, and z are 2, 3, and 4, respectively. If P begins executing in that store, it terminates such that the values of x and y will be 4 and 3, respectively.
Back to Question.
Next Question.