1 /********************* */
2 /*! \file theory_engine.h
4 ** Top contributors (to current version):
5 ** Morgan Deters, Dejan Jovanovic, Andrew Reynolds
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2017 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
12 ** \brief The theory engine
17 #include "cvc4_private.h"
19 #ifndef __CVC4__THEORY_ENGINE_H
20 #define __CVC4__THEORY_ENGINE_H
24 #include <unordered_map>
28 #include "base/cvc4_assert.h"
29 #include "context/cdhashset.h"
30 #include "expr/node.h"
31 #include "options/options.h"
32 #include "options/smt_options.h"
33 #include "prop/prop_engine.h"
34 #include "smt/command.h"
35 #include "smt_util/lemma_channels.h"
36 #include "theory/atom_requests.h"
37 #include "theory/bv/bv_to_bool.h"
38 #include "theory/interrupted.h"
39 #include "theory/rewriter.h"
40 #include "theory/shared_terms_database.h"
41 #include "theory/sort_inference.h"
42 #include "theory/substitutions.h"
43 #include "theory/term_registration_visitor.h"
44 #include "theory/theory.h"
45 #include "theory/uf/equality_engine.h"
46 #include "theory/valuation.h"
47 #include "util/hash.h"
48 #include "util/statistics_registry.h"
49 #include "util/unsafe_interrupt_exception.h"
53 class ResourceManager
;
54 class LemmaProofRecipe
;
57 * A pair of a theory and a node. This is used to mark the flow of
58 * propagations between theories.
60 struct NodeTheoryPair
{
62 theory::TheoryId theory
;
64 NodeTheoryPair(TNode node
, theory::TheoryId theory
, size_t timestamp
= 0)
65 : node(node
), theory(theory
), timestamp(timestamp
) {}
67 : theory(theory::THEORY_LAST
) {}
68 // Comparison doesn't take into account the timestamp
69 bool operator == (const NodeTheoryPair
& pair
) const {
70 return node
== pair
.node
&& theory
== pair
.theory
;
72 };/* struct NodeTheoryPair */
74 struct NodeTheoryPairHashFunction
{
75 NodeHashFunction hashFunction
;
76 // Hash doesn't take into account the timestamp
77 size_t operator()(const NodeTheoryPair
& pair
) const {
78 uint64_t hash
= fnv1a::fnv1a_64(NodeHashFunction()(pair
.node
));
79 return static_cast<size_t>(fnv1a::fnv1a_64(pair
.theory
, hash
));
81 };/* struct NodeTheoryPairHashFunction */
84 /* Forward declarations */
87 class TheoryEngineModelBuilder
;
92 }/* CVC4::theory::eq namespace */
94 namespace quantifiers
{
98 class EntailmentCheckParameters
;
99 class EntailmentCheckSideEffects
;
100 }/* CVC4::theory namespace */
102 class DecisionEngine
;
103 class RemoveTermFormulas
;
104 class UnconstrainedSimplifier
;
107 * This is essentially an abstraction for a collection of theories. A
108 * TheoryEngine provides services to a PropEngine, making various
109 * T-solvers look like a single unit to the propositional part of
114 /** Shared terms database can use the internals notify the theories */
115 friend class SharedTermsDatabase
;
116 friend class theory::quantifiers::TermDb
;
118 /** Associated PropEngine engine */
119 prop::PropEngine
* d_propEngine
;
121 /** Access to decision engine */
122 DecisionEngine
* d_decisionEngine
;
125 context::Context
* d_context
;
127 /** Our user context */
128 context::UserContext
* d_userContext
;
131 * A table of from theory IDs to theory pointers. Never use this table
132 * directly, use theoryOf() instead.
134 theory::Theory
* d_theoryTable
[theory::THEORY_LAST
];
137 * A collection of theories that are "active" for the current run.
138 * This set is provided by the user (as a logic string, say, in SMT-LIBv2
139 * format input), or else by default it's all-inclusive. This is important
140 * because we can optimize for single-theory runs (no sharing), can reduce
141 * the cost of walking the DAG on registration, etc.
143 const LogicInfo
& d_logicInfo
;
146 * The database of shared terms.
148 SharedTermsDatabase d_sharedTerms
;
151 * Master equality engine, to share with theories.
153 theory::eq::EqualityEngine
* d_masterEqualityEngine
;
155 /** notify class for master equality engine */
156 class NotifyClass
: public theory::eq::EqualityEngineNotify
{
159 NotifyClass(TheoryEngine
& te
): d_te(te
) {}
160 bool eqNotifyTriggerEquality(TNode equality
, bool value
) { return true; }
161 bool eqNotifyTriggerPredicate(TNode predicate
, bool value
) { return true; }
162 bool eqNotifyTriggerTermEquality(theory::TheoryId tag
, TNode t1
, TNode t2
, bool value
) { return true; }
163 void eqNotifyConstantTermMerge(TNode t1
, TNode t2
) {}
164 void eqNotifyNewClass(TNode t
) { d_te
.eqNotifyNewClass(t
); }
165 void eqNotifyPreMerge(TNode t1
, TNode t2
) { d_te
.eqNotifyPreMerge(t1
, t2
); }
166 void eqNotifyPostMerge(TNode t1
, TNode t2
) { d_te
.eqNotifyPostMerge(t1
, t2
); }
167 void eqNotifyDisequal(TNode t1
, TNode t2
, TNode reason
) { d_te
.eqNotifyDisequal(t1
, t2
, reason
); }
168 };/* class TheoryEngine::NotifyClass */
169 NotifyClass d_masterEENotify
;
172 * notification methods
174 void eqNotifyNewClass(TNode t
);
175 void eqNotifyPreMerge(TNode t1
, TNode t2
);
176 void eqNotifyPostMerge(TNode t1
, TNode t2
);
177 void eqNotifyDisequal(TNode t1
, TNode t2
, TNode reason
);
180 * The quantifiers engine
182 theory::QuantifiersEngine
* d_quantEngine
;
185 * Default model object
187 theory::TheoryModel
* d_curr_model
;
188 bool d_aloc_curr_model
;
190 * Model builder object
192 theory::TheoryEngineModelBuilder
* d_curr_model_builder
;
193 bool d_aloc_curr_model_builder
;
195 typedef std::unordered_map
<Node
, Node
, NodeHashFunction
> NodeMap
;
196 typedef std::unordered_map
<TNode
, Node
, TNodeHashFunction
> TNodeMap
;
199 * Cache for theory-preprocessing of assertions
204 * Used for "missed-t-propagations" dumping mode only. A set of all
205 * theory-propagable literals.
207 context::CDList
<TNode
> d_possiblePropagations
;
210 * Used for "missed-t-propagations" dumping mode only. A
211 * context-dependent set of those theory-propagable literals that
212 * have been propagated.
214 context::CDHashSet
<Node
, NodeHashFunction
> d_hasPropagated
;
218 * Statistics for a particular theory.
222 static std::string
mkName(std::string prefix
,
223 theory::TheoryId theory
,
224 std::string suffix
) {
225 std::stringstream ss
;
226 ss
<< prefix
<< theory
<< suffix
;
232 IntStat conflicts
, propagations
, lemmas
, requirePhase
, flipDecision
, restartDemands
;
234 Statistics(theory::TheoryId theory
);
236 };/* class TheoryEngine::Statistics */
240 * An output channel for Theory that passes messages
241 * back to a TheoryEngine.
243 class EngineOutputChannel
: public theory::OutputChannel
{
245 friend class TheoryEngine
;
248 * The theory engine we're communicating with.
250 TheoryEngine
* d_engine
;
253 * The statistics of the theory interractions.
255 Statistics d_statistics
;
258 * The theory owning this chanell.
260 theory::TheoryId d_theory
;
264 EngineOutputChannel(TheoryEngine
* engine
, theory::TheoryId theory
) :
266 d_statistics(theory
),
271 void safePoint(uint64_t ammount
) throw(theory::Interrupted
, UnsafeInterruptException
, AssertionException
) {
272 spendResource(ammount
);
273 if (d_engine
->d_interrupted
) {
274 throw theory::Interrupted();
278 void conflict(TNode conflictNode
, Proof
* pf
= NULL
) throw(AssertionException
, UnsafeInterruptException
);
280 bool propagate(TNode literal
) throw(AssertionException
, UnsafeInterruptException
);
282 theory::LemmaStatus
lemma(TNode lemma
,
284 bool removable
= false,
285 bool preprocess
= false,
286 bool sendAtoms
= false);
288 theory::LemmaStatus
splitLemma(TNode lemma
, bool removable
= false);
290 void demandRestart() throw(TypeCheckingExceptionPrivate
, AssertionException
, UnsafeInterruptException
) {
291 NodeManager
* curr
= NodeManager::currentNM();
292 Node restartVar
= curr
->mkSkolem("restartVar",
294 "A boolean variable asserted to be true to force a restart");
295 Trace("theory::restart") << "EngineOutputChannel<" << d_theory
<< ">::restart(" << restartVar
<< ")" << std::endl
;
296 ++ d_statistics
.restartDemands
;
297 lemma(restartVar
, RULE_INVALID
, true);
300 void requirePhase(TNode n
, bool phase
)
301 throw(theory::Interrupted
, AssertionException
, UnsafeInterruptException
) {
302 Debug("theory") << "EngineOutputChannel::requirePhase("
303 << n
<< ", " << phase
<< ")" << std::endl
;
304 ++ d_statistics
.requirePhase
;
305 d_engine
->d_propEngine
->requirePhase(n
, phase
);
309 throw(theory::Interrupted
, AssertionException
, UnsafeInterruptException
) {
310 Debug("theory") << "EngineOutputChannel::flipDecision()" << std::endl
;
311 ++ d_statistics
.flipDecision
;
312 return d_engine
->d_propEngine
->flipDecision();
315 void setIncomplete() throw(AssertionException
, UnsafeInterruptException
) {
316 Trace("theory") << "TheoryEngine::setIncomplete()" << std::endl
;
317 d_engine
->setIncomplete(d_theory
);
320 void spendResource(unsigned ammount
) throw(UnsafeInterruptException
) {
321 d_engine
->spendResource(ammount
);
324 void handleUserAttribute( const char* attr
, theory::Theory
* t
){
325 d_engine
->handleUserAttribute( attr
, t
);
331 * A helper function for registering lemma recipes with the proof engine
333 void registerLemmaRecipe(Node lemma
, Node originalLemma
, bool preprocess
, theory::TheoryId theoryId
);
334 };/* class TheoryEngine::EngineOutputChannel */
337 * Output channels for individual theories.
339 EngineOutputChannel
* d_theoryOut
[theory::THEORY_LAST
];
342 * Are we in conflict.
344 context::CDO
<bool> d_inConflict
;
347 * Called by the theories to notify of a conflict.
349 void conflict(TNode conflict
, theory::TheoryId theoryId
);
352 * Debugging flag to ensure that shutdown() is called before the
358 * True if a theory has notified us of incompleteness (at this
359 * context level or below).
361 context::CDO
<bool> d_incomplete
;
364 * Called by the theories to notify that the current branch is incomplete.
366 void setIncomplete(theory::TheoryId theory
) {
372 * Mapping of propagations from recievers to senders.
374 typedef context::CDHashMap
<NodeTheoryPair
, NodeTheoryPair
, NodeTheoryPairHashFunction
> PropagationMap
;
375 PropagationMap d_propagationMap
;
378 * Timestamp of propagations
380 context::CDO
<size_t> d_propagationMapTimestamp
;
383 * Literals that are propagated by the theory. Note that these are TNodes.
384 * The theory can only propagate nodes that have an assigned literal in the
385 * SAT solver and are hence referenced in the SAT solver.
387 context::CDList
<TNode
> d_propagatedLiterals
;
390 * The index of the next literal to be propagated by a theory.
392 context::CDO
<unsigned> d_propagatedLiteralsIndex
;
395 * Called by the output channel to propagate literals and facts
396 * @return false if immediate conflict
398 bool propagate(TNode literal
, theory::TheoryId theory
);
401 * Internal method to call the propagation routines and collect the
402 * propagated literals.
404 void propagate(theory::Theory::Effort effort
);
407 * Called by the output channel to request decisions "as soon as
410 void propagateAsDecision(TNode literal
, theory::TheoryId theory
);
413 * A variable to mark if we added any lemmas.
418 * A variable to mark if the OutputChannel was "used" by any theory
419 * since the start of the last check. If it has been, we require
420 * a FULL_EFFORT check before exiting and reporting SAT.
422 * See the documentation for the needCheck() function, below.
424 bool d_outputChannelUsed
;
426 /** Atom requests from lemmas */
427 AtomRequests d_atomRequests
;
430 * Adds a new lemma, returning its status.
431 * @param node the lemma
432 * @param negated should the lemma be asserted negated
433 * @param removable can the lemma be remove (restrictions apply)
434 * @param needAtoms if not THEORY_LAST, then
436 theory::LemmaStatus
lemma(TNode node
,
441 theory::TheoryId atomsTo
);
443 /** Enusre that the given atoms are send to the given theory */
444 void ensureLemmaAtoms(const std::vector
<TNode
>& atoms
, theory::TheoryId theory
);
446 RemoveTermFormulas
& d_tform_remover
;
448 /** sort inference module */
449 SortInference d_sortInfer
;
451 /** Time spent in theory combination */
452 TimerStat d_combineTheoriesTime
;
457 /** Whether we were just interrupted (or not) */
459 ResourceManager
* d_resourceManager
;
461 /** Container for lemma input and output channels. */
462 LemmaChannels
* d_channels
;
466 /** Constructs a theory engine */
467 TheoryEngine(context::Context
* context
, context::UserContext
* userContext
,
468 RemoveTermFormulas
& iteRemover
, const LogicInfo
& logic
,
469 LemmaChannels
* channels
);
471 /** Destroys a theory engine */
474 void interrupt() throw(ModalException
);
476 * "Spend" a resource during a search or preprocessing.
478 void spendResource(unsigned ammount
);
481 * Adds a theory. Only one theory per TheoryId can be present, so if
482 * there is another theory it will be deleted.
484 template <class TheoryClass
>
485 inline void addTheory(theory::TheoryId theoryId
) {
486 Assert(d_theoryTable
[theoryId
] == NULL
&& d_theoryOut
[theoryId
] == NULL
);
487 d_theoryOut
[theoryId
] = new EngineOutputChannel(this, theoryId
);
488 d_theoryTable
[theoryId
] =
489 new TheoryClass(d_context
, d_userContext
, *d_theoryOut
[theoryId
],
490 theory::Valuation(this), d_logicInfo
);
493 inline void setPropEngine(prop::PropEngine
* propEngine
) {
494 Assert(d_propEngine
== NULL
);
495 d_propEngine
= propEngine
;
498 inline void setDecisionEngine(DecisionEngine
* decisionEngine
) {
499 Assert(d_decisionEngine
== NULL
);
500 d_decisionEngine
= decisionEngine
;
503 /** Called when all initialization of options/logic is done */
507 * Get a pointer to the underlying propositional engine.
509 inline prop::PropEngine
* getPropEngine() const {
514 * Get a pointer to the underlying sat context.
516 inline context::Context
* getSatContext() const {
521 * Get a pointer to the underlying user context.
523 inline context::Context
* getUserContext() const {
524 return d_userContext
;
528 * Get a pointer to the underlying quantifiers engine.
530 theory::QuantifiersEngine
* getQuantifiersEngine() const {
531 return d_quantEngine
;
537 * Helper for preprocess
539 Node
ppTheoryRewrite(TNode term
);
542 * Queue of nodes for pre-registration.
544 std::queue
<TNode
> d_preregisterQueue
;
547 * Boolean flag denoting we are in pre-registration.
549 bool d_inPreregister
;
552 * Did the theories get any new facts since the last time we called
555 context::CDO
<bool> d_factsAsserted
;
558 * Map from equality atoms to theories that would like to be notified about them.
563 * Assert the formula to the given theory.
564 * @param assertion the assertion to send (not necesserily normalized)
565 * @param original the assertion as it was sent in from the propagating theory
566 * @param toTheoryId the theory to assert to
567 * @param fromTheoryId the theory that sent it
569 void assertToTheory(TNode assertion
, TNode originalAssertion
, theory::TheoryId toTheoryId
, theory::TheoryId fromTheoryId
);
572 * Marks a theory propagation from a theory to a theory where a
573 * theory could be the THEORY_SAT_SOLVER for literals coming from
574 * or being propagated to the SAT solver. If the receiving theory
575 * already recieved the literal, the method returns false, otherwise
578 * @param assertion the normalized assertion being sent
579 * @param originalAssertion the actual assertion that was sent
580 * @param toTheoryId the theory that is on the receiving end
581 * @param fromTheoryId the theory that sent the assertino
582 * @return true if a new assertion, false if theory already got it
584 bool markPropagation(TNode assertion
, TNode originalAssertions
, theory::TheoryId toTheoryId
, theory::TheoryId fromTheoryId
);
587 * Computes the explanation by travarsing the propagation graph and
588 * asking relevant theories to explain the propagations. Initially
589 * the explanation vector should contain only the element (node, theory)
590 * where the node is the one to be explained, and the theory is the
591 * theory that sent the literal. The lemmaProofRecipe will contain a list
592 * of the explanation steps required to produce the original node.
594 void getExplanation(std::vector
<NodeTheoryPair
>& explanationVector
, LemmaProofRecipe
* lemmaProofRecipe
);
599 * Signal the start of a new round of assertion preprocessing
601 void preprocessStart();
604 * Runs theory specific preprocessing on the non-Boolean parts of
605 * the formula. This is only called on input assertions, after ITEs
608 Node
preprocess(TNode node
);
610 /** Notify (preprocessed) assertions. */
611 void notifyPreprocessedAssertions(const std::vector
<Node
>& assertions
);
613 /** Return whether or not we are incomplete (in the current context). */
614 inline bool isIncomplete() const { return d_incomplete
; }
617 * Returns true if we need another round of checking. If this
618 * returns true, check(FULL_EFFORT) _must_ be called by the
619 * propositional layer before reporting SAT.
621 * This is especially necessary for incomplete theories that lazily
622 * output some lemmas on FULL_EFFORT check (e.g. quantifier reasoning
623 * outputing quantifier instantiations). In such a case, a lemma can
624 * be asserted that is simplified away (perhaps it's already true).
625 * However, we must maintain the invariant that, if a theory uses the
626 * OutputChannel, it implicitly requests that another check(FULL_EFFORT)
627 * be performed before exit, even if no new facts are on its fact queue,
628 * as it might decide to further instantiate some lemmas, precluding
631 inline bool needCheck() const {
632 return d_outputChannelUsed
|| d_lemmasAdded
;
636 * This is called at shutdown time by the SmtEngine, just before
637 * destruction. It is important because there are destruction
638 * ordering issues between PropEngine and Theory.
643 * Solve the given literal with a theory that owns it.
645 theory::Theory::PPAssertStatus
solve(TNode literal
,
646 theory::SubstitutionMap
& substitutionOut
);
649 * Preregister a Theory atom with the responsible theory (or
652 void preRegister(TNode preprocessed
);
655 * Assert the formula to the appropriate theory.
656 * @param node the assertion
658 void assertFact(TNode node
);
661 * Check all (currently-active) theories for conflicts.
662 * @param effort the effort level to use
664 void check(theory::Theory::Effort effort
);
667 * Run the combination framework.
669 void combineTheories();
672 * Calls ppStaticLearn() on all theories, accumulating their
673 * combined contributions in the "learned" builder.
675 void ppStaticLearn(TNode in
, NodeBuilder
<>& learned
);
678 * Calls presolve() on all theories and returns true
679 * if one of the theories discovers a conflict.
684 * Calls postsolve() on all theories.
689 * Calls notifyRestart() on all active theories.
691 void notifyRestart();
693 void getPropagatedLiterals(std::vector
<TNode
>& literals
) {
694 for (; d_propagatedLiteralsIndex
< d_propagatedLiterals
.size(); d_propagatedLiteralsIndex
= d_propagatedLiteralsIndex
+ 1) {
695 Debug("getPropagatedLiterals") << "TheoryEngine::getPropagatedLiterals: propagating: " << d_propagatedLiterals
[d_propagatedLiteralsIndex
] << std::endl
;
696 literals
.push_back(d_propagatedLiterals
[d_propagatedLiteralsIndex
]);
700 Node
getNextDecisionRequest();
702 bool properConflict(TNode conflict
) const;
703 bool properPropagation(TNode lit
) const;
704 bool properExplanation(TNode node
, TNode expl
) const;
707 * Returns an explanation of the node propagated to the SAT solver.
709 Node
getExplanation(TNode node
);
712 * Returns an explanation of the node propagated to the SAT solver and the theory
713 * that propagated it.
715 Node
getExplanationAndRecipe(TNode node
, LemmaProofRecipe
* proofRecipe
);
720 void collectModelInfo( theory::TheoryModel
* m
);
721 /** post process model */
722 void postProcessModel( theory::TheoryModel
* m
);
725 * Get the current model
727 theory::TheoryModel
* getModel();
730 * Get the model builder
732 theory::TheoryEngineModelBuilder
* getModelBuilder() { return d_curr_model_builder
; }
735 * Get the theory associated to a given Node.
737 * @returns the theory, or NULL if the TNode is
740 inline theory::Theory
* theoryOf(TNode node
) const {
741 return d_theoryTable
[theory::Theory::theoryOf(node
)];
745 * Get the theory associated to a the given theory id.
747 * @returns the theory
749 inline theory::Theory
* theoryOf(theory::TheoryId theoryId
) const {
750 return d_theoryTable
[theoryId
];
753 inline bool isTheoryEnabled(theory::TheoryId theoryId
) const {
754 return d_logicInfo
.isTheoryEnabled(theoryId
);
758 * Returns the equality status of the two terms, from the theory
759 * that owns the domain type. The types of a and b must be the same.
761 theory::EqualityStatus
getEqualityStatus(TNode a
, TNode b
);
764 * Returns the value that a theory that owns the type of var currently
765 * has (or null if none);
767 Node
getModelValue(TNode var
);
770 * Takes a literal and returns an equivalent literal that is guaranteed to be a SAT literal
772 Node
ensureLiteral(TNode n
);
775 * Print all instantiations made by the quantifiers module.
777 void printInstantiations( std::ostream
& out
);
780 * Print solution for synthesis conjectures found by ce_guided_instantiation module
782 void printSynthSolution( std::ostream
& out
);
785 * Get list of quantified formulas that were instantiated
787 void getInstantiatedQuantifiedFormulas( std::vector
< Node
>& qs
);
790 * Get instantiation methods
791 * first inputs forall x.q[x] and returns ( q[a], ..., q[z] )
792 * second inputs forall x.q[x] and returns ( a, ..., z )
793 * third and fourth return mappings e.g. forall x.q1[x] -> ( q1[a]...q1[z] ) , ... , forall x.qn[x] -> ( qn[a]...qn[z] )
795 void getInstantiations( Node q
, std::vector
< Node
>& insts
);
796 void getInstantiationTermVectors( Node q
, std::vector
< std::vector
< Node
> >& tvecs
);
797 void getInstantiations( std::map
< Node
, std::vector
< Node
> >& insts
);
798 void getInstantiationTermVectors( std::map
< Node
, std::vector
< std::vector
< Node
> > >& insts
);
801 * Get instantiated conjunction, returns q[t1] ^ ... ^ q[tn] where t1...tn are current set of instantiations for q.
802 * Can be used for quantifier elimination when satisfiable and q[t1] ^ ... ^ q[tn] |= q
804 Node
getInstantiatedConjunction( Node q
);
807 * Forwards an entailment check according to the given theoryOfMode.
808 * See theory.h for documentation on entailmentCheck().
810 std::pair
<bool, Node
> entailmentCheck(theory::TheoryOfMode mode
, TNode lit
, const theory::EntailmentCheckParameters
* params
= NULL
, theory::EntailmentCheckSideEffects
* out
= NULL
);
814 /** Default visitor for pre-registration */
815 PreRegisterVisitor d_preRegistrationVisitor
;
817 /** Visitor for collecting shared terms */
818 SharedTermsVisitor d_sharedTermsVisitor
;
820 /** Dump the assertions to the dump */
821 void dumpAssertions(const char* tag
);
824 * A collection of ite preprocessing passes.
826 theory::ITEUtilities
* d_iteUtilities
;
829 /** For preprocessing pass simplifying unconstrained expressions */
830 UnconstrainedSimplifier
* d_unconstrainedSimp
;
832 /** For preprocessing pass lifting bit-vectors of size 1 to booleans */
833 theory::bv::BvToBoolPreprocessor d_bvToBoolPreprocessor
;
835 void staticInitializeBVOptions(const std::vector
<Node
>& assertions
);
836 void ppBvToBool(const std::vector
<Node
>& assertions
, std::vector
<Node
>& new_assertions
);
837 void ppBoolToBv(const std::vector
<Node
>& assertions
, std::vector
<Node
>& new_assertions
);
838 bool ppBvAbstraction(const std::vector
<Node
>& assertions
, std::vector
<Node
>& new_assertions
);
839 void mkAckermanizationAssertions(std::vector
<Node
>& assertions
);
841 Node
ppSimpITE(TNode assertion
);
842 /** Returns false if an assertion simplified to false. */
843 bool donePPSimpITE(std::vector
<Node
>& assertions
);
845 void ppUnconstrainedSimp(std::vector
<Node
>& assertions
);
847 SharedTermsDatabase
* getSharedTermsDatabase() { return &d_sharedTerms
; }
849 theory::eq::EqualityEngine
* getMasterEqualityEngine() { return d_masterEqualityEngine
; }
851 RemoveTermFormulas
* getTermFormulaRemover() { return &d_tform_remover
; }
853 SortInference
* getSortInference() { return &d_sortInfer
; }
855 /** Prints the assertions to the debug stream */
856 void printAssertions(const char* tag
);
858 /** Theory alternative is in use. */
859 bool useTheoryAlternative(const std::string
& name
);
861 /** Enables using a theory alternative by name. */
862 void enableTheoryAlternative(const std::string
& name
);
865 std::set
< std::string
> d_theoryAlternatives
;
867 std::map
< std::string
, std::vector
< theory::Theory
* > > d_attr_handle
;
871 * Set user attribute.
872 * This function is called when an attribute is set by a user. In SMT-LIBv2 this is done
873 * via the syntax (! n :attr)
875 void setUserAttribute(const std::string
& attr
, Node n
, std::vector
<Node
>& node_values
, std::string str_value
);
878 * Handle user attribute.
879 * Associates theory t with the attribute attr. Theory t will be
880 * notified whenever an attribute of name attr is set.
882 void handleUserAttribute(const char* attr
, theory::Theory
* t
);
885 * Check that the theory assertions are satisfied in the model.
886 * This function is called from the smt engine's checkModel routine.
888 void checkTheoryAssertionsWithModel(bool hardFailure
);
891 IntStat d_arithSubstitutionsAdded
;
893 };/* class TheoryEngine */
895 }/* CVC4 namespace */
897 #endif /* __CVC4__THEORY_ENGINE_H */