GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/bv/bv_solver_bitblast.h Lines: 3 4 75.0 %
Date: 2021-08-14 Branches: 0 2 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, 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
 * Bit-blasting solver that supports multiple SAT back ends.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__BV__BV_SOLVER_BITBLAST_H
19
#define CVC5__THEORY__BV__BV_SOLVER_BITBLAST_H
20
21
#include <unordered_map>
22
23
#include "context/cdqueue.h"
24
#include "proof/eager_proof_generator.h"
25
#include "prop/cnf_stream.h"
26
#include "prop/sat_solver.h"
27
#include "theory/bv/bitblast/node_bitblaster.h"
28
#include "theory/bv/bv_solver.h"
29
#include "theory/bv/proof_checker.h"
30
31
namespace cvc5 {
32
33
namespace theory {
34
namespace bv {
35
36
class NotifyResetAssertions;
37
class BBRegistrar;
38
39
/**
40
 * Bit-blasting solver with support for different SAT back ends.
41
 */
42
class BVSolverBitblast : public BVSolver
43
{
44
 public:
45
  BVSolverBitblast(TheoryState* state,
46
                   TheoryInferenceManager& inferMgr,
47
                   ProofNodeManager* pnm);
48
12200
  ~BVSolverBitblast() = default;
49
50
6100
  bool needsEqualityEngine(EeSetupInfo& esi) override { return true; }
51
52
137385
  void preRegisterTerm(TNode n) override {}
53
54
  void postCheck(Theory::Effort level) override;
55
56
  bool preNotifyFact(TNode atom,
57
                     bool pol,
58
                     TNode fact,
59
                     bool isPrereg,
60
                     bool isInternal) override;
61
62
  TrustNode explain(TNode n) override;
63
64
  std::string identify() const override { return "BVSolverBitblast"; };
65
66
  void computeRelevantTerms(std::set<Node>& termSet) override;
67
68
  bool collectModelValues(TheoryModel* m,
69
                          const std::set<Node>& termSet) override;
70
71
  /**
72
   * Get the current value of `node`.
73
   *
74
   * The `initialize` flag indicates whether bits should be zero-initialized
75
   * if they were not bit-blasted yet.
76
   */
77
  Node getValue(TNode node, bool initialize) override;
78
79
 private:
80
  /** Initialize SAT solver and CNF stream.  */
81
  void initSatSolver();
82
83
  /**
84
   * Handle BITVECTOR_EAGER_ATOM atoms and assert/assume to CnfStream.
85
   *
86
   * @param assertFact: Indicates whether the fact should be asserted (true) or
87
   * assumed (false).
88
   */
89
  void handleEagerAtom(TNode fact, bool assertFact);
90
91
  /** Bit-blaster used to bit-blast atoms/terms. */
92
  std::unique_ptr<NodeBitblaster> d_bitblaster;
93
94
  /** Used for initializing `d_cnfStream`. */
95
  std::unique_ptr<BBRegistrar> d_bbRegistrar;
96
  std::unique_ptr<context::Context> d_nullContext;
97
98
  /** SAT solver back end (configured via options::bvSatSolver. */
99
  std::unique_ptr<prop::SatSolver> d_satSolver;
100
  /** CNF stream. */
101
  std::unique_ptr<prop::CnfStream> d_cnfStream;
102
103
  /**
104
   * Bit-blast queue for facts sent to this solver.
105
   *
106
   * Gets populated on preNotifyFact().
107
   */
108
  context::CDQueue<Node> d_bbFacts;
109
110
  /**
111
   * Bit-blast queue for user-level 0 input facts sent to this solver.
112
   *
113
   * Get populated on preNotifyFact().
114
   */
115
  context::CDQueue<Node> d_bbInputFacts;
116
117
  /** Corresponds to the SAT literals of the currently asserted facts. */
118
  context::CDList<prop::SatLiteral> d_assumptions;
119
120
  /** Stores the current input assertions. */
121
  context::CDList<Node> d_assertions;
122
123
  /** Proof generator that manages proofs for lemmas generated by this class. */
124
  std::unique_ptr<EagerProofGenerator> d_epg;
125
126
  BVProofRuleChecker d_bvProofChecker;
127
128
  /** Stores the SatLiteral for a given fact. */
129
  context::CDHashMap<Node, prop::SatLiteral> d_factLiteralCache;
130
131
  /** Reverse map of `d_factLiteralCache`. */
132
  context::CDHashMap<prop::SatLiteral, Node, prop::SatLiteralHashFunction>
133
      d_literalFactCache;
134
135
  /** Option to enable/disable bit-level propagation. */
136
  bool d_propagate;
137
138
  /** Notifies when reset-assertion was called. */
139
  std::unique_ptr<NotifyResetAssertions> d_resetNotify;
140
};
141
142
}  // namespace bv
143
}  // namespace theory
144
}  // namespace cvc5
145
146
#endif