I was doing exercise about program verification, and I had some difficulties in finding this loop invariant:
y = 0;
while (y != x) {
y = y + 1;
}
the precondition is x>=0 and the postcondition is x=y
In the loop there is just one variable so I couldn't think any possible relation that is preserved throughout the program. One weak invariant so far is (y>= 0 && y<=x). So what is the suitable loop invariant for this program?