This is a followup to #4945 which simplifies the contract for computeRelevantTerms.
Debug("arith::collectModelInfo") << "collectModelInfo() begin " << endl;
std::set<Node> termSet;
- d_containing.computeRelevantTerms(termSet);
-
+ const std::set<Kind>& irrKinds = m->getIrrelevantKinds();
+ d_containing.computeAssertedTerms(termSet, irrKinds, true);
// Delta lasts at least the duration of the function call
const Rational& delta = d_partialModel.getDelta();
// MODEL GENERATION
/////////////////////////////////////////////////////////////////////////////
-bool TheoryArrays::collectModelInfo(TheoryModel* m)
+bool TheoryArrays::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
- // Compute terms appearing in assertions and shared terms, and also
- // include additional reads due to the RIntro1 and RIntro2 rules.
- std::set<Node> termSet;
- computeRelevantTerms(termSet);
-
- // Send the equality engine information to the model
- if (!m->assertEqualityEngine(d_equalityEngine, &termSet))
- {
- return false;
- }
-
+ // termSet contains terms appearing in assertions and shared terms, and also
+ // includes additional reads due to the RIntro1 and RIntro2 rules.
NodeManager* nm = NodeManager::currentNM();
// Compute arrays that we need to produce representatives for
std::vector<Node> arrays;
return TrustNode::null();
}
-void TheoryArrays::computeRelevantTerms(std::set<Node>& termSet,
- bool includeShared)
+void TheoryArrays::computeRelevantTerms(std::set<Node>& termSet)
{
- // include all standard terms
- std::set<Kind> irrKinds;
- computeRelevantTermsInternal(termSet, irrKinds, includeShared);
-
NodeManager* nm = NodeManager::currentNM();
// make sure RIntro1 reads are included in the relevant set of reads
eq::EqClassesIterator eqcs_i = eq::EqClassesIterator(d_equalityEngine);
/////////////////////////////////////////////////////////////////////////////
public:
- bool collectModelInfo(TheoryModel* m) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
/////////////////////////////////////////////////////////////////////////////
// NOTIFICATIONS
Node getNextDecisionRequest();
/**
- * Compute relevant terms. This includes additional select nodes for the
+ * Compute relevant terms. This includes select nodes for the
* RIntro1 and RIntro2 rules.
*/
- void computeRelevantTerms(std::set<Node>& termSet,
- bool includeShared = true) override;
+ void computeRelevantTerms(std::set<Node>& termSet) override;
};/* class TheoryArrays */
}/* CVC4::theory::arrays namespace */
bool TLazyBitblaster::collectModelInfo(TheoryModel* m, bool fullModel)
{
std::set<Node> termSet;
- d_bv->computeRelevantTerms(termSet);
+ const std::set<Kind>& irrKinds = m->getIrrelevantKinds();
+ d_bv->computeAssertedTerms(termSet, irrKinds, true);
for (std::set<Node>::const_iterator it = termSet.begin(); it != termSet.end(); ++it) {
TNode var = *it;
Debug("bitvector-model") << "AlgebraicSolver::collectModelInfo\n";
AlwaysAssert(!d_quickSolver->inConflict());
set<Node> termSet;
- d_bv->computeRelevantTerms(termSet);
+ const std::set<Kind>& irrKinds = model->getIrrelevantKinds();
+ d_bv->computeAssertedTerms(termSet, irrKinds, true);
// collect relevant terms that the bv theory abstracts to variables
// (variables and parametric terms such as select apply_uf)
}
}
set<Node> termSet;
- d_bv->computeRelevantTerms(termSet);
+ const std::set<Kind>& irrKinds = m->getIrrelevantKinds();
+ d_bv->computeAssertedTerms(termSet, irrKinds, true);
if (!m->assertEqualityEngine(d_equalityEngine, &termSet))
{
return false;
Trace("dt-cg-summary") << "...done, # pairs = " << n_pairs << std::endl;
}
-bool TheoryDatatypes::collectModelInfo(TheoryModel* m)
+bool TheoryDatatypes::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
Trace("dt-cmi") << "Datatypes : Collect model info "
<< d_equalityEngine->consistent() << std::endl;
printModelDebug( "dt-model" );
Trace("dt-model") << std::endl;
- std::set<Node> termSet;
-
- // Compute terms appearing in assertions and shared terms, and in inferred equalities
- computeRelevantTerms(termSet);
-
- //combine the equality engine
- if (!m->assertEqualityEngine(d_equalityEngine, &termSet))
- {
- return false;
- }
-
//get all constructors
eq::EqClassesIterator eqccs_i = eq::EqClassesIterator(d_equalityEngine);
std::vector< Node > cons;
}
}
-void TheoryDatatypes::computeRelevantTerms(std::set<Node>& termSet,
- bool includeShared)
+void TheoryDatatypes::computeRelevantTerms(std::set<Node>& termSet)
{
- // Compute terms appearing in assertions and shared terms
- std::set<Kind> irrKinds;
- // testers are not relevant for model construction
- irrKinds.insert(APPLY_TESTER);
- computeRelevantTermsInternal(termSet, irrKinds, includeShared);
-
Trace("dt-cmi") << "Have " << termSet.size() << " relevant terms..."
<< std::endl;
TrustNode ppRewrite(TNode n) override;
void notifySharedTerm(TNode t) override;
EqualityStatus getEqualityStatus(TNode a, TNode b) override;
- bool collectModelInfo(TheoryModel* m) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
void shutdown() override {}
std::string identify() const override
{
TNode getRepresentative( TNode a );
/**
- * Compute relevant terms. In addition to all terms in assertions and shared
- * terms, this includes datatypes in non-singleton equivalence classes.
+ * Compute relevant terms. This includes datatypes in non-singleton
+ * equivalence classes.
*/
- void computeRelevantTerms(std::set<Node>& termSet,
- bool includeShared = true) override;
+ void computeRelevantTerms(std::set<Node>& termSet) override;
/** sygus symmetry breaking utility */
std::unique_ptr<SygusExtension> d_sygusExtension;
{
std::set<Node> relevantTerms;
// Work out which variables are needed
- computeRelevantTerms(relevantTerms);
+ const std::set<Kind>& irrKinds = m->getIrrelevantKinds();
+ computeAssertedTerms(relevantTerms, irrKinds);
// this override behavior to not assert equality engine
return collectModelValues(m, relevantTerms);
}
d_internal->check(e);
}
-bool TheorySets::collectModelInfo(TheoryModel* m)
+bool TheorySets::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
- return d_internal->collectModelInfo(m);
+ return d_internal->collectModelValues(m, termSet);
}
void TheorySets::computeCareGraph() {
void notifySharedTerm(TNode) override;
void check(Effort) override;
- bool collectModelInfo(TheoryModel* m) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
void computeCareGraph() override;
TrustNode explain(TNode) override;
EqualityStatus getEqualityStatus(TNode a, TNode b) override;
} // namespace
-bool TheorySetsPrivate::collectModelInfo(TheoryModel* m)
+bool TheorySetsPrivate::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
Trace("sets-model") << "Set collect model info" << std::endl;
- set<Node> termSet;
- // Compute terms appearing in assertions and shared terms
- d_external.computeRelevantTerms(termSet);
-
- // Assert equalities and disequalities to the model
- if (!m->assertEqualityEngine(d_equalityEngine, &termSet))
- {
- return false;
- }
NodeManager* nm = NodeManager::currentNM();
std::map<Node, Node> mvals;
void check(Theory::Effort);
- bool collectModelInfo(TheoryModel* m);
+ bool collectModelValues(TheoryModel* m, const std::set<Node>& termSet);
void computeCareGraph();
std::set<Node> termSet;
// Compute terms appearing in assertions and shared terms
- computeRelevantTerms(termSet);
+ const std::set<Kind>& irrKinds = m->getIrrelevantKinds();
+ computeAssertedTerms(termSet, irrKinds);
// assert the (relevant) portion of the equality engine to the model
if (!m->assertEqualityEngine(d_equalityEngine, &termSet))
{
bool Theory::collectModelInfo(TheoryModel* m)
{
+ // NOTE: the computation of termSet will be moved to model manager
+ // and passed as an argument to collectModelInfo.
std::set<Node> termSet;
// Compute terms appearing in assertions and shared terms
+ TheoryModel* tm = d_valuation.getModel();
+ Assert(tm != nullptr);
+ const std::set<Kind>& irrKinds = tm->getIrrelevantKinds();
+ computeAssertedTerms(termSet, irrKinds, true);
+ // Compute additional relevant terms (theory-specific)
computeRelevantTerms(termSet);
// if we are using an equality engine, assert it to the model
if (d_equalityEngine != nullptr)
}
void Theory::collectTerms(TNode n,
- set<Kind>& irrKinds,
+ const std::set<Kind>& irrKinds,
set<Node>& termSet) const
{
if (termSet.find(n) != termSet.end()) {
}
}
-void Theory::computeRelevantTermsInternal(std::set<Node>& termSet,
- std::set<Kind>& irrKinds,
- bool includeShared) const
+void Theory::computeAssertedTerms(std::set<Node>& termSet,
+ const std::set<Kind>& irrKinds,
+ bool includeShared) const
{
// Collect all terms appearing in assertions
- irrKinds.insert(kind::EQUAL);
- irrKinds.insert(kind::NOT);
context::CDList<Assertion>::const_iterator assert_it = facts_begin(),
assert_it_end = facts_end();
for (; assert_it != assert_it_end; ++assert_it)
}
}
-void Theory::computeRelevantTerms(std::set<Node>& termSet, bool includeShared)
+void Theory::computeRelevantTerms(std::set<Node>& termSet)
{
- std::set<Kind> irrKinds;
- computeRelevantTermsInternal(termSet, irrKinds, includeShared);
+ // by default, there are no additional relevant terms
}
bool Theory::collectModelValues(TheoryModel* m, const std::set<Node>& termSet)
context::CDList<TNode> d_sharedTerms;
//---------------------------------- private collect model info
- /**
- * Scans the current set of assertions and shared terms top-down
- * until a theory-leaf is reached, and adds all terms found to
- * termSet. This is used by collectModelInfo to delimit the set of
- * terms that should be used when constructing a model.
- *
- * irrKinds: The kinds of terms that appear in assertions that should *not*
- * be included in termSet. Note that the kinds EQUAL and NOT are always
- * treated as irrelevant kinds.
- *
- * includeShared: Whether to include shared terms in termSet. Notice that
- * shared terms are not influenced by irrKinds.
- */
- void computeRelevantTermsInternal(std::set<Node>& termSet,
- std::set<Kind>& irrKinds,
- bool includeShared = true) const;
/**
* Helper function for computeRelevantTerms
*/
void collectTerms(TNode n,
- std::set<Kind>& irrKinds,
+ const std::set<Kind>& irrKinds,
std::set<Node>& termSet) const;
//---------------------------------- end private collect model info
*/
virtual bool collectModelInfo(TheoryModel* m);
/**
- * Same as above, but with empty irrKinds. This version can be overridden
- * by the theory, e.g. by restricting or extending the set of terms returned
- * by computeRelevantTermsInternal, which is called by default with no
- * irrKinds.
+ * Scans the current set of assertions and shared terms top-down
+ * until a theory-leaf is reached, and adds all terms found to
+ * termSet. This is used by collectModelInfo to delimit the set of
+ * terms that should be used when constructing a model.
+ *
+ * @param irrKinds The kinds of terms that appear in assertions that should *not*
+ * be included in termSet. Note that the kinds EQUAL and NOT are always
+ * treated as irrelevant kinds.
+ *
+ * @param includeShared Whether to include shared terms in termSet. Notice that
+ * shared terms are not influenced by irrKinds.
+ *
+ * TODO (project #39): this method will be deleted. The version in
+ * model manager will be used.
+ */
+ void computeAssertedTerms(std::set<Node>& termSet,
+ const std::set<Kind>& irrKinds,
+ bool includeShared = true) const;
+ /**
+ * Compute terms that are not necessarily part of the assertions or
+ * shared terms that should be considered relevant, add them to termSet.
*/
- virtual void computeRelevantTerms(std::set<Node>& termSet,
- bool includeShared = true);
+ virtual void computeRelevantTerms(std::set<Node>& termSet);
/**
* Collect model values, after equality information is added to the model.
* The argument termSet is the set of relevant terms returned by