GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/prop/cryptominisat.h Lines: 0 1 0.0 %
Date: 2021-05-22 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, Liana Hadarean, 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
 * SAT Solver.
14
 *
15
 * Implementation of the cryptominisat sat solver for cvc5 (bit-vectors).
16
 */
17
18
#include "cvc5_private.h"
19
20
#ifndef CVC5__PROP__CRYPTOMINISAT_H
21
#define CVC5__PROP__CRYPTOMINISAT_H
22
23
#ifdef CVC5_USE_CRYPTOMINISAT
24
25
#include "prop/sat_solver.h"
26
27
// Cryptominisat has name clashes with the other Minisat implementations since
28
// the Minisat implementations export var_Undef, l_True, ... as macro whereas
29
// Cryptominisat uses static const. In order to avoid these conflicts we
30
// forward declare CMSat::SATSolver and include the cryptominisat header only
31
// in cryptominisat.cpp.
32
namespace CMSat {
33
  class SATSolver;
34
}
35
36
namespace cvc5 {
37
namespace prop {
38
39
class CryptoMinisatSolver : public SatSolver
40
{
41
  friend class SatSolverFactory;
42
43
 public:
44
  ~CryptoMinisatSolver() override;
45
46
  ClauseId addClause(SatClause& clause, bool removable) override;
47
  ClauseId addXorClause(SatClause& clause, bool rhs, bool removable) override;
48
49
  bool nativeXor() override { return true; }
50
51
  SatVariable newVar(bool isTheoryAtom = false,
52
                     bool preRegister = false,
53
                     bool canErase = true) override;
54
55
  SatVariable trueVar() override;
56
  SatVariable falseVar() override;
57
58
  void markUnremovable(SatLiteral lit);
59
60
  void interrupt() override;
61
62
  SatValue solve() override;
63
  SatValue solve(long unsigned int&) override;
64
  SatValue solve(const std::vector<SatLiteral>& assumptions) override;
65
  void getUnsatAssumptions(std::vector<SatLiteral>& assumptions) override;
66
67
  bool ok() const override;
68
  SatValue value(SatLiteral l) override;
69
  SatValue modelValue(SatLiteral l) override;
70
71
  unsigned getAssertionLevel() const override;
72
73
 private:
74
  class Statistics
75
  {
76
   public:
77
    IntStat d_statCallsToSolve;
78
    IntStat d_xorClausesAdded;
79
    IntStat d_clausesAdded;
80
    TimerStat d_solveTime;
81
    Statistics(StatisticsRegistry& registry, const std::string& prefix);
82
  };
83
84
  /**
85
   * Private to disallow creation outside of SatSolverFactory.
86
   * Function init() must be called after creation.
87
   */
88
  CryptoMinisatSolver(StatisticsRegistry& registry,
89
                      const std::string& name = "");
90
  /**
91
   * Initialize SAT solver instance.
92
   * Note: Split out to not call virtual functions in constructor.
93
   */
94
  void init();
95
96
  std::unique_ptr<CMSat::SATSolver> d_solver;
97
  unsigned d_numVariables;
98
  bool d_okay;
99
  SatVariable d_true;
100
  SatVariable d_false;
101
102
  Statistics d_statistics;
103
};
104
105
}  // namespace prop
106
}  // namespace cvc5
107
108
#endif  // CVC5_USE_CRYPTOMINISAT
109
#endif  // CVC5__PROP__CRYPTOMINISAT_H