Mark Worth
description
Transcript of Mark Worth
Mark Worth
The Satisfiability Problem and the MiniSat Solver
1
– What is the Satisfiability problem?
– The MiniSat solver
– Algorithms used by solvers
2
The Satisfiability Problem (SAT)
– A boolean function (X1 + X2 + ¬X3)^(¬X1 + X2 + ¬X3)
– Are there assignments to X1, X2, and X3 thatmake the function TRUE?
– If there are, the function is Satisfiable.
3
(¬X1 + X2) ^ (X1 + X3)
4
(X1 + X2 + ¬X3)^(¬X1 + X2 + ¬X3)
– One assignment is X1=T, X2=F, X3=F
– This function is Satisfiable
5
SAT problems can come in – Conjunctive Normal Form(CNF) or – Disjunctive Normal Form(DNF)
6
(X1 + X2 + ¬X3)^(¬X1 + X2 + ¬X3)
This is in Conjunctive Normal Form (CNF)– A conjunction of disjunctions– Each clause is the OR of variables– Clauses are ANDed together
7
(X5^X6^X7) + (¬X5^X8^¬X9)
This is in Disjunctive Normal Form (DNF)– A disjunction of conjunctions– Each clause is the AND of variables– Clauses are ORed together
8
SAT in DNF can be easier to solve
(X5^X6^X7) + (¬X5^X8^¬X9)
Why not use DNF?
9
– Some problems present themselves in CNF– – Circuit analysis
– Converting to DNF is an NP problem.
10
Complexity Classes
– P Can be solved in polynomial time– NP Verifiable in polynomial time– NP-C As “hard” as any NP problem
11
12
SAT solvers like MiniSat usually accept input in CNF form.
13
There are different types of SAT problems
– 2SAT 2 literals per clause– 3SAT 3 literals per clause– kSAT k literals per clause– Horn SAT
14
(X1 + X2 + ¬X3)^(¬X1 + X2 + ¬X3)
Example of 3SAT problem– Exactly 3 variables per clause– Can have any number of clauses
15
– 2SAT can be solved in polynomial time– 3SAT and over are NP-Complete
16
Horn SAT
– Special case of SAT– Each clause has at most 1 positive variable
(X1+¬X2+¬X3)^(X2+¬X3+¬X4)
17
– SAT is the first problem known to be NP-Complete
– Stephen Cook proved this in 1971
– This was the origin of the concept of an NP-Complete problem
18
Uses of SAT
19
– Since the 1990's, great improvements have been made to SAT solvers
– This has caused SAT to be applied to a wide range of uses
20
SAT is used in:
– Model Checking of Finite State Systems– Test Pattern Generation in Digital Systems– Combinational Equivalence Checking– Planning in AI– – Constraint satisfaction problem– Automated Theorem Proving– Software Verification– Haplotype inference in bioinformatics
21
MiniSat Solver
22
MiniSat Solver
– Accepts problems in CNF– Any number of variables in each clause
23
$ ./minisat --helpWARNING: for repeatability, setting FPU to use double precisionUSAGE: ./minisat [options] <input-file> <result-output-file>
where input may be either in plain or gzipped DIMACS.
CORE OPTIONS:
-rnd-init, -no-rnd-init (default: off) -luby, -no-luby (default: on)
24
-rnd-freq = <double> [ 0 .. 1] (default: 0) -rnd-seed = <double> ( 0 .. inf) (default: 9.16483e+07) -var-decay = <double> ( 0 .. 1) (default: 0.95) -cla-decay = <double> ( 0 .. 1) (default: 0.999) -rinc = <double> ( 1 .. inf) (default: 2) -gc-frac = <double> ( 0 .. inf) (default: 0.2)
-- garbage collection trigger (wasted memory)
-rfirst = <int32> [ 1 .. imax] (default: 100) -ccmin-mode = <int32> [ 0 .. 2] (default: 2) -phase-saving = <int32> [ 0 .. 2] (default: 2)
25
MAIN OPTIONS:
-verb = <int32> [ 0 .. 2] (default: 1) -cpu-lim = <int32> [ 0 .. imax] (default: 2147483647) secs -mem-lim = <int32> [ 0 .. imax] (default: 2147483647) MB
HELP OPTIONS:
--help Print help message. --help-verb Print verbose help message.
26
c All comments begin with a c p cnf 5 3 1 -5 4 0 -1 5 3 4 0 -3 -4 0
– p cnf 5 3 → problem is in CNF, 5 variables, 3 clauses– clauses end with 0
(X1+¬X5+X4)^(¬X1+X5+X3+X4)^(¬X3+¬X4)
27
(X1+¬X5+X4)^(¬X1+X5+X3)^(¬X3+¬X4)
Output:
SAT-1 -2 -3 -4 -5 0
X1=F, X2=F, X3=F, X4=F, X5=F
28
– Only one solution generated
– Purpose is show the problem is satisfiable, not to find all solutions
– Can force a new solution by adding the negation of the output as a new clause to the input
29
c All comments begin with a c p cnf 5 4 1 -5 4 0 -1 5 3 4 0 -3 -4 0 1 2 3 4 5 0
30
Solver Algorithms and Strategies
31
• Davis-Putnam (DP)
• Davis-Logemann-Loveland (DLL/DPLL)
• Stalmarck’s algorithm
• Stochastic search
32
Davis-Putnam (DP)– Based on resolution
33
B B (B (B ¬C) ¬C) ¬B ¬B B B ¬C ¬CB B ¬C ¬C
¬C¬C
(())
(A (A B) B) (B (B ¬C) ¬C) (A (A ¬B) ¬B)
(()) (())
A=0A=0A=0A=0A=0A=0 A=1A=1
B=0B=0 B=1B=1
C=0C=0 C=1C=1
B=1B=1B=0B=0
34
– Good at reducing the function– Still exponential complexity for worst case
35
• Davis-Logemann-Loveland (DLL/DPLL)
– Used by MiniSat– Search-based– Basis for current most successful solvers
36
• Davis-Logemann-Loveland (DLL/DPLL) (cont.)
Step 1
– Loop through the variables – – set each variable (true or false)– – minisat initially sets unknowns to false – – if all variables are set → Satisfiable
37
Step 2– Calculate the value of other variables as you go, looking for conflicts(X1 + X2) ^ (¬X2 + X3)
If X1 is false, X2 has to be true X3 has to be true
Or(X1 + X2) ^ (¬X2 + X3) ^ (¬X3) – until you find a conflict → backtrack and choose a different value 38
39
– SAT The Satisfiability Problem-- Theoretical applications-- Real world applications
– NP-Complete
– Solvers exist
40
Resources
Joao Marques-Silva, “Practical Applications of Boolean Satisfiability”www.cs.ucf.edu/courses/cot4810.spr2003/dhand1.pptThomas Cormen, Charles Leiserson, “Introduction to Algorithms”
41