[API] Add mode argument for `Solver::blockModel()` (#8521)
authorAndres Noetzli <andres.noetzli@gmail.com>
Fri, 1 Apr 2022 16:26:14 +0000 (09:26 -0700)
committerGitHub <noreply@github.com>
Fri, 1 Apr 2022 16:26:14 +0000 (16:26 +0000)
This commit changes Solver::blockModel() to take a mode as an argument
instead of relying on an option.

27 files changed:
src/api/cpp/cvc5.cpp
src/api/cpp/cvc5.h
src/api/java/CMakeLists.txt
src/api/java/genenums.py.in
src/api/java/io/github/cvc5/Solver.java
src/api/java/jni/solver.cpp
src/api/python/cvc5.pxd
src/api/python/cvc5.pxi
src/options/smt_options.toml
src/parser/smt2/Smt2.g
src/parser/smt2/smt2.cpp
src/parser/smt2/smt2.h
src/printer/printer.cpp
src/printer/printer.h
src/printer/smt2/smt2_printer.cpp
src/printer/smt2/smt2_printer.h
src/smt/command.cpp
src/smt/command.h
src/smt/model_blocker.cpp
src/smt/model_blocker.h
src/smt/solver_engine.cpp
src/smt/solver_engine.h
test/regress/cli/regress1/model-blocker-simple.smt2
test/regress/cli/regress1/model-blocker-values.smt2
test/unit/api/cpp/solver_black.cpp
test/unit/api/java/SolverTest.java
test/unit/api/python/test_solver.py

index b7e44a85061466ef05c05d7987e2ee466a12e713..f5d8f6ad4c22227e6fd7c590b39128e6d4ad3dd1 100644 (file)
@@ -7282,7 +7282,7 @@ Term Solver::getAbductNext() const
   CVC5_API_TRY_CATCH_END;
 }
 
-void Solver::blockModel() const
+void Solver::blockModel(modes::BlockModelsMode mode) const
 {
   CVC5_API_TRY_CATCH_BEGIN;
   CVC5_API_CHECK(d_slv->getOptions().smt.produceModels)
@@ -7291,7 +7291,7 @@ void Solver::blockModel() const
   CVC5_API_RECOVERABLE_CHECK(d_slv->isSmtModeSat())
       << "Can only block model after SAT or UNKNOWN response.";
   //////// all checks before this line
-  d_slv->blockModel();
+  d_slv->blockModel(mode);
   ////////
   CVC5_API_TRY_CATCH_END;
 }
index b8bab4bcc9231c59e2d7dac913737aa547155ead..147700fe5fd67c8365a1fbcc886d4beb73efc220 100644 (file)
@@ -4506,8 +4506,10 @@ class CVC5_EXPORT Solver
    * \endverbatim
    *
    * @warning This method is experimental and may change in future versions.
+   *
+   * @param mode The mode to use for blocking
    */
-  void blockModel() const;
+  void blockModel(modes::BlockModelsMode mode) const;
 
   /**
    * Block the current model values of (at least) the values in terms. Can be
index 1c2507f3824c72d59783df767a6ab4276e99013a..2c73f48c2f57ff6715ff8c4242fcf3f91385c05d 100644 (file)
@@ -40,7 +40,7 @@ add_custom_command(
 add_custom_target(generate-java-kinds DEPENDS ${JAVA_KIND_FILE})
 
 set(JAVA_TYPES_FILES
-  "${CMAKE_CURRENT_BINARY_DIR}/io/github/cvc5/BlockModelsMode.java"
+  "${CMAKE_CURRENT_BINARY_DIR}/io/github/cvc5/modes/BlockModelsMode.java"
   "${CMAKE_CURRENT_BINARY_DIR}/io/github/cvc5/RoundingMode.java"
   "${CMAKE_CURRENT_BINARY_DIR}/io/github/cvc5/UnknownExplanation.java"
 )
index a83076486d3bdc9be35614147741de984c5729bd..0140a6fb2a0f6fe00dae6cd29b5d7f7521e4db51 100644 (file)
@@ -36,6 +36,7 @@ DEFAULT_PREFIX = 'Kind'
 ENUM_JAVA_TOP = \
     r"""package io.github.{namespace};
 
+import io.github.cvc5.CVC5ApiException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -162,7 +163,7 @@ def gen_java(parser: EnumParser, path):
     for namespace in parser.namespaces:
         for enum in namespace.enums:
             subnamespace = namespace.name.replace('::', '.')
-            filedir = os.path.join(path, subnamespace)
+            filedir = os.path.join(path, subnamespace.replace('.', '/'))
             if not os.path.exists(filedir):
                 os.mkdir(filedir)
             filename = os.path.join(filedir, enum.name + ".java")
index ea4bc5f1169e4f9295ecf72f66ae6a68c4a327b0..23ad027e41741b73149906d1359d623212c3288d 100644 (file)
@@ -15,6 +15,7 @@
 
 package io.github.cvc5;
 
+import io.github.cvc5.modes.BlockModelsMode;
 import java.io.IOException;
 import java.util.*;
 
@@ -2420,13 +2421,15 @@ public class Solver implements IPointer, AutoCloseable
    * to a mode other than "none".
    *
    * @api.note This method is experimental and may change in future versions.
+   *
+   * @param mode The mode to use for blocking
    */
