Enforcing --no-bv-eq, --no-bv-algebraic and --no-bv-ineq when proofs are enabled...
authoryoni206 <yoni206@users.noreply.github.com>
Fri, 20 Apr 2018 22:07:55 +0000 (15:07 -0700)
committerGitHub <noreply@github.com>
Fri, 20 Apr 2018 22:07:55 +0000 (15:07 -0700)
Currently, if the user enables proofs but does not disable the algebraic/equality/inequality bv-solvers, then we reach an internal error while printing the proof (unreachable code becomes reachable).
This commit auto-disable these bv options when proofs are enabled, unless these options were set by the user. In such a case, an error message is given to the user.

src/smt/smt_engine.cpp
src/theory/bv/theory_bv.cpp
test/regress/Makefile.tests
test/regress/regress0/bv/bv-options1.smt2 [new file with mode: 0644]
test/regress/regress0/bv/bv-options2.smt2 [new file with mode: 0644]
test/regress/regress0/bv/bv-options3.smt2 [new file with mode: 0644]
test/regress/regress0/bv/bv-options4.smt2 [new file with mode: 0644]
test/regress/run_regression.py

index a65d558597260d4ace3c0729322662b0e3e941f5..9cb3387c8cd763f5d112a1657a568dd6bc5f7636 100644 (file)
@@ -2173,6 +2173,42 @@ void SmtEngine::setDefaults() {
     Warning() << "SmtEngine: turning off incremental solving mode (not yet supported with --proof, try --tear-down-incremental instead)" << endl;
     setOption("incremental", SExpr("false"));
   }
+
+  if (options::proof())
+  {
+    if (options::bitvectorAlgebraicSolver())
+    {
+      if (options::bitvectorAlgebraicSolver.wasSetByUser())
+      {
+        throw OptionException(
+            "--bv-algebraic-solver is not supported with proofs");
+      }
+      Notice() << "SmtEngine: turning off bv algebraic solver to support proofs"
+               << std::endl;
+      options::bitvectorAlgebraicSolver.set(false);
+    }
+    if (options::bitvectorEqualitySolver())
+    {
+      if (options::bitvectorEqualitySolver.wasSetByUser())
+      {
+        throw OptionException("--bv-eq-solver is not supported with proofs");
+      }
+      Notice() << "SmtEngine: turning off bv eq solver to support proofs"
+               << std::endl;
+      options::bitvectorEqualitySolver.set(false);
+    }
+    if (options::bitvectorInequalitySolver())
+    {
+      if (options::bitvectorInequalitySolver.wasSetByUser())
+      {
+        throw OptionException(
+            "--bv-inequality-solver is not supported with proofs");
+      }
+      Notice() << "SmtEngine: turning off bv ineq solver to support proofs"
+               << std::endl;
+      options::bitvectorInequalitySolver.set(false);
+    }
+  }
 }
 
 void SmtEngine::setProblemExtended(bool value)
index 47f2b9245e51f17c1ab78e6a79d97df31ad49c7b..1b1e83ae33b6c2ae5409d4a2b07d9b895296ad8c 100644 (file)
@@ -74,25 +74,27 @@ TheoryBV::TheoryBV(context::Context* c, context::UserContext* u,
   setupExtTheory();
   getExtTheory()->addFunctionKind(kind::BITVECTOR_TO_NAT);
   getExtTheory()->addFunctionKind(kind::INT_TO_BITVECTOR);
-
   if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) {
     d_eagerSolver = new EagerBitblastSolver(this);
     return;
   }
 
