GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J....

33
GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J....

Page 1: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

GRASP SAT solver

Presented by Ed ClarkeSlides borrowed from P. Chauhan and C. Bartzis

J. Marques-Silva and K. Sakallah

Page 2: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

SAT Solvers have made some progress…

1

10

100

1000

10000

100000

1960 1970 1980 1990 2000 2010

Year

Vars

Page 3: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Conjunctive Normal Form (CNF)

Atomic proposition: x1, x2, x3,… Literal: xi or xi where xi is atomic Clause: l1 l2 … ln where li is a literal CNF formula: 1 2 … m where i

is a clause Example:

(x2 x3) (x1 x4 x3) (x2 x4)

Page 4: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Putting a formula in CNF Extract from truth table of formula Put in Negation Normal Form (using De

Morgan’s laws) and expand using distributivity of over :

p (q r) (p q) (p r) Put in Negation Normal Form and

introduce new variable for each conjunctive subformula. (equi-satisfiable but not logically equivalent)

Page 5: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

What is SAT? Given a propositional formula in CNF, find

an assignment to boolean variables that makes the formula true

E.g.1 = (x2 x3)

2 = (x1 x4)

3 = (x2 x4)

A = {x1=0, x2=1, x3=0, x4=1}

1 = (x2 x3)

2 = (x1 x4)

3 = (x2 x4)

A = {x1=0, x2=1, x3=0, x4=1}

SATisfying assignment!

Page 6: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Why is SAT important?

Fundamental problem from theoretical point of view

Numerous applications CAD, VLSI Optimization Model Checking and other kinds of

formal verification AI, planning, automated deduction

Page 7: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Terminology CNF formula

x1,…, xn: n variables 1,…, m: m clauses

Assignment A Set of (x,v(x)) pairs |A| < n partial assignment {(x1,0), (x2,1), (x4,1)} |A| = n complete assignment {(x1,0), (x2,1), (x3,0), (x4,1)} |A= 0 unsatisfying assignment {(x1,1), (x4,1)} |A= 1 satisfying assignment {(x1,0), (x2,1), (x4,1)} |A= X unresolved {(x1,0), (x2,0), (x4,1)}

1 = (x2 x3)

2 = (x1 x4)

3 = (x2 x4)

A = {x1=0, x2=1, x3=0, x4=1}

1 = (x2 x3)

2 = (x1 x4)

3 = (x2 x4)

A = {x1=0, x2=1, x3=0, x4=1}

Page 8: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Terminology

An assignment partitions the clause database into three classes Satisfied Unsatisfied Unresolved

Free literals: unassigned literals of a clause Unit clause: unresolved with only one free

literal

Page 9: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Basic Backtracking Search

Organize the search in the form of a decision tree

Each node is an assignment, called decision assignment

Depth of the node in the decision tree decision level (x)

x=v@d x is assigned to v at decision level d

Page 10: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Basic Backtracking Search

Iteration:1. Make new decision assignments to

explore new regions of search space2. Infer implied assignments by a

deduction process. May lead to unsatisfied clauses, conflict.

The assignment is called conflicting assignment.

3. If there is a conflict backtrack

Page 11: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

DPLL in action

1 = (x1 x2 x3 x4)

2 = (x1 x3 x4)

3 = (x1 x2 x3)

4 = (x3 x4)

5 = (x4 x1 x3)

6 = (x2 x4)

7 = (x2 x4 )

1 = (x1 x2 x3 x4)

2 = (x1 x3 x4)

3 = (x1 x2 x3)

4 = (x3 x4)

5 = (x4 x1 x3)

6 = (x2 x4)

7 = (x2 x4 )

x1

x2

UU

x3 = 1@2

x1 = 0@1

//

//

//

x2 = 0@2

x4 = 1@2

conflict

UU

////

//

Page 12: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

DPLL in action

1 = (x1 x2 x3 x4)

2 = (x1 x3 x4)

3 = (x1 x2 x3)

4 = (x3 x4)

5 = (x4 x1 x3)

6 = (x2 x4)

7 = (x2 x4 )

1 = (x1 x2 x3 x4)

2 = (x1 x3 x4)

