GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/bv_intro_pow2.h Lines: 1 1 100.0 %
Date: 2021-09-16 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   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
 * The BvIntroPow2 preprocessing pass.
14
 *
15
 * Traverses the formula and applies the IsPowerOfTwo rewrite rule. This
16
 * preprocessing pass is particularly useful on QF_BV/pspace benchmarks and
17
 * can be enabled via option `--bv-intro-pow2`.
18
 */
19
20
#include "cvc5_private.h"
21
22
#ifndef CVC5__PREPROCESSING__PASSES__BV_INTRO_POW2_H
23
#define CVC5__PREPROCESSING__PASSES__BV_INTRO_POW2_H
24
25
#include "preprocessing/preprocessing_pass.h"
26
27
namespace cvc5 {
28
namespace preprocessing {
29
namespace passes {
30
31
19878
class BvIntroPow2 : public PreprocessingPass
32
{
33
 public:
34
  BvIntroPow2(PreprocessingPassContext* preprocContext);
35
36
 protected:
37
  PreprocessingPassResult applyInternal(
38
      AssertionPipeline* assertionsToPreprocess) override;
39
40
 private:
41
  /** Checks whether PowerOfTwo rewrite applies. */
42
  bool isPowerOfTwo(TNode node);
43
  /**
44
   * Applies PowerOfTwo rewrite.
45
   *
46
   * x & (x-1) = 0 => x = 1 << sk
47
   *
48
   * where sk is a fresh Skolem.
49
   *
50
   * WARNING: this is an **EQUISATISFIABLE** transformation!
51
   * Only to be called on top level assertions.
52
   */
53
  Node rewritePowerOfTwo(TNode node);
54
  /** Does the traversal of assertions and applies rweritePowerOfTwo. */
55
  Node pow2Rewrite(Node node, std::unordered_map<Node, Node>& cache);
56
};
57
58
}  // namespace passes
59
}  // namespace preprocessing
60
}  // namespace cvc5
61
62
#endif /* CVC5__PREPROCESSING__PASSES__BV_INTRO_POW2_H */