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 "theory/theory_engine.h" |
21 |
|
#include "theory/theory_model.h" |
22 |
|
|
23 |
|
namespace cvc5 { |
24 |
|
namespace preprocessing { |
25 |
|
|
26 |
9853 |
PreprocessingPassContext::PreprocessingPassContext( |
27 |
|
SmtEngine* smt, |
28 |
|
Env& env, |
29 |
9853 |
theory::booleans::CircuitPropagator* circuitPropagator) |
30 |
|
: d_smt(smt), |
31 |
|
d_env(env), |
32 |
|
d_circuitPropagator(circuitPropagator), |
33 |
|
d_llm(env.getTopLevelSubstitutions(), |
34 |
|
env.getUserContext(), |
35 |
|
env.getProofNodeManager()), |
36 |
9853 |
d_symsInAssertions(env.getUserContext()) |
37 |
|
{ |
38 |
9853 |
} |
39 |
|
|
40 |
|
theory::TrustSubstitutionMap& |
41 |
38057 |
PreprocessingPassContext::getTopLevelSubstitutions() |
42 |
|
{ |
43 |
38057 |
return d_env.getTopLevelSubstitutions(); |
44 |
|
} |
45 |
|
|
46 |
155573 |
context::Context* PreprocessingPassContext::getUserContext() |
47 |
|
{ |
48 |
155573 |
return d_env.getUserContext(); |
49 |
|
} |
50 |
19706 |
context::Context* PreprocessingPassContext::getDecisionContext() |
51 |
|
{ |
52 |
19706 |
return d_env.getContext(); |
53 |
|
} |
54 |
249724 |
void PreprocessingPassContext::spendResource(Resource r) |
55 |
|
{ |
56 |
249724 |
d_env.getResourceManager()->spendResource(r); |
57 |
249724 |
} |
58 |
6147 |
void PreprocessingPassContext::recordSymbolsInAssertions( |
59 |
|
const std::vector<Node>& assertions) |
60 |
|
{ |
61 |
12294 |
std::unordered_set<TNode> visited; |
62 |
12294 |
std::unordered_set<Node> syms; |
63 |
31501 |
for (TNode cn : assertions) |
64 |
|
{ |
65 |
25354 |
expr::getSymbols(cn, syms, visited); |
66 |
|
} |
67 |
40288 |
for (const Node& s : syms) |
68 |
|
{ |
69 |
34141 |
d_symsInAssertions.insert(s); |
70 |
|
} |
71 |
6147 |
} |
72 |
|
|
73 |
59790 |
void PreprocessingPassContext::notifyLearnedLiteral(TNode lit) |
74 |
|
{ |
75 |
59790 |
d_llm.notifyLearnedLiteral(lit); |
76 |
59790 |
} |
77 |
|
|
78 |
2 |
std::vector<Node> PreprocessingPassContext::getLearnedLiterals() |
79 |
|
{ |
80 |
2 |
return d_llm.getLearnedLiterals(); |
81 |
|
} |
82 |
|
|
83 |
455 |
void PreprocessingPassContext::addSubstitution(const Node& lhs, |
84 |
|
const Node& rhs, |
85 |
|
ProofGenerator* pg) |
86 |
|
{ |
87 |
455 |
getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg); |
88 |
455 |
} |
89 |
|
|
90 |
|
void PreprocessingPassContext::addSubstitution(const Node& lhs, |
91 |
|
const Node& rhs, |
92 |
|
PfRule id, |
93 |
|
const std::vector<Node>& args) |
94 |
|
{ |
95 |
|
getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args); |
96 |
|
} |
97 |
|
|
98 |
9853 |
ProofNodeManager* PreprocessingPassContext::getProofNodeManager() |
99 |
|
{ |
100 |
9853 |
return d_env.getProofNodeManager(); |
101 |
|
} |
102 |
|
|
103 |
|
} // namespace preprocessing |
104 |
29340 |
} // namespace cvc5 |