Some base infrastructure for user push/pop; a few bugfixes to user push/pop and model...
authorMorgan Deters <mdeters@gmail.com>
Thu, 29 Sep 2011 05:15:30 +0000 (05:15 +0000)
committerMorgan Deters <mdeters@gmail.com>
Thu, 29 Sep 2011 05:15:30 +0000 (05:15 +0000)
I also expect this commit to fix bug #273.

No performance change is expected on regressions with this commit, see
http://goedel.cims.nyu.edu/regress-results/compare_jobs.php?job_id=2871&reference_id=2863

31 files changed:
Makefile.am
Makefile.builds.in
src/context/cdmap.h
src/context/context.h
src/expr/expr_manager_template.cpp
src/main/interactive_shell.cpp
src/main/interactive_shell.h
src/prop/minisat/core/Solver.cc
src/smt/smt_engine.cpp
src/smt/smt_engine.h
src/theory/arith/theory_arith.cpp
src/theory/arith/theory_arith.h
src/theory/arrays/theory_arrays.cpp
src/theory/arrays/theory_arrays.h
src/theory/booleans/theory_bool.h
src/theory/builtin/theory_builtin.h
src/theory/bv/theory_bv.h
src/theory/datatypes/theory_datatypes.cpp
src/theory/datatypes/theory_datatypes.h
src/theory/example/theory_uf_tim.cpp
src/theory/example/theory_uf_tim.h
src/theory/substitutions.cpp
src/theory/substitutions.h
src/theory/theory.h
src/theory/theory_engine.cpp
src/theory/theory_engine.h
src/theory/uf/theory_uf.h
test/unit/prop/cnf_stream_black.h
test/unit/theory/theory_arith_white.h
test/unit/theory/theory_black.h
test/unit/theory/theory_engine_white.h

