d_termIndex.clear();
d_stringsEqc.clear();
- std::map<Kind, uint32_t> ncongruent;
- std::map<Kind, uint32_t> congruent;
+ Trace("strings-base") << "BaseSolver::checkInit" << std::endl;
+ // count of congruent, non-congruent per operator (independent of type),
+ // for debugging.
+ std::map<Kind, std::pair<uint32_t, uint32_t>> congruentCount;
eq::EqualityEngine* ee = d_state.getEqualityEngine();
eq::EqClassesIterator eqcs_i = eq::EqClassesIterator(ee);
while (!eqcs_i.isFinished())
if (!tn.isRegExp())
{
Node emps;
+ // get the term index for type tn
+ std::map<Kind, TermIndex>& tti = d_termIndex[tn];
if (tn.isStringLike())
{
d_stringsEqc.push_back(eqc);
{
Node n = *eqc_i;
Kind k = n.getKind();
+ Trace("strings-base") << "initialize term: " << n << std::endl;
// process constant-like terms
if (utils::isConstantLike(n))
{
if (d_congruent.find(n) == d_congruent.end())
{
std::vector<Node> c;
- Node nc = d_termIndex[k].add(n, 0, d_state, emps, c);
+ Node nc = tti[k].add(n, 0, d_state, emps, c);
if (nc != n)
{
+ Trace("strings-base-debug")
+ << "...found congruent term " << nc << std::endl;
// check if we have inferred a new equality by removal of empty
// components
if (k == STRING_CONCAT && !d_state.areEqual(nc, n))
{
std::vector<Node> exp;
+ // the number of empty components of n, nc
size_t count[2] = {0, 0};
while (count[0] < nc.getNumChildren()
|| count[1] < n.getNumChildren())
count[t]++;
}
}
+ Trace("strings-base-debug")
+ << " counts = " << count[0] << ", " << count[1]
+ << std::endl;
// explain equal components
if (count[0] < nc.getNumChildren())
{
// assuming that the reduction of f(a) depends on itself.
}
// this node is congruent to another one, we can ignore it
- Trace("strings-process-debug")
+ Trace("strings-base-debug")
<< " congruent term : " << n << " (via " << nc << ")"
<< std::endl;
d_congruent.insert(n);
- congruent[k]++;
+ congruentCount[k].first++;
}
else if (k == STRING_CONCAT && c.size() == 1)
{
- Trace("strings-process-debug")
+ Trace("strings-base-debug")
<< " congruent term by singular : " << n << " " << c[0]
<< std::endl;
// singular case
d_im.sendInference(exp, n.eqNode(ns), Inference::I_NORM_S);
}
d_congruent.insert(n);
- congruent[k]++;
+ congruentCount[k].first++;
}
else
{
- ncongruent[k]++;
+ congruentCount[k].second++;
}
}
else
{
- congruent[k]++;
+ congruentCount[k].first++;
}
}
}
}
else if (var > n)
{
- Trace("strings-process-debug")
+ Trace("strings-base-debug")
<< " congruent variable : " << var << std::endl;
d_congruent.insert(var);
var = n;
}
else
{
- Trace("strings-process-debug")
+ Trace("strings-base-debug")
<< " congruent variable : " << n << std::endl;
d_congruent.insert(n);
}
}
++eqcs_i;
}
- if (Trace.isOn("strings-process"))
+ if (Trace.isOn("strings-base"))
{
- for (std::map<Kind, TermIndex>::iterator it = d_termIndex.begin();
- it != d_termIndex.end();
- ++it)
+ for (const std::pair<const Kind, std::pair<uint32_t, uint32_t>>& cc :
+ congruentCount)
{
- Trace("strings-process")
- << " Terms[" << it->first << "] = " << ncongruent[it->first] << "/"
- << (congruent[it->first] + ncongruent[it->first]) << std::endl;
+ Trace("strings-base")
+ << " Terms[" << cc.first << "] = " << cc.second.second << "/"
+ << (cc.second.first + cc.second.second) << std::endl;
}
}
+ Trace("strings-base") << "BaseSolver::checkInit finished" << std::endl;
}
void BaseSolver::checkConstantEquivalenceClasses()
do
{
vecc.clear();
- Trace("strings-process-debug")
+ Trace("strings-base-debug")
<< "Check constant equivalence classes..." << std::endl;
prevSize = d_eqcInfo.size();
- checkConstantEquivalenceClasses(&d_termIndex[STRING_CONCAT], vecc, true);
+ for (std::pair<const TypeNode, std::map<Kind, TermIndex>>& tindex :
+ d_termIndex)
+ {
+ checkConstantEquivalenceClasses(
+ &tindex.second[STRING_CONCAT], vecc, true);
+ }
} while (!d_im.hasProcessed() && d_eqcInfo.size() > prevSize);
if (!d_im.hasProcessed())
{
// now, go back and set "most content" terms
vecc.clear();
- checkConstantEquivalenceClasses(&d_termIndex[STRING_CONCAT], vecc, false);
+ for (std::pair<const TypeNode, std::map<Kind, TermIndex>>& tindex :
+ d_termIndex)
+ {
+ checkConstantEquivalenceClasses(
+ &tindex.second[STRING_CONCAT], vecc, false);
+ }
}
}