The SATisfiability problem and its impact Agostino Dovier Dept of - - PowerPoint PPT Presentation

the satisfiability problem and its impact
SMART_READER_LITE
LIVE PREVIEW

The SATisfiability problem and its impact Agostino Dovier Dept of - - PowerPoint PPT Presentation

The SAT problem P versus NP SAT SOLVING The SATisfiability problem and its impact Agostino Dovier Dept of Mathematics, Computer Science, and Physics University of Udine Udine (Italy) TRIESTE, June 19 2019 Agostino Dovier SAT and its


slide-1
SLIDE 1

The SAT problem P versus NP SAT SOLVING

The SATisfiability problem and its impact

Agostino Dovier

Dept of Mathematics, Computer Science, and Physics University of Udine Udine (Italy)

TRIESTE, June 19 2019

Agostino Dovier SAT and its impact

slide-2
SLIDE 2

The SAT problem P versus NP SAT SOLVING

Summary

The SAT problem The role of SAT in the millenium problem P vs NP SAT solving, in brief Reduction to SAT A logic language for NP

Agostino Dovier SAT and its impact

slide-3
SLIDE 3

The SAT problem P versus NP SAT SOLVING

SAT

Given a set of Boolean variables X = {X1, . . . , Xn} and a propositional formula in “CNF” built on X: Φ = (ℓ1

1 ∨ · · · ∨ ℓ1 n1) ∧ · · · ∧ (ℓk 1 ∨ · · · ∨ ℓk nk)

where every ℓi

j is a variable Xp or its negation ¬Xp

The SATisfiability problem is that of establishing the existence

  • f an assignment true/false (1/0) to the variables so as to

make Φ true (1). In this case the assignment is said a solution. Remember that: ¬0 = 1, ¬1 = 0 0 ∨ 0 = 0, 0 ∨ 1 = 1 ∨ 0 = 1 ∨ 1 = 1 0 ∧ 0 = 0 ∧ 1 = 1 ∧ 0 = 0, 1 ∧ 1 = 1

Agostino Dovier SAT and its impact

slide-4
SLIDE 4

The SAT problem P versus NP SAT SOLVING

SAT

Example (X1∨¬X2) (¬X1∨X2∨¬X3) (¬X1∨¬X2∨X3) (¬X1∨¬X2∨¬X3)

  • 1. Given a guess, verifying it is easy.
  • 2. The number of guesses is “huge” (2|X|).

Agostino Dovier SAT and its impact

slide-5
SLIDE 5

The SAT problem P versus NP SAT SOLVING

SAT

Example (X1∨¬X2) (¬X1∨X2∨¬X3) (¬X1∨¬X2∨X3) (¬X1∨¬X2∨¬X3) X1=1

  • 1. Given a guess, verifying it is easy.
  • 2. The number of guesses is “huge” (2|X|).

Agostino Dovier SAT and its impact

slide-6
SLIDE 6

The SAT problem P versus NP SAT SOLVING

SAT

Example (X1∨¬X2) (¬X1∨X2∨¬X3) (¬X1∨¬X2∨X3) (¬X1∨¬X2∨¬X3) X1=1 X2=1

  • 1. Given a guess, verifying it is easy.
  • 2. The number of guesses is “huge” (2|X|).

Agostino Dovier SAT and its impact

slide-7
SLIDE 7

The SAT problem P versus NP SAT SOLVING

SAT

Example (X1∨¬X2) (¬X1∨X2∨¬X3) (¬X1∨¬X2∨X3) (¬X1∨¬X2∨¬X3) X1=1 X2=1 X3=1

  • 1. Given a guess, verifying it is easy.
  • 2. The number of guesses is “huge” (2|X|).

Agostino Dovier SAT and its impact

slide-8
SLIDE 8

The SAT problem P versus NP SAT SOLVING

SAT

Example (X1∨¬X2) (¬X1∨X2∨¬X3) (¬X1∨¬X2∨X3) (¬X1∨¬X2∨¬X3) X1=1 X2=1 X3=0

  • 1. Given a guess, verifying it is easy.
  • 2. The number of guesses is “huge” (2|X|).

Agostino Dovier SAT and its impact

slide-9
SLIDE 9

The SAT problem P versus NP SAT SOLVING

SAT

Example (X1∨¬X2) (¬X1∨X2∨¬X3) (¬X1∨¬X2∨X3) (¬X1∨¬X2∨¬X3) X1=1 X2=0 X3=0

  • 1. Given a guess, verifying it is easy.
  • 2. The number of guesses is “huge” (2|X|).

Agostino Dovier SAT and its impact

slide-10
SLIDE 10

The SAT problem P versus NP SAT SOLVING

SAT

Is CNF important?

