1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/********************* */
/*! \file decision_engine.cpp
** \verbatim
** Top contributors (to current version):
** Kshitij Bansal, Aina Niemetz, Andres Noetzli
** This file is part of the CVC4 project.
** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
** in the top-level source directory and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief Decision engine
**
** Decision engine
**/
#include "decision/decision_engine.h"
#include "decision/decision_attributes.h"
#include "decision/justification_heuristic.h"
#include "expr/node.h"
#include "options/decision_options.h"
#include "options/smt_options.h"
#include "util/resource_manager.h"
using namespace std;
namespace CVC4 {
DecisionEngine::DecisionEngine(context::Context* sc,
context::UserContext* uc,
ResourceManager* rm)
: d_cnfStream(nullptr),
d_satSolver(nullptr),
d_satContext(sc),
d_userContext(uc),
d_result(sc, SAT_VALUE_UNKNOWN),
d_engineState(0),
d_resourceManager(rm),
d_enabledITEStrategy(nullptr)
{
Trace("decision") << "Creating decision engine" << std::endl;
}
void DecisionEngine::init()
{
Assert(d_engineState == 0);
d_engineState = 1;
Trace("decision-init") << "DecisionEngine::init()" << std::endl;
Trace("decision-init") << " * options->decisionMode: "
<< options::decisionMode() << std:: endl;
Trace("decision-init") << " * options->decisionStopOnly: "
<< options::decisionStopOnly() << std::endl;
if (options::decisionMode() == options::DecisionMode::JUSTIFICATION)
{
d_enabledITEStrategy.reset(new decision::JustificationHeuristic(
this, d_userContext, d_satContext));
}
}
void DecisionEngine::shutdown()
{
Trace("decision") << "Shutting down decision engine" << std::endl;
Assert(d_engineState == 1);
d_engineState = 2;
d_enabledITEStrategy.reset(nullptr);
}
SatLiteral DecisionEngine::getNext(bool& stopSearch)
{
d_resourceManager->spendResource(ResourceManager::Resource::DecisionStep);
Assert(d_cnfStream != nullptr)
<< "Forgot to set cnfStream for decision engine?";
Assert(d_satSolver != nullptr)
<< "Forgot to set satSolver for decision engine?";
return d_enabledITEStrategy == nullptr
? undefSatLiteral
: d_enabledITEStrategy->getNext(stopSearch);
}
void DecisionEngine::addAssertion(TNode assertion)
{
// new assertions, reset whatever result we knew
d_result = SAT_VALUE_UNKNOWN;
if (d_enabledITEStrategy != nullptr)
{
d_enabledITEStrategy->addAssertion(assertion);
}
}
void DecisionEngine::addSkolemDefinition(TNode lem, TNode skolem)
{
// new assertions, reset whatever result we knew
d_result = SAT_VALUE_UNKNOWN;
if (d_enabledITEStrategy != nullptr)
{
d_enabledITEStrategy->addSkolemDefinition(lem, skolem);
}
}
}/* CVC4 namespace */
|