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