1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Andrew Reynolds, Andres Noetzli |
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 |
|
* Apply substitutions preprocessing pass. |
14 |
|
* |
15 |
|
* Apply top level substitutions to assertions, rewrite, and store back into |
16 |
|
* assertions. |
17 |
|
*/ |
18 |
|
|
19 |
|
#include "preprocessing/passes/apply_substs.h" |
20 |
|
|
21 |
|
#include "context/cdo.h" |
22 |
|
#include "preprocessing/assertion_pipeline.h" |
23 |
|
#include "preprocessing/preprocessing_pass_context.h" |
24 |
|
#include "theory/rewriter.h" |
25 |
|
#include "theory/substitutions.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
namespace preprocessing { |
29 |
|
namespace passes { |
30 |
|
|
31 |
6278 |
ApplySubsts::ApplySubsts(PreprocessingPassContext* preprocContext) |
32 |
6278 |
: PreprocessingPass(preprocContext, "apply-substs") |
33 |
|
{ |
34 |
6278 |
} |
35 |
|
|
36 |
17100 |
PreprocessingPassResult ApplySubsts::applyInternal( |
37 |
|
AssertionPipeline* assertionsToPreprocess) |
38 |
|
{ |
39 |
17100 |
Chat() << "applying substitutions..." << std::endl; |
40 |
34200 |
Trace("apply-substs") << "SmtEnginePrivate::processAssertions(): " |
41 |
17100 |
<< "applying substitutions" << std::endl; |
42 |
|
// TODO(#1255): Substitutions in incremental mode should be managed with a |
43 |
|
// proper data structure. |
44 |
|
|
45 |
|
theory::TrustSubstitutionMap& tlsm = |
46 |
17100 |
d_preprocContext->getTopLevelSubstitutions(); |
47 |
17100 |
unsigned size = assertionsToPreprocess->size(); |
48 |
148785 |
for (unsigned i = 0; i < size; ++i) |
49 |
|
{ |
50 |
131687 |
if (assertionsToPreprocess->isSubstsIndex(i)) |
51 |
|
{ |
52 |
4888 |
continue; |
53 |
|
} |
54 |
253598 |
Trace("apply-substs") << "applying to " << (*assertionsToPreprocess)[i] |
55 |
126799 |
<< std::endl; |
56 |
126799 |
d_preprocContext->spendResource(Resource::PreprocessStep); |
57 |
126797 |
assertionsToPreprocess->replaceTrusted( |
58 |
253596 |
i, tlsm.applyTrusted((*assertionsToPreprocess)[i])); |
59 |
253594 |
Trace("apply-substs") << " got " << (*assertionsToPreprocess)[i] |
60 |
126797 |
<< std::endl; |
61 |
|
} |
62 |
17098 |
return PreprocessingPassResult::NO_CONFLICT; |
63 |
|
} |
64 |
|
|
65 |
|
} // namespace passes |
66 |
|
} // namespace preprocessing |
67 |
22755 |
} // namespace cvc5 |