For model construction we only compute model values for relevant terms. The set of relevant terms is computed in https://github.com/cvc5/cvc5/blob/master/src/theory/model_manager_distributed.cpp#L58, which skips equalities by default because equalities are usually handled by the equality engine.
When --bitblast=eager is enabled all assertions are wrapped into BITVECTOR_EAGER_ATOM nodes and passed to the BV solver, which results in equalities below BITVECTOR_EAGER_ATOM nodes not being handled by the equality engine but by the BV solver directly. These equalities, however, are skipped when computing the relevant terms and therefore the BV solver is not asked to compute model values for variables below these equalities.
If --bitblast=eager is enabled the BV solver now additionally adds the variables encountered during bit-blasting to the relevant terms via computeRelevantTerms.
Co-authored-by: Andres Noetzli <andres.noetzli@gmail.com>
#include "theory/theory_model.h"
#include "theory/theory_state.h"
+#include "options/bv_options.h"
namespace cvc5 {
namespace theory {
return utils::mkConst(bits.size(), value);
}
+void BBSimple::computeRelevantTerms(std::set<Node>& termSet)
+{
+ Assert(options::bitblastMode() == options::BitblastMode::EAGER);
+ for (const auto& var : d_variables)
+ {
+ termSet.insert(var);
+ }
+}
+
bool BBSimple::collectModelValues(TheoryModel* m,
const std::set<Node>& relevantTerms)
{
/** Create 'bits' for variable 'var'. */
void makeVariable(TNode var, Bits& bits) override;
+ /** Add d_variables to termSet. */
+ void computeRelevantTerms(std::set<Node>& termSet);
/** Collect model values for all relevant terms given in 'relevantTerms'. */
bool collectModelValues(TheoryModel* m, const std::set<Node>& relevantTerms);
BVSolver(TheoryState& state, TheoryInferenceManager& inferMgr)
: d_state(state), d_im(inferMgr){};
- virtual ~BVSolver(){};
+ virtual ~BVSolver() {}
/**
* Returns true if we need an equality engine. If so, we initialize the
virtual bool needsCheckLastEffort() { return false; }
- virtual void propagate(Theory::Effort e){};
+ virtual void propagate(Theory::Effort e) {}
virtual TrustNode explain(TNode n)
{
return TrustNode::null();
}
+ /** Additionally collect terms relevant for collecting model values. */
+ virtual void computeRelevantTerms(std::set<Node>& termSet) {}
+
/** 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 TrustNode ppRewrite(TNode t) { return TrustNode::null(); };
+ virtual TrustNode ppRewrite(TNode t) { return TrustNode::null(); }
- virtual void ppStaticLearn(TNode in, NodeBuilder& learned){};
+ virtual void ppStaticLearn(TNode in, NodeBuilder& learned) {}
- virtual void presolve(){};
+ virtual void presolve() {}
virtual void notifySharedTerm(TNode t) {}
return d_im.explainLit(n);
}
+void BVSolverBitblast::computeRelevantTerms(std::set<Node>& termSet)
+{
+ /* BITVECTOR_EAGER_ATOM wraps input assertions that may also contain
+ * equalities. As a result, these equalities are not handled by the equality
+ * engine and terms below these equalities do not appear in `termSet`.
+ * We need to make sure that we compute model values for all relevant terms
+ * in BitblastMode::EAGER and therefore add all variables from the
+ * bit-blaster to `termSet`.
+ */
+ if (options::bitblastMode() == options::BitblastMode::EAGER)
+ {
+ d_bitblaster->computeRelevantTerms(termSet);
+ }
+}
+
bool BVSolverBitblast::collectModelValues(TheoryModel* m,
const std::set<Node>& termSet)
{
EqualityStatus getEqualityStatus(TNode a, TNode b) override;
+ void computeRelevantTerms(std::set<Node>& termSet) override;
+
bool collectModelValues(TheoryModel* m,
const std::set<Node>& termSet) override;
return d_internal->needsCheckLastEffort();
}
+void TheoryBV::computeRelevantTerms(std::set<Node>& termSet)
+{
+ return d_internal->computeRelevantTerms(termSet);
+}
+
bool TheoryBV::collectModelValues(TheoryModel* m, const std::set<Node>& termSet)
{
return d_internal->collectModelValues(m, termSet);
TrustNode explain(TNode n) override;
+ void computeRelevantTerms(std::set<Node>& termSet) override;
+
/** Collect model values in m based on the relevant terms given by termSet */
bool collectModelValues(TheoryModel* m,
const std::set<Node>& termSet) override;
regress0/issue5743.smt2
regress0/issue5947.smt2
regress0/issue6605-2-abd-triv.smt2
+ regress0/issue6741.smt2
regress0/ite_arith.smt2
regress0/ite_real_int_type.smtv1.smt2
regress0/ite_real_valid.smtv1.smt2
--- /dev/null
+; COMMAND-LINE: --bv-solver=bitblast --bitblast=eager --check-models
+(set-logic QF_BV)
+(set-info :status sat)
+(declare-fun x () (_ BitVec 1))
+(declare-fun y () (_ BitVec 1))
+(assert (= y (ite (= x (_ bv1 1)) (_ bv1 1) (_ bv0 1))))
+(assert (= y (_ bv1 1)))
+(check-sat)