(((X1 ∧ X2) ∨ (X3 ∧ ¬X4)) ∧ (X6 ∨ (X7 ∧ ¬X8))) ∨ X9 (∗) ((A ∨ B) ∧ (X6 ∨ C)) ∨ X9 (∗) A ↔ (X1 ∧ X2) B ↔ (X3 ∧ ¬X4) C ↔ (X7 ∧ ¬X8) (D ∧ E) ∨ X9 (∗) D ↔ (A ∨ B) E ↔ (X6 ∨ C) F ∨ X9 F ↔ (D ∧ E)

Agostino Dovier SAT and its impact

slide-11
SLIDE 11

The SAT problem P versus NP SAT SOLVING

SAT

Is CNF important?

(((X1 ∧ X2) ∨ (X3 ∧ ¬X4)) ∧ (X6 ∨ (X7 ∧ ¬X8))) ∨ X9 (∗) ((A ∨ B) ∧ (X6 ∨ C)) ∨ X9 (∗) A ↔ (X1 ∧ X2) B ↔ (X3 ∧ ¬X4) C ↔ (X7 ∧ ¬X8) (D ∧ E) ∨ X9 (∗) D ↔ (A ∨ B) E ↔ (X6 ∨ C) F ∨ X9 F ↔ (D ∧ E)

Agostino Dovier SAT and its impact

slide-12
SLIDE 12

The SAT problem P versus NP SAT SOLVING

SAT

Is CNF important?

(((X1 ∧ X2) ∨ (X3 ∧ ¬X4)) ∧ (X6 ∨ (X7 ∧ ¬X8))) ∨ X9 (∗) ((A ∨ B) ∧ (X6 ∨ C)) ∨ X9 (∗) A ↔ (X1 ∧ X2) B ↔ (X3 ∧ ¬X4) C ↔ (X7 ∧ ¬X8) (D ∧ E) ∨ X9 (∗) D ↔ (A ∨ B) E ↔ (X6 ∨ C) F ∨ X9 F ↔ (D ∧ E)

Agostino Dovier SAT and its impact

slide-13
SLIDE 13

The SAT problem P versus NP SAT SOLVING

SAT

Is CNF important?

(((X1 ∧ X2) ∨ (X3 ∧ ¬X4)) ∧ (X6 ∨ (X7 ∧ ¬X8))) ∨ X9 (∗) ((A ∨ B) ∧ (X6 ∨ C)) ∨ X9 (∗) A ↔ (X1 ∧ X2) B ↔ (X3 ∧ ¬X4) C ↔ (X7 ∧ ¬X8) (D ∧ E) ∨ X9 (∗) D ↔ (A ∨ B) E ↔ (X6 ∨ C) F ∨ X9 F ↔ (D ∧ E)

Agostino Dovier SAT and its impact

slide-14
SLIDE 14

The SAT problem P versus NP SAT SOLVING

SAT

Is CNF important?

Where U ↔ (V ∧ Z) = U → (V ∧ Z) ∧ (V ∧ Z) → U = (¬U ∨ V ) ∧ (¬U ∨ Z) ∧ (¬V ∨ ¬Z ∨ U) and U ↔ (V ∨ Z) = U → (V ∨ Z) ∧ (V ∨ Z) → U = (¬U ∨ V ∨ Z) ∧ (¬V ∨ U) ∧ (¬Z ∨ U) No, CNF is not important.

Agostino Dovier SAT and its impact

slide-15
SLIDE 15

The SAT problem P versus NP SAT SOLVING

SAT

Is CNF important?

Where U ↔ (V ∧ Z) = U → (V ∧ Z) ∧ (V ∧ Z) → U = (¬U ∨ V ) ∧ (¬U ∨ Z) ∧ (¬V ∨ ¬Z ∨ U) and U ↔ (V ∨ Z) = U → (V ∨ Z) ∧ (V ∨ Z) → U = (¬U ∨ V ∨ Z) ∧ (¬V ∨ U) ∧ (¬Z ∨ U) No, CNF is not important.

Agostino Dovier SAT and its impact

slide-16
SLIDE 16

The SAT problem P versus NP SAT SOLVING

SAT

What about DNF?

(X1 ∧ ¬X2 ∧ X3) ∨ (¬X1 ∧ X2) ∨ · · · SAT on DNF is trivial. DNF is simply a description of the solutions.

Agostino Dovier SAT and its impact

slide-17
SLIDE 17

The SAT problem P versus NP SAT SOLVING

The G¨

  • del letter (to von Neumann)

https://rjlipton.wordpress.com/the-gdel-letter/

(1906–1978) (1903–1957)

Agostino Dovier SAT and its impact

slide-18
SLIDE 18

The SAT problem P versus NP SAT SOLVING

The G¨

  • del letter (to von Neumann)

https://rjlipton.wordpress.com/the-gdel-letter/

