Helps debugging model issues.
// now, finish building the model
d_modelBuiltSuccess = finishBuildModel();
+
+ if (Trace.isOn("model-builder"))
+ {
+ Trace("model-builder") << "Final model:" << std::endl;
+ Trace("model-builder") << d_model->debugPrintModelEqc() << std::endl;
+ }
+
+ Trace("model-builder") << "ModelManager: model built success is "
+ << d_modelBuiltSuccess << std::endl;
+
return d_modelBuiltSuccess;
}
}
if (Trace.isOn("sep-eqc"))
{
- eq::EqClassesIterator eqcs2_i = eq::EqClassesIterator(d_equalityEngine);
- Trace("sep-eqc") << "EQC:" << std::endl;
- while (!eqcs2_i.isFinished())
- {
- Node eqc = (*eqcs2_i);
- eq::EqClassIterator eqc2_i = eq::EqClassIterator(eqc, d_equalityEngine);
- Trace("sep-eqc") << "Eqc( " << eqc << " ) : { ";
- while (!eqc2_i.isFinished())
- {
- if ((*eqc2_i) != eqc)
- {
- Trace("sep-eqc") << (*eqc2_i) << " ";
- }
- ++eqc2_i;
- }
- Trace("sep-eqc") << " } " << std::endl;
- ++eqcs2_i;
- }
- Trace("sep-eqc") << std::endl;
+ Trace("sep-eqc") << d_equalityEngine->debugPrintEqc();
}
bool addedLemma = false;
bool TheoryStrings::collectModelValues(TheoryModel* m,
const std::set<Node>& termSet)
{
- Trace("strings-model") << "TheoryStrings : Collect model values" << std::endl;
-
+ if (Trace.isOn("strings-model"))
+ {
+ Trace("strings-model") << "TheoryStrings : Collect model values"
+ << std::endl;
+ Trace("strings-model") << "Equivalence classes are:" << std::endl;
+ Trace("strings-model") << debugPrintStringsEqc() << std::endl;
+ }
std::map<TypeNode, std::unordered_set<Node, NodeHashFunction> > repSet;
// Generate model
// get the relevant string equivalence classes
<< "Theory of strings " << e << " effort check " << std::endl;
if (Trace.isOn("strings-eqc"))
{
- for (unsigned t = 0; t < 2; t++)
- {
- eq::EqClassesIterator eqcs2_i = eq::EqClassesIterator(d_equalityEngine);
- Trace("strings-eqc") << (t==0 ? "STRINGS:" : "OTHER:") << std::endl;
- while( !eqcs2_i.isFinished() ){
- Node eqc = (*eqcs2_i);
- bool print = (t == 0 && eqc.getType().isStringLike())
- || (t == 1 && !eqc.getType().isStringLike());
- if (print) {
- eq::EqClassIterator eqc2_i =
- eq::EqClassIterator(eqc, d_equalityEngine);
- Trace("strings-eqc") << "Eqc( " << eqc << " ) : { ";
- while( !eqc2_i.isFinished() ) {
- if( (*eqc2_i)!=eqc && (*eqc2_i).getKind()!=kind::EQUAL ){
- Trace("strings-eqc") << (*eqc2_i) << " ";
- }
- ++eqc2_i;
- }
- Trace("strings-eqc") << " } " << std::endl;
- EqcInfo* ei = d_state.getOrMakeEqcInfo(eqc, false);
- if( ei ){
- Trace("strings-eqc-debug")
- << "* Length term : " << ei->d_lengthTerm.get() << std::endl;
- Trace("strings-eqc-debug")
- << "* Cardinality lemma k : " << ei->d_cardinalityLemK.get()
- << std::endl;
- Trace("strings-eqc-debug")
- << "* Normalization length lemma : "
- << ei->d_normalizedLength.get() << std::endl;
- }
- }
- ++eqcs2_i;
- }
- Trace("strings-eqc") << std::endl;
- }
- Trace("strings-eqc") << std::endl;
+ Trace("strings-eqc") << debugPrintStringsEqc() << std::endl;
}
++(d_statistics.d_checkRuns);
bool sentLemma = false;
Trace("strings-process") << "----finished round---" << std::endl;
}
+std::string TheoryStrings::debugPrintStringsEqc()
+{
+ std::stringstream ss;
+ for (unsigned t = 0; t < 2; t++)
+ {
+ eq::EqClassesIterator eqcs2_i = eq::EqClassesIterator(d_equalityEngine);
+ ss << (t == 0 ? "STRINGS:" : "OTHER:") << std::endl;
+ while (!eqcs2_i.isFinished())
+ {
+ Node eqc = (*eqcs2_i);
+ bool print = (t == 0 && eqc.getType().isStringLike())
+ || (t == 1 && !eqc.getType().isStringLike());
+ if (print)
+ {
+ eq::EqClassIterator eqc2_i = eq::EqClassIterator(eqc, d_equalityEngine);
+ ss << "Eqc( " << eqc << " ) : { ";
+ while (!eqc2_i.isFinished())
+ {
+ if ((*eqc2_i) != eqc && (*eqc2_i).getKind() != kind::EQUAL)
+ {
+ ss << (*eqc2_i) << " ";
+ }
+ ++eqc2_i;
+ }
+ ss << " } " << std::endl;
+ EqcInfo* ei = d_state.getOrMakeEqcInfo(eqc, false);
+ if (ei)
+ {
+ Trace("strings-eqc-debug")
+ << "* Length term : " << ei->d_lengthTerm.get() << std::endl;
+ Trace("strings-eqc-debug")
+ << "* Cardinality lemma k : " << ei->d_cardinalityLemK.get()
+ << std::endl;
+ Trace("strings-eqc-debug")
+ << "* Normalization length lemma : "
+ << ei->d_normalizedLength.get() << std::endl;
+ }
+ }
+ ++eqcs2_i;
+ }
+ ss << std::endl;
+ }
+ ss << std::endl;
+ return ss.str();
+}
+
}/* CVC4::theory::strings namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
void runInferStep(InferStep s, int effort);
/** run strategy for effort e */
void runStrategy(Theory::Effort e);
+ /** print strings equivalence classes for debugging */
+ std::string debugPrintStringsEqc();
/** Commonly used constants */
Node d_true;
Node d_false;
bool first = true;
Node rep;
for (; !eqc_i.isFinished(); ++eqc_i) {
- if (termSet != NULL && termSet->find(*eqc_i) == termSet->end()) {
- Trace("model-builder-debug") << "...skip node " << (*eqc_i) << " in eqc " << eqc << std::endl;
+ Node n = *eqc_i;
+ // notice that constants are always relevant
+ if (termSet != nullptr && termSet->find(n) == termSet->end()
+ && !n.isConst())
+ {
+ Trace("model-builder-debug")
+ << "...skip node " << n << " in eqc " << eqc << std::endl;
continue;
}
if (predicate) {
if (predTrue || predFalse)
{
- if (!assertPredicate(*eqc_i, predTrue))
+ if (!assertPredicate(n, predTrue))
{
return false;
}
}
else {
if (first) {
- rep = (*eqc_i);
+ rep = n;
first = false;
}
else {
- Node eq = (*eqc_i).eqNode(rep);
+ Node eq = (n).eqNode(rep);
Trace("model-builder-assertions")
<< "(assert " << eq << ");" << std::endl;
d_equalityEngine->assertEquality(eq, true, Node::null());
}
} else {
if (first) {
- rep = (*eqc_i);
+ rep = n;
//add the term (this is specifically for the case of singleton equivalence classes)
if (rep.getType().isFirstClass())
{
first = false;
}
else {
- if (!assertEquality(*eqc_i, rep, true))
+ if (!assertEquality(n, rep, true))
{
return false;
}
const std::string& TheoryModel::getName() const { return d_name; }
+std::string TheoryModel::debugPrintModelEqc() const
+{
+ std::stringstream ss;
+ ss << "--- Equivalence classes:" << std::endl;
+ ss << d_equalityEngine->debugPrintEqc() << std::endl;
+ ss << "--- Representative map: " << std::endl;
+ for (const std::pair<const Node, Node>& r : d_reps)
+ {
+ ss << r.first << " -> " << r.second << std::endl;
+ }
+ ss << "---" << std::endl;
+ return ss.str();
+}
+
} /* namespace CVC4::theory */
} /* namespace CVC4 */
//---------------------------- end function values
/** Get the name of this model */
const std::string& getName() const;
+ /**
+ * For debugging, print the equivalence classes of the underlying equality
+ * engine.
+ */
+ std::string debugPrintModelEqc() const;
protected:
/** Unique name of this model */
* a model builder constructs this model.
*/
virtual void addTermInternal(TNode n);
-
private:
/** cache for getModelValue */
mutable std::unordered_map<Node, Node, NodeHashFunction> d_modelCache;
Debug("equality::graph") << std::endl;
}
+std::string EqualityEngine::debugPrintEqc() const
+{
+ std::stringstream ss;
+ eq::EqClassesIterator eqcs2_i = eq::EqClassesIterator(this);
+ while (!eqcs2_i.isFinished())
+ {
+ Node eqc = (*eqcs2_i);
+ eq::EqClassIterator eqc2_i = eq::EqClassIterator(eqc, this);
+ ss << "Eqc( " << eqc << " ) : { ";
+ while (!eqc2_i.isFinished())
+ {
+ if ((*eqc2_i) != eqc && (*eqc2_i).getKind() != kind::EQUAL)
+ {
+ ss << (*eqc2_i) << " ";
+ }
+ ++eqc2_i;
+ }
+ ss << " } " << std::endl;
+ ++eqcs2_i;
+ }
+ return ss.str();
+}
+
bool EqualityEngine::areEqual(TNode t1, TNode t2) const {
Debug("equality") << d_name << "::eq::areEqual(" << t1 << "," << t2 << ")";
*/
void setMasterEqualityEngine(EqualityEngine* master);
+ /** Print the equivalence classes for debugging */
+ std::string debugPrintEqc() const;
+
/** Statistics about the equality engine instance */
struct Statistics
{