theory/bv/bv_solver.h
theory/bv/bv_solver_bitblast.cpp
theory/bv/bv_solver_bitblast.h
+ theory/bv/bv_solver_bitblast_internal.cpp
+ theory/bv/bv_solver_bitblast_internal.h
theory/bv/bv_solver_lazy.cpp
theory/bv/bv_solver_lazy.h
- theory/bv/bv_solver_simple.cpp
- theory/bv/bv_solver_simple.h
theory/bv/bv_subtheory.h
theory/bv/bv_subtheory_algebraic.cpp
theory/bv/bv_subtheory_algebraic.h
[[option.mode.LAZY]]
name = "lazy"
help = "Enables the lazy BV solver infrastructure."
-[[option.mode.SIMPLE]]
- name = "simple"
- help = "Enables simple bitblasting solver with proof support."
+[[option.mode.BITBLAST_INTERNAL]]
+ name = "bitblast-internal"
+ help = "Enables bitblasting to internal SAT solver with proof support."
[[option]]
name = "bvAssertInput"
--- /dev/null
+/******************************************************************************
+ * Top contributors (to current version):
+ * Mathias Preiner, Gereon Kremer, Haniel Barbosa
+ *
+ * This file is part of the cvc5 project.
+ *
+ * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
+ * in the top-level source directory and their institutional affiliations.
+ * All rights reserved. See the file COPYING in the top-level source
+ * directory for licensing information.
+ * ****************************************************************************
+ *
+ * Bit-blast solver that sends bit-blast lemmas directly to the internal
+ * MiniSat.
+ */
+
+#include "theory/bv/bv_solver_bitblast_internal.h"
+
+#include "proof/conv_proof_generator.h"
+#include "theory/bv/theory_bv.h"
+#include "theory/bv/theory_bv_utils.h"
+#include "theory/theory_model.h"
+
+namespace cvc5 {
+namespace theory {
+namespace bv {
+
+/* -------------------------------------------------------------------------- */
+
+namespace {
+
+bool isBVAtom(TNode n)
+{
+ return (n.getKind() == kind::EQUAL && n[0].getType().isBitVector())
+ || n.getKind() == kind::BITVECTOR_ULT
+ || n.getKind() == kind::BITVECTOR_ULE
+ || n.getKind() == kind::BITVECTOR_SLT
+ || n.getKind() == kind::BITVECTOR_SLE;
+}
+
+/* Traverse Boolean nodes and collect BV atoms. */
+void collectBVAtoms(TNode n, std::unordered_set<Node>& atoms)
+{
+ std::vector<TNode> visit;
+ std::unordered_set<TNode> visited;
+
+ visit.push_back(n);
+
+ do
+ {
+ TNode cur = visit.back();
+ visit.pop_back();
+
+ if (visited.find(cur) != visited.end() || !cur.getType().isBoolean())
+ continue;
+
+ visited.insert(cur);
+ if (isBVAtom(cur))
+ {
+ atoms.insert(cur);
+ continue;
+ }
+
+ visit.insert(visit.end(), cur.begin(), cur.end());
+ } while (!visit.empty());
+}
+
+} // namespace
+
+BVSolverBitblastInternal::BVSolverBitblastInternal(
+ TheoryState* s, TheoryInferenceManager& inferMgr, ProofNodeManager* pnm)
+ : BVSolver(*s, inferMgr),
+ d_pnm(pnm),
+ d_bitblaster(new BBProof(s, pnm, false))
+{
+}
+
+void BVSolverBitblastInternal::addBBLemma(TNode fact)
+{
+ if (!d_bitblaster->hasBBAtom(fact))
+ {
+ d_bitblaster->bbAtom(fact);
+ }
+ NodeManager* nm = NodeManager::currentNM();
+
+ Node atom_bb = d_bitblaster->getStoredBBAtom(fact);
+ Node lemma = nm->mkNode(kind::EQUAL, fact, atom_bb);
+
+ if (d_pnm == nullptr)
+ {
+ d_im.lemma(lemma, InferenceId::BV_BITBLAST_INTERNAL_BITBLAST_LEMMA);
+ }
+ else
+ {
+ TrustNode tlem =
+ TrustNode::mkTrustLemma(lemma, d_bitblaster->getProofGenerator());
+ d_im.trustedLemma(tlem, InferenceId::BV_BITBLAST_INTERNAL_BITBLAST_LEMMA);
+ }
+}
+
+bool BVSolverBitblastInternal::preNotifyFact(
+ TNode atom, bool pol, TNode fact, bool isPrereg, bool isInternal)
+{
+ if (fact.getKind() == kind::NOT)
+ {
+ fact = fact[0];
+ }
+
+ if (isBVAtom(fact))
+ {
+ addBBLemma(fact);
+ }
+ else if (fact.getKind() == kind::BITVECTOR_EAGER_ATOM)
+ {
+ TNode n = fact[0];
+
+ NodeManager* nm = NodeManager::currentNM();
+ Node lemma = nm->mkNode(kind::EQUAL, fact, n);
+
+ if (d_pnm == nullptr)
+ {
+ d_im.lemma(lemma, InferenceId::BV_BITBLAST_INTERNAL_EAGER_LEMMA);
+ }
+ else
+ {
+ d_bitblaster->getProofGenerator()->addRewriteStep(
+ fact, n, PfRule::BV_EAGER_ATOM, {}, {fact});
+ TrustNode tlem =
+ TrustNode::mkTrustLemma(lemma, d_bitblaster->getProofGenerator());
+ d_im.trustedLemma(tlem, InferenceId::BV_BITBLAST_INTERNAL_EAGER_LEMMA);
+ }
+
+ std::unordered_set<Node> bv_atoms;
+ collectBVAtoms(n, bv_atoms);
+ for (const Node& nn : bv_atoms)
+ {
+ addBBLemma(nn);
+ }
+ }
+
+ return true;
+}
+
+bool BVSolverBitblastInternal::collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet)
+{
+ return d_bitblaster->collectModelValues(m, termSet);
+}
+
+BVProofRuleChecker* BVSolverBitblastInternal::getProofChecker()
+{
+ return &d_checker;
+}
+
+} // namespace bv
+} // namespace theory
+} // namespace cvc5
--- /dev/null
+/******************************************************************************
+ * Top contributors (to current version):
+ * Mathias Preiner, Haniel Barbosa, Andrew Reynolds
+ *
+ * This file is part of the cvc5 project.
+ *
+ * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
+ * in the top-level source directory and their institutional affiliations.
+ * All rights reserved. See the file COPYING in the top-level source
+ * directory for licensing information.
+ * ****************************************************************************
+ *
+ * Bit-blast solver that sends bit-blast lemmas directly to the internal
+ * MiniSat.
+ */
+
+#include "cvc5_private.h"
+
+#ifndef CVC5__THEORY__BV__BV_SOLVER_BITBLAST_INTERNAL_H
+#define CVC5__THEORY__BV__BV_SOLVER_BITBLAST_INTERNAL_H
+
+#include "theory/bv/bitblast/proof_bitblaster.h"
+#include "theory/bv/bv_solver.h"
+#include "theory/bv/proof_checker.h"
+
+namespace cvc5 {
+namespace theory {
+namespace bv {
+
+/**
+ * Bit-blasting solver that sends bit-blasting lemmas directly to the
+ * internal MiniSat. It is also ablo to handle atoms of kind
+ * BITVECTOR_EAGER_ATOM.
+ *
+ * Sends lemmas atom <=> bb(atom) to MiniSat on preNotifyFact().
+ */
+class BVSolverBitblastInternal : public BVSolver
+{
+ public:
+ BVSolverBitblastInternal(TheoryState* state,
+ TheoryInferenceManager& inferMgr,
+ ProofNodeManager* pnm);
+ ~BVSolverBitblastInternal() = default;
+
+ void preRegisterTerm(TNode n) override {}
+
+ bool preNotifyFact(TNode atom,
+ bool pol,
+ TNode fact,
+ bool isPrereg,
+ bool isInternal) override;
+
+ std::string identify() const override { return "BVSolverBitblastInternal"; };
+
+ bool collectModelValues(TheoryModel* m,
+ const std::set<Node>& termSet) override;
+
+ /** get the proof checker of this theory */
+ BVProofRuleChecker* getProofChecker();
+
+ private:
+ /**
+ * Sends a bit-blasting lemma fact <=> d_bitblaster.bbAtom(fact) to the
+ * inference manager.
+ */
+ void addBBLemma(TNode fact);
+
+ /** Proof node manager. */
+ ProofNodeManager* d_pnm;
+ /** Bit-blaster used to bit-blast atoms/terms. */
+ std::unique_ptr<BBProof> d_bitblaster;
+ /** Proof rule checker */
+ BVProofRuleChecker d_checker;
+};
+
+} // namespace bv
+} // namespace theory
+} // namespace cvc5
+
+#endif
+++ /dev/null
-/******************************************************************************
- * Top contributors (to current version):
- * Mathias Preiner, Gereon Kremer, Haniel Barbosa
- *
- * This file is part of the cvc5 project.
- *
- * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
- * in the top-level source directory and their institutional affiliations.
- * All rights reserved. See the file COPYING in the top-level source
- * directory for licensing information.
- * ****************************************************************************
- *
- * Simple bit-blast solver that sends bitblast lemmas directly to MiniSat.
- */
-
-#include "theory/bv/bv_solver_simple.h"
-
-#include "proof/conv_proof_generator.h"
-#include "theory/bv/theory_bv.h"
-#include "theory/bv/theory_bv_utils.h"
-#include "theory/theory_model.h"
-
-namespace cvc5 {
-namespace theory {
-namespace bv {
-
-/* -------------------------------------------------------------------------- */
-
-namespace {
-
-bool isBVAtom(TNode n)
-{
- return (n.getKind() == kind::EQUAL && n[0].getType().isBitVector())
- || n.getKind() == kind::BITVECTOR_ULT
- || n.getKind() == kind::BITVECTOR_ULE
- || n.getKind() == kind::BITVECTOR_SLT
- || n.getKind() == kind::BITVECTOR_SLE;
-}
-
-/* Traverse Boolean nodes and collect BV atoms. */
-void collectBVAtoms(TNode n, std::unordered_set<Node>& atoms)
-{
- std::vector<TNode> visit;
- std::unordered_set<TNode> visited;
-
- visit.push_back(n);
-
- do
- {
- TNode cur = visit.back();
- visit.pop_back();
-
- if (visited.find(cur) != visited.end() || !cur.getType().isBoolean())
- continue;
-
- visited.insert(cur);
- if (isBVAtom(cur))
- {
- atoms.insert(cur);
- continue;
- }
-
- visit.insert(visit.end(), cur.begin(), cur.end());
- } while (!visit.empty());
-}
-
-} // namespace
-
-BVSolverSimple::BVSolverSimple(TheoryState* s,
- TheoryInferenceManager& inferMgr,
- ProofNodeManager* pnm)
- : BVSolver(*s, inferMgr),
- d_pnm(pnm),
- d_bitblaster(new BBProof(s, pnm, false))
-{
-}
-
-void BVSolverSimple::addBBLemma(TNode fact)
-{
- if (!d_bitblaster->hasBBAtom(fact))
- {
- d_bitblaster->bbAtom(fact);
- }
- NodeManager* nm = NodeManager::currentNM();
-
- Node atom_bb = d_bitblaster->getStoredBBAtom(fact);
- Node lemma = nm->mkNode(kind::EQUAL, fact, atom_bb);
-
- if (d_pnm == nullptr)
- {
- d_im.lemma(lemma, InferenceId::BV_SIMPLE_BITBLAST_LEMMA);
- }
- else
- {
- TrustNode tlem =
- TrustNode::mkTrustLemma(lemma, d_bitblaster->getProofGenerator());
- d_im.trustedLemma(tlem, InferenceId::BV_SIMPLE_BITBLAST_LEMMA);
- }
-}
-
-bool BVSolverSimple::preNotifyFact(
- TNode atom, bool pol, TNode fact, bool isPrereg, bool isInternal)
-{
- if (fact.getKind() == kind::NOT)
- {
- fact = fact[0];
- }
-
- if (isBVAtom(fact))
- {
- addBBLemma(fact);
- }
- else if (fact.getKind() == kind::BITVECTOR_EAGER_ATOM)
- {
- TNode n = fact[0];
-
- NodeManager* nm = NodeManager::currentNM();
- Node lemma = nm->mkNode(kind::EQUAL, fact, n);
-
- if (d_pnm == nullptr)
- {
- d_im.lemma(lemma, InferenceId::BV_SIMPLE_LEMMA);
- }
- else
- {
- d_bitblaster->getProofGenerator()->addRewriteStep(
- fact, n, PfRule::BV_EAGER_ATOM, {}, {fact});
- TrustNode tlem =
- TrustNode::mkTrustLemma(lemma, d_bitblaster->getProofGenerator());
- d_im.trustedLemma(tlem, InferenceId::BV_SIMPLE_LEMMA);
- }
-
- std::unordered_set<Node> bv_atoms;
- collectBVAtoms(n, bv_atoms);
- for (const Node& nn : bv_atoms)
- {
- addBBLemma(nn);
- }
- }
-
- return true;
-}
-
-bool BVSolverSimple::collectModelValues(TheoryModel* m,
- const std::set<Node>& termSet)
-{
- return d_bitblaster->collectModelValues(m, termSet);
-}
-
-BVProofRuleChecker* BVSolverSimple::getProofChecker() { return &d_checker; }
-
-} // namespace bv
-} // namespace theory
-} // namespace cvc5
+++ /dev/null
-/******************************************************************************
- * Top contributors (to current version):
- * Mathias Preiner, Haniel Barbosa, Andrew Reynolds
- *
- * This file is part of the cvc5 project.
- *
- * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
- * in the top-level source directory and their institutional affiliations.
- * All rights reserved. See the file COPYING in the top-level source
- * directory for licensing information.
- * ****************************************************************************
- *
- * Simple bit-blast solver that sends bit-blast lemmas directly to MiniSat.
- */
-
-#include "cvc5_private.h"
-
-#ifndef CVC5__THEORY__BV__BV_SOLVER_SIMPLE_H
-#define CVC5__THEORY__BV__BV_SOLVER_SIMPLE_H
-
-#include "theory/bv/bitblast/proof_bitblaster.h"
-#include "theory/bv/bv_solver.h"
-#include "theory/bv/proof_checker.h"
-
-namespace cvc5 {
-
-class TConvProofGenerator;
-
-namespace theory {
-namespace bv {
-
-/**
- * Simple bit-blasting solver that sends bit-blasting lemmas directly to the
- * internal MiniSat. It is also ablo to handle atoms of kind
- * BITVECTOR_EAGER_ATOM.
- *
- * Sends lemmas atom <=> bb(atom) to MiniSat on preNotifyFact().
- */
-class BVSolverSimple : public BVSolver
-{
- public:
- BVSolverSimple(TheoryState* state,
- TheoryInferenceManager& inferMgr,
- ProofNodeManager* pnm);
- ~BVSolverSimple() = default;
-
- void preRegisterTerm(TNode n) override {}
-
- bool preNotifyFact(TNode atom,
- bool pol,
- TNode fact,
- bool isPrereg,
- bool isInternal) override;
-
- std::string identify() const override { return "BVSolverSimple"; };
-
- bool collectModelValues(TheoryModel* m,
- const std::set<Node>& termSet) override;
-
- /** get the proof checker of this theory */
- BVProofRuleChecker* getProofChecker();
-
- private:
- /**
- * Sends a bit-blasting lemma fact <=> d_bitblaster.bbAtom(fact) to the
- * inference manager.
- */
- void addBBLemma(TNode fact);
-
- /** Proof node manager. */
- ProofNodeManager* d_pnm;
- /** Bit-blaster used to bit-blast atoms/terms. */
- std::unique_ptr<BBProof> d_bitblaster;
- /** Proof rule checker */
- BVProofRuleChecker d_checker;
-};
-
-} // namespace bv
-} // namespace theory
-} // namespace cvc5
-
-#endif
#include "proof/proof_checker.h"
#include "smt/smt_statistics_registry.h"
#include "theory/bv/bv_solver_bitblast.h"
+#include "theory/bv/bv_solver_bitblast_internal.h"
#include "theory/bv/bv_solver_lazy.h"
-#include "theory/bv/bv_solver_simple.h"
#include "theory/bv/theory_bv_utils.h"
#include "theory/ee_setup_info.h"
#include "theory/trust_substitutions.h"
break;
default:
- AlwaysAssert(options::bvSolver() == options::BVSolver::SIMPLE);
- d_internal.reset(new BVSolverSimple(&d_state, d_im, pnm));
+ AlwaysAssert(options::bvSolver() == options::BVSolver::BITBLAST_INTERNAL);
+ d_internal.reset(new BVSolverBitblastInternal(&d_state, d_im, pnm));
}
d_theoryState = &d_state;
d_inferManager = &d_im;
ProofRuleChecker* TheoryBV::getProofChecker()
{
- if (options::bvSolver() == options::BVSolver::SIMPLE)
+ if (options::bvSolver() == options::BVSolver::BITBLAST_INTERNAL)
{
- return static_cast<BVSolverSimple*>(d_internal.get())->getProofChecker();
+ return static_cast<BVSolverBitblastInternal*>(d_internal.get())
+ ->getProofChecker();
}
return nullptr;
}
case InferenceId::BV_BITBLAST_CONFLICT: return "BV_BITBLAST_CONFLICT";
case InferenceId::BV_LAZY_CONFLICT: return "BV_LAZY_CONFLICT";
case InferenceId::BV_LAZY_LEMMA: return "BV_LAZY_LEMMA";
- case InferenceId::BV_SIMPLE_LEMMA: return "BV_SIMPLE_LEMMA";
- case InferenceId::BV_SIMPLE_BITBLAST_LEMMA: return "BV_SIMPLE_BITBLAST_LEMMA";
+ case InferenceId::BV_BITBLAST_INTERNAL_EAGER_LEMMA:
+ return "BV_BITBLAST_EAGER_LEMMA";
+ case InferenceId::BV_BITBLAST_INTERNAL_BITBLAST_LEMMA:
+ return "BV_BITBLAST_INTERNAL_BITBLAST_LEMMA";
case InferenceId::BV_EXTF_LEMMA: return "BV_EXTF_LEMMA";
case InferenceId::BV_EXTF_COLLAPSE: return "BV_EXTF_COLLAPSE";
BV_BITBLAST_CONFLICT,
BV_LAZY_CONFLICT,
BV_LAZY_LEMMA,
- BV_SIMPLE_LEMMA,
- BV_SIMPLE_BITBLAST_LEMMA,
+ BV_BITBLAST_INTERNAL_EAGER_LEMMA,
+ BV_BITBLAST_INTERNAL_BITBLAST_LEMMA,
BV_EXTF_LEMMA,
BV_EXTF_COLLAPSE,
// ---------------------------------- end bitvector theory
; COMMAND-LINE: --bitblast=eager --no-check-models
-; COMMAND-LINE: --bitblast=eager --bv-solver=simple --no-check-models
+; COMMAND-LINE: --bitblast=eager --bv-solver=bitblast-internal --no-check-models
; EXPECT: sat
(set-logic QF_UFBV)
(set-info :smt-lib-version 2.6)
; COMMAND-LINE: --bitblast=eager
-; COMMAND-LINE: --bitblast=eager --bv-solver=simple
+; COMMAND-LINE: --bitblast=eager --bv-solver=bitblast-internal
(set-info :status sat)
(set-logic QF_BV)
(declare-fun x () Bool)
; COMMAND-LINE: --bool-to-bv=ite
-; COMMAND-LINE: --bool-to-bv=ite --bv-solver=simple
+; COMMAND-LINE: --bool-to-bv=ite --bv-solver=bitblast-internal
; EXPECT: sat
(set-logic QF_BV)
(declare-fun x2 () (_ BitVec 3))
; COMMAND-LINE: --incremental
-; COMMAND-LINE: --incremental --bv-solver=simple
+; COMMAND-LINE: --incremental --bv-solver=bitblast-internal
; EXPECT: sat
; EXPECT: sat
(set-logic QF_BV)
; COMMAND-LINE: --incremental
-; COMMAND-LINE: --incremental --bv-solver=simple
+; COMMAND-LINE: --incremental --bv-solver=bitblast-internal
; EXPECT: sat
; EXPECT: sat
(set-logic ALL)
; COMMAND-LINE:
-; COMMAND-LINE: --bv-solver=simple
+; COMMAND-LINE: --bv-solver=bitblast-internal
(set-logic QF_BV)
(set-info :status unsat)
(declare-const x (_ BitVec 4))
-; COMMAND-LINE: --bv-solver=simple
+; COMMAND-LINE: --bv-solver=bitblast-internal
; EXPECT: unsat
(set-logic ALL)
(declare-const __ (_ BitVec 3))
-; COMMAND-LINE: --bv-solver=simple
+; COMMAND-LINE: --bv-solver=bitblast-internal
; EXPECT: unsat
(set-logic ALL)
(declare-const __ (_ BitVec 7))
; COMMAND-LINE: --bitblast=lazy
; COMMAND-LINE: --bitblast=eager --no-check-models
-; COMMAND-LINE: --bv-solver=simple
+; COMMAND-LINE: --bv-solver=bitblast-internal
; EXPECT: sat
; Automatically generated by SBV. Do not edit.
(set-logic QF_UFBV)