1 /********************* */
2 /*! \file theory_engine.h
4 ** Top contributors (to current version):
5 ** Dejan Jovanovic, Morgan Deters, Andrew Reynolds
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 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
25 #include <unordered_map>
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 "smt_util/lemma_channels.h"
38 #include "theory/atom_requests.h"
39 #include "theory/decision_manager.h"
40 #include "theory/interrupted.h"
41 #include "theory/rewriter.h"
42 #include "theory/shared_terms_database.h"
43 #include "theory/sort_inference.h"
44 #include "theory/substitutions.h"
45 #include "theory/term_registration_visitor.h"
46 #include "theory/theory.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"
56 class ResourceManager
;
57 class LemmaProofRecipe
;
60 * A pair of a theory and a node. This is used to mark the flow of
61 * propagations between theories.
63 struct NodeTheoryPair
{
65 theory::TheoryId theory
;
67 NodeTheoryPair(TNode node
, theory::TheoryId theory
, size_t timestamp
= 0)
68 : node(node
), theory(theory
), timestamp(timestamp
) {}
69 NodeTheoryPair() : theory(theory::THEORY_LAST
), timestamp() {}
70 // Comparison doesn't take into account the timestamp
71 bool operator == (const NodeTheoryPair
& pair
) const {
72 return node
== pair
.node
&& theory
== pair
.theory
;
74 };/* struct NodeTheoryPair */
76 struct NodeTheoryPairHashFunction
{
77 NodeHashFunction hashFunction
;
78 // Hash doesn't take into account the timestamp
79 size_t operator()(const NodeTheoryPair
& pair
) const {
80 uint64_t hash
= fnv1a::fnv1a_64(NodeHashFunction()(pair
.node
));
81 return static_cast<size_t>(fnv1a::fnv1a_64(pair
.theory
, hash
));
83 };/* struct NodeTheoryPairHashFunction */
86 /* Forward declarations */
89 class TheoryEngineModelBuilder
;
93 }/* CVC4::theory::eq namespace */
95 namespace quantifiers
{
99 class EntailmentCheckParameters
;
100 class EntailmentCheckSideEffects
;
101 }/* CVC4::theory namespace */
103 class DecisionEngine
;
104 class RemoveTermFormulas
;
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
) override
164 bool eqNotifyTriggerPredicate(TNode predicate
, bool value
) override
168 bool eqNotifyTriggerTermEquality(theory::TheoryId tag
,
175 void eqNotifyConstantTermMerge(TNode t1
, TNode t2
) override
{}
176 void eqNotifyNewClass(TNode t
) override
{ d_te
.eqNotifyNewClass(t
); }
177 void eqNotifyPreMerge(TNode t1
, TNode t2
) override
180 void eqNotifyPostMerge(TNode t1
, TNode t2
) override
183 void eqNotifyDisequal(TNode t1
, TNode t2
, TNode reason
) override
186 };/* class TheoryEngine::NotifyClass */
187 NotifyClass d_masterEENotify
;
190 * notification methods
192 void eqNotifyNewClass(TNode t
);
193 void eqNotifyPreMerge(TNode t1
, TNode t2
);
194 void eqNotifyPostMerge(TNode t1
, TNode t2
);
195 void eqNotifyDisequal(TNode t1
, TNode t2
, TNode reason
);
198 * The quantifiers engine
200 theory::QuantifiersEngine
* d_quantEngine
;
202 * The decision manager
204 std::unique_ptr
<theory::DecisionManager
> d_decManager
;
207 * Default model object
209 theory::TheoryModel
* d_curr_model
;
210 bool d_aloc_curr_model
;
212 * Model builder object
214 theory::TheoryEngineModelBuilder
* d_curr_model_builder
;
215 bool d_aloc_curr_model_builder
;
216 /** are we in eager model building mode? (see setEagerModelBuilding). */
217 bool d_eager_model_building
;
219 typedef std::unordered_map
<Node
, Node
, NodeHashFunction
> NodeMap
;
220 typedef std::unordered_map
<TNode
, Node
, TNodeHashFunction
> TNodeMap
;
223 * Cache for theory-preprocessing of assertions
228 * Used for "missed-t-propagations" dumping mode only. A set of all
229 * theory-propagable literals.
231 context::CDList
<TNode
> d_possiblePropagations
;
234 * Used for "missed-t-propagations" dumping mode only. A
235 * context-dependent set of those theory-propagable literals that
236 * have been propagated.
238 context::CDHashSet
<Node
, NodeHashFunction
> d_hasPropagated
;
242 * Statistics for a particular theory.
246 static std::string
mkName(std::string prefix
,
247 theory::TheoryId theory
,
248 std::string suffix
) {
249 std::stringstream ss
;
250 ss
<< prefix
<< theory
<< suffix
;
255 IntStat conflicts
, propagations
, lemmas
, requirePhase
, restartDemands
;
257 Statistics(theory::TheoryId theory
);
259 };/* class TheoryEngine::Statistics */
262 * An output channel for Theory that passes messages
263 * back to a TheoryEngine.
265 class EngineOutputChannel
: public theory::OutputChannel
{
266 friend class TheoryEngine
;
269 * The theory engine we're communicating with.
271 TheoryEngine
* d_engine
;
274 * The statistics of the theory interractions.
276 Statistics d_statistics
;
278 /** The theory owning this channel. */
279 theory::TheoryId d_theory
;
282 EngineOutputChannel(TheoryEngine
* engine
, theory::TheoryId theory
)
283 : d_engine(engine
), d_statistics(theory
), d_theory(theory
) {}
285 void safePoint(ResourceManager::Resource r
) override
288 if (d_engine
->d_interrupted
) {
289 throw theory::Interrupted();
293 void conflict(TNode conflictNode
,
294 std::unique_ptr
<Proof
> pf
= nullptr) override
;
295 bool propagate(TNode literal
) override
;
297 theory::LemmaStatus
lemma(TNode lemma
, ProofRule rule
,
298 bool removable
= false, bool preprocess
= false,
299 bool sendAtoms
= false) override
;
301 theory::LemmaStatus
splitLemma(TNode lemma
,
302 bool removable
= false) override
;
304 void demandRestart() override
{
305 NodeManager
* curr
= NodeManager::currentNM();
306 Node restartVar
= curr
->mkSkolem(
307 "restartVar", curr
->booleanType(),
308 "A boolean variable asserted to be true to force a restart");
309 Trace("theory::restart")
310 << "EngineOutputChannel<" << d_theory
<< ">::restart(" << restartVar
312 ++d_statistics
.restartDemands
;
313 lemma(restartVar
, RULE_INVALID
, true);
316 void requirePhase(TNode n
, bool phase
) override
{
317 Debug("theory") << "EngineOutputChannel::requirePhase(" << n
<< ", "
318 << phase
<< ")" << std::endl
;
319 ++d_statistics
.requirePhase
;
320 d_engine
->d_propEngine
->requirePhase(n
, phase
);
323 void setIncomplete() override
{
324 Trace("theory") << "TheoryEngine::setIncomplete()" << std::endl
;
325 d_engine
->setIncomplete(d_theory
);
328 void spendResource(ResourceManager::Resource r
) override
330 d_engine
->spendResource(r
);
333 void handleUserAttribute(const char* attr
, theory::Theory
* t
) override
{
334 d_engine
->handleUserAttribute(attr
, t
);
339 * A helper function for registering lemma recipes with the proof engine
341 void registerLemmaRecipe(Node lemma
, Node originalLemma
, bool preprocess
,
342 theory::TheoryId theoryId
);
343 }; /* class TheoryEngine::EngineOutputChannel */
346 * Output channels for individual theories.
348 EngineOutputChannel
* d_theoryOut
[theory::THEORY_LAST
];
351 * Are we in conflict.
353 context::CDO
<bool> d_inConflict
;
356 * Are we in "SAT mode"? In this state, the user can query for the model.
357 * This corresponds to the state in Figure 4.1, page 52 of the SMT-LIB
358 * standard, version 2.6.
363 * Called by the theories to notify of a conflict.
365 void conflict(TNode conflict
, theory::TheoryId theoryId
);
368 * Debugging flag to ensure that shutdown() is called before the
374 * True if a theory has notified us of incompleteness (at this
375 * context level or below).
377 context::CDO
<bool> d_incomplete
;
380 * Called by the theories to notify that the current branch is incomplete.
382 void setIncomplete(theory::TheoryId theory
) {
388 * Mapping of propagations from recievers to senders.
390 typedef context::CDHashMap
<NodeTheoryPair
, NodeTheoryPair
, NodeTheoryPairHashFunction
> PropagationMap
;
391 PropagationMap d_propagationMap
;
394 * Timestamp of propagations
396 context::CDO
<size_t> d_propagationMapTimestamp
;
399 * Literals that are propagated by the theory. Note that these are TNodes.
400 * The theory can only propagate nodes that have an assigned literal in the
401 * SAT solver and are hence referenced in the SAT solver.
403 context::CDList
<TNode
> d_propagatedLiterals
;
406 * The index of the next literal to be propagated by a theory.
408 context::CDO
<unsigned> d_propagatedLiteralsIndex
;
411 * Called by the output channel to propagate literals and facts
412 * @return false if immediate conflict
414 bool propagate(TNode literal
, theory::TheoryId theory
);
417 * Internal method to call the propagation routines and collect the
418 * propagated literals.
420 void propagate(theory::Theory::Effort effort
);
423 * A variable to mark if we added any lemmas.
428 * A variable to mark if the OutputChannel was "used" by any theory
429 * since the start of the last check. If it has been, we require
430 * a FULL_EFFORT check before exiting and reporting SAT.
432 * See the documentation for the needCheck() function, below.
434 bool d_outputChannelUsed
;
436 /** Atom requests from lemmas */
437 AtomRequests d_atomRequests
;
440 * Adds a new lemma, returning its status.
441 * @param node the lemma
442 * @param negated should the lemma be asserted negated
443 * @param removable can the lemma be remove (restrictions apply)
444 * @param needAtoms if not THEORY_LAST, then
446 theory::LemmaStatus
lemma(TNode node
,
451 theory::TheoryId atomsTo
);
453 /** Enusre that the given atoms are send to the given theory */
454 void ensureLemmaAtoms(const std::vector
<TNode
>& atoms
, theory::TheoryId theory
);
456 RemoveTermFormulas
& d_tform_remover
;
458 /** sort inference module */
459 SortInference d_sortInfer
;
461 /** Time spent in theory combination */
462 TimerStat d_combineTheoriesTime
;
467 /** Whether we were just interrupted (or not) */
469 ResourceManager
* d_resourceManager
;
471 /** Container for lemma input and output channels. */
472 LemmaChannels
* d_channels
;
476 /** Constructs a theory engine */
477 TheoryEngine(context::Context
* context
, context::UserContext
* userContext
,
478 RemoveTermFormulas
& iteRemover
, const LogicInfo
& logic
,
479 LemmaChannels
* channels
);
481 /** Destroys a theory engine */
486 /** "Spend" a resource during a search or preprocessing.*/
487 void spendResource(ResourceManager::Resource r
);
490 * Adds a theory. Only one theory per TheoryId can be present, so if
491 * there is another theory it will be deleted.
493 template <class TheoryClass
>
494 inline void addTheory(theory::TheoryId theoryId
) {
495 Assert(d_theoryTable
[theoryId
] == NULL
&& d_theoryOut
[theoryId
] == NULL
);
496 d_theoryOut
[theoryId
] = new EngineOutputChannel(this, theoryId
);
497 d_theoryTable
[theoryId
] =
498 new TheoryClass(d_context
, d_userContext
, *d_theoryOut
[theoryId
],
499 theory::Valuation(this), d_logicInfo
);
502 inline void setPropEngine(prop::PropEngine
* propEngine
) {
503 Assert(d_propEngine
== NULL
);
504 d_propEngine
= propEngine
;
507 inline void setDecisionEngine(DecisionEngine
* decisionEngine
) {
508 Assert(d_decisionEngine
== NULL
);
509 d_decisionEngine
= decisionEngine
;
512 /** Called when all initialization of options/logic is done */
516 * Get a pointer to the underlying propositional engine.
518 inline prop::PropEngine
* getPropEngine() const {
523 * Get a pointer to the underlying sat context.
525 inline context::Context
* getSatContext() const {
530 * Get a pointer to the underlying user context.
532 inline context::Context
* getUserContext() const {
533 return d_userContext
;
537 * Get a pointer to the underlying quantifiers engine.
539 theory::QuantifiersEngine
* getQuantifiersEngine() const {
540 return d_quantEngine
;
543 * Get a pointer to the underlying decision manager.
545 theory::DecisionManager
* getDecisionManager() const
547 return d_decManager
.get();
552 * Helper for preprocess
554 Node
ppTheoryRewrite(TNode term
);
557 * Queue of nodes for pre-registration.
559 std::queue
<TNode
> d_preregisterQueue
;
562 * Boolean flag denoting we are in pre-registration.
564 bool d_inPreregister
;
567 * Did the theories get any new facts since the last time we called
570 context::CDO
<bool> d_factsAsserted
;
573 * Map from equality atoms to theories that would like to be notified about them.
578 * Assert the formula to the given theory.
579 * @param assertion the assertion to send (not necesserily normalized)
580 * @param original the assertion as it was sent in from the propagating theory
581 * @param toTheoryId the theory to assert to
582 * @param fromTheoryId the theory that sent it
584 void assertToTheory(TNode assertion
, TNode originalAssertion
, theory::TheoryId toTheoryId
, theory::TheoryId fromTheoryId
);
587 * Marks a theory propagation from a theory to a theory where a
588 * theory could be the THEORY_SAT_SOLVER for literals coming from
589 * or being propagated to the SAT solver. If the receiving theory
590 * already recieved the literal, the method returns false, otherwise
593 * @param assertion the normalized assertion being sent
594 * @param originalAssertion the actual assertion that was sent
595 * @param toTheoryId the theory that is on the receiving end
596 * @param fromTheoryId the theory that sent the assertino
597 * @return true if a new assertion, false if theory already got it
599 bool markPropagation(TNode assertion
, TNode originalAssertions
, theory::TheoryId toTheoryId
, theory::TheoryId fromTheoryId
);
602 * Computes the explanation by travarsing the propagation graph and
603 * asking relevant theories to explain the propagations. Initially
604 * the explanation vector should contain only the element (node, theory)
605 * where the node is the one to be explained, and the theory is the
606 * theory that sent the literal. The lemmaProofRecipe will contain a list
607 * of the explanation steps required to produce the original node.
609 void getExplanation(std::vector
<NodeTheoryPair
>& explanationVector
, LemmaProofRecipe
* lemmaProofRecipe
);
614 * Signal the start of a new round of assertion preprocessing
616 void preprocessStart();
619 * Runs theory specific preprocessing on the non-Boolean parts of
620 * the formula. This is only called on input assertions, after ITEs
623 Node
preprocess(TNode node
);
625 /** Notify (preprocessed) assertions. */
626 void notifyPreprocessedAssertions(const std::vector
<Node
>& assertions
);
628 /** Return whether or not we are incomplete (in the current context). */
629 inline bool isIncomplete() const { return d_incomplete
; }
632 * Returns true if we need another round of checking. If this
633 * returns true, check(FULL_EFFORT) _must_ be called by the
634 * propositional layer before reporting SAT.
636 * This is especially necessary for incomplete theories that lazily
637 * output some lemmas on FULL_EFFORT check (e.g. quantifier reasoning
638 * outputing quantifier instantiations). In such a case, a lemma can
639 * be asserted that is simplified away (perhaps it's already true).
640 * However, we must maintain the invariant that, if a theory uses the
641 * OutputChannel, it implicitly requests that another check(FULL_EFFORT)
642 * be performed before exit, even if no new facts are on its fact queue,
643 * as it might decide to further instantiate some lemmas, precluding
646 inline bool needCheck() const {
647 return d_outputChannelUsed
|| d_lemmasAdded
;
651 * This is called at shutdown time by the SmtEngine, just before
652 * destruction. It is important because there are destruction
653 * ordering issues between PropEngine and Theory.
658 * Solve the given literal with a theory that owns it.
660 theory::Theory::PPAssertStatus
solve(TNode literal
,
661 theory::SubstitutionMap
& substitutionOut
);
664 * Preregister a Theory atom with the responsible theory (or
667 void preRegister(TNode preprocessed
);
670 * Assert the formula to the appropriate theory.
671 * @param node the assertion
673 void assertFact(TNode node
);
676 * Check all (currently-active) theories for conflicts.
677 * @param effort the effort level to use
679 void check(theory::Theory::Effort effort
);
682 * Run the combination framework.
684 void combineTheories();
687 * Calls ppStaticLearn() on all theories, accumulating their
688 * combined contributions in the "learned" builder.
690 void ppStaticLearn(TNode in
, NodeBuilder
<>& learned
);
693 * Calls presolve() on all theories and returns true
694 * if one of the theories discovers a conflict.
699 * Calls postsolve() on all theories.
704 * Calls notifyRestart() on all active theories.
706 void notifyRestart();
708 void getPropagatedLiterals(std::vector
<TNode
>& literals
) {
709 for (; d_propagatedLiteralsIndex
< d_propagatedLiterals
.size(); d_propagatedLiteralsIndex
= d_propagatedLiteralsIndex
+ 1) {
710 Debug("getPropagatedLiterals") << "TheoryEngine::getPropagatedLiterals: propagating: " << d_propagatedLiterals
[d_propagatedLiteralsIndex
] << std::endl
;
711 literals
.push_back(d_propagatedLiterals
[d_propagatedLiteralsIndex
]);
716 * Returns the next decision request, or null if none exist. The next
717 * decision request is a literal that this theory engine prefers the SAT
718 * solver to make as its next decision. Decision requests are managed by
719 * the decision manager d_decManager.
721 Node
getNextDecisionRequest();
723 bool properConflict(TNode conflict
) const;
724 bool properPropagation(TNode lit
) const;
725 bool properExplanation(TNode node
, TNode expl
) const;
728 * Returns an explanation of the node propagated to the SAT solver.
730 Node
getExplanation(TNode node
);
733 * Returns an explanation of the node propagated to the SAT solver and the theory
734 * that propagated it.
736 Node
getExplanationAndRecipe(TNode node
, LemmaProofRecipe
* proofRecipe
);
741 bool collectModelInfo(theory::TheoryModel
* m
);
742 /** post process model */
743 void postProcessModel( theory::TheoryModel
* m
);
746 * Get the pointer to the model object used by this theory engine.
748 theory::TheoryModel
* getModel();
750 * Get the current model for the current set of assertions. This method
751 * should only be called immediately after a satisfiable or unknown
752 * response to a check-sat call, and only if produceModels is true.
754 * If the model is not already built, this will cause this theory engine
755 * to build the model.
757 * If the model is not available (for instance, if the last call to check-sat
758 * was interrupted), then this returns the null pointer.
760 theory::TheoryModel
* getBuiltModel();
761 /** set eager model building
763 * If this method is called, then this TheoryEngine will henceforth build
764 * its model immediately after every satisfiability check that results
765 * in a satisfiable or unknown result. The motivation for this mode is to
766 * accomodate API users that get the model object from the TheoryEngine,
767 * where we want to ensure that this model is always valid.
768 * TODO (#2648): revisit this.
770 void setEagerModelBuilding() { d_eager_model_building
= true; }
772 /** get synth solutions
774 * This method returns true if there is a synthesis solution available. This
775 * is the case if the last call to check satisfiability originated in a
776 * check-synth call, and the synthesis solver successfully found a solution
777 * for all active synthesis conjectures.
779 * This method adds entries to sol_map that map functions-to-synthesize with
780 * their solutions, for all active conjectures. This should be called
781 * immediately after the solver answers unsat for sygus input.
783 * For details on what is added to sol_map, see
784 * SynthConjecture::getSynthSolutions.
786 bool getSynthSolutions(std::map
<Node
, std::map
<Node
, Node
> >& sol_map
);
789 * Get the model builder
791 theory::TheoryEngineModelBuilder
* getModelBuilder() { return d_curr_model_builder
; }
794 * Get the theory associated to a given Node.
796 * @returns the theory, or NULL if the TNode is
799 inline theory::Theory
* theoryOf(TNode node
) const {
800 return d_theoryTable
[theory::Theory::theoryOf(node
)];
804 * Get the theory associated to a the given theory id.
806 * @returns the theory
808 inline theory::Theory
* theoryOf(theory::TheoryId theoryId
) const {
809 Assert(theoryId
< theory::THEORY_LAST
);
810 return d_theoryTable
[theoryId
];
813 inline bool isTheoryEnabled(theory::TheoryId theoryId
) const {
814 return d_logicInfo
.isTheoryEnabled(theoryId
);
816 /** get the logic info used by this theory engine */
817 const LogicInfo
& getLogicInfo() const;
819 * Returns the equality status of the two terms, from the theory
820 * that owns the domain type. The types of a and b must be the same.
822 theory::EqualityStatus
getEqualityStatus(TNode a
, TNode b
);
825 * Returns the value that a theory that owns the type of var currently
826 * has (or null if none);
828 Node
getModelValue(TNode var
);
831 * Takes a literal and returns an equivalent literal that is guaranteed to be a SAT literal
833 Node
ensureLiteral(TNode n
);
836 * Print all instantiations made by the quantifiers module.
838 void printInstantiations( std::ostream
& out
);
841 * Print solution for synthesis conjectures found by ce_guided_instantiation module
843 void printSynthSolution( std::ostream
& out
);
846 * Get list of quantified formulas that were instantiated
848 void getInstantiatedQuantifiedFormulas( std::vector
< Node
>& qs
);
851 * Get instantiation methods
852 * first inputs forall x.q[x] and returns ( q[a], ..., q[z] )
853 * second inputs forall x.q[x] and returns ( a, ..., z )
854 * third and fourth return mappings e.g. forall x.q1[x] -> ( q1[a]...q1[z] ) , ... , forall x.qn[x] -> ( qn[a]...qn[z] )
856 void getInstantiations( Node q
, std::vector
< Node
>& insts
);
857 void getInstantiationTermVectors( Node q
, std::vector
< std::vector
< Node
> >& tvecs
);
858 void getInstantiations( std::map
< Node
, std::vector
< Node
> >& insts
);
859 void getInstantiationTermVectors( std::map
< Node
, std::vector
< std::vector
< Node
> > >& insts
);
862 * Get instantiated conjunction, returns q[t1] ^ ... ^ q[tn] where t1...tn are current set of instantiations for q.
863 * Can be used for quantifier elimination when satisfiable and q[t1] ^ ... ^ q[tn] |= q
865 Node
getInstantiatedConjunction( Node q
);
868 * Forwards an entailment check according to the given theoryOfMode.
869 * See theory.h for documentation on entailmentCheck().
871 std::pair
<bool, Node
> entailmentCheck(
872 options::TheoryOfMode mode
,
874 const theory::EntailmentCheckParameters
* params
= NULL
,
875 theory::EntailmentCheckSideEffects
* out
= NULL
);
878 /** Default visitor for pre-registration */
879 PreRegisterVisitor d_preRegistrationVisitor
;
881 /** Visitor for collecting shared terms */
882 SharedTermsVisitor d_sharedTermsVisitor
;
884 /** Dump the assertions to the dump */
885 void dumpAssertions(const char* tag
);
887 /** For preprocessing pass lifting bit-vectors of size 1 to booleans */
889 void staticInitializeBVOptions(const std::vector
<Node
>& assertions
);
891 Node
ppSimpITE(TNode assertion
);
892 /** Returns false if an assertion simplified to false. */
893 bool donePPSimpITE(std::vector
<Node
>& assertions
);
895 SharedTermsDatabase
* getSharedTermsDatabase() { return &d_sharedTerms
; }
897 theory::eq::EqualityEngine
* getMasterEqualityEngine() { return d_masterEqualityEngine
; }
899 RemoveTermFormulas
* getTermFormulaRemover() { return &d_tform_remover
; }
901 SortInference
* getSortInference() { return &d_sortInfer
; }
903 /** Prints the assertions to the debug stream */
904 void printAssertions(const char* tag
);
906 /** Theory alternative is in use. */
907 bool useTheoryAlternative(const std::string
& name
);
909 /** Enables using a theory alternative by name. */
910 void enableTheoryAlternative(const std::string
& name
);
913 std::set
< std::string
> d_theoryAlternatives
;
915 std::map
< std::string
, std::vector
< theory::Theory
* > > d_attr_handle
;
918 /** Set user attribute.
920 * This function is called when an attribute is set by a user. In SMT-LIBv2
921 * this is done via the syntax (! n :attr)
923 void setUserAttribute(const std::string
& attr
,
925 const std::vector
<Node
>& node_values
,
926 const std::string
& str_value
);
928 /** Handle user attribute.
930 * Associates theory t with the attribute attr. Theory t will be
931 * notified whenever an attribute of name attr is set.
933 void handleUserAttribute(const char* attr
, theory::Theory
* t
);
936 * Check that the theory assertions are satisfied in the model.
937 * This function is called from the smt engine's checkModel routine.
939 void checkTheoryAssertionsWithModel(bool hardFailure
);
942 IntStat d_arithSubstitutionsAdded
;
944 };/* class TheoryEngine */
946 }/* CVC4 namespace */
948 #endif /* CVC4__THEORY_ENGINE_H */