sat solving – algorithms

72
I DPLL I CDCL I A solving abstraction Steffen H¨ olldobler and Norbert Manthey SAT Solving – Algorithms 1 SAT Solving – Algorithms Steffen H ¨ olldobler and Norbert Manthey International Center for Computational Logic Technische Universit¨ at Dresden Germany

Upload: others

Post on 14-Apr-2022

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SAT Solving – Algorithms

I DPLL

I CDCL

I A solving abstraction

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 1

SAT Solving – Algorithms

Steffen Holldobler and Norbert MantheyInternational Center for Computational LogicTechnische Universitat DresdenGermany

Page 2: SAT Solving – Algorithms

Warm Up

I Used programming languages

I Size of implemented projects

I Parallel computing (multi-core, GPGPU, cluster)

I Interest in computer architecture

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 2

Page 3: SAT Solving – Algorithms

Warm Up

I Used programming languages

I Size of implemented projects

I Parallel computing (multi-core, GPGPU, cluster)

I Interest in computer architecture

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 3

Page 4: SAT Solving – Algorithms

Warm Up

I Used programming languages

I Size of implemented projects

I Parallel computing (multi-core, GPGPU, cluster)

I Interest in computer architecture

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 4

Page 5: SAT Solving – Algorithms

Warm Up

I Used programming languages

I Size of implemented projects

I Parallel computing (multi-core, GPGPU, cluster)

I Interest in computer architecture

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 5

Page 6: SAT Solving – Algorithms

Revision

I Used Data Types

I Semantics

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 6

Page 7: SAT Solving – Algorithms

Formulas and Interpretations

I Let F be a formulas an I be an interpretation

I I can. satisfy F , if F |I ≡ >. falsify F , if F |I ≡ ⊥

I A formula can be. unsatisfiable, F ≡ ⊥. satisfiable. tautologic, F ≡ >

I Property: F ≡ >, then ¬F ≡ ⊥.

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 7

Page 8: SAT Solving – Algorithms

Formulas and Interpretations

I Let F be a formulas an I be an interpretation

I I can. satisfy F , if F |I ≡ >. falsify F , if F |I ≡ ⊥

I A formula can be. unsatisfiable, F ≡ ⊥. satisfiable. tautologic, F ≡ >

I Property: F ≡ >, then ¬F ≡ ⊥.

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 8

Page 9: SAT Solving – Algorithms

Formulas and Interpretations

I Let F be a formulas an I be an interpretation

I I can. satisfy F , if F |I ≡ >. falsify F , if F |I ≡ ⊥

I A formula can be. unsatisfiable, F ≡ ⊥. satisfiable. tautologic, F ≡ >

I Property: F ≡ >, then ¬F ≡ ⊥.

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 9

Page 10: SAT Solving – Algorithms

Clauses and Conjunctive Normal Forms

I Definition

. A clause is a generalized disjunction [L1, . . . , Ln], n ≥ 0,where every Li , 1 ≤ i ≤ n, is a literal

. A clause is a unit clause if it contains precisely one literal

. A clause is a binary clause if it contains precisely two literals

I Definition

. A formula is in conjunctive normal form (clause form, CNF) iffit is of the form 〈C1, . . . , Cm〉, m ≥ 0, and every Cj , 1 ≤ j ≤ m, is a clause

I Implementation and working assumptions

. A clause is an array of literals

II Maintained to be a set of literals (no duplicates)

II Clauses are no tautologies (excluded during parsing)

. A formula is an array of (pointers/references to) clauses

II Maintained to be a multi set

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 10

Page 11: SAT Solving – Algorithms

Clauses and Conjunctive Normal Forms

I Definition

. A clause is a generalized disjunction [L1, . . . , Ln], n ≥ 0,where every Li , 1 ≤ i ≤ n, is a literal

. A clause is a unit clause if it contains precisely one literal

. A clause is a binary clause if it contains precisely two literals

I Definition

. A formula is in conjunctive normal form (clause form, CNF) iffit is of the form 〈C1, . . . , Cm〉, m ≥ 0, and every Cj , 1 ≤ j ≤ m, is a clause

I Implementation and working assumptions

. A clause is an array of literals

II Maintained to be a set of literals (no duplicates)

II Clauses are no tautologies (excluded during parsing)

. A formula is an array of (pointers/references to) clauses

II Maintained to be a multi set

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 11

Page 12: SAT Solving – Algorithms

Propositional Resolution

I Remind: clauses are considered to be sets

I Definition Let C1 be a clause containing L and C2 be a clause containing L;The (propositional) resolvent of C1 and C2 with respect to L is the clause

