return utils::mkConst(bits.size(), value);
}
-bool TLazyBitblaster::collectModelInfo(TheoryModel* m, bool fullModel)
+bool TLazyBitblaster::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
- std::set<Node> termSet;
- const std::set<Kind>& irrKinds = m->getIrrelevantKinds();
- d_bv->computeAssertedTerms(termSet, irrKinds, true);
-
for (std::set<Node>::const_iterator it = termSet.begin(); it != termSet.end(); ++it) {
TNode var = *it;
// not actually a leaf of the bit-vector theory
Node const_value = getModelFromSatSolver(var, true);
Assert(const_value.isNull() || const_value.isConst());
if(const_value != Node()) {
- Debug("bitvector-model") << "TLazyBitblaster::collectModelInfo (assert (= "
- << var << " "
- << const_value << "))\n";
+ Debug("bitvector-model")
+ << "TLazyBitblaster::collectModelValues (assert (= " << var << " "
+ << const_value << "))\n";
if (!m->assertEquality(var, const_value, true))
{
return false;
* Adds a constant value for each bit-blasted variable in the model.
*
* @param m the model
- * @param fullModel whether to create a "full model," i.e., add
- * constants to equivalence classes that don't already have them
+ * @param termSet the set of relevant terms
*/
- bool collectModelInfo(TheoryModel* m, bool fullModel);
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet);
typedef TNodeSet::const_iterator vars_iterator;
vars_iterator beginVars() { return d_variables.begin(); }
}
}
-bool BVQuickCheck::collectModelInfo(theory::TheoryModel* model, bool fullModel)
+bool BVQuickCheck::collectModelValues(theory::TheoryModel* model,
+ const std::set<Node>& termSet)
{
- return d_bitblaster->collectModelInfo(model, fullModel);
+ return d_bitblaster->collectModelValues(model, termSet);
}
BVQuickCheck::~BVQuickCheck() {
* @return
*/
uint64_t computeAtomWeight(TNode atom, NodeSet& seen);
- bool collectModelInfo(theory::TheoryModel* model, bool fullModel);
+ bool collectModelValues(theory::TheoryModel* model,
+ const std::set<Node>& termSet);
typedef std::unordered_set<TNode, TNodeHashFunction>::const_iterator
vars_iterator;
Unimplemented() << "BVSolver propagated a node but doesn't implement the "
"BVSolver::explain() interface!";
return TrustNode::null();
- };
+ }
- /**
- * This is temporary only and will be deprecated soon in favor of
- * Theory::collectModelValues.
- */
- virtual bool collectModelInfo(TheoryModel* m) = 0;
+ /** Collect model values in m based on the relevant terms given by termSet */
+ virtual bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) = 0;
virtual std::string identify() const = 0;
virtual void presolve(){};
- virtual void notifySharedTerm(TNode t) = 0;
+ virtual void notifySharedTerm(TNode t) {}
virtual EqualityStatus getEqualityStatus(TNode a, TNode b)
{
return false;
}
-bool BVSolverLazy::collectModelInfo(TheoryModel* m)
+bool BVSolverLazy::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
Assert(!inConflict());
if (options::bitblastMode() == options::BitblastMode::EAGER)
{
if (d_subtheories[i]->isComplete())
{
- return d_subtheories[i]->collectModelInfo(m, true);
+ return d_subtheories[i]->collectModelValues(m, termSet);
}
}
return true;
Debug("bitvector::sharing")
<< indent() << "BVSolverLazy::notifySharedTerm(" << t << ")" << std::endl;
d_sharedTermsSet.insert(t);
- if (options::bitvectorEqualitySolver())
- {
- for (unsigned i = 0; i < d_subtheories.size(); ++i)
- {
- d_subtheories[i]->addSharedTerm(t);
- }
- }
}
EqualityStatus BVSolverLazy::getEqualityStatus(TNode a, TNode b)
TrustNode explain(TNode n) override;
- bool collectModelInfo(TheoryModel* m) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
std::string identify() const override { return std::string("BVSolverLazy"); }
void checkForLemma(TNode node);
- void computeAssertedTerms(std::set<Node>& termSet,
- const std::set<Kind>& irrKinds,
- bool includeShared) const
- {
- return d_bv.computeAssertedTerms(termSet, irrKinds, includeShared);
- }
-
size_t numAssertions() { return d_bv.numAssertions(); }
theory::Assertion get() { return d_bv.get(); }
virtual void explain(TNode literal, std::vector<TNode>& assumptions) = 0;
virtual void preRegister(TNode node) {}
virtual void propagate(Theory::Effort e) {}
- virtual bool collectModelInfo(TheoryModel* m, bool fullModel) = 0;
+ virtual bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) = 0;
virtual Node getModelValue(TNode var) = 0;
virtual bool isComplete() = 0;
virtual EqualityStatus getEqualityStatus(TNode a, TNode b) = 0;
- virtual void addSharedTerm(TNode node) {}
bool done() { return d_assertionQueue.size() == d_assertionIndex; }
TNode get() {
Assert(!done());
return false;
}
-void AlgebraicSolver::setConflict(TNode conflict) {
+void AlgebraicSolver::setConflict(TNode conflict)
+{
Node final_conflict = conflict;
if (options::bitvectorQuickXplain() &&
conflict.getKind() == kind::AND &&
return EQUALITY_UNKNOWN;
}
-bool AlgebraicSolver::collectModelInfo(TheoryModel* model, bool fullModel)
+bool AlgebraicSolver::collectModelValues(TheoryModel* model,
+ const std::set<Node>& termSet)
{
- Debug("bitvector-model") << "AlgebraicSolver::collectModelInfo\n";
+ Debug("bitvector-model") << "AlgebraicSolver::collectModelValues\n";
AlwaysAssert(!d_quickSolver->inConflict());
- set<Node> termSet;
- const std::set<Kind>& irrKinds = model->getIrrelevantKinds();
- d_bv->computeAssertedTerms(termSet, irrKinds, true);
// collect relevant terms that the bv theory abstracts to variables
// (variables and parametric terms such as select apply_uf)
for (NodeSet::const_iterator it = leaf_vars.begin(); it != leaf_vars.end(); ++it) {
TNode var = *it;
Node value = d_quickSolver->getVarValue(var, true);
- Assert(!value.isNull() || !fullModel);
+ Assert(!value.isNull());
// may be a shared term that did not appear in the current assertions
// AJR: need to check whether already in map for cases where collectModelInfo is called multiple times in the same context
Unreachable() << "AlgebraicSolver does not propagate.\n";
}
EqualityStatus getEqualityStatus(TNode a, TNode b) override;
- bool collectModelInfo(TheoryModel* m, bool fullModel) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
Node getModelValue(TNode node) override;
bool isComplete() override;
void assertFact(TNode fact) override;
return d_bitblaster->getEqualityStatus(a, b);
}
-bool BitblastSolver::collectModelInfo(TheoryModel* m, bool fullModel)
+bool BitblastSolver::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
- return d_bitblaster->collectModelInfo(m, fullModel);
+ return d_bitblaster->collectModelValues(m, termSet);
}
Node BitblastSolver::getModelValue(TNode node)
return val;
}
-
-
-void BitblastSolver::setConflict(TNode conflict) {
+void BitblastSolver::setConflict(TNode conflict)
+{
Node final_conflict = conflict;
if (options::bitvectorQuickXplain() &&
conflict.getKind() == kind::AND) {
bool check(Theory::Effort e) override;
void explain(TNode literal, std::vector<TNode>& assumptions) override;
EqualityStatus getEqualityStatus(TNode a, TNode b) override;
- bool collectModelInfo(TheoryModel* m, bool fullModel) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
Node getModelValue(TNode node) override;
bool isComplete() override { return true; }
void bitblastQueue();
bool CoreSolver::assertFactToEqualityEngine(TNode fact, TNode reason) {
// Notify the equality engine
- if (!d_bv->inConflict() && (!d_bv->wasPropagatedBySubtheory(fact) || d_bv->getPropagatingSubtheory(fact) != SUB_CORE)) {
+ if (!d_bv->inConflict()
+ && (!d_bv->wasPropagatedBySubtheory(fact)
+ || d_bv->getPropagatingSubtheory(fact) != SUB_CORE))
+ {
Debug("bv-slicer-eq") << "CoreSolver::assertFactToEqualityEngine fact=" << fact << endl;
// Debug("bv-slicer-eq") << " reason=" << reason << endl;
bool negated = fact.getKind() == kind::NOT;
}
// checking for a conflict
- if (d_bv->inConflict()) {
+ if (d_bv->inConflict())
+ {
return false;
}
return true;
return utils::isEqualityTerm(term, seen);
}
-bool CoreSolver::collectModelInfo(TheoryModel* m, bool fullModel)
+bool CoreSolver::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
if (Debug.isOn("bitvector-model")) {
context::CDQueue<Node>::const_iterator it = d_assertionQueue.begin();
for (; it!= d_assertionQueue.end(); ++it) {
- Debug("bitvector-model") << "CoreSolver::collectModelInfo (assert "
- << *it << ")\n";
+ Debug("bitvector-model")
+ << "CoreSolver::collectModelValues (assert " << *it << ")\n";
}
}
- set<Node> termSet;
- const std::set<Kind>& irrKinds = m->getIrrelevantKinds();
- d_bv->computeAssertedTerms(termSet, irrKinds, true);
- if (!m->assertEqualityEngine(d_equalityEngine, &termSet))
- {
- return false;
- }
if (isComplete()) {
- Debug("bitvector-model") << "CoreSolver::collectModelInfo complete.";
+ Debug("bitvector-model") << "CoreSolver::collectModelValues complete.";
for (ModelValue::const_iterator it = d_modelValues.begin(); it != d_modelValues.end(); ++it) {
Node a = it->first;
Node b = it->second;
- Debug("bitvector-model") << "CoreSolver::collectModelInfo modelValues "
- << a << " => " << b <<")\n";
+ Debug("bitvector-model") << "CoreSolver::collectModelValues modelValues "
+ << a << " => " << b << ")\n";
if (!m->assertEquality(a, b, true))
{
return false;
return result;
}
-void CoreSolver::addSharedTerm(TNode t)
-{
- d_equalityEngine->addTriggerTerm(t, THEORY_BV);
-}
-
EqualityStatus CoreSolver::getEqualityStatus(TNode a, TNode b)
{
if (d_equalityEngine->areEqual(a, b))
ModelValue d_modelValues;
void buildModel();
bool assertFactToEqualityEngine(TNode fact, TNode reason);
- bool decomposeFact(TNode fact);
- Node getBaseDecomposition(TNode a);
bool isCompleteForTerm(TNode term, TNodeBoolMap& seen);
Statistics d_statistics;
void preRegister(TNode node) override;
bool check(Theory::Effort e) override;
void explain(TNode literal, std::vector<TNode>& assumptions) override;
- bool collectModelInfo(TheoryModel* m, bool fullModel) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
Node getModelValue(TNode var) override;
- void addSharedTerm(TNode t) override;
EqualityStatus getEqualityStatus(TNode a, TNode b) override;
bool hasTerm(TNode node) const;
void addTermToEqualityEngine(TNode node);
}
void InequalitySolver::propagate(Theory::Effort e) { Assert(false); }
-bool InequalitySolver::collectModelInfo(TheoryModel* m, bool fullModel)
+bool InequalitySolver::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
{
- Debug("bitvector-model") << "InequalitySolver::collectModelInfo \n";
+ Debug("bitvector-model") << "InequalitySolver::collectModelValues \n";
std::vector<Node> model;
d_inequalityGraph.getAllValuesInModel(model);
for (unsigned i = 0; i < model.size(); ++i) {
void propagate(Theory::Effort e) override;
void explain(TNode literal, std::vector<TNode>& assumptions) override;
bool isComplete() override { return d_isComplete; }
- bool collectModelInfo(TheoryModel* m, bool fullModel) override;
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
Node getModelValue(TNode var) override;
EqualityStatus getEqualityStatus(TNode a, TNode b) override;
void assertFact(TNode fact) override;
return d_internal->needsCheckLastEffort();
}
-bool TheoryBV::collectModelInfo(TheoryModel* m)
+bool TheoryBV::collectModelValues(TheoryModel* m, const std::set<Node>& termSet)
{
- return d_internal->collectModelInfo(m);
+ return d_internal->collectModelValues(m, termSet);
}
void TheoryBV::propagate(Effort e) { return d_internal->propagate(e); }
TrustNode TheoryBV::explain(TNode node) { return d_internal->explain(node); }
-void TheoryBV::notifySharedTerm(TNode t) { d_internal->notifySharedTerm(t); };
+void TheoryBV::notifySharedTerm(TNode t)
+{
+ d_internal->notifySharedTerm(t);
+ // temporary, will be built into Theory::addSharedTerm
+ if (d_equalityEngine != nullptr)
+ {
+ d_equalityEngine->addTriggerTerm(t, THEORY_BV);
+ }
+}
void TheoryBV::ppStaticLearn(TNode in, NodeBuilder<>& learned)
{
TrustNode explain(TNode n) override;
- bool collectModelInfo(TheoryModel* m) override;
+ /** Collect model values in m based on the relevant terms given by termSet */
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
std::string identify() const override { return std::string("TheoryBV"); }