SlideShare a Scribd company logo
1 of 61
Download to read offline
Satisfiability Modulo Theories
Lezione 3 - Efficient SAT-Solvers
(slides revision: Saturday 14th
March, 2015, 11:46)
Roberto Bruttomesso
Seminario di Logica Matematica
(Corso Prof. Silvio Ghilardi)
3 Novembre 2011
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 1 / 24
Recall from last lecture . . .
Approaches to solve SMT formulæ are based on the observation that
SMT can be reduced to SAT, i.e., the purely Boolean Satisfiability
Problem
Eager Lazy
sat / unsat
SMT formula ϕ
ψ
Encoder SAT-solver
good
SAT-solver
SMT formula ϕ
Extract Struct.
T -solver
Candidate
model
unsat sat
not good
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 2 / 24
Outline
1 Introduction
2 DPLL SAT-Solvers
The DPLL Procedure
The Iterative DPLL Procedure
3 CDCL SAT-Solvers
Clause Learning
Conflict Analysis
Non-Chronological Bactracking
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 3 / 24
Disclaimer
The SAT-Solving algorithm described as follows is not the only
approach existing
BDDs
Quantifier Elimination
Random SAT-Solving
We study the DPLL/CDCL approach as it is precise (not
approximate), it uses a linear amount of memory, and very robust
It is fair to say that it is the most used approach by industry for pure
solving
The approach evolved in many years, many groups have contributed.
Here we do not see the history of this evolution but just the final
product
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 4 / 24
Complexity Considerations
SAT is “the” NP-Complete problem
It is unlikely to be solved in polynomial time
Most likely, it takes some O(2n) time complexity for an algorithm to
solve SAT
Complexity of SAT cannot be alleviated by faster machines (only by
parallelism, if we ever reach that technology). Suppose you can execute
M instructions in 1 hour, then the maximum n you can handle is
Speed of machine Max input size in 1 hour
1x log2(M) = n
100x log2(100 · M) ≈ n + 3.3
1000000x log2(1000000 · M) ≈ n + 19
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 5 / 24
CNF Formulæ
From now on we shall focus on solving formulæ in Conjunctive Normal Form CNF
C1 ∧ C2 ∧ . . . ∧ Cn
where each Ci is a clause, a disjunction of the kind
(l1 ∨ l2 ∨ . . . lm)
where every li is a literal, which is a variable or a negated Boolean variable
a or ¬a
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 6 / 24
CNF Formulæ
From now on we shall focus on solving formulæ in Conjunctive Normal Form CNF
C1 ∧ C2 ∧ . . . ∧ Cn
where each Ci is a clause, a disjunction of the kind
(l1 ∨ l2 ∨ . . . lm)
where every li is a literal, which is a variable or a negated Boolean variable
a or ¬a
For simplicity we will write them as a set of clauses, omitting the ∧, like
(¬a1 ∨ a2)
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(¬a4 ∨ a5 ∨ a10)
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 6 / 24
Basic Notation
We indicate a (possibly partial) assignment as the set of literals that
are under it, i.e., we write the assignment
{a1 → , a2 → , a3 → ⊥, a4 → ⊥, a9 → }
as
{a1, a2, ¬a3, ¬a4, a9}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 7 / 24
Basic Notation
We indicate a (possibly partial) assignment as the set of literals that
are under it, i.e., we write the assignment
{a1 → , a2 → , a3 → ⊥, a4 → ⊥, a9 → }
as
{a1, a2, ¬a3, ¬a4, a9}
An assignment is used to evaluate a formula, e.g.,
(¬a1 ∨ a2)
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(¬a4 ∨ a5 ∨ a10)
evaluates to under the assignment above
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 7 / 24
Basic Notation
We indicate a (possibly partial) assignment as the set of literals that
are under it, i.e., we write the assignment
{a1 → , a2 → , a3 → ⊥, a4 → ⊥, a9 → }
as
{a1, a2, ¬a3, ¬a4, a9}
An assignment is used to evaluate a formula, e.g.,
(¬a1 ∨ a2)
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(¬a4 ∨ a5 ∨ a10)
evaluates to under the assignment above
at least one this colored literal in each clause to make it
all this colored literals in one clause to make it ⊥
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 7 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
The assignment evolves incrementally by taking Decisions, starting
from empty { }, but it can be backtracked if found wrong
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
The assignment evolves incrementally by taking Decisions, starting
from empty { }, but it can be backtracked if found wrong
The evolution of the assignment can be represented as a tree
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
The assignment evolves incrementally by taking Decisions, starting
from empty { }, but it can be backtracked if found wrong
The evolution of the assignment can be represented as a tree
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{ }
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
The assignment evolves incrementally by taking Decisions, starting
from empty { }, but it can be backtracked if found wrong
The evolution of the assignment can be represented as a tree
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{¬a1}
¬a1
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
The assignment evolves incrementally by taking Decisions, starting
from empty { }, but it can be backtracked if found wrong
The evolution of the assignment can be represented as a tree
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{¬a1, ¬a2}
¬a2
¬a1
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
The assignment evolves incrementally by taking Decisions, starting
from empty { }, but it can be backtracked if found wrong
The evolution of the assignment can be represented as a tree
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{¬a1, a2}
a2¬a2
¬a1
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
SAT-Solving is (the art of) finding the assignment satisfying all clauses
The assignment evolves incrementally by taking Decisions, starting
from empty { }, but it can be backtracked if found wrong
The evolution of the assignment can be represented as a tree
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{. . .}
a2
a1
¬a2a2¬a2
¬a1
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
Simple Facts
There are assignments which can be trivially driven towards the right
direction. In the example below, given the current assignment, the
third clause can be satisfied only by setting a2 →
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{¬a1}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 9 / 24
Simple Facts
There are assignments which can be trivially driven towards the right
direction. In the example below, given the current assignment, the
third clause can be satisfied only by setting a2 →
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{¬a1, a2}
a2
¬a1
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 9 / 24
Simple Facts
There are assignments which can be trivially driven towards the right
direction. In the example below, given the current assignment, the
third clause can be satisfied only by setting a2 →
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(a1 ∨ a2)
(¬a4 ∨ a5 ∨ a10)
{¬a1, a2}
a2
¬a1
This step is called Boolean Constraint Propagation (BCP). It
represents a forced deduction. It triggers whenever all literals but one
are assigned ⊥
(¬a1 ∨ a2 ∨ ¬a3 ∨ a4 ∨ ¬a5)
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 9 / 24
Simple Facts
Decision-level: in an assignment, it is the number of decisions taken
Clearly, BCPs do not contribute to increase the decision level
When necessary, we will indicate decision level on top of literals
5
a in
the assignment
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 10 / 24
Simple Facts
Decision-level: in an assignment, it is the number of decisions taken
Clearly, BCPs do not contribute to increase the decision level
When necessary, we will indicate decision level on top of literals
5
a in
the assignment
Example:
{
0
a10,
1
¬a1,
2
a3,
3
¬a4,
3
a5}
¬a1
¬a4
a5
a3
a10
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 10 / 24
Simple Facts
The process of finding the satisfying assignment is called search, and
in its basic version it evolves with Decisions, BCPs, and
backtracking
Decision
numberofvariables
failures
model found
Backtracking
BCP
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 11 / 24
The DPLL Procedure (Revised)
DPLL( V , C )
if ( “a clause has all ⊥ literals” ) return unsat; // Failure
if ( “all clauses has a literal” ) return sat; // Model found
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
The DPLL Procedure (Revised)
DPLL( V , C )
if ( “a clause has all ⊥ literals” ) return unsat; // Failure
if ( “all clauses has a literal” ) return sat; // Model found
if ( “a clause has all but one literal l to ⊥” )
return DPLL( V ∪ {l}, C ); // BCP
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
The DPLL Procedure (Revised)
DPLL( V , C )
if ( “a clause has all ⊥ literals” ) return unsat; // Failure
if ( “all clauses has a literal” ) return sat; // Model found
if ( “a clause has all but one literal l to ⊥” )
return DPLL( V ∪ {l}, C ); // BCP
l = “pick an unassigned literal” // Decision
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
The DPLL Procedure (Revised)
DPLL( V , C )
if ( “a clause has all ⊥ literals” ) return unsat; // Failure
if ( “all clauses has a literal” ) return sat; // Model found
if ( “a clause has all but one literal l to ⊥” )
return DPLL( V ∪ {l}, C ); // BCP
l = “pick an unassigned literal” // Decision
if ( DPLL( V ∪ {l}, C ) == sat ) // Left Branch
return sat;
else
return DPLL( V ∪ {¬l}, C ); // Backtracking (Rigth Branch)
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
The DPLL Procedure (Revised)
DPLL( V , C )
if ( “a clause has all ⊥ literals” ) return unsat; // Failure
if ( “all clauses has a literal” ) return sat; // Model found
if ( “a clause has all but one literal l to ⊥” )
return DPLL( V ∪ {l}, C ); // BCP
l = “pick an unassigned literal” // Decision
if ( DPLL( V ∪ {l}, C ) == sat ) // Left Branch
return sat;
else
return DPLL( V ∪ {¬l}, C ); // Backtracking (Rigth Branch)
To be called as DPLL( { }, C )
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
The Iterative DPLL Procedure (Revised)
dl = 0; flipped = { }; trail = { }; // Decision level, flipped vars, assignment
while ( true )
if ( BCP( ) == conflict ) // Do BCP until possible
done = false;
do
if ( dl == 0 ) return unsat; // Unresolvable conflict
l = GetDecisionLiteralAt( dl );
BacktrackTo( dl − 1 ); // Backtracking (shrinks trail)
if ( var(l) ∈ flipped )
dl = dl − 1;
else
trail = trail ∪ {¬l};
flipped = flipped ∪ {var(l)};
done = true;
while ( !done );
else
if ( “all variables assigned” ) return sat; // trail holds satisfying assignment
l = Decision( ); // Do another decision
trail = trail ∪ {l}
dl = dl + 1; // Increase decision level
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 13 / 24
The DPLL Procedure (Revised)
Some characteristics
BCP is called with highest priority, as much as possible
Backtracking is performed chronologically: search backtracks to
the previous decision-level
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 14 / 24
The DPLL Procedure (Revised)
Some characteristics
BCP is called with highest priority, as much as possible
Backtracking is performed chronologically: search backtracks to
the previous decision-level
Some differences w.r.t. “original” DPLL Procedure
C is not touched: non-destructive data-structures (memory
efficient)
Pure Literal Rule is not used: expensive to implement (!)
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 14 / 24
From DPLL to CDCL
Consider the following scenario before and after BCP
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1}
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
From DPLL to CDCL
Consider the following scenario before and after BCP
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1}
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ?
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
From DPLL to CDCL
Consider the following scenario before and after BCP
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1}
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ?
Does it make sense to consider the assignments (which backtracking would produce) ?
{
0
a10,
1
¬a3,
2
¬a7,
3
¬a2,
4
a1} — {
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1} — {
0
a10,
1
¬a3,
2
a7,
3
a2,
4
a1}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
From DPLL to CDCL
Consider the following scenario before and after BCP
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1}
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ?
Does it make sense to consider the assignments (which backtracking would produce) ?
{
0
a10,
1
¬a3,
2
¬a7,
3
¬a2,
4
a1} — {
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1} — {
0
a10,
1
¬a3,
2
a7,
3
a2,
4
a1}
No, because whenever a10, ¬a3 is assigned, then a1 must not be set to .
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
From DPLL to CDCL
Consider the following scenario before and after BCP
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1}
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ?
Does it make sense to consider the assignments (which backtracking would produce) ?
{
0
a10,
1
¬a3,
2
¬a7,
3
¬a2,
4
a1} — {
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1} — {
0
a10,
1
¬a3,
2
a7,
3
a2,
4
a1}
No, because whenever a10, ¬a3 is assigned, then a1 must not be set to . This translates
to an additional clause, which can be learnt, i.e., it can be added to the formula
(¬a10 ∨ a3 ∨ ¬a1)
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
From DPLL to CDCL
Search
Without learnt clause With learnt clause
a10
¬a3
¬a2
¬a7a7
a1
a4
a5
a6
¬a1
¬a2a2 a2
¬a1
¬a3
¬a2
¬a7a7
¬a2a2 a2
a10
¬a1 ¬a1 ¬a1
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 16 / 24
Deriving the clause to be learnt
The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never
caused by a Decision)
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
Deriving the clause to be learnt
The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never
caused by a Decision)
To better analyze a conflict we need to look at the implication graph
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} ¬a3
a4
a5
a1
a10
a6
¬a2
a7
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
Deriving the clause to be learnt
The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never
caused by a Decision)
To better analyze a conflict we need to look at the implication graph
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} ¬a3
a4
a5
a1
a10
a6
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
Deriving the clause to be learnt
The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never
caused by a Decision)
To better analyze a conflict we need to look at the implication graph
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} ¬a3
a4
a5
a1
a10
a6
Any cut of the graph that separates the conflict from the decision variables represents a
possible learnt clause
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
Deriving the clause to be learnt
The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never
caused by a Decision)
To better analyze a conflict we need to look at the implication graph
. . .
(¬a10 ∨ ¬a1 ∨ a4)
(a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a6)
(¬a5 ∨ ¬a6)
. . .
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} ¬a3
a4
a5
a1
a10
a6
Any cut of the graph that separates the conflict from the decision variables represents a
possible learnt clause
In this course we take the clause that contains only one variable of the current
decision level
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6) (¬a4 ∨ a6)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6) (¬a4 ∨ a6)
(¬a5 ∨ ¬a4)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6) (¬a4 ∨ a6)
(¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6) (¬a4 ∨ a6)
(¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a3 ∨ ¬a1)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6) (¬a4 ∨ a6)
(¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a3 ∨ ¬a1) (¬a10 ∨ ¬a1 ∨ a4)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6) (¬a4 ∨ a6)
(¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a3 ∨ ¬a1) (¬a10 ∨ ¬a1 ∨ a4)
(¬a10 ∨ a3 ∨ ¬a1)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Deriving the clause to be learnt
In practice, we use resolution steps to compute the learnt clause:
we start from the clause with all literals to ⊥ (conflicting clause)
iteratively, we take the clause that propagated the last literal on the trail and we
apply resolution
we stop when only one literal from the current decision level is left in the clause
(¬a5 ∨ ¬a6) (¬a4 ∨ a6)
(¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5)
(¬a4 ∨ a3 ∨ ¬a1) (¬a10 ∨ ¬a1 ∨ a4)
(¬a10 ∨ a3 ∨ ¬a1)
Trail dl Reason
a10 0 (a10)
¬a3 1 Decision
a7 2 Decision
¬a2 3 Decision
a1 4 Decision
a4 4 (¬a10 ∨ ¬a1 ∨ a4)
a5 4 (a3 ∨ ¬a1 ∨ a5)
a6 4 (¬a4 ∨ a6)
{
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6}
We say that (¬a10 ∨ a3 ∨ ¬a1) is the conflict clause and it is the one we learn
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
Non-chronological backtracking
So far we have been backtracking chronologically, but
given our (wrong) assignment {
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} and the
computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to
backtrack to level 3 ?
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
Non-chronological backtracking
So far we have been backtracking chronologically, but
given our (wrong) assignment {
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} and the
computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to
backtrack to level 3 ?
The correct level to backtrack to is:
“the level that would have propagated ¬a1 if we had the clause
(¬a10 ∨ a3 ∨ ¬a1) as part of the original formula”
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
Non-chronological backtracking
So far we have been backtracking chronologically, but
given our (wrong) assignment {
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} and the
computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to
backtrack to level 3 ?
The correct level to backtrack to is:
“the level that would have propagated ¬a1 if we had the clause
(¬a10 ∨ a3 ∨ ¬a1) as part of the original formula”
In our case, it is level 1, because assignment {
0
a10,
1
¬a3} is sufficient to
propagate ¬a1 in (¬a10 ∨ a3 ∨ ¬a1)
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
Non-chronological backtracking
So far we have been backtracking chronologically, but
given our (wrong) assignment {
0
a10,
1
¬a3,
2
a7,
3
¬a2,
4
a1,
4
a4,
4
a5,
4
a6} and the
computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to
backtrack to level 3 ?
The correct level to backtrack to is:
“the level that would have propagated ¬a1 if we had the clause
(¬a10 ∨ a3 ∨ ¬a1) as part of the original formula”
In our case, it is level 1, because assignment {
0
a10,
1
¬a3} is sufficient to
propagate ¬a1 in (¬a10 ∨ a3 ∨ ¬a1)
We say that ¬a1 is the asserting literal as it becomes true by BCP
once we have backtracked to the correct decision level
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
CDCL: Conflict Driven Clause Learning
Search
DPLL CDCL
no learning conflict-driven learning
chronological backtracking non-chronological backtracking
¬a3
a1
¬a2 a2
¬a3 a3 ¬a3
a4
a1
¬a2
a3
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 20 / 24
The CDCL Procedure
dl = 0; trail = { }; // Decision level, assignment
while ( true )
if ( BCP( ) == conflict ) // Do BCP until possible
if ( dl == 0 ) return unsat; // Unresolvable conflict
C, dl = AnalyzeConflict( ); // Compute conf. clause, and dec. level
AddClause( C ); // Add C to clause database
BacktrackTo( dl ); // Backtracking (shrinks trail)
else
if ( “all variables assigned” ) return sat; // trail holds satisfying assignment
l = Decision( ); // Do another decision
trail = trail ∪ {l}
dl = dl + 1; // Increase decision level
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 21 / 24
The CDCL Procedure
conflict
no confl.
assign var
conflict at level 0
left
no vars
SATBCP Decision
AnalyzeConflict
UNSAT
AddClause
BacktrackTo
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 22 / 24
Other things which we did not see
Watched Literals: technique to efficiently discover which clauses
become unsat
Decision heuristics: how do we choose the right variable ? And
which polarity ? ( , ⊥). Landmark strategy is VSIDS heuristic
Clause removal: adding too many clauses negatively impacts
performance, need mechanisms to remove learnts
Restarts: start the search from scratch, but retaining learnts
many many other heuristics discovered every year
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 23 / 24
Exercise
Consider the following clause set and assignment
(¬a1 ∨ a2)
(¬a1 ∨ a3 ∨ a9)
(¬a2 ∨ ¬a3 ∨ a4)
(¬a4 ∨ a5 ∨ a10)
(¬a4 ∨ a6 ∨ a11)
(¬a5 ∨ ¬a6)
(a1 ∨ a7 ∨ ¬a12)
(a1 ∨ a8)
(¬a7 ∨ ¬a8 ∨ ¬a13)
. . .
{
1
¬a9,
2
a12,
2
a13,
3
¬a10,
3
¬a11, . . . ,
6
a1}
Find the correct conflict clause
Find the correct decision level to backtrack
R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 24 / 24

