Top Banner
An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15-414: Bug Catching Professor Edmund M. Clarke Carnegie Mellon University 2007
53

An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Feb 16, 2018

Download

Documents

lenguyet
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

An Example of the GRASP SAT Solver

Michael Carl Tschantzwith help from Himanshu Jain

15­414: Bug CatchingProfessor Edmund M. ClarkeCarnegie Mellon University

2007

Page 2: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

GRASP● GRASP is SAT solver ● Created by 

  Joan P. Marques Silva and   Karem A. Sakallah

● See “GRASP – A New Search Algorithm for Satisfiability” by Silva and Sakallah for details

● This just presents an example of the algorithm in action

Page 3: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Simplifying Assumption● I will act as though GRASP selects the next 

variable to assign a value to in numerical order and always tries false first

● In reality, GRASP selects the assignment that would satisfy as many clauses as possible

● I could add clauses to my example to avoid this simplification, but I like small examples

Page 4: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

The Clauses● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = ¬x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

Page 5: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Starting State● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

start

Page 6: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x1● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

Page 7: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x1● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

Page 8: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x2● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2

Page 9: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x3● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2

x3=0@3

Page 10: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x3● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2

x3=0@3

We have a unit clause!  x6 must be set to true.

Page 11: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x3● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2

x3=0@3

The x6 is set to true because x3 was set to false.This might be useful info.  Let's remember it.  

Page 12: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Implication Graph

● An implication graph keeps track of why variables are assigned the value that they are● Each assigned variable has a node● Variables that force another variable to have an certain assignment point to it 

Page 13: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Implication Graph● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

Let's make an implication graph.

Page 14: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Implication Graph● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

Each assignment gets a node.

x1=0@1

x2=0@2

x3=0@3 x6=1@3

Page 15: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Implication Graph● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

Edges connect a node to why it was assigned the way it was

x1=0@1

x2=0@2

x3=0@3 x6=1@3

Page 16: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Implication Graph● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

Edges connect a node to why it was assigned the way it was

x1=0@1

x2=0@2

x3=0@3 x6=1@3w3

Because x3 = 0, x6 must be 1.We know this from w3

Page 17: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Implication Graph● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

Edges connect a node to why it was assigned the way it was

x1=0@1

x2=0@2

x3=0@3 x6=1@3w3

x1, x2, x3 are set to 0 because they are decision variables.

No edges to them.

Page 18: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Implication Graph● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

The finished graph

x1=0@1

x2=0@2

x3=0@3 x6=1@3w3

Page 19: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x3=0@3 x6=1@3w3

x4=0@4

Page 20: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x3=0@3 x6=1@3w3

x4=0@4

Add new node to graph

x4=0@4

Page 21: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

Forces x5 to be false.

x3=0@3 x6=1@3w3

x4=0@4

Page 22: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

Add node and edges

x3=0@3 x6=1@3

x4=0@4 x5=0@4w2w2

w3

w2

Page 23: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

Leads to conflict!

x3=0@3 x6=1@3

x4=0@4 x5=0@4

Page 24: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

Add conflict node k1

x3=0@3 x6=1@3

x4=0@4 x5=0@4 k1@4

Page 25: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

What caused conflict k1?Follow the edges back to see

x3=0@3 x6=1@3

x4=0@4 x5=0@4 k1@4

Page 26: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

What caused conflict k1?Follow the edges back to see

x3=0@3 x6=1@3

x4=0@4 x5=0@4 k1@4

It was that x1=0, x2=0, and x4=0i.e., ¬x1 & ¬x2 & ¬x4 

Page 27: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

What caused conflict k1?Follow the edges back to see

x3=0@3 x6=1@3

x4=0@4 x5=0@4 k1@4

It was that x1=0, x2=0, and x4=0i.e., ¬x1 & ¬x2 & ¬x4 

We don't need x5=0 since it is implied

Page 28: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4.● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

How can we avoid k1?

x3=0@3 x6=1@3

x4=0@4 x5=0@4 k1@4

Page 29: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Conflict Clauses

● k1 was caused by¬x1 & ¬x2 & ¬x4● To avoid k1, force this not to be true● Add conflict clause

                 w(k1) =  ¬(¬x1 & ¬x2 & ¬x4)                            =   x1 + x2 + x4 

Page 30: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Add Conflict Clause ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=0@4 x5=0@4 k1@4

