logical aspects of ai lecture 1 - sat solvers sylvain conchonconchon/enspsaclay/lecture1.pdf ·...

150
ENS Paris-Saclay 2019 - 2020 Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit´ e Paris-Sud ´ Equipe Toccata, INRIA Saclay – ˆ Ile-de-France 1

Upload: others

Post on 28-Sep-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

ENS Paris-Saclay

2019 - 2020

Logical Aspects of AI

Lecture 1 - SAT solvers

Sylvain Conchon

LRI (UMR 8623), Universite Paris-SudEquipe Toccata, INRIA Saclay – Ile-de-France

1

Page 2: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Road map

Lecture 1

I The SAT problem

I Resolution

I DPLL algorithm

I Clause conflict, backjump

I CDCL algorithm

I Heuristics, Two-watched literals

2

Page 3: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Modern SAT solvers

3

Page 4: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

The SAT Problem

Is (p ∨ q ∨ ¬r) ∧ (r ∨ ¬p) satisfiable?

I Truth tables

I Resolution-based procedure (DP [1960])

I Backtracking-based procedure (DPLL [1962])

I 80’s - 90’s: focus on variable selection heuristics

I Search-pruning techniques: Non-chronological backtracking,Learning clauses (Grasp [1996]) CDCL

I Indexing: two-watched literals (Zchaff, 2001)

I Scoring: deletion of bad learning clauses (Glucose, 2009)

4

Page 5: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Propositional Logic : Notations

p, q, r, s are propositional variables or atoms

` is a literal (p or ¬p)

¬` =

{¬p if l is pp if l is ¬p

A disjunction of literals `1 ∨ . . . ∨ `n is a clause

The empty clause is written ⊥

A conjunction of clauses is a CNF

To improve readability, we sometime

I denote atoms by natural numbers and negation by overliningI write CNF as sets of clauses

e.g. (¬`1 ∨ `2 ∨¬`3)∧ (`4 ∨¬`2) is simply written {1∨ 2∨ 3, 4∨ 2}5

Page 6: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Propositional Logic : Assignments

An assignment M is a set of literals such that if ` ∈M then¬` 6∈M

A literal ` is true in M if ` ∈M , and false if ¬` ∈M

A literal ` is defined in M if it is either true or false in M

A clause is true in M if at least one of its literal is true in M , it isfalse if all its literals are false in M , it is undefined otherwise

The empty clause ⊥ is not satisfiable

A clause C ∨ ` is a unit clause in M if C is false in M and ` isundefined in M

6

Page 7: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Propositional Logic : Satisfiability

A CNF F is satisfied by M (or M is a model of F ), writtenM |= F , if all clauses of F are true in M

If F has no model then it is unsatisfiable

F ′ is entailed by F , written F |= F ′, if F ′ is true in all models of F

F and F ′ are equivalent when F |= F ′ and F ′ |= F

F and F ′ are equisatisfiable whenF is satisfiable if and only if F ′ is satisfiable

F is valid if and only if ¬F is unsatisfiable

7

Page 8: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution

I Proof-finder procedure

I Works by saturation until the empty clause is derived

Exhaustive resolution is not practical:

exponential amount of memory

8

Page 9: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : State of the Procedure

The state of the procedure is represented by a variable (imperativestyle) F containing a set of clauses (CNF)

9

Page 10: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Algorithm

ResolveC ∨ ` ∈ F D ∨ ¬` ∈ F C ∨D 6∈ F

F := F ∪ {C ∨D}

Empty` ∈ F ¬` ∈ F

F := F ∪ ⊥

TautoF = F ′ ] {C ∨ ` ∨ ¬`}

F := F ′

SubsumeF = F ′ ] {C ∨D} C ∈ F ′

F := F ′

Fail⊥ ∈ F

returnUnsat

10

Page 11: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

F = {1 ∨ 2 ∨ 3, 1 ∨ 2, 1 ∨ 3, 3}

11

Page 12: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Resolve1 ∨ 2 ∨ 3 ∈ F 1 ∨ 3 ∈ F

F := F ∪ {2 ∨ 3}

F = {1 ∨ 2 ∨ 3, 1 ∨ 2, 1 ∨ 3, 3}

11

Page 13: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Resolve1 ∨ 2 ∨ 3 ∈ F 1 ∨ 3 ∈ F

F := F ∪ {2 ∨ 3}

F = {1 ∨ 2 ∨ 3, 1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3}

11

Page 14: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

SubsumeF = F ′ ] {1 ∨ 2 ∨ 3} 2 ∨ 3 ∈ F ′

F := F ′

F = {1 ∨ 2 ∨ 3, 1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3}

11

Page 15: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

SubsumeF = F ′ ] {1 ∨ 2 ∨ 3} 2 ∨ 3 ∈ F ′

F := F ′

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3}

11

Page 16: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Resolve1 ∨ 2 ∈ F 1 ∨ 3 ∈ F

F := F ∪ {2 ∨ 3}

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3}

11

Page 17: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Resolve1 ∨ 2 ∈ F 1 ∨ 3 ∈ F

F := F ∪ {2 ∨ 3}

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3, 2 ∨ 3}

11

Page 18: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Resolve2 ∨ 3 ∈ F 2 ∨ 3 ∈ F

F := F ∪ {3}

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3, 2 ∨ 3}

11

Page 19: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Resolve2 ∨ 3 ∈ F 2 ∨ 3 ∈ F

F := F ∪ {3}

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3, 2 ∨ 3, 3}

11

Page 20: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Empty3 ∈ F 3 ∈ F

F := F ∪ {⊥}

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3, 2 ∨ 3, 3}

11

Page 21: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Empty3 ∈ F 3 ∈ F

F := F ∪ {⊥}

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3, 2 ∨ 3, 3,⊥}

11

Page 22: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Resolution : Example

Fail⊥ ∈ F

return Unsat

F = {1 ∨ 2, 1 ∨ 3, 3, 2 ∨ 3, 2 ∨ 3, 3,⊥}

11

Page 23: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL

DPLL is a model-finder procedure that builds incrementally amodel M for a CNF formula F by

I deducing the truth value of a literal ` from M and F byBoolean Constraint Propagations (BCP)

If C ∨ ` ∈ F and M |= ¬C then ` must be true

I guessing the truth value of an unassigned literal

If M ∪ {`} leads to a model for which F is unsatisfiablethen backtrack and try M ∪ {¬`}

12

Page 24: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : State of the Procedure

The state of the procedure is represented by

I a variable F containing a set of clauses (CNF)

I a variable M containing a list of literals

13

Page 25: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Algorithm

SuccessM |= F

return Sat

UnitC ∨ ` ∈ F M |= ¬C ` is undefined in M

M := ` :: M

Decide` is undefined in M ` (or ¬`) ∈ F

M := `@ :: M

Backtrack

C ∈ F M |= ¬C M = M1 :: `@ :: M2

M1 contains no decision literals

M := ¬` :: M2

FailC ∈ F M |= ¬C M contains no decision literals

return Unsat14

Page 26: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

M = []

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 27: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide1 is undefined in M 1 ∈ F

M := 1@ :: M

M = []

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 28: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide1 is undefined in M 1 ∈ F

M := 1@ :: M

M = [1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 29: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit1 ∨ 2 ∈ F M |= 1 2 is undefined in M

M := 2 :: M

M = [1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 30: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit1 ∨ 2 ∈ F M |= 1 2 is undefined in M

M := 2 :: M

M = [2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 31: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 32: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 33: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit3 ∨ 4 ∈ F M |= 3 4 is undefined in M

M := 4 :: M

M = [3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 34: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit3 ∨ 4 ∈ F M |= 3 4 is undefined in M

M := 4 :: M

M = [4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 35: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 36: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 37: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 6 :: M

M = [5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 38: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 6 :: M

M = [6; 5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 39: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

6 ∨ 5 ∨ 2 ∈ F

M |= 6 ∧ 5 ∧ 2 M = [6] :: 5@ :: [4; 3@; 2; 1@]

M := 5 :: [4; 3@; 2; 1@]

M = [6; 5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 40: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

6 ∨ 5 ∨ 2 ∈ F

M |= 6 ∧ 5 ∧ 2 M = [6] :: 5@ :: [4; 3@; 2; 1@]

M := 5 :: [4; 3@; 2; 1@]

M = [5; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 41: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [5; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 42: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [7; 5; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 43: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

5 ∨ 7 ∨ 2 ∈ F

M |= 5 ∧ 7 ∧ 2 M = [7; 5; 4] :: 3@ :: [2; 1@]

M := 3 :: [2; 1@]

M = [7; 5; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 44: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

5 ∨ 7 ∨ 2 ∈ F

M |= 5 ∧ 7 ∧ 2 M = [7; 5; 4] :: 3@ :: [2; 1@]

M := 3 :: [2; 1@]

M = [3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 45: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 46: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [5@; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 47: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 6 :: M

M = [5@; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 48: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 6 :: M

M = [6; 5@; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 49: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

6 ∨ 5 ∨ 2 ∈ F

M |= 6 ∧ 5 ∧ 2 M = [6] :: 5@ :: [3; 2; 1@]

M := 5 :: [3; 2; 1@]

M = [6; 5@; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 50: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

6 ∨ 5 ∨ 2 ∈ F

M |= 6 ∧ 5 ∧ 2 M = [6] :: 5@ :: [3; 2; 1@]

M := 5 :: [3; 2; 1@]

M = [5; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 51: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [5; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 52: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [7; 5; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 53: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

5 ∨ 7 ∨ 2 ∈ FM |= 5 ∧ 7 ∧ 2 M = [7; 5; 3; 2] :: 1@ :: []

M := 1 :: []

M = [7; 5; 3; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 54: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Backtrack

5 ∨ 7 ∨ 2 ∈ FM |= 5 ∧ 7 ∧ 2 M = [7; 5; 3; 2] :: 1@ :: []

M := 1 :: []

M = [1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 55: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 56: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 57: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 58: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 59: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 60: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 61: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∨ 2 ∈ F M |= 5 ∧ 7 2 is undefined in M

M := 2 :: M

M = [7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 62: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

Unit5 ∨ 7 ∨ 2 ∈ F M |= 5 ∧ 7 2 is undefined in M

M := 2 :: M

M = [2; 7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 63: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL : Example

SuccessM |= F

return Sat

M = [2; 7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

15

Page 64: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping

I The clause 6 ∨ 5 ∨ 2 is false in [6; 5@; 4; 3@; 2; 1@]

I It is also false in [6; 5@; ; 2; 1@]

I Instead of backtracking to M = [5; 4; 3@; 2; 1@], we wouldprefer to backjump directly to M = [5; 2; 1@]

16

Page 65: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjump Clauses

Conflict are reflected by backjump clauses

For instance, we have the following backjump clauses in theprevious example:

F |= 1 ∨ 5F |= 2 ∨ 5

Given a backjump clause C ∨ `, backjumping can undo severaldecisions at once: it goes back to the assignment M whereM |= ¬C and add ` to M

17

Page 66: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

DPLL + Backjumping

We just replace Backtrack by

Backjump

C ∈ F M |= ¬C M = M1 :: `@ :: M2

F |= C ′ ∨ `′ M2 |= ¬C ′

`′ is undefined in M2 `′ (or ¬`′) ∈ F