More Related Content

What's hot

Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introductionNAMRATA BORKAR
 
Physics Research Summer2009
Physics Research Summer2009Physics Research Summer2009
Physics Research Summer2009Ryan Melvin
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressionsSampath Kumar S
 
periodic functions and Fourier series
periodic functions and Fourier seriesperiodic functions and Fourier series
periodic functions and Fourier seriesUmang Gupta
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2S.Shayan Daneshvar
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Abhimanyu Mishra
 
1.9. minimization of dfa
1.9. minimization of dfa1.9. minimization of dfa
1.9. minimization of dfaSampath Kumar S
 
Consistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticConsistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticYamagata Yoriyuki
 
Introduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysisIntroduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysis宗翰 謝
 
Consistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticConsistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticYamagata Yoriyuki
 

What's hot (20)

Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introduction
 
MSc_thesis
MSc_thesisMSc_thesis
MSc_thesis
 
Np cooks theorem
Np cooks theoremNp cooks theorem
Np cooks theorem
 
Physics Research Summer2009
Physics Research Summer2009Physics Research Summer2009
Physics Research Summer2009
 
Reductions
ReductionsReductions
Reductions
 
Laplace
LaplaceLaplace
Laplace
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions
 
periodic functions and Fourier series
periodic functions and Fourier seriesperiodic functions and Fourier series
periodic functions and Fourier series
 
