Invariant Proof
Invariant Proof
March 1, 2011
From y ≥ 0 & i = y it follows that i ≥ 0, which proves the second part of our invariant.
Also, at loop entry,
r = (y − i) ∗ x = 0 ∗ x = 0
which holds as well, proving our invariant holds at loop entry.
I is maintained over loop iteration We want to prove
1
Since i > 0 and i0 = i − 1 it follows that i0 ≥ 0. The first part of the invariant holds as follows:
r0 = r + x
= (y − i) ∗ x + x
= (y − i + 1) ∗ x
= (y − (i − 1)) ∗ x
= (y − i0 ) ∗ x
Hence, we have proven that all three conditions for the invariant hold.