diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/theory/arrays/theory_arrays.cpp | 27 | ||||
-rw-r--r-- | src/theory/arrays/theory_arrays.h | 2 | ||||
-rw-r--r-- | src/theory/bv/bv_subtheory_eq.cpp | 4 | ||||
-rw-r--r-- | src/theory/theory.cpp | 31 | ||||
-rw-r--r-- | src/theory/theory.h | 10 | ||||
-rw-r--r-- | src/theory/theory_engine.cpp | 2 |
6 files changed, 46 insertions, 30 deletions
diff --git a/src/theory/arrays/theory_arrays.cpp b/src/theory/arrays/theory_arrays.cpp index 3a109b51a..e079c4010 100644 --- a/src/theory/arrays/theory_arrays.cpp +++ b/src/theory/arrays/theory_arrays.cpp @@ -649,36 +649,11 @@ void TheoryArrays::computeCareGraph() ///////////////////////////////////////////////////////////////////////////// -void TheoryArrays::collectTerms(TNode n, set<Node>& termSet) -{ - if (termSet.find(n) != termSet.end()) { - return; - } - termSet.insert(n); - if (n.getType().isBoolean() || !isLeaf(n)) { - for(TNode::iterator child_it = n.begin(); child_it != n.end(); ++child_it) { - collectTerms(*child_it, termSet); - } - } -} - - void TheoryArrays::collectModelInfo( TheoryModel* m, bool fullModel ) { set<Node> termSet; - set<Node> cache; - // Collect all terms appearing in assertions - context::CDList<Assertion>::const_iterator assert_it = facts_begin(), assert_it_end = facts_end(); - for (; assert_it != assert_it_end; ++assert_it) { - collectTerms(*assert_it, termSet); - } - - // Add terms that are shared terms - context::CDList<TNode>::const_iterator shared_it = shared_terms_begin(), shared_it_end = shared_terms_end(); - for (; shared_it != shared_it_end; ++shared_it) { - collectTerms(*shared_it, termSet); - } + computeRelevantTerms(termSet); // Add selects that were generated internally context::CDHashSet<TNode, TNodeHashFunction>::iterator internal_it = d_readsInternal.begin(), internal_it_end = d_readsInternal.end(); diff --git a/src/theory/arrays/theory_arrays.h b/src/theory/arrays/theory_arrays.h index 9bf1201f3..65b77f801 100644 --- a/src/theory/arrays/theory_arrays.h +++ b/src/theory/arrays/theory_arrays.h @@ -218,8 +218,6 @@ class TheoryArrays : public Theory { ///////////////////////////////////////////////////////////////////////////// private: - /** Helper function for collectModelInfo */ - void collectTerms(TNode n, std::set<Node>& termSet); public: diff --git a/src/theory/bv/bv_subtheory_eq.cpp b/src/theory/bv/bv_subtheory_eq.cpp index e809a2566..f8e6882a9 100644 --- a/src/theory/bv/bv_subtheory_eq.cpp +++ b/src/theory/bv/bv_subtheory_eq.cpp @@ -174,5 +174,7 @@ void EqualitySolver::collectModelInfo(TheoryModel* m) { << *it << ")\n"; } } - m->assertEqualityEngine(&d_equalityEngine); + set<Node> termSet; + d_bv->computeRelevantTerms(termSet); + m->assertEqualityEngine(&d_equalityEngine, &termSet); } diff --git a/src/theory/theory.cpp b/src/theory/theory.cpp index 43574f6e4..5dcafff39 100644 --- a/src/theory/theory.cpp +++ b/src/theory/theory.cpp @@ -245,5 +245,36 @@ std::hash_set<TNode, TNodeHashFunction> Theory::currentlySharedTerms() const{ return currentlyShared; } + +void Theory::collectTerms(TNode n, set<Node>& termSet) +{ + if (termSet.find(n) != termSet.end()) { + return; + } + termSet.insert(n); + if (n.getKind() == kind::NOT || n.getKind() == kind::EQUAL || !isLeaf(n)) { + for(TNode::iterator child_it = n.begin(); child_it != n.end(); ++child_it) { + collectTerms(*child_it, termSet); + } + } +} + + +void Theory::computeRelevantTerms(set<Node>& termSet) +{ + // Collect all terms appearing in assertions + context::CDList<Assertion>::const_iterator assert_it = facts_begin(), assert_it_end = facts_end(); + for (; assert_it != assert_it_end; ++assert_it) { + collectTerms(*assert_it, termSet); + } + + // Add terms that are shared terms + context::CDList<TNode>::const_iterator shared_it = shared_terms_begin(), shared_it_end = shared_terms_end(); + for (; shared_it != shared_it_end; ++shared_it) { + collectTerms(*shared_it, termSet); + } +} + + }/* CVC4::theory namespace */ }/* CVC4 namespace */ diff --git a/src/theory/theory.h b/src/theory/theory.h index 9cc5058cc..72206afb8 100644 --- a/src/theory/theory.h +++ b/src/theory/theory.h @@ -233,6 +233,16 @@ protected: context::CDList<TNode> d_sharedTerms; /** + * Helper function for computeRelevantTerms + */ + void collectTerms(TNode n, std::set<Node>& termSet); + /** + * 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 + */ + void computeRelevantTerms(std::set<Node>& termSet); + + /** * Construct a Theory. */ Theory(TheoryId id, context::Context* satContext, context::UserContext* userContext, diff --git a/src/theory/theory_engine.cpp b/src/theory/theory_engine.cpp index 9d93c6cc0..c32f36275 100644 --- a/src/theory/theory_engine.cpp +++ b/src/theory/theory_engine.cpp @@ -546,7 +546,7 @@ bool TheoryEngine::properExplanation(TNode node, TNode expl) const { void TheoryEngine::collectModelInfo( theory::TheoryModel* m, bool fullModel ){ //have shared term engine collectModelInfo - d_sharedTerms.collectModelInfo( m, fullModel ); + // d_sharedTerms.collectModelInfo( m, fullModel ); // Consult each active theory to get all relevant information // concerning the model. for(TheoryId theoryId = theory::THEORY_FIRST; theoryId < theory::THEORY_LAST; ++theoryId) { |