(C1 \ {L}) ∪ (C2 \ {L})

C is said to be a resolvent of C1 and C2 iffthere exists a literal L such that C is the resolvent of C1 and C2 wrt L

I Examples when resolving on a

I (a ∨ ¬a)⊗ (¬a ∨ a) = (a ∨ ¬a)

I (a ∨ ¬b)⊗ (¬a ∨ b) = (b ∨ ¬b)

I (a ∨ b)⊗ (¬a ∨ b) = (b)

I Resolvents can subsume antecedents

I Usually, resolvents have more literals than antecedents

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 12

Page 13: SAT Solving – Algorithms

Propositional Resolution

I Remind: clauses are considered to be sets

I Definition Let C1 be a clause containing L and C2 be a clause containing L;The (propositional) resolvent of C1 and C2 with respect to L is the clause

(C1 \ {L}) ∪ (C2 \ {L})

C is said to be a resolvent of C1 and C2 iffthere exists a literal L such that C is the resolvent of C1 and C2 wrt L

I Examples when resolving on a

I (a ∨ ¬a)⊗ (¬a ∨ a) = (a ∨ ¬a)

I (a ∨ ¬b)⊗ (¬a ∨ b) = (b ∨ ¬b)

I (a ∨ b)⊗ (¬a ∨ b) = (b)

I Resolvents can subsume antecedents

I Usually, resolvents have more literals than antecedents

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 13

Page 14: SAT Solving – Algorithms

Propositional Resolution

I Remind: clauses are considered to be sets

I Definition Let C1 be a clause containing L and C2 be a clause containing L;The (propositional) resolvent of C1 and C2 with respect to L is the clause

(C1 \ {L}) ∪ (C2 \ {L})

C is said to be a resolvent of C1 and C2 iffthere exists a literal L such that C is the resolvent of C1 and C2 wrt L

I Examples when resolving on a

I (a ∨ ¬a)⊗ (¬a ∨ a) = (a ∨ ¬a)

I (a ∨ ¬b)⊗ (¬a ∨ b) = (b ∨ ¬b)

I (a ∨ b)⊗ (¬a ∨ b) = (b)

I Resolvents can subsume antecedents

I Usually, resolvents have more literals than antecedents

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 14

Page 15: SAT Solving – Algorithms

SAT Solving

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 15

Page 16: SAT Solving – Algorithms

SAT Solving - Example

I Given: Conjunction of clauses

I Task: Find satisfying interpretation for variables if possible!

