The program I need to prove is
if(x>y){
z=x;
}else{
z=y;
}
And I need to show that (where the P here should be the program above) is vaild, what I can do is to prove its partial correctness, but how to prove its total correctness?
Here is my proof of the partial correctness:
{T}
{(x>y -> x=max(x,y) ) ∧ (\neg(x>y) -> y=max(x,y) ) }
if (x>y)
{T∧x>y} If-statement
{x=max(x,y)} Implied
z=x
{z=max(x,y)} Assignment
else
{T∧¬(x>y)} If-statement
{y=max(x,y)} Implied
z=y
{z=max(x,y)} Assignment
fi
{z=max(x,y)} If-statement