549f4078e1fbe98361b3deb270d0c4394e96e11e
[cvc5.git] / src / theory / theory_engine.h
1 /********************* */
2 /*! \file theory_engine.h
3 ** \verbatim
4 ** Top contributors (to current version):
5 ** Dejan Jovanovic, Andrew Reynolds, Morgan Deters
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 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.\endverbatim
11 **
12 ** \brief The theory engine
13 **
14 ** The theory engine.
15 **/
16
17 #include "cvc4_private.h"
18
19 #ifndef CVC4__THEORY_ENGINE_H
20 #define CVC4__THEORY_ENGINE_H
21
22 #include <deque>
23 #include <memory>
24 #include <set>
25 #include <unordered_map>
26 #include <utility>
27 #include <vector>
28
29 #include "base/check.h"
30 #include "context/cdhashset.h"
31 #include "expr/node.h"
32 #include "options/options.h"
33 #include "options/smt_options.h"
34 #include "options/theory_options.h"
35 #include "prop/prop_engine.h"
36 #include "smt/command.h"
37 #include "theory/atom_requests.h"
38 #include "theory/engine_output_channel.h"
39 #include "theory/interrupted.h"
40 #include "theory/rewriter.h"
41 #include "theory/shared_terms_database.h"
42 #include "theory/sort_inference.h"
43 #include "theory/substitutions.h"
44 #include "theory/term_registration_visitor.h"
45 #include "theory/theory.h"
46 #include "theory/theory_preprocessor.h"
47 #include "theory/uf/equality_engine.h"
48 #include "theory/valuation.h"
49 #include "util/hash.h"
50 #include "util/resource_manager.h"
51 #include "util/statistics_registry.h"
52 #include "util/unsafe_interrupt_exception.h"
53
54 namespace CVC4 {
55
56 class ResourceManager;
57 class LemmaProofRecipe;
58
59 /**
60 * A pair of a theory and a node. This is used to mark the flow of
61 * propagations between theories.
62 */
63 struct NodeTheoryPair {
64 Node d_node;
65 theory::TheoryId d_theory;
66 size_t d_timestamp;
67 NodeTheoryPair(TNode n, theory::TheoryId t, size_t ts = 0)
68 : d_node(n), d_theory(t), d_timestamp(ts)
69 {
70 }
71 NodeTheoryPair() : d_theory(theory::THEORY_LAST), d_timestamp() {}
72 // Comparison doesn't take into account the timestamp
73 bool operator == (const NodeTheoryPair& pair) const {
74 return d_node == pair.d_node && d_theory == pair.d_theory;
75 }
76 };/* struct NodeTheoryPair */
77
78 struct NodeTheoryPairHashFunction {
79 NodeHashFunction hashFunction;
80 // Hash doesn't take into account the timestamp
81 size_t operator()(const NodeTheoryPair& pair) const {
82 uint64_t hash = fnv1a::fnv1a_64(NodeHashFunction()(pair.d_node));
83 return static_cast<size_t>(fnv1a::fnv1a_64(pair.d_theory, hash));
84 }
85 };/* struct NodeTheoryPairHashFunction */
86
87
88 /* Forward declarations */
89 namespace theory {
90 class TheoryModel;
91 class TheoryEngineModelBuilder;
92 class EqEngineManagerDistributed;
93
94 class DecisionManager;
95 class RelevanceManager;
96
97 namespace eq {
98 class EqualityEngine;
99 }/* CVC4::theory::eq namespace */
100
101 namespace quantifiers {
102 class TermDb;
103 }
104
105 class EntailmentCheckParameters;
106 class EntailmentCheckSideEffects;
107 }/* CVC4::theory namespace */
108
109 class RemoveTermFormulas;
110
111 /**
112 * This is essentially an abstraction for a collection of theories. A
113 * TheoryEngine provides services to a PropEngine, making various
114 * T-solvers look like a single unit to the propositional part of
115 * CVC4.
116 */
117 class TheoryEngine {
118
119 /** Shared terms database can use the internals notify the theories */
120 friend class SharedTermsDatabase;
121 friend class theory::quantifiers::TermDb;
122 friend class theory::EngineOutputChannel;
123
124 /** Associated PropEngine engine */
125 prop::PropEngine* d_propEngine;
126
127 /** Our context */
128 context::Context* d_context;
129
130 /** Our user context */
131 context::UserContext* d_userContext;
132
133 /**
134 * A table of from theory IDs to theory pointers. Never use this table
135 * directly, use theoryOf() instead.
136 */
137 theory::Theory* d_theoryTable[theory::THEORY_LAST];
138
139 /**
140 * A collection of theories that are "active" for the current run.
141 * This set is provided by the user (as a logic string, say, in SMT-LIBv2
142 * format input), or else by default it's all-inclusive. This is important
143 * because we can optimize for single-theory runs (no sharing), can reduce
144 * the cost of walking the DAG on registration, etc.
145 */
146 const LogicInfo& d_logicInfo;
147
148 /**
149 * The database of shared terms.
150 */
151 SharedTermsDatabase d_sharedTerms;
152
153 /**
154 * The distributed equality manager. This class is responsible for
155 * configuring the theories of this class for handling equalties
156 * in a "distributed" fashion, i.e. each theory maintains a unique
157 * instance of an equality engine. These equality engines are memory
158 * managed by this class.
159 */
160 std::unique_ptr<theory::EqEngineManagerDistributed> d_eeDistributed;
161
162 /**
163 * The quantifiers engine
164 */
165 theory::QuantifiersEngine* d_quantEngine;
166 /**
167 * The decision manager
168 */
169 std::unique_ptr<theory::DecisionManager> d_decManager;
170 /** The relevance manager */
171 std::unique_ptr<theory::RelevanceManager> d_relManager;
172
173 /**
174 * Default model object
175 */
176 theory::TheoryModel* d_curr_model;
177 bool d_aloc_curr_model;
178 /**
179 * Model builder object
180 */
181 theory::TheoryEngineModelBuilder* d_curr_model_builder;
182 bool d_aloc_curr_model_builder;
183 /** are we in eager model building mode? (see setEagerModelBuilding). */
184 bool d_eager_model_building;
185
186 typedef std::unordered_map<Node, Node, NodeHashFunction> NodeMap;
187 typedef std::unordered_map<TNode, Node, TNodeHashFunction> TNodeMap;
188
189 /**
190 * Used for "missed-t-propagations" dumping mode only. A set of all
191 * theory-propagable literals.
192 */
193 context::CDList<TNode> d_possiblePropagations;
194
195 /**
196 * Used for "missed-t-propagations" dumping mode only. A
197 * context-dependent set of those theory-propagable literals that
198 * have been propagated.
199 */
200 context::CDHashSet<Node, NodeHashFunction> d_hasPropagated;
201
202 /**
203 * Output channels for individual theories.
204 */
205 theory::EngineOutputChannel* d_theoryOut[theory::THEORY_LAST];
206
207 /**
208 * Are we in conflict.
209 */
210 context::CDO<bool> d_inConflict;
211
212 /**
213 * Are we in "SAT mode"? In this state, the user can query for the model.
214 * This corresponds to the state in Figure 4.1, page 52 of the SMT-LIB
215 * standard, version 2.6.
216 */
217 bool d_inSatMode;
218
219 /**
220 * Called by the theories to notify of a conflict.
221 */
222 void conflict(TNode conflict, theory::TheoryId theoryId);
223
224 /**
225 * Debugging flag to ensure that shutdown() is called before the
226 * destructor.
227 */
228 bool d_hasShutDown;
229
230 /**
231 * True if a theory has notified us of incompleteness (at this
232 * context level or below).
233 */
234 context::CDO<bool> d_incomplete;
235
236 /**
237 * Called by the theories to notify that the current branch is incomplete.
238 */
239 void setIncomplete(theory::TheoryId theory) {
240 d_incomplete = true;
241 }
242
243
244 /**
245 * Mapping of propagations from recievers to senders.
246 */
247 typedef context::CDHashMap<NodeTheoryPair, NodeTheoryPair, NodeTheoryPairHashFunction> PropagationMap;
248 PropagationMap d_propagationMap;
249
250 /**
251 * Timestamp of propagations
252 */
253 context::CDO<size_t> d_propagationMapTimestamp;
254
255 /**
256 * Literals that are propagated by the theory. Note that these are TNodes.
257 * The theory can only propagate nodes that have an assigned literal in the
258 * SAT solver and are hence referenced in the SAT solver.
259 */
260 context::CDList<TNode> d_propagatedLiterals;
261
262 /**
263 * The index of the next literal to be propagated by a theory.
264 */
265 context::CDO<unsigned> d_propagatedLiteralsIndex;
266
267 /**
268 * Called by the output channel to propagate literals and facts
269 * @return false if immediate conflict
270 */
271 bool propagate(TNode literal, theory::TheoryId theory);
272
273 /**
274 * Internal method to call the propagation routines and collect the
275 * propagated literals.
276 */
277 void propagate(theory::Theory::Effort effort);
278
279 /**
280 * A variable to mark if we added any lemmas.
281 */
282 bool d_lemmasAdded;
283
284 /**
285 * A variable to mark if the OutputChannel was "used" by any theory
286 * since the start of the last check. If it has been, we require
287 * a FULL_EFFORT check before exiting and reporting SAT.
288 *
289 * See the documentation for the needCheck() function, below.
290 */
291 bool d_outputChannelUsed;
292
293 /** Atom requests from lemmas */
294 AtomRequests d_atomRequests;
295
296 /**
297 * Adds a new lemma, returning its status.
298 * @param node the lemma
299 * @param negated should the lemma be asserted negated
300 * @param p the properties of the lemma.
301 */
302 theory::LemmaStatus lemma(TNode node,
303 ProofRule rule,
304 bool negated,
305 theory::LemmaProperty p,
306 theory::TheoryId atomsTo);
307
308 /** Enusre that the given atoms are send to the given theory */
309 void ensureLemmaAtoms(const std::vector<TNode>& atoms, theory::TheoryId theory);
310
311 /** sort inference module */
312 SortInference d_sortInfer;
313
314 /** The theory preprocessor */
315 theory::TheoryPreprocessor d_tpp;
316
317 /** Time spent in theory combination */
318 TimerStat d_combineTheoriesTime;
319
320 Node d_true;
321 Node d_false;
322
323 /** Whether we were just interrupted (or not) */
324 bool d_interrupted;
325 ResourceManager* d_resourceManager;
326
327 public:
328 /** Constructs a theory engine */
329 TheoryEngine(context::Context* context,
330 context::UserContext* userContext,
331 ResourceManager* rm,
332 RemoveTermFormulas& iteRemover,
333 const LogicInfo& logic);
334
335 /** Destroys a theory engine */
336 ~TheoryEngine();
337
338 void interrupt();
339
340 /** "Spend" a resource during a search or preprocessing.*/
341 void spendResource(ResourceManager::Resource r);
342
343 /**
344 * Adds a theory. Only one theory per TheoryId can be present, so if
345 * there is another theory it will be deleted.
346 */
347 template <class TheoryClass>
348 inline void addTheory(theory::TheoryId theoryId)
349 {
350 Assert(d_theoryTable[theoryId] == NULL && d_theoryOut[theoryId] == NULL);
351 d_theoryOut[theoryId] = new theory::EngineOutputChannel(this, theoryId);
352 d_theoryTable[theoryId] = new TheoryClass(d_context,
353 d_userContext,
354 *d_theoryOut[theoryId],
355 theory::Valuation(this),
356 d_logicInfo,
357 nullptr);
358 theory::Rewriter::registerTheoryRewriter(
359 theoryId, d_theoryTable[theoryId]->getTheoryRewriter());
360 }
361
362 void setPropEngine(prop::PropEngine* propEngine)
363 {
364 d_propEngine = propEngine;
365 }
366
367 /**
368 * Called when all initialization of options/logic is done, after theory
369 * objects have been created.
370 *
371 * This initializes the quantifiers engine, the "official" equality engines
372 * of each theory as required, and the model and model builder utilities.
373 */
374 void finishInit();
375
376 /**
377 * Get a pointer to the underlying propositional engine.
378 */
379 inline prop::PropEngine* getPropEngine() const {
380 return d_propEngine;
381 }
382
383 /**
384 * Get a pointer to the underlying sat context.
385 */
386 inline context::Context* getSatContext() const {
387 return d_context;
388 }
389
390 /**
391 * Get a pointer to the underlying user context.
392 */
393 inline context::Context* getUserContext() const {
394 return d_userContext;
395 }
396
397 /**
398 * Get a pointer to the underlying quantifiers engine.
399 */
400 theory::QuantifiersEngine* getQuantifiersEngine() const {
401 return d_quantEngine;
402 }
403 /**
404 * Get a pointer to the underlying decision manager.
405 */
406 theory::DecisionManager* getDecisionManager() const
407 {
408 return d_decManager.get();
409 }
410
411 private:
412 /**
413 * Queue of nodes for pre-registration.
414 */
415 std::queue<TNode> d_preregisterQueue;
416
417 /**
418 * Boolean flag denoting we are in pre-registration.
419 */
420 bool d_inPreregister;
421
422 /**
423 * Did the theories get any new facts since the last time we called
424 * check()
425 */
426 context::CDO<bool> d_factsAsserted;
427
428 /**
429 * Map from equality atoms to theories that would like to be notified about them.
430 */
431
432
433 /**
434 * Assert the formula to the given theory.
435 * @param assertion the assertion to send (not necesserily normalized)
436 * @param original the assertion as it was sent in from the propagating theory
437 * @param toTheoryId the theory to assert to
438 * @param fromTheoryId the theory that sent it
439 */
440 void assertToTheory(TNode assertion, TNode originalAssertion, theory::TheoryId toTheoryId, theory::TheoryId fromTheoryId);
441
442 /**
443 * Marks a theory propagation from a theory to a theory where a
444 * theory could be the THEORY_SAT_SOLVER for literals coming from
445 * or being propagated to the SAT solver. If the receiving theory
446 * already recieved the literal, the method returns false, otherwise
447 * it returns true.
448 *
449 * @param assertion the normalized assertion being sent
450 * @param originalAssertion the actual assertion that was sent
451 * @param toTheoryId the theory that is on the receiving end
452 * @param fromTheoryId the theory that sent the assertion
453 * @return true if a new assertion, false if theory already got it
454 */
455 bool markPropagation(TNode assertion, TNode originalAssertions, theory::TheoryId toTheoryId, theory::TheoryId fromTheoryId);
456
457 /**
458 * Computes the explanation by travarsing the propagation graph and
459 * asking relevant theories to explain the propagations. Initially
460 * the explanation vector should contain only the element (node, theory)
461 * where the node is the one to be explained, and the theory is the
462 * theory that sent the literal. The lemmaProofRecipe will contain a list
463 * of the explanation steps required to produce the original node.
464 */
465 void getExplanation(std::vector<NodeTheoryPair>& explanationVector, LemmaProofRecipe* lemmaProofRecipe);
466
467 public:
468
469 /**
470 * Signal the start of a new round of assertion preprocessing
471 */
472 void preprocessStart();
473
474 /**
475 * Runs theory specific preprocessing on the non-Boolean parts of
476 * the formula. This is only called on input assertions, after ITEs
477 * have been removed.
478 */
479 Node preprocess(TNode node);
480
481 /** Notify (preprocessed) assertions. */
482 void notifyPreprocessedAssertions(const std::vector<Node>& assertions);
483
484 /** Return whether or not we are incomplete (in the current context). */
485 inline bool isIncomplete() const { return d_incomplete; }
486
487 /**
488 * Returns true if we need another round of checking. If this
489 * returns true, check(FULL_EFFORT) _must_ be called by the
490 * propositional layer before reporting SAT.
491 *
492 * This is especially necessary for incomplete theories that lazily
493 * output some lemmas on FULL_EFFORT check (e.g. quantifier reasoning
494 * outputing quantifier instantiations). In such a case, a lemma can
495 * be asserted that is simplified away (perhaps it's already true).
496 * However, we must maintain the invariant that, if a theory uses the
497 * OutputChannel, it implicitly requests that another check(FULL_EFFORT)
498 * be performed before exit, even if no new facts are on its fact queue,
499 * as it might decide to further instantiate some lemmas, precluding
500 * a SAT response.
501 */
502 inline bool needCheck() const {
503 return d_outputChannelUsed || d_lemmasAdded;
504 }
505 /**
506 * Is the literal lit (possibly) critical for satisfying the input formula in
507 * the current context? This call is applicable only during collectModelInfo
508 * or during LAST_CALL effort.
509 */
510 bool isRelevant(Node lit) const;
511
512 /**
513 * This is called at shutdown time by the SmtEngine, just before
514 * destruction. It is important because there are destruction
515 * ordering issues between PropEngine and Theory.
516 */
517 void shutdown();
518
519 /**
520 * Solve the given literal with a theory that owns it.
521 */
522 theory::Theory::PPAssertStatus solve(TNode literal,
523 theory::SubstitutionMap& substitutionOut);
524
525 /**
526 * Preregister a Theory atom with the responsible theory (or
527 * theories).
528 */
529 void preRegister(TNode preprocessed);
530
531 /**
532 * Assert the formula to the appropriate theory.
533 * @param node the assertion
534 */
535 void assertFact(TNode node);
536
537 /**
538 * Check all (currently-active) theories for conflicts.
539 * @param effort the effort level to use
540 */
541 void check(theory::Theory::Effort effort);
542
543 /**
544 * Run the combination framework.
545 */
546 void combineTheories();
547
548 /**
549 * Calls ppStaticLearn() on all theories, accumulating their
550 * combined contributions in the "learned" builder.
551 */
552 void ppStaticLearn(TNode in, NodeBuilder<>& learned);
553
554 /**
555 * Calls presolve() on all theories and returns true
556 * if one of the theories discovers a conflict.
557 */
558 bool presolve();
559
560 /**
561 * Calls postsolve() on all theories.
562 */
563 void postsolve();
564
565 /**
566 * Calls notifyRestart() on all active theories.
567 */
568 void notifyRestart();
569
570 void getPropagatedLiterals(std::vector<TNode>& literals) {
571 for (; d_propagatedLiteralsIndex < d_propagatedLiterals.size(); d_propagatedLiteralsIndex = d_propagatedLiteralsIndex + 1) {
572 Debug("getPropagatedLiterals") << "TheoryEngine::getPropagatedLiterals: propagating: " << d_propagatedLiterals[d_propagatedLiteralsIndex] << std::endl;
573 literals.push_back(d_propagatedLiterals[d_propagatedLiteralsIndex]);
574 }
575 }
576
577 /**
578 * Returns the next decision request, or null if none exist. The next
579 * decision request is a literal that this theory engine prefers the SAT
580 * solver to make as its next decision. Decision requests are managed by
581 * the decision manager d_decManager.
582 */
583 Node getNextDecisionRequest();
584
585 bool properConflict(TNode conflict) const;
586 bool properPropagation(TNode lit) const;
587 bool properExplanation(TNode node, TNode expl) const;
588
589 /**
590 * Returns an explanation of the node propagated to the SAT solver.
591 */
592 Node getExplanation(TNode node);
593
594 /**
595 * Returns an explanation of the node propagated to the SAT solver and the theory
596 * that propagated it.
597 */
598 Node getExplanationAndRecipe(TNode node, LemmaProofRecipe* proofRecipe);
599
600 /**
601 * collect model info
602 */
603 bool collectModelInfo(theory::TheoryModel* m);
604 /** post process model */
605 void postProcessModel( theory::TheoryModel* m );
606
607 /**
608 * Get the pointer to the model object used by this theory engine.
609 */
610 theory::TheoryModel* getModel();
611 /**
612 * Get the current model for the current set of assertions. This method
613 * should only be called immediately after a satisfiable or unknown
614 * response to a check-sat call, and only if produceModels is true.
615 *
616 * If the model is not already built, this will cause this theory engine
617 * to build the model.
618 *
619 * If the model is not available (for instance, if the last call to check-sat
620 * was interrupted), then this returns the null pointer.
621 */
622 theory::TheoryModel* getBuiltModel();
623 /** set eager model building
624 *
625 * If this method is called, then this TheoryEngine will henceforth build
626 * its model immediately after every satisfiability check that results
627 * in a satisfiable or unknown result. The motivation for this mode is to
628 * accomodate API users that get the model object from the TheoryEngine,
629 * where we want to ensure that this model is always valid.
630 * TODO (#2648): revisit this.
631 */
632 void setEagerModelBuilding() { d_eager_model_building = true; }
633
634 /** get synth solutions
635 *
636 * This method returns true if there is a synthesis solution available. This
637 * is the case if the last call to check satisfiability originated in a
638 * check-synth call, and the synthesis solver successfully found a solution
639 * for all active synthesis conjectures.
640 *
641 * This method adds entries to sol_map that map functions-to-synthesize with
642 * their solutions, for all active conjectures. This should be called
643 * immediately after the solver answers unsat for sygus input.
644 *
645 * For details on what is added to sol_map, see
646 * SynthConjecture::getSynthSolutions.
647 */
648 bool getSynthSolutions(std::map<Node, std::map<Node, Node> >& sol_map);
649
650 /**
651 * Get the model builder
652 */
653 theory::TheoryEngineModelBuilder* getModelBuilder() { return d_curr_model_builder; }
654
655 /**
656 * Get the theory associated to a given Node.
657 *
658 * @returns the theory, or NULL if the TNode is
659 * of built-in type.
660 */
661 inline theory::Theory* theoryOf(TNode node) const {
662 return d_theoryTable[theory::Theory::theoryOf(node)];
663 }
664
665 /**
666 * Get the theory associated to a the given theory id.
667 *
668 * @returns the theory
669 */
670 inline theory::Theory* theoryOf(theory::TheoryId theoryId) const {
671 Assert(theoryId < theory::THEORY_LAST);
672 return d_theoryTable[theoryId];
673 }
674
675 inline bool isTheoryEnabled(theory::TheoryId theoryId) const {
676 return d_logicInfo.isTheoryEnabled(theoryId);
677 }
678 /** get the logic info used by this theory engine */
679 const LogicInfo& getLogicInfo() const;
680 /**
681 * Returns the equality status of the two terms, from the theory
682 * that owns the domain type. The types of a and b must be the same.
683 */
684 theory::EqualityStatus getEqualityStatus(TNode a, TNode b);
685
686 /**
687 * Returns the value that a theory that owns the type of var currently
688 * has (or null if none);
689 */
690 Node getModelValue(TNode var);
691
692 /**
693 * Takes a literal and returns an equivalent literal that is guaranteed to be a SAT literal
694 */
695 Node ensureLiteral(TNode n);
696
697 /**
698 * Print all instantiations made by the quantifiers module.
699 */
700 void printInstantiations( std::ostream& out );
701
702 /**
703 * Print solution for synthesis conjectures found by ce_guided_instantiation module
704 */
705 void printSynthSolution( std::ostream& out );
706
707 /**
708 * Get list of quantified formulas that were instantiated
709 */
710 void getInstantiatedQuantifiedFormulas( std::vector< Node >& qs );
711
712 /**
713 * Get instantiation methods
714 * first inputs forall x.q[x] and returns ( q[a], ..., q[z] )
715 * second inputs forall x.q[x] and returns ( a, ..., z )
716 * third and fourth return mappings e.g. forall x.q1[x] -> ( q1[a]...q1[z] ) , ... , forall x.qn[x] -> ( qn[a]...qn[z] )
717 */
718 void getInstantiations( Node q, std::vector< Node >& insts );
719 void getInstantiationTermVectors( Node q, std::vector< std::vector< Node > >& tvecs );
720 void getInstantiations( std::map< Node, std::vector< Node > >& insts );
721 void getInstantiationTermVectors( std::map< Node, std::vector< std::vector< Node > > >& insts );
722
723 /**
724 * Get instantiated conjunction, returns q[t1] ^ ... ^ q[tn] where t1...tn are current set of instantiations for q.
725 * Can be used for quantifier elimination when satisfiable and q[t1] ^ ... ^ q[tn] |= q
726 */
727 Node getInstantiatedConjunction( Node q );
728
729 /**
730 * Forwards an entailment check according to the given theoryOfMode.
731 * See theory.h for documentation on entailmentCheck().
732 */
733 std::pair<bool, Node> entailmentCheck(options::TheoryOfMode mode, TNode lit);
734
735 private:
736 /** Default visitor for pre-registration */
737 PreRegisterVisitor d_preRegistrationVisitor;
738
739 /** Visitor for collecting shared terms */
740 SharedTermsVisitor d_sharedTermsVisitor;
741
742 /** Dump the assertions to the dump */
743 void dumpAssertions(const char* tag);
744
745 /** For preprocessing pass lifting bit-vectors of size 1 to booleans */
746 public:
747
748 SharedTermsDatabase* getSharedTermsDatabase();
749
750 SortInference* getSortInference() { return &d_sortInfer; }
751
752 /** Prints the assertions to the debug stream */
753 void printAssertions(const char* tag);
754
755 private:
756
757 std::map< std::string, std::vector< theory::Theory* > > d_attr_handle;
758
759 public:
760 /** Set user attribute.
761 *
762 * This function is called when an attribute is set by a user. In SMT-LIBv2
763 * this is done via the syntax (! n :attr)
764 */
765 void setUserAttribute(const std::string& attr,
766 Node n,
767 const std::vector<Node>& node_values,
768 const std::string& str_value);
769
770 /** Handle user attribute.
771 *
772 * Associates theory t with the attribute attr. Theory t will be
773 * notified whenever an attribute of name attr is set.
774 */
775 void handleUserAttribute(const char* attr, theory::Theory* t);
776
777 /**
778 * Check that the theory assertions are satisfied in the model.
779 * This function is called from the smt engine's checkModel routine.
780 */
781 void checkTheoryAssertionsWithModel(bool hardFailure);
782
783 private:
784 IntStat d_arithSubstitutionsAdded;
785
786 };/* class TheoryEngine */
787
788 }/* CVC4 namespace */
789
790 #endif /* CVC4__THEORY_ENGINE_H */