From cfd85e45da5400e3d5bd48a6f33bd5cfbf20798f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dejan=20Jovanovi=C4=87?= Date: Sat, 9 Jul 2011 05:40:21 +0000 Subject: [PATCH] some immediate bug fixes --- src/theory/uf/equality_engine_impl.h | 4 ++-- src/theory/uf/theory_uf.cpp | 18 ++++++++---------- src/theory/uf/theory_uf.h | 11 +++++------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/theory/uf/equality_engine_impl.h b/src/theory/uf/equality_engine_impl.h index 292761c46..a19ec8d66 100644 --- a/src/theory/uf/equality_engine_impl.h +++ b/src/theory/uf/equality_engine_impl.h @@ -474,10 +474,10 @@ std::string EqualityEngine::edgesToString(EqualityEdgeId edgeId) co template void EqualityEngine::getExplanation(TNode t1, TNode t2, std::vector& equalities) const { - Assert(getRepresentative(t1) == getRepresentative(t2)); - Debug("equality") << "EqualityEngine::getExplanation(" << t1 << "," << t2 << ")" << std::endl; + Assert(getRepresentative(t1) == getRepresentative(t2)); + // Backtrack if necessary const_cast(this)->backtrack(); diff --git a/src/theory/uf/theory_uf.cpp b/src/theory/uf/theory_uf.cpp index 8caac6fb7..7688379d9 100644 --- a/src/theory/uf/theory_uf.cpp +++ b/src/theory/uf/theory_uf.cpp @@ -139,18 +139,15 @@ void TheoryUF::preRegisterTerm(TNode node) { } } -bool TheoryUF::propagate(TNode atom, bool isTrue) { - Debug("uf") << "TheoryUF::propagate(" << atom << ", " << (isTrue ? "true" : "false" ) << ")" << std::endl; +bool TheoryUF::propagate(TNode literal) { + Debug("uf") << "TheoryUF::propagate(" << literal << ")" << std::endl; // If already in conflict, no more propagation if (d_conflict) { - Debug("uf") << "TheoryUF::propagate(" << atom << ", " << (isTrue ? "true" : "false" ) << "): already in conflict" << std::endl; + Debug("uf") << "TheoryUF::propagate(" << literal << "): already in conflict" << std::endl; return false; } - // The literal - TNode literal = isTrue ? (Node) atom : atom.notNode(); - // See if the literal has been asserted already bool satValue = false; bool isAsserted = literal == d_false || d_valuation.hasSatValue(literal, satValue); @@ -158,13 +155,13 @@ bool TheoryUF::propagate(TNode atom, bool isTrue) { // If asserted, we're done or in conflict if (isAsserted) { if (satValue) { - Debug("uf") << "TheoryUF::propagate(" << atom << ", " << (isTrue ? "true" : "false" ) << ") => already known" << std::endl; + Debug("uf") << "TheoryUF::propagate(" << literal << ") => already known" << std::endl; return true; } else { - Debug("uf") << "TheoryUF::propagate(" << atom << ", " << (isTrue ? "true" : "false" ) << ") => conflict" << std::endl; + Debug("uf") << "TheoryUF::propagate(" << literal << ") => conflict" << std::endl; std::vector assumptions; if (literal != d_false) { - TNode negatedLiteral = isTrue ? atom.notNode() : (Node) atom; + TNode negatedLiteral = literal.getKind() == kind::NOT ? literal[0] : (TNode) literal.notNode(); assumptions.push_back(negatedLiteral); } explain(literal, assumptions); @@ -175,7 +172,7 @@ bool TheoryUF::propagate(TNode atom, bool isTrue) { } // Nothing, just enqueue it for propagation and mark it as asserted already - Debug("uf") << "TheoryUF::propagate(" << atom << ", " << (isTrue ? "true" : "false" ) << ") => enqueuing for propagation" << std::endl; + Debug("uf") << "TheoryUF::propagate(" << literal << ") => enqueuing for propagation" << std::endl; d_literalsToPropagate.push_back(literal); return true; @@ -195,6 +192,7 @@ void TheoryUF::explain(TNode literal, std::vector& assumptions) { case kind::NOT: lhs = literal[0]; rhs = d_false; + break; case kind::CONST_BOOLEAN: // we get to explain true = false, since we set false to be the trigger of this lhs = d_true; diff --git a/src/theory/uf/theory_uf.h b/src/theory/uf/theory_uf.h index c77d5a810..eaab96f27 100644 --- a/src/theory/uf/theory_uf.h +++ b/src/theory/uf/theory_uf.h @@ -44,10 +44,10 @@ public: public: NotifyClass(TheoryUF& uf): d_uf(uf) {} - bool notifyEquality(TNode eq) { - Debug("uf") << "NotifyClass::notifyEquality(" << eq << ")" << std::endl; + bool notifyEquality(TNode reason) { + Debug("uf") << "NotifyClass::notifyEquality(" << reason << ")" << std::endl; // Just forward to uf - return d_uf.propagate(eq, true); + return d_uf.propagate(reason); } }; @@ -69,10 +69,9 @@ private: Node d_conflictNode; /** - * Should be called to propagate the atom. If isTrue is true, the atom should be propagated, - * otherwise the negated atom should be propagated. + * Should be called to propagate the literal. */ - bool propagate(TNode atom, bool isTrue); + bool propagate(TNode literal); /** * Explain why this literal is true by adding assumptions -- 2.30.2