From: Liana Hadarean Date: Tue, 7 May 2013 01:46:30 +0000 (-0400) Subject: fixed bv rewrite rule bug X-Git-Tag: cvc5-1.0.0~7287^2~150 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9b035b4aedd977213a5f5acb6e8cb01bf160c415;p=cvc5.git fixed bv rewrite rule bug --- diff --git a/src/theory/bv/theory_bv_rewriter.cpp b/src/theory/bv/theory_bv_rewriter.cpp index 7844e5b92..9c072444d 100644 --- a/src/theory/bv/theory_bv_rewriter.cpp +++ b/src/theory/bv/theory_bv_rewriter.cpp @@ -222,15 +222,16 @@ RewriteResponse TheoryBVRewriter::RewriteConcat(TNode node, bool preregister) { RewriteResponse TheoryBVRewriter::RewriteAnd(TNode node, bool preregister){ Node resultNode = node; - - resultNode = LinearRewriteStrategy - < RewriteRule, - RewriteRule, - RewriteRule - >::apply(node); + if (!preregister) { + resultNode = LinearRewriteStrategy + < RewriteRule, + RewriteRule, + RewriteRule + >::apply(node); - if (resultNode.getKind() != node.getKind()) { - return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); + if (resultNode.getKind() != node.getKind()) { + return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); + } } return RewriteResponse(REWRITE_DONE, resultNode); @@ -238,39 +239,40 @@ RewriteResponse TheoryBVRewriter::RewriteAnd(TNode node, bool preregister){ RewriteResponse TheoryBVRewriter::RewriteOr(TNode node, bool preregister){ Node resultNode = node; + if (! preregister) { + resultNode = LinearRewriteStrategy + < RewriteRule, + RewriteRule, + RewriteRule + >::apply(node); - resultNode = LinearRewriteStrategy - < RewriteRule, - RewriteRule, - RewriteRule - >::apply(node); - - if (resultNode.getKind() != node.getKind()) { - return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); + if (resultNode.getKind() != node.getKind()) { + return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); + } } - return RewriteResponse(REWRITE_DONE, resultNode); } RewriteResponse TheoryBVRewriter::RewriteXor(TNode node, bool preregister) { Node resultNode = node; - - resultNode = LinearRewriteStrategy - < RewriteRule, // flatten the expression - RewriteRule, // simplify duplicates and constants - RewriteRule, // checks if the constant part is zero and eliminates it - RewriteRule - >::apply(node); - - // this simplification introduces new terms and might require further - // rewriting - if (RewriteRule::applies(resultNode)) { - resultNode = RewriteRule::run (resultNode); - return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); - } - - if (resultNode.getKind() != node.getKind()) { - return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); + if (! preregister) { + resultNode = LinearRewriteStrategy + < RewriteRule, // flatten the expression + RewriteRule, // simplify duplicates and constants + RewriteRule, // checks if the constant part is zero and eliminates it + RewriteRule + >::apply(node); + + // this simplification introduces new terms and might require further + // rewriting + if (RewriteRule::applies(resultNode)) { + resultNode = RewriteRule::run (resultNode); + return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); + } + + if (resultNode.getKind() != node.getKind()) { + return RewriteResponse(REWRITE_AGAIN_FULL, resultNode); + } } return RewriteResponse(REWRITE_DONE, resultNode);