I saw an example program which sets every value in an array to 0:
int a[n]; int i = 0;
while(i < n) {
a[i] = 0;
i++;
}
It said that part of the loop invariant was 0<=i<n
. However, after the loop is finished terminating, i will equal n. Am i correct in saying that this is then not part of the loop invariant? If so, what should it be replaced with?
The full invariant was For All j (0<= j < i --> a[i] = 0) & 0 <= i < n)