Merge from theory-break-dependences branch to break Theory and TheoryEngine dependenc...
authorMorgan Deters <mdeters@gmail.com>
Sat, 26 Feb 2011 21:24:18 +0000 (21:24 +0000)
committerMorgan Deters <mdeters@gmail.com>
Sat, 26 Feb 2011 21:24:18 +0000 (21:24 +0000)
21 files changed:
src/theory/Makefile.am
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.cpp
src/theory/booleans/theory_bool.h
src/theory/builtin/theory_builtin.cpp
src/theory/builtin/theory_builtin.h
src/theory/bv/theory_bv.cpp
src/theory/bv/theory_bv.h
src/theory/theory.h
src/theory/theory_engine.cpp
src/theory/theory_engine.h
src/theory/uf/morgan/theory_uf_morgan.cpp
src/theory/uf/morgan/theory_uf_morgan.h
src/theory/uf/tim/theory_uf_tim.h
src/theory/valuation.cpp [new file with mode: 0644]
src/theory/valuation.h [new file with mode: 0644]
test/unit/theory/theory_black.h
test/unit/theory/theory_engine_white.h

index acf0ed5ee3d5ab18feff8889004353b7fb686d94..142aef0048d6c362a8f5872500e397c3844bb1a1 100644 (file)
@@ -21,7 +21,10 @@ libtheory_la_SOURCES = \
        shared_data.cpp \
        rewriter.h \
        rewriter_attributes.h \
-       rewriter.cpp 
+       rewriter.cpp \
+       valuation.h \
+       valuation.cpp
+
 nodist_libtheory_la_SOURCES = \
        rewriter_tables.h \
        theory_traits.h
@@ -47,7 +50,7 @@ BUILT_SOURCES = \
 
 CLEANFILES = \
        rewriter_tables.h \
-       theory_traits.h 
+       theory_traits.h
 
 include @top_srcdir@/src/theory/Makefile.subdirs
 
@@ -66,4 +69,3 @@ theory_traits.h: theory_traits_template.h mktheorytraits @top_builddir@/src/theo
                $< \
                `cat @top_builddir@/src/theory/.subdirs` \
        > $@) || (rm -f $@ && exit 1)
-       
\ No newline at end of file
index 6084e346374d6a5a83dbf85432cc9e19950752e8..2100e0b385c6b63d298708afa7d8d6fda05e1734 100644 (file)
@@ -22,7 +22,7 @@
 #include "expr/metakind.h"
 #include "expr/node_builder.h"
 
-#include "theory/theory_engine.h"
+#include "theory/valuation.h"
 
 #include "util/rational.h"
 #include "util/integer.h"
@@ -567,7 +567,7 @@ void TheoryArith::propagate(Effort e) {
   // }
 }
 
