Eliminate more circular dependencies on solver engine (#7311)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Thu, 7 Oct 2021 01:16:20 +0000 (20:16 -0500)
committerGitHub <noreply@github.com>
Thu, 7 Oct 2021 01:16:20 +0000 (01:16 +0000)
This is work towards replacing our old dump infrastructure. This PR also does some initial reorganization towards printing assertions using the print benchmark utility.

20 files changed:
src/prop/prop_engine.cpp
src/prop/prop_engine.h
src/prop/prop_proof_manager.cpp
src/prop/prop_proof_manager.h
src/smt/assertions.cpp
src/smt/assertions.h
src/smt/check_models.cpp
src/smt/check_models.h
src/smt/preprocessor.cpp
src/smt/preprocessor.h
src/smt/process_assertions.cpp
src/smt/process_assertions.h
src/smt/proof_manager.cpp
src/smt/set_defaults.cpp
src/smt/smt_solver.cpp
src/smt/smt_solver.h
src/smt/solver_engine.cpp
src/smt/sygus_solver.cpp
src/smt/sygus_solver.h
src/smt/unsat_core_manager.cpp

index a98ab02c7eea2e82f9d0224d5bed0e6012dac499..5bd719fe9e01df5c9dfbfee97726c6bd47c054e6 100644 (file)
@@ -656,7 +656,7 @@ bool PropEngine::properExplanation(TNode node, TNode expl) const
   return true;
 }
 
