- loop invariants
- straight-line programs are easy to understand (relatively)
- programs with loops are harder to understand
- what's happening while it's looping
- when does it stop looping
- the trick - find something about the loop that's always true
- easier to verify something stays true
- always true - before, during, and after
- example - search for an element in a vector
- the invariant must be true before the loop executes
- it must be true after the guard executes
- it must be true at the end of the loop body
- it will be true after the loop exits
- the combination of the invariant and negated loop guard gives what we
want
This page last modified on 17 September 2002.