summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-04-14 11:12:30 -0500
committerGitHub <noreply@github.com>2021-04-14 16:12:30 +0000
commit5f6b4f8dd31e21f935c3f4a441af11e18e12d283 (patch)
treeadd52bead6587b5d0e5407f90e1f3056d05a0305 /src
parentf3ecc4bfe17776d08efbbb5ed76a5879efa419ca (diff)
Add interface for getting relevant assertions (#5131)
This adds an interface to TheoryEngine for getting the current set of relevant assertions if it is available. An interface to this can further be added to the API in a future PR.
Diffstat (limited to 'src')
-rw-r--r--src/theory/relevance_manager.cpp15
-rw-r--r--src/theory/relevance_manager.h19
-rw-r--r--src/theory/theory_engine.cpp12
-rw-r--r--src/theory/theory_engine.h20
4 files changed, 62 insertions, 4 deletions
diff --git a/src/theory/relevance_manager.cpp b/src/theory/relevance_manager.cpp
index f48ef98c6..68ec573c3 100644
--- a/src/theory/relevance_manager.cpp
+++ b/src/theory/relevance_manager.cpp
@@ -85,12 +85,12 @@ void RelevanceManager::addAssertionsInternal(std::vector<Node>& toProcess)
void RelevanceManager::resetRound()
{
d_computed = false;
- d_rset.clear();
}
void RelevanceManager::computeRelevance()
{
d_computed = true;
+ d_rset.clear();
Trace("rel-manager") << "RelevanceManager::computeRelevance..." << std::endl;
std::unordered_map<TNode, int, TNodeHashFunction> cache;
for (const Node& node: d_input)
@@ -105,6 +105,7 @@ void RelevanceManager::computeRelevance()
Trace("rel-manager") << serr.str() << std::endl;
Assert(false) << serr.str();
d_success = false;
+ d_rset.clear();
return;
}
}
@@ -314,5 +315,17 @@ bool RelevanceManager::isRelevant(Node lit)
return d_rset.find(lit) != d_rset.end();
}
+const std::unordered_set<TNode, TNodeHashFunction>&
+RelevanceManager::getRelevantAssertions(bool& success)
+{
+ if (!d_computed)
+ {
+ computeRelevance();
+ }
+ // update success flag
+ success = d_success;
+ return d_rset;
+}
+
} // namespace theory
} // namespace cvc5
diff --git a/src/theory/relevance_manager.h b/src/theory/relevance_manager.h
index 83014bcd6..ac0ad83b5 100644
--- a/src/theory/relevance_manager.h
+++ b/src/theory/relevance_manager.h
@@ -88,11 +88,24 @@ class RelevanceManager
*/
void resetRound();
/**
- * Is lit part of the current relevant selection? This call is valid during
- * full effort check in TheoryEngine. This means that theories can query this
- * during FULL or LAST_CALL efforts, through the Valuation class.
+ * Is lit part of the current relevant selection? This computes the set of
+ * relevant assertions if not already done so. This call is valid during a
+ * full effort check in TheoryEngine, or after TheoryEngine has terminated
+ * with "sat". This means that theories can query this during FULL or
+ * LAST_CALL efforts, through the Valuation class.
*/
bool isRelevant(Node lit);
+ /**
+ * Get the current relevant selection (see above). This computes this set
+ * if not already done so. This call is valid during a full effort check in
+ * TheoryEngine, or after TheoryEngine has terminated with "sat". This method
+ * sets the flag success to false if we failed to compute relevant
+ * assertions, which can occur if
+ *
+ * The value of this return is only valid if success was not updated to false.
+ */
+ const std::unordered_set<TNode, TNodeHashFunction>& getRelevantAssertions(
+ bool& success);
private:
/**
diff --git a/src/theory/theory_engine.cpp b/src/theory/theory_engine.cpp
index 55c782f2f..9f0e3eb82 100644
--- a/src/theory/theory_engine.cpp
+++ b/src/theory/theory_engine.cpp
@@ -1114,6 +1114,18 @@ theory::EqualityStatus TheoryEngine::getEqualityStatus(TNode a, TNode b) {
return d_sharedSolver->getEqualityStatus(a, b);
}
+const std::unordered_set<TNode, TNodeHashFunction>&
+TheoryEngine::getRelevantAssertions(bool& success)
+{
+ // if we are not in SAT mode, or there is no relevance manager, we fail
+ if (!d_inSatMode || d_relManager == nullptr)
+ {
+ success = false;
+ return d_emptyRelevantSet;
+ }
+ return d_relManager->getRelevantAssertions(success);
+}
+
Node TheoryEngine::getModelValue(TNode var) {
if (var.isConst())
{
diff --git a/src/theory/theory_engine.h b/src/theory/theory_engine.h
index b43488fa8..09d33edc2 100644
--- a/src/theory/theory_engine.h
+++ b/src/theory/theory_engine.h
@@ -157,6 +157,11 @@ class TheoryEngine {
std::unique_ptr<theory::DecisionManager> d_decManager;
/** The relevance manager */
std::unique_ptr<theory::RelevanceManager> d_relManager;
+ /**
+ * An empty set of relevant assertions, which is returned as a dummy value for
+ * getRelevantAssertions when relevance is disabled.
+ */
+ std::unordered_set<TNode, TNodeHashFunction> d_emptyRelevantSet;
/** are we in eager model building mode? (see setEagerModelBuilding). */
bool d_eager_model_building;
@@ -626,6 +631,21 @@ class TheoryEngine {
Node getModelValue(TNode var);
/**
+ * Get relevant assertions. This returns a set of assertions that are
+ * currently asserted to this TheoryEngine that propositionally entail the
+ * (preprocessed) input formula and all theory lemmas that have been marked
+ * NEEDS_JUSTIFY. For more details on this, see relevance_manager.h.
+ *
+ * This method updates success to false if the set of relevant assertions
+ * is not available. This may occur if we are not in SAT mode, if the
+ * relevance manager is disabled (see option::relevanceFilter) or if the
+ * relevance manager failed to compute relevant assertions due to an internal
+ * error.
+ */
+ const std::unordered_set<TNode, TNodeHashFunction>& getRelevantAssertions(
+ bool& success);
+
+ /**
* Forwards an entailment check according to the given theoryOfMode.
* See theory.h for documentation on entailmentCheck().
*/
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback