1 /******************************************************************************
2 * Top contributors (to current version):
3 * Kshitij Bansal, Aina Niemetz, Andrew Reynolds
5 * This file is part of the cvc5 project.
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 * ****************************************************************************
13 * Old implementation of the decision engine
15 #include "decision/decision_engine_old.h"
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"
28 DecisionEngineOld::DecisionEngineOld(context::Context
* sc
,
29 context::UserContext
* uc
,
31 : DecisionEngine(sc
, rm
),
32 d_result(sc
, SAT_VALUE_UNKNOWN
),
34 d_enabledITEStrategy(nullptr),
35 d_decisionStopOnly(options::decisionMode()
36 == options::DecisionMode::STOPONLY_OLD
)
38 Trace("decision") << "Creating decision engine" << std::endl
;
39 Assert(d_engineState
== 0);
42 Trace("decision-init") << "DecisionEngineOld::init()" << std::endl
;
43 Trace("decision-init") << " * options->decisionMode: "
44 << options::decisionMode() << std::endl
;
45 Trace("decision-init") << " * decisionStopOnly: " << d_decisionStopOnly
48 if (options::decisionMode() == options::DecisionMode::JUSTIFICATION
)
50 d_enabledITEStrategy
.reset(
51 new decision::JustificationHeuristic(this, uc
, sc
));
55 void DecisionEngineOld::shutdown()
57 Trace("decision") << "Shutting down decision engine" << std::endl
;
59 Assert(d_engineState
== 1);
61 d_enabledITEStrategy
.reset(nullptr);
64 SatLiteral
DecisionEngineOld::getNextInternal(bool& stopSearch
)
66 Assert(d_cnfStream
!= nullptr)
67 << "Forgot to set cnfStream for decision engine?";
68 Assert(d_satSolver
!= nullptr)
69 << "Forgot to set satSolver for decision engine?";
71 SatLiteral ret
= d_enabledITEStrategy
== nullptr
73 : d_enabledITEStrategy
->getNext(stopSearch
);
74 // if we are doing stop only, we don't return the literal
75 return d_decisionStopOnly
? undefSatLiteral
: ret
;
78 void DecisionEngineOld::addAssertion(TNode assertion
)
80 // new assertions, reset whatever result we knew
81 d_result
= SAT_VALUE_UNKNOWN
;
82 if (d_enabledITEStrategy
!= nullptr)
84 d_enabledITEStrategy
->addAssertion(assertion
);
88 void DecisionEngineOld::addSkolemDefinition(TNode lem
, TNode skolem
)
90 // new assertions, reset whatever result we knew
91 d_result
= SAT_VALUE_UNKNOWN
;
92 if (d_enabledITEStrategy
!= nullptr)
94 d_enabledITEStrategy
->addSkolemDefinition(lem
, skolem
);