Algorithum Analysis
Algorithum AnalysisAlgorithum Analysis
Algorithum Analysis
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2
 
big_oh
big_ohbig_oh
big_oh
 
Lecture26
Lecture26Lecture26
Lecture26
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
 
1.9. minimization of dfa
1.9. minimization of dfa1.9. minimization of dfa
1.9. minimization of dfa
 
Consistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticConsistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmetic
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
 
Introduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysisIntroduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysis
 
Consistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticConsistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmetic
 

Similar to Efficient SAT Solvers

The Max Cut Problem
The Max Cut ProblemThe Max Cut Problem
The Max Cut Problemdnatapov
 
test pre
test pretest pre
test prefarazch
 
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...KionaHood
 
A Tutorial on Computational Geometry
A Tutorial on Computational GeometryA Tutorial on Computational Geometry
A Tutorial on Computational GeometryMinh-Tri Pham
 
FM 2015 - Narrowing operators on template abstract domains
FM 2015 - Narrowing operators on template abstract domainsFM 2015 - Narrowing operators on template abstract domains
FM 2015 - Narrowing operators on template abstract domainsGianluca Amato
 
A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...narmo
 
Driven Oscillation
Driven Oscillation Driven Oscillation
Driven Oscillation Shahzu2
 
Winter 12 Lecture Mapping Reducibility.pptx
Winter 12 Lecture Mapping Reducibility.pptxWinter 12 Lecture Mapping Reducibility.pptx
Winter 12 Lecture Mapping Reducibility.pptxHarisPrince
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysisIffat Anjum
 

