Transcript
Page 1: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Sofya Raskhodnikova

Intro to Theory of Computation

LECTURE 25 Last time β€’ Class NP

Today

β€’ Polynomial-time reductions

11/29/2012 L25.1

Page 2: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Central ideas

β€’Poly-time as β€œfeasible”

β€’ most natural problems either are easy

(say in TIME(n3)) or have no known poly-time algorithms

β€’ P =languages that can be decided in poly-time

β€’ NP = languages for which the membership in the language is

easy to verify given a hint}

β€’ EXP = languages that can be decided in exponential time

β€’ Poly-time Reductions: X is no harder than Y for poly-time TMs

11/29/2012 L25.2

Page 3: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

The class P

11/29/2012

P is the class of languages decidable in polynomial time on

a deterministic 1-tape TM:

𝑷 = 𝑇𝐼𝑀𝐸 π‘›π‘˜ .

π‘˜

L25.3

Page 4: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

The class NP

11/29/2012

NP is the class of languages that have polynomial-time

verifiers.

L25.4

Page 5: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Classes P, NP, EXP

β€’ P. Languages for which there is a poly-time algorithm.

β€’ EXP. Languages for which there is an exponential-time

algorithm.

β€’ NP. Languages for which there is a poly-time verifier.

β€’ Lemma. P NP.

β€’ Lemma. NP EXP.

β€’ Lemma. A language L is in NP iff L can be decided by

a polynomial-time nondeterministic TM.

11/29/2012 L25.5

Page 6: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

P vs. NP

β€’ Does P = NP? [Cook 1971, Edmonds, Levin, Yablonski, GΓΆdel]

– Is the decision problem as easy as the verification problem?

– Clay $1 million prize.

β€’ If yes: Efficient algorithms for UHamPath, SAT, TSP, factoring

β€’ If no: No efficient algorithms possible for these problems.

β€’ Consensus opinion on P = NP? Probably no.

11/29/2012

EXP NP

P

If P NP If P = NP

EXP

P = NP

would break RSA cryptography (and potentially collapse economy)

L25.6

Page 7: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

7

Classify Problems

β€’ Desiderata: classify problems according to those that can be

solved in polynomial-time and those that cannot.

β€’ Some problems provably require exponential time (next month):

– Given a Turing machine, does it halt in at most k steps?

– Given a board position in an n-by-n generalization of chess, can black

guarantee a win?

β€’ Frustrating news: huge number of fundamental problems have

defied classification for decades.

β€’ Chapters 7.4-7.5 (NP-completeness): Show that these

fundamental problems are "computationally equivalent" and

appear to be different manifestations of one really hard problem.

L25.7

Page 8: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Basic reduction strategies

β€’ Reduction by simple equivalence.

β€’ Reduction from special case to general case.

β€’ Reduction by encoding with gadgets.

Reduction by simple equivalence

L25.8

Page 9: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

9

Independent Set

Given an undirected graph G, an independent set in G is a set of

nodes, which includes at most one endpoint of every edge.

INDEPENDENT SET = { 𝐺, π‘˜ ∣ 𝐺 is an undirected graph which has an

independent set with π‘˜ nodes}

β€’ Is there an independent set of size 6?

– Yes.

β€’ Is there an independent set of size 7?

– No.

independent set

L25.9

Page 10: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

10

Vertex Cover

Given an undirected graph G, a vertex cover in G is a set of nodes,

which includes at least one endpoint of every edge.

VERTEX COVER= { 𝐺, π‘˜ ∣ 𝐺 is an undirected graph which has a vertex cover

with π‘˜ nodes}

β€’ Is there vertex cover of size 4?

– Yes.

β€’ Is there a vertex cover of size 3?

– No.

vertex cover

L25.10

Page 11: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Independent Set and Vertex Cover

Claim. S is an independent set iff V S is a vertex cover.

β€’

– Let S be any independent set.

– Consider an arbitrary edge (u, v).

– S is independent u S or v S u V S or v V S.

– Thus, V S covers (u, v).

β€’

– Let V S be any vertex cover.

– Consider two nodes u S and v S.

– Then (u, v) E since V S is a vertex cover.

– Thus, no two nodes in S are joined by an edge S independent set. β–ͺ

L25.11

Page 12: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

INDEPENDENT SET reduces to

VERTEX COVER

Theorem. INDEPENDENT-SET ≀𝑝 VERTEX-COVER.

Proof. β€œOn input 𝐺, π‘˜ , where 𝐺 is an undirected graph and π‘˜ is an

integer,