3 = (x1 x2 x3)

4 = (x3 x4)

5 = (x4 x1 x3)

6 = (x2 x4)

7 = (x2 x4 )

x1

x2

x3 = 1@2

x1 = 0@1

//

//

//

x2 = 0@2

x4 = 1@2

conflict

UU//

//

x2 = 1@2

x4 = 1@2

conflict

Page 13: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

DPLL in action

1 = (x1 x2 x3 x4)

2 = (x1 x3 x4)

3 = (x1 x2 x3)

4 = (x3 x4)

5 = (x4 x1 x3)

6 = (x2 x4)

7 = (x2 x4 )

1 = (x1 x2 x3 x4)

2 = (x1 x3 x4)

3 = (x1 x2 x3)

4 = (x3 x4)

5 = (x4 x1 x3)

6 = (x2 x4)

7 = (x2 x4 )

x1

x2

x3 = 1@2

x1 = 0@1//

//

x2 = 0@2

x4 = 1@2

conflict

//

x2 = 1@2

x4 = 1@2

conflict

x2

x1 = 1@1

x2 = 0@2

x4

x4 = 1@2

{(x1,1), (x2,0), (x4,1)}

Page 14: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

DPLL Algorithm

Deduction

Decision

Backtrack

Page 15: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

GRASP

GRASP stands for Generalized seaRch Algorithm for the Satisfiability Problem (Silva, Sakallah, ’96)

Features: Implication graphs for BCP and conflict

analysis Learning of new clauses Non-chronological backtracking

Page 16: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

GRASP search template

Page 17: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

GRASP Decision Heuristics

Procedure decide() Which variable to split on What value to assign

Default heuristic in GRASP:

Choose the variable and assignment that directly satisfies the largest number of clauses

Other possibilities exist

Page 18: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

GRASP Deduction

Boolean Constraint Propagation using implication graphsE.g. for the clause = (x y), if y=1, then we must have x=1

For a variable x occuring in a clause, assignment 0 to all other literals is called antecedent assignment A(x)

E.g. for = (x y z),

A(x) = {(y,0), (z,1)}, A(y) = {(x,0),(z,1)}, A(z) = {(x,0), (y,0)}

Variables directly responsible for forcing the value of x Antecedent assignment of a decision variable is empty

Page 19: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Implication Graphs Nodes are variable assignments x=v(x)

(decision or implied) Predecessors of x are antecedent assignments

A(x) No predecessors for decision assignments!

Special conflict vertices have A() = assignments to variables in the unsatisfied clause

Decision level for an implied assignment is(x) = max{(y)|(y,v(y))A(x)}

Page 20: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Example Implication Graph

1 = (x1 x2)

2 = (x1 x3 x9)

3 = (x2 x3 x4)

4 = (x4 x5 x10)

5 = (x4 x6 x11)

6 = (x5 x6)

7 = (x1 x7 x12)

8 = (x1 x8)

9 = (x7 x8 x13)

1 = (x1 x2)

2 = (x1 x3 x9)

3 = (x2 x3 x4)

4 = (x4 x5 x10)

5 = (x4 x6 x11)

6 = (x5 x6)

7 = (x1 x7 x12)

8 = (x1 x8)

9 = (x7 x8 x13)

Current truth assignment: {x9=0@1 ,x10=0@3, x11=0@3, x12=1@2, x13=1@2}

Current decision assignment: {x1=1@6}

6

6

conflict

x9=0@1

x1=1@6

x10=0@3

x11=0@3

x5=1@64

4

5

5 x6=1@62

2

x3=1@6

1

x2=1@6

3

3

x4=1@6

Page 21: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

GRASP Deduction Process

Page 22: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

GRASP Conflict Analysis

After a conflict arises, analyze the implication graph at current decision level

Add new clauses that would prevent the occurrence of the same conflict in the future Learning

Determine decision level to backtrack to, might not be the immediate one Non-chronological backtracking

Page 23: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Learning

Determine the assignment that caused conflict Backward traversal of the IG, find the roots of

the IG in the transitive fanin of This assignment is necessary condition for

Negation of this assignment is called conflict induced clause C()

