1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Yoni Zohar, Gereon Kremer, Andrew Reynolds |
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 static learning preprocessing pass. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "preprocessing/passes/static_learning.h" |
17 |
|
|
18 |
|
#include <string> |
19 |
|
|
20 |
|
#include "expr/node.h" |
21 |
|
#include "preprocessing/assertion_pipeline.h" |
22 |
|
#include "preprocessing/preprocessing_pass_context.h" |
23 |
|
#include "theory/rewriter.h" |
24 |
|
#include "theory/theory_engine.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
namespace preprocessing { |
28 |
|
namespace passes { |
29 |
|
|
30 |
9942 |
StaticLearning::StaticLearning(PreprocessingPassContext* preprocContext) |
31 |
9942 |
: PreprocessingPass(preprocContext, "static-learning"){}; |
32 |
|
|
33 |
13799 |
PreprocessingPassResult StaticLearning::applyInternal( |
34 |
|
AssertionPipeline* assertionsToPreprocess) |
35 |
|
{ |
36 |
13799 |
d_preprocContext->spendResource(Resource::PreprocessStep); |
37 |
|
|
38 |
119261 |
for (unsigned i = 0; i < assertionsToPreprocess->size(); ++i) |
39 |
|
{ |
40 |
210924 |
NodeBuilder learned(kind::AND); |
41 |
105462 |
learned << (*assertionsToPreprocess)[i]; |
42 |
210924 |
d_preprocContext->getTheoryEngine()->ppStaticLearn( |
43 |
105462 |
(*assertionsToPreprocess)[i], learned); |
44 |
105462 |
if (learned.getNumChildren() == 1) |
45 |
|
{ |
46 |
105093 |
learned.clear(); |
47 |
|
} |
48 |
|
else |
49 |
|
{ |
50 |
369 |
assertionsToPreprocess->replace(i, rewrite(learned.constructNode())); |
51 |
|
} |
52 |
|
} |
53 |
13799 |
return PreprocessingPassResult::NO_CONFLICT; |
54 |
|
} |
55 |
|
|
56 |
|
|
57 |
|
} // namespace passes |
58 |
|
} // namespace preprocessing |
59 |
29577 |
} // namespace cvc5 |