Similar to Efficient SAT Solvers (20)

The Max Cut Problem
The Max Cut ProblemThe Max Cut Problem
The Max Cut Problem
 
smtlecture.6
smtlecture.6smtlecture.6
smtlecture.6
 
smtlecture.5
smtlecture.5smtlecture.5
smtlecture.5
 
test pre
test pretest pre
test pre
 
satandsmt.stpetersburg
satandsmt.stpetersburgsatandsmt.stpetersburg
satandsmt.stpetersburg
 
smtlecture.4
smtlecture.4smtlecture.4
smtlecture.4
 
5 csp
5 csp5 csp
5 csp
 
smtlectures.1
smtlectures.1smtlectures.1
smtlectures.1
 
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
 
A Tutorial on Computational Geometry
A Tutorial on Computational GeometryA Tutorial on Computational Geometry
A Tutorial on Computational Geometry
 
smtlecture.7
smtlecture.7smtlecture.7
smtlecture.7
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
 
FM 2015 - Narrowing operators on template abstract domains
FM 2015 - Narrowing operators on template abstract domainsFM 2015 - Narrowing operators on template abstract domains
FM 2015 - Narrowing operators on template abstract domains
 
A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...
 
Driven Oscillation
Driven Oscillation Driven Oscillation
Driven Oscillation
 
