This PR adds optional rewriting to the SubstitutionMap class. Before, only the new TrustSubstitutionMap added optional rewriting, leading to unexpected inconsistencies between the two. In particular, cases exist where the substitution and the rewriting cancel each other (see #5943).
This PR moves the optional rewriting from TrustSubstitutionMap into SubstitutionMap. While the former enables it by default, it is disabled by default for the latter and thus does not change current behavior.
We now use this new option in an assertion in the non-clausal simplification.
Fixes #5943.
c = learnedLiteral[1];
}
Assert(!t.isConst());
- Assert(cps.apply(t) == t);
+ Assert(cps.apply(t, true) == t);
Assert(top_level_substs.apply(t) == t);
Assert(nss.apply(t) == t);
// also add to learned literal
}
}
-Node SubstitutionMap::apply(TNode t) {
+Node SubstitutionMap::apply(TNode t, bool doRewrite) {
Debug("substitution") << "SubstitutionMap::apply(" << t << ")" << endl;
Node result = internalSubstitute(t, d_substitutionCache);
Debug("substitution") << "SubstitutionMap::apply(" << t << ") => " << result << endl;
+ if (doRewrite)
+ {
+ result = Rewriter::rewrite(result);
+ }
+
return result;
}
/**
* Apply the substitutions to the node.
*/
- Node apply(TNode t);
+ Node apply(TNode t, bool doRewrite = false);
/**
* Apply the substitutions to the node.
*/
- Node apply(TNode t) const {
- return const_cast<SubstitutionMap*>(this)->apply(t);
+ Node apply(TNode t, bool doRewrite = false) const {
+ return const_cast<SubstitutionMap*>(this)->apply(t, doRewrite);
}
iterator begin() {
{
Trace("trust-subs") << "TrustSubstitutionMap::addSubstitution: apply " << n
<< std::endl;
- Node ns = d_subs.apply(n);
+ Node ns = d_subs.apply(n, doRewrite);
Trace("trust-subs") << "...subs " << ns << std::endl;
- // rewrite if indicated
- if (doRewrite)
- {
- ns = Rewriter::rewrite(ns);
- Trace("trust-subs") << "...rewrite " << ns << std::endl;
- }
if (n == ns)
{
// no change
regress0/precedence/xor-or.cvc
regress0/preprocess/circuit-prop.smt2
regress0/preprocess/issue5729-rewritten-assertions.smt2
+ regress0/preprocess/issue5943-non-clausal-simp.smt2
regress0/preprocess/preprocess_00.cvc
regress0/preprocess/preprocess_01.cvc
regress0/preprocess/preprocess_02.cvc
--- /dev/null
+; COMMAND-LINE: --strings-exp
+; EXPECT: unsat
+(set-logic QF_SLIA)
+(declare-fun s () String)
+(assert (and (and (= (str.len (str.at s 3)) 4) (not (not (= (ite (not (= (ite (not (= (str.at (str.at s 3)
+(ite (not (not (= (ite (<= (str.len (str.at s 1)) 3) 1 0) 0))) 1 0)) (str.at s 5))) 1 0) 0)) 1 0) 0)))) (not (not (= (str.len s) 3)))))
+(check-sat)