/
Solving SAT Solving SAT

Solving SAT - PowerPoint Presentation

aaron
aaron . @aaron
Follow
373 views
Uploaded On 2017-11-16

Solving SAT - PPT Presentation

1 Haim Kaplan and Uri Zwick Algorithms in Action Tel Aviv University Last updated June 28 2017 Conjunctive Normal Form 2 A Boolean formula which is a conjunction of disjunctions clauses ID: 605828

implication clause conflict decision clause implication decision conflict learning graph level clauses backtracking formula variable unit backtrack add cdcl

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Solving SAT" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Solving SAT

1

Haim Kaplan and Uri Zwick

Algorithms in Action

Tel Aviv University

Last updated: June

28

2017Slide2

Conjunctive Normal Form

2A Boolean formula which is a conjunction of disjunctions (clauses) of literals (a variable or its negation)

 

: Given a Boolean formula in

, does it have a satisfying assignment ?

 Slide3

SAT

3No polynomial (in and ) time algorithm unless

 

= #clauses,

= #vars

 Slide4

-SAT

 4When all clauses contain literals 

 

instance:

 

is also

 

is in

: it even has an

time algorithm

 Slide5

Propositional logic

5General Boolean formula over:  

 

The more general

problem asks if such a formula is

satisfiable

 Slide6

Propositional logic and

 6We can convert any formula to : 

Step 1:

Eliminate

 

 

Step 2:

Push negations down using De Morgan’s Laws

 

 

 Slide7

Propositional logic and

 7Step 3: Apply the distributive law

 

Bottom-up along the formula’s parse tree Slide8

Complexity of this reduction

8This is not a polynomial time reduction:

 

 

 

 Slide9

Polynomial conversion: Tseitin’s encoding

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide10

Polynomial conversion: Tseitin’s encoding

10

 

 

 

 

 

 Slide11

 

 

A formula is a Boolean circuit

(which is a tree)

 

 

 

 

 

 

 

 

 

 

 

Tseitin’s

encoding

 

 

 

 

 Slide12

 

 

 

General Boolean circuits as formulas

 

 

 

 

 

 

 

 

 

 

 

 

 

Tseitin’s

encodingSlide13

Applications of SAT

13Slide14

Checking equivalence of Boolean functions

 Circuit 1

C

ircuit 2

 

 

.

.

.

 

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Circuits are the same if the associated formula is not

satisfiable

 

 

 Slide15

Test generation for fault detection

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

?

 Slide16

Test generation for fault detection

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A satisfying assignment gives a testSlide17

Bounded model checking

Transition function/relation over states

 

Example: a two bit counter

00

01

10

11

iff

can follow

 

 

Assume

is given as a CNF over

and

 Slide18

Bounded model checking

18We want to check if some property holds in some state reachable from, say

after at most

steps

 

 

 

 

 

 

Is there a path like this such that

for

and

holds for some

?

 Slide19

Bounded model checking

19

 

Test satisfiability of the formula:

if

 Slide20

Graph coloring

20The k-Coloring problem:Given an undirected graph

and a natural number k is there

mapping

such that

 Slide21

Graph coloring

21 iff node

has color

 

 

 

 Slide22

SAT solvers22Slide23

DPLL

23Davis & Putnam 1960Davis & Logemann & Loveland 1962Clever backtrack searchSlide24

 

Simple backtrack searchConsider the CNF:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide25

Simple backtracking search

if

then return

if

then return

Pick a variable (smartly)

if

return

else return

 Slide26

 

 

Unit propagation

Consider the CNF:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide27

 

 

 

Unit propagation

Consider the CNF:

 

 

 

 

 

 

 

 

 

 

 

 

 Slide28

DPLL with unit propagation

unit-propagate