Princeton, 20 March 1956 Lieber Herr v. Neumann: With the greatest sorrow I have learned of your illness. [...] I would like to allow myself to write you about a mathematical problem, of which your opinion would very much interest me: One can obviously easily construct a Turing machine, which for every formula F in first order predicate logic and every natural number n, allows one to decide if there is a proof of F of length n (length = number of symbols). Let ψ(F, n) be the number of steps the machine requires for this and let ϕ(n) = maxF ψ(F, n). The question is how fast ϕ(n) grows for an

  • ptimal machine. [...] If there really were a machine with ϕ(n) ∼ kn (or

even ∼ kn2), this would have consequences of the greatest importance. Namely, it would obviously mean that in spite of the undecidability of the Entscheidungsproblem, the mental work of a mathematician concerning Yes-or-No questions could be completely replaced by a machine. [...] Now it seems to me, however, to be completely within the realm of possibility that ϕ(n) grows that slowly. [...] Sincerely yours,

Agostino Dovier SAT and its impact

slide-19
SLIDE 19

The SAT problem P versus NP SAT SOLVING

SAT and G¨

  • del

The formula Φ = (X1 ∨ ¬X2 ∨ X3) ∧ (¬X1 ∨ X2) can be viewed “al la G¨

  • del” as

F = ∃X1∃X2∃X3

  • (p(X1) ∨ ¬p(X2) ∨ p(X3)) ∧ (¬p(X1) ∨ p(X2))
  • del was optimistic on the existence of a polynomial algorithms

(even linear or quadratic) for SAT solving. We don’t know what von Neumann had thought 60 years later we don’t know whether G¨

  • del guess is true or false.

Agostino Dovier SAT and its impact

slide-20
SLIDE 20

The SAT problem P versus NP SAT SOLVING

The class P

A problem/language L ⊆ Σ∗ belongs to the class P if there are an algorithm A and a polynomial p such that for each x ∈ Σ∗: x ∈ L ↔ A(x) = yes and every computation of A halts in at most p(|x|) steps. A, briefly, is said polynomial algorithm. E.g., A runs in time O(n), O(n log n), O(n2), O(n3), etc. Example PAL = {x ∈ Σ∗ : x is palindrome}.

Agostino Dovier SAT and its impact

slide-21
SLIDE 21

The SAT problem P versus NP SAT SOLVING

The class NP

A problem/language L ⊆ Σ∗ belongs to the class NP if there are a polynomial algorithm A and a polinomial q such that for each x ∈ Σ∗: x ∈ L ↔ ∃c ∈ Σq(|x|) A(x, c) = yes

  • c is said guess for x, of size bounded by q(|x|) that allows us to

verify if x ∈ L in polynomial time. Example: SAT. In this case the guess is a variable assignment X1/0, X2/1, . . . , Xn/1. Let us observe that the search space for the guess can be of exponenzial size w.r.t. |x|. Thus, a simple enumeration might lead to exponential time decision algorithms for problems in NP.

Agostino Dovier SAT and its impact

slide-22
SLIDE 22

The SAT problem P versus NP SAT SOLVING

The class NP

A problem/language L ⊆ Σ∗ belongs to the class NP if there are a polynomial algorithm A and a polinomial q such that for each x ∈ Σ∗: x ∈ L ↔ ∃c ∈ Σq(|x|) A(x, c) = yes

  • c is said guess for x, of size bounded by q(|x|) that allows us to

verify if x ∈ L in polynomial time. Example: SAT. In this case the guess is a variable assignment X1/0, X2/1, . . . , Xn/1. Let us observe that the search space for the guess can be of exponenzial size w.r.t. |x|. Thus, a simple enumeration might lead to exponential time decision algorithms for problems in NP.

Agostino Dovier SAT and its impact

slide-23
SLIDE 23

The SAT problem P versus NP SAT SOLVING

P vs EXPTIME

Agostino Dovier SAT and its impact

slide-24
SLIDE 24

The SAT problem P versus NP SAT SOLVING

Towards NP completeness: Reduction

Given two problems/languages A and B, we say that A is reducible to B (briefly, A ≤ B) if there is a function f computed by an “efficient”algorithm (technically, in logarithmic space, for the scope of this talk think to a polynomial time algorithm) such that ∀x

  • x ∈ A ↔ f (x) ∈ B)

Let us observe that f transforms an instance of a problem of A in an instance of a problem of B. ≤ is reflexive and transitive. It is clear that if B ∈ P and A ≤ B then A ∈ P. It is clear that if B ∈ NP and A ≤ B then A ∈ NP. A problem/language L ∈ P is P complete if every language in P can be reduced to it. A problem/language L ∈ NP is NP complete if every language in NP can be reduced to it.

Agostino Dovier SAT and its impact

slide-25
SLIDE 25

The SAT problem P versus NP SAT SOLVING

Towards NP completeness: Reduction

Given two problems/languages A and B, we say that A is reducible to B (briefly, A ≤ B) if there is a function f computed by an “efficient”algorithm (technically, in logarithmic space, for the scope of this talk think to a polynomial time algorithm) such that ∀x

  • x ∈ A ↔ f (x) ∈ B)

