cdcl sat solvers & sat-based problem solvinghaozheng/teach/psv/slides/...cdcl sat solvers &...
TRANSCRIPT
-
CDCL SAT Solvers & SAT-Based Problem Solving
Joao Marques-Silva1,2 & Mikolas Janota2
1University College Dublin, Ireland
2IST/INESC-ID, Lisbon, Portugal
SAT/SMT Summer School 2013
Aalto University, Espoo, Finland
-
The Success of SAT
• Well-known NP-complete decision problem [C71]• In practice, SAT is a success story of Computer Science
– Hundreds (even more?) of practical applications
-
Part I
CDCL SAT Solvers
-
Outline
Basic Definitions
DPLL Solvers
CDCL Solvers
What Next in CDCL Solvers?
-
Outline
Basic Definitions
DPLL Solvers
CDCL Solvers
What Next in CDCL Solvers?
-
Preliminaries
• Variables: w , x , y , z , a, b, c , . . .
• Literals: w , x̄ , ȳ , a, . . . , but also ¬w ,¬y , . . .
• Clauses: disjunction of literals or set of literals
• Formula: conjunction of clauses or set of clauses
• Model (satisfying assignment): partial/total mapping fromvariables to {0, 1}
• Formula can be SAT/UNSAT
• Example:
F , (r) ^ (r̄ _ s) ^ (w̄ _ a) ^ (x̄ _ b) ^ (ȳ _ z̄ _ c) ^ (b̄ _ c̄ _ d)
– Example models:I {r , s, a, b, c, d}I {r , s, x̄ , y , w̄ , z , ā, b, c, d}
-
Preliminaries
• Variables: w , x , y , z , a, b, c , . . .
• Literals: w , x̄ , ȳ , a, . . . , but also ¬w ,¬y , . . .
• Clauses: disjunction of literals or set of literals
• Formula: conjunction of clauses or set of clauses
• Model (satisfying assignment): partial/total mapping fromvariables to {0, 1}
• Formula can be SAT/UNSAT
• Example:
F , (r) ^ (r̄ _ s) ^ (w̄ _ a) ^ (x̄ _ b) ^ (ȳ _ z̄ _ c) ^ (b̄ _ c̄ _ d)
– Example models:I {r , s, a, b, c, d}I {r , s, x̄ , y , w̄ , z , ā, b, c, d}
-
Resolution
• Resolution rule: [DP60,R65]
(↵ _ x) (� _ x̄)(↵ _ �)
– Complete proof system for propositional logic
– Extensively used with (CDCL) SAT solvers
• Self-subsuming resolution (with ↵0 ✓ ↵): [e.g. SP04,EB05]
(↵ _ x) (↵0 _ x̄)(↵)
– (↵) subsumes (↵ _ x)
-
Resolution
• Resolution rule: [DP60,R65]
(↵ _ x) (� _ x̄)(↵ _ �)
– Complete proof system for propositional logic
(x _ a) (x̄ _ a) (ȳ _ ā) (y _ ā)
(a) (ā)
?
– Extensively used with (CDCL) SAT solvers
• Self-subsuming resolution (with ↵0 ✓ ↵): [e.g. SP04,EB05]
(↵ _ x) (↵0 _ x̄)(↵)
– (↵) subsumes (↵ _ x)
-
Resolution
• Resolution rule: [DP60,R65]
(↵ _ x) (� _ x̄)(↵ _ �)
– Complete proof system for propositional logic
(x _ a) (x̄ _ a) (ȳ _ ā) (y _ ā)
(a) (ā)
?
– Extensively used with (CDCL) SAT solvers
• Self-subsuming resolution (with ↵0 ✓ ↵): [e.g. SP04,EB05]
(↵ _ x) (↵0 _ x̄)(↵)
– (↵) subsumes (↵ _ x)
-
Unit Propagation
F = (r) ^ (r̄ _ s)^
(w̄ _ a) ^ (x̄ _ ā _ b)
(ȳ _ z̄ _ c) ^ (b̄ _ c̄ _ d)
• Decisions / Variable Branchings:w = 1, x = 1, y = 1, z = 1
• Additional definitions:– Antecedent (or reason) of an implied assignment
I (b̄ _ c̄ _ d) for d
– Associate assignment with decision levelsI w = 1@1, x = 1@2, y = 1@3, z = 1@4I r = 1@0, d = 1@4, ...
-
Unit Propagation
F = (r) ^ (r̄ _ s)^
(w̄ _ a) ^ (x̄ _ ā _ b)
(ȳ _ z̄ _ c) ^ (b̄ _ c̄ _ d)
• Decisions / Variable Branchings:w = 1, x = 1, y = 1, z = 1
• Additional definitions:– Antecedent (or reason) of an implied assignment
I (b̄ _ c̄ _ d) for d
– Associate assignment with decision levelsI w = 1@1, x = 1@2, y = 1@3, z = 1@4I r = 1@0, d = 1@4, ...
-
Unit Propagation
F = (r) ^ (r̄ _ s)^
(w̄ _ a) ^ (x̄ _ ā _ b)
(ȳ _ z̄ _ c) ^ (b̄ _ c̄ _ d)
• Decisions / Variable Branchings:w = 1, x = 1, y = 1, z = 1
Level Dec. Unit Prop.
0
1
2
3
4
;
w
x
y
z
a
b
c d
r s
• Additional definitions:– Antecedent (or reason) of an implied assignment
I (b̄ _ c̄ _ d) for d
– Associate assignment with decision levelsI w = 1@1, x = 1@2, y = 1@3, z = 1@4I r = 1@0, d = 1@4, ...
-
Unit Propagation
F = (r) ^ (r̄ _ s)^
(w̄ _ a) ^ (x̄ _ ā _ b)
(ȳ _ z̄ _ c) ^ (b̄ _ c̄ _ d)
• Decisions / Variable Branchings:w = 1, x = 1, y = 1, z = 1
Level Dec. Unit Prop.
0
1
2
3
4
;
w
x
y
z
a
b
c d
r s
• Additional definitions:– Antecedent (or reason) of an implied assignment
I (b̄ _ c̄ _ d) for d
– Associate assignment with decision levelsI w = 1@1, x = 1@2, y = 1@3, z = 1@4I r = 1@0, d = 1@4, ...
-
Outline
Basic Definitions
DPLL Solvers
CDCL Solvers
What Next in CDCL Solvers?
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
F = (x_y)^(a_b)^(ā_b)^(a_b̄)^(ā_b̄)
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
F = (x_y)^(a_b)^(ā_b)^(a_b̄)^(ā_b̄)
Level Dec. Unit Prop.
0
1
2
3
;
x
y
a b ?
a ā
y
a ā
ȳ
x
a ā
x̄
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
F = (x_y)^(a_b)^(ā_b)^(a_b̄)^(ā_b̄)
Level Dec. Unit Prop.
0
1
2
3
;
x
y
ā b̄ ?
a ā
y
a ā
ȳ
x
a ā
x̄
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
F = (x_y)^(a_b)^(ā_b)^(a_b̄)^(ā_b̄)
Level Dec. Unit Prop.
0
1
2
3
;
x
ȳ
a b ?
a ā
y
a ā
ȳ
x
a ā
x̄
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
F = (x_y)^(a_b)^(ā_b)^(a_b̄)^(ā_b̄)
Level Dec. Unit Prop.
0
1
2
3
;
x
ȳ
ā b̄ ?
a ā
y
a ā
ȳ
x
a ā
x̄
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
F = (x_y)^(a_b)^(ā_b)^(a_b̄)^(ā_b̄)
Level Dec. Unit Prop.
0
1
2
;
x̄
a
y
b ?
a ā
y
a ā
ȳ
x
a ā
x̄
-
The DPLL Algorithm
Assign valueto variable
Unassignedvariables ?
Unit propagation
Conflict ?
Can undodecision ?
Backtrack &flip variable
Unsatisfiable
SatisfiableY
N
Y
N
Y
N
• Optional: pure literal rule
F = (x_y)^(a_b)^(ā_b)^(a_b̄)^(ā_b̄)
Level Dec. Unit Prop.
0
1
2
;
x̄
ā
y
b̄ ?
a ā
y
a ā
ȳ
x
a ā
x̄
-
Outline
Basic Definitions
DPLL Solvers
CDCL Solvers
What Next in CDCL Solvers?
-
What is a CDCL SAT Solver?
• Extend DPLL SAT solver with: [DP60,DLL62]– Clause learning & non-chronological backtracking [MSS96,BS97,Z97]
I Exploit UIPs [MSS96,SSS12]I Minimize learned clauses [SB09,VG09]I Opportunistically delete clauses [MSS96,MSS99,GN02]
– Search restarts [GSK98,BMS00,H07,B08]
– Lazy data structuresI Watched literals [MMZZM01]
– Conflict-guided branchingI Lightweight branching heuristics [MMZZM01]I Phase saving [PD07]
– ...
-
How Significant are CDCL SAT Solvers?
0
200
400
600
800
1000
1200
0 20 40 60 80 100 120 140 160 180 200
CPU
Tim
e (in
seco
nds)
Number of problems solved
Results of the SAT competition/race winners on the SAT 2009 application benchmarks, 20mn timeout
Limmat (2002)Zchaff (2002)Berkmin (2002)Forklift (2003)Siege (2003)Zchaff (2004)SatELite (2005)Minisat 2 (2006)Picosat (2007)Rsat (2007)Minisat 2.1 (2008)Precosat (2009)Glucose (2009)Clasp (2009)Cryptominisat (2010)Lingeling (2010)Minisat 2.2 (2010)Glucose 2 (2011)Glueminisat (2011)Contrasat (2011)Lingeling 587f (2011)
GRASP
DPLL
? ?
-
Outline
Basic Definitions
DPLL Solvers
CDCL SolversClause Learning, UIPs & MinimizationSearch Restarts & Lazy Data Structures
What Next in CDCL Solvers?
-
Clause Learning
Level Dec. Unit Prop.
0
1
2
3
;
xx
y
zz a
b
?
• Analyze conflict
– Reasons: x and zI Decision variable & literals assigned at lower decision levels
– Create new clause: (x̄ _ z̄)
• Can relate clause learning with resolution
– Learned clauses result from (selected) resolution operations
-
Clause Learning
Level Dec. Unit Prop.
0
1
2
3
;
xx
y
zz a
b
?
(ā _ b̄) (z̄ _ b) (x̄ _ z̄ _ a)
(ā _ z̄)
(x̄ _ z̄)
• Analyze conflict– Reasons: x and z
I Decision variable & literals assigned at lower decision levels
– Create new clause: (x̄ _ z̄)
• Can relate clause learning with resolution
– Learned clauses result from (selected) resolution operations
ab -> false = !(ab) + false = !a + !b
z -> b = !z + b
xz -> a. =. !(xz) + a =. !x + !z + a
-
Clause Learning – After Bracktracking
Level Dec. Unit Prop.
0
1
2
3
;
x
y
zz aa
bb
??
z
• Clause (x̄ _ z̄) is asserting at decision level 1
• Learned clauses are always asserting [MSS96,MSS99]• Backtracking di↵ers from plain DPLL:
– Always bactrack after a conflict [MMZZM01]
-
Clause Learning – After Bracktracking
Level Dec. Unit Prop.
0
1
2
3
;
x
y
zz aa
bb
??
z
• Clause (x̄ _ z̄) is asserting at decision level 1
• Learned clauses are always asserting [MSS96,MSS99]• Backtracking di↵ers from plain DPLL:
– Always bactrack after a conflict [MMZZM01]
-
Clause Learning – After Bracktracking
Level Dec. Unit Prop.
0
1
2
3
;
x
y
zz aa
bb
??
z
Level Dec. Unit Prop.
0
1
;
x z̄
• Clause (x̄ _ z̄) is asserting at decision level 1
• Learned clauses are always asserting [MSS96,MSS99]• Backtracking di↵ers from plain DPLL:
– Always bactrack after a conflict [MMZZM01]
-
Clause Learning – After Bracktracking
Level Dec. Unit Prop.
0
1
2
3
;
x
y
zz aa
bb
??
z
Level Dec. Unit Prop.
0
1
;
x z̄
• Clause (x̄ _ z̄) is asserting at decision level 1
• Learned clauses are always asserting [MSS96,MSS99]• Backtracking di↵ers from plain DPLL:
– Always bactrack after a conflict [MMZZM01]