A data driven approach for algebraic loop invariants

  • Authors:
  • Rahul Sharma;Saurabh Gupta;Bharath Hariharan;Alex Aiken;Percy Liang;Aditya V. Nori

  • Affiliations:
  • Stanford University;University of California at Berkeley;University of California at Berkeley;Stanford University;Stanford University;Microsoft Research, India

  • Venue:
  • ESOP'13 Proceedings of the 22nd European conference on Programming Languages and Systems
  • Year:
  • 2013

Quantified Score

Hi-index 0.00

Visualization

Abstract

We describe a Guess-and-Check algorithm for computing algebraic equation invariants of the form ∧ifi(x1,…,xn)=0, where each fi is a polynomial over the variables x1,…,xn of the program. The "guess" phase is data driven and derives a candidate invariant from data generated from concrete executions of the program. This candidate invariant is subsequently validated in a "check" phase by an off-the-shelf SMT solver. Iterating between the two phases leads to a sound algorithm. Moreover, we are able to prove a bound on the number of decision procedure queries which Guess-and-Check requires to obtain a sound invariant. We show how Guess-and-Check can be extended to generate arbitrary boolean combinations of linear equalities as invariants, which enables us to generate expressive invariants to be consumed by tools that cannot handle non-linear arithmetic. We have evaluated our technique on a number of benchmark programs from recent papers on invariant generation. Our results are encouraging --- we are able to efficiently compute algebraic invariants in all cases, with only a few tests.