50
SAT Solving Presented by Avi Yadgar

SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that. A is a solution for. A partial assignment

  • View
    222

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

SAT SolvingPresented by Avi Yadgar

Page 2: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

The SAT Problem

Given a Boolean formula , look for assignment A for such that . A is a solution for .

A partial assignment assigns a subset of . CNF representation of :

is a conjunction of clauses: A clause is a disjunction of literals:

( )v( ( ))A v true v

( )v

( )v1 2( ) ... mv cl cl cl

1( ... )i lcl lit lit

v

( )v

Page 3: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

The SAT Problem

= (v1 v2 v5) (v1 v7 v9) … (v5 v7)

A satisfies ↔ A satisfies all its clauses. Each clause needs one “true” literal

NP-Complete Many applications Very efficient solvers Search / Proof engine

( )v

Page 4: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Boolean Constraint Propagation Unit Clause: A clause with exactly one

unassigned literal, while all the rest are false. Asserts the value of the unassigned variable.

cl = ( v3)

v1 = 0

v2 = 1

v3 = ?v1 = 0 v2 = 0

v3 = 1 v1 v2

Page 5: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Boolean Constraint Propagation Unit Clause: A clause with exactly one

unassigned literal, while all the rest are false. Asserts the value of the unassigned variable.

cl implies and is its antecedent. v1 and v2 are the antecedent variables of

BCP(): Calculates all the possible implications.

1 2 3( )cl v v v v1 = 0 v2 = 1 v3 = ?

v3 = 1

3v

3v

Page 6: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value.v6

Page 7: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp()

v6 ¬v14 v3

Page 8: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp()

v6 ¬v14 v3

¬v1 v18 v4 ¬v2

v8 ¬v10 v7

Page 9: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp() If a conflict occurs

Flip the highest decision variable not yet flipped.

v6 ¬v14 v3

¬v1 v18 v4 ¬v2

v8 ¬v10 v7

¬v9 v5 ¬v3

Page 10: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp() If a conflict occurs

Flip the highest decision variable not yet flipped.

Mark as flipped.

v6 ¬v14 v3

¬v1 v18 v4 ¬v2

v8 ¬v10 v7

v9**

Page 11: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp() If a conflict occurs

flip the highest decision variable not yet flipped.

Mark as flipped Run bcp().

v6 ¬v14 v3

¬v1 v18 v4 ¬v2

v8 ¬v10 v7

v9** v15 v14

Page 12: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp() If a conflict occurs

flip the highest decision variable not yet flipped.

Mark as flipped Run bcp().

v6 ¬v14 v3

¬v1 v18 v4 ¬v2

¬v8**

v9** v15 v14

Page 13: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp() If a conflict occurs

flip the highest decision variable not yet flipped.

Mark as flipped Run bcp().

v6 ¬v14 v3

¬v1 v18 v4 ¬v2

¬v8** v11

Page 14: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

DPLL: Davis Putnam Logemann Loveland Backtrack Search

Termination No unassigned variables – SAT No decision variable to flip – un-SAT

Page 15: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Optimized BCP

Solver spends 90% in BCP

2 5 6 9 10( , , , , )v v v v v

1 3 4 6 10( , , , , )v v v v v

10v

1v

3v

2v

4v

Page 16: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

cres(c1 , c2) = (v2 v5 v7 v9)

The SAT Problem - Resolution

c1 = (v1 v2 v5) , c2(v1 v7 v9)

cres

cres

v2 v5 v7 v9

Page 17: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

