Lecture 12 P and NP Introduction to intractability Class P and NP Class NPC (NP-complete)

Preview:

Citation preview

Lecture 12 P and NP

• Introduction to intractability

• Class P and NP

• Class NPC (NP-complete)

Roadmap

• Introduction to intractability

• Class P and NP

• Class NPC

Questions on Computation

• What is a general-purpose computer?

• Are there limits on the power of digital

computers?

Turing machine

Definition: TuringMachineA (one-tape) Turing machine is a 6-tuple <Q, Γ, b, δ, q0, F> where‑Q: is a finite, non-empty set of states‑Γ: is a finite, non-empty set of the tape alphabet/symbols‑b: is the blank symbol ‑q0: is the initial state‑F: is the set of final or accepting states.‑δ: is the transition function Q\F × Γ → Q×Γ×{L,R}

QUIZ

Construct a Turing machine to solve the Palindrome problem.

⧐ 1 0 1 0 1 b b b b b ...

Palindrome

M = <{s,f,q0,q1, q0’,q1’,r,a}, {0,1}, b, δ, s, {r,a}>

s, b -> a, b, Rs, 0 -> q0, b, Rs, 1 -> q1, b, R

q0, 0 -> q0, 0, Rq0, 1 -> q0, 1, Rq0, b -> q0’, b, Lq0’, 0 -> f, b, Lq0’, 1 -> r, _, _f, 0 -> f, 0, L

f, 1 -> f, 1, Lf, b -> s, b, R

q1, 0 -> q1, 0, Rq1, 1 -> q1, 1, Rq1, b -> q1’, b, Lq1’, 0 -> r, _, _q1’, 1 -> f, b, L

⧐ 1 0 1 0 1 b b b b b ...

Nondeterministic Turing machine

M = <{s,f,q0,q1,r,a}, {0,1}, b, δ, s, {r,a}>

s, b -> a, b, Rs, 0 -> q0, b, Rs, 1 -> q1, b, R

q0, 0 -> q0, 0, Rq0, 1 -> q0, 1, Rq0, 0 -> f, b, Lq0, 1 -> r, _, _q0, b -> r, _, _f, 0 -> f, 0, L

f, 1 -> f, 0, Lf, b -> s, b, R

q1, 0 -> q1, 0, Rq1, 1 -> q1, 1, Rq1, 0 -> r, _, _q1, 1 -> f, b, L q1, b -> r, _, _

Church-Turing Thesis

ChurchTuringThesis. Every effectively calculable function is a computable function. (can be computed by a turing machine.)

Remark. "Thesis" is not a mathematical theorem because it's a statement about the physical world and not subject to proof.

Models equivalent: simulation. ・ Android simulator on iPhone.

・ iPhone simulator on Android.

Questions on Algorithms

Q: Which algorithms are useful in

practice?

A: Useful in practice ("efficient") =

polynomial time for all inputs.(efficient) Sorting N items takes N log N compares using mergesort.

(inefficient) Finding best TSP tour on N points takes N ! steps using brute search.

Exponential growthSuppose you have a giant parallel computing device... With as many processors as electrons in the universe...

And each processor has power of today's supercomputers... And each processor works for the life of the universe...

Will not help solve 1,000 city TSP problem via brute force.1000! >> 10^1000 >> 10^{79+13+17}

Exponential growth

(Source from Wikipedia)Sessa, the inventor of chess

(Source from Wikipedia)

264 - 1 = 18,446,744,073,709,551,615

Tractability• Some problems can be solved in polynomial time. (Tractable)

• For some problems, we still cannot find polynomial time solutions. (Intractable)

Decision problems

Turing machine

Decision problems are those whose solutions have only two possible outcomes: Yes or No.

Decision problems v.s. optimization problem

Decision problems

Decision v.s. Optimization

DecisionProblem: ColoringInput: An undirected graph G = (V , E ) and a positive integer kOutput: Is G k-colorable?

OptimizationProblem: ColoringInput: An undirected graph G = (V , E )Output: The chromatic number of G

Decision v.s. Optimization

DecisionProblem: CliqueInput: An undirected graph G = (V , E ) and a positive integer kOutput: Does G have a clique of size k?

OptimizationProblem: MaxCliqueInput: An undirected graph G = (V , E )Output: The maximum clique size of G