-void PropEngine::checkProof(context::CDList<Node>* assertions)
+void PropEngine::checkProof(const context::CDList<Node>& assertions)
 {
   if (!d_env.isSatProofProducing())
   {
index ba2c80f46de1d303c521e1b055230219c078adb2..3556108d16575d78cf685f6e53fa07b9b6920da4 100644 (file)
@@ -286,7 +286,7 @@ class PropEngine
 
   /** Checks that the proof is closed w.r.t. asserted formulas to this engine as
    * well as to the given assertions. */
-  void checkProof(context::CDList<Node>* assertions);
+  void checkProof(const context::CDList<Node>& assertions);
 
   /**
    * Return the prop engine proof. This should be called only when proofs are
index 09c5fb915ee0ebd6c3070bc1587c0fbe2e8c251c..4fb027e54cddcaf47101027111b453a721d8c412 100644 (file)
@@ -46,7 +46,7 @@ void PropPfManager::registerAssertion(Node assertion)
   d_assertions.push_back(assertion);
 }
 
-void PropPfManager::checkProof(context::CDList<Node>* assertions)
+void PropPfManager::checkProof(const context::CDList<Node>& assertions)
 {
   Trace("sat-proof") << "PropPfManager::checkProof: Checking if resolution "
                         "proof of false is closed\n";
@@ -55,7 +55,7 @@ void PropPfManager::checkProof(context::CDList<Node>* assertions)
   // connect it with CNF proof
   d_pfpp->process(conflictProof);
   // add given assertions d_assertions
-  for (const Node& assertion : *assertions)
+  for (const Node& assertion : assertions)
   {
     d_assertions.push_back(assertion);
   }
index e415ed4415a79f0d755cb11faaae3a9884fd9e89..0af1833c3783b012ecf009d81041c43d3bac1911 100644 (file)
@@ -73,7 +73,7 @@ class PropPfManager
    * engine's proof with the preprocessing proof) and these changes survive for
    * a next check-sat call.
    */
-  void checkProof(context::CDList<Node>* assertions);
+  void checkProof(const context::CDList<Node>& assertions);
 
  private:
   /** A node manager */
index 704a369159073b145e34057436021b68201d41c9..a9f7ce18e421348f0378df7c55993164d9a56065 100644 (file)
@@ -35,10 +35,11 @@ namespace cvc5 {
 namespace smt {
 
 Assertions::Assertions(Env& env, AbstractValues& absv)
-    : d_env(env),
+    : EnvObj(env),
       d_absValues(absv),
       d_produceAssertions(false),
-      d_assertionList(env.getUserContext()),
+      d_assertionList(userContext()),
+      d_assertionListDefs(userContext()),
       d_globalNegation(false),
       d_assertions()
 {
@@ -104,7 +105,7 @@ void Assertions::initializeCheckSat(const std::vector<Node>& assumptions,
     Node n = d_absValues.substituteAbstractValues(e);
     // Ensure expr is type-checked at this point.
     ensureBoolean(n);
-    addFormula(n, true, true, false, false);
+    addFormula(n, true, false, false);
   }
   if (d_globalDefineFunLemmas != nullptr)
   {
@@ -113,7 +114,7 @@ void Assertions::initializeCheckSat(const std::vector<Node>& assumptions,
     // zero assertions)
     for (const Node& lemma : *d_globalDefineFunLemmas)
     {
-      addFormula(lemma, true, false, true, false);
+      addFormula(lemma, false, true, false);
     }
   }
 }
@@ -122,7 +123,7 @@ void Assertions::assertFormula(const Node& n)
 {
   ensureBoolean(n);
   bool maybeHasFv = language::isLangSygus(options::inputLanguage());
-  addFormula(n, true, false, false, maybeHasFv);
+  addFormula(n, false, false, maybeHasFv);
 }
 
 std::vector<Node>& Assertions::getAssumptions() { return d_assumptions; }
@@ -134,13 +135,17 @@ preprocessing::AssertionPipeline& Assertions::getAssertionPipeline()
   return d_assertions;
 }
 
-context::CDList<Node>* Assertions::getAssertionList()
+const context::CDList<Node>& Assertions::getAssertionList() const
 {
-  return d_produceAssertions ? &d_assertionList : nullptr;
+  return d_assertionList;
+}
+
+const context::CDList<Node>& Assertions::getAssertionListDefinitions() const
+{
+  return d_assertionListDefs;
 }
 
 void Assertions::addFormula(TNode n,
-                            bool inInput,
                             bool isAssumption,
                             bool isFunDef,
                             bool maybeHasFv)
@@ -149,13 +154,17 @@ void Assertions::addFormula(TNode n,
   if (d_produceAssertions)
   {
     d_assertionList.push_back(n);
+    if (isFunDef)
+    {
+      d_assertionListDefs.push_back(n);
+    }
   }
   if (n.isConst() && n.getConst<bool>())
   {
     // true, nothing to do
     return;
   }
-  Trace("smt") << "Assertions::addFormula(" << n << ", inInput = " << inInput
+  Trace("smt") << "Assertions::addFormula(" << n
                << ", isAssumption = " << isAssumption
                << ", isFunDef = " << isFunDef << std::endl;
   if (isFunDef)
@@ -215,7 +224,7 @@ void Assertions::addDefineFunDefinition(Node n, bool global)
     // definitions currently. Thus, we should check for free variables if the
     // input language is SyGuS.
     bool maybeHasFv = language::isLangSygus(options::inputLanguage());
-    addFormula(n, true, false, true, maybeHasFv);
+    addFormula(n, false, true, maybeHasFv);
   }
 }
 
index de7ba72c9260762b2733aad3ce01fa34b5ce106d..15131be60c71b1aa8963ba4065dd4e4eff2197e3 100644 (file)
 #include "context/cdlist.h"
 #include "expr/node.h"
 #include "preprocessing/assertion_pipeline.h"
+#include "smt/env_obj.h"
 
 namespace cvc5 {
-
-class Env;
-
 namespace smt {
 
 class AbstractValues;
@@ -39,7 +37,7 @@ class AbstractValues;
  * check-sat calls. It is *not* responsible for the preprocessing itself, and
  * instead is intended to be the input to a preprocessor utility.
  */
-class Assertions
+class Assertions : protected EnvObj
 {
   /** The type of our internal assertion list */
   typedef context::CDList<Node> AssertionList;
@@ -94,9 +92,15 @@ class Assertions
   preprocessing::AssertionPipeline& getAssertionPipeline();
   /**
    * Get assertions list corresponding to the original list of assertions,
-   * before preprocessing.
+   * before preprocessing. This includes assertions corresponding to define-fun
+   * and define-fun-rec.
+   */
+  const context::CDList<Node>& getAssertionList() const;
+  /**
+   * Get assertions list corresponding to the original list of assertions
+   * that correspond to definitions (define-fun or define-fun-rec).
    */
-  context::CDList<Node>* getAssertionList();
+  const context::CDList<Node>& getAssertionListDefinitions() const;
   /**
    * Get the list of assumptions, which are those registered to this class
    * on initializeCheckSat.
@@ -141,21 +145,19 @@ class Assertions
    * (this is used to distinguish assertions and assumptions)
    */
   void addFormula(TNode n,
-                  bool inInput,
                   bool isAssumption,
                   bool isFunDef,
                   bool maybeHasFv);
-  /** Reference to the environment. */
-  Env& d_env;
   /** Reference to the abstract values utility */
   AbstractValues& d_absValues;
   /** Whether we are producing assertions */
   bool d_produceAssertions;
   /**
-   * The assertion list (before any conversion) for supporting
-   * getAssertions().  Only maintained if in incremental mode.
+   * The assertion list (before any conversion) for supporting getAssertions().
    */
   AssertionList d_assertionList;
+  /** The subset of above the correspond to define-fun or define-fun-rec */
+  AssertionList d_assertionListDefs;
   /**
    * List of lemmas generated for global (recursive) function definitions. We
    * assert this list of definitions in each check-sat call.
index f928a2ce85366df724300cec070ea59ca7076a76..f148d101866a8e1e18feba6cbda8cbf16efff884 100644 (file)
@@ -35,7 +35,7 @@ CheckModels::CheckModels(Env& e) : d_env(e) {}
 CheckModels::~CheckModels() {}
 
 void CheckModels::checkModel(TheoryModel* m,
-                             context::CDList<Node>* al,
+                             const context::CDList<Node>& al,
                              bool hardFailure)
 {
   // Throughout, we use Notice() to give diagnostic output.
@@ -57,7 +57,7 @@ void CheckModels::checkModel(TheoryModel* m,
   // the list of assertions that did not rewrite to true
   std::vector<Node> noCheckList;
   // Now go through all our user assertions checking if they're satisfied.
-  for (const Node& assertion : *al)
+  for (const Node& assertion : al)
   {
     Notice() << "SolverEngine::checkModel(): checking assertion " << assertion
              << std::endl;
index fbfb1c2f5313c90b9a1f56e699c00102f839cecf..d785b53d5fef60cfb5293ff2f5ebcac14dba82de 100644 (file)
@@ -46,7 +46,7 @@ class CheckModels
    * given assertion list al based on the model checking policy.
    */
   void checkModel(theory::TheoryModel* m,
-                  context::CDList<Node>* al,
+                  const context::CDList<Node>& al,
                   bool hardFailure);
 
  private:
index fd736860d9e47bf27f90edc361061f0f69a9d6b3..e66269f718d78359f2b5f4009252752cc1461afc 100644 (file)
@@ -35,17 +35,15 @@ using namespace cvc5::kind;
 namespace cvc5 {
 namespace smt {
 
-Preprocessor::Preprocessor(SolverEngine& slv,
-                           Env& env,
+Preprocessor::Preprocessor(Env& env,
                            AbstractValues& abs,
                            SmtEngineStatistics& stats)
-    : d_slv(slv),
-      d_env(env),
+    : EnvObj(env),
       d_absValues(abs),
       d_propagator(true, true),
       d_assertionsProcessed(env.getUserContext(), false),
       d_exDefs(env, stats),
-      d_processor(slv, *env.getResourceManager(), stats),
+      d_processor(env, stats),
       d_pnm(nullptr)
 {
 }
@@ -59,10 +57,10 @@ Preprocessor::~Preprocessor()
   }
 }
 
-void Preprocessor::finishInit()
+void Preprocessor::finishInit(SolverEngine* slv)
 {
-  d_ppContext.reset(new preprocessing::PreprocessingPassContext(
-      &d_slv, d_env, &d_propagator));
+  d_ppContext.reset(
+      new preprocessing::PreprocessingPassContext(slv, d_env, &d_propagator));
 
   // initialize the preprocessing passes
   d_processor.finishInit(d_ppContext.get());
@@ -149,8 +147,7 @@ Node Preprocessor::simplify(const Node& node)
   Trace("smt") << "SMT simplify(" << node << ")" << endl;
   if (Dump.isOn("benchmark"))
   {
-    d_slv.getOutputManager().getPrinter().toStreamCmdSimplify(
-        d_slv.getOutputManager().getDumpOut(), node);
+    d_env.getPrinter().toStreamCmdSimplify(d_env.getDumpOut(), node);
   }
   Node ret = expandDefinitions(node);
   ret = theory::Rewriter::rewrite(ret);
@@ -162,7 +159,7 @@ void Preprocessor::setProofGenerator(PreprocessProofGenerator* pppg)
   Assert(pppg != nullptr);
   d_pnm = pppg->getManager();
   d_exDefs.setProofNodeManager(d_pnm);
-  d_propagator.setProof(d_pnm, d_env.getUserContext(), pppg);
+  d_propagator.setProof(d_pnm, userContext(), pppg);
 }
 
 }  // namespace smt
index 2f5775cebe6076d92b1a03b14d5362b57663590d..35eb5d35af81ba9d15f613e3f6a2707c0a50c93a 100644 (file)
 
 #include <memory>
 
+#include "smt/env_obj.h"
 #include "smt/expand_definitions.h"
 #include "smt/process_assertions.h"
 #include "theory/booleans/circuit_propagator.h"
 
 namespace cvc5 {
-class Env;
+
+class SolverEngine;
+
 namespace preprocessing {
 class PreprocessingPassContext;
 }
@@ -43,18 +46,15 @@ class PreprocessProofGenerator;
  * (2) implementing methods for expanding and simplifying formulas. The latter
  * takes into account the substitutions inferred by this class.
  */
-class Preprocessor
+class Preprocessor : protected EnvObj
 {
  public:
-  Preprocessor(SolverEngine& smt,
-               Env& env,
-               AbstractValues& abs,
-               SmtEngineStatistics& stats);
+  Preprocessor(Env& env, AbstractValues& abs, SmtEngineStatistics& stats);
   ~Preprocessor();
   /**
    * Finish initialization
    */
-  void finishInit();
+  void finishInit(SolverEngine* slv);
   /**
    * Process the assertions that have been asserted in argument as. Returns
    * true if no conflict was discovered while preprocessing them.
@@ -98,10 +98,6 @@ class Preprocessor
   void setProofGenerator(PreprocessProofGenerator* pppg);
 
  private:
-  /** Reference to the parent SolverEngine */
-  SolverEngine& d_slv;
-  /** Reference to the env */
-  Env& d_env;
   /** Reference to the abstract values utility */
   AbstractValues& d_absValues;
   /**
index c1f60530d9bbbc427ce8fe87983bba7575244195..76059ac72b996d5b3b7be6a6cdea6724b5f40c90 100644 (file)
@@ -33,8 +33,8 @@
 #include "smt/assertions.h"
 #include "smt/dump.h"
 #include "smt/expand_definitions.h"
+#include "smt/print_benchmark.h"
 #include "smt/smt_engine_stats.h"
-#include "smt/solver_engine.h"
 #include "theory/logic_info.h"
 #include "theory/theory_engine.h"
 
@@ -57,13 +57,8 @@ class ScopeCounter
   unsigned& d_depth;
 };
 
-ProcessAssertions::ProcessAssertions(SolverEngine& slv,
-                                     ResourceManager& rm,
-                                     SmtEngineStatistics& stats)
-    : d_slv(slv),
-      d_resourceManager(rm),
-      d_smtStats(stats),
-      d_preprocessingPassContext(nullptr)
+ProcessAssertions::ProcessAssertions(Env& env, SmtEngineStatistics& stats)
+    : EnvObj(env), d_smtStats(stats), d_preprocessingPassContext(nullptr)
 {
   d_true = NodeManager::currentNM()->mkConst(true);
 }
@@ -93,7 +88,7 @@ void ProcessAssertions::cleanup() { d_passes.clear(); }
 
 void ProcessAssertions::spendResource(Resource r)
 {
-  d_resourceManager.spendResource(r);
+  resourceManager()->spendResource(r);
 }
 
 bool ProcessAssertions::apply(Assertions& as)
@@ -101,7 +96,7 @@ bool ProcessAssertions::apply(Assertions& as)
   AssertionPipeline& assertions = as.getAssertionPipeline();
   Assert(d_preprocessingPassContext != nullptr);
   // Dump the assertions
-  dumpAssertions("pre-everything", assertions);
+  dumpAssertions("pre-everything", as);
 
   Trace("smt-proc") << "ProcessAssertions::processAssertions() begin" << endl;
   Trace("smt") << "ProcessAssertions::processAssertions()" << endl;
@@ -132,7 +127,7 @@ bool ProcessAssertions::apply(Assertions& as)
   Trace("smt-proc")
       << "ProcessAssertions::processAssertions() : pre-definition-expansion"
       << endl;
-  dumpAssertions("pre-definition-expansion", assertions);
+  dumpAssertions("pre-definition-expansion", as);
   // Apply substitutions first. If we are non-incremental, this has only the
   // effect of replacing defined functions with their definitions.
   // We do not call theory-specific expand definitions here, since we want
@@ -141,7 +136,7 @@ bool ProcessAssertions::apply(Assertions& as)
   Trace("smt-proc")
       << "ProcessAssertions::processAssertions() : post-definition-expansion"
       << endl;
-  dumpAssertions("post-definition-expansion", assertions);
+  dumpAssertions("post-definition-expansion", as);
 
   Debug("smt") << " assertions     : " << assertions.size() << endl;
 
@@ -229,7 +224,7 @@ bool ProcessAssertions::apply(Assertions& as)
     d_passes["sep-skolem-emp"]->apply(&assertions);
   }
 
-  if (d_slv.getLogicInfo().isQuantified())
+  if (logicInfo().isQuantified())
   {
     // remove rewrite rules, apply pre-skolemization to existential quantifiers
     d_passes["quantifiers-preprocess"]->apply(&assertions);
@@ -256,31 +251,28 @@ bool ProcessAssertions::apply(Assertions& as)
   }
 
   // rephrasing normal inputs as sygus problems
-  if (!d_slv.isInternalSubsolver())
+  if (options().quantifiers.sygusInference)
   {
-    if (options::sygusInference())
-    {
-      d_passes["sygus-infer"]->apply(&assertions);
-    }
-    else if (options::sygusRewSynthInput())
-    {
-      // do candidate rewrite rule synthesis
-      d_passes["synth-rr"]->apply(&assertions);
-    }
+    d_passes["sygus-infer"]->apply(&assertions);
+  }
+  else if (options().quantifiers.sygusRewSynthInput)
+  {
+    // do candidate rewrite rule synthesis
+    d_passes["synth-rr"]->apply(&assertions);
   }
 
   Trace("smt-proc") << "ProcessAssertions::processAssertions() : pre-simplify"
                     << endl;
-  dumpAssertions("pre-simplify", assertions);
+  dumpAssertions("pre-simplify", as);
   Chat() << "simplifying assertions..." << endl;
-  noConflict = simplifyAssertions(assertions);
+  noConflict = simplifyAssertions(as);
   if (!noConflict)
   {
     ++(d_smtStats.d_simplifiedToFalse);
   }
   Trace("smt-proc") << "ProcessAssertions::processAssertions() : post-simplify"
                     << endl;
-  dumpAssertions("post-simplify", assertions);
+  dumpAssertions("post-simplify", as);
 
   if (options::doStaticLearning())
   {
@@ -304,7 +296,7 @@ bool ProcessAssertions::apply(Assertions& as)
     d_smtStats.d_numAssertionsPost += assertions.size();
   }
 
-  dumpAssertions("pre-repeat-simplify", assertions);
+  dumpAssertions("pre-repeat-simplify", as);
   if (options::repeatSimp())
   {
     Trace("smt-proc")
@@ -312,12 +304,12 @@ bool ProcessAssertions::apply(Assertions& as)
         << endl;
     Chat() << "re-simplifying assertions..." << endl;
     ScopeCounter depth(d_simplifyAssertionsDepth);
-    noConflict &= simplifyAssertions(assertions);
+    noConflict &= simplifyAssertions(as);
     Trace("smt-proc")
         << "ProcessAssertions::processAssertions() : post-repeat-simplify"
         << endl;
   }
-  dumpAssertions("post-repeat-simplify", assertions);
+  dumpAssertions("post-repeat-simplify", as);
 
   if (options::ufHo())
   {
@@ -347,18 +339,19 @@ bool ProcessAssertions::apply(Assertions& as)
     d_passes["bv-eager-atoms"]->apply(&assertions);
   }
 
-  Trace("smt-proc") << "ProcessAssertions::apply() end" << endl;
-  dumpAssertions("post-everything", assertions);
+  Trace("smt-proc") << "SmtEnginePrivate::processAssertions() end" << endl;
+  dumpAssertions("post-everything", as);
 
   return noConflict;
 }
 
 // returns false if simplification led to "false"
-bool ProcessAssertions::simplifyAssertions(AssertionPipeline& assertions)
+bool ProcessAssertions::simplifyAssertions(Assertions& as)
 {
   spendResource(Resource::PreprocessStep);
   try
   {
+    AssertionPipeline& assertions = as.getAssertionPipeline();
     ScopeCounter depth(d_simplifyAssertionsDepth);
 
     Trace("simplify") << "ProcessAssertions::simplify()" << endl;
@@ -378,7 +371,7 @@ bool ProcessAssertions::simplifyAssertions(AssertionPipeline& assertions)
       if (  // check that option is on
           options::arithMLTrick() &&
           // only useful in arith
-          d_slv.getLogicInfo().isTheoryEnabled(THEORY_ARITH) &&
+          logicInfo().isTheoryEnabled(THEORY_ARITH) &&
           // we add new assertions and need this (in practice, this
           // restriction only disables miplib processing during
           // re-simplification, which we don't expect to be useful anyway)
@@ -426,7 +419,7 @@ bool ProcessAssertions::simplifyAssertions(AssertionPipeline& assertions)
       }
     }
 
-    dumpAssertions("post-repeatsimp", assertions);
+    dumpAssertions("post-repeatsimp", as);
     Trace("smt") << "POST repeatSimp" << endl;
     Debug("smt") << " assertions     : " << assertions.size() << endl;
   }
@@ -444,17 +437,16 @@ bool ProcessAssertions::simplifyAssertions(AssertionPipeline& assertions)
   return true;
 }
 
-void ProcessAssertions::dumpAssertions(const char* key,
-                                       const AssertionPipeline& assertionList)
+void ProcessAssertions::dumpAssertions(const char* key, Assertions& as)
 {
   if (Dump.isOn("assertions") && Dump.isOn(string("assertions:") + key))
   {
+    const AssertionPipeline& assertionList = as.getAssertionPipeline();
     // Push the simplified assertions to the dump output stream
     for (unsigned i = 0; i < assertionList.size(); ++i)
     {
       TNode n = assertionList[i];
-      d_slv.getOutputManager().getPrinter().toStreamCmdAssert(
-          d_slv.getOutputManager().getDumpOut(), n);
+      d_env.getPrinter().toStreamCmdAssert(d_env.getDumpOut(), n);
     }
   }
 }
index d04663fe2d0c349f4ab390c45bbd6dfc84ce20ed..00b57813f4193846d9eecb77d6775d4d88b6ead2 100644 (file)
 
 #include "context/cdlist.h"
 #include "expr/node.h"
+#include "smt/env_obj.h"
 #include "util/resource_manager.h"
 
 namespace cvc5 {
 
-class SolverEngine;
-
 namespace preprocessing {
 class AssertionPipeline;
 class PreprocessingPass;
@@ -53,16 +52,14 @@ struct SmtEngineStatistics;
  * it processes assertions in a way that assumes that apply(...) could be
  * applied multiple times to different sets of assertions.
  */
-class ProcessAssertions
+class ProcessAssertions : protected EnvObj
 {
   /** The types for the recursive function definitions */
   typedef context::CDList<Node> NodeList;
   typedef std::unordered_map<Node, bool> NodeToBoolHashMap;
 
  public:
-  ProcessAssertions(SolverEngine& smt,
-                    ResourceManager& rm,
-                    SmtEngineStatistics& stats);
+  ProcessAssertions(Env& env, SmtEngineStatistics& stats);
   ~ProcessAssertions();
   /** Finish initialize
    *
@@ -77,14 +74,12 @@ class ProcessAssertions
   /**
    * Process the formulas in as. Returns true if there was no conflict when
    * processing the assertions.
+   *
+   * @param as The assertions.
    */
   bool apply(Assertions& as);
 
  private:
-  /** Reference to the SMT engine */
-  SolverEngine& d_slv;
-  /** Reference to resource manager */
-  ResourceManager& d_resourceManager;
   /** Reference to the SMT stats */
   SmtEngineStatistics& d_smtStats;
   /** The preprocess context */
@@ -111,13 +106,12 @@ class ProcessAssertions
    *
    * Returns false if the formula simplifies to "false"
    */
-  bool simplifyAssertions(preprocessing::AssertionPipeline& assertions);
+  bool simplifyAssertions(Assertions& as);
   /**
    * Dump assertions. Print the current assertion list to the dump
    * assertions:`key` if it is enabled.
    */
-  void dumpAssertions(const char* key,
-                      const preprocessing::AssertionPipeline& assertionList);
+  void dumpAssertions(const char* key, Assertions& as);
 };
 
 }  // namespace smt
index 6aaa6e267f11974393e863f616078d1b778db6dd..4759008dcec189b15698e8db52da27076777c7ed 100644 (file)
@@ -279,12 +279,12 @@ std::shared_ptr<ProofNode> PfManager::getFinalProof(
 void PfManager::getAssertions(Assertions& as,
                               std::vector<Node>& assertions)
 {
-  context::CDList<Node>* al = as.getAssertionList();
-  Assert(al != nullptr);
-  for (context::CDList<Node>::const_iterator i = al->begin(); i != al->end();
-       ++i)
+  const context::CDList<Node>& al = as.getAssertionList();
+  Assert(options().smt.produceAssertions)
+      << "Expected produce assertions to be true when checking proof";
+  for (const Node& a : al)
   {
-    assertions.push_back(*i);
+    assertions.push_back(a);
   }
 }
 
index 40c940b5af64b20674a0090a30b9d464352e3446..31ccaacacab166ae6c952d437172cdbd29a92f69 100644 (file)
@@ -175,6 +175,13 @@ void SetDefaults::setDefaultsPre(Options& opts)
       opts.smt.checkProofs = false;
     }
   }
+  if (d_isInternalSubsolver)
+  {
+    // these options must be disabled on internal subsolvers, as they are
+    // used by the user to rephrase the input.
+    opts.quantifiers.sygusInference = false;
+    opts.quantifiers.sygusRewSynthInput = false;
+  }
 }
 
 void SetDefaults::finalizeLogic(LogicInfo& logic, Options& opts) const
index 8064086adee40a4a4f35add314ef94968fded05a..cf2ecf3871230338463da33e4fd2720b67947241 100644 (file)
@@ -48,7 +48,7 @@ SmtSolver::SmtSolver(Env& env,
 
 SmtSolver::~SmtSolver() {}
 
-void SmtSolver::finishInit(const LogicInfo& logicInfo)
+void SmtSolver::finishInit()
 {
   // We have mutual dependency here, so we add the prop engine to the theory
   // engine later (it is non-essential there)
index d4e844b6c0ebc037f0bfef518bc42d6bad95bb65..9baaea3024f9203ca2e60cfc1a80628695d55580 100644 (file)
@@ -70,11 +70,9 @@ class SmtSolver
             SmtEngineStatistics& stats);
   ~SmtSolver();
   /**
-   * Create theory engine, prop engine based on the logic info.
-   *
-   * @param logicInfo the logic information
+   * Create theory engine, prop engine based on the environment.
    */
-  void finishInit(const LogicInfo& logicInfo);
+  void finishInit();
   /** Reset all assertions, global declarations, etc.  */
   void resetAssertions();
   /**
index 094cc8e267829070e39176da4e1a53f2deec1e09..b458c421f1e6704c660857f3242e7400cd82fe20 100644 (file)
@@ -124,10 +124,9 @@ SolverEngine::SolverEngine(NodeManager* nm, const Options* optr)
   // make statistics
   d_stats.reset(new SmtEngineStatistics());
   // reset the preprocessor
-  d_pp.reset(
-      new smt::Preprocessor(*this, *d_env.get(), *d_absValues.get(), *d_stats));
+  d_pp.reset(new smt::Preprocessor(*d_env, *d_absValues, *d_stats));
   // make the SMT solver
-  d_smtSolver.reset(new SmtSolver(*d_env.get(), *d_state, *d_pp, *d_stats));
+  d_smtSolver.reset(new SmtSolver(*d_env, *d_state, *d_pp, *d_stats));
   // make the SyGuS solver
   d_sygusSolver.reset(new SygusSolver(*d_env.get(), *d_smtSolver, *d_pp));
   // make the quantifier elimination solver
@@ -209,7 +208,7 @@ void SolverEngine::finishInit()
   }
 
   Trace("smt-debug") << "SolverEngine::finishInit" << std::endl;
-  d_smtSolver->finishInit(logic);
+  d_smtSolver->finishInit();
 
   // now can construct the SMT-level model object
   TheoryEngine* te = d_smtSolver->getTheoryEngine();
@@ -255,10 +254,10 @@ void SolverEngine::finishInit()
   if (d_env->getOptions().smt.produceInterpols
       != options::ProduceInterpols::NONE)
   {
-    d_interpolSolver.reset(new InterpolationSolver(*d_env.get()));
+    d_interpolSolver.reset(new InterpolationSolver(*d_env));
   }
 
-  d_pp->finishInit();
+  d_pp->finishInit(this);
 
   AlwaysAssert(getPropEngine()->getAssertionLevel() == 0)
       << "The PropEngine has pushed but the SolverEngine "
@@ -1284,10 +1283,9 @@ std::pair<Node, Node> SolverEngine::getSepHeapAndNilExpr(void)
 std::vector<Node> SolverEngine::getAssertionsInternal()
 {
   Assert(d_state->isFullyInited());
-  context::CDList<Node>* al = d_asserts->getAssertionList();
-  Assert(al != nullptr);
+  const context::CDList<Node>& al = d_asserts->getAssertionList();
   std::vector<Node> res;
-  for (const Node& n : *al)
+  for (const Node& n : al)
   {
     res.emplace_back(n);
   }
@@ -1515,10 +1513,10 @@ void SolverEngine::checkUnsatCore()
 
 void SolverEngine::checkModel(bool hardFailure)
 {
-  context::CDList<Node>* al = d_asserts->getAssertionList();
+  const context::CDList<Node>& al = d_asserts->getAssertionList();
   // --check-model implies --produce-assertions, which enables the
   // assertion list, so we should be ok.
-  Assert(al != nullptr)
+  Assert(d_env->getOptions().smt.produceAssertions)
       << "don't have an assertion list to check in SolverEngine::checkModel()";
 
   TimerStat::CodeTimer checkModelTimer(d_stats->d_checkModelTime);
index 69ea51dd19938235935c93eb193a4be3646ac6f1..ce98b820d1dde45bfef2164465af7eed185a39c5 100644 (file)
@@ -42,10 +42,10 @@ namespace cvc5 {
 namespace smt {
 
 SygusSolver::SygusSolver(Env& env, SmtSolver& sms, Preprocessor& pp)
-    : d_env(env),
+    : EnvObj(env),
       d_smtSolver(sms),
       d_pp(pp),
-      d_sygusConjectureStale(env.getUserContext(), true)
+      d_sygusConjectureStale(userContext(), true)
 {
 }
 
@@ -301,17 +301,15 @@ void SygusSolver::checkSynthSolution(Assertions& as)
 
   Trace("check-synth-sol") << "Retrieving assertions\n";
   // Build conjecture from original assertions
-  context::CDList<Node>* alist = as.getAssertionList();
-  if (alist == nullptr)
-  {
-    Trace("check-synth-sol") << "No assertions to check\n";
-    return;
-  }
+  const context::CDList<Node>& alist = as.getAssertionList();
+  Assert(options().smt.produceAssertions)
+      << "Expected produce assertions to be true when checking synthesis "
+         "solution";
   // auxiliary assertions
   std::vector<Node> auxAssertions;
   // expand definitions cache
   std::unordered_map<Node, Node> cache;
-  for (Node assertion : *alist)
+  for (const Node& assertion : alist)
   {
     Notice() << "SygusSolver::checkSynthSolution(): checking assertion "
              << assertion << std::endl;
index 90a6a87f02da4abf88f22eff1262b425fe746874..aa0355fb83ff3df9d8d1fbdfd50c8328af30272f 100644 (file)
@@ -22,6 +22,7 @@
 #include "expr/node.h"
 #include "expr/type_node.h"
 #include "smt/assertions.h"
+#include "smt/env_obj.h"
 #include "util/result.h"
 
 namespace cvc5 {
@@ -42,7 +43,7 @@ class SmtSolver;
  * It also maintains a reference to a preprocessor for implementing
  * checkSynthSolution.
  */
-class SygusSolver
+class SygusSolver : protected EnvObj
 {
  public:
   SygusSolver(Env& env, SmtSolver& sms, Preprocessor& pp);
@@ -170,8 +171,6 @@ class SygusSolver
    * expansion.
    */
   void expandDefinitionsSygusDt(TypeNode tn) const;
-  /** Reference to the env class */
-  Env& d_env;
   /** The SMT solver, which is used during checkSynth. */
   SmtSolver& d_smtSolver;
   /** The preprocessor, used for checkSynthSolution. */
index 27922acf9bbcedc31d23046d4740392c2107fa75..4d47b57ea462c8773f7797c4a622d88e05161335 100644 (file)
@@ -32,16 +32,14 @@ void UnsatCoreManager::getUnsatCore(std::shared_ptr<ProofNode> pfn,
   expr::getFreeAssumptions(pfn->getChildren()[0].get(), fassumps);
   Trace("unsat-core") << "UCManager::getUnsatCore: free assumptions: "
                       << fassumps << "\n";
-  context::CDList<Node>* al = as.getAssertionList();
-  Assert(al != nullptr);
-  for (context::CDList<Node>::const_iterator i = al->begin(); i != al->end();
-       ++i)
+  const context::CDList<Node>& al = as.getAssertionList();
+  for (const Node& a : al)
   {
-    Trace("unsat-core") << "is assertion " << *i << " there?\n";
-    if (std::find(fassumps.begin(), fassumps.end(), *i) != fassumps.end())
+    Trace("unsat-core") << "is assertion " << a << " there?\n";
+    if (std::find(fassumps.begin(), fassumps.end(), a) != fassumps.end())
     {
       Trace("unsat-core") << "\tyes\n";
-      core.push_back(*i);
+      core.push_back(a);
     }
   }
   if (Trace.isOn("unsat-core"))