Loop invariant

  • Authors:
  • David Gries

  • Affiliations:
  • -

  • Venue:
  • Encyclopedia of Computer Science
  • Year:
  • 2003

Quantified Score

Hi-index 0.00

Visualization

Abstract

Consider a loop while B do S, where B is a Boollean expression and S a statement. This form of loop appears in most modern high-level languages. Let P be some true-false statement about the variables of the programm in which the loop appears. P is a loop invariant if execution of the loop body S begun in any state in which P and B are true terminates with P true. For example, consider the loop