Informatics 1 Michael Fourman Lecture 19 Searching for Satisfaction - - PowerPoint PPT Presentation

informatics 1
SMART_READER_LITE
LIVE PREVIEW

Informatics 1 Michael Fourman Lecture 19 Searching for Satisfaction - - PowerPoint PPT Presentation

Informatics 1 Michael Fourman Lecture 19 Searching for Satisfaction 1 Clausal Form Clausal form is a set of sets of literals { {A,C}, {B,D}, {E,B}, {E,A}, {A,E}, {E,B},{B, C, D} } A (partial) truth assignment makes a


slide-1
SLIDE 1

Informatics 1

Lecture 19 Searching for Satisfaction

Michael Fourman

1

slide-2
SLIDE 2
slide-3
SLIDE 3

Clausal Form

3

Clausal form is a set of sets of literals

{ {¬A,C}, {¬B,D}, {¬E,B}, {¬E,A}, {A,E}, {E,B},{¬B, ¬C, ¬D} }

A (partial) truth assignment makes a clause true iff it makes at least one of its literals true (so it can never make the empty clause {} true) A (partial) truth assignment makes a clausal form true iff it makes all of its clauses true ( so the empty clausal form {} is always true ).

⋀⋁

slide-4
SLIDE 4

The satisfiability problem (SAT) is a fundamental problem from computer science. It is the problem to decide whether a formula of N Boolean variables can be satisfied, i.e. evaluated to TRUE by an assigment of the variables. Without loss of generality one can assume that the formula is

  • rganized as conjunction of clauses, where each clause is a

disjunction of literals. SAT is a very important problem in theoretical computer science (some people would even say: the most important problem), but it has numerous practical applications as well.

slide-5
SLIDE 5

5 5

Perth Adelaide Melbourne Hobart Darwin Sydney Brisbane

slide-6
SLIDE 6

6

P D A S H M B

slide-7
SLIDE 7

7

P D A S H M B

7 nodes 9 edges

slide-8
SLIDE 8

8

P D A S H M B

Br Bg Ba Hr Hg Ha 3 for each edge (eg D–B) ¬Dr ⋁ ¬Br ¬Dg ⋁ ¬Bg ¬Da ⋁ ¬Ba 1 for each node (eg D) Dr ⋁ Dg ⋁Da red green amber Melbourne Sydney Hobart Darwin Perth Adelaide Brisbane Mr Mg Ma Sr Sg Sa Dr Dg Da Pr Pg Pa Ar Ag Aa

21 atoms

34 clauses

eg: Pr ≡ red(Perth)

slide-9
SLIDE 9

9

Br Bg Ba Hr Hg Ha 3 for each edge (e.g. D–B) ¬Dr ⋁ ¬Br ¬Dg ⋁ ¬Bg ¬Da ⋁ ¬Ba 1 for each node (e.g. D) Dr ⋁ Dg ⋁Da red green amber Melbourne Sydney Hobart Darwin Perth Adelaide Brisbane Mr Mg Ma Sr Sg Sa Dr Dg Da Pr Pg Pa Ar Ag Aa

21 atoms

34 clauses

Pg Dr Aa Sr Hr Mg Bg

slide-10
SLIDE 10

10

Pg Dr Aa Sr Hr Mg Bg

slide-11
SLIDE 11

11

Pg Dr Sr Hr Mg Bg Aa

slide-12
SLIDE 12

12

P D A S H M B

Br Bg Ba Hr Hg Ha 3 for each edge (eg D–B) ¬Dr ⋁ ¬Br ¬Dg ⋁ ¬Bg ¬Da ⋁ ¬Ba 1 for each node (eg D) Dr ⋁ Dg ⋁Da red green amber Melbourne Sydney Hobart Darwin Perth Adelaide Brisbane Mr Mg Ma Sr Sg Sa Dr Dg Da Pr Pg Pa Ar Ag Aa

21 atoms

34 clauses

eg: Pr ≡ red(Perth)

slide-13
SLIDE 13

13

slide-14
SLIDE 14

Sudoku

14

Squares i, j (i, j ∈ (1..9)) Numbers k (k ∈ (1..9)) 729 (= 93) Atoms pi, j, k

pi, j, k means the number k is in square i,j

A sudoku problem is defined 
 by saying which numbers are in which squares

slide-15
SLIDE 15

15

at most one number per square every number occurs in each row every number occurs in each column every number occurs in top-left square every number occurs in centre-left square every number occurs in bottom-left square every number occurs in top-middle square

slide-16
SLIDE 16

16

729 atoms structural constraints include 
 many, many occurrences of literals How Many? every number occurs in centre-middle square every number occurs in bottom-middle square every number occurs in top-right square every number occurs in centre-right square every number occurs in bottom-right square

slide-17
SLIDE 17

A clausal form with at most two literals per clause. Corresponds to a conjunction of implications. We can draw the directed graph and count the satisfying valuations. When clauses with 3 or more literals are involved, satisfaction gets complicated. In general, we must search for satisfaction.

2-SAT

slide-18
SLIDE 18

If every clause has 2 variables (2-SAT) the problem is easy. If every clause has 3 variables (3-SAT) the problem is hard. A clause with K literals excludes 1/2K of the 2N possible assignments and the whole formula is satisfiable if the number

  • f clauses is small compared to the number of variables.

Just by counting, we can see that a K-SAT problem is satisfiable if the number of clauses is less than 2K, and it is easy to exclude all valuations with 2K clauses For a large number of variables, N, a random 3-SAT problem with N variables, with less than ~ 4.2 N clauses if is probably satisfiable; with more than ~ 4.2 N clauses if is probably not satisfiable. Hard problems appear near the boundary.

slide-19
SLIDE 19
slide-20
SLIDE 20

Naïve search

function SAT(Φ,V) Φ|V = {} || {} ∉ Φ|V && let A = chooseLiteral (Φ,V) in SAT (Φ,V ^ A) || SAT (Φ,V ^ ¬A)

Φ is a set of clauses V is a partial valuation (a consistent set of literals) V^A = V∪{A} Φ | V is the result of simplifying Φ using V: For each literal L ∈ V

  • remove clauses

containing L

  • delete ¬L from

remaining clauses

chooseLiteral(Φ,V) returns a literal occurring in Φ | V

slide-21
SLIDE 21

partial valuations

slide-22
SLIDE 22

22

A B C ¬C B D ¬A B C ¬A ¬B ¬C []

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[]

search

slide-23
SLIDE 23

23

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A

search

slide-24
SLIDE 24

24

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A,B]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A AB

search

slide-25
SLIDE 25

25

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A,B,C]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A AB A,B,C

search

slide-26
SLIDE 26

26

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A,B]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A AB A,B,C

✘ search

slide-27
SLIDE 27

27

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A,B,C]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A AB A,B,C A,B,¬C

✘ search ✔

slide-28
SLIDE 28

28

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A,B,C]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A AB A,B,C A,B,¬C

✔ ✘ search

slide-29
SLIDE 29

29

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A,B,C]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A AB A,B,C A,B,¬C

✔ ✘ search

slide-30
SLIDE 30

30

A B C ¬C B D ¬A B C ¬A ¬B ¬C [A,B,C]

V : Φ

A B C ¬C B D ¬A B C ¬A ¬B ¬C

Φ | V

[] A AB A,B,C A,B,¬C

✔ ✘ search