mark worth

41
Mark Worth The Satisfiability Problem and the MiniSat Solver 1

Upload: thad

Post on 06-Feb-2016

40 views

Category:

Documents


0 download

DESCRIPTION

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) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mark Worth

Mark Worth

The Satisfiability Problem and the MiniSat Solver

1

Page 2: Mark Worth

– What is the Satisfiability problem?

– The MiniSat solver

– Algorithms used by solvers

2

Page 3: Mark Worth

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

Page 4: Mark Worth

(¬X1 + X2) ^ (X1 + X3)

4

Page 5: Mark Worth

(X1 + X2 + ¬X3)^(¬X1 + X2 + ¬X3)

– One assignment is X1=T, X2=F, X3=F

– This function is Satisfiable

5

Page 6: Mark Worth

SAT problems can come in – Conjunctive Normal Form(CNF) or – Disjunctive Normal Form(DNF)

6

Page 7: Mark Worth

(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

Page 8: Mark Worth

(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

Page 9: Mark Worth

SAT in DNF can be easier to solve

(X5^X6^X7) + (¬X5^X8^¬X9)

Why not use DNF?

9

Page 10: Mark Worth

– Some problems present themselves in CNF– – Circuit analysis

– Converting to DNF is an NP problem.

10

Page 11: Mark Worth

Complexity Classes

– P Can be solved in polynomial time– NP Verifiable in polynomial time– NP-C As “hard” as any NP problem

11

Page 12: Mark Worth

12

Page 13: Mark Worth

SAT solvers like MiniSat usually accept input in CNF form.

13

Page 14: Mark Worth

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

Page 15: Mark Worth

(X1 + X2 + ¬X3)^(¬X1 + X2 + ¬X3)

Example of 3SAT problem– Exactly 3 variables per clause– Can have any number of clauses

15

Page 16: Mark Worth

– 2SAT can be solved in polynomial time– 3SAT and over are NP-Complete

16

Page 17: Mark Worth

Horn SAT

– Special case of SAT– Each clause has at most 1 positive variable

(X1+¬X2+¬X3)^(X2+¬X3+¬X4)

17

Page 18: Mark Worth

– 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

Page 19: Mark Worth

Uses of SAT

19

Page 20: Mark Worth

– 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

Page 21: Mark Worth

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

Page 22: Mark Worth

MiniSat Solver

22

Page 23: Mark Worth

MiniSat Solver

– Accepts problems in CNF– Any number of variables in each clause

23

Page 24: Mark Worth

$ ./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

Page 25: Mark Worth

-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

Page 26: Mark Worth

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

Page 27: Mark Worth

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

Page 28: Mark Worth

(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

Page 29: Mark Worth

– 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

Page 30: Mark Worth

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

Page 31: Mark Worth

Solver Algorithms and Strategies

31

Page 32: Mark Worth

• Davis-Putnam (DP)

• Davis-Logemann-Loveland (DLL/DPLL)

• Stalmarck’s algorithm

• Stochastic search

32

Page 33: Mark Worth

Davis-Putnam (DP)– Based on resolution

33

Page 34: Mark Worth

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

Page 35: Mark Worth

– Good at reducing the function– Still exponential complexity for worst case

35

Page 36: Mark Worth

• Davis-Logemann-Loveland (DLL/DPLL)

– Used by MiniSat– Search-based– Basis for current most successful solvers

36

Page 37: Mark Worth

• 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

Page 38: Mark Worth

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

Page 39: Mark Worth

39

Page 40: Mark Worth

– SAT The Satisfiability Problem-- Theoretical applications-- Real world applications

– NP-Complete

– Solvers exist

40

Page 41: Mark Worth

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