// Rewrite until fix-point is reached
for(;;) {
// Perform the pre-rewrite
+ Kind originalKind = rewriteStackTop.d_node.getKind();
RewriteResponse response = preRewrite(
rewriteStackTop.getTheoryId(), rewriteStackTop.d_node, tcpg);
// Put the rewritten node to the top of the stack
rewriteStackTop.d_node = response.d_node;
TheoryId newTheory = theoryOf(rewriteStackTop.d_node);
- // In the pre-rewrite, if changing theories, we just call the other theories pre-rewrite
- if (newTheory == rewriteStackTop.getTheoryId()
+ // In the pre-rewrite, if changing theories, we just call the other
+ // theories pre-rewrite. If the kind of the node was changed, then we
+ // pre-rewrite again.
+ if (originalKind == rewriteStackTop.d_node.getKind()
&& response.d_status == REWRITE_DONE)
{
+ if (Configuration::isAssertionBuild())
+ {
+ // REWRITE_DONE should imply that no other pre-rewriting can be
+ // done.
+ Node rewritten = rewriteStackTop.d_node;
+ Node rewrittenAgain =
+ preRewrite(newTheory, rewritten, nullptr).d_node;
+ Assert(rewritten == rewrittenAgain)
+ << "Rewriter returned REWRITE_DONE for " << rewritten
+ << " but it can be rewritten to " << rewrittenAgain;
+ }
break;
}
rewriteStackTop.d_theoryId = newTheory;
// Done with all pre-rewriting, so let's do the post rewrite
for(;;) {
// Do the post-rewrite
+ Kind originalKind = rewriteStackTop.d_node.getKind();
RewriteResponse response = postRewrite(
rewriteStackTop.getTheoryId(), rewriteStackTop.d_node, tcpg);
#endif
break;
}
- else if (response.d_status == REWRITE_DONE)
+ else if (response.d_status == REWRITE_DONE
+ && originalKind == response.d_node.getKind())
{
#ifdef CVC5_ASSERTIONS
RewriteResponse r2 =
regress0/bv/pr4993-bvugt-bvurem-a.smt2
regress0/bv/pr4993-bvugt-bvurem-b.smt2
regress0/bv/proj-issue343.smt2
+ regress0/bv/proj-issue438-prerewrite-fixed-point.smt2
regress0/bv/reset-assertions-assert-input.smt2
regress0/bv/sizecheck.cvc.smt2
regress0/bv/smtcompbug.smtv1.smt2
regress1/bv/issue3776.smt2
regress1/bv/issue3958.smt2
regress1/bv/min-pp-rewrite-error.smt2
+ regress1/bv/proj-issue438-prerewrite-fixed-point-original.smt2
regress1/bv/unsound1.smt2
regress1/bvdiv2.smt2
regress1/cee-bug0909-dd-scope.smt2
--- /dev/null
+; Note: This benchmark triggers the same issue as
+; proj-issue438-prerewrite-fixed-point-original.smt2, but for a different node
+; kind.
+
+(set-logic QF_BV)
+(declare-const x (_ BitVec 3))
+(define-fun z () (_ BitVec 3) (bvadd x x))
+(define-fun s () (_ BitVec 3) (bvsub z z))
+(assert (bvule (bvnand s s) s))
+(set-info :status unsat)
+(check-sat)