introduction to minisat v1.14
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 PresentationTRANSCRIPT
![Page 1: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/1.jpg)
Introduction to MiniSat v1.14
Presented by Yunho KimProvable Software Lab, KAIST
![Page 2: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/2.jpg)
Contents• Overview
• VSIDS Decision Heuristic
• Conflict Clause Analysis
• Example
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 2/33
![Page 3: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/3.jpg)
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
![Page 4: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/4.jpg)
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”
![Page 5: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/5.jpg)
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)∧……
![Page 6: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/6.jpg)
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
![Page 7: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/7.jpg)
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”
![Page 8: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/8.jpg)
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
![Page 9: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/9.jpg)
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
![Page 10: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/10.jpg)
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
![Page 11: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/11.jpg)
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
![Page 12: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/12.jpg)
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
![Page 13: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/13.jpg)
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
![Page 14: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/14.jpg)
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
![Page 15: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/15.jpg)
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
![Page 16: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/16.jpg)
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
![Page 17: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/17.jpg)
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
![Page 18: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/18.jpg)
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
![Page 19: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/19.jpg)
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
![Page 20: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/20.jpg)
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
![Page 21: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/21.jpg)
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
![Page 22: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/22.jpg)
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
![Page 23: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/23.jpg)
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
![Page 24: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/24.jpg)
Example• Right-down shows
trail, that is an assignment stack
MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 24/33
![Page 25: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/25.jpg)
Example
• First assign False to x7MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 25/33
![Page 26: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/26.jpg)
Example
• BCP from –x7 MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 26/33
![Page 27: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/27.jpg)
Example
• Second assign False to x3MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 27/33
![Page 28: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/28.jpg)
Example
• C0 is a conflicting clause. Analyze itMiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 28/33
![Page 29: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/29.jpg)
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
![Page 30: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/30.jpg)
Example
• A new learnt clause is (-x2∨x4∨x6∨x7)MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 30/33
![Page 31: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/31.jpg)
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
![Page 32: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/32.jpg)
Example
• Finally we find a model, that is, satisfying assign-ment MiniSat v1.14, Yunho Kim, Provable Software Lab, KAIST 32/33
![Page 33: Introduction to MiniSat v1.14](https://reader033.vdocument.in/reader033/viewer/2022061610/56816108550346895dd051a6/html5/thumbnails/33.jpg)
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