diff options
Diffstat (limited to 'src/theory/bv/bitblast')
-rw-r--r-- | src/theory/bv/bitblast/aig_bitblaster.cpp | 7 | ||||
-rw-r--r-- | src/theory/bv/bitblast/aig_bitblaster.h | 8 | ||||
-rw-r--r-- | src/theory/bv/bitblast/bitblast_strategies_template.h | 2 | ||||
-rw-r--r-- | src/theory/bv/bitblast/bitblast_utils.h | 2 | ||||
-rw-r--r-- | src/theory/bv/bitblast/bitblaster.h | 23 | ||||
-rw-r--r-- | src/theory/bv/bitblast/eager_bitblaster.cpp | 41 | ||||
-rw-r--r-- | src/theory/bv/bitblast/eager_bitblaster.h | 10 | ||||
-rw-r--r-- | src/theory/bv/bitblast/lazy_bitblaster.cpp | 72 | ||||
-rw-r--r-- | src/theory/bv/bitblast/lazy_bitblaster.h | 21 |
9 files changed, 73 insertions, 113 deletions
diff --git a/src/theory/bv/bitblast/aig_bitblaster.cpp b/src/theory/bv/bitblast/aig_bitblaster.cpp index 331db9378..ca1ca4c74 100644 --- a/src/theory/bv/bitblast/aig_bitblaster.cpp +++ b/src/theory/bv/bitblast/aig_bitblaster.cpp @@ -5,7 +5,7 @@ ** Liana Hadarean, Mathias Preiner, Tim King ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** @@ -14,12 +14,12 @@ ** AIG bitblaster. **/ -#include "cvc4_private.h" - #include "theory/bv/bitblast/aig_bitblaster.h" #include "base/check.h" +#include "cvc4_private.h" #include "options/bv_options.h" +#include "prop/cnf_stream.h" #include "prop/sat_solver_factory.h" #include "smt/smt_statistics_registry.h" @@ -28,7 +28,6 @@ extern "C" { #include "base/abc/abc.h" #include "base/main/main.h" -#include "prop/cnf_stream.h" #include "sat/cnf/cnf.h" extern Aig_Man_t* Abc_NtkToDar(Abc_Ntk_t* pNtk, int fExors, int fRegisters); diff --git a/src/theory/bv/bitblast/aig_bitblaster.h b/src/theory/bv/bitblast/aig_bitblaster.h index 1e1b5bab4..ce733cabc 100644 --- a/src/theory/bv/bitblast/aig_bitblaster.h +++ b/src/theory/bv/bitblast/aig_bitblaster.h @@ -5,7 +5,7 @@ ** Liana Hadarean, Mathias Preiner, Andres Noetzli ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** @@ -89,12 +89,6 @@ class AigBitblaster : public TBitblaster<Abc_Obj_t*> prop::SatSolver* getSatSolver() override { return d_satSolver.get(); } - void setProofLog(proof::BitVectorProof* bvp) override - { - // Proofs are currently not supported with ABC - Unimplemented(); - } - class Statistics { public: diff --git a/src/theory/bv/bitblast/bitblast_strategies_template.h b/src/theory/bv/bitblast/bitblast_strategies_template.h index 7f1fe4eeb..a4e1757e2 100644 --- a/src/theory/bv/bitblast/bitblast_strategies_template.h +++ b/src/theory/bv/bitblast/bitblast_strategies_template.h @@ -5,7 +5,7 @@ ** Liana Hadarean, Aina Niemetz, Tim King ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** diff --git a/src/theory/bv/bitblast/bitblast_utils.h b/src/theory/bv/bitblast/bitblast_utils.h index 13ae129be..de98dc8bb 100644 --- a/src/theory/bv/bitblast/bitblast_utils.h +++ b/src/theory/bv/bitblast/bitblast_utils.h @@ -5,7 +5,7 @@ ** Liana Hadarean, Dejan Jovanovic, Mathias Preiner ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** diff --git a/src/theory/bv/bitblast/bitblaster.h b/src/theory/bv/bitblast/bitblaster.h index defc66b74..fd99621d4 100644 --- a/src/theory/bv/bitblast/bitblaster.h +++ b/src/theory/bv/bitblast/bitblaster.h @@ -5,7 +5,7 @@ ** Liana Hadarean, Mathias Preiner, Alex Ozdemir ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** @@ -24,8 +24,8 @@ #include <vector> #include "expr/node.h" -#include "proof/bitvector_proof.h" #include "prop/bv_sat_solver_notify.h" +#include "prop/sat_solver.h" #include "prop/sat_solver_types.h" #include "smt/smt_engine_scope.h" #include "theory/bv/bitblast/bitblast_strategies_template.h" @@ -64,7 +64,6 @@ class TBitblaster // sat solver used for bitblasting and associated CnfStream std::unique_ptr<context::Context> d_nullContext; std::unique_ptr<prop::CnfStream> d_cnfStream; - proof::BitVectorProof* d_bvp; void initAtomBBStrategies(); void initTermBBStrategies(); @@ -91,7 +90,6 @@ class TBitblaster bool hasBBTerm(TNode node) const; void getBBTerm(TNode node, Bits& bits) const; virtual void storeBBTerm(TNode term, const Bits& bits); - virtual void setProofLog(proof::BitVectorProof* bvp); /** * Return a constant representing the value of a in the model. @@ -186,8 +184,7 @@ TBitblaster<T>::TBitblaster() : d_termCache(), d_modelCache(), d_nullContext(new context::Context()), - d_cnfStream(), - d_bvp(nullptr) + d_cnfStream() { initAtomBBStrategies(); initTermBBStrategies(); @@ -218,20 +215,6 @@ void TBitblaster<T>::invalidateModelCache() } template <class T> -void TBitblaster<T>::setProofLog(proof::BitVectorProof* bvp) -{ - if (THEORY_PROOF_ON()) - { - d_bvp = bvp; - prop::SatSolver* satSolver = getSatSolver(); - bvp->attachToSatSolver(*satSolver); - prop::SatVariable t = satSolver->trueVar(); - prop::SatVariable f = satSolver->falseVar(); - bvp->initCnfProof(d_cnfStream.get(), d_nullContext.get(), t, f); - } -} - -template <class T> Node TBitblaster<T>::getTermModel(TNode node, bool fullModel) { if (d_modelCache.find(node) != d_modelCache.end()) return d_modelCache[node]; diff --git a/src/theory/bv/bitblast/eager_bitblaster.cpp b/src/theory/bv/bitblast/eager_bitblaster.cpp index 4acd1d2f8..046ad4b1b 100644 --- a/src/theory/bv/bitblast/eager_bitblaster.cpp +++ b/src/theory/bv/bitblast/eager_bitblaster.cpp @@ -2,10 +2,10 @@ /*! \file eager_bitblaster.cpp ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Mathias Preiner, Tim King + ** Liana Hadarean, Mathias Preiner, Andres Noetzli ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** @@ -14,14 +14,15 @@ ** Bitblaster for the eager bv solver. **/ -#include "cvc4_private.h" - #include "theory/bv/bitblast/eager_bitblaster.h" +#include "cvc4_private.h" #include "options/bv_options.h" #include "prop/cnf_stream.h" #include "prop/sat_solver_factory.h" +#include "smt/smt_engine.h" #include "smt/smt_statistics_registry.h" +#include "theory/bv/bv_solver_lazy.h" #include "theory/bv/theory_bv.h" #include "theory/theory_model.h" @@ -29,7 +30,7 @@ namespace CVC4 { namespace theory { namespace bv { -EagerBitblaster::EagerBitblaster(TheoryBV* theory_bv, context::Context* c) +EagerBitblaster::EagerBitblaster(BVSolverLazy* theory_bv, context::Context* c) : TBitblaster<Node>(), d_context(c), d_satSolver(), @@ -68,12 +69,13 @@ EagerBitblaster::EagerBitblaster(TheoryBV* theory_bv, context::Context* c) } d_satSolver.reset(solver); ResourceManager* rm = smt::currentResourceManager(); - d_cnfStream.reset(new prop::TseitinCnfStream(d_satSolver.get(), - d_bitblastingRegistrar.get(), - d_nullContext.get(), - rm, - options::proof(), - "EagerBitblaster")); + d_cnfStream.reset(new prop::CnfStream(d_satSolver.get(), + d_bitblastingRegistrar.get(), + d_nullContext.get(), + nullptr, + rm, + false, + "EagerBitblaster")); } EagerBitblaster::~EagerBitblaster() {} @@ -87,8 +89,7 @@ void EagerBitblaster::bbFormula(TNode node) } else { - d_cnfStream->convertAndAssert( - node, false, false, RULE_INVALID, TNode::null()); + d_cnfStream->convertAndAssert(node, false, false); } } @@ -116,10 +117,7 @@ void EagerBitblaster::bbAtom(TNode node) ? d_atomBBStrategies[normalized.getKind()](normalized, this) : normalized; - if (!options::proof()) - { - atom_bb = Rewriter::rewrite(atom_bb); - } + atom_bb = Rewriter::rewrite(atom_bb); // asserting that the atom is true iff the definition holds Node atom_definition = @@ -127,21 +125,14 @@ void EagerBitblaster::bbAtom(TNode node) AlwaysAssert(options::bitblastMode() == options::BitblastMode::EAGER); storeBBAtom(node, atom_bb); - d_cnfStream->convertAndAssert( - atom_definition, false, false, RULE_INVALID, TNode::null()); + d_cnfStream->convertAndAssert(atom_definition, false, false); } void EagerBitblaster::storeBBAtom(TNode atom, Node atom_bb) { - if (d_bvp) { - d_bvp->registerAtomBB(atom.toExpr(), atom_bb.toExpr()); - } d_bbAtoms.insert(atom); } void EagerBitblaster::storeBBTerm(TNode node, const Bits& bits) { - if (d_bvp) { - d_bvp->registerTermBB(node.toExpr()); - } d_termCache.insert(std::make_pair(node, bits)); } diff --git a/src/theory/bv/bitblast/eager_bitblaster.h b/src/theory/bv/bitblast/eager_bitblaster.h index a8b7ccbe5..38a9f775b 100644 --- a/src/theory/bv/bitblast/eager_bitblaster.h +++ b/src/theory/bv/bitblast/eager_bitblaster.h @@ -5,7 +5,7 @@ ** Mathias Preiner, Liana Hadarean, Tim King ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** @@ -23,8 +23,6 @@ #include "theory/bv/bitblast/bitblaster.h" -#include "proof/bitvector_proof.h" -#include "proof/resolution_bitvector_proof.h" #include "prop/cnf_stream.h" #include "prop/sat_solver.h" @@ -33,12 +31,12 @@ namespace theory { namespace bv { class BitblastingRegistrar; -class TheoryBV; +class BVSolverLazy; class EagerBitblaster : public TBitblaster<Node> { public: - EagerBitblaster(TheoryBV* theory_bv, context::Context* context); + EagerBitblaster(BVSolverLazy* theory_bv, context::Context* context); ~EagerBitblaster(); void addAtom(TNode atom); @@ -63,7 +61,7 @@ class EagerBitblaster : public TBitblaster<Node> std::unique_ptr<prop::SatSolver> d_satSolver; std::unique_ptr<BitblastingRegistrar> d_bitblastingRegistrar; - TheoryBV* d_bv; + BVSolverLazy* d_bv; TNodeSet d_bbAtoms; TNodeSet d_variables; diff --git a/src/theory/bv/bitblast/lazy_bitblaster.cpp b/src/theory/bv/bitblast/lazy_bitblaster.cpp index c3a305952..95d78c69b 100644 --- a/src/theory/bv/bitblast/lazy_bitblaster.cpp +++ b/src/theory/bv/bitblast/lazy_bitblaster.cpp @@ -5,7 +5,7 @@ ** Liana Hadarean, Aina Niemetz, Mathias Preiner ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** @@ -14,17 +14,17 @@ ** Bitblaster for the lazy bv solver. **/ -#include "cvc4_private.h" - #include "theory/bv/bitblast/lazy_bitblaster.h" +#include "cvc4_private.h" #include "options/bv_options.h" -#include "proof/proof_manager.h" #include "prop/cnf_stream.h" #include "prop/sat_solver.h" #include "prop/sat_solver_factory.h" +#include "smt/smt_engine.h" #include "smt/smt_statistics_registry.h" #include "theory/bv/abstraction.h" +#include "theory/bv/bv_solver_lazy.h" #include "theory/bv/theory_bv.h" #include "theory/bv/theory_bv_utils.h" #include "theory/rewriter.h" @@ -59,7 +59,7 @@ uint64_t numNodes(TNode node, utils::NodeSet& seen) } TLazyBitblaster::TLazyBitblaster(context::Context* c, - bv::TheoryBV* bv, + bv::BVSolverLazy* bv, const std::string name, bool emptyNotify) : TBitblaster<Node>(), @@ -80,12 +80,13 @@ TLazyBitblaster::TLazyBitblaster(context::Context* c, prop::SatSolverFactory::createMinisat(c, smtStatisticsRegistry(), name)); ResourceManager* rm = smt::currentResourceManager(); - d_cnfStream.reset(new prop::TseitinCnfStream(d_satSolver.get(), - d_nullRegistrar.get(), - d_nullContext.get(), - rm, - options::proof(), - "LazyBitblaster")); + d_cnfStream.reset(new prop::CnfStream(d_satSolver.get(), + d_nullRegistrar.get(), + d_nullContext.get(), + nullptr, + rm, + false, + "LazyBitblaster")); d_satSolverNotify.reset( d_emptyNotify @@ -161,8 +162,7 @@ void TLazyBitblaster::bbAtom(TNode node) Assert(!atom_bb.isNull()); Node atom_definition = nm->mkNode(kind::EQUAL, node, atom_bb); storeBBAtom(node, atom_bb); - d_cnfStream->convertAndAssert( - atom_definition, false, false, RULE_INVALID, TNode::null()); + d_cnfStream->convertAndAssert(atom_definition, false, false); return; } @@ -173,28 +173,19 @@ void TLazyBitblaster::bbAtom(TNode node) ? d_atomBBStrategies[normalized.getKind()](normalized, this) : normalized; - if (!options::proof()) - { - atom_bb = Rewriter::rewrite(atom_bb); - } + atom_bb = Rewriter::rewrite(atom_bb); // asserting that the atom is true iff the definition holds Node atom_definition = nm->mkNode(kind::EQUAL, node, atom_bb); storeBBAtom(node, atom_bb); - d_cnfStream->convertAndAssert( - atom_definition, false, false, RULE_INVALID, TNode::null()); + d_cnfStream->convertAndAssert(atom_definition, false, false); } void TLazyBitblaster::storeBBAtom(TNode atom, Node atom_bb) { - // No need to store the definition for the lazy bit-blaster (unless proofs are enabled). - if( d_bvp != NULL ){ - d_bvp->registerAtomBB(atom.toExpr(), atom_bb.toExpr()); - } d_bbAtoms.insert(atom); } void TLazyBitblaster::storeBBTerm(TNode node, const Bits& bits) { - if( d_bvp ){ d_bvp->registerTermBB(node.toExpr()); } d_termCache.insert(std::make_pair(node, bits)); } @@ -303,8 +294,12 @@ bool TLazyBitblaster::assertToSat(TNode lit, bool propagate) { markerLit = ~markerLit; } - Debug("bitvector-bb") << "TheoryBV::TLazyBitblaster::assertToSat asserting node: " << atom <<"\n"; - Debug("bitvector-bb") << "TheoryBV::TLazyBitblaster::assertToSat with literal: " << markerLit << "\n"; + Debug("bitvector-bb") + << "BVSolverLazy::TLazyBitblaster::assertToSat asserting node: " << atom + << "\n"; + Debug("bitvector-bb") + << "BVSolverLazy::TLazyBitblaster::assertToSat with literal: " + << markerLit << "\n"; prop::SatValue ret = d_satSolver->assertAssumption(markerLit, propagate); @@ -421,9 +416,9 @@ void TLazyBitblaster::MinisatNotify::notify(prop::SatClause& clause) { lemmab << d_cnf->getNode(clause[i]); } Node lemma = lemmab; - d_bv->d_out->lemma(lemma); + d_bv->d_inferManager.lemma(lemma); } else { - d_bv->d_out->lemma(d_cnf->getNode(clause[0])); + d_bv->d_inferManager.lemma(d_cnf->getNode(clause[0])); } } @@ -434,7 +429,7 @@ void TLazyBitblaster::MinisatNotify::spendResource(ResourceManager::Resource r) void TLazyBitblaster::MinisatNotify::safePoint(ResourceManager::Resource r) { - d_bv->d_out->safePoint(r); + d_bv->d_inferManager.safePoint(r); } EqualityStatus TLazyBitblaster::getEqualityStatus(TNode a, TNode b) @@ -537,11 +532,9 @@ Node TLazyBitblaster::getModelFromSatSolver(TNode a, bool fullModel) { 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; - d_bv->computeRelevantTerms(termSet); - 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 @@ -555,9 +548,9 @@ bool TLazyBitblaster::collectModelInfo(TheoryModel* m, bool fullModel) 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; @@ -582,8 +575,11 @@ void TLazyBitblaster::clearSolver() { d_satSolver.reset( prop::SatSolverFactory::createMinisat(d_ctx, smtStatisticsRegistry())); ResourceManager* rm = smt::currentResourceManager(); - d_cnfStream.reset(new prop::TseitinCnfStream( - d_satSolver.get(), d_nullRegistrar.get(), d_nullContext.get(), rm)); + d_cnfStream.reset(new prop::CnfStream(d_satSolver.get(), + d_nullRegistrar.get(), + d_nullContext.get(), + nullptr, + rm)); d_satSolverNotify.reset( d_emptyNotify ? (prop::BVSatSolverNotify*)new MinisatEmptyNotify() diff --git a/src/theory/bv/bitblast/lazy_bitblaster.h b/src/theory/bv/bitblast/lazy_bitblaster.h index a355d42c4..a15eb084e 100644 --- a/src/theory/bv/bitblast/lazy_bitblaster.h +++ b/src/theory/bv/bitblast/lazy_bitblaster.h @@ -2,10 +2,10 @@ /*! \file lazy_bitblaster.h ** \verbatim ** Top contributors (to current version): - ** Liana Hadarean, Mathias Preiner, Clark Barrett + ** Mathias Preiner, Liana Hadarean, Clark Barrett ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. + ** 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.\endverbatim ** @@ -19,7 +19,6 @@ #ifndef CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H #define CVC4__THEORY__BV__BITBLAST__LAZY_BITBLASTER_H -#include "proof/resolution_bitvector_proof.h" #include "theory/bv/bitblast/bitblaster.h" #include "context/cdhashmap.h" @@ -33,7 +32,7 @@ namespace CVC4 { namespace theory { namespace bv { -class TheoryBV; +class BVSolverLazy; class TLazyBitblaster : public TBitblaster<Node> { @@ -46,7 +45,7 @@ class TLazyBitblaster : public TBitblaster<Node> bool hasBBAtom(TNode atom) const override; TLazyBitblaster(context::Context* c, - TheoryBV* bv, + BVSolverLazy* bv, const std::string name = "", bool emptyNotify = false); ~TLazyBitblaster(); @@ -73,10 +72,10 @@ class TLazyBitblaster : public TBitblaster<Node> * 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(); } @@ -109,11 +108,11 @@ class TLazyBitblaster : public TBitblaster<Node> class MinisatNotify : public prop::BVSatSolverNotify { prop::CnfStream* d_cnf; - TheoryBV* d_bv; + BVSolverLazy* d_bv; TLazyBitblaster* d_lazyBB; public: - MinisatNotify(prop::CnfStream* cnf, TheoryBV* bv, TLazyBitblaster* lbv) + MinisatNotify(prop::CnfStream* cnf, BVSolverLazy* bv, TLazyBitblaster* lbv) : d_cnf(cnf), d_bv(bv), d_lazyBB(lbv) { } @@ -124,7 +123,7 @@ class TLazyBitblaster : public TBitblaster<Node> void safePoint(ResourceManager::Resource r) override; }; - TheoryBV* d_bv; + BVSolverLazy* d_bv; context::Context* d_ctx; std::unique_ptr<prop::NullRegistrar> d_nullRegistrar; |