1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mathias Preiner, Andrew Reynolds, Aina Niemetz |
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 BvAbstraction preprocessing pass. |
14 |
|
* |
15 |
|
* Abstract common structures over small domains to UF. This preprocessing |
16 |
|
* is particularly useful on QF_BV/mcm benchmarks and can be enabled via |
17 |
|
* option `--bv-abstraction`. |
18 |
|
* For more information see 3.4 Refactoring Isomorphic Circuits in [1]. |
19 |
|
* |
20 |
|
* [1] Liana Hadarean, An Efficient and Trustworthy Theory Solver for |
21 |
|
* Bit-vectors in Satisfiability Modulo Theories |
22 |
|
* https://cs.nyu.edu/media/publications/hadarean_liana.pdf |
23 |
|
*/ |
24 |
|
|
25 |
|
#include "preprocessing/passes/bv_abstraction.h" |
26 |
|
|
27 |
|
#include <vector> |
28 |
|
|
29 |
|
#include "options/bv_options.h" |
30 |
|
#include "preprocessing/assertion_pipeline.h" |
31 |
|
#include "preprocessing/preprocessing_pass_context.h" |
32 |
|
#include "theory/bv/theory_bv.h" |
33 |
|
#include "theory/rewriter.h" |
34 |
|
#include "theory/theory_engine.h" |
35 |
|
|
36 |
|
namespace cvc5 { |
37 |
|
namespace preprocessing { |
38 |
|
namespace passes { |
39 |
|
|
40 |
|
using namespace cvc5::theory; |
41 |
|
|
42 |
9913 |
BvAbstraction::BvAbstraction(PreprocessingPassContext* preprocContext) |
43 |
9913 |
: PreprocessingPass(preprocContext, "bv-abstraction"){}; |
44 |
|
|
45 |
4 |
PreprocessingPassResult BvAbstraction::applyInternal( |
46 |
|
AssertionPipeline* assertionsToPreprocess) |
47 |
|
{ |
48 |
8 |
std::vector<Node> new_assertions; |
49 |
|
std::vector<Node> assertions(assertionsToPreprocess->begin(), |
50 |
8 |
assertionsToPreprocess->end()); |
51 |
4 |
TheoryEngine* te = d_preprocContext->getTheoryEngine(); |
52 |
4 |
bv::TheoryBV* bv_theory = static_cast<bv::TheoryBV*>(te->theoryOf(THEORY_BV)); |
53 |
4 |
bv_theory->applyAbstraction(assertions, new_assertions); |
54 |
14 |
for (unsigned i = 0, size = assertionsToPreprocess->size(); i < size; ++i) |
55 |
|
{ |
56 |
10 |
assertionsToPreprocess->replace(i, rewrite(new_assertions[i])); |
57 |
|
} |
58 |
8 |
return PreprocessingPassResult::NO_CONFLICT; |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
} // namespace passes |
63 |
|
} // namespace preprocessing |
64 |
29502 |
} // namespace cvc5 |