index f8538b548b4224a8a898eb565f4f06dba76d71b8..d2b11fe9c854bfcc575f2d225c6f57e38a394537 100644 (file)
@@ -12,7 +12,7 @@ systemtests regress regress0 regress1 regress2 regress3: all
        +(cd test && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1
 # We descend into "src" with the "check" target here to ensure that
 # the test prerequisites are all built.
-units: all
+units:
        (cd src && $(MAKE) $(AM_MAKEFLAGS) check)
        +(cd test && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1
 
index 44326f0ff6808678d28042743ee54f954280e4c7..7d2e8586b9bcbab182648795512d9f13a5a1a7e5 100644 (file)
@@ -127,7 +127,7 @@ endif
 check test units:
        (cd $(CURRENT_BUILD)/src && $(MAKE) check)
        +(cd $(CURRENT_BUILD)/test && $(MAKE) $@)
-systemtests regress:
+systemtests regress: all
        +(cd $(CURRENT_BUILD)/test && $(MAKE) $@)
 units%:
        (cd $(CURRENT_BUILD)/src && $(MAKE) check)
index 3ac99f72981c6bca0ba01c4dcb5fdbfad8a7176c..2a5365082211f312e6026022b5e3bf62fcb5efbe 100644 (file)
@@ -364,6 +364,10 @@ public:
     return d_map.size();
   }
 
+  bool empty() const {
+    return d_map.empty();
+  }
+
   size_t count(const Key& k) const {
     return d_map.count(k);
   }
index 1e69964a01a74233f7bad0b55e0b98fcf48d428b..78c06e7d5de15ed9ecf1d0f49aac3d27b5fb2028 100644 (file)
@@ -95,6 +95,10 @@ class Context {
   friend std::ostream&
   operator<<(std::ostream&, const Context&) throw(AssertionException);
 
+  // disable copy, assignment
+  Context(const Context&) CVC4_UNUSED;
+  Context& operator=(const Context&) CVC4_UNUSED;
+
 public:
   /**
    * Constructor: create ContextMemoryManager and initial Scope
@@ -153,6 +157,22 @@ public:
 
 };/* class Context */
 
+
+/**
+ * A UserContext is different from a Context only because it's used for
+ * different purposes---so separating the two types gives type errors where
+ * appropriate.
+ */
+class UserContext : public Context {
+private:
+  // disable copy, assignment
+  UserContext(const UserContext&) CVC4_UNUSED;
+  UserContext& operator=(const UserContext&) CVC4_UNUSED;
+public:
+  UserContext() {}
+};/* class UserContext */
+
+
 /**
  * Conceptually, a Scope encapsulates that portion of the context that
  * changes after a call to push() and must be undone on a subsequent call to
index f013c16441775f5f5a60c846a931025d1364de30..28f990c984f3b33c47067aeae3291c515c1bb5c3 100644 (file)
@@ -71,7 +71,7 @@ using namespace CVC4::kind;
 namespace CVC4 {
 
 ExprManager::ExprManager() :
-  d_ctxt(new Context),
+  d_ctxt(new Context()),
   d_nodeManager(new NodeManager(d_ctxt, this)) {
 #ifdef CVC4_STATISTICS_ON
   for (unsigned i = 0; i < kind::LAST_KIND; ++ i) {
@@ -84,7 +84,7 @@ ExprManager::ExprManager() :
 }
 
 ExprManager::ExprManager(const Options& options) :
-  d_ctxt(new Context),
+  d_ctxt(new Context()),
   d_nodeManager(new NodeManager(d_ctxt, this, options)) {
 #ifdef CVC4_STATISTICS_ON
   for (unsigned i = 0; i <= LAST_TYPE; ++ i) {
index 8f1d54a3ad48921706de01bb8a26c7ca793f09c6..1d1f447be6496d03fe6588a1f24b979403954c37 100644 (file)
@@ -18,6 +18,7 @@
  **/
 
 #include <iostream>
+#include <cstdlib>
 #include <vector>
 #include <string>
 #include <set>
@@ -92,23 +93,38 @@ InteractiveShell::InteractiveShell(ExprManager& exprManager,
   if(d_in == cin) {
     ::rl_readline_name = "CVC4";
     ::rl_completion_entry_function = commandGenerator;
+    ::using_history();
 
     switch(OutputLanguage lang = toOutputLanguage(d_language)) {
     case output::LANG_CVC4:
+      d_historyFilename = string(getenv("HOME")) + "/.cvc4_history";
       commandsBegin = cvc_commands;
       commandsEnd = cvc_commands + sizeof(cvc_commands) / sizeof(*cvc_commands);
       break;
     case output::LANG_SMTLIB:
+      d_historyFilename = string(getenv("HOME")) + "/.cvc4_history_smtlib";
       commandsBegin = smt_commands;
       commandsEnd = smt_commands + sizeof(smt_commands) / sizeof(*smt_commands);
       break;
     case output::LANG_SMTLIB_V2:
+      d_historyFilename = string(getenv("HOME")) + "/.cvc4_history_smtlib2";
       commandsBegin = smt2_commands;
       commandsEnd = smt2_commands + sizeof(smt2_commands) / sizeof(*smt2_commands);
       break;
     default: Unhandled(lang);
     }
     d_usingReadline = true;
+    int err = ::read_history(d_historyFilename.c_str());
+    ::stifle_history(s_historyLimit);
+    if(Notice.isOn()) {
+      if(err == 0) {
+        Notice() << "Read " << ::history_length << " lines of history from "
+                 << d_historyFilename << std::endl;
+      } else {
+        Notice() << "Could not read history from " << d_historyFilename
+                 << ": " << strerror(err) << std::endl;
+      }
+    }
   } else {
     d_usingReadline = false;
   }
@@ -117,6 +133,16 @@ InteractiveShell::InteractiveShell(ExprManager& exprManager,
 #endif /* HAVE_LIBREADLINE */
 }/* InteractiveShell::InteractiveShell() */
 
+InteractiveShell::~InteractiveShell() {
+  int err = ::write_history(d_historyFilename.c_str());
+  if(err == 0) {
+    Notice() << "Wrote " << ::history_length << " lines of history to "
+             << d_historyFilename << std::endl;
+  } else {
+    Notice() << "Could not write history to " << d_historyFilename
+             << ": " << strerror(err) << std::endl;
+  }
+}
 
 Command* InteractiveShell::readCommand() {
   /* Don't do anything if the input is closed or if we've seen a
index f6852b95b5a11207a51a55505c515d1f8dc78218..65fea849490a49ff1f5c15ec47972503838f29c0 100644 (file)
@@ -40,11 +40,19 @@ class CVC4_PUBLIC InteractiveShell {
   bool d_quit;
   bool d_usingReadline;
 
+  std::string d_historyFilename;
+
   static const std::string INPUT_FILENAME;
+  static const unsigned s_historyLimit = 500;
 
 public:
   InteractiveShell(ExprManager& exprManager, const Options& options);
 
+  /**
+   * Close out the interactive session.
+   */
+  ~InteractiveShell();
+
   /**
    * Read a command from the interactive shell. This will read as
    * many lines as necessary to parse a well-formed command.
index 77043348918a97c43b54d20b105fbf10bf57fa94..f3a85ed5e996c781d70d94a85a241159a0c44caa 100644 (file)
@@ -1100,7 +1100,7 @@ lbool Solver::solve_()
         ok = false;
 
     // Cancel the trail downto previous push
-    popTrail();
+    //popTrail();
 
     return status;
 }
index 24ebf9bfdf85346c9be96c3373c0db56cd55be58..86d06520add56fc408f5df92114640c39e96d260 100644 (file)
@@ -101,7 +101,7 @@ public:
 class SmtEnginePrivate {
   SmtEngine& d_smt;
 
-  /** The assertions yet to be preprecessed */
+  /** The assertions yet to be preprocessed */
   vector<Node> d_assertionsToPreprocess;
 
   /** Learned literals */
@@ -138,7 +138,10 @@ class SmtEnginePrivate {
 
 public:
 
-  SmtEnginePrivate(SmtEngine& smt) : d_smt(smt) { }
+  SmtEnginePrivate(SmtEngine& smt) :
+    d_smt(smt),
+    d_topLevelSubstitutions(smt.d_userContext) {
+  }
 
   Node applySubstitutions(TNode node) const {
     return Rewriter::rewrite(d_topLevelSubstitutions.apply(node));
@@ -172,7 +175,7 @@ using namespace CVC4::smt;
 
 SmtEngine::SmtEngine(ExprManager* em) throw(AssertionException) :
   d_context(em->getContext()),
-  d_userContext(new Context()),
+  d_userContext(new UserContext()),
   d_exprManager(em),
   d_nodeManager(d_exprManager->getNodeManager()),
   d_private(new smt::SmtEnginePrivate(*this)),
@@ -186,9 +189,9 @@ SmtEngine::SmtEngine(ExprManager* em) throw(AssertionException) :
   StatisticsRegistry::registerStat(&d_nonclausalSimplificationTime);
   StatisticsRegistry::registerStat(&d_staticLearningTime);
 
-  // We have mutual dependancy here, so we add the prop engine to the theory
+  // We have mutual dependency here, so we add the prop engine to the theory
   // engine later (it is non-essential there)
-  d_theoryEngine = new TheoryEngine(d_context);
+  d_theoryEngine = new TheoryEngine(d_context, d_userContext);
 
   // Add the theories
   d_theoryEngine->addTheory<theory::builtin::TheoryBuiltin>(theory::THEORY_BUILTIN);
@@ -927,8 +930,11 @@ Expr SmtEngine::getValue(const Expr& e)
     throw ModalException(msg);
   }
 
+  // Apply what was learned from preprocessing
+  Node n = d_private->applySubstitutions(e.getNode());
+
   // Normalize for the theories
-  Node n = theory::Rewriter::rewrite(e.getNode());
+  n = theory::Rewriter::rewrite(n);
 
   Trace("smt") << "--- getting value of " << n << endl;
   Node resultNode = d_theoryEngine->getValue(n);
index d2abf2fce1cdc9daefd01a0070cfc04fff5a2457..7a5f390568c6a6e135be4e21c612a4c88c37cb1e 100644 (file)
@@ -54,6 +54,7 @@ class StatisticsRegistry;
 
 namespace context {
   class Context;
+  class UserContext;
 }/* CVC4::context namespace */
 
 namespace prop {
@@ -99,7 +100,7 @@ class CVC4_PUBLIC SmtEngine {
   /** The context levels of user pushes */
   std::vector<int> d_userLevels;
   /** User level context */
-  context::Context* d_userContext;
+  context::UserContext* d_userContext;
 
   /** Our expression manager */
   ExprManager* d_exprManager;
index be8feb24567037a481b2265dd1326e17b1787d2f..c69960d373f565a52c277ded9de57b6dfae248a6 100644 (file)
@@ -59,8 +59,8 @@ static const uint32_t RESET_START = 2;
 struct SlackAttrID;
 typedef expr::Attribute<SlackAttrID, bool> Slack;
 
-TheoryArith::TheoryArith(context::Context* c, OutputChannel& out, Valuation valuation) :
-  Theory(THEORY_ARITH, c, out, valuation),
+TheoryArith::TheoryArith(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation) :
+  Theory(THEORY_ARITH, c, u, out, valuation),
   learner(d_pbSubstitutions),
   d_nextIntegerCheckVar(0),
   d_partialModel(c),
@@ -68,6 +68,7 @@ TheoryArith::TheoryArith(context::Context* c, OutputChannel& out, Valuation valu
   d_diseq(c),
   d_tableau(),
   d_diosolver(c, d_tableau, d_partialModel),
+  d_pbSubstitutions(u),
   d_restartsCounter(0),
   d_rowHasBeenAdded(false),
   d_tableauResetDensity(1.6),
index 6bcf6a6134f51634ee29094ff734175b0045032f..4731bea30f4deab26cae8d99339777f5eb913c8b 100644 (file)
@@ -163,7 +163,7 @@ private:
   SimplexDecisionProcedure d_simplex;
 
 public:
-  TheoryArith(context::Context* c, OutputChannel& out, Valuation valuation);
+  TheoryArith(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation);
   virtual ~TheoryArith();
 
   /**
index 0aff30d74e427cc6ea4e613b152beec4d87ada91..f82b6c6700e037e2b448f382d2cadd5de9fc617b 100644 (file)
@@ -32,8 +32,8 @@ using namespace CVC4::theory;
 using namespace CVC4::theory::arrays;
 
 
-TheoryArrays::TheoryArrays(Context* c, OutputChannel& out, Valuation valuation) :
-  Theory(THEORY_ARRAY, c, out, valuation),
+TheoryArrays::TheoryArrays(Context* c, UserContext* u, OutputChannel& out, Valuation valuation) :
+  Theory(THEORY_ARRAY, c, u, out, valuation),
   d_ccChannel(this),
   d_cc(c, &d_ccChannel),
   d_unionFind(c),
index a984cb342469606ceca994b8db46fd8a4d328df4..7fa215bfcf5c00012a7002b5fa27f757df2a11c5 100644 (file)
@@ -364,7 +364,7 @@ private:
   Node recursivePreprocessTerm(TNode term);
 
 public:
-  TheoryArrays(context::Context* c, OutputChannel& out, Valuation valuation);
+  TheoryArrays(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation);
   ~TheoryArrays();
 
   /**
index d53337fa7abbc0b472c352472644d92f05a7763a..bd4c8d56574f038b56695713f362bc5b2113b815 100644 (file)
@@ -30,8 +30,8 @@ namespace booleans {
 
 class TheoryBool : public Theory {
 public:
-  TheoryBool(context::Context* c, OutputChannel& out, Valuation valuation) :
-    Theory(THEORY_BOOL, c, out, valuation) {
+  TheoryBool(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation) :
+    Theory(THEORY_BOOL, c, u, out, valuation) {
   }
 
   Node getValue(TNode n);
index 5c3c7044378b746f1313bcf7041403739a11def5..f5a46b7992f31401734b49f2cd3a6dd0360379fb 100644 (file)
@@ -29,8 +29,8 @@ namespace builtin {
 
 class TheoryBuiltin : public Theory {
 public:
-  TheoryBuiltin(context::Context* c, OutputChannel& out, Valuation valuation) :
-    Theory(THEORY_BUILTIN, c, out, valuation) {}
+  TheoryBuiltin(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation) :
+    Theory(THEORY_BUILTIN, c, u, out, valuation) {}
   Node getValue(TNode n);
   std::string identify() const { return std::string("TheoryBuiltin"); }
 };/* class TheoryBuiltin */
index 8ab806bd87061a13238ee1eb779e90515c2cba7d..11ddceaae2e443a29a327dd20262d013d88c1718 100644 (file)
@@ -122,8 +122,8 @@ private:
 
 public:
 
-  TheoryBV(context::Context* c, OutputChannel& out, Valuation valuation)
-  : Theory(THEORY_BV, c, out, valuation), 
+  TheoryBV(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation)
+  : Theory(THEORY_BV, c, u, out, valuation), 
     d_eqEngine(*this, c, "theory::bv::EqualityEngine"), 
     d_sliceManager(*this, c), 
     d_context(c),
index 4e185febc374c53fb2942d369eb472c9e190997f..08b142fe3c1c43571639107d92e5eed3f9d66728 100644 (file)
@@ -53,8 +53,8 @@ Node TheoryDatatypes::getConstructorForSelector( Node sel )
 }
 
 
-TheoryDatatypes::TheoryDatatypes(Context* c, OutputChannel& out, Valuation valuation) :
-  Theory(THEORY_DATATYPES, c, out, valuation),
+TheoryDatatypes::TheoryDatatypes(Context* c, UserContext* u, OutputChannel& out, Valuation valuation) :
+  Theory(THEORY_DATATYPES, c, u, out, valuation),
   d_currAsserts(c),
   d_currEqualities(c),
   d_selectors(c),
index d91e9e7f42c4bf7af55517fa47d2e5ce3276d458..433af38c3bd92fda0f2400eb39190bf51bf83655 100644 (file)
@@ -140,7 +140,7 @@ private:
   CongruenceClosureExplainer<CongruenceChannel, CONGRUENCE_OPERATORS_2 (kind::APPLY_CONSTRUCTOR, kind::APPLY_SELECTOR)> d_cce;
 
 public:
-  TheoryDatatypes(context::Context* c, OutputChannel& out, Valuation valuation);
+  TheoryDatatypes(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation);
   ~TheoryDatatypes();
   void preRegisterTerm(TNode n);
   void presolve();
index ae37dfe9939de4bc03ffdc5e721cd2f2c643eeb1..03787703af439187d1e4f049b21ff4785f9625ed 100644 (file)
@@ -27,8 +27,8 @@ using namespace CVC4::theory;
 using namespace CVC4::theory::uf;
 using namespace CVC4::theory::uf::tim;
 
-TheoryUFTim::TheoryUFTim(Context* c, OutputChannel& out, Valuation valuation) :
-  TheoryUF(c, out, valuation),
+TheoryUFTim::TheoryUFTim(Context* c, UserContext* u, OutputChannel& out, Valuation valuation) :
+  Theory(THEORY_UF, c, u, out, valuation),
   d_assertions(c),
   d_pending(c),
   d_currentPendingIdx(c,0),
index 70c60728f618427dcd0b77c2fcd1b0274b244fc5..b47536f07c0b0fcc50d873a002dd0a5ad8a69204 100644 (file)
@@ -43,7 +43,7 @@ namespace theory {
 namespace uf {
 namespace tim {
 
-class TheoryUFTim : public TheoryUF {
+class TheoryUFTim : public Theory {
 
 private:
 
@@ -85,7 +85,7 @@ private:
 public:
 
   /** Constructs a new instance of TheoryUF w.r.t. the provided context.*/
-  TheoryUFTim(context::Context* c, OutputChannel& out, Valuation valuation);
+  TheoryUFTim(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation);
 
   /** Destructor for the TheoryUF object. */
   ~TheoryUFTim();
index 88e5b3dba3f1c420115e4bf6b317390b06874f5c..cdcf33f6a94a41f224e664d436ddc49f4d586f0b 100644 (file)
@@ -67,7 +67,7 @@ Node SubstitutionMap::internalSubstitute(TNode t, NodeMap& substitutionCache) {
       }
       for (unsigned i = 0; i < current.getNumChildren(); ++ i) {
         Assert(substitutionCache.find(current[i]) != substitutionCache.end());
-        builder << substitutionCache[current[i]];
+        builder << Node(substitutionCache[current[i]]);
       }
       // Mark the substitution and continue
       Node result = builder;
@@ -104,14 +104,14 @@ void SubstitutionMap::addSubstitution(TNode x, TNode t, bool invalidateCache) {
   Assert(d_substitutions.find(x) == d_substitutions.end());
 
   // Temporary substitution cache
-  NodeMap tempCache;
+  NodeMap tempCache(d_context);
   tempCache[x] = t;
 
   // Put in the new substitutions into the old ones
   NodeMap::iterator it = d_substitutions.begin();
   NodeMap::iterator it_end = d_substitutions.end();
   for(; it != it_end; ++ it) {
-    it->second = internalSubstitute(it->second, tempCache);
+    d_substitutions[(*it).first] = internalSubstitute((*it).second, tempCache);
   }
 
   // Put the new substitution in
@@ -123,11 +123,12 @@ void SubstitutionMap::addSubstitution(TNode x, TNode t, bool invalidateCache) {
   }
 }
 
-bool check(TNode node, const SubstitutionMap::NodeMap& substitutions) {
+static bool check(TNode node, const SubstitutionMap::NodeMap& substitutions) CVC4_UNUSED;
+static bool check(TNode node, const SubstitutionMap::NodeMap& substitutions) {
   SubstitutionMap::NodeMap::const_iterator it = substitutions.begin();
   SubstitutionMap::NodeMap::const_iterator it_end = substitutions.end();
   for (; it != it_end; ++ it) {
-    if (node.hasSubterm(it->first)) {
+    if (node.hasSubterm((*it).first)) {
       return false;
     }
   }
@@ -140,7 +141,12 @@ Node SubstitutionMap::apply(TNode t) {
 
   // Setup the cache
   if (d_cacheInvalidated) {
-    d_substitutionCache = d_substitutions;
+    SubstitutionMap::NodeMap::const_iterator it = d_substitutions.begin();
+    SubstitutionMap::NodeMap::const_iterator it_end = d_substitutions.end();
+    d_substitutionCache.clear();
+    for (; it != it_end; ++ it) {
+      d_substitutionCache[(*it).first] = (*it).second;
+    }
     d_cacheInvalidated = false;
   }
 
@@ -157,7 +163,7 @@ void SubstitutionMap::print(ostream& out) const {
   NodeMap::const_iterator it = d_substitutions.begin();
   NodeMap::const_iterator it_end = d_substitutions.end();
   for (; it != it_end; ++ it) {
-    out << it->first << " -> " << it->second << endl;
+    out << (*it).first << " -> " << (*it).second << endl;
   }
 }
 
index 849c8f166f931e48983a929ec7fce62a8f9643f4..2535076459b21da2e39ff8a7c98471f7a7515efa 100644 (file)
 #include <utility>
 #include <vector>
 #include <algorithm>
+
 #include "expr/node.h"
+#include "context/context.h"
+#include "context/cdo.h"
+#include "context/cdmap.h"
 
 namespace CVC4 {
 namespace theory {
@@ -32,17 +36,22 @@ namespace theory {
 /**
  * The type for the Substitutions mapping output by
  * Theory::simplify(), TheoryEngine::simplify(), and
- * Valuation::simplify().  This is in its own header to avoid circular
- * dependences between those three.
+ * Valuation::simplify().  This is in its own header to
+ * avoid circular dependences between those three.
+ *
+ * This map is context-dependent.
  */
 class SubstitutionMap {
 
 public:
 
-  typedef std::hash_map<Node, Node, NodeHashFunction> NodeMap;
+  typedef context::CDMap<Node, Node, NodeHashFunction> NodeMap;
 
 private:
 
+  /** The context within which this SubstitutionMap was constructed. */
+  context::Context* d_context;
+
   /** The variables, in order of addition */
   NodeMap d_substitutions;
 
@@ -50,14 +59,19 @@ private:
   NodeMap d_substitutionCache;
 
   /** Has the cache been invalidated */
-  bool d_cacheInvalidated;
+  context::CDO<bool> d_cacheInvalidated;
 
-  /** Internaal method that performs substitution */
+  /** Internal method that performs substitution */
   Node internalSubstitute(TNode t, NodeMap& substitutionCache);
 
 public:
 
-  SubstitutionMap(): d_cacheInvalidated(true) {}
+  SubstitutionMap(context::Context* context) :
+    d_context(context),
+    d_substitutions(context),
+    d_substitutionCache(context),
+    d_cacheInvalidated(context) {
+  }
 
   /**
    * Adds a substitution from x to t
@@ -77,24 +91,11 @@ public:
     return const_cast<SubstitutionMap*>(this)->apply(t);
   }
 
-  /**
-   * Clear out the accumulated substitutions, resetting this
-   * SubstitutionMap to the way it was when first constructed.
-   */
-  void clear() {
-    d_substitutions.clear();
-    d_substitutionCache.clear();
-    d_cacheInvalidated = true;
-  }
-
-  /**
-   * Swap the contents of this SubstitutionMap with those of another.
-   */
-  void swap(SubstitutionMap& map) {
-    d_substitutions.swap(map.d_substitutions);
-    d_substitutionCache.swap(map.d_substitutionCache);
-    std::swap(d_cacheInvalidated, map.d_cacheInvalidated);
-  }
+  // NOTE [MGD]: removed clear() and swap() from the interface
+  // when this data structure became context-dependent
+  // because they weren't used---and it's not clear how they
+  // should // best interact with cache invalidation on context
+  // pops.
 
   /**
    * Print to the output stream
index 931b1155ea7b03fd5ad93c0d30011c172b25d7c7..17c9ef14aed98a6f7d100424707bd747eda738ad 100644 (file)
@@ -102,6 +102,11 @@ private:
    */
   context::Context* d_context;
 
+  /**
+   * The user context for the Theory.
+   */
+  context::UserContext* d_userContext;
+
   /**
    * The assertFact() queue.
    *
@@ -133,13 +138,15 @@ protected:
   /**
    * Construct a Theory.
    */
-  Theory(TheoryId id, context::Context* ctxt, OutputChannel& out, Valuation valuation) throw() :
+  Theory(TheoryId id, context::Context* context, context::UserContext* userContext,
+         OutputChannel& out, Valuation valuation) throw() :
     d_id(id),
-    d_context(ctxt),
-    d_facts(ctxt),
-    d_factsHead(ctxt, 0),
-    d_sharedTermsIndex(ctxt, 0),
-    d_sharedTerms(ctxt),
+    d_context(context),
+    d_userContext(userContext),
+    d_facts(context),
+    d_factsHead(context, 0),
+    d_sharedTermsIndex(context, 0),
+    d_sharedTerms(context),
     d_out(&out),
     d_valuation(valuation)
   {
@@ -327,6 +334,13 @@ public:
     return d_context;
   }
 
+  /**
+   * Get the context associated to this Theory.
+   */
+  context::UserContext* getUserContext() const {
+    return d_userContext;
+  }
+
   /**
    * Set the output channel associated to this theory.
    */
index 5bb71532c9c809911de2ee3cf3ef407fe11847c0..93df4fe38062975411f612dfc9e11f9eec0bab8b 100644 (file)
@@ -37,22 +37,24 @@ using namespace std;
 using namespace CVC4;
 using namespace CVC4::theory;
 
-TheoryEngine::TheoryEngine(context::Context* ctxt)
+TheoryEngine::TheoryEngine(context::Context* context,
+                           context::UserContext* userContext)
 : d_propEngine(NULL),
-  d_context(ctxt),
+  d_context(context),
+  d_userContext(userContext),
   d_activeTheories(0),
-  d_sharedTerms(ctxt),
+  d_sharedTerms(context),
   d_atomPreprocessingCache(),
   d_possiblePropagations(),
-  d_hasPropagated(ctxt),
-  d_inConflict(ctxt, false),
+  d_hasPropagated(context),
+  d_inConflict(context, false),
   d_hasShutDown(false),
-  d_incomplete(ctxt, false),
-  d_sharedAssertions(ctxt),
+  d_incomplete(context, false),
+  d_sharedAssertions(context),
   d_logic(""),
-  d_propagatedLiterals(ctxt),
-  d_propagatedLiteralsIndex(ctxt, 0),
-  d_preRegistrationVisitor(this, ctxt),
+  d_propagatedLiterals(context),
+  d_propagatedLiteralsIndex(context, 0),
+  d_preRegistrationVisitor(this, context),
   d_sharedTermsVisitor(d_sharedTerms)
 {
   for(TheoryId theoryId = theory::THEORY_FIRST; theoryId != theory::THEORY_LAST; ++ theoryId) {
@@ -378,10 +380,10 @@ void TheoryEngine::shutdown() {
   theory::Rewriter::shutdown();
 }
 
-theory::Theory::SolveStatus TheoryEngine::solve(TNode literal, SubstitutionMap& substitionOut) {
+theory::Theory::SolveStatus TheoryEngine::solve(TNode literal, SubstitutionMap& substitutionOut) {
   TNode atom = literal.getKind() == kind::NOT ? literal[0] : literal;
   Trace("theory") << "TheoryEngine::solve(" << literal << "): solving with " << theoryOf(atom)->getId() << endl;
-  Theory::SolveStatus solveStatus = theoryOf(atom)->solve(literal, substitionOut);
+  Theory::SolveStatus solveStatus = theoryOf(atom)->solve(literal, substitutionOut);
   Trace("theory") << "TheoryEngine::solve(" << literal << ") => " << solveStatus << endl;
   return solveStatus;
 }
index 04f15e89f34be06c7dac877a9b0492ba66765863..915373074fe21dfbf2af9a19f36bfc9ed443f52f 100644 (file)
@@ -80,6 +80,9 @@ class TheoryEngine {
   /** Our context */
   context::Context* d_context;
 
+  /** Our user context */
+  context::UserContext* d_userContext;
+
   /**
    * A table of from theory IDs to theory pointers. Never use this table
    * directly, use theoryOf() instead.
@@ -343,7 +346,7 @@ class TheoryEngine {
 public:
 
   /** Constructs a theory engine */
-  TheoryEngine(context::Context* ctxt);
+  TheoryEngine(context::Context* context, context::UserContext* userContext);
 
   /** Destroys a theory engine */
   ~TheoryEngine();
@@ -356,7 +359,7 @@ public:
   inline void addTheory(theory::TheoryId theoryId) {
     Assert(d_theoryTable[theoryId] == NULL && d_theoryOut[theoryId] == NULL);
     d_theoryOut[theoryId] = new EngineOutputChannel(this, theoryId);
-    d_theoryTable[theoryId] = new TheoryClass(d_context, *d_theoryOut[theoryId], theory::Valuation(this));
+    d_theoryTable[theoryId] = new TheoryClass(d_context, d_userContext, *d_theoryOut[theoryId], theory::Valuation(this));
   }
 
   /**
@@ -407,7 +410,8 @@ public:
   /**
    * Solve the given literal with a theory that owns it.
    */
-  theory::Theory::SolveStatus solve(TNode literal, theory::SubstitutionMap& substitionOut);
+  theory::Theory::SolveStatus solve(TNode literal,
+                                    theory::SubstitutionMap& substitutionOut);
 
   /**
    * Preregister a Theory atom with the responsible theory (or
index 6cea8b85b6de379b8ce011017e491e2d1e424662..f8e17b1de6be10f26e18695eeb7d8dc0a3153689 100644 (file)
@@ -97,14 +97,14 @@ private:
 public:
 
   /** Constructs a new instance of TheoryUF w.r.t. the provided context.*/
-  TheoryUF(context::Context* ctxt, OutputChannel& out, Valuation valuation):
-    Theory(THEORY_UF, ctxt, out, valuation),
+  TheoryUF(context::Context* c, context::UserContext* u, OutputChannel& out, Valuation valuation):
+    Theory(THEORY_UF, c, u, out, valuation),
     d_notify(*this),
-    d_equalityEngine(d_notify, ctxt, "theory::uf::TheoryUF"),
-    d_knownFacts(ctxt),
-    d_conflict(ctxt, false),
-    d_literalsToPropagate(ctxt),
-    d_literalsToPropagateIndex(ctxt, 0)
+    d_equalityEngine(d_notify, c, "theory::uf::TheoryUF"),
+    d_knownFacts(c),
+    d_conflict(c, false),
+    d_literalsToPropagate(c),
+    d_literalsToPropagateIndex(c, 0)
   {
     // The kinds we are treating as function application in congruence
     d_equalityEngine.addFunctionKind(kind::APPLY_UF);
index c9a2196a561f8fc4433b971295df7938f19b4aa6..62117d4c18bf481b237c87097d855da910dc33d9 100644 (file)
@@ -99,154 +99,159 @@ class CnfStreamBlack : public CxxTest::TestSuite {
   /** The context */
   Context* d_context;
 
+  /** The user context */
+  UserContext* d_userContext;
+
   /** The node manager */
   NodeManager* d_nodeManager;
 
-void setUp() {
-  d_context = new Context;
-  d_nodeManager = new NodeManager(d_context, NULL);
-  NodeManagerScope nms(d_nodeManager);
-  d_satSolver = new FakeSatSolver;
-  d_theoryEngine = new TheoryEngine(d_context);
-  d_theoryEngine->addTheory<theory::builtin::TheoryBuiltin>(theory::THEORY_BUILTIN);
-  d_theoryEngine->addTheory<theory::booleans::TheoryBool>(theory::THEORY_BOOL);
-  d_theoryEngine->addTheory<theory::arith::TheoryArith>(theory::THEORY_ARITH);
-  theory::Registrar registrar(d_theoryEngine);
-  d_cnfStream = new CVC4::prop::TseitinCnfStream(d_satSolver, registrar);
-}
-
-void tearDown() {
-  NodeManagerScope nms(d_nodeManager);
-  delete d_cnfStream;
-  d_theoryEngine->shutdown();
-  delete d_theoryEngine;
-  delete d_satSolver;
-  delete d_nodeManager;
-  delete d_context;
-}
+  void setUp() {
+    d_context = new Context();
+    d_userContext = new UserContext();
+    d_nodeManager = new NodeManager(d_context, NULL);
+    NodeManagerScope nms(d_nodeManager);
+    d_satSolver = new FakeSatSolver();
+    d_theoryEngine = new TheoryEngine(d_context, d_userContext);
+    d_theoryEngine->addTheory<theory::builtin::TheoryBuiltin>(theory::THEORY_BUILTIN);
+    d_theoryEngine->addTheory<theory::booleans::TheoryBool>(theory::THEORY_BOOL);
+    d_theoryEngine->addTheory<theory::arith::TheoryArith>(theory::THEORY_ARITH);
+    theory::Registrar registrar(d_theoryEngine);
+    d_cnfStream = new CVC4::prop::TseitinCnfStream(d_satSolver, registrar);
+  }
+
+  void tearDown() {
+    NodeManagerScope nms(d_nodeManager);
+    delete d_cnfStream;
+    d_theoryEngine->shutdown();
+    delete d_theoryEngine;
+    delete d_satSolver;
+    delete d_nodeManager;
+    delete d_userContext;
+    delete d_context;
+  }
 
 public:
 
-/* [chris 5/26/2010] In the tests below, we don't attempt to delve into the
- * deep structure of the CNF conversion. Firstly, we just want to make sure
- * that the conversion doesn't choke on any boolean Exprs. We'll also check
- * that addClause got called. We won't check that it gets called a particular
- * number of times, or with what.
- */
-
-void testAnd() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node c = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(
-      d_nodeManager->mkNode(kind::AND, a, b, c), false, false);
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testComplexExpr() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node c = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node d = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node e = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node f = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(
-      d_nodeManager->mkNode(
-          kind::IMPLIES,
-          d_nodeManager->mkNode(kind::AND, a, b),
-          d_nodeManager->mkNode(
-              kind::IFF,
-              d_nodeManager->mkNode(kind::OR, c, d),
-              d_nodeManager->mkNode(
-                  kind::NOT,
-                  d_nodeManager->mkNode(kind::XOR, e, f)))), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testFalse() {
-  NodeManagerScope nms(d_nodeManager);
-  d_cnfStream->convertAndAssert( d_nodeManager->mkConst(false), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testIff() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(
-      d_nodeManager->mkNode(kind::IFF, a, b), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testImplies() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(
-      d_nodeManager->mkNode(kind::IMPLIES, a, b), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-// ITEs should be removed before going to CNF
-//void testIte() {
-//  NodeManagerScope nms(d_nodeManager);
-//  d_cnfStream->convertAndAssert(
-//      d_nodeManager->mkNode(
-//          kind::EQUAL,
-//          d_nodeManager->mkNode(
-//              kind::ITE,
-//              d_nodeManager->mkVar(d_nodeManager->booleanType()),
-//              d_nodeManager->mkVar(d_nodeManager->integerType()),
-//              d_nodeManager->mkVar(d_nodeManager->integerType())
-//          ),
-//          d_nodeManager->mkVar(d_nodeManager->integerType())
-//                            ), false, false);
-//
-//}
-
-void testNot() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(
-      d_nodeManager->mkNode(kind::NOT, a), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testOr() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node c = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(
-      d_nodeManager->mkNode(kind::OR, a, b, c), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testTrue() {
-  NodeManagerScope nms(d_nodeManager);
-  d_cnfStream->convertAndAssert( d_nodeManager->mkConst(true), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testVar() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(a, false, false);
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-  d_satSolver->reset();
-  d_cnfStream->convertAndAssert(b, false, false);
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
-
-void testXor() {
-  NodeManagerScope nms(d_nodeManager);
-  Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
-  d_cnfStream->convertAndAssert(
-      d_nodeManager->mkNode(kind::XOR, a, b), false, false );
-  TS_ASSERT( d_satSolver->addClauseCalled() );
-}
+  /* [chris 5/26/2010] In the tests below, we don't attempt to delve into the
  * deep structure of the CNF conversion. Firstly, we just want to make sure
  * that the conversion doesn't choke on any boolean Exprs. We'll also check
  * that addClause got called. We won't check that it gets called a particular
  * number of times, or with what.
  */
+
+  void testAnd() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node c = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(
+                                  d_nodeManager->mkNode(kind::AND, a, b, c), false, false);
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testComplexExpr() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node c = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node d = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node e = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node f = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(
+                                  d_nodeManager->mkNode(
+                                                        kind::IMPLIES,
+                                                        d_nodeManager->mkNode(kind::AND, a, b),
+                                                        d_nodeManager->mkNode(
+                                                                              kind::IFF,
+                                                                              d_nodeManager->mkNode(kind::OR, c, d),
+                                                                              d_nodeManager->mkNode(
+                                                                                                    kind::NOT,
+                                                                                                    d_nodeManager->mkNode(kind::XOR, e, f)))), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testFalse() {
+    NodeManagerScope nms(d_nodeManager);
+    d_cnfStream->convertAndAssert( d_nodeManager->mkConst(false), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testIff() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(
+                                  d_nodeManager->mkNode(kind::IFF, a, b), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testImplies() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(
+                                  d_nodeManager->mkNode(kind::IMPLIES, a, b), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  // ITEs should be removed before going to CNF
+  //void testIte() {
+  //  NodeManagerScope nms(d_nodeManager);
+  //  d_cnfStream->convertAndAssert(
+  //      d_nodeManager->mkNode(
+  //          kind::EQUAL,
+  //          d_nodeManager->mkNode(
+  //              kind::ITE,
+  //              d_nodeManager->mkVar(d_nodeManager->booleanType()),
+  //              d_nodeManager->mkVar(d_nodeManager->integerType()),
+  //              d_nodeManager->mkVar(d_nodeManager->integerType())
+  //          ),
+  //          d_nodeManager->mkVar(d_nodeManager->integerType())
+  //                            ), false, false);
+  //
+  //}
+
+  void testNot() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(
+                                  d_nodeManager->mkNode(kind::NOT, a), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testOr() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node c = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(
+                                  d_nodeManager->mkNode(kind::OR, a, b, c), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testTrue() {
+    NodeManagerScope nms(d_nodeManager);
+    d_cnfStream->convertAndAssert( d_nodeManager->mkConst(true), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testVar() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(a, false, false);
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+    d_satSolver->reset();
+    d_cnfStream->convertAndAssert(b, false, false);
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
+
+  void testXor() {
+    NodeManagerScope nms(d_nodeManager);
+    Node a = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    Node b = d_nodeManager->mkVar(d_nodeManager->booleanType());
+    d_cnfStream->convertAndAssert(
+                                  d_nodeManager->mkNode(kind::XOR, a, b), false, false );
+    TS_ASSERT( d_satSolver->addClauseCalled() );
+  }
 };
index ded7cee9727890bb49d54c6eadb3b18a7f5c0b4c..f0073cc0b1b66842f36a191e69f0c18054715387 100644 (file)
@@ -43,6 +43,7 @@ using namespace std;
 class TheoryArithWhite : public CxxTest::TestSuite {
 
   Context* d_ctxt;
+  UserContext* d_uctxt;
   NodeManager* d_nm;
   NodeManagerScope* d_scope;
 
@@ -92,11 +93,12 @@ public:
   }
 
   void setUp() {
-    d_ctxt = new Context;
+    d_ctxt = new Context();
+    d_uctxt = new UserContext();
     d_nm = new NodeManager(d_ctxt, NULL);
     d_scope = new NodeManagerScope(d_nm);
     d_outputChannel.clear();
-    d_arith = new TheoryArith(d_ctxt, d_outputChannel, Valuation(NULL));
+    d_arith = new TheoryArith(d_ctxt, d_uctxt, d_outputChannel, Valuation(NULL));
 
     preregistered = new std::set<Node>();
 
@@ -115,6 +117,7 @@ public:
     d_outputChannel.clear();
     delete d_scope;
     delete d_nm;
+    delete d_uctxt;
     delete d_ctxt;
   }
 
index 2c3ff0bb1ee8d7519476047e53b1eab7ee60a6f9..63900c19c49160a694a756fbe1f5573e4e6d5f8c 100644 (file)
@@ -95,8 +95,8 @@ public:
   set<Node> d_registered;
   vector<Node> d_getSequence;
 
-  DummyTheory(Context* ctxt, OutputChannel& out, Valuation valuation) :
-    Theory(theory::THEORY_BUILTIN, ctxt, out, valuation) {
+  DummyTheory(Context* ctxt, UserContext* uctxt, OutputChannel& out, Valuation valuation) :
+    Theory(theory::THEORY_BUILTIN, ctxt, uctxt, out, valuation) {
   }
 
   void registerTerm(TNode n) {
@@ -135,11 +135,12 @@ public:
   void explain(TNode n, Effort level) {}
   Node getValue(TNode n) { return Node::null(); }
   string identify() const { return "DummyTheory"; }
-};
+};/* class DummyTheory */
 
 class TheoryBlack : public CxxTest::TestSuite {
 
   Context* d_ctxt;
+  UserContext* d_uctxt;
   NodeManager* d_nm;
   NodeManagerScope* d_scope;
 
@@ -153,10 +154,11 @@ class TheoryBlack : public CxxTest::TestSuite {
 public:
 
   void setUp() {
-    d_ctxt = new Context;
+    d_ctxt = new Context();
+    d_uctxt = new UserContext();
     d_nm = new NodeManager(d_ctxt, NULL);
     d_scope = new NodeManagerScope(d_nm);
-    d_dummy = new DummyTheory(d_ctxt, d_outputChannel, Valuation(NULL));
+    d_dummy = new DummyTheory(d_ctxt, d_uctxt, d_outputChannel, Valuation(NULL));
     d_outputChannel.clear();
     atom0 = d_nm->mkConst(true);
     atom1 = d_nm->mkConst(false);
@@ -168,6 +170,7 @@ public:
     delete d_dummy;
     delete d_scope;
     delete d_nm;
+    delete d_uctxt;
     delete d_ctxt;
   }
 
index e33efb5978afe76aade7ed1a4413bfd1c49cc03d..7132d9b17224e88784d25afb412b03842a14146f 100644 (file)
@@ -104,8 +104,8 @@ class FakeTheory : public Theory {
   // static std::deque<RewriteItem> s_expected;
 
 public:
-  FakeTheory(context::Context* ctxt, OutputChannel& out, Valuation valuation) :
-    Theory(theoryId, ctxt, out, valuation)
+  FakeTheory(context::Context* ctxt, context::UserContext* uctxt, OutputChannel& out, Valuation valuation) :
+    Theory(theoryId, ctxt, uctxt, out, valuation)
   { }
 
   /** Register an expected rewrite call */
@@ -222,6 +222,7 @@ public:
  */
 class TheoryEngineWhite : public CxxTest::TestSuite {
   Context* d_ctxt;
+  UserContext* d_uctxt;
 
   NodeManager* d_nm;
   NodeManagerScope* d_scope;
@@ -231,15 +232,16 @@ class TheoryEngineWhite : public CxxTest::TestSuite {
 public:
 
   void setUp() {
-    d_ctxt = new Context;
+    d_ctxt = new Context();
+    d_uctxt = new UserContext();
 
     d_nm = new NodeManager(d_ctxt, NULL);
     d_scope = new NodeManagerScope(d_nm);
 
-    d_nullChannel = new FakeOutputChannel;
+    d_nullChannel = new FakeOutputChannel();
 
     // create the TheoryEngine
-    d_theoryEngine = new TheoryEngine(d_ctxt);
+    d_theoryEngine = new TheoryEngine(d_ctxt, d_uctxt);
 
     d_theoryEngine->addTheory< FakeTheory<THEORY_BUILTIN> >(THEORY_BUILTIN);
     d_theoryEngine->addTheory< FakeTheory<THEORY_BOOL> >(THEORY_BOOL);
@@ -260,6 +262,7 @@ public:
     delete d_scope;
     delete d_nm;
 
+    delete d_uctxt;
     delete d_ctxt;
   }