Invariant

A statement about a program that stays true the whole way through, even inside a loop. Naming it makes a loop provably correct: "everything before `i` is sorted" tells you when the loop may stop.

Back to the glossary