Skip to content

Commit eee7ca5

Browse files
Z3 option change (runtimeverification#199)
1. SMT options: replaced --z3-executable with --z3-jni which is the opposite. Executable is now the default. 2. Fixed a bug in simplifyModuloPatternFolding that can lead to AssertionError.
1 parent 1f97066 commit eee7ca5

5 files changed

Lines changed: 14 additions & 9 deletions

File tree

java-backend/src/main/java/org/kframework/backend/java/kil/ConstrainedTerm.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,12 @@ public ConjunctiveFormula matchImplies(ConstrainedTerm constrainedTerm, boolean
149149

150150
/* apply pattern folding */
151151
constraint = constraint.simplifyModuloPatternFolding(context)
152-
.add(constrainedTerm.data.constraint)
153-
.simplifyModuloPatternFolding(context);
152+
.add(constrainedTerm.data.constraint);
153+
if (constraint.isFalse()) {
154+
return null;
155+
}
156+
157+
constraint = constraint.simplifyModuloPatternFolding(context);
154158
if (constraint.isFalse()) {
155159
return null;
156160
}

java-backend/src/main/java/org/kframework/backend/java/util/Z3Wrapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public Z3Wrapper(
4949
}
5050

5151
public synchronized boolean isUnsat(CharSequence query, int timeout, Z3Profiler timer) {
52-
if (options.z3Executable) {
53-
return checkQueryWithExternalProcess(query, timeout, timer);
54-
} else {
52+
if (options.z3JNI) {
5553
return checkQueryWithLibrary(query, timeout);
54+
} else {
55+
return checkQueryWithExternalProcess(query, timeout, timer);
5656
}
5757
}
5858

k-distribution/include/ktest-keq.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $(DEF2)/$(DEF2)-kompiled/timestamp: $(DEF2).k
2323
$(KOMPILE) $< -d $(DEF2) --backend java
2424

2525
keq: $(SPEC1) $(SPEC2) kompile
26-
$(KEQ) -d $(DEF0) -d1 $(DEF1) -d2 $(DEF2) -s1 $(SPEC1) -s2 $(SPEC2) -sm1 $(MODULE1) -sm2 $(MODULE2) --smt_prelude $(BASIC_SMT) --z3-executable
26+
$(KEQ) -d $(DEF0) -d1 $(DEF1) -d2 $(DEF2) -s1 $(SPEC1) -s2 $(SPEC2) -sm1 $(MODULE1) -sm2 $(MODULE2) --smt_prelude $(BASIC_SMT)
2727

2828
clean:
2929
rm -rf $(DEF0) $(DEF1) $(DEF2)

k-distribution/include/ktest.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ else
4949
endif
5050

5151
%-spec.k: kompile
52-
$(KPROVE) $(KPROVE_FLAGS) -d $(DEFDIR) --z3-executable $@ $(CHECK) $@.out
52+
$(KPROVE) $(KPROVE_FLAGS) -d $(DEFDIR) $@ $(CHECK) $@.out
5353

5454
clean:
5555
rm -rf $(DEFDIR)/$(DEF)-kompiled

kernel/src/main/java/org/kframework/utils/options/SMTOptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ public Class<SMTSolver> enumClass() {
4141
@Parameter(names={"--smt-prelude", "--smt_prelude"}, description="Path to the SMT prelude file.")
4242
public String smtPrelude;
4343

44-
@Parameter(names="--z3-executable", description="Invokes Z3 as an external process.")
45-
public boolean z3Executable = false;
44+
@Parameter(names="--z3-jni", description="Invokes Z3 as JNI library. Default is external process. " +
45+
"JNI is slightly faster, but can potentially lead to JVM crash.")
46+
public boolean z3JNI = false;
4647

4748
@Parameter(names="--z3-cnstr-timeout", description="The default soft timeout (in milli seconds) of Z3 for checking constraint satisfiability.")
4849
public int z3CnstrTimeout = 50;

0 commit comments

Comments
 (0)