A loop invariant is type of assertion that remains true from one repetition of the loop to the next. Usually, the invariant describes some non-trivial relationship between the variables changed by the loop. For example, if a program has a loop which adds one to inc and subtracts one from dec then the sum of inc and dec will be a constant. Loop invariants are a common type of invariant.
a boolean expression that is true each time the loop guard is evaluated
a condition that should be applicable at the end of each iteration of the loop
a constraint on the input to a loop that should be satisfied by every iteration of the loop
a constraint on the input to an iterative loop (e
a constraint that should be satisfied by everyiteration of a loop
a logical assertion about the state of the program at a key point in the loop, which is supposed to be always true
a property of, or relationship among, the values of the loop variables such that the property is true both initially and after each iteration of the loop; together with the termination condition, a loop invariant is useful in demonstrating the correctness of a loop
In computer science, a loop invariant is an invariant used to prove properties of loops.