dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
CadicalSatSolver.h
1
7#pragma once
8
9#ifndef DLINEAR_ENABLED_CADICAL
10#error CaDiCaL is not enabled. Please enable it by adding "--//tools:enable_cadical" to the bazel command.
11#endif
12
13#include <cadical/cadical.hpp>
14#include <optional>
15#include <set>
16#include <string>
17
18#include "dlinear/solver/SatSolver.h"
19#include "dlinear/symbolic/PredicateAbstractor.h"
20#include "dlinear/symbolic/literal.h"
21#include "dlinear/symbolic/symbolic.h"
22
23namespace dlinear {
24
31 public:
34
36 const std::string &class_name = "CadicalSatSolver");
37
38 void AddLiteral(const Literal &l, bool learned) override;
39
40 void AddLearnedClause(const LiteralSet &literals) override;
41 void AddLearnedClause(const Literal &lit) override;
42
43 void MakeSatVar(const Variable &var) override;
44
45 std::optional<Model> CheckSat() override;
46
47 void Push() override;
48 void Pop() override;
49
50 void FixedTheoryLiterals(LiteralSet &fixed_literals) override;
51
52 void Assume(const Literal &l) override;
53
54 protected:
55 void AddClauseToSat(const Formula &f) override;
56
57 private:
58 [[nodiscard]] std::set<int> GetMainActiveLiterals() override;
59
60 CaDiCaL::Solver sat_{};
61 int next_var_id_{1};
62};
63
64} // namespace dlinear
SAT solver based on CaDiCal.
std::optional< Model > CheckSat() override
Check the satisfiability of the current configuration.
CaDiCaL::Solver sat_
SAT solver.
void AddLearnedClause(const LiteralSet &literals) override
Given a clause = {f₁, ..., fₙ}, adds a clause (¬f₁ ∨ ... ∨ ¬ fₙ) to the solver.
void AddClauseToSat(const Formula &f) override
Add a clause f to the internal SAT solver.
void Assume(const Literal &l) override
Assumption a literals to be fixed for the next iteration.
LiteralSet FixedTheoryLiterals()
Get the theory literals that are fixed in the current configuration.
Definition SatSolver.cpp:83
std::set< int > GetMainActiveLiterals() override
Get a set of the currently active literals in the clauses, ignoring those required by learned clauses...
void MakeSatVar(const Variable &var) override
Add a variable to the internal SAT solver.
void AddLiteral(const Literal &l, bool learned) override
Add a literal l to the SAT solver.
int next_var_id_
Next variable id.
Predicate abstraction is a method to convert a first-order logic formula into a Boolean formula.
Base class for SAT solvers.
Definition SatSolver.h:38
const PredicateAbstractor & predicate_abstractor() const
Get read-only access to the predicate abstractor of the SAT solver.
Definition SatSolver.h:154
LiteralSet FixedTheoryLiterals()
Get the theory literals that are fixed in the current configuration.
Definition SatSolver.cpp:83
void Assume(const LiteralSet &literals)
Assumption a set of literals to be fixed for the next iteration.
Definition SatSolver.cpp:88
Represents a symbolic form of a first-order logic formula.
Represents a symbolic variable.
Global namespace for the dlinear library.
std::set< Literal > LiteralSet
A set of literals.
Definition literal.h:28
A literal is a variable with an associated truth value, indicating whether it is true or false.
Definition literal.h:24