1/30 sat solver changki hong @ pswlab sat solver daniel kroening, ofer strichman

30
1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

Upload: aaliyah-menser

Post on 15-Dec-2015

229 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

1/30 SAT Solver Changki Hong @ PSWLAB

SAT Solver

Daniel Kroening, Ofer Strichman

Page 2: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

2/30 SAT Solver Changki Hong @ PSWLAB

Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References

Page 3: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

3/30

SAT made some progress…

1

10

100

1000

10000

100000

1960 1970 1980 1990 2000 2010

Year

Vars

Page 4: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

4/30 SAT Solver Changki Hong @ PSWLAB

Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References

Page 5: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

5/30 SAT Solver Changki Hong @ PSWLAB

Two main categories of SAT solver Davis-Putnam-Loveland-Logemann (DPLL) frame-

work The solver can be thought of as traversing and backtrack-

ing on a binary tree. Internal nodes represent partial assignments. Leave nodes represent full assignments.

Stochastic search The solver guesses a full assignment, and then, if the

formula is evaluated to FALSE under this assignment, starts to flip values of variables according to some heuristics.

DPLL solvers are considered better in most cases according to the annual competition.

Page 6: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

6/30 SAT Solver Changki Hong @ PSWLAB

Status of a clause A clause can be

Satisfied: at least one literal is satisfied Unsatisfied: all literals are assigned but non are

satisfied Unit: all but one literals are assigned but none are

satisfied Unresolved: all other cases

Example: C = (x1 ∨ x2 ∨ x3)x1 x2 x3 C

1 0 Satisfied

0 0 0 Unsatisfied

0 0 Unit

0 Unresolved

Page 7: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

7/30 SAT Solver Changki Hong @ PSWLAB

A Basic SAT algorithm

While (true){

if (Decide() == FALSE) return (SAT);

while (BCP() == “conflict”) {

backtrack-level = Analyze_Conflict();

if (backtrack-level < 0) return (UNSAT);

else BackTrack(backtrack-level);

}}

Choose the next variable and value.Return False if all

variables are assigned

Apply repeatedly the unit clause rule.

Return False if reached a conflict

Backtrack until no conflict.

Return False if impossible

Page 8: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

8/30 SAT Solver Changki Hong @ PSWLAB

Given in CNF: (x ∨ y ∨ z) ∧ (¬x ∨ y) ∧ (¬y ∨ z) ∧ (¬x ∨ ¬y ∨ ¬z)

Decide()

BCP()

Analyze_Conflict()

A Basic SAT algorithm

(y)∧ (¬y ∨ z ) ∧ (¬y ∨ ¬z )(y ∨ z) ∧ (¬y ∨ z

)

(z) ∧ (¬z )

( ) ( )(y) ∧ (¬y)

( )

( )

( )

( )

x = 1

x = 0

y = 1

y = 0

z = 1 z = 0

z = 1 z = 0 y = 1

y = 0

X

X X X X

Page 9: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

9/30 SAT Solver Changki Hong @ PSWLAB

Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References

Page 10: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

10/30 SAT Solver Changki Hong @ PSWLAB

Boolean Constraints Propagation (BCP) BCP is repeated application of the unit clause

rule until either a conflict is encountered or there are no more implications.

Each assignment is associated with the deci-sion level at which it occurred. notation : x=v@d

x ∈ {0,1} is assigned to v at decision level d

The process of BCP is best illustrated with an implication graph.

Page 11: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

11/30 SAT Solver Changki Hong @ PSWLAB

Implication graph Def: An implication graph is a labeled directed

acyclic graph G(V, E), where: V represents the literals of the current partial assignment.

Each node is labeled with the literal that it represents and the decision level at which it entered the partial assignment.

E with E = { (vi, vj) | vi, vj ∈ V, ¬vi ∈ Antecedent(vj) } denotes the set of directed edges where each edge (vi, vj) is labeled with Antecedent(vj). Def: For a given unit clause C with an unassigned literal l,

we say that l is implied by C and that C is the antecedent clause of l, denoted by Antecedent(l).

Page 12: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

12/30

5

5 x6=1@6

Implication graphs and conflict clause

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

con-flict

x9=0@1

x1=1@6

x10=0@3

x11=0@3

x5=1@6

4

4

2

2

x3=1@6

1

x2=1@6

3

3

x4=1@6

We learn the conflict clause 10 = (¬x1 ∨ x9 ∨ x11 ∨ x10 )

Page 13: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

13/30

Implication graph, flipped assignment

x1=0@6

x11=0@3

x10=0@3

x9=0@1

x7=1@6

x12=1@2

7

7

x8=1@68

10

10

10 9

9

x13=1@2

9

Due to the conflict clause

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)

10 : (x1 x9 x11 x10)

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)

10 : (x1 x9 x11 x10) Another conflict clause:11 = (x13 ∨ x12 ∨ x11 ∨ x10 ∨ x9)

con-flict

Page 14: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

