1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Mathias Preiner, 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 |
|
* Theory of bit-vectors. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__BV__THEORY_BV_H |
19 |
|
#define CVC5__THEORY__BV__THEORY_BV_H |
20 |
|
|
21 |
|
#include "theory/bv/theory_bv_rewriter.h" |
22 |
|
#include "theory/theory.h" |
23 |
|
#include "theory/theory_eq_notify.h" |
24 |
|
#include "theory/theory_state.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
|
28 |
|
class ProofRuleChecker; |
29 |
|
|
30 |
|
namespace theory { |
31 |
|
namespace bv { |
32 |
|
|
33 |
|
class BVSolver; |
34 |
|
|
35 |
|
class TheoryBV : public Theory |
36 |
|
{ |
37 |
|
/* BVSolverLayered accesses methods from theory in a way that is deprecated |
38 |
|
* and will be removed in the future. For now we allow direct access. */ |
39 |
|
friend class BVSolverLayered; |
40 |
|
|
41 |
|
public: |
42 |
|
TheoryBV(Env& env, |
43 |
|
OutputChannel& out, |
44 |
|
Valuation valuation, |
45 |
|
std::string name = ""); |
46 |
|
|
47 |
|
~TheoryBV(); |
48 |
|
|
49 |
|
/** get the official theory rewriter of this theory */ |
50 |
|
TheoryRewriter* getTheoryRewriter() override; |
51 |
|
/** get the proof checker of this theory */ |
52 |
|
ProofRuleChecker* getProofChecker() override; |
53 |
|
|
54 |
|
/** |
55 |
|
* Returns true if we need an equality engine. If so, we initialize the |
56 |
|
* information regarding how it should be setup. For details, see the |
57 |
|
* documentation in Theory::needsEqualityEngine. |
58 |
|
*/ |
59 |
|
bool needsEqualityEngine(EeSetupInfo& esi) override; |
60 |
|
|
61 |
|
void finishInit() override; |
62 |
|
|
63 |
|
void preRegisterTerm(TNode n) override; |
64 |
|
|
65 |
|
bool preCheck(Effort e) override; |
66 |
|
|
67 |
|
void postCheck(Effort e) override; |
68 |
|
|
69 |
|
bool preNotifyFact(TNode atom, |
70 |
|
bool pol, |
71 |
|
TNode fact, |
72 |
|
bool isPrereg, |
73 |
|
bool isInternal) override; |
74 |
|
|
75 |
|
void notifyFact(TNode atom, bool pol, TNode fact, bool isInternal) override; |
76 |
|
|
77 |
|
bool needsCheckLastEffort() override; |
78 |
|
|
79 |
|
void propagate(Effort e) override; |
80 |
|
|
81 |
|
TrustNode explain(TNode n) override; |
82 |
|
|
83 |
|
void computeRelevantTerms(std::set<Node>& termSet) override; |
84 |
|
|
85 |
|
/** Collect model values in m based on the relevant terms given by termSet */ |
86 |
|
bool collectModelValues(TheoryModel* m, |
87 |
|
const std::set<Node>& termSet) override; |
88 |
|
|
89 |
|
std::string identify() const override { return std::string("TheoryBV"); } |
90 |
|
|
91 |
|
PPAssertStatus ppAssert(TrustNode in, |
92 |
|
TrustSubstitutionMap& outSubstitutions) override; |
93 |
|
|
94 |
|
TrustNode ppRewrite(TNode t, std::vector<SkolemLemma>& lems) override; |
95 |
|
|
96 |
|
void ppStaticLearn(TNode in, NodeBuilder& learned) override; |
97 |
|
|
98 |
|
void presolve() override; |
99 |
|
|
100 |
|
EqualityStatus getEqualityStatus(TNode a, TNode b) override; |
101 |
|
|
102 |
|
/** Called by abstraction preprocessing pass. */ |
103 |
|
bool applyAbstraction(const std::vector<Node>& assertions, |
104 |
|
std::vector<Node>& new_assertions); |
105 |
|
|
106 |
|
private: |
107 |
|
void notifySharedTerm(TNode t) override; |
108 |
|
|
109 |
|
Node getValue(TNode node); |
110 |
|
|
111 |
|
/** Internal BV solver. */ |
112 |
|
std::unique_ptr<BVSolver> d_internal; |
113 |
|
|
114 |
|
/** The theory rewriter for this theory. */ |
115 |
|
TheoryBVRewriter d_rewriter; |
116 |
|
|
117 |
|
/** A (default) theory state object */ |
118 |
|
TheoryState d_state; |
119 |
|
|
120 |
|
/** A (default) theory inference manager. */ |
121 |
|
TheoryInferenceManager d_im; |
122 |
|
|
123 |
|
/** The notify class for equality engine. */ |
124 |
|
TheoryEqNotifyClass d_notify; |
125 |
|
|
126 |
|
/** Flag indicating whether `d_modelCache` should be invalidated. */ |
127 |
|
context::CDO<bool> d_invalidateModelCache; |
128 |
|
|
129 |
|
/** |
130 |
|
* Cache for getValue() calls. |
131 |
|
* |
132 |
|
* Is cleared at the beginning of a getValue() call if the |
133 |
|
* `d_invalidateModelCache` flag is set to true. |
134 |
|
*/ |
135 |
|
std::unordered_map<Node, Node> d_modelCache; |
136 |
|
|
137 |
|
/** TheoryBV statistics. */ |
138 |
|
struct Statistics |
139 |
|
{ |
140 |
|
Statistics(const std::string& name); |
141 |
|
IntStat d_solveSubstitutions; |
142 |
|
} d_stats; |
143 |
|
|
144 |
|
}; /* class TheoryBV */ |
145 |
|
|
146 |
|
} // namespace bv |
147 |
|
} // namespace theory |
148 |
|
} // namespace cvc5 |
149 |
|
|
150 |
|
#endif /* CVC5__THEORY__BV__THEORY_BV_H */ |