1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Kshitij Bansal, Aina Niemetz, Andrew Reynolds |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 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. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Old implementation of the decision engine |
14 |
|
*/ |
15 |
|
#include "decision/decision_engine_old.h" |
16 |
|
|
17 |
|
#include "decision/decision_attributes.h" |
18 |
|
#include "decision/justification_heuristic.h" |
19 |
|
#include "expr/node.h" |
20 |
|
#include "options/decision_options.h" |
21 |
|
#include "options/smt_options.h" |
22 |
|
#include "util/resource_manager.h" |
23 |
|
|
24 |
|
using namespace std; |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
|
28 |
2 |
DecisionEngineOld::DecisionEngineOld(context::Context* sc, |
29 |
|
context::UserContext* uc, |
30 |
2 |
ResourceManager* rm) |
31 |
|
: DecisionEngine(sc, rm), |
32 |
|
d_result(sc, SAT_VALUE_UNKNOWN), |
33 |
|
d_engineState(0), |
34 |
|
d_enabledITEStrategy(nullptr), |
35 |
35216 |
d_decisionStopOnly(options::decisionMode() |
36 |
4 |
== options::DecisionMode::STOPONLY_OLD) |
37 |
|
{ |
38 |
2 |
Trace("decision") << "Creating decision engine" << std::endl; |
39 |
2 |
Assert(d_engineState == 0); |
40 |
2 |
d_engineState = 1; |
41 |
|
|
42 |
2 |
Trace("decision-init") << "DecisionEngineOld::init()" << std::endl; |
43 |
4 |
Trace("decision-init") << " * options->decisionMode: " |
44 |
2 |
<< options::decisionMode() << std::endl; |
45 |
4 |
Trace("decision-init") << " * decisionStopOnly: " << d_decisionStopOnly |
46 |
2 |
<< std::endl; |
47 |
|
|
48 |
2 |
if (options::decisionMode() == options::DecisionMode::JUSTIFICATION) |
49 |
|
{ |
50 |
|
d_enabledITEStrategy.reset( |
51 |
|
new decision::JustificationHeuristic(this, uc, sc)); |
52 |
|
} |
53 |
2 |
} |
54 |
|
|
55 |
|
void DecisionEngineOld::shutdown() |
56 |
|
{ |
57 |
|
Trace("decision") << "Shutting down decision engine" << std::endl; |
58 |
|
|
59 |
|
Assert(d_engineState == 1); |
60 |
|
d_engineState = 2; |
61 |
|
d_enabledITEStrategy.reset(nullptr); |
62 |
|
} |
63 |
|
|
64 |
16612 |
SatLiteral DecisionEngineOld::getNextInternal(bool& stopSearch) |
65 |
|
{ |
66 |
16612 |
Assert(d_cnfStream != nullptr) |
67 |
|
<< "Forgot to set cnfStream for decision engine?"; |
68 |
16612 |
Assert(d_satSolver != nullptr) |
69 |
|
<< "Forgot to set satSolver for decision engine?"; |
70 |
|
|
71 |
16612 |
SatLiteral ret = d_enabledITEStrategy == nullptr |
72 |
|
? undefSatLiteral |
73 |
16612 |
: d_enabledITEStrategy->getNext(stopSearch); |
74 |
|
// if we are doing stop only, we don't return the literal |
75 |
16612 |
return d_decisionStopOnly ? undefSatLiteral : ret; |
76 |
|
} |
77 |
|
|
78 |
736 |
void DecisionEngineOld::addAssertion(TNode assertion) |
79 |
|
{ |
80 |
|
// new assertions, reset whatever result we knew |
81 |
736 |
d_result = SAT_VALUE_UNKNOWN; |
82 |
736 |
if (d_enabledITEStrategy != nullptr) |
83 |
|
{ |
84 |
|
d_enabledITEStrategy->addAssertion(assertion); |
85 |
|
} |
86 |
736 |
} |
87 |
|
|
88 |
|
void DecisionEngineOld::addSkolemDefinition(TNode lem, TNode skolem) |
89 |
|
{ |
90 |
|
// new assertions, reset whatever result we knew |
91 |
|
d_result = SAT_VALUE_UNKNOWN; |
92 |
|
if (d_enabledITEStrategy != nullptr) |
93 |
|
{ |
94 |
|
d_enabledITEStrategy->addSkolemDefinition(lem, skolem); |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
342635513 |
} // namespace cvc5 |