1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mathias Preiner, Andrew Reynolds, Andres Noetzli |
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 |
|
* Bit-vector solver interface. |
14 |
|
* |
15 |
|
* Describes the interface for the internal bit-vector solver of TheoryBV. |
16 |
|
*/ |
17 |
|
|
18 |
|
#include "cvc5_private.h" |
19 |
|
|
20 |
|
#ifndef CVC5__THEORY__BV__BV_SOLVER_H |
21 |
|
#define CVC5__THEORY__BV__BV_SOLVER_H |
22 |
|
|
23 |
|
#include "smt/env_obj.h" |
24 |
|
#include "theory/theory.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
namespace theory { |
28 |
|
namespace bv { |
29 |
|
|
30 |
|
class BVSolver : protected EnvObj |
31 |
|
{ |
32 |
|
public: |
33 |
6278 |
BVSolver(Env& env, TheoryState& state, TheoryInferenceManager& inferMgr) |
34 |
6278 |
: EnvObj(env), d_state(state), d_im(inferMgr){}; |
35 |
|
|
36 |
6275 |
virtual ~BVSolver() {} |
37 |
|
|
38 |
|
/** |
39 |
|
* Returns true if we need an equality engine. If so, we initialize the |
40 |
|
* information regarding how it should be setup. For details, see the |
41 |
|
* documentation in Theory::needsEqualityEngine. |
42 |
|
*/ |
43 |
|
virtual bool needsEqualityEngine(EeSetupInfo& esi) { return false; } |
44 |
|
|
45 |
6275 |
virtual void finishInit(){}; |
46 |
|
|
47 |
|
virtual void preRegisterTerm(TNode n) = 0; |
48 |
|
|
49 |
|
/** |
50 |
|
* Forwarded from TheoryBV::preCheck(). |
51 |
|
*/ |
52 |
723568 |
virtual bool preCheck(Theory::Effort level = Theory::Effort::EFFORT_FULL) |
53 |
|
{ |
54 |
723568 |
return false; |
55 |
|
} |
56 |
|
/** |
57 |
|
* Forwarded from TheoryBV::postCheck(). |
58 |
|
*/ |
59 |
598 |
virtual void postCheck(Theory::Effort level = Theory::Effort::EFFORT_FULL){}; |
60 |
|
/** |
61 |
|
* Forwarded from TheoryBV:preNotifyFact(). |
62 |
|
*/ |
63 |
|
virtual bool preNotifyFact( |
64 |
|
TNode atom, bool pol, TNode fact, bool isPrereg, bool isInternal) |
65 |
|
{ |
66 |
|
return false; |
67 |
|
} |
68 |
|
/** |
69 |
|
* Forwarded from TheoryBV::notifyFact(). |
70 |
|
*/ |
71 |
1191559 |
virtual void notifyFact(TNode atom, bool pol, TNode fact, bool isInternal) {} |
72 |
|
|
73 |
6788 |
virtual bool needsCheckLastEffort() { return false; } |
74 |
|
|
75 |
1096886 |
virtual void propagate(Theory::Effort e) {} |
76 |
|
|
77 |
|
virtual TrustNode explain(TNode n) |
78 |
|
{ |
79 |
|
Unimplemented() << "BVSolver propagated a node but doesn't implement the " |
80 |
|
"BVSolver::explain() interface!"; |
81 |
|
return TrustNode::null(); |
82 |
|
} |
83 |
|
|
84 |
|
/** Additionally collect terms relevant for collecting model values. */ |
85 |
49 |
virtual void computeRelevantTerms(std::set<Node>& termSet) {} |
86 |
|
|
87 |
|
/** Collect model values in m based on the relevant terms given by termSet */ |
88 |
|
virtual bool collectModelValues(TheoryModel* m, |
89 |
|
const std::set<Node>& termSet) = 0; |
90 |
|
|
91 |
|
virtual std::string identify() const = 0; |
92 |
|
|
93 |
201125 |
virtual TrustNode ppRewrite(TNode t) { return TrustNode::null(); } |
94 |
|
|
95 |
63533 |
virtual void ppStaticLearn(TNode in, NodeBuilder& learned) {} |
96 |
|
|
97 |
9362 |
virtual void presolve() {} |
98 |
|
|
99 |
79084 |
virtual void notifySharedTerm(TNode t) {} |
100 |
|
|
101 |
27688 |
virtual EqualityStatus getEqualityStatus(TNode a, TNode b) |
102 |
|
{ |
103 |
27688 |
return EqualityStatus::EQUALITY_UNKNOWN; |
104 |
|
} |
105 |
|
|
106 |
|
/** |
107 |
|
* Get the current value of `node`. |
108 |
|
* |
109 |
|
* The `initialize` flag indicates whether bits should be zero-initialized |
110 |
|
* if they don't have a value yet. |
111 |
|
*/ |
112 |
|
virtual Node getValue(TNode node, bool initialize) { return Node::null(); } |
113 |
|
|
114 |
|
/** Called by abstraction preprocessing pass. */ |
115 |
4 |
virtual bool applyAbstraction(const std::vector<Node>& assertions, |
116 |
|
std::vector<Node>& new_assertions) |
117 |
|
{ |
118 |
4 |
new_assertions.insert( |
119 |
8 |
new_assertions.end(), assertions.begin(), assertions.end()); |
120 |
4 |
return false; |
121 |
|
}; |
122 |
|
|
123 |
|
protected: |
124 |
|
TheoryState& d_state; |
125 |
|
TheoryInferenceManager& d_im; |
126 |
|
}; |
127 |
|
|
128 |
|
} // namespace bv |
129 |
|
} // namespace theory |
130 |
|
} // namespace cvc5 |
131 |
|
|
132 |
|
#endif /* CVC5__THEORY__BV__BV_SOLVER_H */ |