Let us observe that f transforms an instance of a problem of A in an instance of a problem of B. ≤ is reflexive and transitive. It is clear that if B ∈ P and A ≤ B then A ∈ P. It is clear that if B ∈ NP and A ≤ B then A ∈ NP. A problem/language L ∈ P is P complete if every language in P can be reduced to it. A problem/language L ∈ NP is NP complete if every language in NP can be reduced to it.

Agostino Dovier SAT and its impact

slide-26
SLIDE 26

The SAT problem P versus NP SAT SOLVING

Towards NP completeness: Reduction

Given two problems/languages A and B, we say that A is reducible to B (briefly, A ≤ B) if there is a function f computed by an “efficient”algorithm (technically, in logarithmic space, for the scope of this talk think to a polynomial time algorithm) such that ∀x

  • x ∈ A ↔ f (x) ∈ B)

Let us observe that f transforms an instance of a problem of A in an instance of a problem of B. ≤ is reflexive and transitive. It is clear that if B ∈ P and A ≤ B then A ∈ P. It is clear that if B ∈ NP and A ≤ B then A ∈ NP. A problem/language L ∈ P is P complete if every language in P can be reduced to it. A problem/language L ∈ NP is NP complete if every language in NP can be reduced to it.

Agostino Dovier SAT and its impact

slide-27
SLIDE 27

The SAT problem P versus NP SAT SOLVING

NP completeness: Cook and Levin

Circuit Value

Input: A logic circuit with logical gates and, or, and not with one

  • utput and an assignment for all the inputs

(e.g. x1 = 0, x2 = 1, x3 = 0) Problem: Establish whether the output is true.

Agostino Dovier SAT and its impact

slide-28
SLIDE 28

The SAT problem P versus NP SAT SOLVING

NP completeness: Cook and Levin

Circuit SAT

Input: A logic circuit with logical gates and, or, and not with one

  • utput and n inputs.

Problema: Establish whether there an assignment of values to the inputs that makes the output true.

Agostino Dovier SAT and its impact

slide-29
SLIDE 29

The SAT problem P versus NP SAT SOLVING

NP completeness: Cook and Levin

Theorem (1971) CIRCUIT VALUE is P-complete. (CIRCUIT) SAT is NP-complete. If a problem A is in P there is a Turing machine that runs in time nk for some k that decides A We abstract its computation with a matrix nk × nk. Position

  • f tape and state are encoded in a cell.

(⊲, q0) a1 a2 . . . an $ . . . $ ⊲ (a1, q1) a2 . . . an $ . . . $ . . . . . . . . . . . . . . . . . . . . . . . . ⊲ yes/no y2 . . . yn yn+1 . . . yk

Agostino Dovier SAT and its impact

slide-30
SLIDE 30

The SAT problem P versus NP SAT SOLVING

NP completeness: Cook and Levin

The content of cell i of the MdT at time t + 1 depends only by cells i − 1, i, i + 1 at time t. The matrix behavior can be simulated by repeating the same template of logical circuit. We obtain an instance of Circuit Value

Agostino Dovier SAT and its impact

slide-31
SLIDE 31

The SAT problem P versus NP SAT SOLVING

NP completeness: Cook and Levin

With A in NP, it is sufficient starting by a circuit template with two subcircuits addressable by a flag. The set of flags (one per row) is the remaining part of the input for (CIRCUIT) SAT

Agostino Dovier SAT and its impact

slide-32
SLIDE 32

The SAT problem P versus NP SAT SOLVING

P versus NP

By definition, P ⊆ NP. But, it will be the case that P = NP or that P ⊂ NP? Thanks to Cook-Levin: To show that P = NP it would be sufficient writing a polynomial algorithm for SAT. To show that P ⊂ NP (P = NP) it would be sufficient to prove that a polynomial algorithm for SAT does not exist. Is this an important problem?

Agostino Dovier SAT and its impact

slide-33
SLIDE 33

The SAT problem P versus NP SAT SOLVING

P versus NP

By definition, P ⊆ NP. But, it will be the case that P = NP or that P ⊂ NP? Thanks to Cook-Levin: To show that P = NP it would be sufficient writing a polynomial algorithm for SAT. To show that P ⊂ NP (P = NP) it would be sufficient to prove that a polynomial algorithm for SAT does not exist. Is this an important problem?

Agostino Dovier SAT and its impact

slide-34
SLIDE 34

The SAT problem P versus NP SAT SOLVING

The millennium problems

http://www.claymath.org/millennium-problems

1 Yang-Mills and Mass Gap 2 Riemann Hypothesis 3 P vs NP Problem. If it is easy to check that a solution to a

problem is correct, is it also easy to solve the problem? This is the essence of the P vs NP question. If you prove that P = NP you are able to solve mechanically all the others [Aaronson 2017]

4 Navier-Stokes Equation 5 Hodge Conjecture 6 Poincar´

e Conjecture (solved by Grigoriy Perelman in 2003)