M := `′ :: M2

where C ′ ∨ `′ is a backjump clause

18

Page 67: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

M = []

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 68: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide1 is undefined in M 1 ∈ F

M := 1@ :: M

M = []

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 69: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide1 is undefined in M 1 ∈ F

M := 1@ :: M

M = [1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 70: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit1 ∨ 2 ∈ F M |= 1 2 is undefined in M

M := 2 :: M

M = [1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 71: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit1 ∨ 2 ∈ F M |= 1 2 is undefined in M

M := 2 :: M

M = [2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 72: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 73: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 74: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit3 ∨ 4 ∈ F M |= 3 4 is undefined in M

M := 4 :: M

M = [3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 75: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit3 ∨ 4 ∈ F M |= 3 4 is undefined in M

M := 4 :: M

M = [4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 76: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 77: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 78: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 6 :: M

M = [5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 79: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 6 :: M

M = [6; 5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 80: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Backjump

6 ∨ 5 ∨ 2 ∈ F M |= 6 ∧ 5 ∧ 2

M = [6; 5@; 4] :: 3@ :: [2; 1@] F |= 2 ∨ 5

[2; 1@] |= 2 5 is undefined in [2; 1@]

M := 5 :: [2; 1@]

M = [6; 5@; 4; 3@; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 81: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Backjump

6 ∨ 5 ∨ 2 ∈ F M |= 6 ∧ 5 ∧ 2

M = [6; 5@; 4] :: 3@ :: [2; 1@] F |= 2 ∨ 5

[2; 1@] |= 2 5 is undefined in [2; 1@]

M := 5 :: [2; 1@]

M = [5; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 82: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [5; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 83: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [7; 5; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 84: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Backjump

5 ∨ 7 ∨ 2 ∈ F

M |= 5 ∧ 7 ∧ 2 M = [7; 5; 2] :: 1@ :: []F |= 1 [] |= true 1 is undefined in []

M := 1 :: []

M = [7; 5; 2; 1@]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 85: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Backjump

5 ∨ 7 ∨ 2 ∈ F

M |= 5 ∧ 7 ∧ 2 M = [7; 5; 2] :: 1@ :: []F |= 1 [] |= true 1 is undefined in []

M := 1 :: []

M = [1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 86: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 87: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide3 is undefined in M 3 ∈ F

M := 3@ :: M

M = [3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 88: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 89: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Decide5 is undefined in M 5 ∈ F

M := 5@ :: M

M = [5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 90: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 91: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 7 ∈ F M |= 5 7 is undefined in M

M := 7 :: M

M = [7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 92: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 7 ∨ 2 ∈ F M |= 5 ∧ 7 2 is undefined in M

M := 2 :: M

M = [7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 93: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

Unit5 ∨ 7 ∨ 2 ∈ F M |= 5 ∧ 7 2 is undefined in M

M := 2 :: M

M = [2; 7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 94: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backjumping : Example

SuccessM |= F

return Sat

M = [2; 7; 5@; 3@; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

19

Page 95: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL

Conflict-Driven Clause Learning SAT solvers (CDCL) addbackjump clauses to M as learned clauses (or lemmas) to preventfuture similar conflicts.

LearnF |= C each atom of C occurs in F or M

F := F ∪ {C}

Lemmas can also be removed from M

ForgetF = F ′ ] C F ′ |= C

F := F ′

20

Page 96: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

How to Find Backjump Clauses?

1. Build an implication graph that captures the way propagationliterals have been derived from decision literals

2. Use the implication graph to explain a conflict (by a specificcutting technique) and extract backjump clauses

21

Page 97: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Implication Graph

An implication graph G is a DAG that can be built during the runof DPLL as follows:

1. Create a node for each decision literal

2. For each clause `1 ∨ . . . ∨ `n ∨ ` such that ¬`1, . . . ,¬`n arenodes in G, add a node for ` (if not already present in thegraph), and add edges ¬`i → `, for 1 ≤ i ≤ n (if not alreadypresent)

22

Page 98: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Implication Graph : Example

(Partial) implication graph for the following state of DPLL

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

6

9

¬7

¬8

4

¬5

¬1

2

¬3

23

Page 99: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph

To extract backjump clauses, we first cut the implication graph intwo parts:

I the first part must contains (at least) all the nodes with noincoming arrows

I the second part must contains (at least) all the nodes with nooutgoing arrows

The literals whose outgoing edges are cut form a backjump clauseprovided that exactly one of these literals belongs to the currentdecision level.

24

Page 100: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

6

9

¬7

¬8

4

¬5

¬1

2

¬3

25

Page 101: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

6

9

¬7

¬8

4

¬5

¬1

2

¬3

25

Page 102: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

6

9

¬7

¬8

4

¬5

¬1

2

¬3

25

Page 103: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

6

9

¬7

¬8

4

¬5

¬1

2

¬3

¬6 v 8 v 7

25

Page 104: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph : Other Example

In the first example, Backjump is applied for the first time when

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

M = [6; 5@; 4; 3@; 2; 1@]

1

2¬6

5

26

Page 105: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph : Other Example

In the first example, Backjump is applied for the first time when

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

M = [6; 5@; 4; 3@; 2; 1@]

1

2¬6

5 ¬2 v ¬5

26

Page 106: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph : Other Example

In the first example, Backjump is applied for the first time when

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

M = [6; 5@; 4; 3@; 2; 1@]

1

2¬6

5 ¬2 v ¬5 ¬1 v ¬5

26

Page 107: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph : Other Example

When Backjump is applied for the second time, we have

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

M = [7; 5; 2; 1@]

1 2 ¬7¬5

¬2

27

Page 108: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph : Other Example

When Backjump is applied for the second time, we have

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

M = [7; 5; 2; 1@]

1 2 ¬7¬5

¬2

27

Page 109: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Cutting the Implication Graph : Other Example

When Backjump is applied for the second time, we have

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

M = [7; 5; 2; 1@]

1 2 ¬7¬5

¬2¬1

27

Page 110: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

FUIP

¬x1 x4 ¬x7 ¬x10

decisions

x16

¬x16

conflictx2

¬x3

¬x5

x6

¬x8

x9

x11

¬x12

x15

x14

¬x13

¬x16 ∨ x16

x13 ∨ ¬x14 ∨ ¬x15

¬x6 ∨ x12

FUIP

¬x6 ∨ x8 ∨ ¬x11

x1 ∨ ¬x4 ∨ x7 ∨ x10

1 2 3 4

28

Page 111: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution

Backjump clauses can also be obtained by successive application ofresolution steps

Starting from the conflict clause, the (negation of) propagationliterals are resolved away in the reverse order with the respectiveclauses that caused their propagations

We stop when the resolvent contains only one literal in the currentdecision level

29

Page 112: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

R = 1 ∨ 2 ∨ 3

30

Page 113: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 1 ∨ 2 ∨ 3 5 ∨ 7 ∨ 3 ∈ F

R := 5 ∨ 7 ∨ 1 ∨ 2

R = 1 ∨ 2 ∨ 3

30

Page 114: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 1 ∨ 2 ∨ 3 5 ∨ 7 ∨ 3 ∈ F

R := 5 ∨ 7 ∨ 1 ∨ 2

R = 5 ∨ 7 ∨ 1 ∨ 2

30

Page 115: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 5 ∨ 7 ∨ 1 ∨ 2 4 ∨ 5 ∨ 2 ∈ F

R := 4 ∨ 5 ∨ 7 ∨ 1

R = 5 ∨ 7 ∨ 1 ∨ 2

30

Page 116: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 5 ∨ 7 ∨ 1 ∨ 2 4 ∨ 5 ∨ 2 ∈ F

R := 4 ∨ 5 ∨ 7 ∨ 1

R = 4 ∨ 5 ∨ 7 ∨ 1

30

Page 117: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 4 ∨ 5 ∨ 7 ∨ 1 4 ∨ 1 ∈ F

R := 5 ∨ 7 ∨ 4

R = 4 ∨ 5 ∨ 7 ∨ 1

30

Page 118: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 4 ∨ 5 ∨ 7 ∨ 1 4 ∨ 1 ∈ F

R := 5 ∨ 7 ∨ 4

R = 5 ∨ 7 ∨ 4

30

Page 119: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 5 ∨ 7 ∨ 4 6 ∨ 8 ∨ 4 ∈ F

R := 6 ∨ 8 ∨ 7 ∨ 5

R = 5 ∨ 7 ∨ 4

30

Page 120: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 5 ∨ 7 ∨ 4 6 ∨ 8 ∨ 4 ∈ F

R := 6 ∨ 8 ∨ 7 ∨ 5

R = 6 ∨ 8 ∨ 7 ∨ 5

30

Page 121: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 6 ∨ 8 ∨ 7 ∨ 5 8 ∨ 7 ∨ 5 ∈ F

R := 8 ∨ 7 ∨ 6

R = 6 ∨ 8 ∨ 7 ∨ 5

30

Page 122: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Backward Conflict Resolution: Example

F = {9∨ 6∨ 7∨ 8, 8∨ 7∨ 5, 6∨ 8∨ 4, 4∨ 1, 4∨ 5∨ 2, 5∨ 7∨ 3, 1∨ 2∨ 3}

M = [3; 2; 1; 4; 5; 8; 9@; . . . ; 7; . . . ; 6; . . .]

ResolveR = 6 ∨ 8 ∨ 7 ∨ 5 8 ∨ 7 ∨ 5 ∈ F

R := 8 ∨ 7 ∨ 6

R = 8 ∨ 7 ∨ 6

30

Page 123: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution + Learning + Restart

When Mode = search

SuccessM |= F

return Sat

UnitC ∨ ` ∈ F M |= ¬C ` is undefined in M

M := `C∨` :: M

Decide` is undefined in M ` (or ¬`) ∈ F

M := ` :: M

ConflictC ∈ F M |= ¬C

R := C; Mode := resolution

31

Page 124: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution + Learning + Restart

When Mode = resolution

FailR = ⊥

return Unsat

ResolveR = C ∨ ¬` `D∨` ∈M

R := C ∨D

Backjump

R = C ∨ ` M = M1 :: `′ :: M2

M2 |= ¬C ` is undefined in M2

M := `C∨` :: M2; Mode := search

32

Page 125: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution + Learning + Restart

When Mode = resolution

LearnR 6∈ F

F := F ∪ {R}

When Mode = search

ForgetC is a learned clause

F := F \ {C}

RestartM := ∅

33

Page 126: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Mode = search

M = []

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 127: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Decide1 is undefined in M 1 ∈ F

M := 1 :: M

Mode = search

M = []

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 128: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Decide1 is undefined in M 1 ∈ F

M := 1 :: M

Mode = search

M = [1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 129: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Unit1 ∨ 2 ∈ F M |= 1 2 is undefined in M

M := 21∨2 :: M

Mode = search

M = [1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 130: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Unit1 ∨ 2 ∈ F M |= 1 2 is undefined in M

M := 21∨2 :: M

Mode = search

M = [21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 131: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Decide3 is undefined in M 3 ∈ F

M := 3 :: M

Mode = search

M = [21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 132: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Decide3 is undefined in M 3 ∈ F

M := 3 :: M

Mode = search

M = [3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 133: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Unit3 ∨ 4 ∈ F M |= 3 4 is undefined in M

M := 43∨4 :: M

Mode = search

M = [3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 134: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Unit3 ∨ 4 ∈ F M |= 3 4 is undefined in M

M := 43∨4 :: M

Mode = search

M = [43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 135: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Decide5 is undefined in M 5 ∈ F

M := 5 :: M

Mode = search

M = [43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 136: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Decide5 is undefined in M 5 ∈ F

M := 5 :: M

Mode = search

M = [5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 137: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 65∨6 :: M

Mode = search

M = [5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 138: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Unit5 ∨ 6 ∈ F M |= 5 6 is undefined in M

M := 65∨6 :: M

Mode = search

M = [65∨6; 5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}R =

34

Page 139: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Conflict6 ∨ 5 ∨ 2 ∈ F M |= 6 ∧ 5 ∧ 2

R := 6 ∨ 5 ∨ 2;Mode := resolution

Mode = search

M = [65∨6; 5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}R =

34

Page 140: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Conflict6 ∨ 5 ∨ 2 ∈ F M |= 6 ∧ 5 ∧ 2

R := 6 ∨ 5 ∨ 2;Mode := resolution

Mode = resolution

M = [65∨6; 5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R = 6 ∨ 5 ∨ 2

34

Page 141: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

ResolveR = 6 ∨ 5 ∨ 2 65∨6 ∈M

R := 2 ∨ 5

Mode = resolution

M = [65∨6; 5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R = 6 ∨ 5 ∨ 2

34

Page 142: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

ResolveR = 6 ∨ 5 ∨ 2 65∨6 ∈M

R := 2 ∨ 5

Mode = resolution

M = [65∨6; 5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R = 2 ∨ 5

34

Page 143: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Backjump

R = 2 ∨ 5M = [65∨6; 5; 43∨4] :: 3 :: [21∨2; 1]

[21∨2; 1] |= 25 undefined in [21∨2; 1]

M := 52∨5 :: [21∨2; 1];Mode := search

Mode = resolution

M = [65∨6; 5; 43∨4; 3; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R = 2 ∨ 5

34

Page 144: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

Backjump

R = 2 ∨ 5M = [65∨6; 5; 43∨4] :: 3 :: [21∨2; 1]

[21∨2; 1] |= 25 undefined in [21∨2; 1]

M := 52∨5 :: [21∨2; 1];Mode := search

Mode = search

M = [52∨5; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 145: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL + Resolution : Example

etc.

Mode = search

M = [52∨5; 21∨2; 1]

F = {1 ∨ 2, 3 ∨ 4, 5 ∨ 6, 6 ∨ 5 ∨ 2, 5 ∨ 7, 5 ∨ 7 ∨ 2}

R =

34

Page 146: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

CDCL (imperative style)

M = []; level = 0; F = the initial set of clauses

while True:

bcp()

if a conflict occurs :

if level == 0: return Unsat

let C be the conflict clause

let ` be the unique literal of C at the conflict level

level = max {level of(x) | x ∈ C \ {`}}M = ` :: M \ {x | x ∈ M ∧ level of(x) > conflict level}F = F ∪ {C}

else:

if M is complete: return Sat

pick a literal ` ∈ F \ MM = ` :: M

level += 1

35

Page 147: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Strategies

The inference rules given for DPLL and CDCL are flexible

Basic strategy :

I apply Decide only if Unit or Fail cannot be applied

Conflict resolution :

I Learn only one clause per conflict (the clause used inBackjump)

I Use Backjump as soon as possible (FUIP)

I When applying Resolve, use the literals in M in the reverseorder they have been added

36

Page 148: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Decision heuristic : VSIDS

The Variable State Independent Decaying Sum (VSIDS) heuristicassociates a score to each literal in order to select the literal withthe highest score when Decide is used

I Each literal has a counter, initialized to 0I Increase the counters of

I the literal ` when Resolve is usedI the literals of the clause in R when Backjump is used

I Counters are divided by a constant, periodically

37

Page 149: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Scoring Learned Clauses

CDCL performances are tightly related to their learning clausemanagement

I Keeping too many clauses decrease the BCP efficiency

I Cleaning out too many clauses break the overall learningbenefit

Quality measures for learning clauses are based on scoresassociated with learned clauses

I VSIDS (dynamic): increase the score of clauses involved inResolve

I LBD (static): number of different decision levels in a learnedclause

38

Page 150: Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchonconchon/ENSPSaclay/lecture1.pdf · Logical Aspects of AI Lecture 1 - SAT solvers Sylvain Conchon LRI (UMR 8623), Universit

Indexing

BCP = 80% of SAT-solver runtime

How to implement efficiently M |= C (in Unit and Conflict) ?

Two watched literals technique:

I assign two non-false watched literals per clauseI only if one of the two watched literal becomes false, the

clause is inspected :I if the other watched literal is assigned to true, then do nothingI otherwise, try to find another watched literalI if no such literal exists, then apply BackjumpI if the only possible literal is the other watched literal of the

clause, then apply Unit

Main advantages :

I clauses are inspected only when watched literal are assignedI no updating when backjumping

39