-  public void blockModel()
+  public void blockModel(BlockModelsMode mode)
   {
-    blockModel(pointer);
+    blockModel(pointer, mode.getValue());
   }
 
-  private native void blockModel(long pointer);
+  private native void blockModel(long pointer, int modeValue);
 
   /**
    * Block the current model values of (at least) the values in terms. Can be
index 41ada6adeaaee77662716129050d84e349aa8542..4bf41d335e3c26132d2f0c44ca9cd51c151c880c 100644 (file)
@@ -2289,15 +2289,17 @@ JNIEXPORT jlong JNICALL Java_io_github_cvc5_Solver_getAbductNext(
 /*
  * Class:     io_github_cvc5_Solver
  * Method:    blockModel
- * Signature: (J)V
+ * Signature: (JI)V
  */
 JNIEXPORT void JNICALL Java_io_github_cvc5_Solver_blockModel(JNIEnv* env,
-                                                                 jobject,
-                                                                 jlong pointer)
+                                                             jobject,
+                                                             jlong pointer,
+                                                             jint modeValue)
 {
   CVC5_JAVA_API_TRY_CATCH_BEGIN;
   Solver* solver = reinterpret_cast<Solver*>(pointer);
-  solver->blockModel();
+  modes::BlockModelsMode mode = static_cast<modes::BlockModelsMode>(modeValue);
+  solver->blockModel(mode);
   CVC5_JAVA_API_TRY_CATCH_END(env);
 }
 
index 13e5041ca984f636c3f6c58f54f31ef6fb56aede..bfde85399fe9cbdd234d937fb9775a1d302c48d8 100644 (file)
@@ -9,7 +9,7 @@ from libcpp.vector cimport vector
 from libcpp.map cimport map
 from libcpp.pair cimport pair
 from cvc5kinds cimport Kind
-from cvc5types cimport RoundingMode, UnknownExplanation
+from cvc5types cimport BlockModelsMode, RoundingMode, UnknownExplanation
 
 
 cdef extern from "<iostream>" namespace "std":
@@ -352,6 +352,7 @@ cdef extern from "api/cpp/cvc5.h" namespace "cvc5":
         Term getAbduct(const Term& conj, Grammar& grammar) except +
         Term getAbductNext() except +
         void blockModel() except +
+        void blockModel(BlockModelsMode mode) except +
         void blockModelValues(const vector[Term]& terms) except +
         string getInstantiations() except +
         Statistics getStatistics() except +
index 1b227e5040f73d8873959ecee39d0f0a40031cd5..bfc139b1a94f2ee9de358860eb016477517f0318 100644 (file)
@@ -37,6 +37,7 @@ from cvc5 cimport wstring as c_wstring
 from cvc5 cimport tuple as c_tuple
 from cvc5 cimport get0, get1, get2
 from cvc5kinds cimport Kind as c_Kind
+from cvc5types cimport BlockModelsMode as c_BlockModelsMode
 from cvc5types cimport RoundingMode as c_RoundingMode
 from cvc5types cimport UnknownExplanation as c_UnknownExplanation
 
@@ -2843,7 +2844,7 @@ cdef class Solver:
         result.cterm  = self.csolver.getAbductNext()
         return result
 
