EnvObj: Add options(), context(), userContext(). (#7137)
authorAina Niemetz <aina.niemetz@gmail.com>
Fri, 3 Sep 2021 23:33:33 +0000 (16:33 -0700)
committerGitHub <noreply@github.com>
Fri, 3 Sep 2021 23:33:33 +0000 (23:33 +0000)
This further renames EnvObj::getLogicInfo to EnvObj::logicInfo.

28 files changed:
src/preprocessing/passes/ackermann.cpp
src/preprocessing/passes/bv_to_int.cpp
src/preprocessing/passes/foreign_theory_rewrite.cpp
src/preprocessing/passes/fun_def_fmf.cpp
src/preprocessing/passes/ite_simp.cpp
src/preprocessing/passes/non_clausal_simp.cpp
src/preprocessing/passes/pseudo_boolean_processor.cpp
src/preprocessing/passes/real_to_int.cpp
src/preprocessing/passes/sygus_inference.cpp
src/preprocessing/passes/unconstrained_simplifier.cpp
src/preprocessing/preprocessing_pass_context.cpp
src/preprocessing/preprocessing_pass_context.h
src/smt/env_obj.cpp
src/smt/env_obj.h
src/theory/arith/theory_arith.cpp
src/theory/arith/theory_arith_private.cpp
src/theory/model_manager.cpp
src/theory/quantifiers/sygus/sygus_repair_const.cpp
src/theory/quantifiers/theory_quantifiers.cpp
src/theory/sep/theory_sep.cpp
src/theory/sets/theory_sets.cpp
src/theory/sort_inference.cpp
src/theory/theory.cpp
src/theory/theory_engine.cpp
src/theory/theory_model.cpp
src/theory/theory_model_builder.cpp
src/theory/theory_state.cpp
src/theory/uf/theory_uf.cpp

index eb6410291b10cc5f738e5f6c3f81f46e37031847..7f3d778fd633720a88f8444c5f5882e9ae4eba39 100644 (file)
@@ -299,9 +299,9 @@ void usortsToBitVectors(const LogicInfo& d_logic,
 
 Ackermann::Ackermann(PreprocessingPassContext* preprocContext)
     : PreprocessingPass(preprocContext, "ackermann"),
-      d_funcToSkolem(preprocContext->getUserContext()),
-      d_usVarsToBVVars(preprocContext->getUserContext()),
-      d_logic(preprocContext->getLogicInfo())
+      d_funcToSkolem(userContext()),
+      d_usVarsToBVVars(userContext()),
+      d_logic(logicInfo())
 {
 }
 
index ad2707035312b0f6c307661bd26bf66f7869806e..65c9bb012309bbb7cd9803a9584d4bb00d3721f8 100644 (file)
@@ -928,11 +928,11 @@ Node BVToInt::reconstructNode(Node originalNode,
 
 BVToInt::BVToInt(PreprocessingPassContext* preprocContext)
     : PreprocessingPass(preprocContext, "bv-to-int"),
-      d_binarizeCache(preprocContext->getUserContext()),
-      d_eliminationCache(preprocContext->getUserContext()),
-      d_rebuildCache(preprocContext->getUserContext()),
-      d_bvToIntCache(preprocContext->getUserContext()),
-      d_rangeAssertions(preprocContext->getUserContext())
+      d_binarizeCache(userContext()),
+      d_eliminationCache(userContext()),
+      d_rebuildCache(userContext()),
+      d_bvToIntCache(userContext()),
+      d_rangeAssertions(userContext())
 {
   d_nm = NodeManager::currentNM();
   d_zero = d_nm->mkConst<Rational>(0);
index 888d5e43a9bb9a4bd7e0f5586186f65b94155052..6040b36698a36a8b23f8856de143703844062886 100644 (file)
@@ -28,9 +28,10 @@ namespace preprocessing {
 namespace passes {
 
 using namespace cvc5::theory;
-ForeignTheoryRewrite::ForeignTheoryRewrite(PreprocessingPassContext* preprocContext)
+ForeignTheoryRewrite::ForeignTheoryRewrite(
+    PreprocessingPassContext* preprocContext)
     : PreprocessingPass(preprocContext, "foreign-theory-rewrite"),
-      d_cache(preprocContext->getUserContext()){};
+      d_cache(userContext()){};
 
 Node ForeignTheoryRewrite::simplify(Node n)
 {
index 44dafefcba8f242ffea8b0f014ce7cd1bd64df39..2405702b004b55b24119fb4dfe5e1fc13e456e1d 100644 (file)
@@ -39,8 +39,7 @@ FunDefFmf::FunDefFmf(PreprocessingPassContext* preprocContext)
     : PreprocessingPass(preprocContext, "fun-def-fmf"),
       d_fmfRecFunctionsDefined(nullptr)
 {
-  d_fmfRecFunctionsDefined =
-      new (true) NodeList(preprocContext->getUserContext());
+  d_fmfRecFunctionsDefined = new (true) NodeList(userContext());
 }
 
 FunDefFmf::~FunDefFmf() { d_fmfRecFunctionsDefined->deleteSelf(); }
index 54e2b657ef45a5e9aaadf65d7b681cd2e52f2ffb..434256d280a8f78e21c8dbf7493c43108dd1b9cb 100644 (file)
@@ -144,16 +144,17 @@ bool ITESimp::doneSimpITE(AssertionPipeline* assertionsToPreprocess)
   }
 
   // Do theory specific preprocessing passes
-  if (d_env.getLogicInfo().isTheoryEnabled(theory::THEORY_ARITH)
+  if (logicInfo().isTheoryEnabled(theory::THEORY_ARITH)
       && !options::incrementalSolving())
   {
     if (!simpDidALotOfWork)
     {
       util::ContainsTermITEVisitor& contains =
           *(d_iteUtilities.getContainsVisitor());
-      arith::ArithIteUtils aiteu(contains,
-                                 d_preprocContext->getUserContext(),
-                                 d_preprocContext->getTopLevelSubstitutions().get());
+      arith::ArithIteUtils aiteu(
+          contains,
+          userContext(),
+          d_preprocContext->getTopLevelSubstitutions().get());
       bool anyItes = false;
       for (size_t i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
       {
index 5610b0117fb907802d03163a502173e2ca63012e..8f390a40261fa89e2eb47bfeced243d189e84f92 100644 (file)
@@ -53,16 +53,12 @@ NonClausalSimp::NonClausalSimp(PreprocessingPassContext* preprocContext)
     : PreprocessingPass(preprocContext, "non-clausal-simp"),
       d_pnm(preprocContext->getProofNodeManager()),
       d_llpg(d_pnm ? new smt::PreprocessProofGenerator(
-                         d_pnm,
-                         preprocContext->getUserContext(),
-                         "NonClausalSimp::llpg")
+                 d_pnm, userContext(), "NonClausalSimp::llpg")
                    : nullptr),
-      d_llra(d_pnm ? new LazyCDProof(d_pnm,
-                                     nullptr,
-                                     preprocContext->getUserContext(),
-                                     "NonClausalSimp::llra")
+      d_llra(d_pnm ? new LazyCDProof(
+                 d_pnm, nullptr, userContext(), "NonClausalSimp::llra")
                    : nullptr),
-      d_tsubsList(preprocContext->getUserContext())
+      d_tsubsList(userContext())
 {
 }
 
@@ -91,7 +87,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
   Trace("non-clausal-simplify") << "asserting to propagator" << std::endl;
   for (size_t i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
   {
-    Assert(Rewriter::rewrite((*assertionsToPreprocess)[i])
+    Assert(rewrite((*assertionsToPreprocess)[i])
            == (*assertionsToPreprocess)[i]);
     // Don't reprocess substitutions
     if (assertionsToPreprocess->isSubstsIndex(i))
@@ -122,7 +118,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
       << "Iterate through " << propagator->getLearnedLiterals().size()
       << " learned literals." << std::endl;
   // No conflict, go through the literals and solve them
-  context::Context* u = d_preprocContext->getUserContext();
+  context::Context* u = userContext();
   TrustSubstitutionMap& ttls = d_preprocContext->getTopLevelSubstitutions();
   CVC5_UNUSED SubstitutionMap& top_level_substs = ttls.get();
   // constant propagations
@@ -152,7 +148,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
   {
     // Simplify the literal we learned wrt previous substitutions
     Node learnedLiteral = learned_literals[i].getNode();
-    Assert(Rewriter::rewrite(learnedLiteral) == learnedLiteral);
+    Assert(rewrite(learnedLiteral) == learnedLiteral);
     Assert(top_level_substs.apply(learnedLiteral) == learnedLiteral);
     // process the learned literal with substitutions and const propagations
     learnedLiteral = processLearnedLit(
@@ -198,7 +194,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
         // The literal should rewrite to true
         Trace("non-clausal-simplify")
             << "solved " << learnedLiteral << std::endl;
-        Assert(Rewriter::rewrite(nss.apply(learnedLiteral)).isConst());
+        Assert(rewrite(nss.apply(learnedLiteral)).isConst());
         // else fall through
         break;
       }
@@ -282,7 +278,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
   for (SubstitutionMap::iterator pos = cps.begin(); pos != cps.end(); ++pos)
   {
     Assert((*pos).second.isConst());
-    Assert(Rewriter::rewrite((*pos).first) == (*pos).first);
+    Assert(rewrite((*pos).first) == (*pos).first);
     Assert(cps.apply((*pos).second) == (*pos).second);
   }
 #endif /* CVC5_ASSERTIONS */
@@ -304,7 +300,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
           << "assertionNew = " << assertionNew.getNode() << std::endl;
       assertionsToPreprocess->replaceTrusted(i, assertionNew);
       assertion = assertionNew.getNode();
-      Assert(Rewriter::rewrite(assertion) == assertion);
+      Assert(rewrite(assertion) == assertion);
     }
     for (;;)
     {
index c60e636bd493907f660b70656dfc19257f253b2a..ca61c9197610a588339a734ed90eb062c9b6e927 100644 (file)
@@ -35,9 +35,9 @@ using namespace cvc5::theory::arith;
 PseudoBooleanProcessor::PseudoBooleanProcessor(
     PreprocessingPassContext* preprocContext)
     : PreprocessingPass(preprocContext, "pseudo-boolean-processor"),
-      d_pbBounds(preprocContext->getUserContext()),
-      d_subCache(preprocContext->getUserContext()),
-      d_pbs(preprocContext->getUserContext(), 0)
+      d_pbBounds(userContext()),
+      d_subCache(userContext()),
+      d_pbs(userContext(), 0)
 {
 }
 
index a60b4a097508a7115b89b21879d217fd1ca8ce98..3cfc29ed690a7b1dd43930837265226d5d580fe2 100644 (file)
@@ -34,8 +34,7 @@ namespace preprocessing {
 namespace passes {
 
 RealToInt::RealToInt(PreprocessingPassContext* preprocContext)
-    : PreprocessingPass(preprocContext, "real-to-int"),
-      d_cache(preprocContext->getUserContext())
+    : PreprocessingPass(preprocContext, "real-to-int"), d_cache(userContext())
 {
 }
 
index c0cddda5eae51dfafb6ee18705b0611e46411c34..d105c436a110b58afc7e657cc081770e943bd21a 100644 (file)
@@ -295,9 +295,7 @@ bool SygusInference::solveSygus(const std::vector<Node>& assertions,
 
   // make a separate smt call
   std::unique_ptr<SmtEngine> rrSygus;
-  theory::initializeSubsolver(rrSygus,
-                              d_preprocContext->getOptions(),
-                              d_preprocContext->getLogicInfo());
+  theory::initializeSubsolver(rrSygus, options(), logicInfo());
   rrSygus->assertFormula(body);
   Trace("sygus-infer") << "*** Check sat..." << std::endl;
   Result r = rrSygus->checkSat();
index f13de5e74c40bc5743080f8e40cc6b5441647e4a..c8ddfc2fad3318b890b65c28ab5d63f2badee8fb 100644 (file)
@@ -42,8 +42,8 @@ UnconstrainedSimplifier::UnconstrainedSimplifier(
     : PreprocessingPass(preprocContext, "unconstrained-simplifier"),
       d_numUnconstrainedElim(smtStatisticsRegistry().registerInt(
           "preprocessor::number of unconstrained elims")),
-      d_context(preprocContext->getDecisionContext()),
-      d_substitutions(preprocContext->getDecisionContext())
+      d_context(context()),
+      d_substitutions(context())
 {
 }
 
@@ -591,7 +591,7 @@ void UnconstrainedSimplifier::processUnconstrained()
         // Uninterpreted function - if domain is infinite, no quantifiers are
         // used, and any child is unconstrained, result is unconstrained
         case kind::APPLY_UF:
-          if (d_preprocContext->getLogicInfo().isQuantified()
+          if (logicInfo().isQuantified()
               || !current.getType().getCardinality().isInfinite())
           {
             break;
index ac0301cc0cefc86b908bf2e1157c28203b096300..a0894351de84bc9d5eaa1c062456a250f6f8574b 100644 (file)
@@ -31,20 +31,11 @@ PreprocessingPassContext::PreprocessingPassContext(
     : EnvObj(env),
       d_smt(smt),
       d_circuitPropagator(circuitPropagator),
-      d_llm(env.getTopLevelSubstitutions(),
-            env.getUserContext(),
-            env.getProofNodeManager()),
-      d_symsInAssertions(env.getUserContext())
+      d_llm(
+          env.getTopLevelSubstitutions(), userContext(), getProofNodeManager()),
+      d_symsInAssertions(userContext())
 {
 }
-const Options& PreprocessingPassContext::getOptions() const
-{
-  return d_env.getOptions();
-}
-const LogicInfo& PreprocessingPassContext::getLogicInfo() const
-{
-  return d_env.getLogicInfo();
-}
 
 theory::TrustSubstitutionMap&
 PreprocessingPassContext::getTopLevelSubstitutions() const
@@ -60,14 +51,7 @@ prop::PropEngine* PreprocessingPassContext::getPropEngine() const
 {
   return d_smt->getPropEngine();
 }
-context::Context* PreprocessingPassContext::getUserContext() const
-{
-  return d_env.getUserContext();
-}
-context::Context* PreprocessingPassContext::getDecisionContext() const
-{
-  return d_env.getContext();
-}
+
 void PreprocessingPassContext::spendResource(Resource r)
 {
   d_env.getResourceManager()->spendResource(r);
index 29b2fda7f229220aac8cf8806f3c0f5b06a5cf94..79b89dda87f631da446e1ded00809605e3e101ee 100644 (file)
@@ -59,10 +59,6 @@ class PreprocessingPassContext : protected EnvObj
   TheoryEngine* getTheoryEngine() const;
   /** Get the associated Propengine. */
   prop::PropEngine* getPropEngine() const;
-  /** Get the current user context. */
-  context::Context* getUserContext() const;
-  /** Get the current decision context. */
-  context::Context* getDecisionContext() const;
 
   /** Get the associated circuit propagator. */
   theory::booleans::CircuitPropagator* getCircuitPropagator() const
@@ -82,11 +78,6 @@ class PreprocessingPassContext : protected EnvObj
   /** Spend resource in the resource manager of the associated Env. */
   void spendResource(Resource r);
 
-  /** Get the options of the environment */
-  const Options& getOptions() const;
-  /** Get the current logic info of the environment */
-  const LogicInfo& getLogicInfo() const;
-
   /** Get a reference to the top-level substitution map */
   theory::TrustSubstitutionMap& getTopLevelSubstitutions() const;
 
index 04a5050dbb7711a70ee220f5640b5fbe928eec00..acc3ab0384c007523290f90082dba0866e9d72c6 100644 (file)
@@ -26,6 +26,15 @@ EnvObj::EnvObj(Env& env) : d_env(env) {}
 
 Node EnvObj::rewrite(TNode node) { return d_env.getRewriter()->rewrite(node); }
 
-const LogicInfo& EnvObj::getLogicInfo() const { return d_env.getLogicInfo(); }
+const LogicInfo& EnvObj::logicInfo() const { return d_env.getLogicInfo(); }
+
+const Options& EnvObj::options() const { return d_env.getOptions(); }
+
+context::Context* EnvObj::context() const { return d_env.getContext(); }
+
+context::UserContext* EnvObj::userContext() const
+{
+  return d_env.getUserContext();
+}
 
 }  // namespace cvc5
index ffd5a391552c6e00866949d68bb7661df3061f2d..d1c882b96a6ea151f563ae204e6474df1051bb19 100644 (file)
@@ -30,6 +30,11 @@ class LogicInfo;
 class NodeManager;
 class Options;
 
+namespace context {
+class Context;
+class UserContext;
+}  // namespace context
+
 class EnvObj
 {
  protected:
@@ -46,7 +51,16 @@ class EnvObj
   Node rewrite(TNode node);
 
   /** Get the current logic information. */
-  const LogicInfo& getLogicInfo() const;
+  const LogicInfo& logicInfo() const;
+
+  /** Get the options object (const version only) via Env. */
+  const Options& options() const;
+
+  /** Get a pointer to the Context via Env. */
+  context::Context* context() const;
+
+  /** Get a pointer to the UserContext via Env. */
+  context::UserContext* userContext() const;
 
   /** The associated environment. */
   Env& d_env;
index ccdf5a90a4fd4b608639b3ce4a7ded8366fd9065..500b1edcdc4441f90177e458530601733b097b3b 100644 (file)
@@ -46,7 +46,7 @@ TheoryArith::TheoryArith(Env& env, OutputChannel& out, Valuation valuation)
       d_eqSolver(nullptr),
       d_internal(new TheoryArithPrivate(*this, env, d_bab)),
       d_nonlinearExtension(nullptr),
-      d_opElim(d_pnm, getLogicInfo()),
+      d_opElim(d_pnm, logicInfo()),
       d_arithPreproc(d_astate, d_im, d_pnm, d_opElim),
       d_rewriter(d_opElim)
 {
@@ -87,8 +87,8 @@ bool TheoryArith::needsEqualityEngine(EeSetupInfo& esi)
 }
 void TheoryArith::finishInit()
 {
-  if (getLogicInfo().isTheoryEnabled(THEORY_ARITH)
-      && getLogicInfo().areTranscendentalsUsed())
+  const LogicInfo& logic = logicInfo();
+  if (logic.isTheoryEnabled(THEORY_ARITH) && logic.areTranscendentalsUsed())
   {
     // witness is used to eliminate square root
     d_valuation.setUnevaluatedKind(kind::WITNESS);
@@ -98,8 +98,7 @@ void TheoryArith::finishInit()
     d_valuation.setUnevaluatedKind(kind::PI);
   }
   // only need to create nonlinear extension if non-linear logic
-  const LogicInfo& logicInfo = getLogicInfo();
-  if (logicInfo.isTheoryEnabled(THEORY_ARITH) && !logicInfo.isLinear())
+  if (logic.isTheoryEnabled(THEORY_ARITH) && !logic.isLinear())
   {
     d_nonlinearExtension.reset(new nl::NonlinearExtension(*this, d_astate));
   }
index 070300b3bed9ad858f61a1803cc4ec40ff82273a..347a86c1b297b4828b9df945a6cf09a6a370aad7 100644 (file)
@@ -96,9 +96,9 @@ TheoryArithPrivate::TheoryArithPrivate(TheoryArith& containing,
       d_pnm(d_env.isTheoryProofProducing() ? d_env.getProofNodeManager()
                                            : nullptr),
       d_checker(),
-      d_pfGen(new EagerProofGenerator(d_pnm, d_env.getUserContext())),
-      d_constraintDatabase(d_env.getContext(),
-                           d_env.getUserContext(),
+      d_pfGen(new EagerProofGenerator(d_pnm, userContext())),
+      d_constraintDatabase(context(),
+                           userContext(),
                            d_partialModel,
                            d_congruenceManager,
                            RaiseConflict(*this),
@@ -107,15 +107,15 @@ TheoryArithPrivate::TheoryArithPrivate(TheoryArith& containing,
       d_qflraStatus(Result::SAT_UNKNOWN),
       d_unknownsInARow(0),
       d_hasDoneWorkSinceCut(false),
-      d_learner(d_env.getUserContext()),
-      d_assertionsThatDoNotMatchTheirLiterals(d_env.getContext()),
+      d_learner(userContext()),
+      d_assertionsThatDoNotMatchTheirLiterals(context()),
       d_nextIntegerCheckVar(0),
-      d_constantIntegerVariables(d_env.getContext()),
-      d_diseqQueue(d_env.getContext(), false),
+      d_constantIntegerVariables(context()),
+      d_diseqQueue(context(), false),
       d_currentPropagationList(),
-      d_learnedBounds(d_env.getContext()),
-      d_preregisteredNodes(d_env.getContext()),
-      d_partialModel(d_env.getContext(), DeltaComputeCallback(*this)),
+      d_learnedBounds(context()),
+      d_preregisteredNodes(context()),
+      d_partialModel(context(), DeltaComputeCallback(*this)),
       d_errorSet(
           d_partialModel, TableauSizes(&d_tableau), BoundCountingLookup(*this)),
       d_tableau(),
@@ -123,23 +123,22 @@ TheoryArithPrivate::TheoryArithPrivate(TheoryArith& containing,
               d_tableau,
               d_rowTracking,
               BasicVarModelUpdateCallBack(*this)),
-      d_diosolver(d_env.getContext()),
+      d_diosolver(context()),
       d_restartsCounter(0),
       d_tableauSizeHasBeenModified(false),
       d_tableauResetDensity(1.6),
       d_tableauResetPeriod(10),
-      d_conflicts(d_env.getContext()),
-      d_blackBoxConflict(d_env.getContext(), Node::null()),
-      d_blackBoxConflictPf(d_env.getContext(),
-                           std::shared_ptr<ProofNode>(nullptr)),
-      d_congruenceManager(d_env.getContext(),
-                          d_env.getUserContext(),
+      d_conflicts(context()),
+      d_blackBoxConflict(context(), Node::null()),
+      d_blackBoxConflictPf(context(), std::shared_ptr<ProofNode>(nullptr)),
+      d_congruenceManager(context(),
+                          userContext(),
                           d_constraintDatabase,
                           SetupLiteralCallBack(*this),
                           d_partialModel,
                           RaiseEqualityEngineConflict(*this),
                           d_pnm),
-      d_cmEnabled(d_env.getContext(), options().arith.arithCongMan),
+      d_cmEnabled(context(), options().arith.arithCongMan),
 
       d_dualSimplex(
           d_linEq, d_errorSet, RaiseConflict(*this), TempVarMalloc(*this)),
@@ -151,22 +150,22 @@ TheoryArithPrivate::TheoryArithPrivate(TheoryArith& containing,
           d_linEq, d_errorSet, RaiseConflict(*this), TempVarMalloc(*this)),
       d_pass1SDP(NULL),
       d_otherSDP(NULL),
-      d_lastContextIntegerAttempted(d_env.getContext(), -1),
+      d_lastContextIntegerAttempted(context(), -1),
 
       d_DELTA_ZERO(0),
-      d_approxCuts(d_env.getContext()),
+      d_approxCuts(context()),
       d_fullCheckCounter(0),
-      d_cutCount(d_env.getContext(), 0),
-      d_cutInContext(d_env.getContext()),
-      d_likelyIntegerInfeasible(d_env.getContext(), false),
-      d_guessedCoeffSet(d_env.getContext(), false),
+      d_cutCount(context(), 0),
+      d_cutInContext(context()),
+      d_likelyIntegerInfeasible(context(), false),
+      d_guessedCoeffSet(context(), false),
       d_guessedCoeffs(),
       d_treeLog(NULL),
       d_replayVariables(),
       d_replayConstraints(),
       d_lhsTmp(),
       d_approxStats(NULL),
-      d_attemptSolveIntTurnedOff(d_env.getUserContext(), 0),
+      d_attemptSolveIntTurnedOff(userContext(), 0),
       d_dioSolveResources(0),
       d_solveIntMaybeHelp(0u),
       d_solveIntAttempts(0u),
@@ -1153,7 +1152,8 @@ void TheoryArithPrivate::setupVariableList(const VarList& vl){
   if(!vl.singleton()){
     // vl is the product of at least 2 variables
     // vl : (* v1 v2 ...)
-    if(getLogicInfo().isLinear()){
+    if (logicInfo().isLinear())
+    {
       throw LogicException("A non-linear fact was asserted to arithmetic in a linear logic.");
     }
     d_foundNl = true;
@@ -1305,7 +1305,8 @@ void TheoryArithPrivate::releaseArithVar(ArithVar v){
 ArithVar TheoryArithPrivate::requestArithVar(TNode x, bool aux, bool internal){
   //TODO : The VarList trick is good enough?
   Assert(isLeaf(x) || VarList::isMember(x) || x.getKind() == PLUS || internal);
-  if(getLogicInfo().isLinear() && Variable::isDivMember(x)){
+  if (logicInfo().isLinear() && Variable::isDivMember(x))
+  {
     stringstream ss;
     ss << "A non-linear fact (involving div/mod/divisibility) was asserted to "
           "arithmetic in a linear logic: "
index 2b746cba14352bfd62542bc98dc985bbf8c0640f..dd06d4afd56845839d0fc4581cdf4c12e04d07d2 100644 (file)
@@ -46,9 +46,8 @@ ModelManager::~ModelManager() {}
 void ModelManager::finishInit(eq::EqualityEngineNotify* notify)
 {
   // construct the model
-  const LogicInfo& logicInfo = d_env.getLogicInfo();
   // Initialize the model and model builder.
-  if (logicInfo.isQuantified())
+  if (logicInfo().isQuantified())
   {
     QuantifiersEngine* qe = d_te.getQuantifiersEngine();
     Assert(qe != nullptr);
index 2b6719b27fcf62f5a253b842af535437bd365e49..bcd826799e22a613df560638d0087eae4ef2d437 100644 (file)
@@ -189,7 +189,7 @@ bool SygusRepairConst::repairSolution(Node sygusBody,
 
   // check whether it is not in the current logic, e.g. non-linear arithmetic.
   // if so, undo replacements until it is in the current logic.
-  const LogicInfo& logic = getLogicInfo();
+  const LogicInfo& logic = logicInfo();
   if (logic.isTheoryEnabled(THEORY_ARITH) && logic.isLinear())
   {
     fo_body = fitToLogic(sygusBody,
index 2ad475f011054d4df45a77b64a71f06bcbb7ecc2..67c40eaacbaa9599f99d4d43a08d8874f1bc52cc 100644 (file)
@@ -34,7 +34,7 @@ TheoryQuantifiers::TheoryQuantifiers(Env& env,
                                      OutputChannel& out,
                                      Valuation valuation)
     : Theory(THEORY_QUANTIFIERS, env, out, valuation),
-      d_qstate(env, valuation, getLogicInfo()),
+      d_qstate(env, valuation, logicInfo()),
       d_qreg(),
       d_treg(d_qstate, d_qreg),
       d_qim(*this, d_qstate, d_qreg, d_treg, d_pnm),
index ba1680c6b9c81914787727328a5c17720f06d2db..b19ba68deff9f462205dd54a4ba2ba2df29577e6 100644 (file)
@@ -1208,7 +1208,7 @@ Node TheorySep::getBaseLabel( TypeNode tn ) {
     bool tn_is_monotonic = true;
     if( tn.isSort() ){
       //TODO: use monotonicity inference
-      tn_is_monotonic = !getLogicInfo().isQuantified();
+      tn_is_monotonic = !logicInfo().isQuantified();
     }else{
       tn_is_monotonic = tn.getCardinality().isInfinite();
     }
index 23ac0874936c6eed4ec38953be1f1ecb5c789cc3..8759f705661ce1f2e1d3ea767df600739ece6722 100644 (file)
@@ -146,7 +146,7 @@ TrustNode TheorySets::ppRewrite(TNode n, std::vector<SkolemLemma>& lems)
   if (nk == COMPREHENSION)
   {
     // set comprehension is an implicit quantifier, require it in the logic
-    if (!getLogicInfo().isQuantified())
+    if (!logicInfo().isQuantified())
     {
       std::stringstream ss;
       ss << "Set comprehensions require quantifiers in the background logic.";
index db2db9937e486cbec86863d840f208f427803929..b0f2a24729791623c898857d04e89e66c1765f01 100644 (file)
@@ -881,7 +881,7 @@ bool SortInference::isMonotonic( TypeNode tn ) {
 
 bool SortInference::isHandledApplyUf(Kind k) const
 {
-  return k == APPLY_UF && !d_env.getLogicInfo().isHigherOrder();
+  return k == APPLY_UF && !logicInfo().isHigherOrder();
 }
 
 }  // namespace theory
index f6513933fe528fe82add1bf208b6945aa85277b0..0c2624d6401db583a436e3ea29db08314b2f010f 100644 (file)
@@ -338,7 +338,7 @@ bool Theory::isLegalElimination(TNode x, TNode val)
   {
     return false;
   }
-  if (!options::produceModels() && !getLogicInfo().isQuantified())
+  if (!options::produceModels() && !logicInfo().isQuantified())
   {
     // Don't care about the model and logic is not quantified, we can eliminate.
     return true;
index 72f3d78ac2b7453637b0b08b4bffcf0d228dcef3..13e41978c0ebd0ce6090b858f67ee5d2f0777b5b 100644 (file)
@@ -158,7 +158,7 @@ void TheoryEngine::finishInit()
   if (options::relevanceFilter())
   {
     d_relManager.reset(
-        new RelevanceManager(d_env.getUserContext(), theory::Valuation(this)));
+        new RelevanceManager(userContext(), theory::Valuation(this)));
   }
 
   // initialize the quantifiers engine
@@ -208,14 +208,11 @@ void TheoryEngine::finishInit()
 
 ProofNodeManager* TheoryEngine::getProofNodeManager() const { return d_pnm; }
 
-context::Context* TheoryEngine::getSatContext() const
-{
-  return d_env.getContext();
-}
+context::Context* TheoryEngine::getSatContext() const { return context(); }
 
 context::UserContext* TheoryEngine::getUserContext() const
 {
-  return d_env.getUserContext();
+  return userContext();
 }
 
 TheoryEngine::TheoryEngine(Env& env)
@@ -224,36 +221,34 @@ TheoryEngine::TheoryEngine(Env& env)
       d_logicInfo(env.getLogicInfo()),
       d_pnm(d_env.isTheoryProofProducing() ? d_env.getProofNodeManager()
                                            : nullptr),
-      d_lazyProof(d_pnm != nullptr
-                      ? new LazyCDProof(d_pnm,
-                                        nullptr,
-                                        d_env.getUserContext(),
-                                        "TheoryEngine::LazyCDProof")
-                      : nullptr),
-      d_tepg(new TheoryEngineProofGenerator(d_pnm, d_env.getUserContext())),
+      d_lazyProof(
+          d_pnm != nullptr ? new LazyCDProof(
+              d_pnm, nullptr, userContext(), "TheoryEngine::LazyCDProof")
+                           : nullptr),
+      d_tepg(new TheoryEngineProofGenerator(d_pnm, userContext())),
       d_tc(nullptr),
       d_sharedSolver(nullptr),
       d_quantEngine(nullptr),
-      d_decManager(new DecisionManager(d_env.getUserContext())),
+      d_decManager(new DecisionManager(userContext())),
       d_relManager(nullptr),
-      d_inConflict(d_env.getContext(), false),
+      d_inConflict(context(), false),
       d_inSatMode(false),
       d_hasShutDown(false),
-      d_incomplete(d_env.getContext(), false),
-      d_incompleteTheory(d_env.getContext(), THEORY_BUILTIN),
-      d_incompleteId(d_env.getContext(), IncompleteId::UNKNOWN),
-      d_propagationMap(d_env.getContext()),
-      d_propagationMapTimestamp(d_env.getContext(), 0),
-      d_propagatedLiterals(d_env.getContext()),
-      d_propagatedLiteralsIndex(d_env.getContext(), 0),
-      d_atomRequests(d_env.getContext()),
+      d_incomplete(context(), false),
+      d_incompleteTheory(context(), THEORY_BUILTIN),
+      d_incompleteId(context(), IncompleteId::UNKNOWN),
+      d_propagationMap(context()),
+      d_propagationMapTimestamp(context(), 0),
+      d_propagatedLiterals(context()),
+      d_propagatedLiteralsIndex(context(), 0),
+      d_atomRequests(context()),
       d_combineTheoriesTime(smtStatisticsRegistry().registerTimer(
           "TheoryEngine::combineTheoriesTime")),
       d_true(),
       d_false(),
       d_interrupted(false),
       d_inPreregister(false),
-      d_factsAsserted(d_env.getContext(), false)
+      d_factsAsserted(context(), false)
 {
   for(TheoryId theoryId = theory::THEORY_FIRST; theoryId != theory::THEORY_LAST;
       ++ theoryId)
@@ -1063,7 +1058,7 @@ bool TheoryEngine::propagate(TNode literal, theory::TheoryId theory) {
   Debug("theory::propagate")
       << "TheoryEngine::propagate(" << literal << ", " << theory << ")" << endl;
 
-  Trace("dtview::prop") << std::string(d_env.getContext()->getLevel(), ' ')
+  Trace("dtview::prop") << std::string(context()->getLevel(), ' ')
                         << ":THEORY-PROP: " << literal << endl;
 
   // spendResource();
index 4cc25a887f1f829bce2c31e20248b04b302fce58..0c14f329ad9c42de2c1ffa62a9839704bd017f5f 100644 (file)
@@ -40,7 +40,7 @@ TheoryModel::TheoryModel(Env& env, std::string name, bool enableFuncModels)
       d_enableFuncModels(enableFuncModels)
 {
   // must use function models when ufHo is enabled
-  Assert(d_enableFuncModels || !d_env.getLogicInfo().isHigherOrder());
+  Assert(d_enableFuncModels || !logicInfo().isHigherOrder());
   d_true = NodeManager::currentNM()->mkConst( true );
   d_false = NodeManager::currentNM()->mkConst( false );
 }
@@ -53,7 +53,7 @@ void TheoryModel::finishInit(eq::EqualityEngine* ee)
   d_equalityEngine = ee;
   // The kinds we are treating as function application in congruence
   d_equalityEngine->addFunctionKind(
-      kind::APPLY_UF, false, d_env.getLogicInfo().isHigherOrder());
+      kind::APPLY_UF, false, logicInfo().isHigherOrder());
   d_equalityEngine->addFunctionKind(kind::HO_APPLY);
   d_equalityEngine->addFunctionKind(kind::SELECT);
   // d_equalityEngine->addFunctionKind(kind::STORE);
@@ -294,8 +294,7 @@ Node TheoryModel::getModelValue(TNode n) const
   // return the representative of the term in the equality engine, if it exists
   TypeNode t = ret.getType();
   bool eeHasTerm;
-  if (!d_env.getLogicInfo().isHigherOrder()
-      && (t.isFunction() || t.isPredicate()))
+  if (!logicInfo().isHigherOrder() && (t.isFunction() || t.isPredicate()))
   {
     // functions are in the equality engine, but *not* as first-class members
     // when higher-order is disabled. In this case, we cannot query
@@ -694,7 +693,7 @@ void TheoryModel::assignFunctionDefinition( Node f, Node f_def ) {
   Trace("model-builder") << "  Assigning function (" << f << ") to (" << f_def << ")" << endl;
   Assert(d_uf_models.find(f) == d_uf_models.end());
 
-  if (d_env.getLogicInfo().isHigherOrder())
+  if (logicInfo().isHigherOrder())
   {
     //we must rewrite the function value since the definition needs to be a constant value
     f_def = Rewriter::rewrite( f_def );
@@ -708,7 +707,7 @@ void TheoryModel::assignFunctionDefinition( Node f, Node f_def ) {
     d_uf_models[f] = f_def;
   }
 
-  if (d_env.getLogicInfo().isHigherOrder() && d_equalityEngine->hasTerm(f))
+  if (logicInfo().isHigherOrder() && d_equalityEngine->hasTerm(f))
   {
     Trace("model-builder-debug") << "  ...function is first-class member of equality engine" << std::endl;
     // assign to representative if higher-order
@@ -743,7 +742,7 @@ std::vector< Node > TheoryModel::getFunctionsToAssign() {
     Assert(d_env.getTopLevelSubstitutions().apply(n) == n);
     if( !hasAssignedFunctionDefinition( n ) ){
       Trace("model-builder-fun-debug") << "Look at function : " << n << std::endl;
-      if (d_env.getLogicInfo().isHigherOrder())
+      if (logicInfo().isHigherOrder())
       {
         // if in higher-order mode, assign function definitions modulo equality
         Node r = getRepresentative( n );
index 23a76d2732c60af01e9f2c0311f974dde551e4fe..bbe1588d68286cd5b588a4b82be702d65fd7f012 100644 (file)
@@ -130,7 +130,7 @@ bool TheoryEngineModelBuilder::isAssignable(TNode n)
   {
     // selectors are always assignable (where we guarantee that they are not
     // evaluatable here)
-    if (!d_env.getLogicInfo().isHigherOrder())
+    if (!logicInfo().isHigherOrder())
     {
       Assert(!n.getType().isFunction());
       return true;
@@ -152,7 +152,7 @@ bool TheoryEngineModelBuilder::isAssignable(TNode n)
   else
   {
     // non-function variables, and fully applied functions
-    if (!d_env.getLogicInfo().isHigherOrder())
+    if (!logicInfo().isHigherOrder())
     {
       // no functions exist, all functions are fully applied
       Assert(n.getKind() != kind::HO_APPLY);
@@ -1229,7 +1229,7 @@ bool TheoryEngineModelBuilder::processBuildModel(TheoryModel* m)
 
 void TheoryEngineModelBuilder::assignFunction(TheoryModel* m, Node f)
 {
-  Assert(!d_env.getLogicInfo().isHigherOrder());
+  Assert(!logicInfo().isHigherOrder());
   uf::UfModelTree ufmt(f);
   Node default_v;
   for (size_t i = 0; i < m->d_uf_terms[f].size(); i++)
@@ -1274,7 +1274,7 @@ void TheoryEngineModelBuilder::assignFunction(TheoryModel* m, Node f)
 
 void TheoryEngineModelBuilder::assignHoFunction(TheoryModel* m, Node f)
 {
-  Assert(d_env.getLogicInfo().isHigherOrder());
+  Assert(logicInfo().isHigherOrder());
   TypeNode type = f.getType();
   std::vector<TypeNode> argTypes = type.getArgTypes();
   std::vector<Node> args;
@@ -1398,7 +1398,7 @@ void TheoryEngineModelBuilder::assignFunctions(TheoryModel* m)
   Trace("model-builder") << "Assigning function values..." << std::endl;
   std::vector<Node> funcs_to_assign = m->getFunctionsToAssign();
 
-  if (d_env.getLogicInfo().isHigherOrder())
+  if (logicInfo().isHigherOrder())
   {
     // sort based on type size if higher-order
     Trace("model-builder") << "Sort functions by type..." << std::endl;
@@ -1425,7 +1425,7 @@ void TheoryEngineModelBuilder::assignFunctions(TheoryModel* m)
     Trace("model-builder") << "  Function #" << k << " is " << f << std::endl;
     // std::map< Node, std::vector< Node > >::iterator itht =
     // m->d_ho_uf_terms.find( f );
-    if (!d_env.getLogicInfo().isHigherOrder())
+    if (!logicInfo().isHigherOrder())
     {
       Trace("model-builder") << "  Assign function value for " << f
                              << " based on APPLY_UF" << std::endl;
index e3655e3ab7261963bec579a9c9357c17e77c1bb2..ec7955125fb6405ff9ffd290400894c673473113 100644 (file)
@@ -21,23 +21,17 @@ namespace cvc5 {
 namespace theory {
 
 TheoryState::TheoryState(Env& env, Valuation val)
-    : EnvObj(env),
-      d_valuation(val),
-      d_ee(nullptr),
-      d_conflict(d_env.getContext(), false)
+    : EnvObj(env), d_valuation(val), d_ee(nullptr), d_conflict(context(), false)
 {
 }
 
 void TheoryState::setEqualityEngine(eq::EqualityEngine* ee) { d_ee = ee; }
 
-context::Context* TheoryState::getSatContext() const
-{
-  return d_env.getContext();
-}
+context::Context* TheoryState::getSatContext() const { return context(); }
 
 context::UserContext* TheoryState::getUserContext() const
 {
-  return d_env.getUserContext();
+  return userContext();
 }
 
 bool TheoryState::hasTerm(TNode a) const
index 9c506f2acf7e75eaa08e92242fd744f5190765d5..bdc5304e47888278dfc2ce007ebe1568f94b73ea 100644 (file)
@@ -48,8 +48,8 @@ TheoryUF::TheoryUF(Env& env,
       d_thss(nullptr),
       d_ho(nullptr),
       d_functionsTerms(getSatContext()),
-      d_symb(getUserContext(), instanceName),
-      d_rewriter(env.getLogicInfo().isHigherOrder()),
+      d_symb(userContext(), instanceName),
+      d_rewriter(logicInfo().isHigherOrder()),
       d_state(env, valuation),
       d_im(*this, d_state, d_pnm, "theory::uf::" + instanceName, false),
       d_notify(d_im, *this)
@@ -95,9 +95,9 @@ void TheoryUF::finishInit() {
     d_thss.reset(new CardinalityExtension(d_state, d_im, this));
   }
   // The kinds we are treating as function application in congruence
-  d_equalityEngine->addFunctionKind(
-      kind::APPLY_UF, false, getLogicInfo().isHigherOrder());
-  if (getLogicInfo().isHigherOrder())
+  bool isHo = logicInfo().isHigherOrder();
+  d_equalityEngine->addFunctionKind(kind::APPLY_UF, false, isHo);
+  if (isHo)
   {
     d_equalityEngine->addFunctionKind(kind::HO_APPLY);
     d_ho.reset(new HoExtension(d_state, d_im));
@@ -148,7 +148,7 @@ void TheoryUF::postCheck(Effort level)
   // check with the higher-order extension at full effort
   if (!d_state.isInConflict() && fullEffort(level))
   {
-    if (getLogicInfo().isHigherOrder())
+    if (logicInfo().isHigherOrder())
     {
       d_ho->check();
     }
@@ -171,7 +171,7 @@ void TheoryUF::notifyFact(TNode atom, bool pol, TNode fact, bool isInternal)
   {
     case kind::EQUAL:
     {
-      if (getLogicInfo().isHigherOrder() && options::ufHoExt())
+      if (logicInfo().isHigherOrder() && options::ufHoExt())
       {
         if (!pol && !d_state.isInConflict() && atom[0].getType().isFunction())
         {
@@ -186,7 +186,7 @@ void TheoryUF::notifyFact(TNode atom, bool pol, TNode fact, bool isInternal)
     {
       if (d_thss == nullptr)
       {
-        if (!getLogicInfo().hasCardinalityConstraints())
+        if (!logicInfo().hasCardinalityConstraints())
         {
           std::stringstream ss;
           ss << "Cardinality constraint " << atom
@@ -214,7 +214,7 @@ TrustNode TheoryUF::ppRewrite(TNode node, std::vector<SkolemLemma>& lems)
   Kind k = node.getKind();
   if (k == kind::HO_APPLY)
   {
-    if (!getLogicInfo().isHigherOrder())
+    if (!logicInfo().isHigherOrder())
     {
       std::stringstream ss;
       ss << "Partial function applications are only supported with "
@@ -234,7 +234,7 @@ TrustNode TheoryUF::ppRewrite(TNode node, std::vector<SkolemLemma>& lems)
     // check for higher-order
     // logic exception if higher-order is not enabled
     if (isHigherOrderType(node.getOperator().getType())
-        && !getLogicInfo().isHigherOrder())
+        && !logicInfo().isHigherOrder())
     {
       std::stringstream ss;
       ss << "UF received an application whose operator has higher-order type "
@@ -256,8 +256,7 @@ void TheoryUF::preRegisterTerm(TNode node)
   }
 
   // we always use APPLY_UF if not higher-order, HO_APPLY if higher-order
-  Assert(node.getKind() != kind::HO_APPLY
-         || getLogicInfo().isHigherOrder());
+  Assert(node.getKind() != kind::HO_APPLY || logicInfo().isHigherOrder());
 
   Kind k = node.getKind();
   switch (k)
@@ -318,7 +317,7 @@ TrustNode TheoryUF::explain(TNode literal) { return d_im.explainLit(literal); }
 
 bool TheoryUF::collectModelValues(TheoryModel* m, const std::set<Node>& termSet)
 {
-  if (getLogicInfo().isHigherOrder())
+  if (logicInfo().isHigherOrder())
   {
     // must add extensionality disequalities for all pairs of (non-disequal)
     // function equivalence classes.