blob: f046d66e4cd1b75f770cb4f5743e5a31e01c4ba7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/******************************************************************************
* Top contributors (to current version):
* Mathias Preiner, Aina Niemetz, Liana Hadarean
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
* in the top-level source directory and their institutional affiliations.
* All rights reserved. See the file COPYING in the top-level source
* directory for licensing information.
* ****************************************************************************
*
* Wrapper for CaDiCaL SAT Solver.
*
* Implementation of the CaDiCaL SAT solver for CVC4 (bit-vectors).
*/
#include "cvc4_private.h"
#ifndef CVC5__PROP__CADICAL_H
#define CVC5__PROP__CADICAL_H
#ifdef CVC5_USE_CADICAL
#include "prop/sat_solver.h"
#include "util/stats_timer.h"
#include <cadical.hpp>
namespace cvc5 {
namespace prop {
class CadicalSolver : public SatSolver
{
friend class SatSolverFactory;
public:
~CadicalSolver() override;
ClauseId addClause(SatClause& clause, bool removable) override;
ClauseId addXorClause(SatClause& clause, bool rhs, bool removable) override;
SatVariable newVar(bool isTheoryAtom = false,
bool preRegister = false,
bool canErase = true) override;
SatVariable trueVar() override;
SatVariable falseVar() override;
SatValue solve() override;
SatValue solve(long unsigned int&) override;
SatValue solve(const std::vector<SatLiteral>& assumptions) override;
bool setPropagateOnly() override;
void getUnsatAssumptions(std::vector<SatLiteral>& assumptions) override;
void interrupt() override;
SatValue value(SatLiteral l) override;
SatValue modelValue(SatLiteral l) override;
unsigned getAssertionLevel() const override;
bool ok() const override;
private:
/**
* Private to disallow creation outside of SatSolverFactory.
* Function init() must be called after creation.
*/
CadicalSolver(StatisticsRegistry* registry, const std::string& name = "");
/**
* Initialize SAT solver instance.
* Note: Split out to not call virtual functions in constructor.
*/
void init();
std::unique_ptr<CaDiCaL::Solver> d_solver;
/**
* Stores the current set of assumptions provided via solve() and is used to
* query the solver if a given assumption is false.
*/
std::vector<SatLiteral> d_assumptions;
unsigned d_nextVarIdx;
bool d_inSatMode;
SatVariable d_true;
SatVariable d_false;
struct Statistics
{
StatisticsRegistry* d_registry;
IntStat d_numSatCalls;
IntStat d_numVariables;
IntStat d_numClauses;
TimerStat d_solveTime;
Statistics(StatisticsRegistry* registry, const std::string& prefix);
~Statistics();
};
Statistics d_statistics;
};
} // namespace prop
} // namespace cvc5
#endif // CVC5_USE_CADICAL
#endif // CVC5__PROP__CADICAL_H
|