Top Banner
cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait until then to start PS7!)
41

Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Dec 15, 2015

Download

Documents

Miranda Hoyt
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

cs3102: Theory of Computation

Class 25: NP-Complete Appetizers

Spring 2010University of VirginiaDavid Evans

PS6 is due Tuesday, April 27 (but don’t wait until then to start PS7!)

Page 2: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Recap

To prove B is in NP-Hard, show that some known NP-Hard problem can be reduced to B.

3SAT NP-Hard

X

NP

B

A problem/language is in NP, if there is a certificate that allows you to verify the answer in polynomial time.

A problem/language is NP Hard‑ if every problem in NP can be reduced to it.

If a problem is in NP and NP Hard‑ , it is in NP Complete‑ .

Page 3: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Today’s Menu

NP-Hardness Reduction Proofs

SATSubset SumKnapsack(Pre-)History of P

= NP Question

Page 4: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

SATisfiability

Is SAT in NP? Yes, the variable assignments are apolynomial-time verifiable certificate.

Page 5: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

SAT is NP-Complete

To prove SAT is in NP-Hard, show that some known NP-Hard problem can be reduced to SAT.

3SAT

NP

SAT

3SAT NP-Hard Assume this is already

known

Page 6: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Proof: SAT is NP-Complete

MSAT

Polynomial-time decider for SAT3S

AT in

put

Polynomial-time Input

Transformer

Poly-time Output

Transformer

3SAT

out

put

If we can use MSAT, a polynomial-time decider for SAT to build a polynomial-time decider for 3SAT, this proves that SAT is at least as “hard” as 3SAT.

Show that if SAT is in P, so is 3SAT.

Page 7: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Proof: SAT is NP-Complete

MSAT

Polynomial-time decider for SAT3S

AT in

put

3SAT

out

put

Show that if SAT is in P, so is 3SAT.

Identify transform:3SAT input is a valid SAT input

Identify transform:SAT output is correct 3SAT output

Page 8: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Subset Sum Language

How many test of SUBSET-SUM do we to solve the subset sum search problem?

Page 9: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Can you order the same appetizer more than once?

Page 10: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

SUBSET-SUM is in NP

Page 11: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

SUBSET-SUM is in NP-Hard

MSS

Polynomial-time decider for SUBSET-

SUM

3SAT

inpu

t

Polynomial-time Input

Transformer

Poly-time Output

Transformer

3SAT

out

put

To finish the proof, we need to describe the transformers!

Page 12: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Transform Goal

Page 13: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Transform Ideax1 x2 x3

...

y11 0 0 ...

z11 0 0 ...

y20 1 0 ...

z20 1 0 ...

y30 0 1 ...

z30 0 1 ...

... ... ... ... ...

Page 14: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

x1 x2 x3 ... xl

y1 1 0 0 ...

z1 1 0 0 ...

y2 0 1 0 ...

z2 0 1 0 ...

... ... ... ... ...

yl 0 0 0 ... 1

zl 0 0 0 ... 1

t

Variables

S

Page 15: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

x1 x2 x3 ... xl c1 c2 c3 ... ck

y1 1 0 0 ...

z1 1 0 0 ...

y2 0 1 0 ...

z2 0 1 0 ...

... ... ... ... ...

yl 0 0 0 ... 1

zl 0 0 0 ... 1

t 1 1 1 ... 1

Variables

S

Clauses

Page 16: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

x1 x2 x3 ... xl c1 c2 c3 ... ck

y1 1 0 0 ... 1 0

z1 1 0 0 ... 0 1

y2 0 1 0 ... 0 1

z2 0 1 0 ... 1 0

... ... ... ... ... ... ...

yl 0 0 0 ... 1 ... ...

zl 0 0 0 ... 1 ... ...

t 1 1 1 ... 1

Variables

S

Clauses

We need to make at least one term in each clause true!

Page 17: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

x1 x2 x3 ... xl c1 c2 c3 ... ck

y1 1 0 0 ... 1 0

z1 1 0 0 ... 0 1

y2 0 1 0 ... 0 1

z2 0 1 0 ... 1 0

... ... ... ... ... ... ...

yl 0 0 0 ... 1 ... ...

zl 0 0 0 ... 1 ... ...

t 1 1 1 ... 1 1 1 1 1 ...

Variables

S

Clauses

We need to make at least one term in each clause true!

Doesn’t work: more than one term in a clause can be true!

Page 18: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

x1 x2 x3 ... xl c1 c2 c3 ... ck

y1 1 0 0 ... 1 0

z1 1 0 0 ... 0 1

y2 0 1 0 ... 0 1

z2 0 1 0 ... 1 0

... ... ... ... ... ... ...

yl 0 0 0 ... 1 ... ...

zl 0 0 0 ... 1 ... ...

ff1 1 0 0 ... 0

fff1 1 0 0 ... 0

ff2 0 1 0 ... 0

fff2 0 1 0 ... 0

... 0 0 ... ... ...

t 1 1 1 ... 1

Variables

S

Clauses

Sele

ct tr

ue/f

alse

for e

ach

Fudg

e fa

ctor

s

Page 19: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

x1 x2 x3 ... xl c1 c2 c3 ... ck

y1 1 0 0 ... 1 0

z1 1 0 0 ... 0 1

y2 0 1 0 ... 0 1

z2 0 1 0 ... 1 0

... ... ... ... ... ... ...

yl 0 0 0 ... 1 ... ...

zl 0 0 0 ... 1 ... ...

ff1 1 0 0 ... 0

fff1 1 0 0 ... 0

ff2 0 1 0 ... 0

fff2 0 1 0 ... 0

... 0 0 ... ... ...

t 1 1 1 ... 1 3 3 3 3 3

Variables

S

Clauses

Sele

ct tr

ue/f

alse

for e

ach

Fudg

e fa

ctor

s

Page 20: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

x1 x2 x3... xl c1 c2 c3

... cl

y11 0 0 ...

z11 0 0 ...

y20 1 0 ...

z20 1 0 ...

y30 0 1 ...

z30 0 1 ...

... ... ... ... ...

yl 0 0 0 ... 1

zl 0 0 0 ... 1

Variables

Page 21: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

3SAT reduces to SUBSET-SUM

MSS

Polynomial-time decider for SUBSET-

SUM

3SAT

inpu

t

Polynomial-time Input

TransformerIdentity

3SAT

out

put

Page 22: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

RejectSolutions involve multiple orders of the same appetizer.

Page 23: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Knapsack

Page 24: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

KNAPSACK is in NP

Page 26: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Is KNAPSACK in NP-Hard?

MSS

Polynomial-time decider for

KNAPSACK

3SAT

inpu

t

Polynomial-time Input

Transformer

Output transformer

3SAT

out

put

Could prove by reducing 3SAT to KNAPSACK.

Any easier way?

Page 27: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Is KNAPSACK in NP-Hard?

MSS

Polynomial-time decider for

KNAPSACK

SUBS

ET-S

UM

inpu

t

Polynomial-time Input

Transformer

Output transformer

SUBS

ET-S

UM

out

put

Prove by reducing SUBSET-SUM to KNAPSACK

Page 28: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Input Transformation

Page 29: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Input Transformation

S = { 102.15, 1002.75, 10003.35, 100003.55,

1000004.20, 1000005.80, 100.00, 1000.00, 10000.00, 100000.00, 1000000.00, 1000000.00 }t = 11111115.05

Opps! Iit was pointed out in class that this doesn’t work since the KNAPSACK solver might include 10x or 100x of one of the numbers and still get the right sum. This should be fixable…if you can fix it, a good answer replaces Problem 5 on PS6.

Page 30: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Chain of Reductions

KNAPSACK

SUBSET-SUM

3SAT

reduces to

reduces to

Every problem in NPreduces to

Page 31: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Hints for PS6, Problem 5

• Prove Genome Assembly is NP-Complete• Solve this by thinking, not googling• You can (of course!) do the reduction from any

NP-Complete problem to Genome Assembly– But, some will be easier than others– Some of the problems described in Sipser are

better choices than ones we have covered in class

Page 32: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

History of P = NP

Stephen Cook (US, 1971): The complexity of theorem proving proceduresRichard Karp (US 1972): List of 21 NP-Complete problems

Leonid Levin (USSR 1969-73): Universal search problems

Cook-Levin Theorem: SAT is NP-Complete

Page 34: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

(Pre)-History of P=NP

Page 35: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Princeton, 20 March 1956 Dear Mr. von Neumann:

With the greatest sorrow I have learned of your illness. … I hope and wish for you that your condition will soon improve even more and that the newest medical discoveries, if possible, will lead to a complete recovery.

Since you now, as I hear, are feeling stronger, 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 optimal machine. One can show that ϕ(n) ≥ k ⋅ n. If there really were a machine with ϕ(n) ∼ k ⋅ n (or even ∼ k ⋅ n2), this would have consequences of the greatest importance. Namely, it would obviously mean that inspite of the undecidability of the Entscheidungsproblem, the mental work of a mathematician concerning Yes-or-No questions could be completely replaced by a machine. After all, one would simply have to choose the natural number n so large that when the machine does not deliver a result, it makes no sense to think more about the problem.

Gödel’s 1956 Letter (Translated)

Page 36: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Princeton, 20 March 1956 Dear Mr. von Neumann:

With the greatest sorrow I have learned of your illness. … I hope and wish for you that your condition will soon improve even more and that the newest medical discoveries, if possible, will lead to a complete recovery.

Since you now, as I hear, are feeling stronger, 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 optimal machine. One can show that ϕ(n) ≥ k ⋅ n. If there really were a machine with ϕ(n) ∼ k ⋅ n (or even ∼ k ⋅ n2), this would have consequences of the greatest importance. Namely, it would obviously mean that inspite of the undecidability of the Entscheidungsproblem, the mental work of a mathematician concerning Yes-or-No questions could be completely replaced by a machine. After all, one would simply have to choose the natural number n so large that when the machine does not deliver a result, it makes no sense to think more about the problem.

Gödel’s 1956 Letter (Translated)

Page 37: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Has-Short-Proof

“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).”

Page 38: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Has Short Proof is Decidable

• Try all possible proofs of length n – How do we know this is finite?

• For each possible proof, check if it is a valid proof of F.– A proof is valid if:• It starts from the accepted axioms.• Each step follows a deduction rule (finite set of rules).• It reaches the statement F.

Page 39: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Princeton, 20 March 1956 Dear Mr. von Neumann: …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 optimal machine. One can show that ϕ(n) ≥ k ⋅ n. If there really were a machine with ϕ(n) ∼ k ⋅ n (or even ∼ k ⋅ n2), this would have consequences of the greatest importance. …

Page 40: Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.

Princeton, 20 March 1956 Dear Mr. von Neumann: …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 optimal machine. One can show that ϕ(n) ≥ k ⋅ n. If there really were a machine with ϕ(n) ∼ k ⋅ n (or even ∼ k ⋅ n2), this would have consequences of the greatest importance. …

Let’s give Gödel the benefit of the doubt, and read this as, “(or even ∼kn2, ∼kn3, ∼kn4, ...)”

We’ll continue with this Tuesday…