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 |
8954 |
PreprocessingPassContext::PreprocessingPassContext( |
27 |
|
SmtEngine* smt, |
28 |
|
Env& env, |
29 |
8954 |
theory::booleans::CircuitPropagator* circuitPropagator) |
30 |
|
: d_smt(smt), |
31 |
|
d_env(env), |
32 |
|
d_circuitPropagator(circuitPropagator), |
33 |
8954 |
d_symsInAssertions(env.getUserContext()) |
34 |
|
{ |
35 |
8954 |
} |
36 |
|
|
37 |
|
theory::TrustSubstitutionMap& |
38 |
33031 |
PreprocessingPassContext::getTopLevelSubstitutions() |
39 |
|
{ |
40 |
33031 |
return d_env.getTopLevelSubstitutions(); |
41 |
|
} |
42 |
|
|
43 |
140964 |
context::Context* PreprocessingPassContext::getUserContext() |
44 |
|
{ |
45 |
140964 |
return d_env.getUserContext(); |
46 |
|
} |
47 |
17908 |
context::Context* PreprocessingPassContext::getDecisionContext() |
48 |
|
{ |
49 |
17908 |
return d_env.getContext(); |
50 |
|
} |
51 |
234030 |
void PreprocessingPassContext::spendResource(Resource r) |
52 |
|
{ |
53 |
234030 |
d_env.getResourceManager()->spendResource(r); |
54 |
234030 |
} |
55 |
4377 |
void PreprocessingPassContext::recordSymbolsInAssertions( |
56 |
|
const std::vector<Node>& assertions) |
57 |
|
{ |
58 |
8754 |
std::unordered_set<TNode> visited; |
59 |
8754 |
std::unordered_set<Node> syms; |
60 |
22797 |
for (TNode cn : assertions) |
61 |
|
{ |
62 |
18420 |
expr::getSymbols(cn, syms, visited); |
63 |
|
} |
64 |
32010 |
for (const Node& s : syms) |
65 |
|
{ |
66 |
27633 |
d_symsInAssertions.insert(s); |
67 |
|
} |
68 |
4377 |
} |
69 |
|
|
70 |
369 |
void PreprocessingPassContext::addSubstitution(const Node& lhs, |
71 |
|
const Node& rhs, |
72 |
|
ProofGenerator* pg) |
73 |
|
{ |
74 |
369 |
getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg); |
75 |
369 |
} |
76 |
|
|
77 |
|
void PreprocessingPassContext::addSubstitution(const Node& lhs, |
78 |
|
const Node& rhs, |
79 |
|
PfRule id, |
80 |
|
const std::vector<Node>& args) |
81 |
|
{ |
82 |
|
getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args); |
83 |
|
} |
84 |
|
|
85 |
8954 |
ProofNodeManager* PreprocessingPassContext::getProofNodeManager() |
86 |
|
{ |
87 |
8954 |
return d_env.getProofNodeManager(); |
88 |
|
} |
89 |
|
|
90 |
|
} // namespace preprocessing |
91 |
27735 |
} // namespace cvc5 |