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

Forked smt #2380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class KILtoSMTLib extends CopyOnWriteTransformer {
"int_max",
"int_min",
"int_abs",
"int_and",
/* extra float theory */
"remainder",
"min",
Expand Down Expand Up @@ -194,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 @@ -209,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 @@ -63,7 +63,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 | SMTTranslationFailure 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
2 changes: 1 addition & 1 deletion k-distribution/include/builtin/domains.k
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ module INT
Int ">>Int" Int [function, left, latex({#1}\mathrel{\gg_{\scriptstyle\it Int}}{#2}), hook(INT.shr)]
| Int "<<Int" Int [function, left, latex({#1}\mathrel{\ll_{\scriptstyle\it Int}}{#2}), hook(INT.shl)]
> left:
Int "&Int" Int [function, left, latex({#1}\mathrel{\&_{\scriptstyle\it Int}}{#2}), hook(INT.and)]
Int "&Int" Int [function, left, smtlib(int_and), latex({#1}\mathrel{\&_{\scriptstyle\it Int}}{#2}), hook(INT.and)]
> left:
Int "xorInt" Int [function, left, latex({#1}\mathrel{\oplus_{\scriptstyle\it Int}}{#2}), hook(INT.xor)]
> left:
Expand Down