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