Node resultNode =
LinearRewriteStrategy<RewriteRule<EvalITEBv>,
RewriteRule<BvIteConstCond>,
- RewriteRule<BvIteEqualChildren>,
- RewriteRule<BvIteConstChildren>,
- RewriteRule<BvIteEqualCond>>::apply(node);
+ RewriteRule<BvIteEqualChildren>>::apply(node);
+ // If the node has been rewritten, we return here because we need to make
+ // sure that `BvIteEqualChildren` has been applied until we reach a fixpoint
+ // before applying `BvIteConstChildren`. Otherwise, `BvIteConstChildren`
+ // potentially performs an unsound rewrite. Returning hands back the control
+ // to the `Rewriter` which will then call this method again, ensuring that
+ // the rewrites are applied in the correct order.
+ if (resultNode != node)
+ {
+ return RewriteResponse(REWRITE_AGAIN, resultNode);
+ }
+
+ resultNode = LinearRewriteStrategy<RewriteRule<BvIteConstChildren>,
+ RewriteRule<BvIteEqualCond>>::apply(node);
if (resultNode != node)
{
return RewriteResponse(REWRITE_AGAIN, resultNode);
TS_ASSERT_EQUALS(nr, Rewriter::rewrite(nr));
}
+ void testRewriteBvIte()
+ {
+ TypeNode boolType = d_nm->booleanType();
+ TypeNode bvType = d_nm->mkBitVectorType(1);
+
+ Node zero = d_nm->mkConst(BitVector(1, 0u));
+ Node c1 = d_nm->mkVar("c1", bvType);
+ Node c2 = d_nm->mkVar("c2", bvType);
+
+ Node ite = d_nm->mkNode(BITVECTOR_ITE, c2, zero, zero);
+ Node n = d_nm->mkNode(BITVECTOR_ITE, c1, ite, ite);
+ Node nr = Rewriter::rewrite(n);
+ TS_ASSERT_EQUALS(nr, Rewriter::rewrite(nr));
+ }
+
private:
ExprManager* d_em;
SmtEngine* d_smt;