(

if

then return

if

then return

Pick a variable (smartly) if

return

else return

 Slide29

Conflict Driven Clause Learning (CDCL)A heuristic added to DPLL solvers with unit propagation

29Slide30

Implication graph (by example)

 

 

 

 

 

 

 

 

 Slide31

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 Slide32

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide33

 

 

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide34

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide35

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide36

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide37

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide38

Implication graph (by example)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide39

Decision levels

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide40

Implication graph (formally)

A “root” node with indegree for each decision variable (marked by the literal which is set to )A node per implied variable, marked with the clause that become unit and triggered the implication. Incoming edges from the nodes of the other variables in  Slide41

The planMaintain the implication graph

When a conflict is detected use the implication graph for learning implied clauses (clause learning) and smart backtracking (non-chronological backtracking)This heuristic made a huge difference in performance of DPLL SAT solversSlide42

Another example

 

 

 

 

 

 

 

 

 

 Slide43

First conflict

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide44

Trying

 

 

 

 

 

 

 

 

 

 

 Slide45

Second conflict

 

 

 

 

 

 

 

 

 Slide46

Next we would try

then …. 

 

 

 

 

 

 

 

 

 

 Slide47

How CDCL would save us

Implication graphs “tells us” that and are unrelated to the conflict 

 

 

 

 

 

 

 

 

 

 

So after failing with

there is no point in trying

and

 

 

 

 

 

 

 

 

 Slide48

 

 

 

 

 

 

 

 

 

 

After first conflict we add the clause

 

Backtrack

to the point where we assigned

 

How CDCL would save usSlide49

 

 

 

 

 

 

 

 

 

 

 

 

How CDCL would save us

 Slide50

After second conflict we add the clause

 Backtrack to decision level 0 (unit prop.

at the beginning)

How CDCL would save us

 

 

 

 Slide51

So how exactly do we use the implication graph ?

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We know that in any satisfying assignment we

cannot

have that

so we can add the claus

e

 Slide52

Clause learning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We also know that

mus

t be

false

so we can add the claus

e

 Slide53

Clause learning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Every cut that separates the decision variables from the conflicting pair gives a clauseSlide54

Clause learning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide55

Clause learning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Slide56

Clause learning & backtrackingWhich clause do we add ?

How do we backtrack ?Slide57

Clause learning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Start from the conflict and collect vertices of the largest decision level in reverse implication orderSlide58

Clause learning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Until all edges

of the largest decision level

crossing the cut emanate from a single vertex

(Unique implication point (UIP))Slide59

Clause learning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We will always reach such a situation as it must occur after we collect all implied variables at the largest decision levelSlide60

Clause learning & backtracking

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We

backtrack

to the point where we assigned

 

We add the clause

 Slide61

Clause learning, backtracking (formally)

Such a clause is called an asserting clauseWe will backtrack to the largest decision level of a variable in this clause which is not the UIP, restart from there, keeping the same assignment to It causes an immediate implication after backtracking: At that level the new clause becomes a unit clause. The UIP is implied Slide62

Clause learning, backtracking

 

 

 

 

 

 

 

 

 

 

UIP

Add

Backtrack to decision level

4

 Slide63

Alternatively

 

 

 

 

 

 

 

 

 

 

UIP

UIP

Add

Backtrack to decision level

7

 Slide64

The general rule (motivation)The clause corresponding to the UIP

closest to the conflict tends to be shorter (cannot be longer)The backtracking is to a lower decision levelEmpirically seems to be most effectiveSlide65

Few more observations about these CDCL solvers

We never switch the value of a decision variable while backtracking There may be implied variables at decision level 065

 

 

 

 

 

 

 Slide66

When do we stop ?

During the computation we will learn unit clausesComputation stops if we reach a conflict before the first decision (We have learnt two clauses ) or if we discover a satisfying assignment If terminates then the alg is correct 

66Slide67

Does the algorithm terminate ?

Consider the vector where

is the number of variables assigned at decision level

(

if

and

is the current decision level)

 

Claim:

This vector strictly increases lexicographically with every step of the algorithmProof: When we take another decision and increase the decision level then the “leftmost ” ( changes to  When we perform an implication then the rightmost nonzero increases Slide68

Correctness (CDCL, noncronological backtracking)

When we perform clause learning and non-chronological backtracking say to level then we set for but immediately increase by

since we get a new implication at level

 Slide69

Selecting the next decision variable and its value

A lot of research has been invested in developing heuristics for this. Here are few examples:1. Pick the literal that satisfies the maximum number of clauses2. For each literal compute

Pick the literal that maximizes

 Slide70

3. Variable State Independent Decaying Sum (VSIDS)

Maintain a score for each literal Initially it is equal to the number of clauses containing the literalPeriodically divide the score by a factor of two

When learning a new clause add

to the score of all its literals

 Slide71

Other elements of modern solversRestarts (when? how?)

Clause deletions (which clauses to keep?)Data structures for efficient implementation are crucial71Slide72

State of the art CDCL solversMinisat (2005)

Glucose (2009)72Slide73

Certifying SAT solversIn case the formula is satisfiable

– just give a satisfying assignment How do we prove that the formula is not satisfiable ?73Slide74

Resolution74

 

Any assignment that satisfies these

clauses also satisfies

 

We can

resolve

2 clauses

and

and obtain the

implied clause

 Slide75

Resolution is refutation complete

75Thm: If there is no satisfying assignment then there is a sequence of resolution steps that will generate the empty clauseSome unsatisfiable formulae require very long proofsSlide76

Resolution is refutation complete

 

Consider the CNF

defined as follows:

 

 

 

 

 

Thm:

The length of every resolution refutation of

is

 Slide77

Conflict clause via resolution

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

First resolve the clauses with the conflicting variable to get:

 Slide78

Conflict clause via resolution

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Resolve

with

to get

 

In general we resolve all clauses associated with literals in the conflict side of the cut and get the conflict clauseSlide79

Unsatisfiability proof

79Original clauses conflict clauses gives a resolution derivation of the final conflict

 

From the final conflict we resolve the empty clause