14/30 SAT Solver Changki Hong @ PSWLAB

Non-chronological backtracking

Non-chrono-logical backtrack-ing

x1

4

5

6

Decision level

Which assignments caused the conflicts ? x9= 0@1

x10= 0@3

x11= 0@3

x12= 1@2

x13= 1@2

Backtrack to DL = 3

3

These assignmentsAre sufficient forCausing a conflict.

Page 15: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

15/30 SAT Solver Changki Hong @ PSWLAB

Non-chronological backtracking So the rule is: backtrack to the largest deci-

sion level in the conflict clause. x1 = 0

x2 = 0

x3 = 1

x4 = 0

x5 = 0

x7 = 1

x9 = 0

x6 = 0

...x5 = 1

x9 = 1

x3 = 0

Page 16: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

16/30 SAT Solver Changki Hong @ PSWLAB

Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References

Page 17: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

17/30 SAT Solver Changki Hong @ PSWLAB

Conflict clauses Def: A clause is asserting if the clause con-

tains all value 0 literals; and among them only one is assigned at current decision level.

After backtracking, this clause will become a unit clause and force the literal to assume an-other value, thus bringing the search to a new space.

Modern solvers only consider Asserting Clauses.

Page 18: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

18/30 SAT Solver Changki Hong @ PSWLAB

Unique Implication Points (UIP’s) Definition: A Unique Implication Point (UIP) is

an internal node in the implication graph that all paths from the decision to the conflict node go through it.

The First-UIP is the closest UIP to the conflict.

5

5

6

6

con-flict

4

4

2

2

1 3

3

UIPUIP

Page 19: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

Conflict clauses and Resolution

The Binary-resolution :

Example:

Page 20: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

20/30 SAT Solver Changki Hong @ PSWLAB

Conflict clauses and resolution

This function is to return TRUE if and only if cl con-tains the negation of the first UIP as its single literal at the current decision level

Page 21: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

21/30 SAT Solver Changki Hong @ PSWLAB

Conflict clauses and resolution

Resolution order : x4, x5, x6, x7Since the c5 contains the negation of the first UIP as its single literal at the current decision level, the stop criterion is met.c5 is asserting clause.

First UIP

Page 22: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

22/30 SAT Solver Changki Hong @ PSWLAB

Resolution graph

1

2

3

4

5

6

10

7

8

9

11

7

7

8

10

10

10 9

9

con-flict

5

5

6

6

con-flict

4

4

2

2

1 3

3

9

Resolution Graph

Page 23: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

23/30 SAT Solver Changki Hong @ PSWLAB

Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References

Page 24: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

24/30 SAT Solver Changki Hong @ PSWLAB

Compute for every clause w and every variable l (in each phase):

J(l) :=

Choose a variable l that maximizes J(l). This gives an exponentially higher weight

to literals in shorter clauses.

,

||2l

Decision heuristics - JW

Jeroslow-Wang method

Page 25: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

25/30 SAT Solver Changki Hong @ PSWLAB

Choose the assignment that satisfies the largest number of currently unsatisfied clauses Cxp – # unresolved clauses in which x appears Let x be the literal with Cxp

Let y be the literal with Cyp

If Cxp > Cyp choose x, Otherwise choose y

Requires l (#literals) queries for each decision.

DLIS (Dynamic Largest Individual Sum)

Decision heuristics - DLIS

Page 26: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

26/30 SAT Solver Changki Hong @ PSWLAB

Decision heuristics – VSIDS

(Implemented in Chaff)

VSIDS (Variable State Independent Decay-ing Sum)

1. Each variable in each polarity has a counter initialized to 0.

2. When a clause is added, the counters are updated.

3. The unassigned variable with the highest counter is chosen.

4. Periodically, all the counters are divided by a constant.

Page 27: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

27/30 SAT Solver Changki Hong @ PSWLAB

Decision heuristics – VSIDS (cont’d)

Chaff holds a list of unassigned variables sorted by the counter value.

Updates are needed only when adding con-flict clauses.

Thus decision is made in constant time.

Page 28: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

28/30 SAT Solver Changki Hong @ PSWLAB

Decision Heuristics - Berkmin Keep conflict clauses in a stack Choose the first unresolved clause in the stack

If there is no such clause, use VSIDS Choose from this clause a variable + value

according to some scoring (e.g. VSIDS)

This gives absolute priority to conflicts.

Page 29: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

29/30 SAT Solver Changki Hong @ PSWLAB

Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References

Page 30: 1/30 SAT Solver Changki Hong @ PSWLAB SAT Solver Daniel Kroening, Ofer Strichman

30/30 SAT Solver Changki Hong @ PSWLAB

References Decision Procedures – Daniel Kroening and Ofer Strichman The Quest for Efficient Boolean Satisfiability Solvers – Lintao

Zhang and Sharad Malik Efficient Conflict Driven Learning in a Boolean Satisfiability

Solver – Lintao Zhang, Conor F. Madigan, Matthew H. Moskewicz and Sharad Malik