Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Commit

Permalink
Add (check-sat) to preprocess context before proving goal
Browse files Browse the repository at this point in the history
  • Loading branch information
bmmoore committed Nov 17, 2017
1 parent 1b4fb8e commit 199a476
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ public static String translateImplication(
sb.append(leftTransformer.getConstantDeclarations(Sets.difference(
Sets.union(leftTransformer.variables(), rightTransformer.variables()),
rightHandSideOnlyVariables)));
sb.append("(assert (and ");
sb.append("(assert ");
sb.append(leftExpression);
sb.append(" (not ");
sb.append(")\n(check-sat)\n(assert (not ");
rightHandSideOnlyVariables = Sets.intersection(
rightTransformer.variables(),
rightHandSideOnlyVariables);
Expand All @@ -210,7 +210,7 @@ public static String translateImplication(
if (!rightHandSideOnlyVariables.isEmpty()) {
sb.append(")");
}
sb.append(")))");
sb.append("))");
return sb.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean impliesSMT(
Set<Variable> rightOnlyVariables) {
if (smtOptions.smt == SMTSolver.Z3) {
try {
return z3.isUnsat(
return z3.isImplication(
KILtoSMTLib.translateImplication(left, right, rightOnlyVariables),
smtOptions.z3ImplTimeout);
} catch (UnsupportedOperationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ public Z3Wrapper(

public synchronized boolean isUnsat(String query, int timeout) {
if (options.z3Executable) {
return checkQueryWithExternalProcess(query, timeout);
return checkQueryWithExternalProcess(query, 0, timeout);
} else {
return checkQueryWithLibrary(query, timeout);
}
}

public synchronized boolean isImplication(String query, int timeout) {
if (options.z3Executable) {
return checkQueryWithExternalProcess(query, 1, timeout);
} else {
return checkQueryWithLibrary(query, timeout);
}
Expand All @@ -76,7 +84,7 @@ private boolean checkQueryWithLibrary(String query, int timeout) {
return result;
}

private boolean checkQueryWithExternalProcess(String query, int timeout) {
private boolean checkQueryWithExternalProcess(String query, int intermediateCheckSatCalls, int timeout) {
String result = "";
try {
for (int i = 0; i < Z3_RESTART_LIMIT; i++) {
Expand All @@ -94,6 +102,16 @@ private boolean checkQueryWithExternalProcess(String query, int timeout) {
z3Process.getInputStream()));
input.write(SMT_PRELUDE + query + "(check-sat)\n");
input.flush();
input.close();
for (int ignores = 0; ignores < intermediateCheckSatCalls; ++ignores) {
result = output.readLine();
if (result == null) {
break;
}
if (globalOptions.debug && !Z3_QUERY_RESULTS.contains(result)) {
break;
}
}
result = output.readLine();
z3Process.destroy();
if (result != null) {
Expand Down

0 comments on commit 199a476

Please sign in to comment.