Remove context getters from `TheoryState` (#7174)
authorAndres Noetzli <andres.noetzli@gmail.com>
Mon, 13 Sep 2021 23:14:54 +0000 (16:14 -0700)
committerGitHub <noreply@github.com>
Mon, 13 Sep 2021 23:14:54 +0000 (18:14 -0500)
This removes TheoryState::getSatContext() and
TheoryState::getUserContext().

61 files changed:
src/theory/arrays/theory_arrays.cpp
src/theory/bv/bv_solver.h
src/theory/bv/bv_solver_bitblast.cpp
src/theory/bv/bv_solver_bitblast.h
src/theory/bv/bv_solver_bitblast_internal.h
src/theory/bv/bv_solver_layered.cpp
src/theory/bv/bv_solver_layered.h
src/theory/bv/theory_bv.cpp
src/theory/datatypes/sygus_extension.cpp
src/theory/datatypes/sygus_extension.h
src/theory/decision_strategy.cpp
src/theory/decision_strategy.h
src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp
src/theory/quantifiers/conjecture_generator.cpp
src/theory/quantifiers/equality_query.cpp
src/theory/quantifiers/first_order_model.cpp
src/theory/quantifiers/first_order_model.h
src/theory/quantifiers/fmf/bounded_integers.cpp
src/theory/quantifiers/fmf/bounded_integers.h
src/theory/quantifiers/inst_match_trie.cpp
src/theory/quantifiers/inst_match_trie.h
src/theory/quantifiers/instantiate.cpp
src/theory/quantifiers/quant_conflict_find.cpp
src/theory/quantifiers/quant_split.cpp
src/theory/quantifiers/quantifiers_inference_manager.cpp
src/theory/quantifiers/skolemize.cpp
src/theory/quantifiers/skolemize.h
src/theory/quantifiers/sygus/cegis_unif.cpp
src/theory/quantifiers/sygus/synth_conjecture.cpp
src/theory/quantifiers/sygus_inst.cpp
src/theory/quantifiers/term_database.cpp
src/theory/quantifiers/term_registry.cpp
src/theory/quantifiers_engine.cpp
src/theory/sep/theory_sep.cpp
src/theory/sets/cardinality_extension.cpp
src/theory/sets/cardinality_extension.h
src/theory/sets/term_registry.cpp
src/theory/sets/term_registry.h
src/theory/sets/theory_sets_private.cpp
src/theory/sets/theory_sets_rels.cpp
src/theory/sets/theory_sets_rels.h
src/theory/strings/base_solver.cpp
src/theory/strings/base_solver.h
src/theory/strings/core_solver.cpp
src/theory/strings/core_solver.h
src/theory/strings/extf_solver.cpp
src/theory/strings/extf_solver.h
src/theory/strings/regexp_solver.cpp
src/theory/strings/regexp_solver.h
src/theory/strings/strings_fmf.cpp
src/theory/strings/strings_fmf.h
src/theory/strings/term_registry.cpp
src/theory/strings/term_registry.h
src/theory/strings/theory_strings.cpp
src/theory/theory_state.cpp
src/theory/theory_state.h
src/theory/uf/cardinality_extension.cpp
src/theory/uf/cardinality_extension.h
src/theory/uf/ho_extension.cpp
src/theory/uf/ho_extension.h
src/theory/uf/theory_uf.cpp

index c975fbbfac872f429715fbb3533f37282f4e32a5..774c5db3f87ddb439a18b5a5a89f7baf63c19e51 100644 (file)
@@ -2125,7 +2125,7 @@ void TheoryArrays::conflict(TNode a, TNode b) {
 
 TheoryArrays::TheoryArraysDecisionStrategy::TheoryArraysDecisionStrategy(
     TheoryArrays* ta)
-    : d_ta(ta)
+    : DecisionStrategy(ta->d_env), d_ta(ta)
 {
 }
 void TheoryArrays::TheoryArraysDecisionStrategy::initialize() {}
index 510c8a29aae4bd230453430aa1e3b6d08717708b..82d6a4a5db220bdb9e6284ef04c4a395a5311c3a 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef CVC5__THEORY__BV__BV_SOLVER_H
 #define CVC5__THEORY__BV__BV_SOLVER_H
 
-#include "smt/env.h"
 #include "smt/env_obj.h"
 #include "theory/theory.h"
 
index bb9cdb011e2a15f0328ff00a13dbd6c6928fc7b6..a8ae3b117224d14e7c25420e241efeff867f33b4 100644 (file)
@@ -116,16 +116,16 @@ BVSolverBitblast::BVSolverBitblast(Env& env,
       d_bitblaster(new NodeBitblaster(env, s)),
       d_bbRegistrar(new BBRegistrar(d_bitblaster.get())),
       d_nullContext(new context::Context()),
-      d_bbFacts(s->getSatContext()),
-      d_bbInputFacts(s->getSatContext()),
-      d_assumptions(s->getSatContext()),
-      d_assertions(s->getSatContext()),
-      d_epg(pnm ? new EagerProofGenerator(pnm, s->getUserContext(), "")
+      d_bbFacts(context()),
+      d_bbInputFacts(context()),
+      d_assumptions(context()),
+      d_assertions(context()),
+      d_epg(pnm ? new EagerProofGenerator(pnm, userContext(), "")
                 : nullptr),
-      d_factLiteralCache(s->getSatContext()),
-      d_literalFactCache(s->getSatContext()),
+      d_factLiteralCache(context()),
+      d_literalFactCache(context()),
       d_propagate(options().bv.bitvectorPropagate),
-      d_resetNotify(new NotifyResetAssertions(s->getUserContext()))
+      d_resetNotify(new NotifyResetAssertions(userContext()))
 {
   if (pnm != nullptr)
   {
index e8931acff3f0c0e1e82d1225b1cef3135970b659..b9ae84f23cceb4d5a9e457f83cb568e618ed72ee 100644 (file)
@@ -24,6 +24,7 @@
 #include "proof/eager_proof_generator.h"
 #include "prop/cnf_stream.h"
 #include "prop/sat_solver.h"
+#include "smt/env_obj.h"
 #include "theory/bv/bitblast/node_bitblaster.h"
 #include "theory/bv/bv_solver.h"
 #include "theory/bv/proof_checker.h"
index cc365e109ecb6b5d7234e47f3eb33310bf611c44..72b8b4f4d33aefb8c6dfd58f11b5274be335859e 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef CVC5__THEORY__BV__BV_SOLVER_BITBLAST_INTERNAL_H
 #define CVC5__THEORY__BV__BV_SOLVER_BITBLAST_INTERNAL_H
 
+#include "smt/env_obj.h"
 #include "theory/bv/bitblast/proof_bitblaster.h"
 #include "theory/bv/bv_solver.h"
 #include "theory/bv/proof_checker.h"
index bf76ed2f98308f468d6e5df9f46f8da5cf8cc6e6..682c556ccbba8523182f686adddc8eabf34bc11c 100644 (file)
@@ -37,8 +37,8 @@ namespace cvc5 {
 namespace theory {
 namespace bv {
 
-BVSolverLayered::BVSolverLayered(TheoryBV& bv,
-                                 Env& env,
+BVSolverLayered::BVSolverLayered(Env& env,
+                                 TheoryBV& bv,
                                  context::Context* c,
                                  context::UserContext* u,
                                  ProofNodeManager* pnm,
index 325f2fc72369bde45e33cd6a698486f04d4aa2b3..3b723b0520a64b33be1bd1f6f4de03350944f665 100644 (file)
@@ -24,6 +24,7 @@
 #include "context/cdhashset.h"
 #include "context/cdlist.h"
 #include "context/context.h"
+#include "smt/env_obj.h"
 #include "theory/bv/bv_solver.h"
 #include "theory/bv/bv_subtheory.h"
 #include "theory/bv/theory_bv.h"
@@ -57,8 +58,8 @@ class BVSolverLayered : public BVSolver
       d_subtheoryMap;
 
  public:
-  BVSolverLayered(TheoryBV& bv,
-                  Env& env,
+  BVSolverLayered(Env& env,
+                  TheoryBV& bv,
                   context::Context* c,
                   context::UserContext* u,
                   ProofNodeManager* pnm = nullptr,
index 397120ff1f89f825774274e0e70248a2469dba24..ba90c669ed781c8521992da4062ebfd64c5260bf 100644 (file)
@@ -46,17 +46,16 @@ TheoryBV::TheoryBV(Env& env,
   switch (options().bv.bvSolver)
   {
     case options::BVSolver::BITBLAST:
-      d_internal.reset(new BVSolverBitblast(d_env, &d_state, d_im, d_pnm));
+      d_internal.reset(new BVSolverBitblast(env, &d_state, d_im, d_pnm));
       break;
 
     case options::BVSolver::LAYERED:
       d_internal.reset(new BVSolverLayered(
-          *this, d_env, context(), userContext(), d_pnm, name));
+          env, *this, context(), userContext(), d_pnm, name));
       break;
 
     default:
-      AlwaysAssert(options().bv.bvSolver
-                   == options::BVSolver::BITBLAST_INTERNAL);
+      AlwaysAssert(options().bv.bvSolver == options::BVSolver::BITBLAST_INTERNAL);
       d_internal.reset(
           new BVSolverBitblastInternal(d_env, &d_state, d_im, d_pnm));
   }
index ed112e4ea2ba502eddc72643dbdb96bd83caf8ec..2411013b28c21ef17dafbaafa5a33dc44bae53e8 100644 (file)
@@ -51,10 +51,10 @@ SygusExtension::SygusExtension(Env& env,
       d_im(im),
       d_tds(tds),
       d_ssb(tds),
-      d_testers(s.getSatContext()),
-      d_testers_exp(s.getSatContext()),
-      d_active_terms(s.getSatContext()),
-      d_currTermSize(s.getSatContext())
+      d_testers(context()),
+      d_testers_exp(context()),
+      d_active_terms(context()),
+      d_currTermSize(context())
 {
   d_zero = NodeManager::currentNM()->mkConst(Rational(0));
   d_true = NodeManager::currentNM()->mkConst(true);
@@ -1325,11 +1325,8 @@ void SygusExtension::registerSizeTerm(Node e)
         d_anchor_to_ag_strategy.find(e);
     if (itaas == d_anchor_to_ag_strategy.end())
     {
-      d_anchor_to_ag_strategy[e].reset(
-          new DecisionStrategySingleton("sygus_enum_active",
-                                        ag,
-                                        d_state.getSatContext(),
-                                        d_state.getValuation()));
+      d_anchor_to_ag_strategy[e].reset(new DecisionStrategySingleton(
+          d_env, "sygus_enum_active", ag, d_state.getValuation()));
     }
     d_im.getDecisionManager()->registerStrategy(
         DecisionManager::STRAT_DT_SYGUS_ENUM_ACTIVE,
@@ -1411,7 +1408,7 @@ void SygusExtension::registerMeasureTerm( Node m ) {
       d_szinfo.find(m);
   if( it==d_szinfo.end() ){
     Trace("sygus-sb") << "Sygus : register measure term : " << m << std::endl;
-    d_szinfo[m].reset(new SygusSizeDecisionStrategy(d_im, m, d_state));
+    d_szinfo[m].reset(new SygusSizeDecisionStrategy(d_env, d_im, m, d_state));
     // register this as a decision strategy
     d_im.getDecisionManager()->registerStrategy(
         DecisionManager::STRAT_DT_SYGUS_ENUM_SIZE, d_szinfo[m].get());
@@ -1748,8 +1745,8 @@ Node SygusExtension::getCurrentTemplate( Node n, std::map< TypeNode, int >& var_
 }
 
 SygusExtension::SygusSizeDecisionStrategy::SygusSizeDecisionStrategy(
-    InferenceManager& im, Node t, TheoryState& s)
-    : DecisionStrategyFmf(s.getSatContext(), s.getValuation()),
+    Env& env, InferenceManager& im, Node t, TheoryState& s)
+    : DecisionStrategyFmf(env, s.getValuation()),
       d_this(t),
       d_curr_search_size(0),
       d_im(im)
index 5860dca99ea5459cc1f44dff23f0376657b11501..c7a9e7893bf848604d1f8bb703cf4eace8040515 100644 (file)
@@ -555,7 +555,10 @@ private:
   class SygusSizeDecisionStrategy : public DecisionStrategyFmf
   {
    public:
-    SygusSizeDecisionStrategy(InferenceManager& im, Node t, TheoryState& s);
+    SygusSizeDecisionStrategy(Env& env,
+                              InferenceManager& im,
+                              Node t,
+                              TheoryState& s);
     /** the measure term */
     Node d_this;
     /**
index dabfb55bbf77da2f9a08ec98c437f26824932032..7c932177a7835e82fad0adedfc44035bfa69c35a 100644 (file)
@@ -23,11 +23,11 @@ using namespace cvc5::kind;
 namespace cvc5 {
 namespace theory {
 
-DecisionStrategyFmf::DecisionStrategyFmf(context::Context* satContext,
-                                         Valuation valuation)
-    : d_valuation(valuation),
-      d_has_curr_literal(false, satContext),
-      d_curr_literal(0, satContext)
+DecisionStrategyFmf::DecisionStrategyFmf(Env& env, Valuation valuation)
+    : DecisionStrategy(env),
+      d_valuation(valuation),
+      d_has_curr_literal(false, context()),
+      d_curr_literal(0, context())
 {
 }
 
@@ -127,12 +127,11 @@ Node DecisionStrategyFmf::getLiteral(unsigned n)
   return ret;
 }
 
-DecisionStrategySingleton::DecisionStrategySingleton(
-    const char* name,
-    Node lit,
-    context::Context* satContext,
-    Valuation valuation)
-    : DecisionStrategyFmf(satContext, valuation), d_name(name), d_literal(lit)
+DecisionStrategySingleton::DecisionStrategySingleton(Env& env,
+                                                     const char* name,
+                                                     Node lit,
+                                                     Valuation valuation)
+    : DecisionStrategyFmf(env, valuation), d_name(name), d_literal(lit)
 {
 }
 
index 8b5f7510880cc39ef8946326998cc6f149a24d7f..fc297513744cbb0500f85159ee62f250d26bc635 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "context/cdo.h"
 #include "expr/node.h"
+#include "smt/env_obj.h"
 #include "theory/valuation.h"
 
 namespace cvc5 {
@@ -29,10 +30,10 @@ namespace theory {
 /**
  * Virtual base class for decision strategies.
  */
-class DecisionStrategy
+class DecisionStrategy : protected EnvObj
 {
  public:
-  DecisionStrategy() {}
+  DecisionStrategy(Env& env) : EnvObj(env) {}
   virtual ~DecisionStrategy() {}
   /**
    * Initalize this strategy, This is called once per satisfiability call by
@@ -68,7 +69,7 @@ class DecisionStrategy
 class DecisionStrategyFmf : public DecisionStrategy
 {
  public:
-  DecisionStrategyFmf(context::Context* satContext, Valuation valuation);
+  DecisionStrategyFmf(Env& env, Valuation valuation);
   virtual ~DecisionStrategyFmf() {}
   /** initialize */
   void initialize() override;
@@ -119,9 +120,9 @@ class DecisionStrategyFmf : public DecisionStrategy
 class DecisionStrategySingleton : public DecisionStrategyFmf
 {
  public:
-  DecisionStrategySingleton(const char* name,
+  DecisionStrategySingleton(Env& env,
+                            const char* name,
                             Node lit,
-                            context::Context* satContext,
                             Valuation valuation);
   /**
    * Make the n^th literal of this strategy. This method returns d_literal if
index 8334cc24832216de006bb6004a5dfcc8404aff9e..1ccfd8ede0ad0f2b352ee37510558e6bd0c1bf48 100644 (file)
@@ -56,7 +56,7 @@ InstStrategyCegqi::InstStrategyCegqi(Env& env,
       d_irew(new InstRewriterCegqi(this)),
       d_cbqi_set_quant_inactive(false),
       d_incomplete_check(false),
-      d_added_cbqi_lemma(qs.getUserContext()),
+      d_added_cbqi_lemma(userContext()),
       d_vtsCache(new VtsTermCache(qim)),
       d_bv_invert(nullptr),
       d_small_const_multiplier(
@@ -168,10 +168,8 @@ bool InstStrategyCegqi::registerCbqiLemma(Node q)
     DecisionStrategy* dlds = nullptr;
     if (itds == d_dstrat.end())
     {
-      d_dstrat[q].reset(new DecisionStrategySingleton("CexLiteral",
-                                                      ceLit,
-                                                      d_qstate.getSatContext(),
-                                                      d_qstate.getValuation()));
+      d_dstrat[q].reset(new DecisionStrategySingleton(
+          d_env, "CexLiteral", ceLit, d_qstate.getValuation()));
       dlds = d_dstrat[q].get();
     }
     else
index f9625d7ac4bd0480eb48c32be787f1e73c20687a..da8727c125cd98c3a96a567368888ef234b836f9 100644 (file)
@@ -167,7 +167,7 @@ ConjectureGenerator::EqcInfo* ConjectureGenerator::getOrMakeEqcInfo( TNode n, bo
   if( eqc_i!=d_eqc_info.end() ){
     return eqc_i->second;
   }else if( doMake ){
-    EqcInfo* ei = new EqcInfo(d_qstate.getSatContext());
+    EqcInfo* ei = new EqcInfo(context());
     d_eqc_info[n] = ei;
     return ei;
   }else{
index 92ec1e4520442df24dc64449f79c4884605ec3ed..30d223b2af979a1e818898c232d017f6a860aa0c 100644 (file)
@@ -33,7 +33,7 @@ EqualityQuery::EqualityQuery(Env& env, QuantifiersState& qs, FirstOrderModel* m)
     : QuantifiersUtil(env),
       d_qstate(qs),
       d_model(m),
-      d_eqi_counter(qs.getSatContext()),
+      d_eqi_counter(context()),
       d_reset_count(0)
 {
 }
index 841177a7f340f4cf41e0a13e5d5fb4ac686c28e5..cfd903646b370b156d8c45a42b15e53314c5a34e 100644 (file)
@@ -46,11 +46,12 @@ FirstOrderModel::FirstOrderModel(Env& env,
                                  QuantifiersState& qs,
                                  QuantifiersRegistry& qr,
                                  TermRegistry& tr)
-    : d_model(nullptr),
+    : EnvObj(env),
+      d_model(nullptr),
       d_qreg(qr),
       d_treg(tr),
       d_eq_query(env, qs, this),
-      d_forall_asserts(qs.getSatContext()),
+      d_forall_asserts(context()),
       d_forallRlvComputed(false)
 {
 }
index 05bdcbee6984c464b3f73acad2cfd4d253f55763..526bbe10b3b8d95562ecc60ed8435e14ac0807de 100644 (file)
@@ -19,6 +19,7 @@
 #define CVC5__FIRST_ORDER_MODEL_H
 
 #include "context/cdlist.h"
+#include "smt/env_obj.h"
 #include "theory/quantifiers/equality_query.h"
 #include "theory/theory_model.h"
 #include "theory/uf/theory_uf_model.h"
@@ -36,7 +37,7 @@ class TermRegistry;
 class QuantifiersRegistry;
 
 // TODO (#1301) : document and refactor this class
-class FirstOrderModel
+class FirstOrderModel : protected EnvObj
 {
  public:
   FirstOrderModel(Env& env,
index b04391db3e26936b5cac650af9957aef222a3cf4..4a3e13dd05b405ff6b07e54fd37e389da237fe12 100644 (file)
@@ -37,12 +37,10 @@ using namespace cvc5::theory::quantifiers;
 using namespace cvc5::kind;
 
 BoundedIntegers::IntRangeDecisionHeuristic::IntRangeDecisionHeuristic(
-    Node r,
-    context::Context* c,
-    context::Context* u,
-    Valuation valuation,
-    bool isProxy)
-    : DecisionStrategyFmf(c, valuation), d_range(r), d_ranges_proxied(u)
+    Env& env, Node r, Valuation valuation, bool isProxy)
+    : DecisionStrategyFmf(env, valuation),
+      d_range(r),
+      d_ranges_proxied(userContext())
 {
   if( options::fmfBoundLazy() ){
     SkolemManager* sm = NodeManager::currentNM()->getSkolemManager();
@@ -514,12 +512,8 @@ void BoundedIntegers::checkOwnership(Node f)
           {
             Trace("bound-int") << "For " << v << ", bounded Integer Module will try to minimize : " << r << std::endl;
             d_ranges.push_back( r );
-            d_rms[r].reset(
-                new IntRangeDecisionHeuristic(r,
-                                              d_qstate.getSatContext(),
-                                              d_qstate.getUserContext(),
-                                              d_qstate.getValuation(),
-                                              isProxy));
+            d_rms[r].reset(new IntRangeDecisionHeuristic(
+                d_env, r, d_qstate.getValuation(), isProxy));
             dm->registerStrategy(DecisionManager::STRAT_QUANT_BOUND_INT_SIZE,
                                  d_rms[r].get());
           }
index 8c468c1de8043e1dbbc59a61118daaea402b274c..2c3a86fc7facceddf107069999c1af64a5f80770 100644 (file)
@@ -100,9 +100,8 @@ private:
  class IntRangeDecisionHeuristic : public DecisionStrategyFmf
  {
   public:
-   IntRangeDecisionHeuristic(Node r,
-                             context::Context* c,
-                             context::Context* u,
+   IntRangeDecisionHeuristic(Env& env,
+                             Node r,
                              Valuation valuation,
                              bool isProxy);
    /** make the n^th literal of this strategy */
index ba9ea91523ee4f6b4dd3d1e945b72eac135766ac..a4107564e30ae5bf9e4fd90e89da46600b8834ca 100644 (file)
@@ -189,16 +189,18 @@ CDInstMatchTrie::~CDInstMatchTrie()
   d_data.clear();
 }
 
-bool CDInstMatchTrie::existsInstMatch(quantifiers::QuantifiersState& qs,
+bool CDInstMatchTrie::existsInstMatch(context::Context* context,
+                                      quantifiers::QuantifiersState& qs,
                                       Node q,
                                       const std::vector<Node>& m,
                                       bool modEq,
                                       unsigned index)
 {
-  return !addInstMatch(qs, q, m, modEq, index, true);
+  return !addInstMatch(context, qs, q, m, modEq, index, true);
 }
 
-bool CDInstMatchTrie::addInstMatch(quantifiers::QuantifiersState& qs,
+bool CDInstMatchTrie::addInstMatch(context::Context* context,
+                                   quantifiers::QuantifiersState& qs,
                                    Node f,
                                    const std::vector<Node>& m,
                                    bool modEq,
@@ -226,7 +228,8 @@ bool CDInstMatchTrie::addInstMatch(quantifiers::QuantifiersState& qs,
   std::map<Node, CDInstMatchTrie*>::iterator it = d_data.find(n);
   if (it != d_data.end())
   {
-    bool ret = it->second->addInstMatch(qs, f, m, modEq, index + 1, onlyExist);
+    bool ret =
+        it->second->addInstMatch(context, qs, f, m, modEq, index + 1, onlyExist);
     if (!onlyExist || !ret)
     {
       return reset || ret;
@@ -246,7 +249,8 @@ bool CDInstMatchTrie::addInstMatch(quantifiers::QuantifiersState& qs,
           std::map<Node, CDInstMatchTrie*>::iterator itc = d_data.find(en);
           if (itc != d_data.end())
           {
-            if (itc->second->addInstMatch(qs, f, m, modEq, index + 1, true))
+            if (itc->second->addInstMatch(
+                    context, qs, f, m, modEq, index + 1, true))
             {
               return false;
             }
@@ -259,10 +263,10 @@ bool CDInstMatchTrie::addInstMatch(quantifiers::QuantifiersState& qs,
 
   if (!onlyExist)
   {
-    CDInstMatchTrie* imt = new CDInstMatchTrie(qs.getUserContext());
+    CDInstMatchTrie* imt = new CDInstMatchTrie(context);
     Assert(d_data.find(n) == d_data.end());
     d_data[n] = imt;
-    imt->addInstMatch(qs, f, m, modEq, index + 1, false);
+    imt->addInstMatch(context, qs, f, m, modEq, index + 1, false);
   }
   return true;
 }
index 83bd8d3b18b9a69393a88ddf7474dc561e2bc881..5ddc299af922d880b04c728a5d9bfcf2b709e1ca 100644 (file)
@@ -23,6 +23,7 @@
 #include "context/cdlist.h"
 #include "context/cdo.h"
 #include "expr/node.h"
+#include "smt/env_obj.h"
 
 namespace cvc5 {
 namespace theory {
@@ -131,7 +132,8 @@ class CDInstMatchTrie
    * equalities in the equality engine of qs.
    * It additionally takes a context c, for which the entry is valid in.
    */
-  bool existsInstMatch(QuantifiersState& qs,
+  bool existsInstMatch(context::Context* context,
+                       QuantifiersState& qs,
                        Node q,
                        const std::vector<Node>& m,
                        bool modEq = false,
@@ -145,7 +147,8 @@ class CDInstMatchTrie
    * equalities in the equality engine of qs.
    * It additionally takes a context c, for which the entry is valid in.
    */
-  bool addInstMatch(QuantifiersState& qs,
+  bool addInstMatch(context::Context* context,
+                    QuantifiersState& qs,
                     Node q,
                     const std::vector<Node>& m,
                     bool modEq = false,
index f0af73832b09012ce2a667f6031d93e10c97591f..2a3974d492fd7a49633f7ef2fa4e2da2a1fc2a5a 100644 (file)
@@ -54,11 +54,10 @@ Instantiate::Instantiate(Env& env,
       d_qreg(qr),
       d_treg(tr),
       d_pnm(pnm),
-      d_insts(qs.getUserContext()),
-      d_c_inst_match_trie_dom(qs.getUserContext()),
-      d_pfInst(
-          pnm ? new CDProof(pnm, qs.getUserContext(), "Instantiate::pfInst")
-              : nullptr)
+      d_insts(userContext()),
+      d_c_inst_match_trie_dom(userContext()),
+      d_pfInst(pnm ? new CDProof(pnm, userContext(), "Instantiate::pfInst")
+                   : nullptr)
 {
 }
 
@@ -507,7 +506,7 @@ bool Instantiate::existsInstantiation(Node q,
     std::map<Node, CDInstMatchTrie*>::iterator it = d_c_inst_match_trie.find(q);
     if (it != d_c_inst_match_trie.end())
     {
-      return it->second->existsInstMatch(d_qstate, q, terms, modEq);
+      return it->second->existsInstMatch(userContext(), d_qstate, q, terms, modEq);
     }
   }
   else
@@ -594,10 +593,10 @@ bool Instantiate::recordInstantiationInternal(Node q, std::vector<Node>& terms)
     const auto res = d_c_inst_match_trie.insert({q, nullptr});
     if (res.second)
     {
-      res.first->second = new CDInstMatchTrie(d_qstate.getUserContext());
+      res.first->second = new CDInstMatchTrie(userContext());
     }
     d_c_inst_match_trie_dom.insert(q);
-    return res.first->second->addInstMatch(d_qstate, q, terms);
+    return res.first->second->addInstMatch(userContext(), d_qstate, q, terms);
   }
   Trace("inst-add-debug") << "Adding into inst trie" << std::endl;
   return d_inst_match_trie[q].addInstMatch(d_qstate, q, terms);
@@ -750,7 +749,7 @@ InstLemmaList* Instantiate::getOrMkInstLemmaList(TNode q)
     return it->second.get();
   }
   std::shared_ptr<InstLemmaList> ill =
-      std::make_shared<InstLemmaList>(d_qstate.getUserContext());
+      std::make_shared<InstLemmaList>(userContext());
   d_insts.insert(q, ill);
   return ill.get();
 }
index 983eee9ae50b8a4143e955e9aac5cbbc0d07f18b..1de60422fa8b8698e789bd12eade434123f23386 100644 (file)
@@ -1859,7 +1859,7 @@ QuantConflictFind::QuantConflictFind(Env& env,
                                      QuantifiersRegistry& qr,
                                      TermRegistry& tr)
     : QuantifiersModule(env, qs, qim, qr, tr),
-      d_conflict(qs.getSatContext(), false),
+      d_conflict(context(), false),
       d_true(NodeManager::currentNM()->mkConst<bool>(true)),
       d_false(NodeManager::currentNM()->mkConst<bool>(false)),
       d_effort(EFFORT_INVALID)
index 905424107886f901d73617d4b5232e232782b905..db07d07d0a7e7ab8ec4a4688b967c99f42e98945 100644 (file)
@@ -33,8 +33,7 @@ QuantDSplit::QuantDSplit(Env& env,
                          QuantifiersInferenceManager& qim,
                          QuantifiersRegistry& qr,
                          TermRegistry& tr)
-    : QuantifiersModule(env, qs, qim, qr, tr),
-      d_added_split(qs.getUserContext())
+    : QuantifiersModule(env, qs, qim, qr, tr), d_added_split(userContext())
 {
 }
 
index b2a08c2493cab60e18b4027bbea99c26ee8a95af..20987b02e46fd2d427e83c299a5e1a1cd26ea77e 100644 (file)
@@ -31,7 +31,7 @@ QuantifiersInferenceManager::QuantifiersInferenceManager(
     ProofNodeManager* pnm)
     : InferenceManagerBuffered(env, t, state, pnm, "theory::quantifiers::"),
       d_instantiate(new Instantiate(env, state, *this, qr, tr, pnm)),
-      d_skolemize(new Skolemize(state, tr, pnm))
+      d_skolemize(new Skolemize(env, state, tr, pnm))
 {
 }
 
index 23b66b1de9fdda07793c0c51e05f2d6242b6eec2..bb0fa389980be555fa5c15b0492962a1da1d575b 100644 (file)
@@ -35,16 +35,18 @@ namespace cvc5 {
 namespace theory {
 namespace quantifiers {
 
-Skolemize::Skolemize(QuantifiersState& qs,
+Skolemize::Skolemize(Env& env,
+                     QuantifiersState& qs,
                      TermRegistry& tr,
                      ProofNodeManager* pnm)
-    : d_qstate(qs),
+    : EnvObj(env),
+      d_qstate(qs),
       d_treg(tr),
-      d_skolemized(qs.getUserContext()),
+      d_skolemized(userContext()),
       d_pnm(pnm),
-      d_epg(pnm == nullptr ? nullptr
-                           : new EagerProofGenerator(
-                                 pnm, qs.getUserContext(), "Skolemize::epg"))
+      d_epg(pnm == nullptr
+                ? nullptr
+                : new EagerProofGenerator(pnm, userContext(), "Skolemize::epg"))
 {
 }
 
index fbb79f5d2f1a4b0746a391350f77e761b01c0088..294ad0084389bb8d703a5deb1a1ac9f9ebf67c72 100644 (file)
@@ -26,6 +26,7 @@
 #include "expr/type_node.h"
 #include "proof/eager_proof_generator.h"
 #include "proof/trust_node.h"
+#include "smt/env_obj.h"
 
 namespace cvc5 {
 
@@ -63,12 +64,15 @@ class TermRegistry;
  * default and can be enabled by option:
  *   --quant-ind
  */
-class Skolemize
+class Skolemize : protected EnvObj
 {
   typedef context::CDHashMap<Node, Node> NodeNodeMap;
 
  public:
-  Skolemize(QuantifiersState& qs, TermRegistry& tr, ProofNodeManager* pnm);
+  Skolemize(Env& env,
+            QuantifiersState& qs,
+            TermRegistry& tr,
+            ProofNodeManager* pnm);
   ~Skolemize() {}
   /** skolemize quantified formula q
    * If the return value ret of this function is non-null, then ret is a trust
index 871a85fbd591b1c8508b162a9360cd6d26cae7c1..6b260bb81db8fb76d284d78dd0f29df8eed13b4d 100644 (file)
@@ -409,7 +409,7 @@ CegisUnifEnumDecisionStrategy::CegisUnifEnumDecisionStrategy(
     QuantifiersInferenceManager& qim,
     TermDbSygus* tds,
     SynthConjecture* parent)
-    : DecisionStrategyFmf(qs.getSatContext(), qs.getValuation()),
+    : DecisionStrategyFmf(env, qs.getValuation()),
       d_qim(qim),
       d_tds(tds),
       d_parent(parent)
index da021227ab8ae12c414bc125ca22d1e8ed18c60a..22ba879d7dd31d74f1b42e420bf83543aef1f04c 100644 (file)
@@ -241,11 +241,8 @@ void SynthConjecture::assign(Node q)
   }
 
   // register the strategy
-  d_feasible_strategy.reset(
-      new DecisionStrategySingleton("sygus_feasible",
-                                    d_feasible_guard,
-                                    d_qstate.getSatContext(),
-                                    d_qstate.getValuation()));
+  d_feasible_strategy.reset(new DecisionStrategySingleton(
+      d_env, "sygus_feasible", d_feasible_guard, d_qstate.getValuation()));
   d_qim.getDecisionManager()->registerStrategy(
       DecisionManager::STRAT_QUANT_SYGUS_FEASIBLE, d_feasible_strategy.get());
   // this must be called, both to ensure that the feasible guard is
index 4da273cd9f3c82d77fada08ceaeb6009fea9b20b..64bc578a55cf15da8ca3dd6f0b97193044e187c4 100644 (file)
@@ -529,7 +529,7 @@ void SygusInst::registerCeLemma(Node q, std::vector<TypeNode>& types)
    */
   Assert(d_dstrat.find(q) == d_dstrat.end());
   DecisionStrategy* ds = new DecisionStrategySingleton(
-      "CeLiteral", lit, d_qstate.getSatContext(), d_qstate.getValuation());
+      d_env, "CeLiteral", lit, d_qstate.getValuation());
 
   d_dstrat[q].reset(ds);
   d_qim.getDecisionManager()->registerStrategy(
index 6aa2a816a356083ce5cbcc00155f33f8735dbf7a..7126d35670caf4c8899b66ef3753a82fdc4d8369 100644 (file)
@@ -43,13 +43,12 @@ TermDb::TermDb(Env& env, QuantifiersState& qs, QuantifiersRegistry& qr)
       d_qim(nullptr),
       d_qreg(qr),
       d_termsContext(),
-      d_termsContextUse(options::termDbCd() ? qs.getSatContext()
-                                            : &d_termsContext),
+      d_termsContextUse(options::termDbCd() ? context() : &d_termsContext),
       d_processed(d_termsContextUse),
       d_typeMap(d_termsContextUse),
       d_ops(d_termsContextUse),
       d_opMap(d_termsContextUse),
-      d_inactive_map(qs.getSatContext())
+      d_inactive_map(context())
 {
   d_consistent_ee = true;
   d_true = NodeManager::currentNM()->mkConst(true);
index 98618f3f7701819a357ae4b3341d0d4f6efb8704..ab999ad9ba60862c187a437adeac93ff7b42a4af 100644 (file)
@@ -33,8 +33,8 @@ TermRegistry::TermRegistry(Env& env,
                            QuantifiersState& qs,
                            QuantifiersRegistry& qr)
     : EnvObj(env),
-      d_presolve(qs.getUserContext(), true),
-      d_presolveCache(qs.getUserContext()),
+      d_presolve(userContext(), true),
+      d_presolveCache(userContext()),
       d_termEnum(new TermEnumeration),
       d_termPools(new TermPools(env, qs)),
       d_termDb(logicInfo().isHigherOrder() ? new HoTermDb(env, qs, qr)
index 5f914484a53c80a8240e8da45e011c6e5a2eb69f..b713dbec13586d55c0ce075c16e3821375d2ef09 100644 (file)
@@ -59,8 +59,8 @@ QuantifiersEngine::QuantifiersEngine(
       d_qreg(qr),
       d_treg(tr),
       d_model(nullptr),
-      d_quants_prereg(qs.getUserContext()),
-      d_quants_red(qs.getUserContext()),
+      d_quants_prereg(userContext()),
+      d_quants_red(userContext()),
       d_numInstRoundsLemma(0)
 {
   Trace("quant-init-debug")
index e19e9063498e9ad7667302eca96bb8924351767a..d28bae12a4f6ae16ed4264f31f3e568551d7d063 100644 (file)
@@ -467,7 +467,7 @@ void TheorySep::reduceFact(TNode atom, bool polarity, TNode fact)
         << std::endl;
     Node g = sm->mkDummySkolem("G", nm->booleanType());
     d_neg_guard_strategy[g].reset(new DecisionStrategySingleton(
-        "sep_neg_guard", g, context(), getValuation()));
+        d_env, "sep_neg_guard", g, getValuation()));
     DecisionStrategySingleton* ds = d_neg_guard_strategy[g].get();
     d_im.getDecisionManager()->registerStrategy(
         DecisionManager::STRAT_SEP_NEG_GUARD, ds);
index 39b1fcca9da7189ff334acb1f6420d85fc65ef09..1842147247182c27eecb38d08e032fc386071d79 100644 (file)
@@ -35,13 +35,15 @@ namespace cvc5 {
 namespace theory {
 namespace sets {
 
-CardinalityExtension::CardinalityExtension(SolverState& s,
+CardinalityExtension::CardinalityExtension(Env& env,
+                                           SolverState& s,
                                            InferenceManager& im,
                                            TermRegistry& treg)
-    : d_state(s),
+    : EnvObj(env),
+      d_state(s),
       d_im(im),
       d_treg(treg),
-      d_card_processed(s.getUserContext()),
+      d_card_processed(userContext()),
       d_finite_type_constants_processed(false)
 {
   d_true = NodeManager::currentNM()->mkConst(true);
index bddcfaf1bd3ded6607f63fb81b5c328ca616216b..d3f9971d60d81d48fac41fb3f17365020310c2fe 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "context/cdhashset.h"
 #include "context/context.h"
+#include "smt/env_obj.h"
 #include "theory/sets/inference_manager.h"
 #include "theory/sets/solver_state.h"
 #include "theory/sets/term_registry.h"
@@ -60,7 +61,7 @@ namespace sets {
  * normal forms, where the normal form for Set terms is a set of (equivalence
  * class representatives of) Venn regions that do not contain the empty set.
  */
-class CardinalityExtension
+class CardinalityExtension : protected EnvObj
 {
   typedef context::CDHashSet<Node> NodeSet;
 
@@ -69,7 +70,8 @@ class CardinalityExtension
    * Constructs a new instance of the cardinality solver w.r.t. the provided
    * contexts.
    */
-  CardinalityExtension(SolverState& s,
+  CardinalityExtension(Env& env,
+                       SolverState& s,
                        InferenceManager& im,
                        TermRegistry& treg);
 
index be8e5858edea5489c88863bd352b57370026d3cf..f1fe1c6b27945c7ed7d5a7848590977b17e6fc90 100644 (file)
@@ -25,14 +25,16 @@ namespace cvc5 {
 namespace theory {
 namespace sets {
 
-TermRegistry::TermRegistry(SolverState& state,
+TermRegistry::TermRegistry(Env& env,
+                           SolverState& state,
                            InferenceManager& im,
                            SkolemCache& skc,
                            ProofNodeManager* pnm)
-    : d_im(im),
+    : EnvObj(env),
+      d_im(im),
       d_skCache(skc),
-      d_proxy(state.getUserContext()),
-      d_proxy_to_term(state.getUserContext()),
+      d_proxy(userContext()),
+      d_proxy_to_term(userContext()),
       d_epg(
           pnm ? new EagerProofGenerator(pnm, nullptr, "sets::TermRegistry::epg")
               : nullptr)
index f88596ffe65d0aee12780c270d281bcaf69d0558..e0a03cef4a11b0134ec3cf652b090367f873795c 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "context/cdhashmap.h"
 #include "proof/eager_proof_generator.h"
+#include "smt/env_obj.h"
 #include "theory/sets/inference_manager.h"
 #include "theory/sets/skolem_cache.h"
 #include "theory/sets/solver_state.h"
@@ -35,12 +36,13 @@ namespace sets {
  * Term registry, the purpose of this class is to maintain a database of
  * commonly used terms, and mappings from sets to their "proxy variables".
  */
-class TermRegistry
+class TermRegistry : protected EnvObj
 {
   typedef context::CDHashMap<Node, Node> NodeMap;
 
  public:
-  TermRegistry(SolverState& state,
+  TermRegistry(Env& env,
+               SolverState& state,
                InferenceManager& im,
                SkolemCache& skc,
                ProofNodeManager* pnm);
index 8073b4c2acd2f3fc32b310b024f24f53d03ee8d0..2164c26b061fd579bc9b68b33a80c9de299aaa98 100644 (file)
@@ -51,9 +51,9 @@ TheorySetsPrivate::TheorySetsPrivate(Env& env,
       d_state(state),
       d_im(im),
       d_skCache(skc),
-      d_treg(state, im, skc, pnm),
-      d_rels(new TheorySetsRels(state, im, skc, d_treg)),
-      d_cardSolver(new CardinalityExtension(state, im, d_treg)),
+      d_treg(d_env, state, im, skc, pnm),
+      d_rels(new TheorySetsRels(d_env, state, im, skc, d_treg)),
+      d_cardSolver(new CardinalityExtension(d_env, state, im, d_treg)),
       d_rels_enabled(false),
       d_card_enabled(false)
 {
index 65f5cedf577fc3a05019533e265549638ac80486..f6ea88b75899438958987efabadb4d889807e35a 100644 (file)
@@ -34,15 +34,17 @@ typedef std::map< Node, std::map< kind::Kind_t, std::vector< Node > > >::iterato
 typedef std::map<Node, std::map<Node, std::unordered_set<Node> > >::iterator
     TC_IT;
 
-TheorySetsRels::TheorySetsRels(SolverState& s,
+TheorySetsRels::TheorySetsRels(Env& env,
+                               SolverState& s,
                                InferenceManager& im,
                                SkolemCache& skc,
                                TermRegistry& treg)
-    : d_state(s),
+    : EnvObj(env),
+      d_state(s),
       d_im(im),
       d_skCache(skc),
       d_treg(treg),
-      d_shared_terms(s.getUserContext())
+      d_shared_terms(userContext())
 {
   d_trueNode = NodeManager::currentNM()->mkConst(true);
   d_falseNode = NodeManager::currentNM()->mkConst(false);
index 89514c64149df34180f3d6d8aaf6dfc71d82ab5a..560f474823a5eda75eb7f63966d4dbf0745643a5 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "context/cdhashset.h"
 #include "context/cdlist.h"
+#include "smt/env_obj.h"
 #include "theory/sets/inference_manager.h"
 #include "theory/sets/rels_utils.h"
 #include "theory/sets/solver_state.h"
@@ -59,13 +60,15 @@ public:
  * extension of the theory of sets. That is, it shares many components of the
  * TheorySets object which owns it.
  */
-class TheorySetsRels {
+class TheorySetsRels : protected EnvObj
+{
   typedef context::CDList<Node> NodeList;
   typedef context::CDHashSet<Node> NodeSet;
   typedef context::CDHashMap<Node, Node> NodeMap;
 
  public:
-  TheorySetsRels(SolverState& s,
+  TheorySetsRels(Env& env,
+                 SolverState& s,
                  InferenceManager& im,
                  SkolemCache& skc,
                  TermRegistry& treg);
index 5e685576c7d741a9e2bb50bb1837029f06a28974..3c825e4ae0133a230621200e5f95c68ed79c72e0 100644 (file)
@@ -31,8 +31,8 @@ namespace cvc5 {
 namespace theory {
 namespace strings {
 
-BaseSolver::BaseSolver(SolverState& s, InferenceManager& im)
-    : d_state(s), d_im(im), d_congruent(s.getSatContext())
+BaseSolver::BaseSolver(Env& env, SolverState& s, InferenceManager& im)
+    : EnvObj(env), d_state(s), d_im(im), d_congruent(context())
 {
   d_false = NodeManager::currentNM()->mkConst(false);
   d_cardSize = utils::getAlphabetCardinality();
index 6c423e3b893c7780ba0b36f4d4593460c697bfe1..27f9ec40da6de1c29bb6b1fed91749192e1bc3e3 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "context/cdhashset.h"
 #include "context/cdlist.h"
+#include "smt/env_obj.h"
 #include "theory/strings/infer_info.h"
 #include "theory/strings/inference_manager.h"
 #include "theory/strings/normal_form.h"
@@ -37,12 +38,12 @@ namespace strings {
  * current context, and techniques for inferring when equivalence classes
  * are equivalent to constants.
  */
-class BaseSolver
+class BaseSolver : protected EnvObj
 {
   using NodeSet = context::CDHashSet<Node>;
 
  public:
-  BaseSolver(SolverState& s, InferenceManager& im);
+  BaseSolver(Env& env, SolverState& s, InferenceManager& im);
   ~BaseSolver();
 
   //-----------------------inference steps
index fb1d086a4197622fa226cbb444be51d318bcde65..98a0e819cddbe2af0d2b062e5cc502d248b3d47f 100644 (file)
@@ -37,15 +37,17 @@ namespace strings {
 
 CoreInferInfo::CoreInferInfo(InferenceId id) : d_infer(id), d_index(0), d_rev(false) {}
 
-CoreSolver::CoreSolver(SolverState& s,
+CoreSolver::CoreSolver(Env& env,
+                       SolverState& s,
                        InferenceManager& im,
                        TermRegistry& tr,
                        BaseSolver& bs)
-    : d_state(s),
+    : EnvObj(env),
+      d_state(s),
       d_im(im),
       d_termReg(tr),
       d_bsolver(bs),
-      d_nfPairs(s.getSatContext())
+      d_nfPairs(context())
 {
   d_zero = NodeManager::currentNM()->mkConst( Rational( 0 ) );
   d_one = NodeManager::currentNM()->mkConst( Rational( 1 ) );
index 4e8a0a96b9ab6c286fe8f0aa01b5b670f4116907..35d37ce1276c7dc0e1cb80a1cede1a7840ab7679 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "context/cdhashset.h"
 #include "context/cdlist.h"
+#include "smt/env_obj.h"
 #include "theory/strings/base_solver.h"
 #include "theory/strings/infer_info.h"
 #include "theory/strings/inference_manager.h"
@@ -76,13 +77,14 @@ class CoreInferInfo
  * This implements techniques for handling (dis)equalities involving
  * string concatenation terms based on the procedure by Liang et al CAV 2014.
  */
-class CoreSolver
+class CoreSolver : protected EnvObj
 {
   friend class InferenceManager;
   using NodeIntMap = context::CDHashMap<Node, int>;
 
  public:
-  CoreSolver(SolverState& s,
+  CoreSolver(Env& env,
+             SolverState& s,
              InferenceManager& im,
              TermRegistry& tr,
              BaseSolver& bs);
index d5b1b70887eb7cee3cc57eb0b145b1861805b47b..86f4e48fd70e1d4b2d23f516837ecc27de6ec2d9 100644 (file)
@@ -29,7 +29,8 @@ namespace cvc5 {
 namespace theory {
 namespace strings {
 
-ExtfSolver::ExtfSolver(SolverState& s,
+ExtfSolver::ExtfSolver(Env& env,
+                       SolverState& s,
                        InferenceManager& im,
                        TermRegistry& tr,
                        StringsRewriter& rewriter,
@@ -37,7 +38,8 @@ ExtfSolver::ExtfSolver(SolverState& s,
                        CoreSolver& cs,
                        ExtTheory& et,
                        SequencesStatistics& statistics)
-    : d_state(s),
+    : EnvObj(env),
+      d_state(s),
       d_im(im),
       d_termReg(tr),
       d_rewriter(rewriter),
@@ -46,9 +48,9 @@ ExtfSolver::ExtfSolver(SolverState& s,
       d_extt(et),
       d_statistics(statistics),
       d_preproc(d_termReg.getSkolemCache(), &statistics.d_reductions),
-      d_hasExtf(s.getSatContext(), false),
-      d_extfInferCache(s.getSatContext()),
-      d_reduced(s.getUserContext())
+      d_hasExtf(context(), false),
+      d_extfInferCache(context()),
+      d_reduced(userContext())
 {
   d_extt.addFunctionKind(kind::STRING_SUBSTR);
   d_extt.addFunctionKind(kind::STRING_UPDATE);
index 82b4f61ee819e4137463e1d54f8ce83ff525c542..2a9ca2d45f379c0d7fdc8d7af7b759668058e513 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "context/cdo.h"
 #include "expr/node.h"
+#include "smt/env_obj.h"
 #include "theory/ext_theory.h"
 #include "theory/strings/base_solver.h"
 #include "theory/strings/core_solver.h"
@@ -79,12 +80,13 @@ class ExtfInfoTmp
  * functions for the theory of strings using a combination of context-dependent
  * simplification (Reynolds et al CAV 2017) and lazy reductions.
  */
-class ExtfSolver
+class ExtfSolver : protected EnvObj
 {
   typedef context::CDHashSet<Node> NodeSet;
 
  public:
-  ExtfSolver(SolverState& s,
+  ExtfSolver(Env& env,
+             SolverState& s,
              InferenceManager& im,
              TermRegistry& tr,
              StringsRewriter& rewriter,
index 18815c731ee0eeae4490841c1812d0931c150f63..7d077059b49a5e618ef43b2887455c83500a11e4 100644 (file)
@@ -32,20 +32,22 @@ namespace cvc5 {
 namespace theory {
 namespace strings {
 
-RegExpSolver::RegExpSolver(SolverState& s,
+RegExpSolver::RegExpSolver(Env& env,
+                           SolverState& s,
                            InferenceManager& im,
                            SkolemCache* skc,
                            CoreSolver& cs,
                            ExtfSolver& es,
                            SequencesStatistics& stats)
-    : d_state(s),
+    : EnvObj(env),
+      d_state(s),
       d_im(im),
       d_csolver(cs),
       d_esolver(es),
       d_statistics(stats),
-      d_regexp_ucached(s.getUserContext()),
-      d_regexp_ccached(s.getSatContext()),
-      d_processed_memberships(s.getSatContext()),
+      d_regexp_ucached(userContext()),
+      d_regexp_ccached(context()),
+      d_processed_memberships(context()),
       d_regexp_opr(skc)
 {
   d_emptyString = NodeManager::currentNM()->mkConst(::cvc5::String(""));
index 98e2449c57068f6e4aad41f1a74c68febd090fc5..1d617eb1e678b265af4cf36016c2d0233be207a1 100644 (file)
 #define CVC5__THEORY__STRINGS__REGEXP_SOLVER_H
 
 #include <map>
+
 #include "context/cdhashset.h"
 #include "context/cdlist.h"
 #include "context/context.h"
 #include "expr/node.h"
+#include "smt/env_obj.h"
 #include "theory/strings/extf_solver.h"
 #include "theory/strings/inference_manager.h"
-#include "theory/strings/skolem_cache.h"
 #include "theory/strings/regexp_operation.h"
 #include "theory/strings/sequences_stats.h"
+#include "theory/strings/skolem_cache.h"
 #include "theory/strings/solver_state.h"
 #include "util/string.h"
 
@@ -35,7 +37,7 @@ namespace cvc5 {
 namespace theory {
 namespace strings {
 
-class RegExpSolver
+class RegExpSolver : protected EnvObj
 {
   typedef context::CDList<Node> NodeList;
   typedef context::CDHashMap<Node, bool> NodeBoolMap;
@@ -45,7 +47,8 @@ class RegExpSolver
   typedef context::CDHashSet<Node> NodeSet;
 
  public:
-  RegExpSolver(SolverState& s,
+  RegExpSolver(Env& env,
+               SolverState& s,
                InferenceManager& im,
                SkolemCache* skc,
                CoreSolver& cs,
index 9bb6a2420acb0ddc48a4f51b930c83356da3f3e0..b1050f480849a4d64924ad371929f816020a308c 100644 (file)
@@ -25,15 +25,8 @@ namespace cvc5 {
 namespace theory {
 namespace strings {
 
-StringsFmf::StringsFmf(context::Context* c,
-                       context::UserContext* u,
-                       Valuation valuation,
-                       TermRegistry& tr)
-    : d_sslds(nullptr),
-      d_satContext(c),
-      d_userContext(u),
-      d_valuation(valuation),
-      d_termReg(tr)
+StringsFmf::StringsFmf(Env& env, Valuation valuation, TermRegistry& tr)
+    : EnvObj(env), d_sslds(nullptr), d_valuation(valuation), d_termReg(tr)
 {
 }
 
@@ -41,8 +34,7 @@ StringsFmf::~StringsFmf() {}
 
 void StringsFmf::presolve()
 {
-  d_sslds.reset(new StringSumLengthDecisionStrategy(
-      d_satContext, d_userContext, d_valuation));
+  d_sslds.reset(new StringSumLengthDecisionStrategy(d_env, d_valuation));
   Trace("strings-dstrat-reg")
       << "presolve: register decision strategy." << std::endl;
   const NodeSet& ivars = d_termReg.getInputVars();
@@ -60,8 +52,8 @@ DecisionStrategy* StringsFmf::getDecisionStrategy() const
 }
 
 StringsFmf::StringSumLengthDecisionStrategy::StringSumLengthDecisionStrategy(
-    context::Context* c, context::UserContext* u, Valuation valuation)
-    : DecisionStrategyFmf(c, valuation), d_inputVarLsum(u)
+    Env& env, Valuation valuation)
+    : DecisionStrategyFmf(env, valuation), d_inputVarLsum(userContext())
 {
 }
 
index 39ba6168a3de213563ed2093a122b0ce94713858..6b09ba198d09718010c2d307d514b8c57b1013bb 100644 (file)
@@ -22,6 +22,7 @@
 #include "context/cdo.h"
 #include "context/context.h"
 #include "expr/node.h"
+#include "smt/env_obj.h"
 #include "theory/decision_strategy.h"
 #include "theory/strings/term_registry.h"
 #include "theory/valuation.h"
@@ -35,15 +36,12 @@ namespace strings {
  * This class manages the creation of a decision strategy that bounds the
  * sum of lengths of terms of type string.
  */
-class StringsFmf
+class StringsFmf : protected EnvObj
 {
   typedef context::CDHashSet<Node> NodeSet;
 
  public:
-  StringsFmf(context::Context* c,
-             context::UserContext* u,
-             Valuation valuation,
-             TermRegistry& tr);
+  StringsFmf(Env& env, Valuation valuation, TermRegistry& tr);
   ~StringsFmf();
   /** presolve
    *
@@ -68,9 +66,7 @@ class StringsFmf
   class StringSumLengthDecisionStrategy : public DecisionStrategyFmf
   {
    public:
-    StringSumLengthDecisionStrategy(context::Context* c,
-                                    context::UserContext* u,
-                                    Valuation valuation);
+    StringSumLengthDecisionStrategy(Env& env, Valuation valuation);
     /** make literal */
     Node mkLiteral(unsigned i) override;
     /** identify */
@@ -95,10 +91,6 @@ class StringsFmf
   };
   /** an instance of the above class */
   std::unique_ptr<StringSumLengthDecisionStrategy> d_sslds;
-  /** The SAT search context for the theory of strings. */
-  context::Context* d_satContext;
-  /** The user level assertion context for the theory of strings. */
-  context::UserContext* d_userContext;
   /** The valuation object of theory of strings */
   Valuation d_valuation;
   /** The term registry of theory of strings */
index 1b77308d708a8ea72d229f982cd1baa4572b9659..dd53adecc9dae51920fcb7793865b5bd17825844 100644 (file)
@@ -40,25 +40,26 @@ struct StringsProxyVarAttributeId
 typedef expr::Attribute<StringsProxyVarAttributeId, bool>
     StringsProxyVarAttribute;
 
-TermRegistry::TermRegistry(SolverState& s,
+TermRegistry::TermRegistry(Env& env,
+                           SolverState& s,
                            SequencesStatistics& statistics,
                            ProofNodeManager* pnm)
-    : d_state(s),
+    : EnvObj(env),
+      d_state(s),
       d_im(nullptr),
       d_statistics(statistics),
       d_hasStrCode(false),
-      d_functionsTerms(s.getSatContext()),
-      d_inputVars(s.getUserContext()),
-      d_preregisteredTerms(s.getSatContext()),
-      d_registeredTerms(s.getUserContext()),
-      d_registeredTypes(s.getUserContext()),
-      d_proxyVar(s.getUserContext()),
-      d_lengthLemmaTermsCache(s.getUserContext()),
-      d_epg(pnm ? new EagerProofGenerator(
-                      pnm,
-                      s.getUserContext(),
-                      "strings::TermRegistry::EagerProofGenerator")
-                : nullptr)
+      d_functionsTerms(context()),
+      d_inputVars(userContext()),
+      d_preregisteredTerms(context()),
+      d_registeredTerms(userContext()),
+      d_registeredTypes(userContext()),
+      d_proxyVar(userContext()),
+      d_lengthLemmaTermsCache(userContext()),
+      d_epg(
+          pnm ? new EagerProofGenerator(
+              pnm, userContext(), "strings::TermRegistry::EagerProofGenerator")
+              : nullptr)
 {
   NodeManager* nm = NodeManager::currentNM();
   d_zero = nm->mkConst(Rational(0));
index 7d660e019fcc0e743671d8e9102e1744761afdc6..ba973fac8e0f4ff931f823e783d5be64609794c7 100644 (file)
@@ -22,6 +22,7 @@
 #include "context/cdlist.h"
 #include "proof/eager_proof_generator.h"
 #include "proof/proof_node_manager.h"
+#include "smt/env_obj.h"
 #include "theory/output_channel.h"
 #include "theory/strings/infer_info.h"
 #include "theory/strings/sequences_stats.h"
@@ -44,14 +45,15 @@ class InferenceManager;
  * (5) Maintaining a skolem cache. Notice that this skolem cache is the
  * official skolem cache that should be used by all modules in TheoryStrings.
  */
-class TermRegistry
+class TermRegistry : protected EnvObj
 {
   typedef context::CDHashSet<Node> NodeSet;
   typedef context::CDHashSet<TypeNode, std::hash<TypeNode>> TypeNodeSet;
   typedef context::CDHashMap<Node, Node> NodeNodeMap;
 
  public:
-  TermRegistry(SolverState& s,
+  TermRegistry(Env& env,
+               SolverState& s,
                SequencesStatistics& statistics,
                ProofNodeManager* pnm);
   ~TermRegistry();
index 3e807c3ac0c835482496748f88642e3197d705e9..1b315447e6502bf80ab135aeb5f85776663111c7 100644 (file)
@@ -56,14 +56,15 @@ TheoryStrings::TheoryStrings(Env& env, OutputChannel& out, Valuation valuation)
       d_statistics(),
       d_state(env, d_valuation),
       d_eagerSolver(d_state),
-      d_termReg(d_state, d_statistics, d_pnm),
+      d_termReg(env, d_state, d_statistics, d_pnm),
       d_extTheoryCb(),
       d_im(env, *this, d_state, d_termReg, d_extTheory, d_statistics, d_pnm),
       d_extTheory(d_extTheoryCb, context(), userContext(), d_im),
       d_rewriter(&d_statistics.d_rewrites),
-      d_bsolver(d_state, d_im),
-      d_csolver(d_state, d_im, d_termReg, d_bsolver),
-      d_esolver(d_state,
+      d_bsolver(env, d_state, d_im),
+      d_csolver(env, d_state, d_im, d_termReg, d_bsolver),
+      d_esolver(env,
+                d_state,
                 d_im,
                 d_termReg,
                 d_rewriter,
@@ -71,14 +72,15 @@ TheoryStrings::TheoryStrings(Env& env, OutputChannel& out, Valuation valuation)
                 d_csolver,
                 d_extTheory,
                 d_statistics),
-      d_rsolver(d_state,
+      d_rsolver(env,
+                d_state,
                 d_im,
                 d_termReg.getSkolemCache(),
                 d_csolver,
                 d_esolver,
                 d_statistics),
       d_regexp_elim(options::regExpElimAgg(), d_pnm, userContext()),
-      d_stringsFmf(context(), userContext(), valuation, d_termReg)
+      d_stringsFmf(env, valuation, d_termReg)
 {
   d_termReg.finishInit(&d_im);
 
index ec7955125fb6405ff9ffd290400894c673473113..484e27eaddbfa2702104f7fe5ea06ce65cfdd44d 100644 (file)
@@ -27,13 +27,6 @@ TheoryState::TheoryState(Env& env, Valuation val)
 
 void TheoryState::setEqualityEngine(eq::EqualityEngine* ee) { d_ee = ee; }
 
-context::Context* TheoryState::getSatContext() const { return context(); }
-
-context::UserContext* TheoryState::getUserContext() const
-{
-  return userContext();
-}
-
 bool TheoryState::hasTerm(TNode a) const
 {
   Assert(d_ee != nullptr);
index 574aa935510403bcc9c13b84d8925cdfb5da1668..e8da3ad3922483af0eb88b2598a5c6b8c74fe34c 100644 (file)
@@ -42,10 +42,6 @@ class TheoryState : protected EnvObj
    * of theory.
    */
   void setEqualityEngine(eq::EqualityEngine* ee);
-  /** Get the SAT context */
-  context::Context* getSatContext() const;
-  /** Get the user context */
-  context::UserContext* getUserContext() const;
   //-------------------------------------- equality information
   /** Is t registered as a term in the equality engine of this class? */
   virtual bool hasTerm(TNode a) const;
index 5b919860ec6670f339f958e9eb79c9ffd1da75a5..3c71cdbb9bcb37b5913669c7b33b80af463b51d8 100644 (file)
@@ -186,7 +186,7 @@ void Region::setDisequal( Node n1, Node n2, int type, bool valid ){
 void Region::setRep( Node n, bool valid ) {
   Assert(hasRep(n) != valid);
   if( valid && d_nodes.find( n )==d_nodes.end() ){
-    d_nodes[n] = new RegionNodeInfo(d_cf->d_state.getSatContext());
+    d_nodes[n] = new RegionNodeInfo(d_cf->d_thss->context());
   }
   d_nodes[n]->setValid(valid);
   d_reps_size = d_reps_size + ( valid ? 1 : -1 );
@@ -447,8 +447,8 @@ void Region::debugPrint( const char* c, bool incClique ) {
 }
 
 SortModel::CardinalityDecisionStrategy::CardinalityDecisionStrategy(
-    Node t, context::Context* satContext, Valuation valuation)
-    : DecisionStrategyFmf(satContext, valuation), d_cardinality_term(t)
+    Env& env, Node t, Valuation valuation)
+    : DecisionStrategyFmf(env, valuation), d_cardinality_term(t)
 {
 }
 Node SortModel::CardinalityDecisionStrategy::mkLiteral(unsigned i)
@@ -470,15 +470,15 @@ SortModel::SortModel(Node n,
       d_state(state),
       d_im(im),
       d_thss(thss),
-      d_regions_index(d_state.getSatContext(), 0),
-      d_regions_map(d_state.getSatContext()),
-      d_split_score(d_state.getSatContext()),
-      d_disequalities_index(d_state.getSatContext(), 0),
-      d_reps(d_state.getSatContext(), 0),
-      d_cardinality(d_state.getSatContext(), 1),
-      d_hasCard(d_state.getSatContext(), false),
-      d_maxNegCard(d_state.getSatContext(), 0),
-      d_initialized(d_state.getUserContext(), false),
+      d_regions_index(thss->context(), 0),
+      d_regions_map(thss->context()),
+      d_split_score(thss->context()),
+      d_disequalities_index(thss->context(), 0),
+      d_reps(thss->context(), 0),
+      d_cardinality(thss->context(), 1),
+      d_hasCard(thss->context(), false),
+      d_maxNegCard(thss->context(), 0),
+      d_initialized(thss->userContext(), false),
       d_c_dec_strat(nullptr)
 {
   d_cardinality_term = n;
@@ -489,7 +489,7 @@ SortModel::SortModel(Node n,
     // We are guaranteed that the decision manager is ready since we
     // construct this module during TheoryUF::finishInit.
     d_c_dec_strat.reset(new CardinalityDecisionStrategy(
-        n, d_state.getSatContext(), thss->getTheory()->getValuation()));
+        thss->d_env, n, thss->getTheory()->getValuation()));
   }
 }
 
@@ -530,7 +530,7 @@ void SortModel::newEqClass( Node n ){
         d_regions[d_regions_index]->setValid(true);
         Assert(d_regions[d_regions_index]->getNumReps() == 0);
       }else{
-        d_regions.push_back(new Region(this, d_state.getSatContext()));
+        d_regions.push_back(new Region(this, d_thss->context()));
       }
       d_regions[d_regions_index]->addRep(n);
       d_regions_index = d_regions_index + 1;
@@ -1225,29 +1225,31 @@ Node SortModel::getCardinalityLiteral(uint32_t c)
   return lit;
 }
 
-CardinalityExtension::CardinalityExtension(TheoryState& state,
+CardinalityExtension::CardinalityExtension(Env& env,
+                                           TheoryState& state,
                                            TheoryInferenceManager& im,
                                            TheoryUF* th)
-    : d_state(state),
+    : EnvObj(env),
+      d_state(state),
       d_im(im),
       d_th(th),
       d_rep_model(),
-      d_min_pos_com_card(state.getSatContext(), 0),
-      d_min_pos_com_card_set(state.getSatContext(), false),
+      d_min_pos_com_card(context(), 0),
+      d_min_pos_com_card_set(context(), false),
       d_cc_dec_strat(nullptr),
-      d_initializedCombinedCardinality(state.getUserContext(), false),
-      d_card_assertions_eqv_lemma(state.getUserContext()),
-      d_min_pos_tn_master_card(state.getSatContext(), 0),
-      d_min_pos_tn_master_card_set(state.getSatContext(), false),
-      d_rel_eqc(state.getSatContext())
+      d_initializedCombinedCardinality(userContext(), false),
+      d_card_assertions_eqv_lemma(userContext()),
+      d_min_pos_tn_master_card(context(), 0),
+      d_min_pos_tn_master_card_set(context(), false),
+      d_rel_eqc(context())
 {
   if (options::ufssMode() == options::UfssMode::FULL && options::ufssFairness())
   {
     // Register the strategy with the decision manager of the theory.
     // We are guaranteed that the decision manager is ready since we
     // construct this module during TheoryUF::finishInit.
-    d_cc_dec_strat.reset(new CombinedCardinalityDecisionStrategy(
-        state.getSatContext(), th->getValuation()));
+    d_cc_dec_strat.reset(
+        new CombinedCardinalityDecisionStrategy(env, th->getValuation()));
   }
 }
 
@@ -1560,9 +1562,8 @@ void CardinalityExtension::presolve()
 }
 
 CardinalityExtension::CombinedCardinalityDecisionStrategy::
-    CombinedCardinalityDecisionStrategy(context::Context* satContext,
-                                        Valuation valuation)
-    : DecisionStrategyFmf(satContext, valuation)
+    CombinedCardinalityDecisionStrategy(Env& env, Valuation valuation)
+    : DecisionStrategyFmf(env, valuation)
 {
 }
 Node CardinalityExtension::CombinedCardinalityDecisionStrategy::mkLiteral(
index 1809a30bdc329ceb58c3e19980ceeab90db9f56e..10e9ceb4496df2c067ab4d62d32c7723f5c3c936 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "context/cdhashmap.h"
 #include "context/context.h"
+#include "smt/env_obj.h"
 #include "theory/decision_strategy.h"
 #include "theory/theory.h"
 #include "util/statistics_stats.h"
@@ -36,7 +37,7 @@ class TheoryUF;
  * CAV 2013, or Reynolds dissertation "Finite Model Finding in Satisfiability
  * Modulo Theories".
  */
-class CardinalityExtension
+class CardinalityExtension : protected EnvObj
 {
  protected:
   typedef context::CDHashMap<Node, bool> NodeBoolMap;
@@ -340,9 +341,7 @@ class CardinalityExtension
     class CardinalityDecisionStrategy : public DecisionStrategyFmf
     {
      public:
-      CardinalityDecisionStrategy(Node t,
-                                  context::Context* satContext,
-                                  Valuation valuation);
+      CardinalityDecisionStrategy(Env& env, Node t, Valuation valuation);
       /** make literal (the i^th combined cardinality literal) */
       Node mkLiteral(unsigned i) override;
       /** identify */
@@ -357,7 +356,8 @@ class CardinalityExtension
   }; /** class SortModel */
 
  public:
-  CardinalityExtension(TheoryState& state,
+  CardinalityExtension(Env& env,
+                       TheoryState& state,
                        TheoryInferenceManager& im,
                        TheoryUF* th);
   ~CardinalityExtension();
@@ -436,8 +436,7 @@ class CardinalityExtension
   class CombinedCardinalityDecisionStrategy : public DecisionStrategyFmf
   {
    public:
-    CombinedCardinalityDecisionStrategy(context::Context* satContext,
-                                        Valuation valuation);
+    CombinedCardinalityDecisionStrategy(Env& env, Valuation valuation);
     /** make literal (the i^th combined cardinality literal) */
     Node mkLiteral(unsigned i) override;
     /** identify */
index af2bf4a3b307b146b2ac8e7534c138b4c3faca5b..925805332a172332e193d46ed4300d0217226938 100644 (file)
@@ -28,11 +28,14 @@ namespace cvc5 {
 namespace theory {
 namespace uf {
 
-HoExtension::HoExtension(TheoryState& state, TheoryInferenceManager& im)
-    : d_state(state),
+HoExtension::HoExtension(Env& env,
+                         TheoryState& state,
+                         TheoryInferenceManager& im)
+    : EnvObj(env),
+      d_state(state),
       d_im(im),
-      d_extensionality(state.getUserContext()),
-      d_uf_std_skolem(state.getUserContext())
+      d_extensionality(userContext()),
+      d_uf_std_skolem(userContext())
 {
   d_true = NodeManager::currentNM()->mkConst(true);
 }
index af8f727fd31750f9b26f4b7ed8bbd48e1d60a918..a646b57bef32a83b4f749322d17379b0346ca7b2 100644 (file)
@@ -22,6 +22,7 @@
 #include "context/cdhashset.h"
 #include "context/cdo.h"
 #include "expr/node.h"
+#include "smt/env_obj.h"
 #include "theory/theory_inference_manager.h"
 #include "theory/theory_model.h"
 #include "theory/theory_state.h"
@@ -47,13 +48,13 @@ class TheoryUF;
  *
  * For more details, see "Extending SMT Solvers to Higher-Order", Barbosa et al.
  */
-class HoExtension
+class HoExtension : protected EnvObj
 {
   typedef context::CDHashSet<Node> NodeSet;
   typedef context::CDHashMap<Node, Node> NodeNodeMap;
 
  public:
-  HoExtension(TheoryState& state, TheoryInferenceManager& im);
+  HoExtension(Env& env, TheoryState& state, TheoryInferenceManager& im);
 
   /** ppRewrite
    *
index 07820a41d5a5ef120661ba57fadd3ac7e975ce1b..056b0407abb1f4401126385c31d3c87f4f518687 100644 (file)
@@ -92,7 +92,7 @@ void TheoryUF::finishInit() {
   if (options::finiteModelFind()
       && options::ufssMode() != options::UfssMode::NONE)
   {
-    d_thss.reset(new CardinalityExtension(d_state, d_im, this));
+    d_thss.reset(new CardinalityExtension(d_env, d_state, d_im, this));
   }
   // The kinds we are treating as function application in congruence
   bool isHo = logicInfo().isHigherOrder();
@@ -100,7 +100,7 @@ void TheoryUF::finishInit() {
   if (isHo)
   {
     d_equalityEngine->addFunctionKind(kind::HO_APPLY);
-    d_ho.reset(new HoExtension(d_state, d_im));
+    d_ho.reset(new HoExtension(d_env, d_state, d_im));
   }
 }