From: Liana Hadarean Date: Sat, 14 Jun 2014 15:01:59 +0000 (-0400) Subject: added bv inequality lemmas X-Git-Tag: cvc5-1.0.0~6815^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0da16116e7568a0b7783aa66084c4cd1ec5b88d0;p=cvc5.git added bv inequality lemmas --- diff --git a/src/theory/bv/bv_subtheory_inequality.cpp b/src/theory/bv/bv_subtheory_inequality.cpp index c6a92a439..55bd829e1 100644 --- a/src/theory/bv/bv_subtheory_inequality.cpp +++ b/src/theory/bv/bv_subtheory_inequality.cpp @@ -137,8 +137,8 @@ void InequalitySolver::assertFact(TNode fact) { } bool InequalitySolver::isInequalityOnly(TNode node) { - if (d_ineqTermCache.find(node) != d_ineqTermCache.end()) { - return d_ineqTermCache[node]; + if (d_ineqOnlyCache.find(node) != d_ineqOnlyCache.end()) { + return d_ineqOnlyCache[node]; } if (node.getKind() == kind::NOT) { @@ -158,7 +158,7 @@ bool InequalitySolver::isInequalityOnly(TNode node) { for (unsigned i = 0; i < node.getNumChildren(); ++i) { res = res && isInequalityOnly(node[i]); } - d_ineqTermCache[node] = res; + d_ineqOnlyCache[node] = res; return res; } @@ -198,6 +198,28 @@ Node InequalitySolver::getModelValue(TNode var) { return result; } +void InequalitySolver::preRegister(TNode node) { + Kind kind = node.getKind(); + if (kind == kind::EQUAL || + kind == kind::BITVECTOR_ULE || + kind == kind::BITVECTOR_ULT) { + d_ineqTerms.insert(node[0]); + d_ineqTerms.insert(node[1]); + } +} + +bool InequalitySolver::addInequality(TNode a, TNode b, bool strict, TNode fact) { + bool ok = d_inequalityGraph.addInequality(a, b, false, fact); + if (!ok || !strict) return ok; + + Node one = utils::mkConst(utils::getSize(a), 1); + Node a_plus_one = Rewriter::rewrite(utils::mkNode(kind::BITVECTOR_PLUS, a, one)); + if (d_ineqTerms.find(a_plus_one) != d_ineqTerms.end()) { + ok = d_inequalityGraph.addInequality(a_plus_one, b, false, fact); + } + return ok; +} + InequalitySolver::Statistics::Statistics() : d_numCallstoCheck("theory::bv::InequalitySolver::NumCallsToCheck", 0) { diff --git a/src/theory/bv/bv_subtheory_inequality.h b/src/theory/bv/bv_subtheory_inequality.h index f142ff7be..ef03166e6 100644 --- a/src/theory/bv/bv_subtheory_inequality.h +++ b/src/theory/bv/bv_subtheory_inequality.h @@ -38,8 +38,11 @@ class InequalitySolver: public SubtheorySolver { InequalityGraph d_inequalityGraph; context::CDHashMap d_explanations; context::CDO d_isComplete; - __gnu_cxx::hash_map d_ineqTermCache; + __gnu_cxx::hash_map d_ineqOnlyCache; + typedef __gnu_cxx::hash_set TNodeSet; + TNodeSet d_ineqTerms; bool isInequalityOnly(TNode node); + bool addInequality(TNode a, TNode b, bool strict, TNode fact); Statistics d_statistics; public: InequalitySolver(context::Context* c, TheoryBV* bv) @@ -48,7 +51,8 @@ public: d_inequalityGraph(c), d_explanations(c), d_isComplete(c, true), - d_ineqTermCache(), + d_ineqOnlyCache(), + d_ineqTerms(), d_statistics() {} @@ -60,6 +64,7 @@ public: Node getModelValue(TNode var); EqualityStatus getEqualityStatus(TNode a, TNode b); void assertFact(TNode fact); + void preRegister(TNode node); }; }