Allow (set-logic ...) after (reset) (#3457)
authorAndres Noetzli <andres.noetzli@gmail.com>
Wed, 13 Nov 2019 22:14:09 +0000 (14:14 -0800)
committerGitHub <noreply@github.com>
Wed, 13 Nov 2019 22:14:09 +0000 (14:14 -0800)
Fixes #3353. #3062 introduced a flag that tracks whether we have seen a
`(set-logic ...)` command to improve the handling of `--force-logic`.
However, the flag was not set to `false` when `(reset)` was called. This
commit fixes the issue.

src/parser/smt2/smt2.cpp
test/regress/CMakeLists.txt
test/regress/regress0/smtlib/reset-force-logic.smt2 [new file with mode: 0644]
test/regress/regress0/smtlib/reset-set-logic.smt2 [new file with mode: 0644]

index f9942049a78d460f04d2c0599aa1aed0f045c1dc..8031e81e6259e56b3774861966566e17ed193e2e 100644 (file)
@@ -610,6 +610,7 @@ void Smt2::pushDefineFunRecScope(
 
 void Smt2::reset() {
   d_logicSet = false;
+  d_seenSetLogic = false;
   d_logic = LogicInfo();
   operatorKindMap.clear();
   d_lastNamedTerm = std::pair<Expr, std::string>();
index aa5329e2f535cff20cbfe7d69563badd1faa047e..0d953c19e52eaf84aed927276924ac8c1763cbf9 100644 (file)
@@ -851,6 +851,8 @@ set(regress_0_tests
   regress0/smtlib/get-unsat-assumptions.smt2
   regress0/smtlib/global-decls.smt2
   regress0/smtlib/reason-unknown.smt2
+  regress0/smtlib/reset-force-logic.smt2
+  regress0/smtlib/reset-set-logic.smt2
   regress0/smtlib/set-info-status.smt2
   regress0/strings/bug001.smt2
   regress0/strings/bug002.smt2
diff --git a/test/regress/regress0/smtlib/reset-force-logic.smt2 b/test/regress/regress0/smtlib/reset-force-logic.smt2
new file mode 100644 (file)
index 0000000..91aac50
--- /dev/null
@@ -0,0 +1,17 @@
+; COMMAND-LINE: --force-logic QF_LIRA
+; EXPECT: sat
+; EXPECT: sat
+
+; Intentionally set the wrong logic
+(set-logic QF_BV)
+(declare-const x Real)
+(assert (= x (- 2.5)))
+(check-sat)
+
+(reset)
+
+; Intentionally set the wrong logic
+(set-logic QF_BV)
+(declare-const x Int)
+(assert (= x 2))
+(check-sat)
diff --git a/test/regress/regress0/smtlib/reset-set-logic.smt2 b/test/regress/regress0/smtlib/reset-set-logic.smt2
new file mode 100644 (file)
index 0000000..361af3d
--- /dev/null
@@ -0,0 +1,13 @@
+; EXPECT: sat
+; EXPECT: sat
+(set-logic QF_LRA)
+(declare-const x Real)
+(assert (= x (- 2.5)))
+(check-sat)
+
+(reset)
+
+(set-logic QF_LIA)
+(declare-const x Int)
+(assert (= x 2))
+(check-sat)