1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Andres Noetzli, 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 |
|
* Remove ITEs from the assertions. |
14 |
|
* |
15 |
|
* [[ Add lengthier description here ]] |
16 |
|
* \todo document this file |
17 |
|
*/ |
18 |
|
|
19 |
|
#include "preprocessing/passes/ite_removal.h" |
20 |
|
|
21 |
|
#include "options/smt_options.h" |
22 |
|
#include "preprocessing/assertion_pipeline.h" |
23 |
|
#include "preprocessing/preprocessing_pass_context.h" |
24 |
|
#include "prop/prop_engine.h" |
25 |
|
#include "theory/rewriter.h" |
26 |
|
#include "theory/theory_preprocessor.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace preprocessing { |
30 |
|
namespace passes { |
31 |
|
|
32 |
|
using namespace cvc5::theory; |
33 |
|
|
34 |
|
// TODO (project #42): note this preprocessing pass is deprecated |
35 |
9942 |
IteRemoval::IteRemoval(PreprocessingPassContext* preprocContext) |
36 |
9942 |
: PreprocessingPass(preprocContext, "ite-removal") |
37 |
|
{ |
38 |
9942 |
} |
39 |
|
|
40 |
1 |
PreprocessingPassResult IteRemoval::applyInternal(AssertionPipeline* assertions) |
41 |
|
{ |
42 |
1 |
d_preprocContext->spendResource(Resource::PreprocessStep); |
43 |
|
|
44 |
1 |
IteSkolemMap& imap = assertions->getIteSkolemMap(); |
45 |
|
// Remove all of the ITE occurrences and normalize |
46 |
1 |
prop::PropEngine* pe = d_preprocContext->getPropEngine(); |
47 |
3 |
for (unsigned i = 0, size = assertions->size(); i < size; ++i) |
48 |
|
{ |
49 |
4 |
Node assertion = (*assertions)[i]; |
50 |
4 |
std::vector<TrustNode> newAsserts; |
51 |
4 |
std::vector<Node> newSkolems; |
52 |
4 |
TrustNode trn = pe->removeItes(assertion, newAsserts, newSkolems); |
53 |
2 |
if (!trn.isNull()) |
54 |
|
{ |
55 |
|
// process |
56 |
1 |
assertions->replaceTrusted(i, trn); |
57 |
|
} |
58 |
2 |
Assert(newSkolems.size() == newAsserts.size()); |
59 |
326 |
for (unsigned j = 0, nnasserts = newAsserts.size(); j < nnasserts; j++) |
60 |
|
{ |
61 |
324 |
imap[assertions->size()] = newSkolems[j]; |
62 |
324 |
assertions->pushBackTrusted(newAsserts[j]); |
63 |
|
} |
64 |
|
} |
65 |
327 |
for (unsigned i = 0, size = assertions->size(); i < size; ++i) |
66 |
|
{ |
67 |
326 |
assertions->replace(i, rewrite((*assertions)[i])); |
68 |
|
} |
69 |
|
|
70 |
1 |
return PreprocessingPassResult::NO_CONFLICT; |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
} // namespace passes |
75 |
|
} // namespace preprocessing |
76 |
29577 |
} // namespace cvc5 |