From 48f837c9d53e2e93b14786943f9961228e0d9933 Mon Sep 17 00:00:00 2001 From: Clark Barrett Date: Sun, 10 Jun 2012 14:43:58 +0000 Subject: Added a very fruitful assertion to the rewriter: checks that rewriting after "REWRITE_DONE" is idempotent Found several problems where this is not the case and fixed them --- src/theory/bv/theory_bv_rewrite_rules_normalization.h | 8 +++++++- src/theory/bv/theory_bv_rewriter.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/theory/bv') diff --git a/src/theory/bv/theory_bv_rewrite_rules_normalization.h b/src/theory/bv/theory_bv_rewrite_rules_normalization.h index 197134b6a..4fa96c231 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_normalization.h +++ b/src/theory/bv/theory_bv_rewrite_rules_normalization.h @@ -429,8 +429,11 @@ Node RewriteRule::apply(TNode node) { // If both constants are nonzero, combine on right, otherwise leave them where they are if (rightConst != zero) { + leftConst = zero; rightConst = rightConst - leftConst; - childrenRight.push_back(utils::mkConst(rightConst)); + if (rightConst != zero) { + childrenRight.push_back(utils::mkConst(rightConst)); + } } else if (leftConst != zero) { childrenLeft.push_back(utils::mkConst(leftConst)); @@ -540,6 +543,9 @@ Node RewriteRule::apply(TNode node) { newRight = utils::mkSortedNode(kind::BITVECTOR_PLUS, childrenRight); } + Assert(newLeft == Rewriter::rewrite(newLeft)); + Assert(newRight == Rewriter::rewrite(newRight)); + if (newLeft == newRight) { Assert (newLeft == utils::mkConst(size, (unsigned)0)); return utils::mkTrue(); diff --git a/src/theory/bv/theory_bv_rewriter.cpp b/src/theory/bv/theory_bv_rewriter.cpp index d6de6edbd..47725444d 100644 --- a/src/theory/bv/theory_bv_rewriter.cpp +++ b/src/theory/bv/theory_bv_rewriter.cpp @@ -107,7 +107,7 @@ RewriteResponse TheoryBVRewriter::RewriteUle(TNode node, bool preregister){ RewriteRule, RewriteRule >::apply(node); - return RewriteResponse(REWRITE_DONE, resultNode); + return RewriteResponse(resultNode == node ? REWRITE_DONE : REWRITE_AGAIN, resultNode); } RewriteResponse TheoryBVRewriter::RewriteSle(TNode node, bool preregister){ -- cgit v1.2.3