1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mathias Preiner, Liana Hadarean, Tim King |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Bitblaster for the eager BV solver. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H |
19 |
|
#define CVC5__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H |
20 |
|
|
21 |
|
#include <memory> |
22 |
|
#include <unordered_set> |
23 |
|
|
24 |
|
#include "theory/bv/bitblast/bitblaster.h" |
25 |
|
|
26 |
|
#include "prop/sat_solver.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace theory { |
30 |
|
namespace bv { |
31 |
|
|
32 |
|
class BitblastingRegistrar; |
33 |
|
class BVSolverLayered; |
34 |
|
|
35 |
|
class EagerBitblaster : public TBitblaster<Node> |
36 |
|
{ |
37 |
|
public: |
38 |
|
EagerBitblaster(BVSolverLayered* theory_bv, context::Context* context); |
39 |
|
~EagerBitblaster(); |
40 |
|
|
41 |
|
void addAtom(TNode atom); |
42 |
|
void makeVariable(TNode node, Bits& bits) override; |
43 |
|
void bbTerm(TNode node, Bits& bits) override; |
44 |
|
void bbAtom(TNode node) override; |
45 |
|
Node getBBAtom(TNode node) const override; |
46 |
|
bool hasBBAtom(TNode atom) const override; |
47 |
|
void bbFormula(TNode formula); |
48 |
|
void storeBBAtom(TNode atom, Node atom_bb) override; |
49 |
|
void storeBBTerm(TNode node, const Bits& bits) override; |
50 |
|
|
51 |
|
bool assertToSat(TNode node, bool propagate = true); |
52 |
|
bool solve(); |
53 |
|
bool solve(const std::vector<Node>& assumptions); |
54 |
|
bool collectModelInfo(TheoryModel* m, bool fullModel); |
55 |
|
|
56 |
|
private: |
57 |
|
context::Context* d_context; |
58 |
|
|
59 |
|
typedef std::unordered_set<TNode> TNodeSet; |
60 |
|
std::unique_ptr<prop::SatSolver> d_satSolver; |
61 |
|
std::unique_ptr<BitblastingRegistrar> d_bitblastingRegistrar; |
62 |
|
|
63 |
|
BVSolverLayered* d_bv; |
64 |
|
TNodeSet d_bbAtoms; |
65 |
|
TNodeSet d_variables; |
66 |
|
|
67 |
|
// This is either an MinisatEmptyNotify or NULL. |
68 |
|
std::unique_ptr<MinisatEmptyNotify> d_notify; |
69 |
|
|
70 |
|
Node getModelFromSatSolver(TNode a, bool fullModel) override; |
71 |
|
prop::SatSolver* getSatSolver() override { return d_satSolver.get(); } |
72 |
|
bool isSharedTerm(TNode node); |
73 |
|
}; |
74 |
|
|
75 |
4 |
class BitblastingRegistrar : public prop::Registrar |
76 |
|
{ |
77 |
|
public: |
78 |
2 |
BitblastingRegistrar(EagerBitblaster* bb) : d_bitblaster(bb) {} |
79 |
68 |
void preRegister(Node n) override { d_bitblaster->bbAtom(n); } |
80 |
|
|
81 |
|
private: |
82 |
|
EagerBitblaster* d_bitblaster; |
83 |
|
}; |
84 |
|
|
85 |
|
} // namespace bv |
86 |
|
} // namespace theory |
87 |
|
} // namespace cvc5 |
88 |
|
#endif // CVC5__THEORY__BV__BITBLAST__EAGER_BITBLASTER_H |