Automatic Generation of Polynomial Loop Invariants: Algebraic Foundations

This paper presents the algebraic foundation for an approach for generating polynomial loop invariants in imperative programs. It is first shown that the set of polynomials serving as loop invariants has the algebraic structure of an ideal. Using this connection, a procedure for finding loop invariants is given in terms of operations on ideals, for which Grobner basis constructions can be employed. Most importantly, it is proved that if the assignment statements in a loop are solvable (in particular, affine) mappings with positive eigenvalues, then the procedure terminates in at most 2m+1 iterations, where m is the number of variables in the loop. The proof is done by showing that the irreducible subvarieties of the variety associated with the polynomial ideal approximating the invariant polynomial ideal of the loop either stay the same or increase their dimension in every iteration. This yields a correct and complete algorithm for inferring conjunctions of polynomial equations as invariants. The method has been implemented in Maple using the Groebner package. The implementation has been used to automatically discover nontrivial invariants for several examples to illustrate the power of the techniques.

[1]  Michael Karr,et al.  Affine relationships among variables of a program , 1976, Acta Informatica.

[2]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[3]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[4]  Ben Wegbreit,et al.  The synthesis of loop predicates , 1974, CACM.

[5]  Steven M. German,et al.  A synthesizer of inductive assertions , 1975, IEEE Transactions on Software Engineering.

[6]  Donal O'Shea,et al.  Ideals, varieties, and algorithms - an introduction to computational algebraic geometry and commutative algebra (2. ed.) , 1997, Undergraduate texts in mathematics.

[7]  David A. Cox,et al.  Ideals, Varieties, and Algorithms , 1997 .

[8]  Deepak Kapur,et al.  Automatic Generation of Polynomial Loop Invariants for Imperative Programs ? , .

[9]  C. A. R. Hoare,et al.  The verifying compiler: A grand challenge for computing research , 2003, JACM.

[10]  Zohar Manna,et al.  Logical analysis of programs , 1976, CACM.

[11]  Alan F. Blackwell,et al.  Programming , 1973, CSC '73.

[12]  Edward Cohen,et al.  Programming in the 1990s , 1990, Texts and Monographs in Computer Science.

[13]  Henny B. Sipma,et al.  Non-linear loop invariant generation using Gröbner bases , 2004, POPL.

[14]  David M. Bressoud Factorization and Primality Testing , 1989 .

[15]  Donald Ervin Knuth,et al.  The Art of Computer Programming, Volume II: Seminumerical Algorithms , 1970 .

[16]  Ben Wegbreit,et al.  Property extraction in well-founded property sets , 1975, IEEE Transactions on Software Engineering.

[17]  Edsger W. Dijkstra,et al.  A Discipline of Programming , 1976 .

[18]  Henny B. Sipma,et al.  Linear Invariant Generation Using Non-linear Constraint Solving , 2003, CAV.

[19]  Anne Kaldewaij,et al.  Programming - the derivation of algorithms , 1990, Prentice Hall international series in computer science.

[20]  Markus Müller Interprocedurally Valid Relations in Affine Prog rams , 2004 .

[21]  R. Stanley What Is Enumerative Combinatorics , 1986 .

[22]  Nicolas Halbwachs,et al.  Automatic discovery of linear restraints among variables of a program , 1978, POPL.