-  if (options::bitvectorEqualitySolver()) {
+  if (options::bitvectorEqualitySolver() && !options::proof())
+  {
     SubtheorySolver* core_solver = new CoreSolver(c, this);
     d_subtheories.push_back(core_solver);
     d_subtheoryMap[SUB_CORE] = core_solver;
   }
 
-  if (options::bitvectorInequalitySolver()) {
+  if (options::bitvectorInequalitySolver() && !options::proof())
+  {
     SubtheorySolver* ineq_solver = new InequalitySolver(c, u, this);
     d_subtheories.push_back(ineq_solver);
     d_subtheoryMap[SUB_INEQUALITY] = ineq_solver;
   }
 
-  if (options::bitvectorAlgebraicSolver()) {
+  if (options::bitvectorAlgebraicSolver() && !options::proof())
+  {
     SubtheorySolver* alg_solver = new AlgebraicSolver(c, this);
     d_subtheories.push_back(alg_solver);
     d_subtheoryMap[SUB_ALGEBRAIC] = alg_solver;
index a292369148543d5bcad401e235afb043c90f85cf..88ea4ebd5c69168528477d12f9243d32ed230cf1 100644 (file)
@@ -161,6 +161,10 @@ REG0_TESTS = \
        regress0/bv/bug734.smt2 \
        regress0/bv/bv-int-collapse1.smt2 \
        regress0/bv/bv-int-collapse2.smt2 \
+       regress0/bv/bv-options1.smt2 \
+       regress0/bv/bv-options2.smt2 \
+       regress0/bv/bv-options3.smt2 \
+       regress0/bv/bv-options4.smt2 \
        regress0/bv/bv2nat-ground-c.smt2 \
        regress0/bv/bv2nat-simp-range.smt2 \
        regress0/bv/bvmul-pow2-only.smt2 \
diff --git a/test/regress/regress0/bv/bv-options1.smt2 b/test/regress/regress0/bv/bv-options1.smt2
new file mode 100644 (file)
index 0000000..b1e87fc
--- /dev/null
@@ -0,0 +1,24 @@
+; SCRUBBER: sed -e 's/(error \"Error.in.option.parsing.*$/Error in option parsing/'
+; EXPECT: Error in option parsing
+; COMMAND-LINE: --check-proofs --bv-algebraic-solver
+; EXIT: 1
+(set-logic QF_BV)
+(set-info :smt-lib-version 2.0)
+(set-info :category "crafted")
+(declare-fun v0 () (_ BitVec 16))
+(declare-fun v1 () (_ BitVec 16))
+(declare-fun v2 () (_ BitVec 16))
+(declare-fun v3 () (_ BitVec 16))
+(declare-fun v4 () (_ BitVec 16))
+(declare-fun v5 () (_ BitVec 16))
+(assert (and
+        (bvult v2 v4)
+        (bvult v3 v4)
+        (bvult v0 v1)
+        (bvult v1 v2)
+        (bvult v1 v3)
+        (bvult v4 v5)
+        (bvult v5 v1)
+        ))
+(check-sat)
+(exit)
diff --git a/test/regress/regress0/bv/bv-options2.smt2 b/test/regress/regress0/bv/bv-options2.smt2
new file mode 100644 (file)
index 0000000..d1ee440
--- /dev/null
@@ -0,0 +1,24 @@
+; SCRUBBER: sed -e 's/(error \"Error.in.option.parsing.*$/Error in option parsing/'
+; EXPECT: Error in option parsing
+; COMMAND-LINE: --check-proofs --bv-eq-solver
+; EXIT: 1
+(set-logic QF_BV)
+(set-info :smt-lib-version 2.0)
+(set-info :category "crafted")
+(declare-fun v0 () (_ BitVec 16))
+(declare-fun v1 () (_ BitVec 16))
+(declare-fun v2 () (_ BitVec 16))
+(declare-fun v3 () (_ BitVec 16))
+(declare-fun v4 () (_ BitVec 16))
+(declare-fun v5 () (_ BitVec 16))
+(assert (and
+        (bvult v2 v4)
+        (bvult v3 v4)
+        (bvult v0 v1)
+        (bvult v1 v2)
+        (bvult v1 v3)
+        (bvult v4 v5)
+        (bvult v5 v1)
+        ))
+(check-sat)
+(exit)
diff --git a/test/regress/regress0/bv/bv-options3.smt2 b/test/regress/regress0/bv/bv-options3.smt2
new file mode 100644 (file)
index 0000000..4d16230
--- /dev/null
@@ -0,0 +1,24 @@
+; SCRUBBER: sed -e 's/(error \"Error.in.option.parsing.*$/Error in option parsing/'
+; EXPECT: Error in option parsing
+; COMMAND-LINE: --check-proofs --bv-inequality-solver
+; EXIT: 1
+(set-logic QF_BV)
+(set-info :smt-lib-version 2.0)
+(set-info :category "crafted")
+(declare-fun v0 () (_ BitVec 16))
+(declare-fun v1 () (_ BitVec 16))
+(declare-fun v2 () (_ BitVec 16))
+(declare-fun v3 () (_ BitVec 16))
+(declare-fun v4 () (_ BitVec 16))
+(declare-fun v5 () (_ BitVec 16))
+(assert (and
+        (bvult v2 v4)
+        (bvult v3 v4)
+        (bvult v0 v1)
+        (bvult v1 v2)
+        (bvult v1 v3)
+        (bvult v4 v5)
+        (bvult v5 v1)
+        ))
+(check-sat)
+(exit)
diff --git a/test/regress/regress0/bv/bv-options4.smt2 b/test/regress/regress0/bv/bv-options4.smt2
new file mode 100644 (file)
index 0000000..842650e
--- /dev/null
@@ -0,0 +1,24 @@
+; SCRUBBER: sed -e 's/unsat.*/unsat/'
+; EXPECT: unsat
+; COMMAND-LINE: --check-proofs 
+; EXIT: 0
+(set-logic QF_BV)
+(set-info :smt-lib-version 2.0)
+(set-info :category "crafted")
+(declare-fun v0 () (_ BitVec 16))
+(declare-fun v1 () (_ BitVec 16))
+(declare-fun v2 () (_ BitVec 16))
+(declare-fun v3 () (_ BitVec 16))
+(declare-fun v4 () (_ BitVec 16))
+(declare-fun v5 () (_ BitVec 16))
+(assert (and
+        (bvult v2 v4)
+        (bvult v3 v4)
+        (bvult v0 v1)
+        (bvult v1 v2)
+        (bvult v1 v3)
+        (bvult v4 v5)
+        (bvult v5 v1)
+        ))
+(check-sat)
+(exit)
index db72854eb5d90c1fa70b3a73b874165e45b3c745..ea744d83839ac0cfc1d929eca6ce3f7e3b97a87d 100755 (executable)
@@ -201,13 +201,6 @@ def run_regression(proof, dump, wrapper, cvc4_binary, benchmark_path, timeout):
             # If there is no expected output/error and the exit status has not
             # been set explicitly, the benchmark is invalid.
             sys.exit('Cannot determine status of "{}"'.format(benchmark_path))
-
-    if not proof and ('(get-unsat-core)' in benchmark_content
-                      or '(get-unsat-assumptions)' in benchmark_content):
-        print(
-            '1..0 # Skipped: unsat cores not supported without proof support')
-        return
-
     if expected_exit_status is None:
         expected_exit_status = 0
 
@@ -216,6 +209,13 @@ def run_regression(proof, dump, wrapper, cvc4_binary, benchmark_path, timeout):
             os.environ['CVC4_REGRESSION_ARGS'])
     basic_command_line_args += shlex.split(command_line)
     command_line_args_configs = [basic_command_line_args]
+    if not proof and ('(get-unsat-core)' in benchmark_content
+                      or '(get-unsat-assumptions)' in benchmark_content
+                      or '--check-proofs' in basic_command_line_args
+                      or '--dump-proofs' in basic_command_line_args):
+        print(
+            '1..0 # Skipped: unsat cores not supported without proof support')
+        return
 
     extra_command_line_args = []
     if benchmark_ext == '.sy' and \