-Node TheoryArith::getValue(TNode n, TheoryEngine* engine) {
+Node TheoryArith::getValue(TNode n, Valuation* valuation) {
   NodeManager* nodeManager = NodeManager::currentNM();
 
   switch(n.getKind()) {
@@ -578,7 +578,7 @@ Node TheoryArith::getValue(TNode n, TheoryEngine* engine) {
       Node eq = d_removedRows.find(var)->second;
       Assert(n == eq[0]);
       Node rhs = eq[1];
-      return getValue(rhs, engine);
+      return getValue(rhs, valuation);
     }
 
     DeltaRational drat = d_partialModel.getAssignment(var);
@@ -591,7 +591,7 @@ Node TheoryArith::getValue(TNode n, TheoryEngine* engine) {
 
   case kind::EQUAL: // 2 args
     return nodeManager->
-      mkConst( engine->getValue(n[0]) == engine->getValue(n[1]) );
+      mkConst( valuation->getValue(n[0]) == valuation->getValue(n[1]) );
 
   case kind::PLUS: { // 2+ args
     Rational value = d_constants.d_ZERO;
@@ -599,7 +599,7 @@ Node TheoryArith::getValue(TNode n, TheoryEngine* engine) {
             iend = n.end();
           i != iend;
           ++i) {
-      value += engine->getValue(*i).getConst<Rational>();
+      value += valuation->getValue(*i).getConst<Rational>();
     }
     return nodeManager->mkConst(value);
   }
@@ -610,7 +610,7 @@ Node TheoryArith::getValue(TNode n, TheoryEngine* engine) {
             iend = n.end();
           i != iend;
           ++i) {
-      value *= engine->getValue(*i).getConst<Rational>();
+      value *= valuation->getValue(*i).getConst<Rational>();
     }
     return nodeManager->mkConst(value);
   }
@@ -624,24 +624,24 @@ Node TheoryArith::getValue(TNode n, TheoryEngine* engine) {
     Unreachable();
 
   case kind::DIVISION: // 2 args
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<Rational>() /
-                                 engine->getValue(n[1]).getConst<Rational>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<Rational>() /
+                                 valuation->getValue(n[1]).getConst<Rational>() );
 
   case kind::LT: // 2 args
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<Rational>() <
-                                 engine->getValue(n[1]).getConst<Rational>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<Rational>() <
+                                 valuation->getValue(n[1]).getConst<Rational>() );
 
   case kind::LEQ: // 2 args
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<Rational>() <=
-                                 engine->getValue(n[1]).getConst<Rational>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<Rational>() <=
+                                 valuation->getValue(n[1]).getConst<Rational>() );
 
   case kind::GT: // 2 args
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<Rational>() >
-                                 engine->getValue(n[1]).getConst<Rational>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<Rational>() >
+                                 valuation->getValue(n[1]).getConst<Rational>() );
 
   case kind::GEQ: // 2 args
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<Rational>() >=
-                                 engine->getValue(n[1]).getConst<Rational>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<Rational>() >=
+                                 valuation->getValue(n[1]).getConst<Rational>() );
 
   default:
     Unhandled(n.getKind());
index 60d24708c0d5d8a22dfcc341ac85f414de535838..e29054c16101791f37de53ec6049f5f4499e5ba0 100644 (file)
@@ -152,7 +152,7 @@ public:
 
   void notifyEq(TNode lhs, TNode rhs);
 
-  Node getValue(TNode n, TheoryEngine* engine);
+  Node getValue(TNode n, Valuation* valuation);
 
   void shutdown(){ }
 
index ad7550a6c9e5e7f92c9599ae3620235ff56aee9e..d45320266948126c1bd03e9064ed2ca135011f44 100644 (file)
@@ -18,7 +18,7 @@
 
 
 #include "theory/arrays/theory_arrays.h"
-#include "theory/theory_engine.h"
+#include "theory/valuation.h"
 #include "expr/kind.h"
 
 
@@ -60,7 +60,7 @@ void TheoryArrays::check(Effort e) {
   Debug("arrays") << "TheoryArrays::check(): done" << endl;
 }
 
