From f9f3d26e4f34bfa0b03e05af6b827e7b72ea6ebd Mon Sep 17 00:00:00 2001 From: Dejan Jovanović Date: Fri, 7 Nov 2014 12:31:26 -0500 Subject: Bug 593 fix: if the type is finite, it is now considered for detecting theories of nested terms. --- src/theory/term_registration_visitor.cpp | 76 ++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'src/theory') diff --git a/src/theory/term_registration_visitor.cpp b/src/theory/term_registration_visitor.cpp index 0e573ce62..7ece4594d 100644 --- a/src/theory/term_registration_visitor.cpp +++ b/src/theory/term_registration_visitor.cpp @@ -50,13 +50,36 @@ bool PreRegisterVisitor::alreadyVisited(TNode current, TNode parent) { d_theories = Theory::setInsert(parentTheoryId, d_theories); // Should we use the theory of the type - bool useType = current != parent && currentTheoryId != parentTheoryId; + bool useType = false; + TheoryId typeTheoryId = THEORY_LAST; + if (current != parent) { + if (currentTheoryId != parentTheoryId) { + // If enclosed by different theories it's shared -- in read(a, f(a)) f(a) should be shared with integers + TypeNode type = current.getType(); + useType = true; + typeTheoryId = Theory::theoryOf(type); + } else { + TypeNode type = current.getType(); + typeTheoryId = Theory::theoryOf(type); + if (typeTheoryId != currentTheoryId) { + if (options::finiteModelFind() && type.isSort()) { + // We're looking for finite models + useType = true; + } else { + Cardinality card = type.getCardinality(); + if (card.isFinite()) { + useType = true; + } + } + } + } + } + // Get the theories that have already visited this node TNodeToTheorySetMap::iterator find = d_visited.find(current); if (find == d_visited.end()) { if (useType) { - TheoryId typeTheoryId = Theory::theoryOf(current.getType()); d_theories = Theory::setInsert(typeTheoryId, d_theories); } return false; @@ -93,8 +116,32 @@ void PreRegisterVisitor::visit(TNode current, TNode parent) { TheoryId parentTheoryId = Theory::theoryOf(parent); // Should we use the theory of the type - bool useType = current != parent && currentTheoryId != parentTheoryId; + bool useType = false; + TheoryId typeTheoryId = THEORY_LAST; + if (current != parent) { + if (currentTheoryId != parentTheoryId) { + // If enclosed by different theories it's shared -- in read(a, f(a)) f(a) should be shared with integers + TypeNode type = current.getType(); + useType = true; + typeTheoryId = Theory::theoryOf(type); + } else { + TypeNode type = current.getType(); + typeTheoryId = Theory::theoryOf(type); + if (typeTheoryId != currentTheoryId) { + if (options::finiteModelFind() && type.isSort()) { + // We're looking for finite models + useType = true; + } else { + Cardinality card = type.getCardinality(); + if (card.isFinite()) { + useType = true; + } + } + } + } + } + Theory::Set visitedTheories = d_visited[current]; Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): previously registered with " << Theory::setToString(visitedTheories) << std::endl; if (!Theory::setContains(currentTheoryId, visitedTheories)) { @@ -112,7 +159,6 @@ void PreRegisterVisitor::visit(TNode current, TNode parent) { Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): adding " << parentTheoryId << std::endl; } if (useType) { - TheoryId typeTheoryId = Theory::theoryOf(current.getType()); if (!Theory::setContains(typeTheoryId, visitedTheories)) { visitedTheories = Theory::setInsert(typeTheoryId, visitedTheories); d_visited[current] = visitedTheories; @@ -165,6 +211,28 @@ bool SharedTermsVisitor::alreadyVisited(TNode current, TNode parent) const { bool useType = false; TheoryId typeTheoryId = THEORY_LAST; + if (current != parent) { + if (currentTheoryId != parentTheoryId) { + // If enclosed by different theories it's shared -- in read(a, f(a)) f(a) should be shared with integers + TypeNode type = current.getType(); + useType = true; + typeTheoryId = Theory::theoryOf(type); + } else { + TypeNode type = current.getType(); + typeTheoryId = Theory::theoryOf(type); + if (typeTheoryId != currentTheoryId) { + if (options::finiteModelFind() && type.isSort()) { + // We're looking for finite models + useType = true; + } else { + Cardinality card = type.getCardinality(); + if (card.isFinite()) { + useType = true; + } + } + } + } + } if (current != parent) { if (currentTheoryId != parentTheoryId) { // If enclosed by different theories it's shared -- in read(a, f(a)) f(a) should be shared with integers -- cgit v1.2.3