Given an algorithm for decision problem, how to solve its corresponding optimization problem?

Efficiency• Some problems can be solved in polynomial time. (Tractable)

• For some problems, we still cannot find polynomial time solutions. (Intractable)

Decision problems

Turing machine

Where are we?

• Introduction to intractability

• Class P and NP

• Class NPC

Class P

Definition: ClassPA problem π is in class P if and only if there exists a deterministic Turing machine M, such that‐M runs in polynomial time on all inputs‐For all instance with Yes answer, M terminates with accept state‐For all instance with No answer, M terminates with reject state

Class NP

Definition: ClassNPA problem π is in class NP if and only if there exists a nondeterministic Turing machine M, such that‐M runs in polynomial time on all inputs‐For all instance with Yes answer, there exists a path of M that terminates with accept state‐For all instance with No answer, all paths terminates with reject state

Guess a witness --> verify the witness is valid

Examples

DecisionProblem: 3-ColoringInput: A graph G=<V,E>Output: Is G 3-colorable?

DecisionProblem: 2-ColoringInput: A graph G=<V,E>Output: Is G 2-colorable?

Examples

DecisionProblem: HamiltonianTourInput: A graph G=<V,E>Output: Does G have a Hamiltonian tour?

DecisionProblem: EulerianTourInput: A graph G=<V,E>Output: Does G have a Eulerian tour?

P is in NP

Lemma. P⊆NP.

NP = P? or P ⊂ NP?

Class co-P and co-NP

co-P = P

The complement of a decision problem is the decision problem resulting from reversing the yes and no answers.

If problem π is in P (NP), then its complement is in co-P (co-NP).

co-NP = NP?

Examples

DecisionProblem: Co-3-ColoringInput: A graph G=<V,E>Output: Is G not 3-colorable?

DecisionProblem:3-ColoringInput: A graph G=<V,E>Output: Is G 3-colorable?

DecisionProblem: Co-2-ColoringInput: A graph G=<V,E>Output: Is G not 2-colorable?

DecisionProblem:2-ColoringInput: A graph G=<V,E>Output: Is G 2-colorable?

Possible pictures

NPNPco-NPco-NP

PP

P=NP=co-P=NP=co-NPNP

NP = co-NPNP = co-NP

PP

NPNPco-NPco-NP

P

P = NP ?

Where are we?

• Introduction to intractability

• Class P and NP

• Class NPC

Reduction“ Give me a lever long enough and a fulcrum on which to place it, and I shall move the world. ”

-- Archimedes

I shall move the world

Give me a lever long enough and a fulcrum on which to place it

∝reduce to

Polynomial-time reduction

Transform

An algorithm for problem

Q’Input of Q’Input of Q

An algorithm for Q

Q∝p Q’ : Q’ is harder than QPolynomial-time

Q is polynomially reduced to Q’

yes

no

Examples

Median ∝p Sorting

Uniqueness∝p Sorting

Longest palindrome subsequence ∝p

Longest common subsequence

Bipartite matching ∝p Max flow

......

NP complete: The hardest problem in NPDefinition: NP-CompleteA decision problem π is said to be NP-complete if the following two properties hold:1. π ∈ NP,and 2. for every problem π′ ∈ NP, π′ ∝p π.

NPNP

PP

NPCNPC

The first NPC problem

Cook-Levin Theorem [Cook, 1971; Levin, 1973]

SAT is NP-complete.

How to find the second NPC problem?

DecisionProblem: SATInput: A boolean formulaOutput: Is this formula satisfiable?

2-SAT:

3-SAT:

The 2nd, 3rd, ..., NPC problems

LemmaFor any two decision problem A,B in NP, if A is NP-complete and

A∝pB,then B is NP-complete.

SAT --> 3-SAT

3-SAT --> Clique

Clique --> Vertex Cover

Vertex Cover --> Hamiltonian

Vertex Cover --> Hamiltonian

Hamiltonian --> TSP

0

0

0

00

01

11

3-SAT --> Subset Sum

Conclusion

NPI = ∅? NPNP

PP

NPCNPC

Ladner’s Theorem [Ladner,1975]

If P ≠ NP, then NPI is not empty;

Possible candidates: •Factoring•Graph isomorphism

1. What is P, NP, and NPC?2. How to prove a problem is NPC?3. What is the possible picture of NP theory?

Recommended