GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/bv_abstraction.cpp Lines: 12 12 100.0 %
Date: 2021-03-23 Branches: 13 26 50.0 %

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