/// simplification rules
/// all of these rules decrease formula size
BvIteConstCond,
- BvIteChildren,
+ BvIteEqualChildren,
BvIteConstChildren,
+ BvIteEqualCond,
BvComp,
ShlByConst,
LshrByConst,
case EvalRotateRight : out << "EvalRotateRight"; return out;
case EvalNeg : out << "EvalNeg"; return out;
case BvIteConstCond : out << "BvIteConstCond"; return out;
- case BvIteChildren : out << "BvIteChildren"; return out;
+ case BvIteEqualChildren : out << "BvIteEqualChildren"; return out;
case BvIteConstChildren : out << "BvIteConstChildren"; return out;
+ case BvIteEqualCond : out << "BvIteEqualCond"; return out;
case BvComp : out << "BvComp"; return out;
case ShlByConst : out << "ShlByConst"; return out;
case LshrByConst : out << "LshrByConst"; return out;
RewriteRule<NormalizeEqPlusNeg> rule129;
RewriteRule<BvComp> rule130;
RewriteRule<BvIteConstCond> rule131;
- RewriteRule<BvIteChildren> rule132;
+ RewriteRule<BvIteEqualChildren> rule132;
RewriteRule<BvIteConstChildren> rule133;
+ RewriteRule<BvIteEqualCond> rule134;
};
template<> inline
}
/**
- * BvIteChildren
+ * BvIteEqualChildren
*
* BITVECTOR_ITE with term_then = term_else
*/
template <>
-inline bool RewriteRule<BvIteChildren>::applies(TNode node)
+inline bool RewriteRule<BvIteEqualChildren>::applies(TNode node)
{
return (node.getKind() == kind::BITVECTOR_ITE && node[1] == node[2]);
}
template <>
-inline Node RewriteRule<BvIteChildren>::apply(TNode node)
+inline Node RewriteRule<BvIteEqualChildren>::apply(TNode node)
{
- Debug("bv-rewrite") << "RewriteRule<BvIteChildren>(" << node << ")"
+ Debug("bv-rewrite") << "RewriteRule<BvIteEqualChildren>(" << node << ")"
<< std::endl;
return node[1];
}
return NodeManager::currentNM()->mkNode(kind::BITVECTOR_NOT, node[0]);
}
+/**
+ * BvIteEqualCond
+ *
+ * Nested BITVECTOR_ITE with cond_outer == cond_inner
+ *
+ * c0 ? (c0 ? t0 : e0) : e1 -> c0 ? t0 : e1
+ * c0 ? t0 : (c0 ? t1 : e1) -> c0 ? t0 : e1
+ * c0 ? (c0 ? t0 : e0) : (c0 ? t1 : e1) -> c0 ? t0 : e1
+ */
+template <>
+inline bool RewriteRule<BvIteEqualCond>::applies(TNode node)
+{
+ return (
+ node.getKind() == kind::BITVECTOR_ITE
+ && ((node[1].getKind() == kind::BITVECTOR_ITE && node[0] == node[1][0])
+ || (node[2].getKind() == kind::BITVECTOR_ITE
+ && node[0] == node[2][0])));
+}
+
+template <>
+inline Node RewriteRule<BvIteEqualCond>::apply(TNode node)
+{
+ Debug("bv-rewrite") << "RewriteRule<BvIteEqualCond>(" << node << ")"
+ << std::endl;
+ Node t0 = node[1].getKind() == kind::BITVECTOR_ITE && node[0] == node[1][0]
+ ? node[1][1]
+ : node[1];
+ Node e1 = node[2].getKind() == kind::BITVECTOR_ITE && node[0] == node[2][0]
+ ? node[2][2]
+ : node[2];
+ return NodeManager::currentNM()->mkNode(kind::BITVECTOR_ITE, node[0], t0, e1);
+}
/**
* BvComp
*
Node resultNode =
LinearRewriteStrategy<RewriteRule<EvalITEBv>,
RewriteRule<BvIteConstCond>,
- RewriteRule<BvIteChildren>,
- RewriteRule<BvIteConstChildren> >::apply(node);
+ RewriteRule<BvIteEqualChildren>,
+ RewriteRule<BvIteConstChildren>,
+ RewriteRule<BvIteEqualCond>>::apply(node);
return RewriteResponse(REWRITE_DONE, resultNode);
}