This makes 3 changes related to arithmetic preprocessing of equalities which revert to the original behavior of master before
a129c57.
For background, the commit
a129c57 unintentionally changed the default behavior slightly in 3 ways (each corrected in this PR), which led a performance regression on QF_LIA in current master.
The 3 fixes are:
(1) Rewrite equalities should be applied as a post-rewrite, not a pre-rewrite in the theory-rewrite-eq preprocessing pass. This is particularly important for equalities between ITE terms that contain other equalities recursively.
(2) theory-rewrite-eq should apply after rewriting and just before the normal theory preprocessing.
(3) The arith-brab test should call ppRewrite on the arithmetic equality it introduces, as it has a choice of whether to eliminate the equality before the lemma is sent out.
if (it == visited.end())
{
- // don't consider Boolean equality
- if (cur.getKind() == kind::EQUAL && !cur[0].getType().isBoolean())
+ if (cur.getNumChildren()==0)
{
- // For example, (= x y) ---> (and (>= x y) (<= x y))
- theory::TrustNode trn = te->ppRewriteEquality(cur);
- // can make proof producing by using proof generator from trn
- visited[cur] = trn.isNull() ? Node(cur) : trn.getNode();
+ visited[cur] = cur;
}
else
{
{
ret = nm->mkNode(cur.getKind(), children);
}
+ if (ret.getKind() == kind::EQUAL && !ret[0].getType().isBoolean())
+ {
+ // For example, (= x y) ---> (and (>= x y) (<= x y))
+ theory::TrustNode trn = te->ppRewriteEquality(ret);
+ // can make proof producing by using proof generator from trn
+ ret = trn.isNull() ? Node(ret) : trn.getNode();
+ }
visited[cur] = ret;
}
} while (!visit.empty());
{
d_passes["ho-elim"]->apply(&assertions);
}
-
- // rewrite equalities based on theory-specific rewriting
- d_passes["theory-rewrite-eq"]->apply(&assertions);
-
+
// begin: INVARIANT to maintain: no reordering of assertions or
// introducing new ones
// ensure rewritten
d_passes["rewrite"]->apply(&assertions);
+ // rewrite equalities based on theory-specific rewriting
+ d_passes["theory-rewrite-eq"]->apply(&assertions);
// apply theory preprocess, which includes ITE removal
d_passes["theory-preprocess"]->apply(&assertions);
// This is needed because when solving incrementally, removeITEs may
lem = nm->mkNode(kind::OR, ub, lb);
Node eq = Rewriter::rewrite(
nm->mkNode(kind::EQUAL, var, mkRationalNode(nearest)));
+ // Also preprocess it before we send it out. This is important since
+ // arithmetic may prefer eliminating equalities.
+ if (Theory::theoryOf(eq) == THEORY_ARITH)
+ {
+ TrustNode teq = d_containing.ppRewrite(eq);
+ eq = teq.isNull() ? eq : teq.getNode();
+ }
Node literal = d_containing.getValuation().ensureLiteral(eq);
d_containing.getOutputChannel().requirePhase(literal, true);
lem = nm->mkNode(kind::OR, literal, lem);
theory::LemmaStatus EngineOutputChannel::lemma(TNode lemma, LemmaProperty p)
{
- Debug("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma("
+ Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma("
<< lemma << ")"
<< ", properties = " << p << std::endl;
++d_statistics.lemmas;
theory::LemmaStatus EngineOutputChannel::splitLemma(TNode lemma, bool removable)
{
- Debug("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma("
+ Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma("
<< lemma << ")" << std::endl;
++d_statistics.lemmas;
d_engine->d_outputChannelUsed = true;
- Debug("pf::explain") << "EngineOutputChannel::splitLemma( " << lemma << " )"
+ Trace("pf::explain") << "EngineOutputChannel::splitLemma( " << lemma << " )"
<< std::endl;
TrustNode tlem = TrustNode::mkTrustLemma(lemma);
LemmaProperty p = removable ? LemmaProperty::REMOVABLE : LemmaProperty::NONE;
bool EngineOutputChannel::propagate(TNode literal)
{
- Debug("theory::propagate") << "EngineOutputChannel<" << d_theory
+ Trace("theory::propagate") << "EngineOutputChannel<" << d_theory
<< ">::propagate(" << literal << ")" << std::endl;
++d_statistics.propagations;
d_engine->d_outputChannelUsed = true;
void EngineOutputChannel::requirePhase(TNode n, bool phase)
{
- Debug("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase
+ Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase
<< ")" << std::endl;
++d_statistics.requirePhase;
d_engine->getPropEngine()->requirePhase(n, phase);
LemmaStatus EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p)
{
- Debug("theory::lemma") << "EngineOutputChannel<" << d_theory
+ Trace("theory::lemma") << "EngineOutputChannel<" << d_theory
<< ">::trustedLemma(" << plem << ")" << std::endl;
Assert(plem.getKind() == TrustNodeKind::LEMMA);
if (plem.getGenerator() != nullptr)