M HYPE SPLASH
// news

Precondition of while loop program?

By Emma Terry
$\begingroup$

I am having trouble finding precondition for the following program. Consider the following program segment:

x:=x+y;
if (x<0) then abort
else while (x != y) do x:=x+1; y:=y+2 od
fi

If it is assumed that its postcondition is ${x = y}$, then which condition is its precondition?

These are some of the choices that professors at my university make:

a) $x=2y$ and $y < 2$

b) $x>2y$ and $y=2$

c) $x=2y$ and $y>2 $

d) $x<2y$ and $y>2$

Hope for the help of everyone. Thanks for very much!

$\endgroup$ 6 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy