Sat propositional satisfiability
Download
1 / 37

SAT: Propositional Satisfiability - PowerPoint PPT Presentation


  • 70 Views
  • Uploaded on

SAT: Propositional Satisfiability. A tutorial. What is SAT?. Given a propositional formula in CNF, find an assignment to Boolean variables that makes the formula true:.  1 = (x 2  x 3 )  2 = (  x 1  x 4 )  3 = (  x 2  x 4 ) A = {x 1 =0, x 2 =1, x 3 =0, x 4 =1}.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' SAT: Propositional Satisfiability' - sakina


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

What is sat
What is SAT?

Given a propositional formula in CNF, find an assignment to Boolean variables that makes the formula true:

1 = (x2  x3)

2 = (x1  x4)

3 = (x2  x4)

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

SATisfying assignment!


Why sat
Why SAT?

  • Fundamental problem from theoretical point of view

    • Cook theorem, 1971: the first NP-complete problem.

  • Numerous applications:

    • Solving any NP problem...

    • Verification: Model Checking, theorem-proving, ...

    • AI: Planning, automated deduction, ...

    • Design and analysis: CAD, VLSI

    • Physics: statistical mechanics (models for spin-glass material)



Cnf sat
CNF-SAT

  • Conjunctive Normal Form: Conjunction of disjunction of literals. Example:(:x1Ç:x2) Æ (x2Ç x4Ç: x1) Æ ...

  • Experience shows that CNF-SAT solving is faster than solving a general propositional formula.

  • There exists a polynomial transformation of a general propositional formula  to CNF, with addition of || variables.


Cnf sat basic definitions literals
(CNF) SAT basic definitions: literals

  • A literal is a variable or its negation.

  • Var(l) is the variable associated with a literal l.

  • A literal is called negative if it is a negated variable, and positive otherwise.


Sat basic definitions literals
SAT basic definitions: literals

  • If var(l) is unassigned, then l is unresolved.

  • Otherwise, l is satisfied by an assignment  if (var(l)) = 1 and l is positive, or (var(l)) = 0 and l is negative, and unsatisfied otherwise.


Sat basic definitions clauses
SAT basic definitions: clauses

  • The state of an n-literal clause C under a partial assignment  is:

    • Satisfied if at least one of C’s literals is satisfied,

    • Conflicting if all of C’s literals are unsatisfied,

    • Unit if n-1 literals in C are unsatisfied and 1 literal is unresolved, and

    • Unresolved otherwise.



Sat basic definitions the unit clause rule
SAT basic definitions: the unit clause rule

  • The unit clause rule: in a unit clause the unresolved literal must be satisfied.


X

X

X

X

X

A Basic SAT algorithm

Given  in CNF: (x,y,z),(-x,y),(-y,z),(-x,-y,-z)

Decide()

Deduce()

Resolve_Conflict()


Basic backtracking search
Basic Backtracking Search

  • Organize the search in the form of a decision tree

    • Each node corresponds to a decision

    • Depth of the node in the decision tree is called the decision level

    • Notation:[email protected] assigned v2 {0,1} at decision level d


Backtracking search in action

x1

x1 = [email protected]

x2

x2 = [email protected]

Backtracking Search in Action

1 = (x2  x3)

2 = (x1  x4)

3 = (x2  x4)

x1 = [email protected]

 x4 = [email protected]

 x2 = [email protected]

 x3 = [email protected]

 x3 = [email protected]

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

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

No backtrack in this example, regardless of the decision!


Backtracking search in action1

x1

x1 = [email protected]

x1 = [email protected]

x2

x2 = [email protected]

 x3 = [email protected]

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

Backtracking Search in Action

Add a clause

1 = (x2  x3)

2 = (x1  x4)

3 = (x2  x4)

4 = (x1  x2  x3)

 x4 = [email protected]

 x2 = [email protected]

 x3 = [email protected]

conflict


A Basic SAT algorithm(DPLL-based)