Page 31: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Add Conflict Clause ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=0@4 x5=0@4 k1@4

w(k1) forces x4 to be true

Page 32: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Undo x4=0@4 ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

Page 33: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign True to x4 ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4

x4=1@4

Page 34: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign True to x4 ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4x4=0@4

Forces x7 to be true

x4=1@4

Page 35: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign True to x4 ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4x4=0@4

Add node and edges

x4=1@4

x7=1@4

Page 36: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign True to x4 ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4x4=0@4

Leads to conflict!

x4=1@4

x7=1@4

Page 37: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign True to x4 ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4x4=0@4

Add conflict node k2

x4=1@4

x7=1@4k2@4

Page 38: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign True to x4 ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4x4=0@4

Go backwards from k2 to find root causes

x4=1@4

x7=1@4k2@4

Page 39: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Add Conflict Clause w(k2) ● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4x4=0@4

x4=1@4

x7=1@4k2@4

Page 40: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Backtracking● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4

x3=0@3 x6=1@3

x4=1@4x4=0@4

We need to undo x4=1@4

Page 41: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Backtracking● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4 x4=1@4x4=0@4

Since we tried both x4=0 and x4=1,we'll also have to undo x3=0

Page 42: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Backtracking● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4 x4=1@4x4=0@4

Now we try x3=1@3

Page 43: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Backtracking● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x2=0@2

x4=0@4 x4=1@4x4=0@4

Now we try x3=1@3

But wait!  x3 had nothing to do with k2.  We can skip trying x3=1@3 and backtrack up to x2=0@2

Page 44: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Non­Chronological Backtracking● SAT solvers like Davis­Putnam undo 

assignments in the reserve order in which they are made and always try the other assignment

● GRASP does non­chronological backtracking:it will skip assignment points all together and jump up higher in the decision tree

Page 45: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Non­Chronological Backtracking● SAT solvers like Davis­Putnam undo 

assignments in the reserve order in which they are made and always try the other assignment 

● GRASP does non­chronological backtracking:it will skip assignment points all together and jump up higher in the decision tree

x1=0@1

start

x2=0@2x3=0@3x4=0@4 x4=1@4x4=0@4

Page 46: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Non­Chronological Backtracking● GRASP gets away with this because the conflict 

clause made from the implication graph allows it to know what assignments did not play a role in the conflict

● GRASP then jumps up to the latest assignment that did play a role

● This called conflict­driven backtracking

Page 47: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Backtracking● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

Undo x2=0@2

x1=0@1

start

x2=0@2x3=0@3x4=0@4x4=0@4 x4=1@4

Page 48: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign True to x2● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

x2=1@2

x1=0@1

start

x2=0@2x3=0@3x4=0@4x4=0@4

x2=1@2

x4=1@4

Page 49: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x3● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

x2=1@2

x3=0@3 x6=1@3x1=0@1

start

x2=0@2x3=0@3x4=0@4x4=0@4

x2=1@2

x4=1@4

x3=0@3

Page 50: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x4=0@4x4=0@4

x2=1@2

x4=1@4

x2=1@2

x3=0@3 x6=1@3

x3=0@3

x4=0@4

x4=0@4

Page 51: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Assign False to x4● w1 = x1 + x2 + x5 + x4● w2 = x1 + x2 + ¬x5 + x4● w3 = x3 + x6● w4 = ¬x4 + x7 + x1● w5 = ¬x4 + ¬x7 + x2● w(k1) = x1 + x2 + x4● w(k2) = x1 + x2

x1=0@1

start

x2=0@2x3=0@3

x1=0@1

x4=0@4x4=0@4

x2=1@2

x4=1@4

x2=1@2

x3=0@3 x6=1@3

x3=0@3

x4=0@4

x4=0@4All Clauses Satisfied

We Are Done!

Page 52: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Key Points

● The implication graph allows us to know why a conflict forms

● A conflict clause summarizes how to avoid a conflict

● Knowing this allows for conflict­driven non­chronological backtracking

Page 53: An Example of the GRASP SAT Solvermtschant/15414-f07/lectures/grasp-ex.pdf · An Example of the GRASP SAT Solver Michael Carl Tschantz with help from Himanshu Jain 15414: Bug Catching

Something to Ponder● Keeping an implication graph takes both time and 

memory● Is the ability to do conflict­driven backtracking 

worth this cost?● How would you find out?