Upload
mayten
View
77
Download
0
Embed Size (px)
DESCRIPTION
Introduction to MiniSat v1.14. Presented by Yunho Kim Provable Software Lab, KAIST. Overview VSIDS Decision Heuristic Conflict Clause Analysis Example. Contents. MiniSat is a fast SAT solver developed by Niklas Eén and Niklas Sörensson - PowerPoint PPT Presentation
Citation preview
Introduction to MiniSat v1.14
Presented by Yunho KimProvable Software Lab, KAIST
Contents• Overview
• VSIDS Decision Heuristic
• Conflict Clause Analysis
• Example
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 2/33
Overview• MiniSat is a fast SAT solver developed by Niklas
Eén and Niklas Sörensson– MiniSat won all industrial categories in SAT 2005 compe-
tition– MiniSat won SAT-Race 2006
• MiniSat is simple and well-documented– Well-defined interface for general use– Helpful implementation documents and comments– Minimal but efficient heuristic
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 3/33
Overview• CNF is a logical AND of one or more clauses
• Clause is a logical OR of one or more literals
• Literal is either the positive or the negative vari-able
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 4/33
(x2∨x4∨x5∨x6) ∧ (x0∨-x1∨x6) ∧ (-x2∨-x3∨-x4)
(x2∨x4∨x5∨x6), (x0∨-x1∨x6), (-x2∨-x3∨-x4)
Variables: x0, x1, x2, x3, x4, x5, x6Literals: x0, -x1, x2, -x2, -x3, x4, -x4, x5, x6 Definition from Lintao Zhang and Sharad malik
“The Quest for Efficient Boolean Satisfiability Solvers”
Overview• Unit clause is a clause in which all but one of literals is as-
signed to False• Unit literal is the unassigned literal in a unit clause
– (x0) is a unit clause and ‘x0’ is a unit literal– (-x0∨x1) is a unit clause since x0 has to be True– (-x2∨-x3∨-x4) can be a unit clause if the current assignment is
that x3 and x4 are True• Boolean Constrain Propagation(BCP) is the process of as-
signing the True value to all unit literalsMiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 5/33
……(x0)∧ (-x0∨x1)∧ (-x2∨-x3∨-x4)∧……
Overview/* overall structure of Minisat solve procedure */Solve(){
while(true){boolean_constraint_propagation();if(no_conflict){if(no_unassigned_variable) return SAT;decision_level++;make_decision();}else{if (no_dicisions_made) return UNSAT;analyze_conflict();undo_assignments();add_conflict_clause();}}
}
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 6/33
VSIDS Decision Heuristic• Variable State Independent Decaying Sum(VSIDS)
– decision heuristic to determine what variable will be as-signed next
– decision is independent from the current assignment of each variable
• VSIDS makes decisions based on activity– Activity is a literal occurrence count with higher weight
on the more recently added clauses
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 7/33
activity description from Lintao Zhang and Sharad malik “The Quest for Efficient Boolean Satisfiability Solvers”
VSIDS Decision Heuristic• VSIDS is proposed by chaff first.• Initially, the score for each literal is the occur-
rence on the given input CNF instance
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 8/33
Initial con-straints(x1∨x4) ∧(x1∨-x3∨-x5) ∧(x1∨x5∨x7) ∧(x2∨x8) ∧(-x7∨-x3∨x6) ∧(-x7∨x5∨-x6) ∧(x7∨x5∨-x9)
Score Literal3 x1, x5
2 -x3, x7, -x7
1 x2, x4, -x5, x6, -x6, x8, -x9
VSIDS Decision Heuristic• When a clause is added to DB, the related coun-
ters are incremented– Conflict analysis adds a new learnt clause to DB
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 9/33
(x1∨x4) ∧(x1∨-x3∨-x5) ∧(x1∨x5∨x7) ∧(x2∨x8) ∧(-x7∨-x3∨x6) ∧(-x7∨x5∨-x6) ∧(x7∨x5∨-x9) ∧(x7∨x6∨-x9)
Score Literal3 x1, x5, x7
2 -x3, x7, -x7, x6, -x9
1 x2, x4, -x5, x6, -x6, x8, -x9
VSIDS Decision Heuristic• Periodically, the scores are divided by a constant
factor– In this example, a constant factor is 2
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 10/33
(x1∨x4) ∧(x1∨-x3∨-x5) ∧(x1∨x5∨x7) ∧(x2∨x8) ∧(-x7∨-x3∨x6) ∧(-x7∨x5∨-x6) ∧(x7∨x5∨-x9) ∧(x7∨x6∨-x9)
Score Literal1.5 x1, x5, x7
1 -x3, -x7, x6, -x9
0.5 x2, x4, -x5, -x6, x8
VSIDS Decision Heuristic• Literals on more recently added clause have
higher weighted scores
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 11/33
(x1∨x4) ∧(x1∨-x3∨-x5) ∧(x1∨x5∨x7) ∧(x2∨x8) ∧(-x7∨-x3∨x6) ∧(-x7∨x5∨-x6) ∧(x7∨x5∨-x9) ∧(x7∨x6∨-x9) ∧(-x9∨x8)
Score Literal2 -x9
1.5 x1, x5, x7, x8
1 -x3, -x7, x6, -x9
0.5 x2, x4, -x5, -x6, x8
VSIDS Decision Heuristic• VSIDS in MiniSat is slightly different from chaff
– MiniSat does not consider polarity– Before adding the first learnt clause, all the scores are 0– All the scores are decaying by 5% when a conflict occurs– The activities of all variables occurring in some clause
used in the conflict analysis are increased
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 12/33
Conflict Clause Analysis• A conflict happens when one clause is fal-
sified by unit propagation
• Analyze the conflicting clause to infer a clause– (-x3∨-x2∨-x1) is conflicting clause
• The inferred clause is a new knowledge– A new learnt clause is added to constraints
Assume x4 is False(x1∨x4) ∧(-x1∨x2) ∧(-x2∨x3) ∧(-x3∨-x2∨-x1) Falsi-fied!Omitted clauses
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 13/33
Conflict Clause Analysis• Learnt clauses are inferred by conflict
analysis
• They help prune future parts of the search space– Assigning False to x4 is the casual of conflict– Adding (x4) to constraints prohibit conflict from
–x4
• Learnt clauses actually drive backtracking
(x1∨x4) ∧(-x1∨x2) ∧(-x2∨x3) ∧(-x3∨-x2∨-x1) ∧omitted clauses ∧(x4) learnt clause
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 14/33
Conflict Clause Analysis/* conflict analysis algorithm */Analyze_conflict(){
cl = find_confclicting_clause();/* Loop until cl is falsified and zero or one propagated literals in current decision level are remained */While(!stop_criterion_met(cl)){
lit = choose_literal(cl); /* select the last propagated literal */
Var = variable_of_literal(lit);ante = antecedent(var);cl = resolve(cl, ante, var);
}add_clause_to_database(cl);/* backtrack level is the lowest decision level for which the learnt clause is unit clause */back_dl = clause_asserting_level(cl);return back_dl;
}Algorithm from Lintao Zhang and Sharad malik “The Quest for Efficient Boolean Satisfiability Solvers”MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 15/33
Conflict Clause AnalysisAssignments antecedente=F assumptionf=F -f∨eg=F -g∨fh=F -h∨ga=T assumptionb=T b∨-a∨ec=T c∨e∨f∨-b d=T d∨-b∨h
e=F
a=T
-b∨-c∨-dConflict
DLevel=2
DLevel=1
Example slides are from CMU 15-414 course ppt
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 16/33
Conflict Clause Analysis
e=F
a=T
-b∨-c∨-d
Assignments antecedente=F assumptionf=F -f∨eg=F -g∨fh=F -h∨ga=T assumptionb=T b∨-a∨ec=T c∨e∨f∨-b d=T d∨-b∨h
DLevel=2
DLevel=1
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 17/33
Conflict Clause Analysis
e=F
a=T
-b∨-c∨-d-b∨-c∨h
Assignments antecedente=F assumptionf=F -f∨eg=F -g∨fh=F -h∨ga=T assumptionb=T b∨-a∨ec=T c∨e∨f∨-b d=T d∨-b∨h
DLevel=2
DLevel=1
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 18/33
Conflict Clause Analysis
e=F
a=T
-b∨-c∨-d-b∨-c∨h
Assignments antecedente=F assumptionf=F -f∨eg=F -g∨fh=F -h∨ga=T assumptionb=T b∨-a∨ec=T c∨e∨f∨-b d=T d∨-b∨h
DLevel=2
DLevel=1
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 19/33
Conflict Clause Analysis
e=F
a=T
-b∨-c∨-d
-b∨e∨f∨h learnt clause-b∨-c∨h
Assignments antecedente=F assumptionf=F -f∨eg=F -g∨fh=F -h∨ga=T assumptionb=T b∨-a∨ec=T c∨e∨f∨-b d=T d∨-b∨h
DLevel=2
DLevel=1
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 20/33
Conflict Clause Analysis
e=F
a=T
-b∨-c∨-d-b∨-c∨h
b=F
-b∨e∨f∨h
Assignments antecedente=F assumptionf=F -f∨eg=F -g∨fh=F -h∨gb=F -b∨e∨f∨h… …
DLevel=1
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 21/33
Example• Left side shows
status of clauses
• Green literals are True, reds are False and yellows are Undefined
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 22/33
Example• Right-up side
shows variable data
• Reason indicates what clause the variable propa-gated from
• Level is a deci-sion level
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 23/33
Example• Right-down shows
trail, that is an assignment stack
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 24/33
Example
• First assign False to x7MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 25/33
Example
• BCP from –x7 MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 26/33
Example
• Second assign False to x3MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 27/33
Example
• C0 is a conflicting clause. Analyze itMiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 28/33
Example
• First resolve last propagated literal• c0 and c2 are resolved w.r.t x0MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 29/33
Activity is changed
Example
• A new learnt clause is (-x2∨x4∨x6∨x7)MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 30/33
Example
• Adds a learnt clause to DB and go on searchMiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 31/33
Activities are de-cayed for next added clause
Example
• Finally we find a model, that is, satisfying assign-ment MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 32/33
References• An Extensible SAT-solver
by Niklas Een and Niklas Sörensson in SAT 2003
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 33/33