summaryrefslogtreecommitdiff
path: root/src/theory
diff options
context:
space:
mode:
authorClark Barrett <barrett@cs.nyu.edu>2012-11-15 02:14:42 +0000
committerClark Barrett <barrett@cs.nyu.edu>2012-11-15 02:14:42 +0000
commitdc0372a91ae46e6fc5ead1f51a1fe033cfd19944 (patch)
treea45d1ae09a4026f516af9e68e37cab4cc76d2506 /src/theory
parent0cf2cf65658ce8128d0cc87d6a9714b5284d45c4 (diff)
Fixed another AUFBV model bug. BV equality subtheory needed to do something
similar to arrays - limit the set of terms reported to those relevant in the current context. Also removed collectModelInfo from sharedTermsDatabase - doesn't seem to be needed any more.
Diffstat (limited to 'src/theory')
-rw-r--r--src/theory/arrays/theory_arrays.cpp27
-rw-r--r--src/theory/arrays/theory_arrays.h2
-rw-r--r--src/theory/bv/bv_subtheory_eq.cpp4
-rw-r--r--src/theory/theory.cpp31
-rw-r--r--src/theory/theory.h10
-rw-r--r--src/theory/theory_engine.cpp2
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) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback