lecture 40 - np-completeness

35
NP- Completeness Robb T. Koether Homework Review NP- Completeness The SAT Problem Cook’s Theorem The Reduction of 3SAT to CLIQUE Assignment NP-Completeness Lecture 40 Section 7.4 Robb T. Koether Hampden-Sydney College Wed, Dec 3, 2008

Upload: ninh-ha

Post on 10-May-2017

237 views

Category:

Documents


2 download

TRANSCRIPT

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

NP-CompletenessLecture 40Section 7.4

Robb T. Koether

Hampden-Sydney College

Wed, Dec 3, 2008

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Outline

1 Homework Review

2 NP-Completeness

3 The SAT Problem

4 Cook’s Theorem

5 The Reduction of 3SAT to CLIQUE

6 Assignment

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Homework Review

Exercise 7.12, page 295.Let

MODEXP = {〈a, b, c, p〉 | a, b, c, and p are binaryintegers such that ab ≡ c (mod p)}.

Show that MODEXP ∈ P. (Note that the most obviousalgorithm doesn’t run in polynomial time. Hint: Try it firstwhere b is a power of 2.)

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Homework Review

SolutionThe efficient algorithm to raise a number to the power n(n > 0) is to use repeated squaring.For example,

a16 =(((

a2)2

)2)2

.

If the exponent is not a power of 2, then there are somemore details.For example,

a13 =((

a2 · a)2

)2· a.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Homework Review

SolutionUse this algorithm together with reduction modulo pafter each operation.For example, 313 (mod 5):

32 ≡ 9 ≡ 4 (mod 5).4 · 3 ≡ 12 ≡ 2 (mod 5).

22 ≡ 4 (mod 5).42 ≡ 16 ≡ 1 (mod 5).

1 · 3 ≡ 3 (mod 5).

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Homework Review

Factoring

On a related note, if it were possible (is possible) tocompute (n− 1)! (mod n) in polynomial time, then itwould be possible (is possible) to factor n in polynomialtime.How so?

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

NP-Completeness

Certain problems in NP have been shown to have aspecial property:If they are solvable deterministically in polynomial time,

then so are all problems in NP.These problems are called NP-complete.We will show that SAT is NP-complete.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

The Satisfiability Problem

The SAT ProblemGiven a Boolean expression in m variables x1, x2, . . . , xm

consisting of n literals (occurrences of xi or ¬xi), do thereexist Boolean values for x1, x2, . . . , xm that make theexpression true? (n is the size of the problem.)

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

The Satisfiability Problem

For example, is the expression

(x ∧ (y ∨ ¬z)) ∧ ((¬x ∨ y) ∧ z) ∨ ¬ (x ∧ ¬z)

satisfiable?How can we tell?

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Cook’s Theorem

Theorem (Cook’s Theorem)SAT ∈ P if and only if P = NP.

Proof idea.First show that SAT is in NP.Then show that every problem in NP is polynomial-timereducible to SAT.Details in the next lecture.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Polynomial-Time Computability

Definition (Polynomial-time computable)A function f : Σ∗ → Σ∗ is polynomial-time computable ifthere is a polynomial-time Turing machine M that halts onall inputs w with f(w) on its tape.

Definition (Polynomial-time reducible)A language A is polynomial-time reducible to a language Bif there exists a polynomial-time computable function f suchthat

w ∈ A⇔ f(w) ∈ B.

We write A ≤P B.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

NP-Complete

DefinitionA language B is NP-complete if B ∈ NP, and every problemA in NP is polynomial-time reducible to B.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

A Polynomial-Time Reduction

Before proving Cook’s Theorem, we will look at anexample of a polynomial-time reduction.We will reduce 3SAT to CLIQUE.That is, we will show that

3SAT ≤P SAT.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

Let f be a Boolean expression in conjunctive normalform with exactly 3 literals per clause.Create a graph G by the following two steps.

(1) For each clause, create a group of nodes labeled withthe literals in that clause.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

For example, let

f = (x∨y∨z)∧(¬x∨¬y∨z)∧(¬x∨y∨¬z)∧(x∨y∨¬z).

Then there are four groups of three nodes each.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

(2) Connect each node in one group with every node in theother groups that is logically compatible with it.

That is, for every variable x, connect x with everythingexcept ¬x in every other clause.Do this for each group.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

Let k be the number of clauses in the expression.We now ask, does the graph have a clique of size k?

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

Does this graph have a clique of size 4?

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

Yes it does, namely {x,¬y,¬z}.

x

¬x

¬x

x

y y

y

¬y z

z

¬z

¬z

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Reduction of 3SAT to CLIQUE

This clique gives us values for x, y, and z that willsatisfy the expression.Namely, x is true, y is false, and z is false.This shows that “yes” to CLIQUE implies “yes” to 3SAT.It is also easy to see that “no” to CLIQUE implies “no”to 3SAT.It is also the case that this reduction can be done inpolynomial time.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

NP-Complete

TheoremIf B is NP-complete and B ∈ P, then P = NP.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

NP-Complete

TheoremIf B is NP-complete and B ≤P C for some C ∈ NP, then Cis NP-complete.

Proof.The relation ≤P is transitive.

NP-Completeness

Robb T.Koether

HomeworkReview

NP-Completeness

The SATProblem

Cook’sTheorem

TheReduction of3SAT toCLIQUE

Assignment

Assignment

HomeworkRead Section 7.4, pages 271 - 276.Exercises 9, 10, page 295.Problems 13, 18, page 295.