-    def blockModel(self):
+    def blockModel(self, mode):
         """
             Block the current model. Can be called only if immediately preceded
             by a SAT or INVALID query.
@@ -2862,8 +2863,10 @@ cdef class Solver:
 
             .. warning:: This method is experimental and may change in future
                          versions.
+
+            :param mode: The mode to use for blocking
         """
-        self.csolver.blockModel()
+        self.csolver.blockModel(<c_BlockModelsMode> mode.value)
 
     def blockModelValues(self, terms):
         """
index 9aebabde618cb97448173147bc432d8952432d4f..645d0629631bd87abbe746f84123d931e09f7022 100644 (file)
@@ -92,24 +92,6 @@ name   = "SMT Layer"
   name = "non-implied"
   help = "Only include a subset of variables whose values, in addition to the values of variables whose values are implied, are sufficient to show the input formula is satisfied by the given model."
 
-[[option]]
-  name       = "blockModelsMode"
-  category   = "expert"
-  long       = "block-models=MODE"
-  type       = "BlockModelsMode"
-  default    = "NONE"
-  help       = "mode for producing several models"
-  help_mode  = "Blocking models modes."
-[[option.mode.NONE]]
-  name = "none"
-  help = "Do not block models."
-[[option.mode.LITERALS]]
-  name = "literals"
-  help = "Block models based on the SAT skeleton."
-[[option.mode.VALUES]]
-  name = "values"
-  help = "Block models based on the concrete model values for the free variables."
-
 [[option]]
   name       = "produceLearnedLiterals"
   category   = "regular"
index c0458c4f506bebcd4a40a589fd2f41335e8ef655..188f6ad06f9ee1ea83219d20b01ac4370841260e 100644 (file)
@@ -1045,9 +1045,13 @@ extendedCommand[std::unique_ptr<cvc5::Command>* cmd]
       PARSER_STATE->defineVar(name, pool);
       cmd->reset(new DeclarePoolCommand(name, pool, t, terms));
     }
-  | BLOCK_MODEL_TOK { PARSER_STATE->checkThatLogicIsSet(); }
-    { cmd->reset(new BlockModelCommand()); }
-
+  | BLOCK_MODEL_TOK KEYWORD { PARSER_STATE->checkThatLogicIsSet(); }
+    {
+      modes::BlockModelsMode mode =
+        PARSER_STATE->getBlockModelsMode(
+          AntlrInput::tokenText($KEYWORD).c_str() + 1);
+      cmd->reset(new BlockModelCommand(mode));
+    }
   | BLOCK_MODEL_VALUES_TOK { PARSER_STATE->checkThatLogicIsSet(); }
     ( LPAREN_TOK termList[terms,e] RPAREN_TOK
       { cmd->reset(new BlockModelValuesCommand(terms)); }
index b27d477c97d40d6248bb1b49990a3bcd70537ae1..bf610ae86683244b8ea98770e30050bd0b6eb1cb 100644 (file)
@@ -299,6 +299,20 @@ bool Smt2::isOperatorEnabled(const std::string& name) const {
   return d_operatorKindMap.find(name) != d_operatorKindMap.end();
 }
 
+modes::BlockModelsMode Smt2::getBlockModelsMode(const std::string& mode)
+{
+  if (mode == "literals")
+  {
+    return modes::BlockModelsMode::LITERALS;
+  }
+  else if (mode == "values")
+  {
+    return modes::BlockModelsMode::VALUES;
+  }
+  parseError(std::string("Unknown block models mode `") + mode + "'");
+  return modes::BlockModelsMode::LITERALS;
+}
+
 bool Smt2::isTheoryEnabled(internal::theory::TheoryId theory) const
 {
   return d_logic.isTheoryEnabled(theory);
index f844c9802d7d45c06e7b398741f29ad79062fd09..bdf329538b529e335ab939de7b3077f731b43094 100644 (file)
@@ -100,6 +100,8 @@ class Smt2 : public Parser
 
   bool isOperatorEnabled(const std::string& name) const;
 
+  modes::BlockModelsMode getBlockModelsMode(const std::string& mode);
+
   bool isTheoryEnabled(internal::theory::TheoryId theory) const;
 
   /**
index accba62ea3ea15cf6a242385637739b37e340c4b..642a24eabd7c71289c5ff83920b6675be846a887 100644 (file)
@@ -376,7 +376,8 @@ void Printer::toStreamCmdGetModel(std::ostream& out) const
   printUnknownCommand(out, "ge-model");
 }
 
-void Printer::toStreamCmdBlockModel(std::ostream& out) const
+void Printer::toStreamCmdBlockModel(std::ostream& out,
+                                    modes::BlockModelsMode mode) const
 {
   printUnknownCommand(out, "block-model");
 }
index d873b3accc6bdcc36542be6ea5d95d3562e0437e..9b655077cfc7282fda6e502a40f1292262e62bd4 100644 (file)
@@ -185,7 +185,8 @@ class Printer
   virtual void toStreamCmdGetModel(std::ostream& out) const;
 
   /** Print block-model command */
-  virtual void toStreamCmdBlockModel(std::ostream& out) const;
+  virtual void toStreamCmdBlockModel(std::ostream& out,
+                                     modes::BlockModelsMode mode) const;
 
   /** Print block-model-values command */
   virtual void toStreamCmdBlockModelValues(
index 0187c2768591b5e62821f9e67b1fba6e9cdbda50..2aab3d9806cdf1eb755bee7b7f4dcb8b6dc96961 100644 (file)
@@ -1691,9 +1691,17 @@ void Smt2Printer::toStreamCmdGetModel(std::ostream& out) const
   out << "(get-model)" << std::endl;
 }
 
-void Smt2Printer::toStreamCmdBlockModel(std::ostream& out) const
+void Smt2Printer::toStreamCmdBlockModel(std::ostream& out,
+                                        modes::BlockModelsMode mode) const
 {
-  out << "(block-model)" << std::endl;
+  out << "(block-model :";
+  switch (mode)
+  {
+    case modes::BlockModelsMode::LITERALS: out << "literals"; break;
+    case modes::BlockModelsMode::VALUES: out << "values"; break;
+    default: Unreachable() << "Invalid block models mode " << mode;
+  }
+  out << ")" << std::endl;
 }
 
 void Smt2Printer::toStreamCmdBlockModelValues(
index 91a17266ec6eb722e9a065cd2a02b3e44c649297..afa1539adc1440ce01533ab027502a8939a84203 100644 (file)
@@ -159,7 +159,8 @@ class Smt2Printer : public cvc5::internal::Printer
   void toStreamCmdGetModel(std::ostream& out) const override;
 
   /** Print block-model command */
-  void toStreamCmdBlockModel(std::ostream& out) const override;
+  void toStreamCmdBlockModel(std::ostream& out,
+                             modes::BlockModelsMode mode) const override;
 
   /** Print block-model-values command */
   void toStreamCmdBlockModelValues(
index d2f80e853be2301f6731476bf07f5332ae84acf6..e9820940559d4d63ede3365b07836b12cfd5f3c4 100644 (file)
@@ -1698,12 +1698,14 @@ void GetModelCommand::toStream(std::ostream& out,
 /* class BlockModelCommand */
 /* -------------------------------------------------------------------------- */
 
-BlockModelCommand::BlockModelCommand() {}
+BlockModelCommand::BlockModelCommand(modes::BlockModelsMode mode) : d_mode(mode)
+{
+}
 void BlockModelCommand::invoke(cvc5::Solver* solver, SymbolManager* sm)
 {
   try
   {
-    solver->blockModel();
+    solver->blockModel(d_mode);
     d_commandStatus = CommandSuccess::instance();
   }
   catch (cvc5::CVC5ApiRecoverableException& e)
@@ -1718,7 +1720,7 @@ void BlockModelCommand::invoke(cvc5::Solver* solver, SymbolManager* sm)
 
 Command* BlockModelCommand::clone() const
 {
-  BlockModelCommand* c = new BlockModelCommand();
+  BlockModelCommand* c = new BlockModelCommand(d_mode);
   return c;
 }
 
@@ -1729,7 +1731,7 @@ void BlockModelCommand::toStream(std::ostream& out,
                                  size_t dag,
                                  Language language) const
 {
-  Printer::getPrinter(language)->toStreamCmdBlockModel(out);
+  Printer::getPrinter(language)->toStreamCmdBlockModel(out, d_mode);
 }
 
 /* -------------------------------------------------------------------------- */
index e4bab01a9e15aad3392e6efa1f8cbdbdd82ce9fd..a502568d62c1a30f0f6f202b60a5e11759ba230c 100644 (file)
@@ -969,7 +969,7 @@ class CVC5_EXPORT GetModelCommand : public Command
 class CVC5_EXPORT BlockModelCommand : public Command
 {
  public:
-  BlockModelCommand();
+  BlockModelCommand(modes::BlockModelsMode mode);
 
   void invoke(cvc5::Solver* solver, SymbolManager* sm) override;
   Command* clone() const override;
@@ -979,6 +979,10 @@ class CVC5_EXPORT BlockModelCommand : public Command
                 size_t dag = 1,
                 internal::Language language =
                     internal::Language::LANG_AUTO) const override;
+
+ private:
+  /** The mode to use for blocking. */
+  modes::BlockModelsMode d_mode;
 }; /* class BlockModelCommand */
 
 /** The command to block model values. */
index 4cd3f20a22251e4ce8bfdc6447f22fa03a6f5423..518dcd7a6f71f0e2f7b38af324727662a7a16b24 100644 (file)
@@ -29,7 +29,7 @@ ModelBlocker::ModelBlocker(Env& e) : EnvObj(e) {}
 
 Node ModelBlocker::getModelBlocker(const std::vector<Node>& assertions,
                                    theory::TheoryModel* m,
-                                   options::BlockModelsMode mode,
+                                   modes::BlockModelsMode mode,
                                    const std::vector<Node>& exprToBlock)
 {
   NodeManager* nm = NodeManager::currentNM();
@@ -38,7 +38,7 @@ Node ModelBlocker::getModelBlocker(const std::vector<Node>& assertions,
   std::vector<Node> nodesToBlock = exprToBlock;
   Trace("model-blocker") << "Compute model blocker, assertions:" << std::endl;
   Node blocker;
-  if (mode == options::BlockModelsMode::LITERALS)
+  if (mode == modes::BlockModelsMode::LITERALS)
   {
     Assert(nodesToBlock.empty());
     // optimization: filter out top-level unit assertions, as they cannot
@@ -229,7 +229,7 @@ Node ModelBlocker::getModelBlocker(const std::vector<Node>& assertions,
   }
   else
   {
-    Assert(mode == options::BlockModelsMode::VALUES);
+    Assert(mode == modes::BlockModelsMode::VALUES);
     std::vector<Node> blockers;
     // if specific terms were not specified, block all variables of
     // the model
index b6b1f8d0f73a974d601962197775f60598598340..6d10e6c27cae2c529e8da2a56af3fab23f1a9e2f 100644 (file)
@@ -20,8 +20,8 @@
 
 #include <vector>
 
+#include "api/cpp/cvc5_types.h"
 #include "expr/node.h"
-#include "options/smt_options.h"
 #include "smt/env_obj.h"
 
 namespace cvc5::internal {
@@ -68,7 +68,7 @@ class ModelBlocker : protected EnvObj
   Node getModelBlocker(
       const std::vector<Node>& assertions,
       theory::TheoryModel* m,
-      options::BlockModelsMode mode,
+      modes::BlockModelsMode mode,
       const std::vector<Node>& exprToBlock = std::vector<Node>());
 }; /* class TheoryModelCoreBuilder */
 
index 3babf40ae3984c685521c7955cf35f6897908bb4..a074ab758d696e419178cfd38e484ba162254f6c 100644 (file)
@@ -1089,7 +1089,7 @@ std::string SolverEngine::getModel(const std::vector<TypeNode>& declaredSorts,
   return ssm.str();
 }
 
-void SolverEngine::blockModel()
+void SolverEngine::blockModel(modes::BlockModelsMode mode)
 {
   Trace("smt") << "SMT blockModel()" << endl;
   SolverEngineScope smts(this);
@@ -1098,18 +1098,10 @@ void SolverEngine::blockModel()
 
   TheoryModel* m = getAvailableModel("block model");
 
-  if (d_env->getOptions().smt.blockModelsMode == options::BlockModelsMode::NONE)
-  {
-    std::stringstream ss;
-    ss << "Cannot block model when block-models is set to none.";
-    throw RecoverableModalException(ss.str().c_str());
-  }
-
   // get expanded assertions
   std::vector<Node> eassertsProc = getExpandedAssertions();
   ModelBlocker mb(*d_env.get());
-  Node eblocker = mb.getModelBlocker(
-      eassertsProc, m, d_env->getOptions().smt.blockModelsMode);
+  Node eblocker = mb.getModelBlocker(eassertsProc, m, mode);
   Trace("smt") << "Block formula: " << eblocker << std::endl;
   assertFormulaInternal(eblocker);
 }
@@ -1133,7 +1125,7 @@ void SolverEngine::blockModelValues(const std::vector<Node>& exprs)
   // we always do block model values mode here
   ModelBlocker mb(*d_env.get());
   Node eblocker = mb.getModelBlocker(
-      eassertsProc, m, options::BlockModelsMode::VALUES, exprs);
+      eassertsProc, m, modes::BlockModelsMode::VALUES, exprs);
   assertFormulaInternal(eblocker);
 }
 
index bfcc45dce238d84a0e7e4f997884eff4e744e24d..ea45784e75ba5695148f45dec1f336ac849d500c 100644 (file)
@@ -227,7 +227,7 @@ class CVC5_EXPORT SolverEngine
    * This adds an assertion to the assertion stack that blocks the current
    * model based on the current options configured by cvc5.
    */
-  void blockModel();
+  void blockModel(modes::BlockModelsMode mode);
 
   /**
    * Block the current model values of (at least) the values in exprs.
index 526b510078e4e8a2c780890e90fa27ea0e552545..d29f83f2a19024a03f171da479e133c6e3234a34 100644 (file)
@@ -1,4 +1,4 @@
-; COMMAND-LINE: --incremental --produce-models --block-models=literals
+; COMMAND-LINE: --incremental --produce-models
 ; EXPECT: sat
 ; EXPECT: sat
 ; EXPECT: sat
@@ -10,9 +10,9 @@
 (check-sat)
 (block-model-values (x))
 (check-sat)
-(block-model)
+(block-model :literals)
 (check-sat)
 (block-model-values ((+ x 1)))
 (check-sat)
-(block-model)
+(block-model :literals)
 (check-sat)
index 25cb0810c3e5214639fc5e32d6b55b337f07e236..94b7a771779c1e0bd13ef3dee976f260f7bd0450 100644 (file)
@@ -1,4 +1,4 @@
-; COMMAND-LINE: --incremental --produce-models --block-models=values
+; COMMAND-LINE: --incremental --produce-models
 ; EXPECT: sat
 ; EXPECT: sat
 ; if we only block models restricted to (a,b), then there are only 2 models
@@ -14,7 +14,7 @@
 (assert (distinct a b))
 (assert (and (>= a 0) (>= b 0) (< a 2) (< b 2)))
 (check-sat)
-(block-model)
+(block-model :values)
 (check-sat)
-(block-model)
+(block-model :values)
 (check-sat)
index 69bdf60c1f5752c71eca88677203abe2916cce81..204d270a0d3dbccb298b4e7c5b141a6ca295e239 100644 (file)
@@ -2226,45 +2226,34 @@ TEST_F(TestApiBlackSolver, pop3)
 
 TEST_F(TestApiBlackSolver, blockModel1)
 {
-  d_solver.setOption("produce-models", "true");
   Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
   d_solver.assertFormula(x.eqTerm(x));
   d_solver.checkSat();
-  ASSERT_THROW(d_solver.blockModel(), CVC5ApiException);
+  ASSERT_THROW(d_solver.blockModel(modes::BlockModelsMode::LITERALS),
+               CVC5ApiException);
 }
 
 TEST_F(TestApiBlackSolver, blockModel2)
-{
-  d_solver.setOption("block-models", "literals");
-  Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
-  d_solver.assertFormula(x.eqTerm(x));
-  d_solver.checkSat();
-  ASSERT_THROW(d_solver.blockModel(), CVC5ApiException);
-}
-
-TEST_F(TestApiBlackSolver, blockModel3)
 {
   d_solver.setOption("produce-models", "true");
-  d_solver.setOption("block-models", "literals");
   Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
   d_solver.assertFormula(x.eqTerm(x));
-  ASSERT_THROW(d_solver.blockModel(), CVC5ApiException);
+  ASSERT_THROW(d_solver.blockModel(modes::BlockModelsMode::LITERALS),
+               CVC5ApiException);
 }
 
-TEST_F(TestApiBlackSolver, blockModel4)
+TEST_F(TestApiBlackSolver, blockModel3)
 {
   d_solver.setOption("produce-models", "true");
-  d_solver.setOption("block-models", "literals");
   Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
   d_solver.assertFormula(x.eqTerm(x));
   d_solver.checkSat();
-  ASSERT_NO_THROW(d_solver.blockModel());
+  ASSERT_NO_THROW(d_solver.blockModel(modes::BlockModelsMode::LITERALS));
 }
 
 TEST_F(TestApiBlackSolver, blockModelValues1)
 {
   d_solver.setOption("produce-models", "true");
-  d_solver.setOption("block-models", "literals");
   Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
   d_solver.assertFormula(x.eqTerm(x));
   d_solver.checkSat();
@@ -2285,7 +2274,6 @@ TEST_F(TestApiBlackSolver, blockModelValues2)
 
 TEST_F(TestApiBlackSolver, blockModelValues3)
 {
-  d_solver.setOption("block-models", "literals");
   Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
   d_solver.assertFormula(x.eqTerm(x));
   d_solver.checkSat();
@@ -2295,7 +2283,6 @@ TEST_F(TestApiBlackSolver, blockModelValues3)
 TEST_F(TestApiBlackSolver, blockModelValues4)
 {
   d_solver.setOption("produce-models", "true");
-  d_solver.setOption("block-models", "literals");
   Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
   d_solver.assertFormula(x.eqTerm(x));
   ASSERT_THROW(d_solver.blockModelValues({x}), CVC5ApiException);
@@ -2304,7 +2291,6 @@ TEST_F(TestApiBlackSolver, blockModelValues4)
 TEST_F(TestApiBlackSolver, blockModelValues5)
 {
   d_solver.setOption("produce-models", "true");
-  d_solver.setOption("block-models", "literals");
   Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
   d_solver.assertFormula(x.eqTerm(x));
   d_solver.checkSat();
index 41ebf499ae1310f1d3984c413e0362120e3070cf..33ebd2ddb35835a143e7ee05e58bcf1546e1caa0 100644 (file)
@@ -20,6 +20,7 @@ import static io.github.cvc5.RoundingMode.*;
 import static org.junit.jupiter.api.Assertions.*;
 
 import io.github.cvc5.*;
+import io.github.cvc5.modes.BlockModelsMode;
 import java.math.BigInteger;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
@@ -2268,49 +2269,35 @@ class SolverTest
   @Test
   void blockModel1()
   {
-    d_solver.setOption("produce-models", "true");
     Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
     d_solver.assertFormula(x.eqTerm(x));
     d_solver.checkSat();
-    assertThrows(CVC5ApiException.class, () -> d_solver.blockModel());
+    assertThrows(CVC5ApiException.class, () -> d_solver.blockModel(BlockModelsMode.LITERALS));
   }
 
   @Test
   void blockModel2() throws CVC5ApiException
-  {
-    d_solver.setOption("block-models", "literals");
-    Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
-    d_solver.assertFormula(x.eqTerm(x));
-    d_solver.checkSat();
-    assertThrows(CVC5ApiException.class, () -> d_solver.blockModel());
-  }
-
-  @Test
-  void blockModel3() throws CVC5ApiException
   {
     d_solver.setOption("produce-models", "true");
-    d_solver.setOption("block-models", "literals");
     Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
     d_solver.assertFormula(x.eqTerm(x));
-    assertThrows(CVC5ApiException.class, () -> d_solver.blockModel());
+    assertThrows(CVC5ApiException.class, () -> d_solver.blockModel(BlockModelsMode.LITERALS));
   }
 
   @Test
-  void blockModel4() throws CVC5ApiException
+  void blockModel3() throws CVC5ApiException
   {
     d_solver.setOption("produce-models", "true");
-    d_solver.setOption("block-models", "literals");
     Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
     d_solver.assertFormula(x.eqTerm(x));
     d_solver.checkSat();
-    assertDoesNotThrow(() -> d_solver.blockModel());
+    assertDoesNotThrow(() -> d_solver.blockModel(BlockModelsMode.LITERALS));
   }
 
   @Test
   void blockModelValues1() throws CVC5ApiException
   {
     d_solver.setOption("produce-models", "true");
-    d_solver.setOption("block-models", "literals");
     Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
     d_solver.assertFormula(x.eqTerm(x));
     d_solver.checkSat();
@@ -2336,7 +2323,6 @@ class SolverTest
   @Test
   void blockModelValues3() throws CVC5ApiException
   {
-    d_solver.setOption("block-models", "literals");
     Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
     d_solver.assertFormula(x.eqTerm(x));
     d_solver.checkSat();
@@ -2347,7 +2333,6 @@ class SolverTest
   void blockModelValues4() throws CVC5ApiException
   {
     d_solver.setOption("produce-models", "true");
-    d_solver.setOption("block-models", "literals");
     Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
     d_solver.assertFormula(x.eqTerm(x));
     assertThrows(CVC5ApiException.class, () -> d_solver.blockModelValues(new Term[] {x}));
@@ -2357,7 +2342,6 @@ class SolverTest
   void blockModelValues5() throws CVC5ApiException
   {
     d_solver.setOption("produce-models", "true");
-    d_solver.setOption("block-models", "literals");
     Term x = d_solver.mkConst(d_solver.getBooleanSort(), "x");
     d_solver.assertFormula(x.eqTerm(x));
     d_solver.checkSat();
index 7478f244a210eda981b508f528a0b3c20f193239..74dc04620f8ec477fcaebb166f2e48f5889cadd4 100644 (file)
@@ -15,7 +15,7 @@ import pytest
 import cvc5
 import sys
 
-from cvc5 import Kind, RoundingMode
+from cvc5 import Kind, BlockModelsMode, RoundingMode
 
 
 @pytest.fixture
@@ -1577,41 +1577,28 @@ def test_pop3(solver):
         solver.pop(1)
 
 def test_block_model1(solver):
-    solver.setOption("produce-models", "true")
     x = solver.mkConst(solver.getBooleanSort(), "x")
     solver.assertFormula(x.eqTerm(x))
     solver.checkSat()
     with pytest.raises(RuntimeError):
-        solver.blockModel()
+        solver.blockModel(BlockModelsMode.Literals)
 
 def test_block_model2(solver):
-    solver.setOption("block-models", "literals")
-    x = solver.mkConst(solver.getBooleanSort(), "x")
-    solver.assertFormula(x.eqTerm(x))
-    solver.checkSat()
-    with pytest.raises(RuntimeError):
-        solver.blockModel()
-
-def test_block_model3(solver):
     solver.setOption("produce-models", "true")
-    solver.setOption("block-models", "literals")
     x = solver.mkConst(solver.getBooleanSort(), "x")
     solver.assertFormula(x.eqTerm(x))
     with pytest.raises(RuntimeError):
-        solver.blockModel()
+        solver.blockModel(BlockModelsMode.Literals)
 
-
-def test_block_model4(solver):
+def test_block_model3(solver):
     solver.setOption("produce-models", "true")
-    solver.setOption("block-models", "literals")
     x = solver.mkConst(solver.getBooleanSort(), "x");
     solver.assertFormula(x.eqTerm(x))
     solver.checkSat()
-    solver.blockModel()
+    solver.blockModel(BlockModelsMode.Literals)
 
 def test_block_model_values1(solver):
     solver.setOption("produce-models", "true")
-    solver.setOption("block-models", "literals")
     x = solver.mkConst(solver.getBooleanSort(), "x");
     solver.assertFormula(x.eqTerm(x))
     solver.checkSat()
@@ -1630,7 +1617,6 @@ def test_block_model_values2(solver):
     solver.blockModelValues([x])
 
 def test_block_model_values3(solver):
-    solver.setOption("block-models", "literals")
     x = solver.mkConst(solver.getBooleanSort(), "x")
     solver.assertFormula(x.eqTerm(x))
     solver.checkSat()
@@ -1639,7 +1625,6 @@ def test_block_model_values3(solver):
 
 def test_block_model_values4(solver):
     solver.setOption("produce-models", "true")
-    solver.setOption("block-models", "literals")
     x = solver.mkConst(solver.getBooleanSort(), "x")
     solver.assertFormula(x.eqTerm(x))
     with pytest.raises(RuntimeError):
@@ -1647,7 +1632,6 @@ def test_block_model_values4(solver):
 
 def test_block_model_values5(solver):
     solver.setOption("produce-models", "true")
-    solver.setOption("block-models", "literals")
     x = solver.mkConst(solver.getBooleanSort(), "x")
     solver.assertFormula(x.eqTerm(x))
     solver.checkSat()