Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online. In computer
science, a loop variant is a mathematical function defined on the state
space of a computer program whose value is monotonically decreased with
respect to a well-founded relation by the iteration of a while loop
under some invariant conditions, thereby ensuring its termination. A
loop variant whose range is restricted to the non-negative integers is
also known as a bound function, because in this case it provides a
trivial upper bound on the number of iterations of a loop before it
terminates. In general, however, the smallest set sufficient to
represent the range of any loop variant that might be useful in a
termination proof is an ordinal number at least ¿1CK, but no more than
¿1. The existence of a variant proves the termination of a while loop in
a computer program by well-founded descent. A basic property of a
well-founded relation is that it has no infinite descending chains.
Therefore a loop possessing a variant will terminate after a finite
number of iterations, as long as its body terminates each time.