1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Andrew Reynolds, Mathias Preiner |
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 |
|
* The preprocessing pass context for passes. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "preprocessing/preprocessing_pass_context.h" |
17 |
|
|
18 |
|
#include "expr/node_algorithm.h" |
19 |
|
#include "smt/env.h" |
20 |
|
#include "smt/smt_engine.h" |
21 |
|
#include "theory/theory_engine.h" |
22 |
|
#include "theory/theory_model.h" |
23 |
|
|
24 |
|
namespace cvc5 { |
25 |
|
namespace preprocessing { |
26 |
|
|
27 |
9987 |
PreprocessingPassContext::PreprocessingPassContext( |
28 |
|
SmtEngine* smt, |
29 |
|
Env& env, |
30 |
9987 |
theory::booleans::CircuitPropagator* circuitPropagator) |
31 |
|
: EnvObj(env), |
32 |
|
d_smt(smt), |
33 |
|
d_circuitPropagator(circuitPropagator), |
34 |
|
d_llm( |
35 |
|
env.getTopLevelSubstitutions(), userContext(), getProofNodeManager()), |
36 |
9987 |
d_symsInAssertions(userContext()) |
37 |
|
{ |
38 |
9987 |
} |
39 |
|
|
40 |
|
theory::TrustSubstitutionMap& |
41 |
38111 |
PreprocessingPassContext::getTopLevelSubstitutions() const |
42 |
|
{ |
43 |
38111 |
return d_env.getTopLevelSubstitutions(); |
44 |
|
} |
45 |
|
|
46 |
324973 |
TheoryEngine* PreprocessingPassContext::getTheoryEngine() const |
47 |
|
{ |
48 |
324973 |
return d_smt->getTheoryEngine(); |
49 |
|
} |
50 |
13779 |
prop::PropEngine* PreprocessingPassContext::getPropEngine() const |
51 |
|
{ |
52 |
13779 |
return d_smt->getPropEngine(); |
53 |
|
} |
54 |
|
|
55 |
249775 |
void PreprocessingPassContext::spendResource(Resource r) |
56 |
|
{ |
57 |
249775 |
d_env.getResourceManager()->spendResource(r); |
58 |
249775 |
} |
59 |
6155 |
void PreprocessingPassContext::recordSymbolsInAssertions( |
60 |
|
const std::vector<Node>& assertions) |
61 |
|
{ |
62 |
12310 |
std::unordered_set<TNode> visited; |
63 |
12310 |
std::unordered_set<Node> syms; |
64 |
31523 |
for (TNode cn : assertions) |
65 |
|
{ |
66 |
25368 |
expr::getSymbols(cn, syms, visited); |
67 |
|
} |
68 |
40108 |
for (const Node& s : syms) |
69 |
|
{ |
70 |
33953 |
d_symsInAssertions.insert(s); |
71 |
|
} |
72 |
6155 |
} |
73 |
|
|
74 |
59951 |
void PreprocessingPassContext::notifyLearnedLiteral(TNode lit) |
75 |
|
{ |
76 |
59951 |
d_llm.notifyLearnedLiteral(lit); |
77 |
59951 |
} |
78 |
|
|
79 |
2 |
std::vector<Node> PreprocessingPassContext::getLearnedLiterals() const |
80 |
|
{ |
81 |
2 |
return d_llm.getLearnedLiterals(); |
82 |
|
} |
83 |
|
|
84 |
450 |
void PreprocessingPassContext::addSubstitution(const Node& lhs, |
85 |
|
const Node& rhs, |
86 |
|
ProofGenerator* pg) |
87 |
|
{ |
88 |
450 |
getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg); |
89 |
450 |
} |
90 |
|
|
91 |
|
void PreprocessingPassContext::addSubstitution(const Node& lhs, |
92 |
|
const Node& rhs, |
93 |
|
PfRule id, |
94 |
|
const std::vector<Node>& args) |
95 |
|
{ |
96 |
|
getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args); |
97 |
|
} |
98 |
|
|
99 |
19900 |
ProofNodeManager* PreprocessingPassContext::getProofNodeManager() const |
100 |
|
{ |
101 |
19900 |
return d_env.getProofNodeManager(); |
102 |
|
} |
103 |
|
|
104 |
|
} // namespace preprocessing |
105 |
29502 |
} // namespace cvc5 |