, solves(0), starts(0), decisions(0), rnd_decisions(0), propagations(0), conflicts(0)
, dec_vars(0), clauses_literals(0), learnts_literals(0), max_literals(0), tot_literals(0)
+ , need_to_propagate(false)
, only_bcp(false)
, clause_added(false)
, ok (true)
else if (ps.size() == 1){
uncheckedEnqueue(ps[0]);
return ok = (propagate() == CRef_Undef);
- }else{
+ } else {
CRef cr = ca.alloc(ps, false);
clauses.push(cr);
attachClause(cr);
}
-
- return true;
+ return ok;
}
void Solver::attachClause(CRef cr) {
}
lbool Solver::assertAssumption(Lit p, bool propagate) {
-
- assert(marker[var(p)] == 1);
+
+ // assert(marker[var(p)] == 1);
if (decisionLevel() > assumptions.size()) {
cancelUntil(assumptions.size());
analyzeFinal(p, conflict);
return l_False;
}
-
+
varDecayActivity();
claDecayActivity();
//
void Solver::explain(Lit p, std::vector<Lit>& explanation) {
-
vec<Lit> queue;
queue.push(p);
: Theory(THEORY_BV, c, u, out, valuation, logicInfo),
d_context(c),
d_assertions(c),
+ d_bitblastQueue(c),
d_bitblaster(new Bitblaster(c, this) ),
d_alreadyPropagatedSet(c),
d_sharedTermsSet(c),
return;
}
- if (node.getKind() == kind::EQUAL ||
- node.getKind() == kind::BITVECTOR_ULT ||
- node.getKind() == kind::BITVECTOR_ULE ||
- node.getKind() == kind::BITVECTOR_SLT ||
- node.getKind() == kind::BITVECTOR_SLE) {
- d_bitblaster->bbAtom(node);
+ if ((node.getKind() == kind::EQUAL ||
+ node.getKind() == kind::BITVECTOR_ULT ||
+ node.getKind() == kind::BITVECTOR_ULE ||
+ node.getKind() == kind::BITVECTOR_SLT ||
+ node.getKind() == kind::BITVECTOR_SLE) &&
+ !d_bitblaster->hasBBAtom(node)) {
+ d_bitblastQueue.push_back(node);
}
if (d_useEqualityEngine) {
return;
}
+ // getting the new assertions
+
+ std::vector<TNode> new_assertions;
while (!done() && !d_conflict) {
Assertion assertion = get();
TNode fact = assertion.assertion;
-
+ new_assertions.push_back(fact);
BVDebug("bitvector-assertions") << "TheoryBV::check assertion " << fact << "\n";
+ }
+
+ // sending assertions to equality engine first
+
+ for (unsigned i = 0; i < new_assertions.size(); ++i) {
+ TNode fact = new_assertions[i];
+ TypeNode factType = fact[0].getType();
// Notify the equality engine
if (d_useEqualityEngine && !d_conflict && !propagatedBy(fact, SUB_EQUALITY) ) {
}
}
- // Bit-blaster
+ // checking for a conflict
+ if (d_conflict) {
+ BVDebug("bitvector") << indent() << "TheoryBV::check(): conflict " << d_conflictNode;
+ d_out->conflict(d_conflictNode);
+ return;
+ }
+ }
+
+ // bit-blasting atoms on queue
+
+ for (unsigned i = 0; i < d_bitblastQueue.size(); ++i) {
+ d_bitblaster->bbAtom(d_bitblastQueue[i]);
+ // would be nice to clear the bitblastQueue?
+ }
+
+ // bit-blaster propagation
+ for (unsigned i = 0; i < new_assertions.size(); ++i) {
+ TNode fact = new_assertions[i];
if (!d_conflict && !propagatedBy(fact, SUB_BITBLASTER)) {
// Some atoms have not been bit-blasted yet
d_bitblaster->bbAtom(fact);
// If in conflict, output the conflict
if (d_conflict) {
- BVDebug("bitvector") << spaces(getSatContext()->getLevel()) << "TheoryBV::check(): conflict " << d_conflictNode;
+ BVDebug("bitvector") << indent() << "TheoryBV::check(): conflict " << d_conflictNode;
d_out->conflict(d_conflictNode);
return;
}
void TheoryBV::propagate(Effort e) {
- BVDebug("bitvector") << spaces(getSatContext()->getLevel()) << "TheoryBV::propagate()" << std::endl;
+ BVDebug("bitvector") << indent() << "TheoryBV::propagate()" << std::endl;
if (d_conflict) {
return;
// check if we already propagated the negation
Node negLiteral = literal.getKind() == kind::NOT ? (Node)literal[0] : mkNot(literal);
if (d_alreadyPropagatedSet.find(negLiteral) != d_alreadyPropagatedSet.end()) {
- Debug("bitvector") << spaces(getSatContext()->getLevel()) << "TheoryBV::propagate(): in conflict " << literal << " and its negation both propagated \n";
+ Debug("bitvector") << indent() << "TheoryBV::propagate(): in conflict " << literal << " and its negation both propagated \n";
// we are in conflict
std::vector<TNode> assumptions;
explain(literal, assumptions);
return;
}
- BVDebug("bitvector") << spaces(getSatContext()->getLevel()) << "TheoryBV::propagate(): " << literal << std::endl;
+ BVDebug("bitvector") << indent() << "TheoryBV::propagate(): " << literal << std::endl;
d_out->propagate(literal);
d_alreadyPropagatedSet.insert(literal);
} else {
- Debug("bitvector") << spaces(getSatContext()->getLevel()) << "TheoryBV::propagate(): in conflict, normalized = " << normalized << std::endl;
+ Debug("bitvector") << indent() << "TheoryBV::propagate(): in conflict, normalized = " << normalized << std::endl;
Node negatedLiteral;
std::vector<TNode> assumptions;
bool TheoryBV::storePropagation(TNode literal, SubTheory subtheory)
{
- Debug("bitvector") << spaces(getSatContext()->getLevel()) << "TheoryBV::storePropagation(" << literal << ")" << std::endl;
+ Debug("bitvector") << indent() << "TheoryBV::storePropagation(" << literal << ")" << std::endl;
// If already in conflict, no more propagation
if (d_conflict) {
- Debug("bitvector") << spaces(getSatContext()->getLevel()) << "TheoryBV::storePropagation(" << literal << "): already in conflict" << std::endl;
+ Debug("bitvector") << indent() << "TheoryBV::storePropagation(" << literal << "): already in conflict" << std::endl;
return false;
}
// If asserted, we might be in conflict
if (hasSatValue && !satValue) {
- Debug("bitvector-prop") << spaces(getSatContext()->getLevel()) << "TheoryBV::storePropagation(" << literal << ") => conflict" << std::endl;
+ Debug("bitvector-prop") << indent() << "TheoryBV::storePropagation(" << literal << ") => conflict" << std::endl;
std::vector<TNode> assumptions;
Node negatedLiteral = literal.getKind() == kind::NOT ? (Node) literal[0] : literal.notNode();
assumptions.push_back(negatedLiteral);
}
// Nothing, just enqueue it for propagation and mark it as asserted already
- Debug("bitvector-prop") << spaces(getSatContext()->getLevel()) << "TheoryBV::storePropagation(" << literal << ") => enqueuing for propagation" << std::endl;
+ Debug("bitvector-prop") << indent() << "TheoryBV::storePropagation(" << literal << ") => enqueuing for propagation" << std::endl;
d_literalsToPropagate.push_back(literal);
// No conflict
void TheoryBV::addSharedTerm(TNode t) {
- Debug("bitvector::sharing") << spaces(getSatContext()->getLevel()) << "TheoryBV::addSharedTerm(" << t << ")" << std::endl;
+ Debug("bitvector::sharing") << indent() << "TheoryBV::addSharedTerm(" << t << ")" << std::endl;
d_sharedTermsSet.insert(t);
if (!Options::current()->bitvectorEagerBitblast && d_useEqualityEngine) {
d_equalityEngine.addTriggerTerm(t);
/// forward declarations
class Bitblaster;
-static inline std::string spaces(int level)
-{
- std::string indentStr(level, ' ');
- return indentStr;
-}
-
class TheoryBV : public Theory {
/** Bitblaster */
Bitblaster* d_bitblaster;
-
+
+ context::CDList<TNode> d_bitblastQueue;
+
/** Context dependent set of atoms we already propagated */
context::CDHashSet<TNode, TNodeHashFunction> d_alreadyPropagatedSet;
context::CDHashSet<TNode, TNodeHashFunction> d_sharedTermsSet;
if (value) {
return d_bv.storePropagation(predicate, SUB_EQUALITY);
} else {
- return d_bv.storePropagation(predicate, SUB_EQUALITY);
+ return d_bv.storePropagation(predicate.notNode(), SUB_EQUALITY);
}
}
bool eqNotifyConstantTermMerge(TNode t1, TNode t2) {
Debug("bitvector") << "NotifyClass::eqNotifyConstantTermMerge(" << t1 << ", " << t2 << std::endl;
+ if (Theory::theoryOf(t1) == THEORY_BOOL) {
+ return d_bv.storePropagation(t1.iffNode(t2), SUB_EQUALITY);
+ }
return d_bv.storePropagation(t1.eqNode(t2), SUB_EQUALITY);
}
};
friend class Bitblaster;
+ inline std::string indent()
+ {
+ std::string indentStr(getSatContext()->getLevel(), ' ');
+ return indentStr;
+ }
+
public:
void propagate(Effort e);