dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
PicosatSatSolver.h
1
7#pragma once
8
9#ifndef DLINEAR_ENABLED_PICOSAT
10#error PicoSAT is not enabled. Please enable it by adding "--//tools:enable_picosat" to the bazel command.
11#endif
12
13#include <picosat/picosat.h>
14
15#include <optional>
16#include <set>
17#include <string>
18
19#include "dlinear/solver/SatSolver.h"
20#include "dlinear/symbolic/PredicateAbstractor.h"
21#include "dlinear/symbolic/literal.h"
22#include "dlinear/symbolic/symbolic.h"
23
24namespace dlinear {
25
32 public:
35
37 const std::string &class_name = "PicosatSatSolver");
38 ~PicosatSatSolver() override;
39
40 void AddLiteral(const Literal &l, bool learned) override;
41
42 void AddLearnedClause(const LiteralSet &literals) override;
43 void AddLearnedClause(const Literal &lit) override;
44
45 void MakeSatVar(const Variable &var) override;
46
47 std::optional<Model> CheckSat() override;
48
49 void Push() override;
50 void Pop() override;
51
52 void FixedTheoryLiterals(LiteralSet &fixed_literals) override;
53
54 void Assume(const Literal &l) override;
55
56 protected:
57 void AddClauseToSat(const Formula &f) override;
58
59 private:
60 [[nodiscard]] std::set<int> GetMainActiveLiterals() override;
61
62 PicoSAT *const sat_{};
63
64 bool has_picosat_pop_used_;
65};
66
67} // namespace dlinear
PicoSAT is a SAT solver written in C.
std::optional< Model > CheckSat() override
Check the satisfiability of the current configuration.
void MakeSatVar(const Variable &var) override
Add a variable to the internal SAT solver.
void AddLearnedClause(const LiteralSet &literals) override
Given a clause = {f₁, ..., fₙ}, adds a clause (¬f₁ ∨ ... ∨ ¬ fₙ) to the 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
void AddLiteral(const Literal &l, bool learned) override
Add a literal l to the SAT solver.
void AddClauseToSat(const Formula &f) override
Add a clause f to the internal SAT solver.
std::set< int > GetMainActiveLiterals() override
Get a set of the currently active literals in the clauses, ignoring those required by learned clauses...
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