Choose the next

variable and value.

Return False if all

variables are assigned

While (true)

{

if (!Decide()) return (SAT);

while (!Deduce())

if (!Resolve_Conflict()) return (UNSAT);

}

Apply unit clause rule.

Return False if reached

a conflict

Backtrack until

no conflict.

Return False if impossible


Decision heuristics dlis dynamic largest individual sum
Decision heuristicsDLIS (Dynamic Largest Individual Sum)

  • Maintain a counter for each literal: in how many unresolved clauses it appears ?

  • Decide on the literal with the largest counter.

  • Requires O(#literals) queries for each decision.


Decision heuristicsMOM (Maximum Occurrence of clauses of Minimum size).

  • Let f*(x) be the # of unresolved shortest clauses containing x. Choose x that maximizes:

    ((f*(x) + f*(!x)) * 2k + f*(x) * f*(!x)

  • k is chosen heuristically.

  • The idea:

    • Give preference to satisfying small clauses.

    • Among those, give preference to balanced variables (e.g. f*(x) = 3, f*(!x) = 3 is better than f*(x) = 1, f*(!x) = 5).


Implication graphs and learning

4

[email protected]

[email protected]

1

4

3

6

[email protected]

conflict

6

3

2

5

2

5

[email protected]

[email protected]

Implication graphs and learning

Current truth assignment: [email protected] ,[email protected], [email protected], [email protected], [email protected]}

Current decision assignment: [email protected]}

[email protected]

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

[email protected]

[email protected]

[email protected]

We learn the conflict clause10 : (: x1Ç x9Ç x11Ç x10)

and backtrack to the highest (deepest) dec. level in this clause (6).


Implication graph flipped assignment

x[email protected]

[email protected]

9

8

9

’

9

7

[email protected]

7

[email protected]

Implication graph, flipped assignment

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

[email protected]

10

[email protected]

[email protected]

10

10

[email protected]

Due to theconflict clause

We learn the conflict clause11 : (:x13Ç x9Ç x10Ç x11 Ç :x12)

and backtrack to the highest (deepest) dec. level in this clause (3).


Non chronological backtracking
Non-chronological backtracking

Which assignments caused

the conflicts ?

x9= [email protected]

x10= [email protected]

x11= [email protected]

x12= [email protected]

x13= [email protected]

Backtrack to decision level 3

3

Decision level

4

5

These assignments

are sufficient for

causing a conflict.

x1

6

’

Non-chronological

backtracking


