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.
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)
Trace("rel-manager") << serr.str() << std::endl;
Assert(false) << serr.str();
d_success = false;
+ d_rset.clear();
return;
}
}
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
*/
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:
/**
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())
{
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;
*/
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().