Winter 12 Lecture Mapping Reducibility.pptx
Winter 12 Lecture Mapping Reducibility.pptxWinter 12 Lecture Mapping Reducibility.pptx
Winter 12 Lecture Mapping Reducibility.pptx
 
21 All Pairs Shortest Path
21 All Pairs Shortest Path21 All Pairs Shortest Path
21 All Pairs Shortest Path
 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
 
Lesson 7: The Derivative
Lesson 7: The DerivativeLesson 7: The Derivative
Lesson 7: The Derivative
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 

Efficient SAT Solvers

  • 1. Satisfiability Modulo Theories Lezione 3 - Efficient SAT-Solvers (slides revision: Saturday 14th March, 2015, 11:46) Roberto Bruttomesso Seminario di Logica Matematica (Corso Prof. Silvio Ghilardi) 3 Novembre 2011 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 1 / 24
  • 2. Recall from last lecture . . . Approaches to solve SMT formulæ are based on the observation that SMT can be reduced to SAT, i.e., the purely Boolean Satisfiability Problem Eager Lazy sat / unsat SMT formula ϕ ψ Encoder SAT-solver good SAT-solver SMT formula ϕ Extract Struct. T -solver Candidate model unsat sat not good R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 2 / 24
  • 3. Outline 1 Introduction 2 DPLL SAT-Solvers The DPLL Procedure The Iterative DPLL Procedure 3 CDCL SAT-Solvers Clause Learning Conflict Analysis Non-Chronological Bactracking R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 3 / 24
  • 4. Disclaimer The SAT-Solving algorithm described as follows is not the only approach existing BDDs Quantifier Elimination Random SAT-Solving We study the DPLL/CDCL approach as it is precise (not approximate), it uses a linear amount of memory, and very robust It is fair to say that it is the most used approach by industry for pure solving The approach evolved in many years, many groups have contributed. Here we do not see the history of this evolution but just the final product R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 4 / 24
  • 5. Complexity Considerations SAT is “the” NP-Complete problem It is unlikely to be solved in polynomial time Most likely, it takes some O(2n) time complexity for an algorithm to solve SAT Complexity of SAT cannot be alleviated by faster machines (only by parallelism, if we ever reach that technology). Suppose you can execute M instructions in 1 hour, then the maximum n you can handle is Speed of machine Max input size in 1 hour 1x log2(M) = n 100x log2(100 · M) ≈ n + 3.3 1000000x log2(1000000 · M) ≈ n + 19 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 5 / 24
  • 6. CNF Formulæ From now on we shall focus on solving formulæ in Conjunctive Normal Form CNF C1 ∧ C2 ∧ . . . ∧ Cn where each Ci is a clause, a disjunction of the kind (l1 ∨ l2 ∨ . . . lm) where every li is a literal, which is a variable or a negated Boolean variable a or ¬a R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 6 / 24
  • 7. CNF Formulæ From now on we shall focus on solving formulæ in Conjunctive Normal Form CNF C1 ∧ C2 ∧ . . . ∧ Cn where each Ci is a clause, a disjunction of the kind (l1 ∨ l2 ∨ . . . lm) where every li is a literal, which is a variable or a negated Boolean variable a or ¬a For simplicity we will write them as a set of clauses, omitting the ∧, like (¬a1 ∨ a2) (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (¬a4 ∨ a5 ∨ a10) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 6 / 24
  • 8. Basic Notation We indicate a (possibly partial) assignment as the set of literals that are under it, i.e., we write the assignment {a1 → , a2 → , a3 → ⊥, a4 → ⊥, a9 → } as {a1, a2, ¬a3, ¬a4, a9} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 7 / 24
  • 9. Basic Notation We indicate a (possibly partial) assignment as the set of literals that are under it, i.e., we write the assignment {a1 → , a2 → , a3 → ⊥, a4 → ⊥, a9 → } as {a1, a2, ¬a3, ¬a4, a9} An assignment is used to evaluate a formula, e.g., (¬a1 ∨ a2) (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (¬a4 ∨ a5 ∨ a10) evaluates to under the assignment above R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 7 / 24
  • 10. Basic Notation We indicate a (possibly partial) assignment as the set of literals that are under it, i.e., we write the assignment {a1 → , a2 → , a3 → ⊥, a4 → ⊥, a9 → } as {a1, a2, ¬a3, ¬a4, a9} An assignment is used to evaluate a formula, e.g., (¬a1 ∨ a2) (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (¬a4 ∨ a5 ∨ a10) evaluates to under the assignment above at least one this colored literal in each clause to make it all this colored literals in one clause to make it ⊥ R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 7 / 24
  • 11. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 12. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses The assignment evolves incrementally by taking Decisions, starting from empty { }, but it can be backtracked if found wrong R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 13. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses The assignment evolves incrementally by taking Decisions, starting from empty { }, but it can be backtracked if found wrong The evolution of the assignment can be represented as a tree R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 14. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses The assignment evolves incrementally by taking Decisions, starting from empty { }, but it can be backtracked if found wrong The evolution of the assignment can be represented as a tree (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) { } R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 15. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses The assignment evolves incrementally by taking Decisions, starting from empty { }, but it can be backtracked if found wrong The evolution of the assignment can be represented as a tree (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) {¬a1} ¬a1 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 16. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses The assignment evolves incrementally by taking Decisions, starting from empty { }, but it can be backtracked if found wrong The evolution of the assignment can be represented as a tree (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) {¬a1, ¬a2} ¬a2 ¬a1 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 17. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses The assignment evolves incrementally by taking Decisions, starting from empty { }, but it can be backtracked if found wrong The evolution of the assignment can be represented as a tree (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) {¬a1, a2} a2¬a2 ¬a1 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 18. Simple Facts SAT-Solving is (the art of) finding the assignment satisfying all clauses The assignment evolves incrementally by taking Decisions, starting from empty { }, but it can be backtracked if found wrong The evolution of the assignment can be represented as a tree (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) {. . .} a2 a1 ¬a2a2¬a2 ¬a1 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 8 / 24
  • 19. Simple Facts There are assignments which can be trivially driven towards the right direction. In the example below, given the current assignment, the third clause can be satisfied only by setting a2 → (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) {¬a1} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 9 / 24
  • 20. Simple Facts There are assignments which can be trivially driven towards the right direction. In the example below, given the current assignment, the third clause can be satisfied only by setting a2 → (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) {¬a1, a2} a2 ¬a1 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 9 / 24
  • 21. Simple Facts There are assignments which can be trivially driven towards the right direction. In the example below, given the current assignment, the third clause can be satisfied only by setting a2 → (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (a1 ∨ a2) (¬a4 ∨ a5 ∨ a10) {¬a1, a2} a2 ¬a1 This step is called Boolean Constraint Propagation (BCP). It represents a forced deduction. It triggers whenever all literals but one are assigned ⊥ (¬a1 ∨ a2 ∨ ¬a3 ∨ a4 ∨ ¬a5) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 9 / 24
  • 22. Simple Facts Decision-level: in an assignment, it is the number of decisions taken Clearly, BCPs do not contribute to increase the decision level When necessary, we will indicate decision level on top of literals 5 a in the assignment R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 10 / 24
  • 23. Simple Facts Decision-level: in an assignment, it is the number of decisions taken Clearly, BCPs do not contribute to increase the decision level When necessary, we will indicate decision level on top of literals 5 a in the assignment Example: { 0 a10, 1 ¬a1, 2 a3, 3 ¬a4, 3 a5} ¬a1 ¬a4 a5 a3 a10 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 10 / 24
  • 24. Simple Facts The process of finding the satisfying assignment is called search, and in its basic version it evolves with Decisions, BCPs, and backtracking Decision numberofvariables failures model found Backtracking BCP R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 11 / 24
  • 25. The DPLL Procedure (Revised) DPLL( V , C ) if ( “a clause has all ⊥ literals” ) return unsat; // Failure if ( “all clauses has a literal” ) return sat; // Model found R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
  • 26. The DPLL Procedure (Revised) DPLL( V , C ) if ( “a clause has all ⊥ literals” ) return unsat; // Failure if ( “all clauses has a literal” ) return sat; // Model found if ( “a clause has all but one literal l to ⊥” ) return DPLL( V ∪ {l}, C ); // BCP R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
  • 27. The DPLL Procedure (Revised) DPLL( V , C ) if ( “a clause has all ⊥ literals” ) return unsat; // Failure if ( “all clauses has a literal” ) return sat; // Model found if ( “a clause has all but one literal l to ⊥” ) return DPLL( V ∪ {l}, C ); // BCP l = “pick an unassigned literal” // Decision R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
  • 28. The DPLL Procedure (Revised) DPLL( V , C ) if ( “a clause has all ⊥ literals” ) return unsat; // Failure if ( “all clauses has a literal” ) return sat; // Model found if ( “a clause has all but one literal l to ⊥” ) return DPLL( V ∪ {l}, C ); // BCP l = “pick an unassigned literal” // Decision if ( DPLL( V ∪ {l}, C ) == sat ) // Left Branch return sat; else return DPLL( V ∪ {¬l}, C ); // Backtracking (Rigth Branch) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
  • 29. The DPLL Procedure (Revised) DPLL( V , C ) if ( “a clause has all ⊥ literals” ) return unsat; // Failure if ( “all clauses has a literal” ) return sat; // Model found if ( “a clause has all but one literal l to ⊥” ) return DPLL( V ∪ {l}, C ); // BCP l = “pick an unassigned literal” // Decision if ( DPLL( V ∪ {l}, C ) == sat ) // Left Branch return sat; else return DPLL( V ∪ {¬l}, C ); // Backtracking (Rigth Branch) To be called as DPLL( { }, C ) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 12 / 24
  • 30. The Iterative DPLL Procedure (Revised) dl = 0; flipped = { }; trail = { }; // Decision level, flipped vars, assignment while ( true ) if ( BCP( ) == conflict ) // Do BCP until possible done = false; do if ( dl == 0 ) return unsat; // Unresolvable conflict l = GetDecisionLiteralAt( dl ); BacktrackTo( dl − 1 ); // Backtracking (shrinks trail) if ( var(l) ∈ flipped ) dl = dl − 1; else trail = trail ∪ {¬l}; flipped = flipped ∪ {var(l)}; done = true; while ( !done ); else if ( “all variables assigned” ) return sat; // trail holds satisfying assignment l = Decision( ); // Do another decision trail = trail ∪ {l} dl = dl + 1; // Increase decision level R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 13 / 24
  • 31. The DPLL Procedure (Revised) Some characteristics BCP is called with highest priority, as much as possible Backtracking is performed chronologically: search backtracks to the previous decision-level R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 14 / 24
  • 32. The DPLL Procedure (Revised) Some characteristics BCP is called with highest priority, as much as possible Backtracking is performed chronologically: search backtracks to the previous decision-level Some differences w.r.t. “original” DPLL Procedure C is not touched: non-destructive data-structures (memory efficient) Pure Literal Rule is not used: expensive to implement (!) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 14 / 24
  • 33. From DPLL to CDCL Consider the following scenario before and after BCP . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
  • 34. From DPLL to CDCL Consider the following scenario before and after BCP . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ? R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
  • 35. From DPLL to CDCL Consider the following scenario before and after BCP . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ? Does it make sense to consider the assignments (which backtracking would produce) ? { 0 a10, 1 ¬a3, 2 ¬a7, 3 ¬a2, 4 a1} — { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} — { 0 a10, 1 ¬a3, 2 a7, 3 a2, 4 a1} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
  • 36. From DPLL to CDCL Consider the following scenario before and after BCP . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ? Does it make sense to consider the assignments (which backtracking would produce) ? { 0 a10, 1 ¬a3, 2 ¬a7, 3 ¬a2, 4 a1} — { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} — { 0 a10, 1 ¬a3, 2 a7, 3 a2, 4 a1} No, because whenever a10, ¬a3 is assigned, then a1 must not be set to . R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
  • 37. From DPLL to CDCL Consider the following scenario before and after BCP . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} BCP leads to a conflict, but, what is the reason for it ? Do a7 and a2 play any role ? Does it make sense to consider the assignments (which backtracking would produce) ? { 0 a10, 1 ¬a3, 2 ¬a7, 3 ¬a2, 4 a1} — { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1} — { 0 a10, 1 ¬a3, 2 a7, 3 a2, 4 a1} No, because whenever a10, ¬a3 is assigned, then a1 must not be set to . This translates to an additional clause, which can be learnt, i.e., it can be added to the formula (¬a10 ∨ a3 ∨ ¬a1) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 15 / 24
  • 38. From DPLL to CDCL Search Without learnt clause With learnt clause a10 ¬a3 ¬a2 ¬a7a7 a1 a4 a5 a6 ¬a1 ¬a2a2 a2 ¬a1 ¬a3 ¬a2 ¬a7a7 ¬a2a2 a2 a10 ¬a1 ¬a1 ¬a1 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 16 / 24
  • 39. Deriving the clause to be learnt The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never caused by a Decision) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
  • 40. Deriving the clause to be learnt The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never caused by a Decision) To better analyze a conflict we need to look at the implication graph . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} ¬a3 a4 a5 a1 a10 a6 ¬a2 a7 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
  • 41. Deriving the clause to be learnt The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never caused by a Decision) To better analyze a conflict we need to look at the implication graph . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} ¬a3 a4 a5 a1 a10 a6 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
  • 42. Deriving the clause to be learnt The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never caused by a Decision) To better analyze a conflict we need to look at the implication graph . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} ¬a3 a4 a5 a1 a10 a6 Any cut of the graph that separates the conflict from the decision variables represents a possible learnt clause R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
  • 43. Deriving the clause to be learnt The clause to be learnt is derived from the conflict “caused” by BCP (conflict is never caused by a Decision) To better analyze a conflict we need to look at the implication graph . . . (¬a10 ∨ ¬a1 ∨ a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a6) (¬a5 ∨ ¬a6) . . . { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} ¬a3 a4 a5 a1 a10 a6 Any cut of the graph that separates the conflict from the decision variables represents a possible learnt clause In this course we take the clause that contains only one variable of the current decision level R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 17 / 24
  • 44. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 45. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 46. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) (¬a4 ∨ a6) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 47. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) (¬a4 ∨ a6) (¬a5 ∨ ¬a4) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 48. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) (¬a4 ∨ a6) (¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 49. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) (¬a4 ∨ a6) (¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a3 ∨ ¬a1) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 50. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) (¬a4 ∨ a6) (¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a3 ∨ ¬a1) (¬a10 ∨ ¬a1 ∨ a4) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 51. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) (¬a4 ∨ a6) (¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a3 ∨ ¬a1) (¬a10 ∨ ¬a1 ∨ a4) (¬a10 ∨ a3 ∨ ¬a1) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 52. Deriving the clause to be learnt In practice, we use resolution steps to compute the learnt clause: we start from the clause with all literals to ⊥ (conflicting clause) iteratively, we take the clause that propagated the last literal on the trail and we apply resolution we stop when only one literal from the current decision level is left in the clause (¬a5 ∨ ¬a6) (¬a4 ∨ a6) (¬a5 ∨ ¬a4) (a3 ∨ ¬a1 ∨ a5) (¬a4 ∨ a3 ∨ ¬a1) (¬a10 ∨ ¬a1 ∨ a4) (¬a10 ∨ a3 ∨ ¬a1) Trail dl Reason a10 0 (a10) ¬a3 1 Decision a7 2 Decision ¬a2 3 Decision a1 4 Decision a4 4 (¬a10 ∨ ¬a1 ∨ a4) a5 4 (a3 ∨ ¬a1 ∨ a5) a6 4 (¬a4 ∨ a6) { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} We say that (¬a10 ∨ a3 ∨ ¬a1) is the conflict clause and it is the one we learn R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 18 / 24
  • 53. Non-chronological backtracking So far we have been backtracking chronologically, but given our (wrong) assignment { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} and the computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to backtrack to level 3 ? R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
  • 54. Non-chronological backtracking So far we have been backtracking chronologically, but given our (wrong) assignment { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} and the computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to backtrack to level 3 ? The correct level to backtrack to is: “the level that would have propagated ¬a1 if we had the clause (¬a10 ∨ a3 ∨ ¬a1) as part of the original formula” R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
  • 55. Non-chronological backtracking So far we have been backtracking chronologically, but given our (wrong) assignment { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} and the computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to backtrack to level 3 ? The correct level to backtrack to is: “the level that would have propagated ¬a1 if we had the clause (¬a10 ∨ a3 ∨ ¬a1) as part of the original formula” In our case, it is level 1, because assignment { 0 a10, 1 ¬a3} is sufficient to propagate ¬a1 in (¬a10 ∨ a3 ∨ ¬a1) R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
  • 56. Non-chronological backtracking So far we have been backtracking chronologically, but given our (wrong) assignment { 0 a10, 1 ¬a3, 2 a7, 3 ¬a2, 4 a1, 4 a4, 4 a5, 4 a6} and the computed conflict clause (¬a10 ∨ a3 ∨ ¬a1), is it really clever to backtrack to level 3 ? The correct level to backtrack to is: “the level that would have propagated ¬a1 if we had the clause (¬a10 ∨ a3 ∨ ¬a1) as part of the original formula” In our case, it is level 1, because assignment { 0 a10, 1 ¬a3} is sufficient to propagate ¬a1 in (¬a10 ∨ a3 ∨ ¬a1) We say that ¬a1 is the asserting literal as it becomes true by BCP once we have backtracked to the correct decision level R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 19 / 24
  • 57. CDCL: Conflict Driven Clause Learning Search DPLL CDCL no learning conflict-driven learning chronological backtracking non-chronological backtracking ¬a3 a1 ¬a2 a2 ¬a3 a3 ¬a3 a4 a1 ¬a2 a3 R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 20 / 24
  • 58. The CDCL Procedure dl = 0; trail = { }; // Decision level, assignment while ( true ) if ( BCP( ) == conflict ) // Do BCP until possible if ( dl == 0 ) return unsat; // Unresolvable conflict C, dl = AnalyzeConflict( ); // Compute conf. clause, and dec. level AddClause( C ); // Add C to clause database BacktrackTo( dl ); // Backtracking (shrinks trail) else if ( “all variables assigned” ) return sat; // trail holds satisfying assignment l = Decision( ); // Do another decision trail = trail ∪ {l} dl = dl + 1; // Increase decision level R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 21 / 24
  • 59. The CDCL Procedure conflict no confl. assign var conflict at level 0 left no vars SATBCP Decision AnalyzeConflict UNSAT AddClause BacktrackTo R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 22 / 24
  • 60. Other things which we did not see Watched Literals: technique to efficiently discover which clauses become unsat Decision heuristics: how do we choose the right variable ? And which polarity ? ( , ⊥). Landmark strategy is VSIDS heuristic Clause removal: adding too many clauses negatively impacts performance, need mechanisms to remove learnts Restarts: start the search from scratch, but retaining learnts many many other heuristics discovered every year R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 23 / 24
  • 61. Exercise Consider the following clause set and assignment (¬a1 ∨ a2) (¬a1 ∨ a3 ∨ a9) (¬a2 ∨ ¬a3 ∨ a4) (¬a4 ∨ a5 ∨ a10) (¬a4 ∨ a6 ∨ a11) (¬a5 ∨ ¬a6) (a1 ∨ a7 ∨ ¬a12) (a1 ∨ a8) (¬a7 ∨ ¬a8 ∨ ¬a13) . . . { 1 ¬a9, 2 a12, 2 a13, 3 ¬a10, 3 ¬a11, . . . , 6 a1} Find the correct conflict clause Find the correct decision level to backtrack R. Bruttomesso (SMT) SAT-Solvers 3 Novembre 2011 24 / 24