1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Dejan Jovanovic, Morgan Deters |
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 |
|
* The theory engine. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY_ENGINE_H |
19 |
|
#define CVC5__THEORY_ENGINE_H |
20 |
|
|
21 |
|
#include <memory> |
22 |
|
#include <vector> |
23 |
|
|
24 |
|
#include "base/check.h" |
25 |
|
#include "context/cdhashmap.h" |
26 |
|
#include "expr/node.h" |
27 |
|
#include "options/theory_options.h" |
28 |
|
#include "proof/trust_node.h" |
29 |
|
#include "smt/env_obj.h" |
30 |
|
#include "theory/atom_requests.h" |
31 |
|
#include "theory/engine_output_channel.h" |
32 |
|
#include "theory/interrupted.h" |
33 |
|
#include "theory/rewriter.h" |
34 |
|
#include "theory/sort_inference.h" |
35 |
|
#include "theory/theory.h" |
36 |
|
#include "theory/theory_preprocessor.h" |
37 |
|
#include "theory/trust_substitutions.h" |
38 |
|
#include "theory/uf/equality_engine.h" |
39 |
|
#include "theory/valuation.h" |
40 |
|
#include "util/hash.h" |
41 |
|
#include "util/statistics_stats.h" |
42 |
|
#include "util/unsafe_interrupt_exception.h" |
43 |
|
|
44 |
|
namespace cvc5 { |
45 |
|
|
46 |
|
class Env; |
47 |
|
class ResourceManager; |
48 |
|
class TheoryEngineProofGenerator; |
49 |
|
class ProofChecker; |
50 |
|
|
51 |
|
/** |
52 |
|
* A pair of a theory and a node. This is used to mark the flow of |
53 |
|
* propagations between theories. |
54 |
|
*/ |
55 |
472959656 |
struct NodeTheoryPair { |
56 |
|
Node d_node; |
57 |
|
theory::TheoryId d_theory; |
58 |
|
size_t d_timestamp; |
59 |
68444750 |
NodeTheoryPair(TNode n, theory::TheoryId t, size_t ts = 0) |
60 |
68444750 |
: d_node(n), d_theory(t), d_timestamp(ts) |
61 |
|
{ |
62 |
68444750 |
} |
63 |
47263110 |
NodeTheoryPair() : d_theory(theory::THEORY_LAST), d_timestamp() {} |
64 |
|
// Comparison doesn't take into account the timestamp |
65 |
82561714 |
bool operator == (const NodeTheoryPair& pair) const { |
66 |
82561714 |
return d_node == pair.d_node && d_theory == pair.d_theory; |
67 |
|
} |
68 |
|
};/* struct NodeTheoryPair */ |
69 |
|
|
70 |
|
struct NodeTheoryPairHashFunction { |
71 |
|
std::hash<Node> hashFunction; |
72 |
|
// Hash doesn't take into account the timestamp |
73 |
129929574 |
size_t operator()(const NodeTheoryPair& pair) const { |
74 |
129929574 |
uint64_t hash = fnv1a::fnv1a_64(std::hash<Node>()(pair.d_node)); |
75 |
129929574 |
return static_cast<size_t>(fnv1a::fnv1a_64(pair.d_theory, hash)); |
76 |
|
} |
77 |
|
};/* struct NodeTheoryPairHashFunction */ |
78 |
|
|
79 |
|
|
80 |
|
/* Forward declarations */ |
81 |
|
namespace theory { |
82 |
|
|
83 |
|
class CombinationEngine; |
84 |
|
class DecisionManager; |
85 |
|
class RelevanceManager; |
86 |
|
class Rewriter; |
87 |
|
class SharedSolver; |
88 |
|
class TheoryModel; |
89 |
|
|
90 |
|
} // namespace theory |
91 |
|
|
92 |
|
namespace prop { |
93 |
|
class PropEngine; |
94 |
|
} |
95 |
|
|
96 |
|
/** |
97 |
|
* This is essentially an abstraction for a collection of theories. A |
98 |
|
* TheoryEngine provides services to a PropEngine, making various |
99 |
|
* T-solvers look like a single unit to the propositional part of |
100 |
|
* cvc5. |
101 |
|
*/ |
102 |
|
class TheoryEngine : protected EnvObj |
103 |
|
{ |
104 |
|
/** Shared terms database can use the internals notify the theories */ |
105 |
|
friend class SharedTermsDatabase; |
106 |
|
friend class theory::EngineOutputChannel; |
107 |
|
friend class theory::CombinationEngine; |
108 |
|
friend class theory::SharedSolver; |
109 |
|
|
110 |
|
public: |
111 |
|
/** Constructs a theory engine */ |
112 |
|
TheoryEngine(Env& env); |
113 |
|
|
114 |
|
/** Destroys a theory engine */ |
115 |
|
~TheoryEngine(); |
116 |
|
|
117 |
|
void interrupt(); |
118 |
|
|
119 |
|
/** "Spend" a resource during a search or preprocessing.*/ |
120 |
|
void spendResource(Resource r); |
121 |
|
|
122 |
|
/** |
123 |
|
* Adds a theory. Only one theory per TheoryId can be present, so if |
124 |
|
* there is another theory it will be deleted. |
125 |
|
*/ |
126 |
|
template <class TheoryClass> |
127 |
128931 |
void addTheory(theory::TheoryId theoryId) |
128 |
|
{ |
129 |
128931 |
Assert(d_theoryTable[theoryId] == NULL && d_theoryOut[theoryId] == NULL); |
130 |
128931 |
d_theoryOut[theoryId] = new theory::EngineOutputChannel(this, theoryId); |
131 |
257862 |
d_theoryTable[theoryId] = |
132 |
128931 |
new TheoryClass(d_env, *d_theoryOut[theoryId], theory::Valuation(this)); |
133 |
515724 |
getRewriter()->registerTheoryRewriter( |
134 |
386793 |
theoryId, d_theoryTable[theoryId]->getTheoryRewriter()); |
135 |
128931 |
} |
136 |
|
|
137 |
|
/** Register theory proof rule checkers to the given proof checker */ |
138 |
|
void initializeProofChecker(ProofChecker* pc); |
139 |
|
|
140 |
9982 |
void setPropEngine(prop::PropEngine* propEngine) |
141 |
|
{ |
142 |
9982 |
d_propEngine = propEngine; |
143 |
9982 |
} |
144 |
|
|
145 |
|
/** |
146 |
|
* Called when all initialization of options/logic is done, after theory |
147 |
|
* objects have been created. |
148 |
|
* |
149 |
|
* This initializes the quantifiers engine, the "official" equality engines |
150 |
|
* of each theory as required, and the model and model builder utilities. |
151 |
|
*/ |
152 |
|
void finishInit(); |
153 |
|
|
154 |
|
/** |
155 |
|
* Get a pointer to the underlying propositional engine. |
156 |
|
*/ |
157 |
2650892 |
prop::PropEngine* getPropEngine() const { return d_propEngine; } |
158 |
|
|
159 |
|
/** Get the proof node manager */ |
160 |
|
ProofNodeManager* getProofNodeManager() const; |
161 |
|
|
162 |
|
/** |
163 |
|
* Get a pointer to the underlying sat context. |
164 |
|
*/ |
165 |
|
context::Context* getSatContext() const; |
166 |
|
|
167 |
|
/** |
168 |
|
* Get a pointer to the underlying user context. |
169 |
|
*/ |
170 |
|
context::UserContext* getUserContext() const; |
171 |
|
|
172 |
|
/** |
173 |
|
* Get a pointer to the underlying quantifiers engine. |
174 |
|
*/ |
175 |
14047 |
theory::QuantifiersEngine* getQuantifiersEngine() const |
176 |
|
{ |
177 |
14047 |
return d_quantEngine; |
178 |
|
} |
179 |
|
/** |
180 |
|
* Get a pointer to the underlying decision manager. |
181 |
|
*/ |
182 |
|
theory::DecisionManager* getDecisionManager() const |
183 |
|
{ |
184 |
|
return d_decManager.get(); |
185 |
|
} |
186 |
|
|
187 |
|
/** |
188 |
|
* Preprocess rewrite equality, called by the preprocessor to rewrite |
189 |
|
* equalities appearing in the input. |
190 |
|
*/ |
191 |
|
TrustNode ppRewriteEquality(TNode eq); |
192 |
|
/** Notify (preprocessed) assertions. */ |
193 |
|
void notifyPreprocessedAssertions(const std::vector<Node>& assertions); |
194 |
|
|
195 |
|
/** Return whether or not we are incomplete (in the current context). */ |
196 |
7480 |
bool isIncomplete() const { return d_incomplete; } |
197 |
|
|
198 |
|
/** |
199 |
|
* Returns true if we need another round of checking. If this |
200 |
|
* returns true, check(FULL_EFFORT) _must_ be called by the |
201 |
|
* propositional layer before reporting SAT. |
202 |
|
* |
203 |
|
* This is especially necessary for incomplete theories that lazily |
204 |
|
* output some lemmas on FULL_EFFORT check (e.g. quantifier reasoning |
205 |
|
* outputing quantifier instantiations). In such a case, a lemma can |
206 |
|
* be asserted that is simplified away (perhaps it's already true). |
207 |
|
* However, we must maintain the invariant that, if a theory uses the |
208 |
|
* OutputChannel, it implicitly requests that another check(FULL_EFFORT) |
209 |
|
* be performed before exit, even if no new facts are on its fact queue, |
210 |
|
* as it might decide to further instantiate some lemmas, precluding |
211 |
|
* a SAT response. |
212 |
|
*/ |
213 |
4943898 |
bool needCheck() const { return d_outputChannelUsed || d_lemmasAdded; } |
214 |
|
/** |
215 |
|
* Is the literal lit (possibly) critical for satisfying the input formula in |
216 |
|
* the current context? This call is applicable only during collectModelInfo |
217 |
|
* or during LAST_CALL effort. |
218 |
|
*/ |
219 |
|
bool isRelevant(Node lit) const; |
220 |
|
/** |
221 |
|
* This is called at shutdown time by the SmtEngine, just before |
222 |
|
* destruction. It is important because there are destruction |
223 |
|
* ordering issues between PropEngine and Theory. |
224 |
|
*/ |
225 |
|
void shutdown(); |
226 |
|
|
227 |
|
/** |
228 |
|
* Solve the given literal with a theory that owns it. The proof of tliteral |
229 |
|
* is carried in the trust node. The proof added to substitutionOut should |
230 |
|
* take this proof into account (when proofs are enabled). |
231 |
|
*/ |
232 |
|
theory::Theory::PPAssertStatus solve( |
233 |
|
TrustNode tliteral, theory::TrustSubstitutionMap& substitutionOut); |
234 |
|
|
235 |
|
/** |
236 |
|
* Preregister a Theory atom with the responsible theory (or |
237 |
|
* theories). |
238 |
|
*/ |
239 |
|
void preRegister(TNode preprocessed); |
240 |
|
|
241 |
|
/** |
242 |
|
* Assert the formula to the appropriate theory. |
243 |
|
* @param node the assertion |
244 |
|
*/ |
245 |
|
void assertFact(TNode node); |
246 |
|
|
247 |
|
/** |
248 |
|
* Check all (currently-active) theories for conflicts. |
249 |
|
* @param effort the effort level to use |
250 |
|
*/ |
251 |
|
void check(theory::Theory::Effort effort); |
252 |
|
|
253 |
|
/** |
254 |
|
* Calls ppStaticLearn() on all theories, accumulating their |
255 |
|
* combined contributions in the "learned" builder. |
256 |
|
*/ |
257 |
|
void ppStaticLearn(TNode in, NodeBuilder& learned); |
258 |
|
|
259 |
|
/** |
260 |
|
* Calls presolve() on all theories and returns true |
261 |
|
* if one of the theories discovers a conflict. |
262 |
|
*/ |
263 |
|
bool presolve(); |
264 |
|
|
265 |
|
/** |
266 |
|
* Calls postsolve() on all theories. |
267 |
|
*/ |
268 |
|
void postsolve(); |
269 |
|
|
270 |
|
/** |
271 |
|
* Calls notifyRestart() on all active theories. |
272 |
|
*/ |
273 |
|
void notifyRestart(); |
274 |
|
|
275 |
11394364 |
void getPropagatedLiterals(std::vector<TNode>& literals) |
276 |
|
{ |
277 |
25801102 |
for (; d_propagatedLiteralsIndex < d_propagatedLiterals.size(); |
278 |
14406738 |
d_propagatedLiteralsIndex = d_propagatedLiteralsIndex + 1) |
279 |
|
{ |
280 |
14406738 |
Debug("getPropagatedLiterals") |
281 |
7203369 |
<< "TheoryEngine::getPropagatedLiterals: propagating: " |
282 |
7203369 |
<< d_propagatedLiterals[d_propagatedLiteralsIndex] << std::endl; |
283 |
7203369 |
literals.push_back(d_propagatedLiterals[d_propagatedLiteralsIndex]); |
284 |
|
} |
285 |
4190995 |
} |
286 |
|
|
287 |
|
/** |
288 |
|
* Returns the next decision request, or null if none exist. The next |
289 |
|
* decision request is a literal that this theory engine prefers the SAT |
290 |
|
* solver to make as its next decision. Decision requests are managed by |
291 |
|
* the decision manager d_decManager. |
292 |
|
*/ |
293 |
|
Node getNextDecisionRequest(); |
294 |
|
|
295 |
|
bool properConflict(TNode conflict) const; |
296 |
|
|
297 |
|
/** |
298 |
|
* Returns an explanation of the node propagated to the SAT solver. |
299 |
|
*/ |
300 |
|
TrustNode getExplanation(TNode node); |
301 |
|
|
302 |
|
/** |
303 |
|
* Get the pointer to the model object used by this theory engine. |
304 |
|
*/ |
305 |
|
theory::TheoryModel* getModel(); |
306 |
|
/** |
307 |
|
* Get the current model for the current set of assertions. This method |
308 |
|
* should only be called immediately after a satisfiable or unknown |
309 |
|
* response to a check-sat call, and only if produceModels is true. |
310 |
|
* |
311 |
|
* If the model is not already built, this will cause this theory engine |
312 |
|
* to build the model. |
313 |
|
* |
314 |
|
* If the model is not available (for instance, if the last call to check-sat |
315 |
|
* was interrupted), then this returns the null pointer. |
316 |
|
*/ |
317 |
|
theory::TheoryModel* getBuiltModel(); |
318 |
|
/** |
319 |
|
* This forces the model maintained by the combination engine to be built |
320 |
|
* if it has not been done so already. This should be called only during a |
321 |
|
* last call effort check after theory combination is run. |
322 |
|
* |
323 |
|
* @return true if the model was successfully built (possibly prior to this |
324 |
|
* call). |
325 |
|
*/ |
326 |
|
bool buildModel(); |
327 |
|
|
328 |
|
/** |
329 |
|
* Get the theory associated to a given Node. |
330 |
|
* |
331 |
|
* @returns the theory, or NULL if the TNode is |
332 |
|
* of built-in type. |
333 |
|
*/ |
334 |
2360783 |
theory::Theory* theoryOf(TNode node) const |
335 |
|
{ |
336 |
2360783 |
return d_theoryTable[theory::Theory::theoryOf(node)]; |
337 |
|
} |
338 |
|
|
339 |
|
/** |
340 |
|
* Get the theory associated to a the given theory id. |
341 |
|
* |
342 |
|
* @returns the theory |
343 |
|
*/ |
344 |
43313663 |
theory::Theory* theoryOf(theory::TheoryId theoryId) const |
345 |
|
{ |
346 |
43313663 |
Assert(theoryId < theory::THEORY_LAST); |
347 |
43313663 |
return d_theoryTable[theoryId]; |
348 |
|
} |
349 |
|
|
350 |
1956963 |
bool isTheoryEnabled(theory::TheoryId theoryId) const |
351 |
|
{ |
352 |
1956963 |
return d_logicInfo.isTheoryEnabled(theoryId); |
353 |
|
} |
354 |
|
/** get the logic info used by this theory engine */ |
355 |
|
const LogicInfo& getLogicInfo() const; |
356 |
|
/** get the separation logic heap types */ |
357 |
|
bool getSepHeapTypes(TypeNode& locType, TypeNode& dataType) const; |
358 |
|
|
359 |
|
/** |
360 |
|
* Declare heap. This is used for separation logics to set the location |
361 |
|
* and data types. It should be called only once, and before any separation |
362 |
|
* logic constraints are asserted to this theory engine. |
363 |
|
*/ |
364 |
|
void declareSepHeap(TypeNode locT, TypeNode dataT); |
365 |
|
|
366 |
|
/** |
367 |
|
* Returns the equality status of the two terms, from the theory |
368 |
|
* that owns the domain type. The types of a and b must be the same. |
369 |
|
*/ |
370 |
|
theory::EqualityStatus getEqualityStatus(TNode a, TNode b); |
371 |
|
|
372 |
|
/** |
373 |
|
* Returns the value that a theory that owns the type of var currently |
374 |
|
* has (or null if none); |
375 |
|
*/ |
376 |
|
Node getModelValue(TNode var); |
377 |
|
|
378 |
|
/** |
379 |
|
* Get relevant assertions. This returns a set of assertions that are |
380 |
|
* currently asserted to this TheoryEngine that propositionally entail the |
381 |
|
* (preprocessed) input formula and all theory lemmas that have been marked |
382 |
|
* NEEDS_JUSTIFY. For more details on this, see relevance_manager.h. |
383 |
|
* |
384 |
|
* This method updates success to false if the set of relevant assertions |
385 |
|
* is not available. This may occur if we are not in SAT mode, if the |
386 |
|
* relevance manager is disabled (see option::relevanceFilter) or if the |
387 |
|
* relevance manager failed to compute relevant assertions due to an internal |
388 |
|
* error. |
389 |
|
*/ |
390 |
|
const std::unordered_set<TNode>& getRelevantAssertions(bool& success); |
391 |
|
|
392 |
|
/** |
393 |
|
* Forwards an entailment check according to the given theoryOfMode. |
394 |
|
* See theory.h for documentation on entailmentCheck(). |
395 |
|
*/ |
396 |
|
std::pair<bool, Node> entailmentCheck(options::TheoryOfMode mode, TNode lit); |
397 |
|
|
398 |
|
//---------------------- information about cardinality of types |
399 |
|
/** |
400 |
|
* Is the cardinality of type tn finite? This method depends on whether |
401 |
|
* finite model finding is enabled. If finite model finding is enabled, then |
402 |
|
* we assume that all uninterpreted sorts have finite cardinality. |
403 |
|
* |
404 |
|
* Notice that if finite model finding is enabled, this method returns true |
405 |
|
* if tn is an uninterpreted sort. It also returns true for the sort |
406 |
|
* (Array Int U) where U is an uninterpreted sort. This type |
407 |
|
* is finite if and only if U has cardinality one; for cases like this, |
408 |
|
* we conservatively return that tn has finite cardinality. |
409 |
|
* |
410 |
|
* This method does *not* depend on the state of the theory engine, e.g. |
411 |
|
* if U in the above example currently is entailed to have cardinality >1 |
412 |
|
* based on the assertions. |
413 |
|
*/ |
414 |
|
bool isFiniteType(TypeNode tn) const; |
415 |
|
//---------------------- end information about cardinality of types |
416 |
|
|
417 |
5177 |
theory::SortInference* getSortInference() { return d_sortInfer.get(); } |
418 |
|
|
419 |
|
/** Prints the assertions to the debug stream */ |
420 |
|
void printAssertions(const char* tag); |
421 |
|
|
422 |
|
/** |
423 |
|
* Check that the theory assertions are satisfied in the model. |
424 |
|
* This function is called from the smt engine's checkModel routine. |
425 |
|
*/ |
426 |
|
void checkTheoryAssertionsWithModel(bool hardFailure); |
427 |
|
|
428 |
|
private: |
429 |
|
typedef context:: |
430 |
|
CDHashMap<NodeTheoryPair, NodeTheoryPair, NodeTheoryPairHashFunction> |
431 |
|
PropagationMap; |
432 |
|
|
433 |
|
/** |
434 |
|
* Called by the theories to notify of a conflict. |
435 |
|
* |
436 |
|
* @param conflict The trust node containing the conflict and its proof |
437 |
|
* generator (if it exists), |
438 |
|
* @param theoryId The theory that sent the conflict |
439 |
|
*/ |
440 |
|
void conflict(TrustNode conflict, theory::TheoryId theoryId); |
441 |
|
|
442 |
|
/** set in conflict */ |
443 |
|
void markInConflict(); |
444 |
|
|
445 |
|
/** |
446 |
|
* Called by the theories to notify that the current branch is incomplete. |
447 |
|
*/ |
448 |
|
void setIncomplete(theory::TheoryId theory, theory::IncompleteId id); |
449 |
|
|
450 |
|
/** |
451 |
|
* Called by the output channel to propagate literals and facts |
452 |
|
* @return false if immediate conflict |
453 |
|
*/ |
454 |
|
bool propagate(TNode literal, theory::TheoryId theory); |
455 |
|
|
456 |
|
/** |
457 |
|
* Internal method to call the propagation routines and collect the |
458 |
|
* propagated literals. |
459 |
|
*/ |
460 |
|
void propagate(theory::Theory::Effort effort); |
461 |
|
|
462 |
|
/** |
463 |
|
* Assert the formula to the given theory. |
464 |
|
* @param assertion the assertion to send (not necesserily normalized) |
465 |
|
* @param original the assertion as it was sent in from the propagating theory |
466 |
|
* @param toTheoryId the theory to assert to |
467 |
|
* @param fromTheoryId the theory that sent it |
468 |
|
*/ |
469 |
|
void assertToTheory(TNode assertion, |
470 |
|
TNode originalAssertion, |
471 |
|
theory::TheoryId toTheoryId, |
472 |
|
theory::TheoryId fromTheoryId); |
473 |
|
|
474 |
|
/** |
475 |
|
* Marks a theory propagation from a theory to a theory where a |
476 |
|
* theory could be the THEORY_SAT_SOLVER for literals coming from |
477 |
|
* or being propagated to the SAT solver. If the receiving theory |
478 |
|
* already recieved the literal, the method returns false, otherwise |
479 |
|
* it returns true. |
480 |
|
* |
481 |
|
* @param assertion the normalized assertion being sent |
482 |
|
* @param originalAssertion the actual assertion that was sent |
483 |
|
* @param toTheoryId the theory that is on the receiving end |
484 |
|
* @param fromTheoryId the theory that sent the assertion |
485 |
|
* @return true if a new assertion, false if theory already got it |
486 |
|
*/ |
487 |
|
bool markPropagation(TNode assertion, |
488 |
|
TNode originalAssertions, |
489 |
|
theory::TheoryId toTheoryId, |
490 |
|
theory::TheoryId fromTheoryId); |
491 |
|
|
492 |
|
/** |
493 |
|
* Computes the explanation by traversing the propagation graph and |
494 |
|
* asking relevant theories to explain the propagations. Initially |
495 |
|
* the explanation vector should contain only the element (node, theory) |
496 |
|
* where the node is the one to be explained, and the theory is the |
497 |
|
* theory that sent the literal. |
498 |
|
*/ |
499 |
|
TrustNode getExplanation(std::vector<NodeTheoryPair>& explanationVector); |
500 |
|
|
501 |
|
/** Are proofs enabled? */ |
502 |
|
bool isProofEnabled() const; |
503 |
|
|
504 |
|
/** |
505 |
|
* Get a pointer to the rewriter owned by the associated Env. |
506 |
|
*/ |
507 |
|
theory::Rewriter* getRewriter(); |
508 |
|
|
509 |
|
/** |
510 |
|
* Adds a new lemma, returning its status. |
511 |
|
* @param node the lemma |
512 |
|
* @param p the properties of the lemma. |
513 |
|
* @param atomsTo the theory that atoms of the lemma should be sent to |
514 |
|
* @param from the theory that sent the lemma |
515 |
|
*/ |
516 |
|
void lemma(TrustNode node, |
517 |
|
theory::LemmaProperty p, |
518 |
|
theory::TheoryId from = theory::THEORY_LAST); |
519 |
|
|
520 |
|
/** Ensure atoms from the given node are sent to the given theory */ |
521 |
|
void ensureLemmaAtoms(TNode n, theory::TheoryId atomsTo); |
522 |
|
/** Ensure that the given atoms are sent to the given theory */ |
523 |
|
void ensureLemmaAtoms(const std::vector<TNode>& atoms, |
524 |
|
theory::TheoryId atomsTo); |
525 |
|
|
526 |
|
/** Dump the assertions to the dump */ |
527 |
|
void dumpAssertions(const char* tag); |
528 |
|
|
529 |
|
/** Associated PropEngine engine */ |
530 |
|
prop::PropEngine* d_propEngine; |
531 |
|
|
532 |
|
/** |
533 |
|
* A table of from theory IDs to theory pointers. Never use this table |
534 |
|
* directly, use theoryOf() instead. |
535 |
|
*/ |
536 |
|
theory::Theory* d_theoryTable[theory::THEORY_LAST]; |
537 |
|
|
538 |
|
/** |
539 |
|
* A collection of theories that are "active" for the current run. |
540 |
|
* This set is provided by the user (as a logic string, say, in SMT-LIBv2 |
541 |
|
* format input), or else by default it's all-inclusive. This is important |
542 |
|
* because we can optimize for single-theory runs (no sharing), can reduce |
543 |
|
* the cost of walking the DAG on registration, etc. |
544 |
|
*/ |
545 |
|
const LogicInfo& d_logicInfo; |
546 |
|
|
547 |
|
/** The separation logic location and data types */ |
548 |
|
TypeNode d_sepLocType; |
549 |
|
TypeNode d_sepDataType; |
550 |
|
|
551 |
|
//--------------------------------- new proofs |
552 |
|
/** Proof node manager used by this theory engine, if proofs are enabled */ |
553 |
|
ProofNodeManager* d_pnm; |
554 |
|
/** The lazy proof object |
555 |
|
* |
556 |
|
* This stores instructions for how to construct proofs for all theory lemmas. |
557 |
|
*/ |
558 |
|
std::shared_ptr<LazyCDProof> d_lazyProof; |
559 |
|
/** The proof generator */ |
560 |
|
std::shared_ptr<TheoryEngineProofGenerator> d_tepg; |
561 |
|
//--------------------------------- end new proofs |
562 |
|
/** The combination manager we are using */ |
563 |
|
std::unique_ptr<theory::CombinationEngine> d_tc; |
564 |
|
/** The shared solver of the above combination engine. */ |
565 |
|
theory::SharedSolver* d_sharedSolver; |
566 |
|
/** The quantifiers engine, which is owned by the quantifiers theory */ |
567 |
|
theory::QuantifiersEngine* d_quantEngine; |
568 |
|
/** |
569 |
|
* The decision manager |
570 |
|
*/ |
571 |
|
std::unique_ptr<theory::DecisionManager> d_decManager; |
572 |
|
/** The relevance manager */ |
573 |
|
std::unique_ptr<theory::RelevanceManager> d_relManager; |
574 |
|
/** |
575 |
|
* An empty set of relevant assertions, which is returned as a dummy value for |
576 |
|
* getRelevantAssertions when relevance is disabled. |
577 |
|
*/ |
578 |
|
std::unordered_set<TNode> d_emptyRelevantSet; |
579 |
|
|
580 |
|
/** are we in eager model building mode? (see setEagerModelBuilding). */ |
581 |
|
bool d_eager_model_building; |
582 |
|
|
583 |
|
/** |
584 |
|
* Output channels for individual theories. |
585 |
|
*/ |
586 |
|
theory::EngineOutputChannel* d_theoryOut[theory::THEORY_LAST]; |
587 |
|
|
588 |
|
/** |
589 |
|
* Are we in conflict. |
590 |
|
*/ |
591 |
|
context::CDO<bool> d_inConflict; |
592 |
|
|
593 |
|
/** |
594 |
|
* Are we in "SAT mode"? In this state, the user can query for the model. |
595 |
|
* This corresponds to the state in Figure 4.1, page 52 of the SMT-LIB |
596 |
|
* standard, version 2.6. |
597 |
|
*/ |
598 |
|
bool d_inSatMode; |
599 |
|
|
600 |
|
/** |
601 |
|
* Debugging flag to ensure that shutdown() is called before the |
602 |
|
* destructor. |
603 |
|
*/ |
604 |
|
bool d_hasShutDown; |
605 |
|
|
606 |
|
/** |
607 |
|
* True if a theory has notified us of incompleteness (at this |
608 |
|
* context level or below). |
609 |
|
*/ |
610 |
|
context::CDO<bool> d_incomplete; |
611 |
|
/** The theory and identifier that (most recently) set incomplete */ |
612 |
|
context::CDO<theory::TheoryId> d_incompleteTheory; |
613 |
|
context::CDO<theory::IncompleteId> d_incompleteId; |
614 |
|
|
615 |
|
/** |
616 |
|
* Mapping of propagations from recievers to senders. |
617 |
|
*/ |
618 |
|
PropagationMap d_propagationMap; |
619 |
|
|
620 |
|
/** |
621 |
|
* Timestamp of propagations |
622 |
|
*/ |
623 |
|
context::CDO<size_t> d_propagationMapTimestamp; |
624 |
|
|
625 |
|
/** |
626 |
|
* Literals that are propagated by the theory. Note that these are TNodes. |
627 |
|
* The theory can only propagate nodes that have an assigned literal in the |
628 |
|
* SAT solver and are hence referenced in the SAT solver. |
629 |
|
*/ |
630 |
|
context::CDList<TNode> d_propagatedLiterals; |
631 |
|
|
632 |
|
/** |
633 |
|
* The index of the next literal to be propagated by a theory. |
634 |
|
*/ |
635 |
|
context::CDO<unsigned> d_propagatedLiteralsIndex; |
636 |
|
|
637 |
|
/** |
638 |
|
* A variable to mark if we added any lemmas. |
639 |
|
*/ |
640 |
|
bool d_lemmasAdded; |
641 |
|
|
642 |
|
/** |
643 |
|
* A variable to mark if the OutputChannel was "used" by any theory |
644 |
|
* since the start of the last check. If it has been, we require |
645 |
|
* a FULL_EFFORT check before exiting and reporting SAT. |
646 |
|
* |
647 |
|
* See the documentation for the needCheck() function, below. |
648 |
|
*/ |
649 |
|
bool d_outputChannelUsed; |
650 |
|
|
651 |
|
/** Atom requests from lemmas */ |
652 |
|
AtomRequests d_atomRequests; |
653 |
|
|
654 |
|
/** sort inference module */ |
655 |
|
std::unique_ptr<theory::SortInference> d_sortInfer; |
656 |
|
|
657 |
|
/** Time spent in theory combination */ |
658 |
|
TimerStat d_combineTheoriesTime; |
659 |
|
|
660 |
|
Node d_true; |
661 |
|
Node d_false; |
662 |
|
|
663 |
|
/** Whether we were just interrupted (or not) */ |
664 |
|
bool d_interrupted; |
665 |
|
|
666 |
|
/** |
667 |
|
* Queue of nodes for pre-registration. |
668 |
|
*/ |
669 |
|
std::queue<TNode> d_preregisterQueue; |
670 |
|
|
671 |
|
/** |
672 |
|
* Boolean flag denoting we are in pre-registration. |
673 |
|
*/ |
674 |
|
bool d_inPreregister; |
675 |
|
|
676 |
|
/** |
677 |
|
* Did the theories get any new facts since the last time we called |
678 |
|
* check() |
679 |
|
*/ |
680 |
|
context::CDO<bool> d_factsAsserted; |
681 |
|
|
682 |
|
}; /* class TheoryEngine */ |
683 |
|
|
684 |
|
} // namespace cvc5 |
685 |
|
|
686 |
|
#endif /* CVC5__THEORY_ENGINE_H */ |