7 Birch and Swinnerton-Dyer Conjecture Agostino Dovier SAT and its impact

slide-35
SLIDE 35

The SAT problem P versus NP SAT SOLVING

On P versus NP

We already saw the G¨

  • del letter

Now my general conjecture is as follows: for almost all sufficiently complex types of enciphering . . . the mean key computation length increases exponentially with the length of the key, or in other words, the information content of the key . . . The nature of this conjecture is such that I cannot prove it, even for a special type of ciphers. Nor do I expect it to be

  • proven. [John Nash, 1955 (Nobel Economia 1994)]

P versus NP — a gift to mathematics from computer science [Steve Smale (Fields 1996, Wolf 2006)] The P versus NP problem deals with the central mystery of

  • computation. The story of the long assault on this problem is
  • ur Iliad and our Odyssey; it is the defining myth of our field.

[Eric Allender, 2009]

Agostino Dovier SAT and its impact

slide-36
SLIDE 36

The SAT problem P versus NP SAT SOLVING

On P versus NP

Readings

Juris Hartmanis (TA 1993). G¨

  • del, von Neumann and the P

=? NP Problem (1989). Michael Sipser. The History and Status of the P versus NP Question (1992). Stephen Cook (TA 1982). The Importance of the P versus NP Question (2003). Avi Widgerson. P, NP and mathematics — a computational complexity perspective (2006). Eric Allender. A Status Report on the P versus NP Question (2009). Scott Aaronson. P ? = NP (2017).

Agostino Dovier SAT and its impact

slide-37
SLIDE 37

The SAT problem P versus NP SAT SOLVING

SAT solving

Martin Davis (1928) Hillary Putnam (1926–2016) G¨

  • del and Turing proved that the automatization of logic is not a

topic for human and machines. However, it makes sense to attack the problem of automatically guess/verity proofs of theorems of finite length (what G¨

  • del considered “obviously, easily”)

Agostino Dovier SAT and its impact

slide-38
SLIDE 38

The SAT problem P versus NP SAT SOLVING

Davis Putnam —JACM 7(3):201–215 (1960)

Agostino Dovier SAT and its impact

slide-39
SLIDE 39

The SAT problem P versus NP SAT SOLVING

Davis Putnam —JACM 7(3):201–215 (1960)

Agostino Dovier SAT and its impact

slide-40
SLIDE 40

The SAT problem P versus NP SAT SOLVING

Davis Putnam —JACM 7(3):201–215 (1960)

Two main ingredients Unit Rule Given a clause ℓ1 ∨ · · · ∨ ℓn such that the current assigment makes {ℓ1, . . . , ℓn} \ {ℓi} false, then deterministically assign ℓi to true. Rule III (resolution) Rewrite F = ( a ∨ p) ∧ ( b ∨ ¬p) ∧ R with: F ′ = ( a ∨ b) ∧ R Rule III* (splitting) Choose a (free) variable x in F. Try (x ∧ F). If it fails then try (¬x ∧ F) (Introduced by Loveland in [DPLL62])

Agostino Dovier SAT and its impact

slide-41
SLIDE 41

The SAT problem P versus NP SAT SOLVING

DPLL —page 323 of Davis’ Book

Agostino Dovier SAT and its impact

slide-42
SLIDE 42

The SAT problem P versus NP SAT SOLVING

DPLL —page 323 of Davis’ Book

Agostino Dovier SAT and its impact

slide-43
SLIDE 43

The SAT problem P versus NP SAT SOLVING

DPLL —page 323 of Davis’ Book

Agostino Dovier SAT and its impact

slide-44
SLIDE 44

The SAT problem P versus NP SAT SOLVING

DPLL —page 323 of Davis’ Book

Agostino Dovier SAT and its impact

slide-45
SLIDE 45

The SAT problem P versus NP SAT SOLVING

DPLL —page 323 of Davis’ Book

Agostino Dovier SAT and its impact

slide-46
SLIDE 46

The SAT problem P versus NP SAT SOLVING

SAT solving

DPLL (1962)

Given Φ (CNF), establishing whether exists θ s.t. Φθ is true. DP(Φ,θ) θ′ ← unit propagation(Φ,θ) if (satisfied(Φθ′)) return θ′ else if (failed(Φθ′)) return false else X ← select variable(Φ,θ′) θ′′ ←DP(Φ, θ′[X/true]) if (θ′′ = false) return θ′′ else return DP(Φ, θ′[X/false])

Agostino Dovier SAT and its impact

slide-47
SLIDE 47

The SAT problem P versus NP SAT SOLVING

SAT solving

DPLL (1962)

P P' P', X=f P', X=t Backtracking UNIT PROPAGATION P'' P'''

UNIT PROPAGATION UNIT PROPAGATION

Agostino Dovier SAT and its impact

slide-48
SLIDE 48

The SAT problem P versus NP SAT SOLVING

Searching=Propagation+ND assignment

Agostino Dovier SAT and its impact

