![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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/1.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/7.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/9.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/10.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/11.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/12.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/13.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/14.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/15.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/16.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/17.jpg)
β’ 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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/18.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022042804/5f571603443874624e2eb3ea/html5/thumbnails/19.jpg)
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