ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SatSolvers.h

Two solvers of the satisfiability of a formula in conjunctive normal form, after Knuth (section 7.2.2.2 of The Art of Computer Programming), beyond the book. More...

Files

file  ADS/backtrack/SatSolvers.h
 Two solvers of the satisfiability of a formula in conjunctive normal form [see Problems.h for the formula and the backtrack of the reductions], after Knuth (section 7.2.2.2 of The Art of Computer Programming), beyond the book.

Classes

class  ADS::BasicCdcl< Heap >
 conflict-driven clause learning with two watched literals, the free variables by activity in a Heap of pairs \( ( \mathit{activity} , v ) \), the largest on top: std::priority_queue by default, or a heap of Boost or of ADS [see DaryHeap.h], with the same decisions and conflicts, since the pairs are ordered totally More...

Typedefs

using ADS::Cdcl = BasicCdcl<>
 the clause learning on std::priority_queue

Functions

std::optional< std::vector< bool > > ADS::dpll (const Cnf &F, int n)
 a model of the formula \( F \) of \( n \) variables by DPLL, the variables left free false, or nothing if \( F \) is unsatisfiable

Detailed description

Two solvers of the satisfiability of a formula in conjunctive normal form, after Knuth (section 7.2.2.2 of The Art of Computer Programming), beyond the book.

The definitions, the invariants and the costs of the area are in Theory of backtracking.

Typedef documentation

◆ Cdcl

using ADS::Cdcl = BasicCdcl<>

the clause learning on std::priority_queue

Function documentation

◆ dpll()

std::optional< std::vector< bool > > ADS::dpll ( const Cnf & F,
int n )
inline

a model of the formula \( F \) of \( n \) variables by DPLL, the variables left free false, or nothing if \( F \) is unsatisfiable

In pseudocode (the procedure of Davis, Putnam, Logemann and Loveland, beyond the book), \( a \) the partial assignment, all free at the start:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{dpll}( F , a ) \cr 2 & \quad \textbf{repeat}\quad \triangleright\ \text{the unit} \text{ propagation} \cr 3 & \qquad \textbf{foreach}\ C \in F \text{ not satisfied by } a \ \textbf{do} \cr 4 & \qquad\quad \textbf{if}\ \text{every literal of } C \text{ is} \text{ false }\ \textbf{then}\ \text{undo the forced ones}; \ \textbf{return false} \cr 5 & \qquad\quad \textbf{if}\ \text{one literal } \ell \text{ of } C \text{ alone is free }\ \textbf{then}\ \text{make } \ell \text{ true, a forced one} \cr 6 & \quad \textbf{until}\ \text{no literal was forced} \cr 7 & \quad \textbf{if}\ \text{every clause is satisfied } \ \textbf{then return true} \cr 8 & \quad \ell \gets \text{the first free literal of a shortest open} \text{ clause} \cr 9 & \quad \textbf{foreach}\ \text{value of } \ell \text{, true} \text{ first}\ \textbf{do} \cr 10 & \qquad \text{give it to } \ell;\ \textbf{if}\ \mathrm{dpll}( F , a )\ \textbf{then return true} \cr 11 & \quad \text{free } \ell \text{ and undo the forced ones}; \ \textbf{return false} \end{array}} \]

Precondition
\( n \ge 0 \) and the literals of \( F \) are variables of \( [ 0 , n ) \)
Postcondition
a model returned passes satCertificate()