1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Gereon Kremer, Aina Niemetz |
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 |
|
* Smt Environment, main access to global utilities available to |
14 |
|
* internal code. |
15 |
|
*/ |
16 |
|
|
17 |
|
#include "smt/env.h" |
18 |
|
|
19 |
|
#include "context/context.h" |
20 |
|
#include "expr/node.h" |
21 |
|
#include "options/base_options.h" |
22 |
|
#include "options/smt_options.h" |
23 |
|
#include "printer/printer.h" |
24 |
|
#include "proof/conv_proof_generator.h" |
25 |
|
#include "smt/dump_manager.h" |
26 |
|
#include "smt/smt_engine_stats.h" |
27 |
|
#include "theory/rewriter.h" |
28 |
|
#include "theory/trust_substitutions.h" |
29 |
|
#include "util/resource_manager.h" |
30 |
|
#include "util/statistics_registry.h" |
31 |
|
|
32 |
|
using namespace cvc5::smt; |
33 |
|
|
34 |
|
namespace cvc5 { |
35 |
|
|
36 |
13221 |
Env::Env(NodeManager* nm, const Options* opts) |
37 |
13221 |
: d_context(new context::Context()), |
38 |
13221 |
d_userContext(new context::UserContext()), |
39 |
|
d_nodeManager(nm), |
40 |
|
d_proofNodeManager(nullptr), |
41 |
13221 |
d_rewriter(new theory::Rewriter()), |
42 |
26442 |
d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())), |
43 |
13221 |
d_dumpManager(new DumpManager(d_userContext.get())), |
44 |
|
d_logic(), |
45 |
|
d_statisticsRegistry(std::make_unique<StatisticsRegistry>(*this)), |
46 |
|
d_options(), |
47 |
|
d_originalOptions(opts), |
48 |
92547 |
d_resourceManager() |
49 |
|
{ |
50 |
13221 |
if (opts != nullptr) |
51 |
|
{ |
52 |
12335 |
d_options.copyValues(*opts); |
53 |
|
} |
54 |
13221 |
d_statisticsRegistry->registerTimer("global::totalTime").start(); |
55 |
13221 |
d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options); |
56 |
13221 |
} |
57 |
|
|
58 |
10574 |
Env::~Env() {} |
59 |
|
|
60 |
3794 |
void Env::setProofNodeManager(ProofNodeManager* pnm) |
61 |
|
{ |
62 |
3794 |
Assert(pnm != nullptr); |
63 |
3794 |
Assert(d_proofNodeManager == nullptr); |
64 |
3794 |
d_proofNodeManager = pnm; |
65 |
3794 |
d_rewriter->setProofNodeManager(pnm); |
66 |
3794 |
d_topLevelSubs->setProofNodeManager(pnm); |
67 |
3794 |
} |
68 |
|
|
69 |
10560 |
void Env::shutdown() |
70 |
|
{ |
71 |
10560 |
d_rewriter.reset(nullptr); |
72 |
10560 |
d_dumpManager.reset(nullptr); |
73 |
|
// d_resourceManager must be destroyed before d_statisticsRegistry |
74 |
10560 |
d_resourceManager.reset(nullptr); |
75 |
10560 |
} |
76 |
|
|
77 |
1023555 |
context::UserContext* Env::getUserContext() { return d_userContext.get(); } |
78 |
|
|
79 |
36517251 |
context::Context* Env::getContext() { return d_context.get(); } |
80 |
|
|
81 |
1464138 |
NodeManager* Env::getNodeManager() const { return d_nodeManager; } |
82 |
|
|
83 |
92459 |
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; } |
84 |
|
|
85 |
133414 |
bool Env::isSatProofProducing() const |
86 |
|
{ |
87 |
133414 |
return d_proofNodeManager != nullptr |
88 |
156030 |
&& (!d_options.smt.unsatCores |
89 |
54309 |
|| (d_options.smt.unsatCoresMode |
90 |
|
!= options::UnsatCoresMode::ASSUMPTIONS |
91 |
22620 |
&& d_options.smt.unsatCoresMode |
92 |
133414 |
!= options::UnsatCoresMode::PP_ONLY)); |
93 |
|
} |
94 |
|
|
95 |
175169 |
bool Env::isTheoryProofProducing() const |
96 |
|
{ |
97 |
175169 |
return d_proofNodeManager != nullptr |
98 |
196779 |
&& (!d_options.smt.unsatCores |
99 |
65995 |
|| d_options.smt.unsatCoresMode |
100 |
175169 |
== options::UnsatCoresMode::FULL_PROOF); |
101 |
|
} |
102 |
|
|
103 |
37066029 |
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); } |
104 |
|
|
105 |
359851 |
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions() |
106 |
|
{ |
107 |
359851 |
return *d_topLevelSubs.get(); |
108 |
|
} |
109 |
|
|
110 |
25513 |
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); } |
111 |
|
|
112 |
5920732 |
const LogicInfo& Env::getLogicInfo() const { return d_logic; } |
113 |
|
|
114 |
3995548 |
StatisticsRegistry& Env::getStatisticsRegistry() |
115 |
|
{ |
116 |
3995548 |
return *d_statisticsRegistry; |
117 |
|
} |
118 |
|
|
119 |
35676173 |
const Options& Env::getOptions() const { return d_options; } |
120 |
|
|
121 |
|
const Options& Env::getOriginalOptions() const { return *d_originalOptions; } |
122 |
|
|
123 |
16775849 |
ResourceManager* Env::getResourceManager() const |
124 |
|
{ |
125 |
16775849 |
return d_resourceManager.get(); |
126 |
|
} |
127 |
|
|
128 |
27 |
const Printer& Env::getPrinter() |
129 |
|
{ |
130 |
27 |
return *Printer::getPrinter(d_options.base.outputLanguage); |
131 |
|
} |
132 |
|
|
133 |
27 |
std::ostream& Env::getDumpOut() { return *d_options.base.out; } |
134 |
|
|
135 |
29574 |
} // namespace cvc5 |