Inference of polynomial invariants for imperative programs:
a farewell to Gröbner
A companion web page

Additional material

Benchmarks and measurements


A Caml implementation

The annotation Java package

The fast polynomial invariant generator (last update: 06/25/12)

How to use it

How to annotate your classes

Simply annotated the method you would like to analyze with @Analyze.

Examples

The Mannadiv class, implementing the division algorithm from Manna's "Mathematical Theory of Computation".

import quantitative.Analyze;

public class Mannadiv {

  @Analyze 
  public static void main(String[] args) {
    int x1, x2, y1, y2, y3;
    x1 = Integer.parseInt(args[0]);
    x2 = Integer.parseInt(args[1]);
    y1 = 0;
    y2 = 0;
    y3 = x1;
    while (y3 != 0) {
      if (x2 == y2 + 1) {
        y1++;
        y2 = 0;
        y3--;
      } else {
        y2++;
        y3--;
      }
      System.out.format("x1 = %d, x2 = %d\ny1 = %d, y2 = %d, y3 = %d\n", x1, x2, y1, y2, y3);
    }
  }
}

The Knuth class, implementing the divisor research algorithm from Knuth's "The Art of Computer Programming, Volume 2".

import quantitative.Analyze;

public class Knuth {

  @Analyze
  public static void main(String[] args) {
    int n, d, r, rp, q, t, n1, n2;
    double s;
    n  = Integer.parseInt(args[0]);
    d  = Integer.parseInt(args[1]);
    n1 = n/d;
    n2 = n/(d-2);
    r  = n - n1 * d;
    rp = n - n2 * (d-2);
    q  = 4 * (n2 - n1);
    s  = Math.sqrt(n);

    while ((s >= d) && (r != 0)) {
      if (2*r-rp+q < 0) {
        t  = r;
        r  = 2*r-rp+q+d+2;
        rp = t;
        q  = q+4;
        d  = d+2;
      } else if ((2*r-rp+q >= 0) && (2*r-rp+q < d+2))  {
        t  = r;
        r  = 2*r-rp+q;
        rp = t;
        d  = d+2;
      } else if ((2*r-rp+q >= 0) && (2*r-rp+q >= d+2) && (2*r-rp+q < 2*d+4)) {
        t  = r;
        r  = 2*r-rp+q-d-2;
        rp = t;
        q  = q-4;
        d  = d+2;
      } else { /* ((2*r-rp+q >= 0) && (2*r-rp+q >= 2*d+4)) */
        t  = r;
        r  = 2*r-rp+q-2*d-4;
        rp = t;
        q  = q-8;
        d  = d+2;
      }
      System.out.format("n = %d, d = %d\nr = %d, rp = %d, q = %d, s = %f, t = %d, n1 = %d, n2 = %d\n", n, d, r, rp, q, s, t, n1, n2);
    }
    System.out.format("Result: d = %d\n", d);
  }
}