slide-49
SLIDE 49

The SAT problem P versus NP SAT SOLVING

Searching=Propagation+ND assignment

Agostino Dovier SAT and its impact

slide-50
SLIDE 50

The SAT problem P versus NP SAT SOLVING

Searching=Propagation+ND assignment

Agostino Dovier SAT and its impact

slide-51
SLIDE 51

The SAT problem P versus NP SAT SOLVING

Searching=Propagation+ND assignment

Agostino Dovier SAT and its impact

slide-52
SLIDE 52

The SAT problem P versus NP SAT SOLVING

Searching=Propagation+ND assignment

Agostino Dovier SAT and its impact

slide-53
SLIDE 53

The SAT problem P versus NP SAT SOLVING

Searching=Propagation+ND assignment

Agostino Dovier SAT and its impact

slide-54
SLIDE 54

The SAT problem P versus NP SAT SOLVING

Searching=Propagation+ND assignment

Agostino Dovier SAT and its impact

slide-55
SLIDE 55

The SAT problem P versus NP SAT SOLVING

SAT competition

SAT is (the most famous) NP complete problem Every problem in NP can therefore be reduced to SAT An efficient dolution for SAT would be inherithed by all problems in NP DPLL is the ancestor of a family of algorithms called SAT SOLVERS An important point is the SAT COMPETITION (SAT Race) http://www.satcompetition.org/ organized since 2002. Huge speed-up was introduced by conflict-driven clause learning.

Agostino Dovier SAT and its impact

slide-56
SLIDE 56

The SAT problem P versus NP SAT SOLVING

Conflict Driven Clause Learning

ω1

  • (x1 ∨ x31 ∨ ¬x2) ∧

ω2

  • (x1 ∨ ¬x3) ∧

ω3

  • (x2 ∨ x3 ∨ x4) ∧

ω4

  • (¬x4 ∨ ¬x5) ∧

ω5

  • (x21 ∨ ¬x4 ∨ ¬x6) ∧

ω6

  • (x5 ∨ x6)

We can learn learn x31 ∨ x1 ∨ x21. (alternatively, ¬x4 ∨ x21—several strategies are developped) [Marques-Silva, Lynce, and Malik. Handbook of Satisfiability, Chapter 4, 2008]

Agostino Dovier SAT and its impact

slide-57
SLIDE 57

The SAT problem P versus NP SAT SOLVING

Conflict Driven Clause Learning

ω1

  • (x1 ∨ x31 ∨ ¬x2) ∧

ω2

  • (x1 ∨ ¬x3) ∧

ω3

  • (x2 ∨ x3 ∨ x4) ∧

ω4

  • (¬x4 ∨ ¬x5) ∧

ω5

  • (x21 ∨ ¬x4 ∨ ¬x6) ∧

ω6

  • (x5 ∨ x6)

We can learn learn x31 ∨ x1 ∨ x21. (alternatively, ¬x4 ∨ x21—several strategies are developped) [Marques-Silva, Lynce, and Malik. Handbook of Satisfiability, Chapter 4, 2008]

Agostino Dovier SAT and its impact

slide-58
SLIDE 58

The SAT problem P versus NP SAT SOLVING

Conflict Driven Clause Learning

The graph is not written: it will be discovered after the conflict using the resolution rule (again, the same as [DP60]): (α ∨ X) ∧ (β ∨ ¬X) ↔ (α ∨ β) In our example:

ω1

  • (x1 ∨ x31 ∨ ¬x2) ∧

ω2

  • (x1 ∨ ¬x3) ∧

ω3

  • (x2 ∨ x3 ∨ x4) ∧

ω4

  • (¬x4 ∨ ¬x5) ∧

ω5

  • (x21 ∨ ¬x4 ∨ ¬x6) ∧

ω6

  • (x5 ∨ x6)

X6 : ω5 ∧ ω6 ↔ (X21 ∨ ¬X4 ∨ X5) X5 : (x21 ∨ ¬X4 ∨ X5) ∧ ω4 ↔ (x21 ∨ ¬X4) One could stop here or continue: X4 : (x21 ∨ ¬X4) ∧ ω3 ↔ (X21 ∨ X2 ∨ X3) X3 : (X21 ∨ X2 ∨ X3) ∧ ω2 ↔ (X21 ∨ X1 ∨ X2) X2 : (X21 ∨ X1 ∨ X2) ∧ ω1 ↔ (X21 ∨ X31 ∨ X1) (now we have the decision variable of this level or variables of higher levels: stop)

Agostino Dovier SAT and its impact

slide-59
SLIDE 59

The SAT problem P versus NP SAT SOLVING

The DIMACS input format

A standard input format has been introduced Instances are in a ASCII file (typically, with suffix “.cnf”) Variables are represented by positive non zero integer numbers; − is the negation. Commented lines start with “c” The symbol “0” terminates clauses There is an initial line starting with “p” reporting number of variables and clauses (X1 ∨ ¬X2 ∨ X3) ∧ (¬X1 ∨ ¬X3)