Non chronological backtracking option 1
Non-chronological backtracking (option #1)

  • So the rule is: backtrack to the largest decision level in the conflict clause.

  • Q: What if the flipped assignment works ? A: continue to the next decision level, leaving the current one without a decision variable.

    • Backtracking back to this level will lead to another conflict and further backtracking.


Non chronological backtracking1
Non-chronological Backtracking

x1 = 0

x2 = 0

x3 = 1

x3 = 0

x4 = 0

x6 = 0

...

x5 = 0

x5 = 1

x7 = 1

x9 = 1

x9 = 0


More conflict clauses

4

[email protected]

[email protected]

1

4

2

3

6

1

[email protected]

conflict

6

3

2

5

2

5

[email protected]

[email protected]

3

More Conflict Clauses

  • Def: A Conflict Clause is any clause implied by the formula

  • Let L be a set of literals labeling nodes that form a cut in the implication graph, separating the conflict node from the roots.

  • Claim: Çl2L:l is a Conflict Clause.

1. (x10Ç:x1Ç x9Ç x11)

[email protected]

2. (x10Ç:x4Ç x11)

3. (x10Ç:x2Ç:x3Ç x11)

[email protected]

[email protected]

[email protected]


Conflict clauses
Conflict clauses

  • How many clauses should we add ?

  • If not all, then which ones ?

    • Shorter ones ?

    • Check their influence on the backtracking level ?

    • The most “influential” ?

  • The answer requires two definitions:

    • Asserting clauses

    • Unique Implication points (UIP’s)


Asserting clauses
Asserting clauses

  • Def: An Asserting Clause is a Conflict Clause with a single literal from the current decision level. Backtracking (to the right level) makes it a Unit clause.

  • Modern solvers only consider Asserting Clauses.


Conflict driven backtracking option 2

Previous method: backtrack to highest decision level in conflict clause (and erase it).

A better method (empirically): backtrack to the second highest decision level in the clause, without erasing it. The asserted literal is implied at that level.

In our example: (x10Ç:x4Çx11)

Previously we backtracked to decision level 6.

Now we backtrack to decision level 3. x4 = [email protected] is implied.

Conflict-driven backtracking (option #2)

3

6

3


Conflict driven backtracking
Conflict-driven Backtracking conflict clause (and erase it).

x1 = 0

x2 = 0

x5 = 1

x3 = 1

x7 = 1

x9 = 1

x4 = 0

x3 = 1

x6 = 0

...

x5 = 0

x9 = 0


Conflict driven backtracking1
Conflict-Driven Backtracking conflict clause (and erase it).

  • So the rule is: backtrack to the second highest decision level dl, but do not erase it.

    • If the conflict clause has a single literal, backtrack to decision level 0.

  • Q: It seems to waste work, since it erases assignments in decision levels higher than dl, unrelated to the conflict.

  • A: indeed. But allows the SAT solver to redirect itself with the new information.


Progress of a sat solver
Progress of a SAT solver conflict clause (and erase it).

work invested in refutingx=1

(some of it seems wasted)

C

x=1

Refutation of x=1

C5

C2

Decision

Level

C1

C4

BCP

C3

Decision

Time

Conflict


Conflict clauses and resolution
Conflict clauses and Resolution conflict clause (and erase it).

The Resolution is a sound inference rule:

Example:


Conflict clauses and resolution1
Conflict clauses and resolution conflict clause (and erase it).

  • Consider the following example:

  • Conflict clause: c5: (x2 Ç:x4Çx10)


Conflict clauses and resolution2
Conflict clauses and resolution conflict clause (and erase it).

  • Conflict clause: c5: (x2 Ç:x4Çx10)

  • Resolution order: x4,x5,x6,x7

    • T1 = Resolve(c4,c3,x7) = (:x5Ç:x6)

    • T2 = Resolve(T1, c2, x6) = (:x4Ç:x5 Ç X10 )

    • T3 = Resolve(T2,c1,x5) = (x2Ç:x4Ç x10 )


Finding the conflict clause
Finding the conflict clause: conflict clause (and erase it).

cl is asserting the first UIP

Applied to our example:


Gsat stochastic sat solving
GSAT: stochastic SAT solving conflict clause (and erase it).

Given a CNF formula , choose max_tries and max_flips

for i = 1 to max_tries {

T := randomly generated truth assignment

for j = 1 to max_flips {

if T satisfies  return TRUE

choose v s.t. flipping v’s value gives largest increase in

the # of satisfied clauses (break ties randomly).

T := T with v’s assignment flipped. } }

Many alternative heuristics


Numerous progressing heuristics
Numerous progressing heuristics conflict clause (and erase it).

  • Hill-climbing

  • Tabu-list

  • Simulated-annealing

  • Random-Walk

  • Min-conflicts

  • ...


Formulation of problems as SAT: conflict clause (and erase it).

k-Coloring

The K-Coloring problem:

Given an undirected graph G(V,E) and a natural number k, is there an assignment color:


Formulation of problems as SAT: conflict clause (and erase it).

k-Coloring

xi,j= node i is assigned the ‘color’ j (1 in, 1 jk)

Constraints:

i) At least one color to each node: (x1,1  x1,2 … x1,k …)

ii) At most one color to each node:

iii) Coloring constraints: for each i,j such that (i,j) 2 E:


ad