Added witnesses to Constraints.
authorTim King <taking@cs.nyu.edu>
Wed, 13 Jun 2012 21:30:05 +0000 (21:30 +0000)
committerTim King <taking@cs.nyu.edu>
Wed, 13 Jun 2012 21:30:05 +0000 (21:30 +0000)
src/theory/arith/constraint.cpp
src/theory/arith/constraint.h
src/theory/arith/theory_arith.cpp

index bedb917562471822376b4ef5b0a9753b66c4351e..b441058953586195bb3afd15486934d063c3c299 100644 (file)
@@ -56,7 +56,8 @@ ConstraintValue::ConstraintValue(ArithVar x,  ConstraintType t, const DeltaRatio
     d_literal(Node::null()),
     d_negation(NullConstraint),
     d_canBePropagated(false),
-    d_assertionOrder(AssertionOrderSentinel),
+    _d_assertionOrder(AssertionOrderSentinel),
+    d_witness(TNode::null()),
     d_proof(ProofIdSentinel),
     d_split(false),
     d_variablePosition()
@@ -347,11 +348,11 @@ void ConstraintValue::setCanBePropagated() {
   d_database->pushCanBePropagatedWatch(this);
 }
 
-void ConstraintValue::setAssertedToTheTheory() {
+void ConstraintValue::setAssertedToTheTheory(TNode witness) {
   Assert(hasLiteral());
   Assert(!assertedToTheTheory());
   Assert(!d_negation->assertedToTheTheory());
-  d_database->pushAssertionOrderWatch(this);
+  d_database->pushAssertionOrderWatch(this, witness);
 }
 
 bool ConstraintValue::isSelfExplaining() const {
@@ -853,7 +854,7 @@ void ConstraintValue::explainBefore(NodeBuilder<>& nb, AssertionOrder order) con
   Assert(!isSelfExplaining() || assertedToTheTheory());
 
   if(assertedBefore(order)){
-    nb << getLiteral();
+    nb << getWitness();
   }else if(hasEqualityEngineProof()){
     d_database->eeExplain(this, nb);
   }else{
@@ -870,7 +871,7 @@ Node ConstraintValue::explainBefore(AssertionOrder order) const{
   Assert(hasProof());
   Assert(!isSelfExplaining() || assertedBefore(order));
   if(assertedBefore(order)){
-    return getLiteral();
+    return getWitness();
   }else if(hasEqualityEngineProof()){
     return d_database->eeExplain(this);
   }else{
index dcc3bf8bb6f356c2dfadf5ddf07e33faaf101389..be4197a26715f20a0c004373a2568a1cc36956aa 100644 (file)
@@ -273,7 +273,12 @@ private:
    * Sat Context Dependent.
    * This is initially AssertionOrderSentinel.
    */
-  AssertionOrder d_assertionOrder;
+  AssertionOrder _d_assertionOrder;
+  /**
+   * This is guarenteed to be on the fact queue.
+   * For example if x + y = x + 1 is on the fact queue, then use this 
+   */
+  TNode d_witness;
 
   /**
    * This points at the proof for the constraint in the current context.
@@ -347,7 +352,8 @@ private:
     inline void operator()(Constraint* p){
       Constraint constraint = *p;
       Assert(constraint->assertedToTheTheory());
-      constraint->d_assertionOrder = AssertionOrderSentinel;
+      constraint->_d_assertionOrder = AssertionOrderSentinel;
+      constraint->d_witness = TNode::null();
       Assert(!constraint->assertedToTheTheory());
     }
   };
@@ -439,15 +445,20 @@ public:
   }
 
   bool assertedToTheTheory() const {
-    return d_assertionOrder < AssertionOrderSentinel;
+    Assert((_d_assertionOrder < AssertionOrderSentinel) != d_witness.isNull());
+    return _d_assertionOrder < AssertionOrderSentinel;
+  }
+  TNode getWitness() const {
+    Assert(assertedToTheTheory());
+    return d_witness;
   }
 
   bool assertedBefore(AssertionOrder time) const {
-    return d_assertionOrder < time;
+    return _d_assertionOrder < time;
   }
 
 
-  void setAssertedToTheTheory();
+  void setAssertedToTheTheory(TNode witness);
 
 
   bool hasLiteral() const {
@@ -518,7 +529,7 @@ public:
   Node explainForPropagation() const {
     Assert(hasProof());
     Assert(!isSelfExplaining());
-    return explainBefore(d_assertionOrder);
+    return explainBefore(_d_assertionOrder);
   }
 
 private:
@@ -733,9 +744,10 @@ private:
     d_watches->d_canBePropagatedWatches.push_back(c);
   }
 
-  void pushAssertionOrderWatch(Constraint c){
+  void pushAssertionOrderWatch(Constraint c, TNode witness){
     Assert(!c->assertedToTheTheory());
-    c->d_assertionOrder = d_watches->d_assertionOrderWatches.size();
+    c->_d_assertionOrder = d_watches->d_assertionOrderWatches.size();
+    c->d_witness = witness;
     d_watches->d_assertionOrderWatches.push_back(c);
   }
 
index faf0e35631052f0f7c0b4d4992fda4f60769aea8..3ba987124e8d9426cbb384ce99fd1da416e00ba2 100644 (file)
@@ -1132,7 +1132,7 @@ Constraint TheoryArith::constraintFromFactQueue(){
     return NullConstraint;
   }else{
     Debug("arith::constraint") << "arith constraint " << constraint << std::endl;
-    constraint->setAssertedToTheTheory();
+    constraint->setAssertedToTheTheory(assertion);
 
     if(!constraint->hasProof()){
       Debug("arith::constraint") << "marking as constraint as self explaining " << endl;
@@ -1661,8 +1661,7 @@ void TheoryArith::propagate(Effort e) {
 
       d_out->propagate(literal);
     }else{
-      Node literal = c->getLiteral();
-      Debug("arith::prop") << "already asserted to the theory " << literal << endl;
+      Debug("arith::prop") << "already asserted to the theory " <<  c->getLiteral() << endl;
     }
   }