Proving loop programs

Given a `DO WHILE' program P and a function F on a domain D, the authors investigate the problem of proving (or disproving) if P computes F over D. It is shown that if P satisfies certain natural constraints (well behaved), then there is a loop assertion independent of the structure of the loop body, that is both necessary and sufficient for proving the hypothesis. These results are extended to classes of loop programs which are not well behaved and to FOR loops. The sufficiency of Hoare's DO WHILE axiom for well-behaved loop programs is shown. Applications of these ideas to the problem of mechanical generation of assertions is discussed.