INSTITUTE FOR THEORETICAL COMPUTER SCIENCE
Practical SAT SolvingLecture 6
Carsten Sinz, Tomáš Balyo, Markus Iser | May 30, 2016
KIT – University of the State of Baden-Wuerttemberg and
National Laboratory of the Helmholtz Association
www.kit.edu
Review: Last Week
Details on implementing DPLLDecision HeuristicsRestartsImplementing Unit Propagation
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 2/23
Lecture Outline: Today
More Details on implementing DPLLPhase Saving
Towards CDCLReview: ResolutionNon-Chronological Backtracking (Backjumping)Implication GraphClause Learing
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 3/23
Phase Saving
First implemented in RSAT (2006)http://reasoning.cs.ucla.edu/rsat/
Observeration: Frequent Restartsdecrease performance on some SATinstances
Goal: Cache partial solutions to subsets ofthe formula and reuse them after a restart
Idea: Remember last assignment of eachvariable and use it first in branching
Result: Phase Saving stabilizes positiveeffect of restarts; best results incombination with non-chronologicalbacktracking (later in this lecture)
A B
C�
F
Example: A and B aresatisfied, search works oncomponent C
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 4/23
Review: Resolution
General deduction rule for clauses: (A ∨ l), (B ∨ l) =⇒ (A ∨ B)
Can be used to extend DPLL Search by adding resolved clauses tothe input formula
Special Case: Unit Resolution (central part of DPLL Search)
Resolution Operator: C ◦l D denotes the resolvent of clauses C andD on literal l
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 5/23
Terminology
TrailThe partial assignment that represents the current path in the search tree
Decision LevelStarting with decision level 0 every branching step increases the decisionlevel by 1. Note: Unit-propagation does not change the decision level.
Conflicting ClauseClause with all literals assigned to 0 under the current trail (empty underunit resolution)
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 6/23
DPLL: Chronological Backtracking
A
B
C
X
[Y=1]
[Z]�
[Z]�
X
� �
[C=1]
X
� �
[B=1]
1 0
10
1 0
1 0 1 0 1 0
F = {{A,B},{B,C},{¬A,¬X ,Y},{¬A,X ,Z},{¬A,¬Y ,Z},{¬A,X ,¬Z},{¬A,¬Y ,¬Z}}
Trail: A,B,C,X ,Y ,Z
Conflicting Clause:{¬A,¬Y ,¬Z}
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 7/23
DPLL: Chronological Backtracking
A
B
C
X
[Y=1]
[Z]�
[Z]�
X
� �
[C=1]
X
� �
[B=1]
1 0
10
1 0
1 0 1 0 1 0
F = {{A,B},{B,C},{¬A,¬X ,Y},{¬A,X ,Z},{¬A,¬Y ,Z},{¬A,X ,¬Z},{¬A,¬Y ,¬Z}}
Trail: A,B,C,¬X ,Z
Conflicting Clause:{¬A,X ,¬Z}
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 7/23
Non-Chronological Backtracking
A
B
C
X
[Y=1]
[Z=1, Z=0]�
[Z=1, Z=0]�
[ B = 1 ]
1 0
1
1
1 0
The first two conflicting clauses{¬A,¬Y ,¬Z}, {¬A,X ,¬Z} containonly a fraction of the assignments onthe trail
Assignments to B and C obviously playno role in the present conflicting stateand we could immediately backtrack toflip the assignment to A
How to find out which assignments onthe trail are relevant for the actualconflict?
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 8/23
Implication Graph
Implication Graph
The Implication Graph GI = (V ∪ {�},E) (for a given formula F and atrail T ending in a conflict) is a directed acyclic graph (DAG) where eachvertex v ∈ V is a tuple (x = b, d) consisting of an assignment x = b onthe trail and its decision level d . There is an additional vertex�(with noassignment and decision level) indicating a conflicting assignment. Foreach clause C = (l1, . . . , lk , u) that became unit and caused a unitpropagation of u there are edges e ∈ E connecting the assignment ofliteral li to the assignment of unit u. Similarly, for a clause C, in which allliterals are assigned false, there are edged from each literal in C to�.
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 9/23
Example: Implication GraphThe graph shows the implication graph for the conflicting state under thetrail A,B,C,X ,Y ,Z . The edge labels denote clauses, node labelsindicate an assignment and its decision level.
0A = 1
1B = 1
2C = 1
3X = 1
3Y = 1
3Z = 1 �
3 57
57
37
F = {{A,B}, =: 1
{B,C}, =: 2
{¬A,¬X ,Y}, =: 3
{¬A,X ,Z}, =: 4
{¬A,¬Y ,Z}, =: 5
{¬A,X ,¬Z}, =: 6
{¬A,¬Y ,¬Z}} =: 7
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 10/23
Implication GraphIn the implication graph
the sink is always the conflicting assignment
the sources are the desicion literals that take part in the conflict
we can use it to detect the reasons for a conflict
0A = 1
1B = 1
2C = 1
3X = 1
3Y = 1
3Z = 1 �
3 57
57
37
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 11/23
Implication Graph: Implementation
Trail with conflicting clause {¬A,¬Y ,¬Z}:
A
B
C
X
Y
Z
null
null
null
null
{¬A,¬X ,Y}
{¬A,¬Y ,Z}for each assignment store a pointer tothe reason clause, the one that hasbecome unit
decision literals store a null pointer
with the clause pointers and the trail wecan trace all the implications back totheir sources
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 12/23
Clause Learing
Back-jumping does not fully avoid the occurrence of the same conflict, thesame (partial) assignments may generate the same conflict in anotherpart of the search tree.
Idea: store no-good constraint like in CSP (No-Good-Learning)
Great in SAT: no-good is clause!
generate conflict clauses and add them to CNF
the literals contributing to a conflict form a partial assignment and itsnegation is a clause (implied by the original CNF)
adding this clause avoids the conflicting partial assignment
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 13/23
Conflict Analysis: ExampleIn the first conflict of the previous example we can learn the clause{¬A,¬X} in order to prevent the solver to pick the same partialassignment again. This can also be expressed as the following sequenceof resolution steps along the edges in the implication graph:C = (7 ◦Z 5) ◦Y 3
0A = 1
1B = 1
2C = 1
3X = 1
3Y = 1
3Z = 1 �
3 57
57
37
F = {{A,B}, =: 1
{B,C}, =: 2
{¬A,¬X ,Y}, =: 3
{¬A,X ,Z}, =: 4
{¬A,¬Y ,Z}, =: 5
{¬A,X ,¬Z}, =: 6
{¬A,¬Y ,¬Z}} =: 7
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 14/23
Confict Clause
Trail with conflicting clause{¬A,¬Y ,¬Z}:
A
B
C
X
Y
Z
null
null
null
null
{¬A,¬X ,Y}
{¬A,¬Y ,Z}
Given the trail the conflict clause (learnedclause) can be generated by subsequentresolution, starting with the conflict clause{¬A,¬Y ,¬Z} and the first reason clause onthe trail {¬A,¬Y ,Z} we can resolve the in-termediate clause {¬A,¬Y}. An additionalresolution step results in the conflict clauseC = {¬A,¬X}.
Properties of conflict clause C:
F |= C
F ∪ ¬C `UP ⊥D /∈ F , ∀D ⊆ C
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 15/23
Unique Implication Points (UIP)In general: several possibilities to learn a clause from an implicationgraph. A learned clause can be resolved for every cut in the theimplication graph.
Graphic from Beame et al.: “Understandingthe Power of Clause Learning”
UIP is a dominator in theimplication graph
A node v is a dominator(for�), if all paths fromthe last decision to�contain v
FirstUIP: “first”dominator (seen fromconflict side)
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 16/23
Common Implementation (1UIP LearningScheme)
FirstUIP-clause: resolve conflicting clause and reason clauses untilonly a single literal of the current decision level remains
Advantage: Stopping at a UIP always leads to an asserting clause.Algorithm becomes easier: backtrack until clause becomes asserting
Undo all decisions until that level where the learned clause becomesasserting. The assertion level is the second highest level in a conflictclause.
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 17/23
Backtracking with Clause LearningIn our previous example the conflict clause (1UIP) with backtracking toassertion level changes the decision tree like this:
A
B
C
X
[Y=1]
[Z=1, Z=0]�
[Y=0]
[X=0]
[Z=1, Z=0]�
[ B = 1 ]
1 1 0
1
1
1
F = {{A,B}, {B,C},{¬A,¬X ,Y},{¬A,X ,Z},{¬A,¬Y ,Z},{¬A,X ,¬Z},{¬A,¬Y ,¬Z}}
Trail: A,B,C,X ,Y ,ZConflicting Clause: {¬A,¬Y ,¬Z}Conflict Clause (1UIP): {¬A,¬Y}
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 18/23
Backtracking with Clause LearningIn our previous example the conflict clause (1UIP) with backtracking toassertion level changes the decision tree like this:
A
B
C
X
[Y=1]
[Z=1, Z=0]�
[Y=0]
[X=0]
[Z=1, Z=0]�
[ B = 1 ]
1 1 0
1
1
1
F = {{A,B}, {B,C},{¬A,¬X ,Y},{¬A,X ,Z},{¬A,¬Y ,Z},{¬A,X ,¬Z},{¬A,¬Y ,¬Z}{¬A,¬Y}}
Trail: A,¬Y ,¬X ,ZConflicting Clause: {¬A,X ,¬Z}
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 18/23
Clause Database Maintenance
Without restrictions the clause database grows exponentially. Besides therisk of running out of memory this also slows down unit propagation.Clause database is regularly cleaned up. Quality measures for clauses(e.g. clause size, clause activity, LBD value)
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 19/23
CDCL Algorithm
Data: Formula FResult: SAT / UNSAT
1 dl ← 02 V ← ∅3 if unit propagation (F, V) == CONFLICT then4 return UNSAT
5 while not all variables assigned do6 (x , l)← pick branching literal7 dl ← dl + 18 V ← ∪(x , l)9 if unit propagation (F, V) == CONFLICT then
10 bl← analyze conflict11 if bl < 0 then12 return UNSAT
13 else14 backtrack to bl15 dl← bl
16 return SAT
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 20/23
Resolution Proof
With Clause Learning a complete resolution refutation can be derived withCDCL
proof can serve as a certificate for validating the correctness of theSAT solver
resolution refutations based on clause learning find key practicalapplications (e.g. model checking)
can help to determine minimally unsatisfiable subsets in anunsatisfiable formula
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 21/23
NEWS: Boolean Pythagorean triplesproblem was recently cracked using SATtechnology
The problem asks whether it is possible to colour each positive integereither red or blue, so that no trio of integers a, b and c that satisfyPythagoras famous equation a2 + b2 = c2 are all the same colour.
Solutions exist for numbers up to 7824
Proof that from 7825 onwards there is no such coloring
"Largest math proof" ever built (200 TB)
Paper will be presented at the SAT conference 2016.
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 22/23
References
Phase Saving: “A Lightweight Component Caching Scheme forSatisfiability Solvers” (Pipatsrisawat and Darwiche)
Clause Learning: “Understanding the Power of Clause Learning”(Beame et al.)
Two-Coloring of Pythagorean Triplets:http://www.nature.com/news/
two-hundred-terabyte-maths-proof-is-largest-ever-1.
19990
Carsten Sinz, Tomáš Balyo, Markus Iser – SAT Solving May 30, 2016 23/23