c ******************************************** c SAT Encoding of problem above c ******************************************** p cnf 3 2 1

  • 2

3 0

  • 1 -3 0

Agostino Dovier SAT and its impact

slide-60
SLIDE 60

The SAT problem P versus NP SAT SOLVING

IDEA: solving problems by reduction to SAT

Suppose we need to solve a problem A that looks in NP We can write a program in one of our favourite languages that transforms instances of A into equivalent instances of SAT (DIMACS) This is exactly a reduction A ≤ SAT Then we can run a SAT solver (e.g., MiniSAT) A viewer of the output of MiniSAT can be also defined If A is NP-complete, we will be proud of our job

Agostino Dovier SAT and its impact

slide-61
SLIDE 61

The SAT problem P versus NP SAT SOLVING

EXAMPLE: SUDOKU

1 2 3 4 5 6 7 8 5 9 1 3 5 4 7 1 9

Agostino Dovier SAT and its impact

slide-62
SLIDE 62

The SAT problem P versus NP SAT SOLVING

EXAMPLE: SUDOKU

We have cells (r, c) in {(1, 1), (1, 2), . . . , (9, 8), (9, 9)} In each cell (r, c) there is exactly one number in 1 . . . 9. We introduce 9 variables per cell: (r, c): X (r,c)

1

, . . . , X (r,c)

9

At least one is true: X (r,c)

1

∨X (r,c)

2

∨X (r,c)

3

∨X (r,c)

4

∨X (r,c)

5

∨X (r,c)

6

∨X (r,c)

7

∨X (r,c)

8

∨X (r,c)

9

Never two of them is true, namely for i = 1, . . . , 8 and j = i + 1, . . . , 9: ¬X (r,c)

i

∨ ¬X (r,c)

j

We are encoding Sudoku using 93 variables: the search space is 2729 ≈ 2.8 · 10219

Agostino Dovier SAT and its impact

slide-63
SLIDE 63

The SAT problem P versus NP SAT SOLVING

EXAMPLE: SUDOKU

In every row r each value k in 1 . . . 9 occurs exactly once At least once: X (r,1)

k

∨X (r,2)

k

∨X (r,3)

k

∨X (r,4)

k

∨X (r,5)

k

∨X (r,6)

k

∨X (r,7)

k

∨X (r,8)

k

∨X (r,9)

k

Never two: for i = 1, . . . , 8 and j = i + 1, . . . , 9: ¬X (r,i)

k

∨ ¬X (r,j)

k

Symmetrically for columns c

Agostino Dovier SAT and its impact

slide-64
SLIDE 64

The SAT problem P versus NP SAT SOLVING

EXAMPLE: SUDOKU

1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 3 3 3 4 4 4 5 5 5 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 6 6 6 7 7 7 8 8 8 6 6 6 7 7 7 8 8 8

Let us associate an integer 0 . . . 8 to each subsquare For simplicity, consider (in this slide) rows and columns in 0 . . . 8 Cell (r, c) belongs to the subsquare 3 ∗ (r div 3) + c div 3. Then add the clauses as previously (in each subsquare . . . ) Of course, some “+1” and “-1” should be added to be coherent :) All of this does not depend on the specific instance!

Agostino Dovier SAT and its impact

slide-65
SLIDE 65

The SAT problem P versus NP SAT SOLVING

EXAMPLE: SUDOKU

1 2 3 4 5 6 7 8 5 9 1 3 5 4 7 1 9

For the instance each input data is added as single literal clauses X (1,5)

1

X (2,4)

2

e X (2,6)

3

. . . X (9,5)

9

Agostino Dovier SAT and its impact

slide-66
SLIDE 66

The SAT problem P versus NP SAT SOLVING

EXAMPLE: SUDOKU

The only thing that remains is to do is finding a mapping from a triple r, c, k and a number in 1 . . . 729 (E.g. 81 · (r − 1) + 9 · (c − 1) + k) Let us see a quick look at the code DEMO Everything is convicing, but . . . writing a SAT encoding might be a nighmare (in particular if the problem is not yet fully understood and we have to refine the model later).

Agostino Dovier SAT and its impact

slide-67
SLIDE 67

The SAT problem P versus NP SAT SOLVING

EXAMPLE: SUDOKU

The only thing that remains is to do is finding a mapping from a triple r, c, k and a number in 1 . . . 729 (E.g. 81 · (r − 1) + 9 · (c − 1) + k) Let us see a quick look at the code DEMO Everything is convicing, but . . . writing a SAT encoding might be a nighmare (in particular if the problem is not yet fully understood and we have to refine the model later).

Agostino Dovier SAT and its impact

slide-68
SLIDE 68

The SAT problem P versus NP SAT SOLVING

Answer Set Programming

Stable Models

