}
bool InequalitySolver::isInequalityOnly(TNode node) {
- if (d_ineqOnlyCache.find(node) != d_ineqOnlyCache.end()) {
- return d_ineqOnlyCache[node];
- }
-
if (node.getKind() == kind::NOT) {
node = node[0];
}
+ if (node.getAttribute(IneqOnlyComputedAttribute())) {
+ return node.getAttribute(IneqOnlyAttribute());
+ }
+
if (node.getKind() != kind::EQUAL &&
node.getKind() != kind::BITVECTOR_ULT &&
node.getKind() != kind::BITVECTOR_ULE &&
node.getKind() != kind::SELECT &&
node.getKind() != kind::STORE &&
node.getMetaKind() != kind::metakind::VARIABLE) {
+ // not worth caching
return false;
}
bool res = true;
- for (unsigned i = 0; i < node.getNumChildren(); ++i) {
+ for (unsigned i = 0; res && i < node.getNumChildren(); ++i) {
res = res && isInequalityOnly(node[i]);
}
- d_ineqOnlyCache[node] = res;
+ node.setAttribute(IneqOnlyComputedAttribute(), true);
+ node.setAttribute(IneqOnlyAttribute(), res);
return res;
}
#include "theory/bv/bv_subtheory.h"
#include "theory/bv/bv_inequality_graph.h"
#include "context/cdhashset.h"
+#include "expr/attribute.h"
namespace CVC4 {
namespace theory {
namespace bv {
+/** Cache for InequalitySolver::isInequalityOnly() */
+struct IneqOnlyAttributeId {};
+typedef expr::Attribute<IneqOnlyAttributeId, bool> IneqOnlyAttribute;
+
+/** Whether the above has been computed yet or not for an expr */
+struct IneqOnlyComputedAttributeId {};
+typedef expr::Attribute<IneqOnlyComputedAttributeId, bool> IneqOnlyComputedAttribute;
+
class InequalitySolver: public SubtheorySolver {
struct Statistics {
IntStat d_numCallstoCheck;
InequalityGraph d_inequalityGraph;
context::CDHashMap<Node, TNode, NodeHashFunction> d_explanations;
context::CDO<bool> d_isComplete;
- __gnu_cxx::hash_map<TNode, bool, TNodeHashFunction> d_ineqOnlyCache;
typedef __gnu_cxx::hash_set<TNode, TNodeHashFunction> TNodeSet;
TNodeSet d_ineqTerms;
bool isInequalityOnly(TNode node);
d_inequalityGraph(c),
d_explanations(c),
d_isComplete(c, true),
- d_ineqOnlyCache(),
d_ineqTerms(),
d_statistics()
{}