SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A...

Preview:

Citation preview

SAT SolvingPresented 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 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

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

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

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

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value.v6

DPLL: Davis Putnam Logemann Loveland Backtrack Search Choose a decision

variable and value. Run bcp()

v6 ¬v14 v3

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

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

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**

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

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

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

DPLL: Davis Putnam Logemann Loveland Backtrack Search

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

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

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

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)

(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

(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

(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

(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

(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

(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

(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

(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

(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

(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

(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

(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

(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

(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***

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

Learning: Cuts

¬v5

¬v9

v4 ¬v1

v12

v7

¬v8

v19

¬v6

v3

¬v3 v15

Conflict

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)

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

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.

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

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)

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

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

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

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

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

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

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

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

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

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

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()

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

Recommended