SAT Solving - Implication Graph (v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

Page 18: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v9

SAT Solving - Implication Graph

Page 19: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

SAT Solving - Implication Graph

Page 20: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

¬v8

SAT Solving - Implication Graph

Page 21: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v12¬v8

SAT Solving - Implication Graph

Page 22: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v12

v7

¬v8

SAT Solving - Implication Graph

Page 23: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v12

v7

¬v8

v3

SAT Solving - Implication Graph

Page 24: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4

v12

v7

¬v8

v3

SAT Solving - Implication Graph

Page 25: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v3

SAT Solving - Implication Graph

Page 26: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

v3

SAT Solving - Implication Graph

Page 27: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

¬v6

v3

SAT Solving - Implication Graph

Page 28: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

¬v6

v3

v15

SAT Solving - Implication Graph

Page 29: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

v3

¬v3 v15

SAT Solving - Implication Graph

¬v6

Page 30: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

¬v6

v3

¬v3 v15

Conflict

SAT Solving - Implication Graph

Page 31: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v12

v7

¬v8

v3

SAT Solving - Implication Graph

¬v4***

Page 32: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

CUT: A bi-partition of the graph. The conflict is on the ‘conflict side’. The decisions are on the ‘reason side’ No edge from the ‘conflict side’ to the ‘reason

side’. The edges which cut the cut represent the

reason to the conflict.

Learning: Cuts

Page 33: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Learning: Cuts

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

¬v6

v3

¬v3 v15

Conflict

Page 34: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Learning: Conflict Clauses

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

¬v6

v3

¬v3 v15

Conflict

Conflict Side

Reason Side

v7,¬v5,v15 are the reason for the conflict. Adding the clause will prevent it in

the future.7 5 15(¬v v ¬v )

(v5,¬v7,v3)

(¬v7,¬v15,¬v3)

(¬v7,v5,¬v15)

Page 35: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Learning: Conflict Clausesv1

v2 v2

v3 v3 v3v3

0

00

00

1

1 1

The clause (v2,v3) is

created after a conflict

The search tree is pruned accordingly

Page 36: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Learning: Conflict Clauses Prevent the reason to the conflict.

Consists of the negation to the reason literals. Prunes the search tree.

Different cuts yield different conflict clauses. We choose cuts such that:

Conflict clause includes one variable from the top level.

It is a unit clause after backtracking one level. The new problem is equivalent to the original.

Page 37: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Learning: Implication Graph(v9,¬v5)

(v9,¬v8)

(v9,v12)

(v5,v7)

(v5,¬v7,v3)

(¬v4,¬v1)

(v1,¬v12,v19)

(v1,¬v6)

(v6,¬v19,v8,v15)

(¬v7,¬v15,¬v3)

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

¬v6

v3

¬v3 v15

Conflict

1 UIP2 UIP3 UIP

Page 38: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Non –Chronological Backtracking Backtrack multiple levels instead of one. Use conflict clause to determine the level

Backtrack to the minimum level where the clause is still asserting.

Emphasis on recent learning.

v8 ¬v10 v3 v7 v14

¬v2 v5 v1

¬v4 v21 ¬v12 ¬v15

v19 v18 v32

¬v6 v16 ¬v9 ¬v14

v8 ¬v10 v3 v7

¬v2 v5 v1 v9

Conflict Clause

(v10,¬v7,v2,v9)

Page 39: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Non –Chronological Backtracking

v8 ¬v10 v3 v7 v14

¬v2 v5 v1

¬v4 v21 ¬v12 ¬v15

v19 v18 v32

¬v6 v16 ¬v9 ¬v14

v8 ¬v10 v3 v7

¬v2 v5 v1 v9

v8

v6

v2

v19

v4

1

0

0

1

1

v8

v2

v9

0

1

1

Page 40: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Branching - VSIDS(Variable State Independent Decaying Sum) Counter for each literal

Updated when clauses are added Branch on the literal with the highest rank Divide counters periodically Favors recent conflict clauses.

Recent gained knowledge

Page 41: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Restarts

After a fixed interval Lengthen interval after each restart

Nullify all branching and implications Keep conflict clauses Leads to a new branching order

New score for the literals Hopefully a better order

Page 42: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Branching for BMC

Add static ordering Forward backward

Branch on latches \ inputs

0 0 0 0 1 1( ... ) ( ) ( , ) ... ( , ) ( )k k k k kv v I v R v v R v v P v

Page 43: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Branching for BMC

Create independent sub-problems

0 1 1 1 1( , ) ... ( , ) ( , ) ... ( , )i i i i k kR v v R v v R v v R v v

Page 44: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

un-SAT Core

1 2( , )v v2 3( , )v v 1 3 4( , , )v v v1 3( , )v v 2 3( , )v v1 2 4( , , )v v v 1 2 3( , , )v v v 2 3( , )v v2 3( , )v v

¬v2

¬v3

¬v1

v1

Conflict

2( )v

2 3( , )v v

Page 45: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

un-SAT Core

1 2( , )v v2 3( , )v v 1 3 4( , , )v v v1 3( , )v v 2 3( , )v v1 2 4( , , )v v v 1 2 3( , , )v v v 2 3( , )v v2 3( , )v v

v2

¬v3 ¬v2

Conflict

2( )v

( )

2( )v

2 3( , )v v

Page 46: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

un-SAT Core

1 2( , )v v2 3( , )v v 1 3 4( , , )v v v1 3( , )v v 2 3( , )v v1 2 4( , , )v v v 1 2 3( , , )v v v 2 3( , )v v2 3( , )v v

2( )v

( )

2( )v

2 3( , )v v

Page 47: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

un-SAT Core

1 2( , )v v2 3( , )v v 1 3 4( , , )v v v1 3( , )v v 2 3( , )v v1 2 4( , , )v v v 1 2 3( , , )v v v 2 3( , )v v2 3( , )v v

2( )v

( )

2( )v

2 3( , )v v

Easily obtained from a DPLL SAT solver Requires saving the resolution graph

Page 48: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

Branching – BerkMin \HaifaSAT SAT as abstraction / refinement Stack of added conflict clauses

Order clauses chronologically (BerkMin) Order on clauses topologically (HaifaSAT)

Branch on a literal from the top clause

1 2 ... n rescl cl cl cl 1 2 ... ncl cl cl

rescl

Page 49: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

The Rise and Fall of Parallel SAT Solving VERY appealing! Obstacles

Dependencies Communication

Parallelized BCP() Centralized Appealing since bcp() is 90% of the runtime Useless since bcp() is only 90% of the runtime

BC

P()

Page 50: SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment

The Rise and Fall of Parallel SAT Solving Parallelize for BMC Create “independent” formulae

Take advantage of symmetry Share learned clauses

Inference is local

0 1 1 1 1( , ) ... ( , ) ( , ) ... ( , )i i i i k kR v v R v v R v v R v v