Adding C() to the clause database will

prevent the occurrence of again

Page 24: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Learning

6

6

conflict

x9=0@1

x1=1@6

x10=0@3

x11=0@3

x5=1@64

4

5

5 x6=1@62

2

x3=1@6

1

x2=1@6

3

3

x4=1@6

C() = (x1 x9 x10 x11)

Page 25: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

For any node of an IG x, partition A(x) into

(x) = {(y,v(y)) A(x)|(y)<(x)}

(x) = {(y,v(y)) A(x)|(y)=(x)}

Conflicting assignment AC() = causesof(), where

Learning

(x,v(x)) if A(x) =

(x) [ causesof(y) ]o/w(y,v(y)) (x)

causesof(x) =

Page 26: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Learning

Learning of new clauses increases clause database size

Increase may be exponential Heuristically delete clauses based

on a user provided parameter If size of learned clause > parameter,

don’t include it

Page 27: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Backtracking

Failure driven assertions (FDA): If C() involves current decision

variable, a different assignment for the current variable is immediately tried.

In our IG, after erasing the assignment at level 6, C() becomes a unit clause x1

This immediately implies x1=0

Page 28: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Example Implication Graph

1 = (x1 x2)

2 = (x1 x3 x9)

3 = (x2 x3 x4)

4 = (x4 x5 x10)

5 = (x4 x6 x11)

6 = (x5 x6)

7 = (x1 x7 x12)

8 = (x1 x8)

9 = (x7 x8 x13)

C()=(x1 x9 x10 x11)

1 = (x1 x2)

2 = (x1 x3 x9)

3 = (x2 x3 x4)

4 = (x4 x5 x10)

5 = (x4 x6 x11)

6 = (x5 x6)

7 = (x1 x7 x12)

8 = (x1 x8)

9 = (x7 x8 x13)

C()=(x1 x9 x10 x11)

Current truth assignment: {x9=0@1 ,x10=0@3, x11=0@3, x12=1@2, x13=1@2}

Current decision assignment: {x1=1@6}

6

6

conflict

x9=0@1

x1=1@6

x10=0@3

x11=0@3

x5=1@64

4

5

5 x6=1@62

2

x3=1@6

1

x2=1@6

3

3

x4=1@6

Page 29: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Example Implication Graph

1 = (x1 x2)

2 = (x1 x3 x9)

3 = (x2 x3 x4)

4 = (x4 x5 x10)

5 = (x4 x6 x11)

6 = (x5 x6)

7 = (x1 x7 x12)

8 = (x1 x8)

9 = (x7 x8 x13)

C() = (x1 x9 x10 x11)

1 = (x1 x2)

2 = (x1 x3 x9)

3 = (x2 x3 x4)

4 = (x4 x5 x10)

5 = (x4 x6 x11)

6 = (x5 x6)

7 = (x1 x7 x12)

8 = (x1 x8)

9 = (x7 x8 x13)

C() = (x1 x9 x10 x11)

Current truth assignment: {x9=0@1 ,x10=0@3, x11=0@3, x12=1@2, x13=1@2}

Current decision assignment: {x1=0@6}

x11=0@3

x10=0@3

x9=0@1

C() C()

C()

x1=0@6

Page 30: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Non-chronological backtracking

9

9

x12=1@2

x7=1@6

x8=1@6

x1=0@6

x11=0@3

x10=0@3

x9=0@1

7

7

8

C() C()

C() x13=1@2

9

AC(’) = {x9 =0@1, x10 = 0@3, x11 = 0@3, x12=1@2, x13=1@2}

C() = (x9 x10 x11 x12 x13)

Decision level

4

5

x1

6

'

3

Page 31: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Backtrack level is given by

= d-1 chronological backtrack < d-1 non-chronological backtrack

Backtracking

= max{(x)|(x,v(x))AC(’)} = max{(x)|(x,v(x))AC(’)}

Page 32: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

Procedure Diagnose()

Page 33: GRASP SAT solver Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis J. Marques-Silva and K. Sakallah.

What’s next?

Reduce overhead for constraint propagation

Better decision heuristics Better learning, problem specific Better engineering

Chaff