1 /********************* */
2 /*! \file theory_engine.cpp
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Dejan Jovanovic, 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
12 ** \brief The theory engine
17 #include "theory/theory_engine.h"
22 #include "base/map_util.h"
23 #include "decision/decision_engine.h"
24 #include "expr/attribute.h"
25 #include "expr/lazy_proof.h"
26 #include "expr/node.h"
27 #include "expr/node_builder.h"
28 #include "expr/node_visitor.h"
29 #include "expr/proof_ensure_closed.h"
30 #include "options/bv_options.h"
31 #include "options/options.h"
32 #include "options/quantifiers_options.h"
33 #include "options/theory_options.h"
34 #include "printer/printer.h"
36 #include "smt/logic_exception.h"
37 #include "smt/term_formula_removal.h"
38 #include "theory/arith/arith_ite_utils.h"
39 #include "theory/bv/theory_bv_utils.h"
40 #include "theory/care_graph.h"
41 #include "theory/combination_care_graph.h"
42 #include "theory/decision_manager.h"
43 #include "theory/quantifiers/first_order_model.h"
44 #include "theory/quantifiers/fmf/model_engine.h"
45 #include "theory/quantifiers/theory_quantifiers.h"
46 #include "theory/quantifiers_engine.h"
47 #include "theory/relevance_manager.h"
48 #include "theory/rewriter.h"
49 #include "theory/theory.h"
50 #include "theory/theory_engine_proof_generator.h"
51 #include "theory/theory_id.h"
52 #include "theory/theory_model.h"
53 #include "theory/theory_traits.h"
54 #include "theory/uf/equality_engine.h"
55 #include "util/resource_manager.h"
59 using namespace CVC4::preprocessing
;
60 using namespace CVC4::theory
;
64 /* -------------------------------------------------------------------------- */
69 * IMPORTANT: The order of the theories is important. For example, strings
70 * depends on arith, quantifiers needs to come as the very last.
71 * Do not change this order.
74 #define CVC4_FOR_EACH_THEORY \
75 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_BUILTIN) \
76 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_BOOL) \
77 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_UF) \
78 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_ARITH) \
79 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_BV) \
80 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_FP) \
81 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_ARRAYS) \
82 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_DATATYPES) \
83 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_SEP) \
84 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_SETS) \
85 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_BAGS) \
86 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_STRINGS) \
87 CVC4_FOR_EACH_THEORY_STATEMENT(CVC4::theory::THEORY_QUANTIFIERS)
91 /* -------------------------------------------------------------------------- */
93 inline void flattenAnd(Node n
, std::vector
<TNode
>& out
){
94 Assert(n
.getKind() == kind::AND
);
95 for(Node::iterator i
=n
.begin(), i_end
=n
.end(); i
!= i_end
; ++i
){
97 if(curr
.getKind() == kind::AND
){
98 flattenAnd(curr
, out
);
105 inline Node
flattenAnd(Node n
){
106 std::vector
<TNode
> out
;
108 return NodeManager::currentNM()->mkNode(kind::AND
, out
);
112 * Compute the string for a given theory id. In this module, we use
113 * THEORY_SAT_SOLVER as an id, which is not a normal id but maps to
114 * THEORY_LAST. Thus, we need our own string conversion here.
116 * @param id The theory id
117 * @return The string corresponding to the theory id
119 std::string
getTheoryString(theory::TheoryId id
)
121 if (id
== theory::THEORY_SAT_SOLVER
)
123 return "THEORY_SAT_SOLVER";
127 std::stringstream ss
;
133 void TheoryEngine::finishInit()
135 // NOTE: This seems to be required since
136 // theory::TheoryTraits<THEORY>::isParametric cannot be accessed without
137 // using the CVC4_FOR_EACH_THEORY_STATEMENT macro. -AJR
138 std::vector
<theory::Theory
*> paraTheories
;
139 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
140 #undef CVC4_FOR_EACH_THEORY_STATEMENT
142 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
143 if (theory::TheoryTraits<THEORY>::isParametric \
144 && d_logicInfo.isTheoryEnabled(THEORY)) \
146 paraTheories.push_back(theoryOf(THEORY)); \
148 // Collect the parametric theories, which are given to the theory combination
150 CVC4_FOR_EACH_THEORY
;
152 // Initialize the theory combination architecture
153 if (options::tcMode() == options::TcMode::CARE_GRAPH
)
155 d_tc
.reset(new CombinationCareGraph(*this, paraTheories
, d_pnm
));
159 Unimplemented() << "TheoryEngine::finishInit: theory combination mode "
160 << options::tcMode() << " not supported";
162 // create the relevance filter if any option requires it
163 if (options::relevanceFilter())
166 new RelevanceManager(d_userContext
, theory::Valuation(this)));
169 // initialize the quantifiers engine
170 if (d_logicInfo
.isQuantified())
172 // initialize the quantifiers engine
173 d_quantEngine
= new QuantifiersEngine(this, *d_decManager
.get(), d_pnm
);
175 // initialize the theory combination manager, which decides and allocates the
176 // equality engines to use for all theories.
178 // get pointer to the shared solver
179 d_sharedSolver
= d_tc
->getSharedSolver();
181 // set the core equality engine on quantifiers engine
182 if (d_logicInfo
.isQuantified())
184 d_quantEngine
->setMasterEqualityEngine(d_tc
->getCoreEqualityEngine());
187 // finish initializing the theories by linking them with the appropriate
188 // utilities and then calling their finishInit method.
189 for(TheoryId theoryId
= theory::THEORY_FIRST
; theoryId
!= theory::THEORY_LAST
; ++ theoryId
) {
190 Theory
* t
= d_theoryTable
[theoryId
];
195 // setup the pointers to the utilities
196 const EeTheoryInfo
* eeti
= d_tc
->getEeTheoryInfo(theoryId
);
197 Assert(eeti
!= nullptr);
198 // the theory's official equality engine is the one specified by the
199 // equality engine manager
200 t
->setEqualityEngine(eeti
->d_usedEe
);
201 // set the quantifiers engine
202 t
->setQuantifiersEngine(d_quantEngine
);
203 // set the decision manager for the theory
204 t
->setDecisionManager(d_decManager
.get());
205 // finish initializing the theory
209 // finish initializing the quantifiers engine
210 if (d_logicInfo
.isQuantified())
212 d_quantEngine
->finishInit();
216 ProofNodeManager
* TheoryEngine::getProofNodeManager() const { return d_pnm
; }
218 TheoryEngine::TheoryEngine(context::Context
* context
,
219 context::UserContext
* userContext
,
221 const LogicInfo
& logicInfo
,
222 OutputManager
& outMgr
,
223 ProofNodeManager
* pnm
)
224 : d_propEngine(nullptr),
226 d_userContext(userContext
),
227 d_logicInfo(logicInfo
),
233 d_pnm
, nullptr, d_userContext
, "TheoryEngine::LazyCDProof")
235 d_tepg(new TheoryEngineProofGenerator(d_pnm
, d_userContext
)),
237 d_sharedSolver(nullptr),
238 d_quantEngine(nullptr),
239 d_decManager(new DecisionManager(userContext
)),
240 d_relManager(nullptr),
241 d_preRegistrationVisitor(this, context
),
242 d_eager_model_building(false),
243 d_inConflict(context
, false),
245 d_hasShutDown(false),
246 d_incomplete(context
, false),
247 d_propagationMap(context
),
248 d_propagationMapTimestamp(context
, 0),
249 d_propagatedLiterals(context
),
250 d_propagatedLiteralsIndex(context
, 0),
251 d_atomRequests(context
),
252 d_combineTheoriesTime("TheoryEngine::combineTheoriesTime"),
255 d_interrupted(false),
256 d_resourceManager(rm
),
257 d_inPreregister(false),
258 d_factsAsserted(context
, false),
260 d_arithSubstitutionsAdded("theory::arith::zzz::arith::substitutions", 0)
262 for(TheoryId theoryId
= theory::THEORY_FIRST
; theoryId
!= theory::THEORY_LAST
;
265 d_theoryTable
[theoryId
] = NULL
;
266 d_theoryOut
[theoryId
] = NULL
;
269 smtStatisticsRegistry()->registerStat(&d_combineTheoriesTime
);
270 d_true
= NodeManager::currentNM()->mkConst
<bool>(true);
271 d_false
= NodeManager::currentNM()->mkConst
<bool>(false);
273 smtStatisticsRegistry()->registerStat(&d_arithSubstitutionsAdded
);
276 TheoryEngine::~TheoryEngine() {
277 Assert(d_hasShutDown
);
279 for(TheoryId theoryId
= theory::THEORY_FIRST
; theoryId
!= theory::THEORY_LAST
; ++ theoryId
) {
280 if(d_theoryTable
[theoryId
] != NULL
) {
281 delete d_theoryTable
[theoryId
];
282 delete d_theoryOut
[theoryId
];
286 delete d_quantEngine
;
288 smtStatisticsRegistry()->unregisterStat(&d_combineTheoriesTime
);
289 smtStatisticsRegistry()->unregisterStat(&d_arithSubstitutionsAdded
);
292 void TheoryEngine::interrupt() { d_interrupted
= true; }
293 void TheoryEngine::preRegister(TNode preprocessed
) {
294 Debug("theory") << "TheoryEngine::preRegister( " << preprocessed
<< ")"
296 d_preregisterQueue
.push(preprocessed
);
298 if (!d_inPreregister
) {
299 // We're in pre-register
300 d_inPreregister
= true;
302 // Process the pre-registration queue
303 while (!d_preregisterQueue
.empty()) {
304 // Get the next atom to pre-register
305 preprocessed
= d_preregisterQueue
.front();
306 d_preregisterQueue
.pop();
308 // the atom should not have free variables
309 Debug("theory") << "TheoryEngine::preRegister: " << preprocessed
311 Assert(!expr::hasFreeVar(preprocessed
));
312 // should not have witness
313 Assert(!expr::hasSubtermKind(kind::WITNESS
, preprocessed
));
315 // Pre-register the terms in the atom
316 theory::TheoryIdSet theories
= NodeVisitor
<PreRegisterVisitor
>::run(
317 d_preRegistrationVisitor
, preprocessed
);
318 theories
= TheoryIdSetUtil::setRemove(THEORY_BOOL
, theories
);
319 // Remove the top theory, if any more that means multiple theories were
321 bool multipleTheories
=
322 TheoryIdSetUtil::setRemove(Theory::theoryOf(preprocessed
), theories
);
323 if (Configuration::isAssertionBuild())
326 // This should never throw an exception, since theories should be
327 // guaranteed to be initialized.
328 // These checks don't work with finite model finding, because it
329 // uses Rational constants to represent cardinality constraints,
330 // even though arithmetic isn't actually involved.
331 if (!options::finiteModelFind())
333 while ((i
= TheoryIdSetUtil::setPop(theories
)) != THEORY_LAST
)
335 if (!d_logicInfo
.isTheoryEnabled(i
))
337 LogicInfo newLogicInfo
= d_logicInfo
.getUnlockedCopy();
338 newLogicInfo
.enableTheory(i
);
340 std::stringstream ss
;
341 ss
<< "The logic was specified as " << d_logicInfo
.getLogicString()
342 << ", which doesn't include " << i
343 << ", but found a term in that theory." << std::endl
344 << "You might want to extend your logic to "
345 << newLogicInfo
.getLogicString() << std::endl
;
346 throw LogicException(ss
.str());
352 // pre-register with the shared solver, which also handles
353 // calling prepregister on individual theories.
354 Assert(d_sharedSolver
!= nullptr);
355 d_sharedSolver
->preRegisterShared(preprocessed
, multipleTheories
);
358 // Leaving pre-register
359 d_inPreregister
= false;
363 void TheoryEngine::printAssertions(const char* tag
) {
364 if (Trace
.isOn(tag
)) {
366 for (TheoryId theoryId
= THEORY_FIRST
; theoryId
< THEORY_LAST
; ++theoryId
) {
367 Theory
* theory
= d_theoryTable
[theoryId
];
368 if (theory
&& d_logicInfo
.isTheoryEnabled(theoryId
)) {
369 Trace(tag
) << "--------------------------------------------" << endl
;
370 Trace(tag
) << "Assertions of " << theory
->getId() << ": " << endl
;
372 context::CDList
<Assertion
>::const_iterator it
= theory
->facts_begin(),
375 for (unsigned i
= 0; it
!= it_end
; ++it
, ++i
)
377 if ((*it
).d_isPreregistered
)
379 Trace(tag
) << "[" << i
<< "]: ";
383 Trace(tag
) << "(" << i
<< "): ";
385 Trace(tag
) << (*it
).d_assertion
<< endl
;
389 if (d_logicInfo
.isSharingEnabled()) {
390 Trace(tag
) << "Shared terms of " << theory
->getId() << ": " << endl
;
391 context::CDList
<TNode
>::const_iterator it
= theory
->shared_terms_begin(), it_end
= theory
->shared_terms_end();
392 for (unsigned i
= 0; it
!= it_end
; ++ it
, ++i
) {
393 Trace(tag
) << "[" << i
<< "]: " << (*it
) << endl
;
401 void TheoryEngine::dumpAssertions(const char* tag
) {
402 if (Dump
.isOn(tag
)) {
403 const Printer
& printer
= d_outMgr
.getPrinter();
404 std::ostream
& out
= d_outMgr
.getDumpOut();
405 printer
.toStreamCmdComment(out
, "Starting completeness check");
406 for (TheoryId theoryId
= THEORY_FIRST
; theoryId
< THEORY_LAST
; ++theoryId
) {
407 Theory
* theory
= d_theoryTable
[theoryId
];
408 if (theory
&& d_logicInfo
.isTheoryEnabled(theoryId
)) {
409 printer
.toStreamCmdComment(out
, "Completeness check");
410 printer
.toStreamCmdPush(out
);
412 // Dump the shared terms
413 if (d_logicInfo
.isSharingEnabled()) {
414 printer
.toStreamCmdComment(out
, "Shared terms");
415 context::CDList
<TNode
>::const_iterator it
= theory
->shared_terms_begin(), it_end
= theory
->shared_terms_end();
416 for (unsigned i
= 0; it
!= it_end
; ++ it
, ++i
) {
419 printer
.toStreamCmdComment(out
, ss
.str());
423 // Dump the assertions
424 printer
.toStreamCmdComment(out
, "Assertions");
425 context::CDList
<Assertion
>::const_iterator it
= theory
->facts_begin(), it_end
= theory
->facts_end();
426 for (; it
!= it_end
; ++ it
) {
428 Node assertionNode
= (*it
).d_assertion
;
429 // Purify all the terms
431 if ((*it
).d_isPreregistered
)
433 printer
.toStreamCmdComment(out
, "Preregistered");
437 printer
.toStreamCmdComment(out
, "Shared assertion");
439 printer
.toStreamCmdAssert(out
, assertionNode
);
441 printer
.toStreamCmdCheckSat(out
);
443 printer
.toStreamCmdPop(out
);
450 * Check all (currently-active) theories for conflicts.
451 * @param effort the effort level to use
453 void TheoryEngine::check(Theory::Effort effort
) {
456 // Reset the interrupt flag
457 d_interrupted
= false;
459 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
460 #undef CVC4_FOR_EACH_THEORY_STATEMENT
462 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
463 if (theory::TheoryTraits<THEORY>::hasCheck \
464 && d_logicInfo.isTheoryEnabled(THEORY)) \
466 theoryOf(THEORY)->check(effort); \
469 Debug("conflict") << THEORY << " in conflict. " << std::endl; \
477 // Mark the output channel unused (if this is FULL_EFFORT, and nothing
478 // is done by the theories, no additional check will be needed)
479 d_outputChannelUsed
= false;
481 // Mark the lemmas flag (no lemmas added)
482 d_lemmasAdded
= false;
484 Debug("theory") << "TheoryEngine::check(" << effort
<< "): d_factsAsserted = " << (d_factsAsserted
? "true" : "false") << endl
;
486 // If in full effort, we have a fake new assertion just to jumpstart the checking
487 if (Theory::fullEffort(effort
)) {
488 d_factsAsserted
= true;
489 // Reset round for the relevance manager, which notice only sets a flag
490 // to indicate that its information must be recomputed.
491 if (d_relManager
!= nullptr)
493 d_relManager
->resetRound();
499 while (d_factsAsserted
&& !d_inConflict
&& !d_lemmasAdded
) {
501 Debug("theory") << "TheoryEngine::check(" << effort
<< "): running check" << endl
;
503 Trace("theory::assertions") << endl
;
504 if (Trace
.isOn("theory::assertions")) {
505 printAssertions("theory::assertions");
508 if(Theory::fullEffort(effort
)) {
509 Trace("theory::assertions::fulleffort") << endl
;
510 if (Trace
.isOn("theory::assertions::fulleffort")) {
511 printAssertions("theory::assertions::fulleffort");
515 // Note that we've discharged all the facts
516 d_factsAsserted
= false;
519 CVC4_FOR_EACH_THEORY
;
521 Debug("theory") << "TheoryEngine::check(" << effort
<< "): running propagation after the initial check" << endl
;
523 // We are still satisfiable, propagate as much as possible
526 // We do combination if all has been processed and we are in fullcheck
527 if (Theory::fullEffort(effort
) && d_logicInfo
.isSharingEnabled() && !d_factsAsserted
&& !d_lemmasAdded
&& !d_inConflict
) {
528 // Do the combination
529 Debug("theory") << "TheoryEngine::check(" << effort
<< "): running combination" << endl
;
531 TimerStat::CodeTimer
combineTheoriesTimer(d_combineTheoriesTime
);
532 d_tc
->combineTheories();
534 if(d_logicInfo
.isQuantified()){
535 d_quantEngine
->notifyCombineTheories();
540 // Must consult quantifiers theory for last call to ensure sat, or otherwise add a lemma
541 if( Theory::fullEffort(effort
) && ! d_inConflict
&& ! needCheck() ) {
542 Trace("theory::assertions-model") << endl
;
543 if (Trace
.isOn("theory::assertions-model")) {
544 printAssertions("theory::assertions-model");
546 // reset the model in the combination engine
548 //checks for theories requiring the model go at last call
549 for (TheoryId theoryId
= THEORY_FIRST
; theoryId
< THEORY_LAST
; ++theoryId
) {
550 if( theoryId
!=THEORY_QUANTIFIERS
){
551 Theory
* theory
= d_theoryTable
[theoryId
];
552 if (theory
&& d_logicInfo
.isTheoryEnabled(theoryId
)) {
553 if( theory
->needsCheckLastEffort() ){
554 if (!d_tc
->buildModel())
558 theory
->check(Theory::EFFORT_LAST_CALL
);
565 if(d_logicInfo
.isQuantified()) {
566 // quantifiers engine must check at last call effort
567 d_quantEngine
->check(Theory::EFFORT_LAST_CALL
);
570 if (!d_inConflict
&& !needCheck())
572 // If d_eager_model_building is false, then we only mark that we
573 // are in "SAT mode". We build the model later only if the user asks
574 // for it via getBuiltModel.
576 if (d_eager_model_building
)
583 Debug("theory") << "TheoryEngine::check(" << effort
<< "): done, we are " << (d_inConflict
? "unsat" : "sat") << (d_lemmasAdded
? " with new lemmas" : " with no new lemmas");
584 Debug("theory") << ", need check = " << (needCheck() ? "YES" : "NO") << endl
;
586 if( Theory::fullEffort(effort
) && !d_inConflict
&& !needCheck()) {
587 // Do post-processing of model from the theories (e.g. used for THEORY_SEP
588 // to construct heap model)
589 d_tc
->postProcessModel(d_incomplete
.get());
591 } catch(const theory::Interrupted
&) {
592 Trace("theory") << "TheoryEngine::check() => interrupted" << endl
;
594 // If fulleffort, check all theories
595 if(Dump
.isOn("theory::fullcheck") && Theory::fullEffort(effort
)) {
596 if (!d_inConflict
&& !needCheck()) {
597 dumpAssertions("theory::fullcheck");
602 void TheoryEngine::propagate(Theory::Effort effort
)
604 // Reset the interrupt flag
605 d_interrupted
= false;
607 // Definition of the statement that is to be run by every theory
608 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
609 #undef CVC4_FOR_EACH_THEORY_STATEMENT
611 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
612 if (theory::TheoryTraits<THEORY>::hasPropagate && d_logicInfo.isTheoryEnabled(THEORY)) { \
613 theoryOf(THEORY)->propagate(effort); \
616 // Reset the interrupt flag
617 d_interrupted
= false;
619 // Propagate for each theory using the statement above
620 CVC4_FOR_EACH_THEORY
;
623 Node
TheoryEngine::getNextDecisionRequest()
625 return d_decManager
->getNextDecisionRequest();
628 bool TheoryEngine::properConflict(TNode conflict
) const {
630 if (conflict
.getKind() == kind::AND
) {
631 for (unsigned i
= 0; i
< conflict
.getNumChildren(); ++ i
) {
632 if (! getPropEngine()->hasValue(conflict
[i
], value
)) {
633 Debug("properConflict") << "Bad conflict is due to unassigned atom: "
634 << conflict
[i
] << endl
;
638 Debug("properConflict") << "Bad conflict is due to false atom: "
639 << conflict
[i
] << endl
;
642 if (conflict
[i
] != Rewriter::rewrite(conflict
[i
])) {
643 Debug("properConflict") << "Bad conflict is due to atom not in normal form: "
644 << conflict
[i
] << " vs " << Rewriter::rewrite(conflict
[i
]) << endl
;
649 if (! getPropEngine()->hasValue(conflict
, value
)) {
650 Debug("properConflict") << "Bad conflict is due to unassigned atom: "
655 Debug("properConflict") << "Bad conflict is due to false atom: "
659 if (conflict
!= Rewriter::rewrite(conflict
)) {
660 Debug("properConflict") << "Bad conflict is due to atom not in normal form: "
661 << conflict
<< " vs " << Rewriter::rewrite(conflict
) << endl
;
668 TheoryModel
* TheoryEngine::getModel()
670 Assert(d_tc
!= nullptr);
671 TheoryModel
* m
= d_tc
->getModel();
672 Assert(m
!= nullptr);
676 TheoryModel
* TheoryEngine::getBuiltModel()
678 Assert(d_tc
!= nullptr);
679 // If this method was called, we should be in SAT mode, and produceModels
681 AlwaysAssert(options::produceModels());
684 // not available, perhaps due to interuption.
687 // must build model at this point
688 if (!d_tc
->buildModel())
692 return d_tc
->getModel();
695 bool TheoryEngine::buildModel()
697 Assert(d_tc
!= nullptr);
698 return d_tc
->buildModel();
701 bool TheoryEngine::getSynthSolutions(
702 std::map
<Node
, std::map
<Node
, Node
>>& sol_map
)
706 return d_quantEngine
->getSynthSolutions(sol_map
);
708 // we are not in a quantified logic, there is no synthesis solution
712 bool TheoryEngine::presolve() {
713 // Reset the interrupt flag
714 d_interrupted
= false;
716 // Reset the decision manager. This clears its decision strategies that are
717 // no longer valid in this user context.
718 d_decManager
->presolve();
721 // Definition of the statement that is to be run by every theory
722 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
723 #undef CVC4_FOR_EACH_THEORY_STATEMENT
725 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
726 if (theory::TheoryTraits<THEORY>::hasPresolve) { \
727 theoryOf(THEORY)->presolve(); \
733 // Presolve for each theory using the statement above
734 CVC4_FOR_EACH_THEORY
;
735 } catch(const theory::Interrupted
&) {
736 Trace("theory") << "TheoryEngine::presolve() => interrupted" << endl
;
738 // return whether we have a conflict
740 }/* TheoryEngine::presolve() */
742 void TheoryEngine::postsolve() {
743 // no longer in SAT mode
745 // Reset the interrupt flag
746 d_interrupted
= false;
747 bool CVC4_UNUSED wasInConflict
= d_inConflict
;
750 // Definition of the statement that is to be run by every theory
751 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
752 #undef CVC4_FOR_EACH_THEORY_STATEMENT
754 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
755 if (theory::TheoryTraits<THEORY>::hasPostsolve) \
757 theoryOf(THEORY)->postsolve(); \
758 Assert(!d_inConflict || wasInConflict) \
759 << "conflict raised during postsolve()"; \
762 // Postsolve for each theory using the statement above
763 CVC4_FOR_EACH_THEORY
;
764 } catch(const theory::Interrupted
&) {
765 Trace("theory") << "TheoryEngine::postsolve() => interrupted" << endl
;
767 }/* TheoryEngine::postsolve() */
770 void TheoryEngine::notifyRestart() {
771 // Reset the interrupt flag
772 d_interrupted
= false;
774 // Definition of the statement that is to be run by every theory
775 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
776 #undef CVC4_FOR_EACH_THEORY_STATEMENT
778 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
779 if (theory::TheoryTraits<THEORY>::hasNotifyRestart && d_logicInfo.isTheoryEnabled(THEORY)) { \
780 theoryOf(THEORY)->notifyRestart(); \
783 // notify each theory using the statement above
784 CVC4_FOR_EACH_THEORY
;
787 void TheoryEngine::ppStaticLearn(TNode in
, NodeBuilder
<>& learned
) {
788 // Reset the interrupt flag
789 d_interrupted
= false;
791 // Definition of the statement that is to be run by every theory
792 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
793 #undef CVC4_FOR_EACH_THEORY_STATEMENT
795 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
796 if (theory::TheoryTraits<THEORY>::hasPpStaticLearn) { \
797 theoryOf(THEORY)->ppStaticLearn(in, learned); \
800 // static learning for each theory using the statement above
801 CVC4_FOR_EACH_THEORY
;
804 bool TheoryEngine::isRelevant(Node lit
) const
806 if (d_relManager
!= nullptr)
808 return d_relManager
->isRelevant(lit
);
810 // otherwise must assume its relevant
814 void TheoryEngine::shutdown() {
815 // Set this first; if a Theory shutdown() throws an exception,
816 // at least the destruction of the TheoryEngine won't confound
818 d_hasShutDown
= true;
820 // Shutdown all the theories
821 for(TheoryId theoryId
= theory::THEORY_FIRST
; theoryId
< theory::THEORY_LAST
; ++theoryId
) {
822 if(d_theoryTable
[theoryId
]) {
823 theoryOf(theoryId
)->shutdown();
828 theory::Theory::PPAssertStatus
TheoryEngine::solve(
829 TrustNode tliteral
, TrustSubstitutionMap
& substitutionOut
)
831 // Reset the interrupt flag
832 d_interrupted
= false;
834 TNode literal
= tliteral
.getNode();
835 TNode atom
= literal
.getKind() == kind::NOT
? literal
[0] : literal
;
836 Trace("theory::solve") << "TheoryEngine::solve(" << literal
<< "): solving with " << theoryOf(atom
)->getId() << endl
;
838 if(! d_logicInfo
.isTheoryEnabled(Theory::theoryOf(atom
)) &&
839 Theory::theoryOf(atom
) != THEORY_SAT_SOLVER
) {
841 ss
<< "The logic was specified as " << d_logicInfo
.getLogicString()
842 << ", which doesn't include " << Theory::theoryOf(atom
)
843 << ", but got a preprocessing-time fact for that theory." << endl
844 << "The fact:" << endl
846 throw LogicException(ss
.str());
849 Theory::PPAssertStatus solveStatus
=
850 theoryOf(atom
)->ppAssert(tliteral
, substitutionOut
);
851 Trace("theory::solve") << "TheoryEngine::solve(" << literal
<< ") => " << solveStatus
<< endl
;
855 theory::TrustNode
TheoryEngine::ppRewriteEquality(TNode eq
)
857 Assert(eq
.getKind() == kind::EQUAL
);
858 return theoryOf(eq
)->ppRewrite(eq
);
861 void TheoryEngine::notifyPreprocessedAssertions(
862 const std::vector
<Node
>& assertions
) {
863 // call all the theories
864 for (TheoryId theoryId
= theory::THEORY_FIRST
; theoryId
< theory::THEORY_LAST
;
866 if (d_theoryTable
[theoryId
]) {
867 theoryOf(theoryId
)->ppNotifyAssertions(assertions
);
870 if (d_relManager
!= nullptr)
872 d_relManager
->notifyPreprocessedAssertions(assertions
);
876 bool TheoryEngine::markPropagation(TNode assertion
, TNode originalAssertion
, theory::TheoryId toTheoryId
, theory::TheoryId fromTheoryId
) {
878 // What and where we are asserting
879 NodeTheoryPair
toAssert(assertion
, toTheoryId
, d_propagationMapTimestamp
);
880 // What and where it came from
881 NodeTheoryPair
toExplain(originalAssertion
, fromTheoryId
, d_propagationMapTimestamp
);
883 // See if the theory already got this literal
884 PropagationMap::const_iterator find
= d_propagationMap
.find(toAssert
);
885 if (find
!= d_propagationMap
.end()) {
886 // The theory already knows this
887 Trace("theory::assertToTheory") << "TheoryEngine::markPropagation(): already there" << endl
;
891 Trace("theory::assertToTheory") << "TheoryEngine::markPropagation(): marking [" << d_propagationMapTimestamp
<< "] " << assertion
<< ", " << toTheoryId
<< " from " << originalAssertion
<< ", " << fromTheoryId
<< endl
;
893 // Mark the propagation
894 d_propagationMap
[toAssert
] = toExplain
;
895 d_propagationMapTimestamp
= d_propagationMapTimestamp
+ 1;
901 void TheoryEngine::assertToTheory(TNode assertion
, TNode originalAssertion
, theory::TheoryId toTheoryId
, theory::TheoryId fromTheoryId
) {
903 Trace("theory::assertToTheory") << "TheoryEngine::assertToTheory(" << assertion
<< ", " << originalAssertion
<< "," << toTheoryId
<< ", " << fromTheoryId
<< ")" << endl
;
905 Assert(toTheoryId
!= fromTheoryId
);
906 if(toTheoryId
!= THEORY_SAT_SOLVER
&&
907 ! d_logicInfo
.isTheoryEnabled(toTheoryId
)) {
909 ss
<< "The logic was specified as " << d_logicInfo
.getLogicString()
910 << ", which doesn't include " << toTheoryId
911 << ", but got an asserted fact to that theory." << endl
912 << "The fact:" << endl
914 throw LogicException(ss
.str());
921 // If sharing is disabled, things are easy
922 if (!d_logicInfo
.isSharingEnabled()) {
923 Assert(assertion
== originalAssertion
);
924 if (fromTheoryId
== THEORY_SAT_SOLVER
) {
925 // Send to the apropriate theory
926 theory::Theory
* toTheory
= theoryOf(toTheoryId
);
927 // We assert it, and we know it's preregistereed
928 toTheory
->assertFact(assertion
, true);
929 // Mark that we have more information
930 d_factsAsserted
= true;
932 Assert(toTheoryId
== THEORY_SAT_SOLVER
);
933 // Check for propositional conflict
935 if (d_propEngine
->hasValue(assertion
, value
)) {
937 Trace("theory::propagate") << "TheoryEngine::assertToTheory(" << assertion
<< ", " << toTheoryId
<< ", " << fromTheoryId
<< "): conflict (no sharing)" << endl
;
938 Trace("dtview::conflict")
939 << ":THEORY-CONFLICT: " << assertion
<< std::endl
;
945 d_propagatedLiterals
.push_back(assertion
);
950 // If sending to the shared terms database, it's also simple
951 if (toTheoryId
== THEORY_BUILTIN
) {
952 Assert(assertion
.getKind() == kind::EQUAL
953 || (assertion
.getKind() == kind::NOT
954 && assertion
[0].getKind() == kind::EQUAL
))
955 << "atom should be an EQUALity, not `" << assertion
<< "'";
956 if (markPropagation(assertion
, originalAssertion
, toTheoryId
, fromTheoryId
)) {
957 // assert to the shared solver
958 bool polarity
= assertion
.getKind() != kind::NOT
;
959 TNode atom
= polarity
? assertion
: assertion
[0];
960 d_sharedSolver
->assertSharedEquality(atom
, polarity
, assertion
);
965 // Things from the SAT solver are already normalized, so they go
966 // directly to the apropriate theory
967 if (fromTheoryId
== THEORY_SAT_SOLVER
) {
968 // We know that this is normalized, so just send it off to the theory
969 if (markPropagation(assertion
, originalAssertion
, toTheoryId
, fromTheoryId
)) {
970 // Is it preregistered
971 bool preregistered
= d_propEngine
->isSatLiteral(assertion
) && Theory::theoryOf(assertion
) == toTheoryId
;
973 theoryOf(toTheoryId
)->assertFact(assertion
, preregistered
);
974 // Mark that we have more information
975 d_factsAsserted
= true;
980 // Propagations to the SAT solver are just enqueued for pickup by
981 // the SAT solver later
982 if (toTheoryId
== THEORY_SAT_SOLVER
) {
983 if (markPropagation(assertion
, originalAssertion
, toTheoryId
, fromTheoryId
)) {
984 // Enqueue for propagation to the SAT solver
985 d_propagatedLiterals
.push_back(assertion
);
986 // Check for propositional conflicts
988 if (d_propEngine
->hasValue(assertion
, value
) && !value
) {
989 Trace("theory::propagate")
990 << "TheoryEngine::assertToTheory(" << assertion
<< ", "
991 << toTheoryId
<< ", " << fromTheoryId
<< "): conflict (sharing)"
993 Trace("dtview::conflict")
994 << ":THEORY-CONFLICT: " << assertion
<< std::endl
;
1001 Assert(assertion
.getKind() == kind::EQUAL
1002 || (assertion
.getKind() == kind::NOT
1003 && assertion
[0].getKind() == kind::EQUAL
));
1006 Node normalizedLiteral
= Rewriter::rewrite(assertion
);
1008 // See if it rewrites false directly -> conflict
1009 if (normalizedLiteral
.isConst()) {
1010 if (!normalizedLiteral
.getConst
<bool>()) {
1011 // Mark the propagation for explanations
1012 if (markPropagation(normalizedLiteral
, originalAssertion
, toTheoryId
, fromTheoryId
)) {
1013 // special case, trust node has no proof generator
1014 TrustNode trnn
= TrustNode::mkTrustConflict(normalizedLiteral
);
1015 // Get the explanation (conflict will figure out where it came from)
1016 conflict(trnn
, toTheoryId
);
1024 // Try and assert (note that we assert the non-normalized one)
1025 if (markPropagation(assertion
, originalAssertion
, toTheoryId
, fromTheoryId
)) {
1026 // Check if has been pre-registered with the theory
1027 bool preregistered
= d_propEngine
->isSatLiteral(assertion
) && Theory::theoryOf(assertion
) == toTheoryId
;
1029 theoryOf(toTheoryId
)->assertFact(assertion
, preregistered
);
1030 d_factsAsserted
= true;
1036 void TheoryEngine::assertFact(TNode literal
)
1038 Trace("theory") << "TheoryEngine::assertFact(" << literal
<< ")" << endl
;
1042 // If we're in conflict, nothing to do
1048 bool polarity
= literal
.getKind() != kind::NOT
;
1049 TNode atom
= polarity
? literal
: literal
[0];
1051 if (d_logicInfo
.isSharingEnabled()) {
1052 // If any shared terms, it's time to do sharing work
1053 d_sharedSolver
->preNotifySharedFact(atom
);
1055 // If it's an equality, assert it to the shared term manager, even though the terms are not
1056 // yet shared. As the terms become shared later, the shared terms manager will then add them
1057 // to the assert the equality to the interested theories
1058 if (atom
.getKind() == kind::EQUAL
) {
1059 // Assert it to the the owning theory
1060 assertToTheory(literal
, literal
, /* to */ Theory::theoryOf(atom
), /* from */ THEORY_SAT_SOLVER
);
1061 // Shared terms manager will assert to interested theories directly, as
1062 // the terms become shared
1063 assertToTheory(literal
, literal
, /* to */ THEORY_BUILTIN
, /* from */ THEORY_SAT_SOLVER
);
1065 // Now, let's check for any atom triggers from lemmas
1066 AtomRequests::atom_iterator it
= d_atomRequests
.getAtomIterator(atom
);
1067 while (!it
.done()) {
1068 const AtomRequests::Request
& request
= it
.get();
1070 polarity
? (Node
)request
.d_atom
: request
.d_atom
.notNode();
1071 Debug("theory::atoms") << "TheoryEngine::assertFact(" << literal
<< "): sending requested " << toAssert
<< endl
;
1073 toAssert
, literal
, request
.d_toTheory
, THEORY_SAT_SOLVER
);
1078 // Not an equality, just assert to the appropriate theory
1079 assertToTheory(literal
, literal
, /* to */ Theory::theoryOf(atom
), /* from */ THEORY_SAT_SOLVER
);
1082 // Assert the fact to the appropriate theory directly
1083 assertToTheory(literal
, literal
, /* to */ Theory::theoryOf(atom
), /* from */ THEORY_SAT_SOLVER
);
1087 bool TheoryEngine::propagate(TNode literal
, theory::TheoryId theory
) {
1088 Debug("theory::propagate") << "TheoryEngine::propagate(" << literal
<< ", " << theory
<< ")" << endl
;
1090 Trace("dtview::prop") << std::string(d_context
->getLevel(), ' ')
1091 << ":THEORY-PROP: " << literal
<< endl
;
1096 bool polarity
= literal
.getKind() != kind::NOT
;
1097 TNode atom
= polarity
? literal
: literal
[0];
1099 if (d_logicInfo
.isSharingEnabled() && atom
.getKind() == kind::EQUAL
) {
1100 if (d_propEngine
->isSatLiteral(literal
)) {
1101 // We propagate SAT literals to SAT
1102 assertToTheory(literal
, literal
, /* to */ THEORY_SAT_SOLVER
, /* from */ theory
);
1104 if (theory
!= THEORY_BUILTIN
) {
1105 // Assert to the shared terms database
1106 assertToTheory(literal
, literal
, /* to */ THEORY_BUILTIN
, /* from */ theory
);
1109 // Just send off to the SAT solver
1110 Assert(d_propEngine
->isSatLiteral(literal
));
1111 assertToTheory(literal
, literal
, /* to */ THEORY_SAT_SOLVER
, /* from */ theory
);
1114 return !d_inConflict
;
1117 const LogicInfo
& TheoryEngine::getLogicInfo() const { return d_logicInfo
; }
1119 bool TheoryEngine::getSepHeapTypes(TypeNode
& locType
, TypeNode
& dataType
) const
1121 if (d_sepLocType
.isNull())
1125 locType
= d_sepLocType
;
1126 dataType
= d_sepDataType
;
1130 void TheoryEngine::declareSepHeap(TypeNode locT
, TypeNode dataT
)
1132 Theory
* tsep
= theoryOf(THEORY_SEP
);
1133 if (tsep
== nullptr)
1135 Assert(false) << "TheoryEngine::declareSepHeap called without the "
1136 "separation logic theory enabled";
1140 // Definition of the statement that is to be run by every theory
1141 #ifdef CVC4_FOR_EACH_THEORY_STATEMENT
1142 #undef CVC4_FOR_EACH_THEORY_STATEMENT
1144 #define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
1145 theoryOf(THEORY)->declareSepHeap(locT, dataT);
1147 // notify each theory using the statement above
1148 CVC4_FOR_EACH_THEORY
;
1150 // remember the types we have set
1151 d_sepLocType
= locT
;
1152 d_sepDataType
= dataT
;
1155 theory::EqualityStatus
TheoryEngine::getEqualityStatus(TNode a
, TNode b
) {
1156 Assert(a
.getType().isComparableTo(b
.getType()));
1157 return d_sharedSolver
->getEqualityStatus(a
, b
);
1160 Node
TheoryEngine::getModelValue(TNode var
) {
1163 // the model value of a constant must be itself
1166 Assert(d_sharedSolver
->isShared(var
));
1167 return theoryOf(Theory::theoryOf(var
.getType()))->getModelValue(var
);
1171 Node
TheoryEngine::ensureLiteral(TNode n
) {
1172 Trace("ensureLiteral") << "ensureLiteral rewriting: " << n
<< std::endl
;
1173 Node rewritten
= Rewriter::rewrite(n
);
1174 return d_propEngine
->ensureLiteral(rewritten
);
1177 Node
TheoryEngine::getPreprocessedTerm(TNode n
)
1179 Node rewritten
= Rewriter::rewrite(n
);
1180 return d_propEngine
->getPreprocessedTerm(rewritten
);
1183 void TheoryEngine::printInstantiations( std::ostream
& out
) {
1184 if( d_quantEngine
){
1185 d_quantEngine
->printInstantiations( out
);
1187 out
<< "Internal error : instantiations not available when quantifiers are not present." << std::endl
;
1192 void TheoryEngine::printSynthSolution( std::ostream
& out
) {
1193 if( d_quantEngine
){
1194 d_quantEngine
->printSynthSolution( out
);
1196 out
<< "Internal error : synth solution not available when quantifiers are not present." << std::endl
;
1201 void TheoryEngine::getInstantiatedQuantifiedFormulas( std::vector
< Node
>& qs
) {
1202 if( d_quantEngine
){
1203 d_quantEngine
->getInstantiatedQuantifiedFormulas( qs
);
1209 void TheoryEngine::getInstantiationTermVectors( Node q
, std::vector
< std::vector
< Node
> >& tvecs
) {
1210 if( d_quantEngine
){
1211 d_quantEngine
->getInstantiationTermVectors( q
, tvecs
);
1217 void TheoryEngine::getInstantiationTermVectors( std::map
< Node
, std::vector
< std::vector
< Node
> > >& insts
) {
1218 if( d_quantEngine
){
1219 d_quantEngine
->getInstantiationTermVectors( insts
);
1225 TrustNode
TheoryEngine::getExplanation(TNode node
)
1227 Debug("theory::explain") << "TheoryEngine::getExplanation(" << node
1228 << "): current propagation index = "
1229 << d_propagationMapTimestamp
<< endl
;
1230 bool polarity
= node
.getKind() != kind::NOT
;
1231 TNode atom
= polarity
? node
: node
[0];
1233 // If we're not in shared mode, explanations are simple
1234 if (!d_logicInfo
.isSharingEnabled())
1236 Debug("theory::explain")
1237 << "TheoryEngine::getExplanation: sharing is NOT enabled. "
1238 << " Responsible theory is: " << theoryOf(atom
)->getId() << std::endl
;
1240 TrustNode texplanation
= theoryOf(atom
)->explain(node
);
1241 Node explanation
= texplanation
.getNode();
1242 Debug("theory::explain") << "TheoryEngine::getExplanation(" << node
1243 << ") => " << explanation
<< endl
;
1244 if (isProofEnabled())
1246 texplanation
.debugCheckClosed(
1247 "te-proof-exp", "texplanation no share", false);
1248 // check if no generator, if so, add THEORY_LEMMA
1249 if (texplanation
.getGenerator() == nullptr)
1251 Node proven
= texplanation
.getProven();
1252 TheoryId tid
= theoryOf(atom
)->getId();
1253 Node tidn
= builtin::BuiltinProofRuleChecker::mkTheoryIdNode(tid
);
1254 d_lazyProof
->addStep(proven
, PfRule::THEORY_LEMMA
, {}, {proven
, tidn
});
1256 TrustNode::mkTrustPropExp(node
, explanation
, d_lazyProof
.get());
1259 return texplanation
;
1262 Debug("theory::explain") << "TheoryEngine::getExplanation: sharing IS enabled"
1265 // Initial thing to explain
1266 NodeTheoryPair
toExplain(node
, THEORY_SAT_SOLVER
, d_propagationMapTimestamp
);
1267 Assert(d_propagationMap
.find(toExplain
) != d_propagationMap
.end());
1269 NodeTheoryPair nodeExplainerPair
= d_propagationMap
[toExplain
];
1270 Debug("theory::explain")
1271 << "TheoryEngine::getExplanation: explainer for node "
1272 << nodeExplainerPair
.d_node
1273 << " is theory: " << nodeExplainerPair
.d_theory
<< std::endl
;
1275 // Create the workplace for explanations
1276 std::vector
<NodeTheoryPair
> vec
{d_propagationMap
[toExplain
]};
1277 // Process the explanation
1278 TrustNode texplanation
= getExplanation(vec
);
1279 Debug("theory::explain") << "TheoryEngine::getExplanation(" << node
<< ") => "
1280 << texplanation
.getNode() << endl
;
1281 return texplanation
;
1284 struct AtomsCollect
{
1286 std::vector
<TNode
> d_atoms
;
1287 std::unordered_set
<TNode
, TNodeHashFunction
> d_visited
;
1291 typedef void return_type
;
1293 bool alreadyVisited(TNode current
, TNode parent
) {
1294 // Check if already visited
1295 if (d_visited
.find(current
) != d_visited
.end()) return true;
1296 // Don't visit non-boolean
1297 if (!current
.getType().isBoolean()) return true;
1302 void visit(TNode current
, TNode parent
) {
1303 if (Theory::theoryOf(current
) != theory::THEORY_BOOL
) {
1304 d_atoms
.push_back(current
);
1306 d_visited
.insert(current
);
1309 void start(TNode node
) {}
1310 void done(TNode node
) {}
1312 std::vector
<TNode
> getAtoms() const {
1317 void TheoryEngine::ensureLemmaAtoms(const std::vector
<TNode
>& atoms
, theory::TheoryId atomsTo
) {
1318 for (unsigned i
= 0; i
< atoms
.size(); ++ i
) {
1320 // Non-equality atoms are either owned by theory or they don't make sense
1321 if (atoms
[i
].getKind() != kind::EQUAL
) {
1327 // Simple normalization to not repeat stuff
1328 if (eq
[0] > eq
[1]) {
1329 eq
= eq
[1].eqNode(eq
[0]);
1332 // Rewrite the equality
1333 Node eqNormalized
= Rewriter::rewrite(atoms
[i
]);
1335 Debug("theory::atoms") << "TheoryEngine::ensureLemmaAtoms(): " << eq
<< " with nf " << eqNormalized
<< endl
;
1337 // If the equality is a boolean constant, we send immediately
1338 if (eqNormalized
.isConst()) {
1339 if (eqNormalized
.getConst
<bool>()) {
1340 assertToTheory(eq
, eqNormalized
, /** to */ atomsTo
, /** Sat solver */ theory::THEORY_SAT_SOLVER
);
1342 assertToTheory(eq
.notNode(), eqNormalized
.notNode(), /** to */ atomsTo
, /** Sat solver */ theory::THEORY_SAT_SOLVER
);
1345 }else if( eqNormalized
.getKind() != kind::EQUAL
){
1346 Assert(eqNormalized
.getKind() == kind::BOOLEAN_TERM_VARIABLE
1347 || (eqNormalized
.getKind() == kind::NOT
1348 && eqNormalized
[0].getKind() == kind::BOOLEAN_TERM_VARIABLE
));
1349 // this happens for Boolean term equalities V = true that are rewritten to V, we should skip
1350 // TODO : revisit this
1354 // If the normalization did the just flips, keep the flip
1355 if (eqNormalized
[0] == eq
[1] && eqNormalized
[1] == eq
[0]) {
1359 // Check if the equality is already known by the sat solver
1360 if (d_propEngine
->isSatLiteral(eqNormalized
)) {
1362 if (d_propEngine
->hasValue(eqNormalized
, value
)) {
1364 assertToTheory(eq
, eqNormalized
, atomsTo
, theory::THEORY_SAT_SOLVER
);
1367 assertToTheory(eq
.notNode(), eqNormalized
.notNode(), atomsTo
, theory::THEORY_SAT_SOLVER
);
1373 // If the theory is asking about a different form, or the form is ok but if will go to a different theory
1374 // then we must figure it out
1375 if (eqNormalized
!= eq
|| Theory::theoryOf(eq
) != atomsTo
) {
1376 // If you get eqNormalized, send atoms[i] to atomsTo
1377 d_atomRequests
.add(eqNormalized
, eq
, atomsTo
);
1382 theory::LemmaStatus
TheoryEngine::lemma(theory::TrustNode tlemma
,
1383 theory::LemmaProperty p
,
1384 theory::TheoryId atomsTo
,
1385 theory::TheoryId from
)
1387 // For resource-limiting (also does a time check).
1389 Assert(tlemma
.getKind() == TrustNodeKind::LEMMA
1390 || tlemma
.getKind() == TrustNodeKind::CONFLICT
);
1392 Node node
= tlemma
.getNode();
1393 Node lemma
= tlemma
.getProven();
1394 Trace("te-lemma") << "Lemma, input: " << lemma
<< ", property = " << p
1397 Assert(!expr::hasFreeVar(lemma
));
1399 // when proofs are enabled, we ensure the trust node has a generator by
1400 // adding a trust step to the lazy proof maintained by this class
1401 if (isProofEnabled())
1403 // ensure proof: set THEORY_LEMMA if no generator is provided
1404 if (tlemma
.getGenerator() == nullptr)
1406 // internal lemmas should have generators
1407 Assert(from
!= THEORY_LAST
);
1408 // add theory lemma step to proof
1409 Node tidn
= builtin::BuiltinProofRuleChecker::mkTheoryIdNode(from
);
1410 d_lazyProof
->addStep(lemma
, PfRule::THEORY_LEMMA
, {}, {lemma
, tidn
});
1411 // update the trust node
1412 tlemma
= TrustNode::mkTrustLemma(lemma
, d_lazyProof
.get());
1415 tlemma
.debugCheckClosed("te-proof-debug", "TheoryEngine::lemma_initial");
1418 // Do we need to check atoms
1419 if (atomsTo
!= theory::THEORY_LAST
) {
1420 Debug("theory::atoms") << "TheoryEngine::lemma(" << node
<< ", " << atomsTo
<< ")" << endl
;
1421 AtomsCollect collectAtoms
;
1422 NodeVisitor
<AtomsCollect
>::run(collectAtoms
, node
);
1423 ensureLemmaAtoms(collectAtoms
.getAtoms(), atomsTo
);
1426 if(Dump
.isOn("t-lemmas")) {
1427 // we dump the negation of the lemma, to show validity of the lemma
1428 Node n
= lemma
.negate();
1429 const Printer
& printer
= d_outMgr
.getPrinter();
1430 std::ostream
& out
= d_outMgr
.getDumpOut();
1431 printer
.toStreamCmdComment(out
, "theory lemma: expect valid");
1432 printer
.toStreamCmdCheckSat(out
, n
);
1435 Node retLemma
= d_propEngine
->assertLemma(tlemma
, p
);
1437 // If specified, we must add this lemma to the set of those that need to be
1438 // justified, where note we pass all auxiliary lemmas in lemmas, since these
1439 // by extension must be justified as well.
1440 if (d_relManager
!= nullptr && isLemmaPropertyNeedsJustify(p
))
1442 d_relManager
->notifyPreprocessedAssertion(retLemma
);
1445 // Mark that we added some lemmas
1446 d_lemmasAdded
= true;
1448 return theory::LemmaStatus(retLemma
, d_userContext
->getLevel());
1451 void TheoryEngine::conflict(theory::TrustNode tconflict
, TheoryId theoryId
)
1453 Assert(tconflict
.getKind() == TrustNodeKind::CONFLICT
);
1454 TNode conflict
= tconflict
.getNode();
1455 Trace("theory::conflict") << "TheoryEngine::conflict(" << conflict
<< ", "
1456 << theoryId
<< ")" << endl
;
1457 Trace("te-proof-debug") << "Check closed conflict" << std::endl
;
1458 // doesn't require proof generator, yet, since THEORY_LEMMA is added below
1459 tconflict
.debugCheckClosed(
1460 "te-proof-debug", "TheoryEngine::conflict_initial", false);
1462 Trace("dtview::conflict") << ":THEORY-CONFLICT: " << conflict
<< std::endl
;
1464 // Mark that we are in conflict
1465 d_inConflict
= true;
1467 if(Dump
.isOn("t-conflicts")) {
1468 const Printer
& printer
= d_outMgr
.getPrinter();
1469 std::ostream
& out
= d_outMgr
.getDumpOut();
1470 printer
.toStreamCmdComment(out
, "theory conflict: expect unsat");
1471 printer
.toStreamCmdCheckSat(out
, conflict
);
1474 // In the multiple-theories case, we need to reconstruct the conflict
1475 if (d_logicInfo
.isSharingEnabled()) {
1476 // Create the workplace for explanations
1477 std::vector
<NodeTheoryPair
> vec
;
1479 NodeTheoryPair(conflict
, theoryId
, d_propagationMapTimestamp
));
1481 // Process the explanation
1482 TrustNode tncExp
= getExplanation(vec
);
1483 Trace("te-proof-debug")
1484 << "Check closed conflict explained with sharing" << std::endl
;
1485 tncExp
.debugCheckClosed("te-proof-debug",
1486 "TheoryEngine::conflict_explained_sharing");
1487 Node fullConflict
= tncExp
.getNode();
1489 if (isProofEnabled())
1491 Trace("te-proof-debug") << "Process conflict: " << conflict
<< std::endl
;
1492 Trace("te-proof-debug") << "Conflict " << tconflict
<< " from "
1493 << tconflict
.identifyGenerator() << std::endl
;
1494 Trace("te-proof-debug") << "Explanation " << tncExp
<< " from "
1495 << tncExp
.identifyGenerator() << std::endl
;
1496 Assert(d_lazyProof
!= nullptr);
1497 if (tconflict
.getGenerator() != nullptr)
1499 d_lazyProof
->addLazyStep(tconflict
.getProven(),
1500 tconflict
.getGenerator());
1504 // add theory lemma step
1505 Node tidn
= builtin::BuiltinProofRuleChecker::mkTheoryIdNode(theoryId
);
1506 Node conf
= tconflict
.getProven();
1507 d_lazyProof
->addStep(conf
, PfRule::THEORY_LEMMA
, {}, {conf
, tidn
});
1509 // store the explicit step, which should come from a different
1510 // generator, e.g. d_tepg.
1511 Node proven
= tncExp
.getProven();
1512 Assert(tncExp
.getGenerator() != d_lazyProof
.get());
1513 Trace("te-proof-debug") << "add lazy step " << tncExp
.identifyGenerator()
1514 << " for " << proven
<< std::endl
;
1515 d_lazyProof
->addLazyStep(proven
, tncExp
.getGenerator());
1516 pfgEnsureClosed(proven
,
1519 "TheoryEngine::conflict_during");
1520 Node fullConflictNeg
= fullConflict
.notNode();
1521 std::vector
<Node
> children
;
1522 children
.push_back(proven
);
1523 std::vector
<Node
> args
;
1524 args
.push_back(fullConflictNeg
);
1525 if (conflict
== d_false
)
1527 AlwaysAssert(proven
== fullConflictNeg
);
1531 if (fullConflict
!= conflict
)
1533 // ------------------------- explained ---------- from theory
1534 // fullConflict => conflict ~conflict
1535 // ------------------------------------------ MACRO_SR_PRED_TRANSFORM
1537 children
.push_back(conflict
.notNode());
1538 args
.push_back(mkMethodId(MethodId::SB_LITERAL
));
1539 d_lazyProof
->addStep(
1540 fullConflictNeg
, PfRule::MACRO_SR_PRED_TRANSFORM
, children
, args
);
1544 // pass the processed trust node
1546 TrustNode::mkTrustConflict(fullConflict
, d_lazyProof
.get());
1547 Debug("theory::conflict") << "TheoryEngine::conflict(" << conflict
<< ", " << theoryId
<< "): full = " << fullConflict
<< endl
;
1548 Assert(properConflict(fullConflict
));
1549 Trace("te-proof-debug")
1550 << "Check closed conflict with sharing" << std::endl
;
1551 tconf
.debugCheckClosed("te-proof-debug", "TheoryEngine::conflict:sharing");
1552 lemma(tconf
, LemmaProperty::REMOVABLE
);
1554 // When only one theory, the conflict should need no processing
1555 Assert(properConflict(conflict
));
1556 // pass the trust node that was sent from the theory
1557 lemma(tconflict
, LemmaProperty::REMOVABLE
, THEORY_LAST
, theoryId
);
1561 theory::TrustNode
TheoryEngine::getExplanation(
1562 std::vector
<NodeTheoryPair
>& explanationVector
)
1564 Assert(explanationVector
.size() == 1);
1565 Node conclusion
= explanationVector
[0].d_node
;
1566 std::shared_ptr
<LazyCDProof
> lcp
;
1567 if (isProofEnabled())
1569 Trace("te-proof-exp") << "=== TheoryEngine::getExplanation " << conclusion
1571 lcp
.reset(new LazyCDProof(
1572 d_pnm
, nullptr, nullptr, "TheoryEngine::LazyCDProof::getExplanation"));
1574 unsigned i
= 0; // Index of the current literal we are processing
1576 std::unique_ptr
<std::set
<Node
>> inputAssertions
= nullptr;
1577 // the overall explanation
1578 std::set
<TNode
> exp
;
1579 // vector of trust nodes to explain at the end
1580 std::vector
<std::pair
<TheoryId
, TrustNode
>> texplains
;
1581 // cache of nodes we have already explained by some theory
1582 std::unordered_map
<Node
, size_t, NodeHashFunction
> cache
;
1584 while (i
< explanationVector
.size()) {
1585 // Get the current literal to explain
1586 NodeTheoryPair toExplain
= explanationVector
[i
];
1588 Debug("theory::explain")
1589 << "[i=" << i
<< "] TheoryEngine::explain(): processing ["
1590 << toExplain
.d_timestamp
<< "] " << toExplain
.d_node
<< " sent from "
1591 << toExplain
.d_theory
<< endl
;
1593 if (cache
.find(toExplain
.d_node
) != cache
.end()
1594 && cache
[toExplain
.d_node
] < toExplain
.d_timestamp
)
1599 cache
[toExplain
.d_node
] = toExplain
.d_timestamp
;
1601 // If a true constant or a negation of a false constant we can ignore it
1602 if ((toExplain
.d_node
.isConst() && toExplain
.d_node
.getConst
<bool>())
1603 || (toExplain
.d_node
.getKind() == kind::NOT
1604 && toExplain
.d_node
[0].isConst()
1605 && !toExplain
.d_node
[0].getConst
<bool>()))
1608 // if we are building a proof
1611 Trace("te-proof-exp")
1612 << "- explain " << toExplain
.d_node
<< " trivially..." << std::endl
;
1613 // ------------------MACRO_SR_PRED_INTRO
1615 std::vector
<Node
> children
;
1616 std::vector
<Node
> args
;
1617 args
.push_back(toExplain
.d_node
);
1619 toExplain
.d_node
, PfRule::MACRO_SR_PRED_INTRO
, children
, args
);
1624 // If from the SAT solver, keep it
1625 if (toExplain
.d_theory
== THEORY_SAT_SOLVER
)
1627 Debug("theory::explain") << "\tLiteral came from THEORY_SAT_SOLVER. Kepping it." << endl
;
1628 exp
.insert(explanationVector
[i
++].d_node
);
1629 // it will be a free assumption in the proof
1630 Trace("te-proof-exp") << "- keep " << toExplain
.d_node
<< std::endl
;
1634 // If an and, expand it
1635 if (toExplain
.d_node
.getKind() == kind::AND
)
1637 Debug("theory::explain")
1638 << "TheoryEngine::explain(): expanding " << toExplain
.d_node
1639 << " got from " << toExplain
.d_theory
<< endl
;
1640 size_t nchild
= toExplain
.d_node
.getNumChildren();
1641 for (size_t k
= 0; k
< nchild
; ++k
)
1643 NodeTheoryPair
newExplain(
1644 toExplain
.d_node
[k
], toExplain
.d_theory
, toExplain
.d_timestamp
);
1645 explanationVector
.push_back(newExplain
);
1649 Trace("te-proof-exp")
1650 << "- AND expand " << toExplain
.d_node
<< std::endl
;
1651 // delay explanation, use a dummy trust node
1652 TrustNode tnAndExp
= TrustNode::mkTrustPropExp(
1653 toExplain
.d_node
, toExplain
.d_node
, nullptr);
1654 texplains
.push_back(
1655 std::pair
<TheoryId
, TrustNode
>(THEORY_LAST
, tnAndExp
));
1661 // See if it was sent to the theory by another theory
1662 PropagationMap::const_iterator find
= d_propagationMap
.find(toExplain
);
1663 if (find
!= d_propagationMap
.end()) {
1664 Debug("theory::explain")
1665 << "\tTerm was propagated by another theory (theory = "
1666 << getTheoryString((*find
).second
.d_theory
) << ")" << std::endl
;
1667 // There is some propagation, check if its a timely one
1668 if ((*find
).second
.d_timestamp
< toExplain
.d_timestamp
)
1670 Debug("theory::explain")
1671 << "\tRelevant timetsamp, pushing " << (*find
).second
.d_node
1672 << "to index = " << explanationVector
.size() << std::endl
;
1673 explanationVector
.push_back((*find
).second
);
1678 if (!CDProof::isSame(toExplain
.d_node
, (*find
).second
.d_node
))
1680 Trace("te-proof-exp")
1681 << "- t-explained cached: " << toExplain
.d_node
<< " by "
1682 << (*find
).second
.d_node
<< std::endl
;
1683 // delay explanation, use a dummy trust node that says that
1684 // (*find).second.d_node explains toExplain.d_node.
1685 TrustNode tnRewExp
= TrustNode::mkTrustPropExp(
1686 toExplain
.d_node
, (*find
).second
.d_node
, nullptr);
1687 texplains
.push_back(
1688 std::pair
<TheoryId
, TrustNode
>(THEORY_LAST
, tnRewExp
));
1694 // It was produced by the theory, so ask for an explanation
1695 TrustNode texplanation
=
1696 d_sharedSolver
->explain(toExplain
.d_node
, toExplain
.d_theory
);
1699 texplanation
.debugCheckClosed("te-proof-exp", "texplanation", false);
1700 Trace("te-proof-exp")
1701 << "- t-explained[" << toExplain
.d_theory
<< "]: " << toExplain
.d_node
1702 << " by " << texplanation
.getNode() << std::endl
;
1703 // if not a trivial explanation
1704 if (!CDProof::isSame(texplanation
.getNode(), toExplain
.d_node
))
1706 // We add it to the list of theory explanations, to be processed at
1707 // the end of this method. We wait to explain here because it may
1708 // be that a later explanation may preempt the need for proving this
1709 // step. For instance, if the conclusion lit is later added as an
1710 // assumption in the final explanation. This avoids cyclic proofs.
1711 texplains
.push_back(
1712 std::pair
<TheoryId
, TrustNode
>(toExplain
.d_theory
, texplanation
));
1715 Node explanation
= texplanation
.getNode();
1717 Debug("theory::explain")
1718 << "TheoryEngine::explain(): got explanation " << explanation
1719 << " got from " << toExplain
.d_theory
<< endl
;
1720 Assert(explanation
!= toExplain
.d_node
)
1721 << "wasn't sent to you, so why are you explaining it trivially";
1722 // Mark the explanation
1723 NodeTheoryPair
newExplain(
1724 explanation
, toExplain
.d_theory
, toExplain
.d_timestamp
);
1725 explanationVector
.push_back(newExplain
);
1730 // make the explanation node
1732 if (exp
.size() == 0)
1734 // Normalize to true
1735 expNode
= NodeManager::currentNM()->mkConst
<bool>(true);
1737 else if (exp
.size() == 1)
1739 // All the same, or just one
1740 expNode
= *exp
.begin();
1744 NodeBuilder
<> conjunction(kind::AND
);
1745 std::set
<TNode
>::const_iterator it
= exp
.begin();
1746 std::set
<TNode
>::const_iterator it_end
= exp
.end();
1747 while (it
!= it_end
)
1752 expNode
= conjunction
;
1754 // if we are building a proof, go back through the explanations and
1758 if (Trace
.isOn("te-proof-exp"))
1760 Trace("te-proof-exp") << "Explanation is:" << std::endl
;
1763 Trace("te-proof-exp") << " " << e
<< std::endl
;
1765 Trace("te-proof-exp") << "=== Replay explanations..." << std::endl
;
1767 // Now, go back and add the necessary steps of theory explanations, i.e.
1768 // add those that prove things that aren't in the final explanation. We
1769 // iterate in reverse order so that most recent steps take priority. This
1770 // avoids cyclic proofs in the lazy proof we are building (lcp).
1771 for (std::vector
<std::pair
<TheoryId
, TrustNode
>>::reverse_iterator
1772 it
= texplains
.rbegin(),
1773 itEnd
= texplains
.rend();
1777 TrustNode trn
= it
->second
;
1778 Assert(trn
.getKind() == TrustNodeKind::PROP_EXP
);
1779 Node proven
= trn
.getProven();
1780 Assert(proven
.getKind() == kind::IMPLIES
);
1781 Node tConc
= proven
[1];
1782 Trace("te-proof-exp") << "- Process " << trn
<< std::endl
;
1783 if (exp
.find(tConc
) != exp
.end())
1785 // already added to proof
1786 Trace("te-proof-exp") << "...already added" << std::endl
;
1789 Node symTConc
= CDProof::getSymmFact(tConc
);
1790 if (!symTConc
.isNull())
1792 if (exp
.find(symTConc
) != exp
.end())
1794 // symmetric direction
1795 Trace("te-proof-exp") << "...already added (SYMM)" << std::endl
;
1799 // remember that we've explained this formula, to avoid cycles in lcp
1801 TheoryId ttid
= it
->first
;
1802 Node tExp
= proven
[0];
1803 if (ttid
== THEORY_LAST
)
1807 // dummy trust node, do AND expansion
1808 Assert(tConc
.getKind() == kind::AND
);
1809 // tConc[0] ... tConc[n]
1810 // ---------------------- AND_INTRO
1812 std::vector
<Node
> pfChildren
;
1813 pfChildren
.insert(pfChildren
.end(), tConc
.begin(), tConc
.end());
1814 lcp
->addStep(tConc
, PfRule::AND_INTRO
, pfChildren
, {});
1815 Trace("te-proof-exp") << "...via AND_INTRO" << std::endl
;
1818 // otherwise should hold by rewriting
1819 Assert(Rewriter::rewrite(tConc
) == Rewriter::rewrite(tExp
));
1821 // ---- MACRO_SR_PRED_TRANSFORM
1823 lcp
->addStep(tConc
, PfRule::MACRO_SR_PRED_TRANSFORM
, {tExp
}, {tConc
});
1824 Trace("te-proof-exp") << "...via MACRO_SR_PRED_TRANSFORM" << std::endl
;
1830 Trace("te-proof-exp") << "...trivial" << std::endl
;
1833 // ------------- Via theory
1834 // tExp tExp => tConc
1835 // ---------------------------------MODUS_PONENS
1837 if (trn
.getGenerator() != nullptr)
1839 Trace("te-proof-exp") << "...via theory generator" << std::endl
;
1840 lcp
->addLazyStep(proven
, trn
.getGenerator());
1844 Trace("te-proof-exp") << "...via trust THEORY_LEMMA" << std::endl
;
1845 // otherwise, trusted theory lemma
1846 Node tidn
= builtin::BuiltinProofRuleChecker::mkTheoryIdNode(it
->first
);
1847 lcp
->addStep(proven
, PfRule::THEORY_LEMMA
, {}, {proven
, tidn
});
1849 std::vector
<Node
> pfChildren
;
1850 pfChildren
.push_back(trn
.getNode());
1851 pfChildren
.push_back(proven
);
1852 lcp
->addStep(tConc
, PfRule::MODUS_PONENS
, pfChildren
, {});
1854 // store in the proof generator
1855 TrustNode trn
= d_tepg
->mkTrustExplain(conclusion
, expNode
, lcp
);
1856 // return the trust node
1860 return theory::TrustNode::mkTrustLemma(expNode
, nullptr);
1863 bool TheoryEngine::isProofEnabled() const { return d_pnm
!= nullptr; }
1865 void TheoryEngine::setUserAttribute(const std::string
& attr
,
1867 const std::vector
<Node
>& node_values
,
1868 const std::string
& str_value
)
1870 Trace("te-attr") << "set user attribute " << attr
<< " " << n
<< endl
;
1871 if( d_attr_handle
.find( attr
)!=d_attr_handle
.end() ){
1872 for( size_t i
=0; i
<d_attr_handle
[attr
].size(); i
++ ){
1873 d_attr_handle
[attr
][i
]->setUserAttribute(attr
, n
, node_values
, str_value
);
1876 //unhandled exception?
1880 void TheoryEngine::handleUserAttribute(const char* attr
, Theory
* t
) {
1881 Trace("te-attr") << "Handle user attribute " << attr
<< " " << t
<< endl
;
1882 std::string
str( attr
);
1883 d_attr_handle
[ str
].push_back( t
);
1886 void TheoryEngine::checkTheoryAssertionsWithModel(bool hardFailure
) {
1887 for(TheoryId theoryId
= THEORY_FIRST
; theoryId
< THEORY_LAST
; ++theoryId
) {
1888 Theory
* theory
= d_theoryTable
[theoryId
];
1889 if(theory
&& d_logicInfo
.isTheoryEnabled(theoryId
)) {
1890 for(context::CDList
<Assertion
>::const_iterator it
= theory
->facts_begin(),
1891 it_end
= theory
->facts_end();
1894 Node assertion
= (*it
).d_assertion
;
1895 if (!isRelevant(assertion
))
1897 // not relevant, skip
1900 Node val
= d_tc
->getModel()->getValue(assertion
);
1903 std::stringstream ss
;
1904 ss
<< " " << theoryId
1905 << " has an asserted fact that the model doesn't satisfy." << endl
1906 << "The fact: " << assertion
<< endl
1907 << "Model value: " << val
<< endl
;
1912 // Always an error if it is false
1913 InternalError() << ss
.str();
1917 // Otherwise just a warning. Notice this case may happen for
1918 // assertions with unevaluable operators, e.g. transcendental
1919 // functions. It also may happen for separation logic, where
1920 // check-model support is limited.
1921 Warning() << ss
.str();
1930 std::pair
<bool, Node
> TheoryEngine::entailmentCheck(options::TheoryOfMode mode
,
1933 TNode atom
= (lit
.getKind() == kind::NOT
) ? lit
[0] : lit
;
1934 if( atom
.getKind()==kind::AND
|| atom
.getKind()==kind::OR
|| atom
.getKind()==kind::IMPLIES
){
1935 //Boolean connective, recurse
1936 std::vector
< Node
> children
;
1937 bool pol
= (lit
.getKind()!=kind::NOT
);
1938 bool is_conjunction
= pol
==(lit
.getKind()==kind::AND
);
1939 for( unsigned i
=0; i
<atom
.getNumChildren(); i
++ ){
1941 if( pol
==( lit
.getKind()==kind::IMPLIES
&& i
==0 ) ){
1942 ch
= atom
[i
].negate();
1944 std::pair
<bool, Node
> chres
= entailmentCheck(mode
, ch
);
1946 if( !is_conjunction
){
1949 children
.push_back( chres
.second
);
1951 }else if( !chres
.first
&& is_conjunction
){
1952 return std::pair
<bool, Node
>(false, Node::null());
1955 if( is_conjunction
){
1956 return std::pair
<bool, Node
>(true, NodeManager::currentNM()->mkNode(kind::AND
, children
));
1958 return std::pair
<bool, Node
>(false, Node::null());
1960 }else if( atom
.getKind()==kind::ITE
|| ( atom
.getKind()==kind::EQUAL
&& atom
[0].getType().isBoolean() ) ){
1961 bool pol
= (lit
.getKind()!=kind::NOT
);
1962 for( unsigned r
=0; r
<2; r
++ ){
1967 std::pair
<bool, Node
> chres
= entailmentCheck(mode
, ch
);
1969 Node ch2
= atom
[ atom
.getKind()==kind::ITE
? r
+1 : 1 ];
1970 if( pol
==( atom
.getKind()==kind::ITE
? true : r
==1 ) ){
1973 std::pair
<bool, Node
> chres2
= entailmentCheck(mode
, ch2
);
1975 return std::pair
<bool, Node
>(true, NodeManager::currentNM()->mkNode(kind::AND
, chres
.second
, chres2
.second
));
1981 return std::pair
<bool, Node
>(false, Node::null());
1983 //it is a theory atom
1984 theory::TheoryId tid
= theory::Theory::theoryOf(mode
, atom
);
1985 theory::Theory
* th
= theoryOf(tid
);
1988 Trace("theory-engine-entc") << "Entailment check : " << lit
<< std::endl
;
1990 std::pair
<bool, Node
> chres
= th
->entailmentCheck(lit
);
1995 void TheoryEngine::spendResource(ResourceManager::Resource r
)
1997 d_resourceManager
->spendResource(r
);
2000 }/* CVC4 namespace */