1. Output 𝐺, 𝑛 βˆ’ π‘˜ , where 𝑛 is the number of nodes in 𝐺.”

Correctness:

β€’ G has an independent set of size π‘˜ iff it has a vertex cover of size

𝑛 βˆ’ π‘˜.

β€’ Reduction runs in linear time.

L25.12

Page 13: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Basic reduction strategies

β€’ Reduction by simple equivalence.

β€’ Reduction from special case to general case.

β€’ Reduction by encoding with gadgets.

Reduction from special case to

general case

L25.13

Page 14: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Set Cover

Given a set U, called a universe, and a collection of its subsets

𝑆1, 𝑆2, … , π‘†π‘š, a set cover of U is a subcollection of subsets whose

union is U.

β€’ SET COVER={ π‘ˆ, 𝑆1, 𝑆2, … , π‘†π‘š; π‘˜ ∣

U has a set cover of size π‘˜}

β€’ Sample application.

– m available pieces of software.

– Set U of n capabilities that we would like our system to have.

– The 𝑖th piece of software provides the set Si U of capabilities.

– Goal: achieve all 𝑛 capabilities using fewest pieces of software.

U = { 1, 2, 3, 4, 5, 6, 7 }

k = 2

S1 = {3, 7} S4 = {2, 4}

S2 = {3, 4, 5, 6} S5 = {5}

S3 = {1} S6 = {1, 2, 6, 7}

L25.14

Page 15: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

15

VERTEX COVER reduces to

SET COVER

Theorem. VERTEX-COVER P SET-COVER.

Proof. β€œOn input 𝐺, π‘˜ , where 𝐺 = (𝑉, 𝐸) is an undirected graph

and π‘˜ is an integer,

1. Output π‘ˆ, 𝑆1, 𝑆2, … , π‘†π‘š; π‘˜ , where U=E and

Sv = {e E : e incident to v }”

Correctness:

β€’ G has a vertex cover of size k iff U has a set cover of size k.

β€’ Reduction runs in linear time.

.

L25.15

Page 16: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Basic reduction strategies

β€’ Reduction by simple equivalence.

β€’ Reduction from special case to general case.

β€’ Reduction by encoding with gadgets.

Reduction by encoding with gadgets

L25.16

Page 17: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

β€’ Boolean variables: variables that can take on values T/F (or 1/0)

β€’ Boolean operations: ∨, ∧, and Β¬

β€’ Boolean formula: expression with Boolean variables and ops

SAT = {⟨Φ⟩ ∣ Φ is a satisfiable Boolean formula}

β€’ Literal: A Boolean variable or its negation.

β€’ Clause: OR of literals.

β€’ Conjunctive normal form (CNF): AND of clauses.

3SAT = {⟨Φ⟩ ∣ Φ is a satisfiable Boolean CNF formula, where each clause

contains exactly 3 literals}

Satisfiability

C j x1 x2 x3

xi or xi

C1C2 C3 C4

each corresponds to a different variable

Ex:

Yes: x1 = true, x2 = true x3 = false.

x1 x2 x3 x1 x2 x3 x2 x3 x1 x2 x3

L25.17

Page 18: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

3SAT reduces to INDEPENDENT SET

Theorem. 3-SAT P INDEPENDENT-SET. Proof. β€œOn input Ξ¦ , where Ξ¦ is a 3CNF formula,

1. Construct graph G from Ξ¦

– G contains 3 vertices for each clause, one for each literal.

– Connect 3 literals in a clause in a triangle.

– Connect literal to each of its negations.

2. Output 𝐺, π‘˜ , where π‘˜ is the number of clauses in G.”

x2

x1 x2 x3 x1 x2 x3 x1 x2 x4

x3

x1

x1

x2

x4

x1

x2

x3

k = 3

G

L25.18

Page 19: Intro to Theory of Computationsxr48/...notes/CMPSC464-F12-Lec25.pdfΒ Β· Set Cover Given a set U, called a universe, and a collection of its subsets 1, 2,…, π‘š, a set cover of U

Summary

β€’ Basic reduction strategies.

– Simple equivalence: INDEPENDENT-SET P VERTEX-COVER.

– Special case to general case: VERTEX-COVER P SET-COVER.

– Encoding with gadgets: 3-SAT P INDEPENDENT-SET.

β€’ Transitivity. If X P Y and Y P Z, then X P Z.

β€’ Proof idea. Compose the two algorithms.

β€’ Ex: 3-SAT P INDEPENDENT-SET P VERTEX-COVER P SET-COVER.

L25.20


Top Related