Skip to content

Commit

Permalink
Performance improvements to incremental invariant generation
Browse files Browse the repository at this point in the history
  • Loading branch information
agacek committed Nov 14, 2012
1 parent 9ef1637 commit a48447a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
bin
*.xml
*.yc_base
*.yc_induct
*.yc_inv
47 changes: 27 additions & 20 deletions src/jkind/processes/InvariantProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public void main() {
debug("No invariants proposed");
return;
}

assertInductiveTransition(0);

for (int k = 1; k <= kMax; k++) {
debug("K = " + k);

Expand Down Expand Up @@ -77,40 +76,39 @@ private void defineCandidates(List<Candidate> candidates) {
}
}

private void assertInductiveTransition(int k) {
solver.send(new Cons("assert", new Cons(Keywords.T, getInductiveIndex(k))));
}

private Sexp getInductiveIndex(int offset) {
return new Cons("+", Keywords.N, Sexp.fromInt(offset));
}

private boolean refineBaseStep(int k, Graph graph) {
private void refineBaseStep(int k, Graph graph) {
solver.push();
SolverResult result;
boolean refined = false;

for (int i = 0; i < k; i++) {
assertBaseTransition(i);
}

do {
result = solver.query(getBaseQuery(k, graph));
result = solver.query(graph.toInvariant(Sexp.fromInt(k - 1)));

if (result.getResult() == Result.SAT) {
refined = true;
if (result.getResult() == Result.SAT) {
graph.refine(result.getModel(), BigInteger.valueOf(k - 1));
debug("Base step refinement, graph size = " + graph.size());
}
} while (!graph.isTrivial() && result.getResult() == Result.SAT);

return refined;
solver.pop();
}

private Sexp getBaseQuery(int k, Graph graph) {
Sexp inv = graph.toInvariant(Sexp.fromInt(k - 1));
return new Cons("=>", new Cons("=", Keywords.N, Sexp.fromInt(k - 1)), inv);
private void assertBaseTransition(int i) {
solver.send(new Cons("assert", new Cons(Keywords.T, Sexp.fromInt(i))));
}

private Graph refineInductiveStep(int k, Graph original) {
solver.push();
Graph graph = new Graph(original);
SolverResult result;

for (int i = 0; i <= k; i++) {
assertInductiveTransition(i);
}

do {
result = solver.query(getInductiveQuery(k, graph));

Expand All @@ -122,9 +120,18 @@ private Graph refineInductiveStep(int k, Graph original) {
}
} while (!graph.isTrivial() && result.getResult() != Result.UNSAT);

solver.pop();
return graph;
}

private void assertInductiveTransition(int k) {
solver.send(new Cons("assert", new Cons(Keywords.T, getInductiveIndex(k))));
}

private Sexp getInductiveIndex(int offset) {
return new Cons("+", Keywords.N, Sexp.fromInt(offset));
}

private BigInteger getN(Model model) {
NumericValue value = (NumericValue) model.getValue(Keywords.N);
return new BigInteger(value.toString());
Expand Down

0 comments on commit a48447a

Please sign in to comment.