/// simplification rules
/// all of these rules decrease formula size
+ BvIte,
+ BvComp,
ShlByConst,
LshrByConst,
AshrByConst,
case EvalRotateLeft : out << "EvalRotateLeft"; return out;
case EvalRotateRight : out << "EvalRotateRight"; return out;
case EvalNeg : out << "EvalNeg"; return out;
+ case BvIte : out << "BvIte"; return out;
+ case BvComp : out << "BvComp"; return out;
case ShlByConst : out << "ShlByConst"; return out;
case LshrByConst : out << "LshrByConst"; return out;
case AshrByConst : out << "AshrByConst"; return out;
RewriteRule<EvalRotateRight> rule46;
RewriteRule<EvalEquals> rule47;
RewriteRule<EvalNeg> rule48;
+ RewriteRule<BvIte> rule49;
RewriteRule<ShlByConst> rule50;
RewriteRule<LshrByConst> rule51;
RewriteRule<AshrByConst> rule52;
RewriteRule<ZeroExtendUltConst> rule127;
RewriteRule<MultSltMult> rule128;
RewriteRule<NormalizeEqPlusNeg> rule129;
+ RewriteRule<BvComp> rule130;
};
template<> inline
// FIXME: this rules subsume the constant evaluation ones
+/**
+ * BvIte
+ *
+ * BITVECTOR_ITE with constant condition
+ */
+template <>
+inline bool RewriteRule<BvIte>::applies(TNode node)
+{
+ return (node.getKind() == kind::BITVECTOR_ITE && node[0].isConst());
+}
+
+template <>
+inline Node RewriteRule<BvIte>::apply(TNode node)
+{
+ Debug("bv-rewrite") << "RewriteRule<BvIte>(" << node << ")" << std::endl;
+ return utils::isZero(node[0]) ? node[2] : node[1];
+}
+
+/**
+ * BvComp
+ *
+ * BITVECTOR_COMP of children of size 1 with one constant child
+ */
+template <>
+inline bool RewriteRule<BvComp>::applies(TNode node)
+{
+ return (node.getKind() == kind::BITVECTOR_COMP
+ && utils::getSize(node[0]) == 1
+ && (node[0].isConst() || node[1].isConst()));
+}
+
+template <>
+inline Node RewriteRule<BvComp>::apply(TNode node)
+{
+ Debug("bv-rewrite") << "RewriteRule<BvComp>(" << node << ")" << std::endl;
+ NodeManager* nm = NodeManager::currentNM();
+ if (node[0].isConst())
+ {
+ return utils::isZero(node[0]) ? nm->mkNode(kind::BITVECTOR_NOT, node[1])
+ : Node(node[1]);
+ }
+ return utils::isZero(node[1]) ? nm->mkNode(kind::BITVECTOR_NOT, node[0])
+ : Node(node[0]);
+}
/**
* ShlByConst
return RewriteResponse(REWRITE_AGAIN_FULL, resultNode);
}
-RewriteResponse TheoryBVRewriter::RewriteITEBv(TNode node, bool prerewrite){
- Node resultNode = LinearRewriteStrategy
- < RewriteRule < EvalITEBv >
- >::apply(node);
+RewriteResponse TheoryBVRewriter::RewriteITEBv(TNode node, bool prerewrite)
+{
+ Node resultNode =
+ LinearRewriteStrategy<RewriteRule<EvalITEBv>, RewriteRule<BvIte> >::apply(
+ node);
- return RewriteResponse(REWRITE_DONE, resultNode);
+ return RewriteResponse(REWRITE_DONE, resultNode);
}
RewriteResponse TheoryBVRewriter::RewriteNot(TNode node, bool prerewrite){
return RewriteResponse(REWRITE_AGAIN_FULL, resultNode);
}
-RewriteResponse TheoryBVRewriter::RewriteComp(TNode node, bool prerewrite) {
- Node resultNode = LinearRewriteStrategy
- < RewriteRule < EvalComp >
- >::apply(node);
+RewriteResponse TheoryBVRewriter::RewriteComp(TNode node, bool prerewrite)
+{
+ Node resultNode =
+ LinearRewriteStrategy<RewriteRule<EvalComp>, RewriteRule<BvComp> >::apply(
+ node);
- return RewriteResponse(REWRITE_DONE, resultNode);
+ return RewriteResponse(REWRITE_DONE, resultNode);
}
RewriteResponse TheoryBVRewriter::RewriteMult(TNode node, bool prerewrite) {
bool isBvConstTerm(TNode node)
{
- if (node.getNumChildren() == 0) { return node.isConst();
+ if (node.getNumChildren() == 0)
+ {
+ return node.isConst();
}
for (const TNode& n : node)