F = (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I How to find a solution?

I Some questions:

1. How many combinations (solution candidates) exist for 6 Boolean variables?

2. How many percent of the candidates are cut by a unit clause?

3. How many percent of the candidates are cut by a binary, ternary, ... clause?

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 16

Page 17: SAT Solving – Algorithms

SAT Solving - Example

I Given: Conjunction of clauses

I Task: Find satisfying interpretation for variables if possible!

F = (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I How to find a solution?

I Some questions:

1. How many combinations (solution candidates) exist for 6 Boolean variables?

2. How many percent of the candidates are cut by a unit clause?

3. How many percent of the candidates are cut by a binary, ternary, ... clause?

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 17

Page 18: SAT Solving – Algorithms

SAT Solving - Example

I Given: Conjunction of clauses

I Task: Find satisfying interpretation for variables if possible!

F = (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I How to find a solution?

I Some questions:

1. How many combinations (solution candidates) exist for 6 Boolean variables?

2. How many percent of the candidates are cut by a unit clause?

3. How many percent of the candidates are cut by a binary, ternary, ... clause?

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 18

Page 19: SAT Solving – Algorithms

SAT Solving - Example

I Given: Conjunction of clauses

I Task: Find satisfying interpretation for variables if possible!

F = (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I How to find a solution?

I Some questions:

1. How many combinations (solution candidates) exist for 6 Boolean variables?

2. How many percent of the candidates are cut by a unit clause?

3. How many percent of the candidates are cut by a binary, ternary, ... clause?

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 19

Page 20: SAT Solving – Algorithms

Power of Modern SAT Solvers

10

100

1000

10000

100000

1e+06

1e+07

1e+08

10 100 1000 10000 100000 1e+06 1e+07 1e+08

Cla

use

s

Variables

identity

0

100

200

300

400

500

600

700

800

900

run

tim

e

I RISS 4.27, SAT Competition 2014, application track

I Formulas with several million clauses and variables can be solved

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 20

Page 21: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F

|b

a

= (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a

and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 21

Page 22: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F

|b

a

= (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a

and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 22

Page 23: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F

|b

a

= (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a

and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 23

Page 24: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F

|b

a

= (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a

and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 24

Page 25: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F |b

a

= (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a

and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 25

Page 26: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F |b

a

= (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a

and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 26

Page 27: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F |ba = (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a

and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 27

Page 28: SAT Solving – Algorithms

SAT Solving – With Search

I Assume a literal

I Propagate immediate consequences

I If a conflict, backtrack

I Known as DPLL (Davis Putnam Logemann Loveland)

I What are immediate consequences?

F |ba = (a ∨ c) ∧ (b ∨ e ∨ f ) ∧ (a ∨ d ∨ f ) ∧ (a ∨ b ∨ d ∨ e) ∧ (a ∨ b)

I Assume b = >, then we have J = (b)

I Are there variables with a forced assignment?

. a and c

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 28

Page 29: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

-

c

-

d

-

e

-

f

-

a

b

c

dd

e

f

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 29

Page 30: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

-

c

-

d

-

e

-

f

-

a

b

c

dd

e

f

I add a search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 30

Page 31: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

C1

c

-

d

-

e

-

f

-

a

b

c

dd

e

f

I propagate consequences

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 31

Page 32: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

C1

c

-

d

-

e

-

f

-

a

b

c

dd

e

f

I add a search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 32

Page 33: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

C1

c

-

d

-

e

-

f

-

a

b

c

d

d

e

f

I add a search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 33

Page 34: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C2

f

-

a

b

c

d

d

e

f

I propagate consequences

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 34

Page 35: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C2

f

C4

a

b

c

d

d

e

f

I propagate consequences

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 35

Page 36: SAT Solving – Algorithms

Davis Putnam Logemann Loveland (DPLL) in a Nutshell

=(a ∨ b) ∧ (b ∨ d ∨ e) ∧ (c ∨ d) ∧ (a ∨ b ∨ e ∨ f ) ∧ (a ∨ e ∨ f ) ∧ (d ∨ f ) ∧ (c ∨ e ∨ f )

DPLL

found conflictC5 = (a ∨ e ∨ f)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C2

f

C4

a

b

c

dd

e

f

I backtrack from conflict and proceed with search

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 36

Page 37: SAT Solving – Algorithms

DPLL pseudo code

I An iterative solving algorithm

IDPLL (CNF formula F )

Input: A formula F in CNFOutput: The solution SAT or UNSAT of this formula

1 J := () // start with empty interpretation2 while true // until we find a solution3 if F |J = ∅ then return SAT // satisfiability rule4 if [] ∈ F |J then // there was a conflict5 if J = J′xJ′′ and @y ∈ J′′ then // backtrack and undo most recent decision6 J := J′x // add the complement7 continue8 else return UNSAT // unsatisfiability rule9 if (x) ∈ F |J then // unit rule

10 J := Jx // extend the interpretation11 continue12 if x ∈ lits(F |J ) and x /∈ lits(F |J ) then // pure literal rule13 J := Jx14 continue15 J := Jx for some x ∈ lits(F |J ) // decide rule

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 37

Page 38: SAT Solving – Algorithms

Conclusions of the DPLL Algorithm

I Chronological backtracking

I Heavily depends on the order of the decision variables

I How to perform unit propagation? How to find a unit in the formula efficiently?

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 38

Page 39: SAT Solving – Algorithms

Unit Propagation

I How to perform unit propagation?

I How to find a unit in the formula efficiently?

I Assumption: we use the presented pseudo code as algorithm.

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 39

Page 40: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 40

Page 41: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

-

c

-

d

-

e

-

f

-

a

b

ce

d

e

f

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 41

Page 42: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

-

c

-

d

-

e

-

f

-

a

b

ce

d

e

f

I add a search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 42

Page 43: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

-

f

-

a

b

ce

d

e

f

I propagate consequences

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 43

Page 44: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

-

f

-

a

b

c

ed

e

f

I add a search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 44

Page 45: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

-

f

-

a

b

c

e

d

e

f

I add a search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 45

Page 46: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C2

f

-

a

b

c

e

d

e

f

I propagate consequences

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 46

Page 47: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C2

f

C4

a

b

c

e

d

e

f

I propagate consequences

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 47

Page 48: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C2

f

C4

a

b

c

e

d

e

f

I create and add the learned clause to the formula

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 48

Page 49: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C2

f

C4

a

b

c

e

d

e

f

I create and add the learned clause to the formula

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 49

Page 50: SAT Solving – Algorithms

Conflict Driven Clause Learning (CDCL) in a Nutshell

F =(a ∨ b)∧ (b ∨ d ∨ e)∧ (c ∨ d)∧ (a ∨ b ∨ e ∨ f )∧ (a ∨ e ∨ f )∧ (d ∨ f )∧ (c ∨ e ∨ f )

CDCL

found conflictC5 = (a ∨ e ∨ f)

clause learningC7 = C4 ⊗ C5 : (a ∨ b ∨ e)

minimizationC8 = C7 ⊗ C1 : (a ∨ e)

Variable

Reason

a

-

b

C1

c

-

d

-

e

C8

f

-

a

b

ce

d

e

f

I backtrack, add C8, and proceed with unit propagation

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 50

Page 51: SAT Solving – Algorithms

The CDCL Algorithm

CDCL (CNF formula F )

Input: A formula F in CNFOutput: The solution SAT or UNSAT of this formula

1 J := () // start with empty interpretation2 while true3 while (x) ∈ F |J do // unit rule4 J := Jx5 if [] ∈ F |J then // conflict6 if ∃y ∈ J, such that J = J′J′′yJ′′′ then7 F := F ∪ C with F |= C and C /∈ F // learning8 J := J′ // backjumping9 else return UNSAT // unsatisfiability rule

10 else // no empty clause in F |J11 if atoms(J) ⊇ atoms(F ) then return SAT // satisfiability rule12 else J := Jz with atoms(z) ⊆ atoms(F ) // decision rule

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 51

Page 52: SAT Solving – Algorithms

Conclusions of the CDCL Algorithm

I Heavily depends on the order of the decision variables

I Non-Chronological backtracking, backjumping

I Learning of new clauses

I No mentioned here: restarts, clause removal

I Question: can the CDCL algorithm simulate the DPLL algorithm?

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 52

Page 53: SAT Solving – Algorithms

An Intuitive Abstraction of SAT Solver Techniques

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 53

Page 54: SAT Solving – Algorithms

Finding an Exit in a Maze

I Some rules

. starting point is located in the left column

. exit is on the right side (if there exists one)

. search decisions can be done only when moving right

. when moving left, use backtracking

I Property: satisfiable formulas correspond to mazes that can be solved bysearching right only

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 54

Page 55: SAT Solving – Algorithms

The DPLL Algorithm

I Heuristics:

. pick the highest possible column

. then, pick the lowest column

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 55

Page 56: SAT Solving – Algorithms

The DPLL Algorithm

I Heuristics:

. pick the highest possible column

. then, pick the lowest column

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 56

Page 57: SAT Solving – Algorithms

The DPLL Algorithm

I Heuristics:

. pick the highest possible column

. then, pick the lowest column

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 57

Page 58: SAT Solving – Algorithms

The DPLL Algorithm

I No decision, hence propagate

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 58

Page 59: SAT Solving – Algorithms

The DPLL Algorithm

I No exit (conflict), hence backtrack

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 59

Page 60: SAT Solving – Algorithms

The DPLL Algorithm

I No exit in the upper search space, hence backtrack

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 60

Page 61: SAT Solving – Algorithms

The DPLL Algorithm

I Do next search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 61

Page 62: SAT Solving – Algorithms

The DPLL Algorithm

I Enter the same search space as before

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 62

Page 63: SAT Solving – Algorithms

The CDCL Algorithm (conflict driven clause learning)

I Choose,

I Propagate,

I and Backtrack after Conflict

I . . . enters the same search space again and again.

I Let’s go a few steps back . . .

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 63

Page 64: SAT Solving – Algorithms

The CDCL Algorithm (conflict driven clause learning)

I No decision, hence propagate

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 64

Page 65: SAT Solving – Algorithms

The CDCL Algorithm (conflict driven clause learning)

I No exit (conflict), hence backtrack

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 65

Page 66: SAT Solving – Algorithms

The CDCL Algorithm (conflict driven clause learning)

I . . . and learn a clause

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 66

Page 67: SAT Solving – Algorithms

The CDCL Algorithm (conflict driven clause learning)

I No exit in upper search space, backtrack and learn

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 67

Page 68: SAT Solving – Algorithms

The CDCL Algorithm (conflict driven clause learning)

I Do next search decision

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 68

Page 69: SAT Solving – Algorithms

The CDCL Algorithm (conflict driven clause learning)

I Does not enter the same search space as before

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 69

Page 70: SAT Solving – Algorithms

Motivating Clause Removal

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 70

Page 71: SAT Solving – Algorithms

How to perform Unit Propagation

I When is a unit clause in the reduct?

I How to find a unit clause in the reduct, especially in the CDCL algorithm?

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 71

Page 72: SAT Solving – Algorithms

Coming Next

I Simplification

I Parallel Search

Steffen Holldobler and Norbert MantheySAT Solving – Algorithms 72