// return Rewriter::rewrite(result);
// }
- if (options::bitvectorCoreSolver() && t.getKind() == kind::EQUAL) {
+ if (/*options::bitvectorCoreSolver() && */t.getKind() == kind::EQUAL) {
std::vector<Node> equalities;
Slicer::splitEqualities(t, equalities);
return utils::mkAnd(equalities);
UremOne,
UremSelf,
ShiftZero,
+
+ UltOne,
+ SltZero,
+ ZeroUlt,
/// normalization rules
ExtractBitwise,
case OrSimplify : out << "OrSimplify"; return out;
case XorSimplify : out << "XorSimplify"; return out;
case NegPlus : out << "NegPlus"; return out;
- case BBPlusNeg : out << "BBPlusNeg"; return out;
+ case BBPlusNeg : out << "BBPlusNeg"; return out;
+ case UltOne : out << "UltOne"; return out;
+ case SltZero : out << "SltZero"; return out;
+ case ZeroUlt : out << "ZeroUlt"; return out;
default:
Unreachable();
}
RewriteRule<BBPlusNeg> rule111;
RewriteRule<SolveEq> rule112;
RewriteRule<BitwiseEq> rule113;
+ RewriteRule<UltOne> rule114;
+ RewriteRule<SltZero> rule115;
+
};
template<> inline
}
+// template <>
+// bool RewriteRule<SleEliminate>::applies(TNode node) {
+// return (node.getKind() == kind::BITVECTOR_SLE);
+// }
+
+// template <>
+// Node RewriteRule<SleEliminate>::apply(TNode node) {
+// Debug("bv-rewrite") << "RewriteRule<SleEliminate>(" << node << ")" << std::endl;
+
+// unsigned size = utils::getSize(node[0]);
+// Node pow_two = utils::mkConst(BitVector(size, Integer(1).multiplyByPow2(size - 1)));
+// Node a = utils::mkNode(kind::BITVECTOR_PLUS, node[0], pow_two);
+// Node b = utils::mkNode(kind::BITVECTOR_PLUS, node[1], pow_two);
+
+// return utils::mkNode(kind::BITVECTOR_ULE, a, b);
+
+// }
+
template <>
bool RewriteRule<SleEliminate>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_SLE);
template <>
Node RewriteRule<SleEliminate>::apply(TNode node) {
Debug("bv-rewrite") << "RewriteRule<SleEliminate>(" << node << ")" << std::endl;
-
- unsigned size = utils::getSize(node[0]);
- Node pow_two = utils::mkConst(BitVector(size, Integer(1).multiplyByPow2(size - 1)));
- Node a = utils::mkNode(kind::BITVECTOR_PLUS, node[0], pow_two);
- Node b = utils::mkNode(kind::BITVECTOR_PLUS, node[1], pow_two);
-
- return utils::mkNode(kind::BITVECTOR_ULE, a, b);
-
+
+ TNode a = node[0];
+ TNode b = node[1];
+ Node b_slt_a = utils::mkNode(kind::BITVECTOR_SLT, b, a);
+ return utils::mkNode(kind::NOT, b_slt_a);
}
+
template <>
bool RewriteRule<CompEliminate>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_COMP);
return utils::mkTrue();
}
+/**
+ * ZeroUlt
+ *
+ * 0 < a ==> a != 0
+ */
+
+template<> inline
+bool RewriteRule<ZeroUlt>::applies(TNode node) {
+ return (node.getKind() == kind::BITVECTOR_ULT &&
+ node[0] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(0))));
+}
+
+template<> inline
+Node RewriteRule<ZeroUlt>::apply(TNode node) {
+ Debug("bv-rewrite") << "RewriteRule<ZeroUlt>(" << node << ")" << std::endl;
+ return utils::mkNode(kind::NOT, utils::mkNode(kind::EQUAL, node[0], node[1]));
+}
+
+
/**
* UltZero
*
return utils::mkFalse();
}
+
+/**
+ *
+ */
+template<> inline
+bool RewriteRule<UltOne>::applies(TNode node) {
+ return (node.getKind() == kind::BITVECTOR_ULT &&
+ node[1] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(1))));
+}
+
+template<> inline
+Node RewriteRule<UltOne>::apply(TNode node) {
+ Debug("bv-rewrite") << "RewriteRule<UltOne>(" << node << ")" << std::endl;
+ return utils::mkNode(kind::EQUAL, node[0], utils::mkConst(BitVector(utils::getSize(node[0]), 0u)));
+}
+
+/**
+ *
+ */
+template<> inline
+bool RewriteRule<SltZero>::applies(TNode node) {
+ return (node.getKind() == kind::BITVECTOR_SLT &&
+ node[1] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(0))));
+}
+
+template<> inline
+Node RewriteRule<SltZero>::apply(TNode node) {
+ Debug("bv-rewrite") << "RewriteRule<UltZero>(" << node << ")" << std::endl;
+ unsigned size = utils::getSize(node[0]);
+ Node most_significant_bit = utils::mkExtract(node[0], size - 1, size - 1);
+ Node one = utils::mkConst(BitVector(1, 1u));
+
+ return utils::mkNode(kind::EQUAL, most_significant_bit, one);
+}
+
+
/**
* UltSelf
*
Node resultNode = LinearRewriteStrategy
< RewriteRule<EvalUlt>,
// if both arguments are constants evaluates
- RewriteRule<UltZero>
+ RewriteRule<UltZero>,
// a < 0 rewrites to false
+ RewriteRule<UltOne>,
+ RewriteRule<ZeroUlt>
>::apply(node);
return RewriteResponse(REWRITE_DONE, resultNode);
RewriteResponse TheoryBVRewriter::RewriteSlt(TNode node, bool preregister){
Node resultNode = LinearRewriteStrategy
- < RewriteRule < EvalSlt >
+ < RewriteRule < EvalSlt >,
+ RewriteRule < SltZero >
>::apply(node);
return RewriteResponse(REWRITE_DONE, resultNode);
RewriteResponse TheoryBVRewriter::RewriteSle(TNode node, bool preregister){
Node resultNode = LinearRewriteStrategy
- < RewriteRule < EvalSle >
+ < RewriteRule <EvalSle>,
+ RewriteRule <SleEliminate>
>::apply(node);
return RewriteResponse(REWRITE_DONE, resultNode);
* Notifies the engine of all the theories used.
*/
bool done(TNode node);
- ~PreRegisterVisitor() {
- for (TNodeToTheorySetMap::const_iterator it = d_visited.begin(); it != d_visited.end(); ++it) {
- std::cout << it->first <<"\n";
- }
- }
};