-Node TheoryArrays::getValue(TNode n, TheoryEngine* engine) {
+Node TheoryArrays::getValue(TNode n, Valuation* valuation) {
   NodeManager* nodeManager = NodeManager::currentNM();
 
   switch(n.getKind()) {
@@ -70,7 +70,7 @@ Node TheoryArrays::getValue(TNode n, TheoryEngine* engine) {
 
   case kind::EQUAL: // 2 args
     return nodeManager->
-      mkConst( engine->getValue(n[0]) == engine->getValue(n[1]) );
+      mkConst( valuation->getValue(n[0]) == valuation->getValue(n[1]) );
 
   default:
     Unhandled(n.getKind());
index d3472f9520ab9841dc9708f51f42e5ab560ae2a5..5a63fd26c364a530692d1ea0536ce89ec6405d11 100644 (file)
@@ -43,7 +43,7 @@ public:
   void check(Effort e);
   void propagate(Effort e) { }
   void explain(TNode n) { }
-  Node getValue(TNode n, TheoryEngine* engine);
+  Node getValue(TNode n, Valuation* valuation);
   void shutdown() { }
   std::string identify() const { return std::string("TheoryArrays"); }
 };/* class TheoryArrays */
index f8071d45dedfe5a9b5adac2b116bd76bd6a3a11c..44f5d60a62f673536c9af9987836d84cb309ef7a 100644 (file)
 
 #include "theory/theory.h"
 #include "theory/booleans/theory_bool.h"
-#include "theory/theory_engine.h"
+#include "theory/valuation.h"
 
 namespace CVC4 {
 namespace theory {
 namespace booleans {
 
-Node TheoryBool::getValue(TNode n, TheoryEngine* engine) {
+Node TheoryBool::getValue(TNode n, Valuation* valuation) {
   NodeManager* nodeManager = NodeManager::currentNM();
 
   switch(n.getKind()) {
@@ -38,14 +38,14 @@ Node TheoryBool::getValue(TNode n, TheoryEngine* engine) {
     Unreachable();
 
   case kind::NOT: // 1 arg
-    return nodeManager->mkConst(! engine->getValue(n[0]).getConst<bool>());
+    return nodeManager->mkConst(! valuation->getValue(n[0]).getConst<bool>());
 
   case kind::AND: { // 2+ args
     for(TNode::iterator i = n.begin(),
             iend = n.end();
           i != iend;
           ++i) {
-      if(! engine->getValue(*i).getConst<bool>()) {
+      if(! valuation->getValue(*i).getConst<bool>()) {
         return nodeManager->mkConst(false);
       }
     }
@@ -53,19 +53,19 @@ Node TheoryBool::getValue(TNode n, TheoryEngine* engine) {
   }
 
   case kind::IFF: // 2 args
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<bool>() ==
-                                 engine->getValue(n[1]).getConst<bool>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<bool>() ==
+                                 valuation->getValue(n[1]).getConst<bool>() );
 
   case kind::IMPLIES: // 2 args
-    return nodeManager->mkConst( (! engine->getValue(n[0]).getConst<bool>()) ||
-                                 engine->getValue(n[1]).getConst<bool>() );
+    return nodeManager->mkConst( (! valuation->getValue(n[0]).getConst<bool>()) ||
+                                 valuation->getValue(n[1]).getConst<bool>() );
 
   case kind::OR: { // 2+ args
     for(TNode::iterator i = n.begin(),
             iend = n.end();
           i != iend;
           ++i) {
-      if(engine->getValue(*i).getConst<bool>()) {
+      if(valuation->getValue(*i).getConst<bool>()) {
         return nodeManager->mkConst(true);
       }
     }
@@ -73,16 +73,16 @@ Node TheoryBool::getValue(TNode n, TheoryEngine* engine) {
   }
 
   case kind::XOR: // 2 args
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<bool>() !=
-                                 engine->getValue(n[1]).getConst<bool>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<bool>() !=
+                                 valuation->getValue(n[1]).getConst<bool>() );
 
   case kind::ITE: // 3 args
     // all ITEs should be gone except (bool,bool,bool) ones
     Assert( n[1].getType() == nodeManager->booleanType() &&
             n[2].getType() == nodeManager->booleanType() );
-    return nodeManager->mkConst( engine->getValue(n[0]).getConst<bool>() ?
-                                 engine->getValue(n[1]).getConst<bool>() :
-                                 engine->getValue(n[2]).getConst<bool>() );
+    return nodeManager->mkConst( valuation->getValue(n[0]).getConst<bool>() ?
+                                 valuation->getValue(n[1]).getConst<bool>() :
+                                 valuation->getValue(n[2]).getConst<bool>() );
 
   default:
     Unhandled(n.getKind());
index 5d91842d7e364e056be71d8887a5db2341c667ec..4120159df473c6ec9c924bcd1104b6f8e4924d19 100644 (file)
@@ -43,7 +43,7 @@ public:
     Debug("bool") << "bool: end preRegisterTerm(" << n << ")" << std::endl;
   }
 
-  Node getValue(TNode n, TheoryEngine* engine);
+  Node getValue(TNode n, Valuation* valuation);
 
   std::string identify() const { return std::string("TheoryBool"); }
 };
index 489c97e67518f9bf6ae30fc82caa32ca1add233a..a276fa0ce8b98e85d5fed38e968c2a4c2f5c12b3 100644 (file)
@@ -17,7 +17,7 @@
  **/
 
 #include "theory/builtin/theory_builtin.h"
-#include "theory/theory_engine.h"
+#include "theory/valuation.h"
 #include "expr/kind.h"
 
 using namespace std;
@@ -26,7 +26,7 @@ namespace CVC4 {
 namespace theory {
 namespace builtin {
 
-Node TheoryBuiltin::getValue(TNode n, TheoryEngine* engine) {
+Node TheoryBuiltin::getValue(TNode n, Valuation* valuation) {
   switch(n.getKind()) {
 
   case kind::VARIABLE:
@@ -39,7 +39,7 @@ Node TheoryBuiltin::getValue(TNode n, TheoryEngine* engine) {
     Assert(n[0].getKind() == kind::TUPLE &&
            n[1].getKind() == kind::TUPLE);
     return NodeManager::currentNM()->
-      mkConst( getValue(n[0], engine) == getValue(n[1], engine) );
+      mkConst( getValue(n[0], valuation) == getValue(n[1], valuation) );
   }
 
   case kind::TUPLE: { // 2+ args
@@ -48,14 +48,14 @@ Node TheoryBuiltin::getValue(TNode n, TheoryEngine* engine) {
           iend = n.end();
         i != iend;
         ++i) {
-      nb << engine->getValue(*i);
+      nb << valuation->getValue(*i);
     }
     return Node(nb);
   }
 
   default:
     // all other "builtins" should have been rewritten away or handled
-    // by theory engine, or handled elsewhere.
+    // by the valuation, or handled elsewhere.
     Unhandled(n.getKind());
   }
 }
index baa1493b6fcfb268ba1e619827e7e66e2ea85d92..5b981032612ba51411ab3732f1d1842b6f1e447a 100644 (file)
@@ -31,7 +31,7 @@ class TheoryBuiltin : public Theory {
 public:
   TheoryBuiltin(context::Context* c, OutputChannel& out) :
     Theory(THEORY_BUILTIN, c, out) {}
-  Node getValue(TNode n, TheoryEngine* engine);
+  Node getValue(TNode n, Valuation* valuation);
   std::string identify() const { return std::string("TheoryBuiltin"); }
 };/* class TheoryBuiltin */
 
index 0356e5f270df1eb66f60dba430a172faa387992c..b600bc8f10cbafc4b48177904cee837ee0a62cda 100644 (file)
@@ -20,7 +20,7 @@
 #include "theory/bv/theory_bv.h"
 #include "theory/bv/theory_bv_utils.h"
 
-#include "theory/theory_engine.h"
+#include "theory/valuation.h"
 
 using namespace CVC4;
 using namespace CVC4::theory;
@@ -115,7 +115,7 @@ bool TheoryBV::triggerEquality(size_t triggerId) {
   return true;
 }
 
-Node TheoryBV::getValue(TNode n, TheoryEngine* engine) {
+Node TheoryBV::getValue(TNode n, Valuation* valuation) {
   NodeManager* nodeManager = NodeManager::currentNM();
 
   switch(n.getKind()) {
@@ -125,7 +125,7 @@ Node TheoryBV::getValue(TNode n, TheoryEngine* engine) {
 
   case kind::EQUAL: // 2 args
     return nodeManager->
-      mkConst( engine->getValue(n[0]) == engine->getValue(n[1]) );
+      mkConst( valuation->getValue(n[0]) == valuation->getValue(n[1]) );
 
   default:
     Unhandled(n.getKind());
index ed23bf53ff0093c8bb8b482555596d0723738231..ede98004f11d79c51eee4027e857ea26665994e9 100644 (file)
@@ -88,7 +88,7 @@ public:
 
   void explain(TNode n) { }
 
-  Node getValue(TNode n, TheoryEngine* engine);
+  Node getValue(TNode n, Valuation* valuation);
 
   std::string identify() const { return std::string("TheoryBV"); }
 };/* class TheoryBV */
index a4682710fef56baa0fc44310fd8999a5c4b40b88..b4c3a897b505264abefe12efb8c1e1d8faa7aa69 100644 (file)
@@ -35,6 +35,10 @@ namespace CVC4 {
 
 class TheoryEngine;
 
+namespace theory {
+  class Valuation;
+}/* CVC4::theory namespace */
+
 namespace theory {
 
 /**
@@ -322,7 +326,8 @@ public:
    * if you *know* that you are responsible handle the Node you're
    * asking for; other theories can use your types, so be careful
    * here!  To be safe, it's best to delegate back to the
-   * TheoryEngine.
+   * TheoryEngine (by way of the Valuation proxy object, which avoids
+   * direct dependence on TheoryEngine).
    *
    * Usually, you need to handle at least the two cases of EQUAL and
    * VARIABLE---EQUAL in case a value of yours is on the LHS of an
@@ -337,7 +342,7 @@ public:
    * and suspect this situation is the case, return Node::null()
    * rather than throwing an exception.
    */
-  virtual Node getValue(TNode n, TheoryEngine* engine) = 0;
+  virtual Node getValue(TNode n, Valuation* valuation) = 0;
 
   /**
    * The theory should only add (via .operator<< or .append()) to the
index 25fe29c67dcbcee896d1e133a42ac543f45291f2..97cb8f471d840f0df634372be641d8d59f1527ee 100644 (file)
@@ -134,6 +134,7 @@ TheoryEngine::TheoryEngine(context::Context* ctxt, const Options& opts) :
   d_theoryRegistration(opts.theoryRegistration),
   d_hasShutDown(false),
   d_incomplete(ctxt, false),
+  d_valuation(this),
   d_statistics() {
 
   Rewriter::init();
@@ -226,6 +227,49 @@ Node TheoryEngine::preprocess(TNode node) {
   return preprocessed;
 }
 
+/**
+ * Check all (currently-active) theories for conflicts.
+ * @param effort the effort level to use
+ */
+bool TheoryEngine::check(theory::Theory::Effort effort) {
+  d_theoryOut.d_conflictNode = Node::null();
+  d_theoryOut.d_propagatedLiterals.clear();
+
+#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
+#undef CVC4_FOR_EACH_THEORY_STATEMENT
+#endif
+#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
+  if (theory::TheoryTraits<THEORY>::hasCheck) { \
+     reinterpret_cast<theory::TheoryTraits<THEORY>::theory_class*>(d_theoryTable[THEORY])->check(effort); \
+     if (!d_theoryOut.d_conflictNode.get().isNull()) { \
+       return false; \
+     } \
+  }
+
+  // Do the checking
+  try {
+    CVC4_FOR_EACH_THEORY
+  } catch(const theory::Interrupted&) {
+    Debug("theory") << "TheoryEngine::check() => conflict" << std::endl;
+  }
+
+  return true;
+}
+
+void TheoryEngine::propagate() {
+  // Definition of the statement that is to be run by every theory
+#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
+#undef CVC4_FOR_EACH_THEORY_STATEMENT
+#endif
+#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
+  if (theory::TheoryTraits<THEORY>::hasPropagate) { \
+      reinterpret_cast<theory::TheoryTraits<THEORY>::theory_class*>(d_theoryTable[THEORY])->propagate(theory::Theory::FULL_EFFORT); \
+  }
+
+  // Propagate for each theory using the statement above
+  CVC4_FOR_EACH_THEORY
+}
+
 /* Our goal is to tease out any ITE's sitting under a theory operator. */
 Node TheoryEngine::removeITEs(TNode node) {
   Debug("ite") << "removeITEs(" << node << ")" << endl;
@@ -294,7 +338,7 @@ Node TheoryEngine::getValue(TNode node) {
   }
 
   // otherwise ask the theory-in-charge
-  return theoryOf(node)->getValue(node, this);
+  return theoryOf(node)->getValue(node, &d_valuation);
 }/* TheoryEngine::getValue(TNode node) */
 
 bool TheoryEngine::presolve() {
index bb0e9c10eef7f0d49f3f8f3fd3ccd8672f02fa61..6a343717abde9d178cb87ae93e26b666a3dfba3d 100644 (file)
@@ -27,8 +27,8 @@
 #include "prop/prop_engine.h"
 #include "theory/shared_term_manager.h"
 #include "theory/theory.h"
-#include "theory/theory_traits.h"
 #include "theory/rewriter.h"
+#include "theory/valuation.h"
 #include "util/options.h"
 #include "util/stats.h"
 
@@ -143,6 +143,12 @@ class TheoryEngine {
    */
   context::CDO<bool> d_incomplete;
 
+  /**
+   * A "valuation proxy" for this TheoryEngine.  Used only in getValue()
+   * for decoupled Theory-to-TheoryEngine communication.
+   */
+  theory::Valuation d_valuation;
+
   /**
    * Replace ITE forms in a node.
    */
@@ -270,31 +276,7 @@ public:
    * Check all (currently-active) theories for conflicts.
    * @param effort the effort level to use
    */
-  inline bool check(theory::Theory::Effort effort)
-  {
-    d_theoryOut.d_conflictNode = Node::null();
-    d_theoryOut.d_propagatedLiterals.clear();
-
-#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
-#undef CVC4_FOR_EACH_THEORY_STATEMENT
-#endif
-#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
-    if (theory::TheoryTraits<THEORY>::hasCheck) { \
-       reinterpret_cast<theory::TheoryTraits<THEORY>::theory_class*>(d_theoryTable[THEORY])->check(effort); \
-       if (!d_theoryOut.d_conflictNode.get().isNull()) { \
-         return false; \
-       } \
-    }
-
-    // Do the checking
-    try {
-      CVC4_FOR_EACH_THEORY
-    } catch(const theory::Interrupted&) {
-      Debug("theory") << "TheoryEngine::check() => conflict" << std::endl;
-    }
-
-    return true;
-  }
+  bool check(theory::Theory::Effort effort);
 
   /**
    * Calls staticLearning() on all active theories, accumulating their
@@ -332,20 +314,7 @@ public:
     return d_theoryOut.d_conflictNode;
   }
 
-  inline void propagate() {
-
-    // Definition of the statement that is to be run by every theory
-#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
-#undef CVC4_FOR_EACH_THEORY_STATEMENT
-#endif
-#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
-    if (theory::TheoryTraits<THEORY>::hasPropagate) { \
-        reinterpret_cast<theory::TheoryTraits<THEORY>::theory_class*>(d_theoryTable[THEORY])->propagate(theory::Theory::FULL_EFFORT); \
-    }
-
-    // Propagate for each theory using the statement above
-    CVC4_FOR_EACH_THEORY
-  }
+  void propagate();
 
   inline Node getExplanation(TNode node, theory::Theory* theory) {
     theory->explain(node);
index 33c8bc7b66e9f8c5d41a0a9e4eb8a2f3c476ce59..5d4d44d0a9f290ed63c52ae2a0838bf81eee2936 100644 (file)
@@ -17,7 +17,7 @@
  **/
 
 #include "theory/uf/morgan/theory_uf_morgan.h"
-#include "theory/theory_engine.h"
+#include "theory/valuation.h"
 #include "expr/kind.h"
 #include "util/congruence_closure.h"
 
@@ -567,7 +567,7 @@ void TheoryUFMorgan::notifyRestart() {
   Debug("uf") << "uf: end notifyDecisionLevelZero()" << endl;
 }
 
-Node TheoryUFMorgan::getValue(TNode n, TheoryEngine* engine) {
+Node TheoryUFMorgan::getValue(TNode n, Valuation* valuation) {
   NodeManager* nodeManager = NodeManager::currentNM();
 
   switch(n.getKind()) {
@@ -585,7 +585,7 @@ Node TheoryUFMorgan::getValue(TNode n, TheoryEngine* engine) {
 
   case kind::EQUAL: // 2 args
     return nodeManager->
-      mkConst( engine->getValue(n[0]) == engine->getValue(n[1]) );
+      mkConst( valuation->getValue(n[0]) == valuation->getValue(n[1]) );
 
   default:
     Unhandled(n.getKind());
index 2a079603b220de21e0955272bbc2752813b98746..47c860c9adc6cdef6687d6be39baf46f543c0f61 100644 (file)
@@ -214,7 +214,7 @@ public:
    * Overloads Node getValue(TNode n); from theory.h.
    * See theory/theory.h for more information about this method.
    */
-  Node getValue(TNode n, TheoryEngine* engine);
+  Node getValue(TNode n, Valuation* valuation);
 
   std::string identify() const { return std::string("TheoryUFMorgan"); }
 
index cdaa7975cee536ca502451a6fd2014a5d3f467a9..d07f49f037b4e560a7304d3b4cee54467ee9e722 100644 (file)
@@ -20,7 +20,6 @@
  **  (http://portal.acm.org/ft_gateway.cfm?id=322198&type=pdf)
  ** This has been extended to work in a context-dependent way.
  ** This interacts heavily with the data-structures given in ecdata.h .
- **
  **/
 
 #include "cvc4_private.h"
@@ -151,7 +150,7 @@ public:
    * Overloads Node getValue(TNode n); from theory.h.
    * See theory/theory.h for more information about this method.
    */
-  Node getValue(TNode n, TheoryEngine* engine) {
+  Node getValue(TNode n, Valuation* valuation) {
     Unimplemented("TheoryUFTim doesn't support model generation");
   }
 
diff --git a/src/theory/valuation.cpp b/src/theory/valuation.cpp
new file mode 100644 (file)
index 0000000..20d339b
--- /dev/null
@@ -0,0 +1,31 @@
+/*********************                                                        */
+/*! \file valuation.cpp
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009, 2010  The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief A "valuation" proxy for TheoryEngine
+ **
+ ** Implementation of Valuation class.
+ **/
+
+#include "expr/node.h"
+#include "theory/valuation.h"
+#include "theory/theory_engine.h"
+
+namespace CVC4 {
+namespace theory {
+
+Node Valuation::getValue(TNode n) {
+  return d_engine->getValue(n);
+}
+
+}/* CVC4::theory namespace */
+}/* CVC4 namespace */
diff --git a/src/theory/valuation.h b/src/theory/valuation.h
new file mode 100644 (file)
index 0000000..2d38c29
--- /dev/null
@@ -0,0 +1,48 @@
+/*********************                                                        */
+/*! \file valuation.h
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009, 2010  The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief A "valuation" proxy for TheoryEngine
+ **
+ ** A "valuation" proxy for TheoryEngine.  This class breaks the dependence
+ ** of theories' getValue() implementations on TheoryEngine.  getValue()
+ ** takes a Valuation, which delegates to TheoryEngine.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__THEORY__VALUATION_H
+#define __CVC4__THEORY__VALUATION_H
+
+#include "expr/node.h"
+
+namespace CVC4 {
+
+class TheoryEngine;
+
+namespace theory {
+
+class Valuation {
+  TheoryEngine* d_engine;
+public:
+  Valuation(TheoryEngine* engine) :
+    d_engine(engine) {
+  }
+
+  Node getValue(TNode n);
+
+};/* class Valuation */
+
+}/* CVC4::theory namespace */
+}/* CVC4 namespace */
+
+#endif /* __CVC4__THEORY__VALUATION_H */
index 2315268a8dfbd72c55ef4439b0e050ab7e3c8d49..18408acd3a1b4c1bd37f8f0c71340c68bafc0e58 100644 (file)
@@ -142,7 +142,7 @@ public:
   void preRegisterTerm(TNode n) {}
   void propagate(Effort level) {}
   void explain(TNode n, Effort level) {}
-  Node getValue(TNode n, TheoryEngine* engine) { return Node::null(); }
+  Node getValue(TNode n, Valuation* valuation) { return Node::null(); }
   string identify() const { return "DummyTheory"; }
 };
 
index c78a7456d535a0194806ba2f8cf092ca338806a2..5915ac1f7624e4bdf3a02dfd27491c9f70778f34 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "theory/theory.h"
 #include "theory/theory_engine.h"
+#include "theory/valuation.h"
 #include "theory/rewriter.h"
 #include "expr/node.h"
 #include "expr/node_manager.h"
@@ -211,7 +212,7 @@ public:
   void check(Theory::Effort) { Unimplemented(); }
   void propagate(Theory::Effort) { Unimplemented(); }
   void explain(TNode, Theory::Effort) { Unimplemented(); }
-  Node getValue(TNode n, TheoryEngine* engine) { return Node::null(); }
+  Node getValue(TNode n, Valuation* valuation) { return Node::null(); }
 };/* class FakeTheory */