Using a Loop Invariant at Exit
An invariant describes maintained facts. The loop's exit condition says which facts about remaining work hold when it finishes.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Trace a sum
If the accumulator equals the sum of the first i entries and exit occurs at i=n, then the accumulator equals the sum of all n. See preservation of a step.
Check termination separately
An invariant can hold even during an infinite run. Establish that execution reaches the required boundary if the contract promises a result. Termination measures provide one technique.[1]