A general program is a set of rules: A ← B1, . . . , Bm, not C1, . . . , not Cn where A, Bi, Cj are (propositional) atoms. S is a stable model of P if and only if it is the minimum Herbrand model of PS (reduct of P w.r.t. S [GL88]). PS is obtained:

1 removing any rule whose body contains a naf-literal not L s.t.

L ∈ S;

2 removing any naf-literal from the bodies of the remaining

rules.

Agostino Dovier SAT and its impact

slide-69
SLIDE 69

The SAT problem P versus NP SAT SOLVING

Answer Set Programming

Stable Models

A general program is a set of rules: A ← B1, . . . , Bm, not C1, . . . , not Cn where A, Bi, Cj are (propositional) atoms. S is a stable model of P if and only if it is the minimum Herbrand model of PS (reduct of P w.r.t. S [GL88]). PS is obtained:

1 removing any rule whose body contains a naf-literal not L s.t.

L ∈ S;

2 removing any naf-literal from the bodies of the remaining

rules.

Agostino Dovier SAT and its impact

slide-70
SLIDE 70

The SAT problem P versus NP SAT SOLVING

Answer Set Programming

Two simple syntactic extensions

A constraint/denial is a rule without head. ← BODY that is equivalent (under stable model semantics to) newpred ← ¬newpred, BODY Read as “it is impossible that BODY is true”.

Agostino Dovier SAT and its impact

slide-71
SLIDE 71

The SAT problem P versus NP SAT SOLVING

Answer Set Programming

Two simple syntactic extensions

h{ℓ1, . . . , ℓn}k. that means that we look for stable models where al least h literals in ℓ1, . . . , ℓn are true and no more than k (this rule also “supports” those literals). E.g., 1{p, q, r}1. is equivalent to p :- not np. np :- not p. q :- not nq. nq :- not q. r :- not nr. nr :- not r. :- p,q. :- p,r. :- q,r. :- np, nq, nr.

Agostino Dovier SAT and its impact

slide-72
SLIDE 72

The SAT problem P versus NP SAT SOLVING

Consistency Problem

General Programs

Theorem The problem of establishing whether a general ground program admits a stable model is NP-complete. NP Let P ground program, a candidate stable model S will contain

  • nly atoms occurring in P, thus |S| ≤ |P|. Computing PS, the

fixpoint computation of MPS, and checking if S = MPS therefore polynomial w.r.t. |P|. Thus the problem is in NP.

Agostino Dovier SAT and its impact

slide-73
SLIDE 73

The SAT problem P versus NP SAT SOLVING

Consistency Problem

General Programs

Theorem The problem of establishing whether a general ground program admits a stable model is NP-complete. Hardness Let us consider an instance ϕ of SAT:

(A ∨ ¬B ∨ C)

  • c1

∧ (¬A ∨ B ∨ ¬C)

  • c2

and define accordingly the program Pϕ: a :- not na. na :- not a. b :- not nb. nb :- not b. c :- not nc. nc :- not c. c1 :- a. c1 :- nb. c1 :- c. c2 :- na. c2 :- b. c2 :- nc. goal :- c1,c2. :- not goal. Pϕ admits a stable model iff ϕ is satisfiable.

Agostino Dovier SAT and its impact

slide-74
SLIDE 74

The SAT problem P versus NP SAT SOLVING

ASP: a logic language for NP

Sudoku encoded using simple syntactic extensions

coord(1..9). val(1..9). % Assign a pair (X,Y) to a subsquare - and vice versa square(I,X,Y) :- coord(X),coord(Y),coord(I), I == (X-1) / 3 + 3*((Y-1) / 3) + 1. % Each cell will store exactly one value 1 { x(X,Y,N) : val(N) } 1 :- coord(X), coord(Y). % Each value is used exacly once per column 1 { x(X,Y,N) : coord(X) } 1 :- coord(Y), val(N). % Each value is used exacly once per row 1 { x(X,Y,N) : coord(Y) } 1 :- coord(X), val(N). % Each value is used exacly once per subsquare 1 { x(X,Y,N) : square(I,X,Y) } 1 :- val(N), coord(I). % instance x(1,5,1). x(2,4,2). x(2,6,3). ...

Agostino Dovier SAT and its impact

slide-75
SLIDE 75

The SAT problem P versus NP SAT SOLVING

Conclusions

We have surveyed the theoretical and practical importance of the SAT problem The problema P vs NP is waiting for your solution! If you need to solve a (apparently) NP complete problem, do not face it directly. Just reduce it to SAT and exploits SAT solvers efficiency Or, alternatively, encode it to ASP and exploits ASP solvers efficiency (e.g., DLV, clingo and their many variants) Machine learning techniques are implemented to visit first some parts of the search tree according to problem features (portfolio/algorithm selection) Hot topic in AI

Agostino Dovier SAT and its impact

slide-76
SLIDE 76

The SAT problem P versus NP SAT SOLVING

QUESTIONS?

Found SAT at 2000m

Agostino Dovier SAT and its impact