NP-Completeness Yin Tat Lee

Slides:



Advertisements
Similar presentations
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Advertisements

NP-Completeness: Reductions
The Theory of NP-Completeness
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
CS21 Decidability and Tractability
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 24 Instructor: Paul Beame.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Clique Cover Cook’s Theorem 3SAT and Independent Set
Lecture 22 More NPC problems
CSEP 521 Applied Algorithms Richard Anderson Lecture 10 NP Completeness.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 Computational Complexity Classify problems according to the amount of computational resources used by the best algorithms that solve them Recall: worst-case.
1 3-COLOURING: Input: Graph G Question: Does there exist a way to 3-colour the vertices of G so that adjacent vertices are different colours? 1.What could.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
May 9, New Topic The complexity of counting.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
1 Suppose I construct a TM M f which: 1. Preserves its input u. 2. Simulates a machine M b on input ε. 3. If M b hangs on input ε, force an infinite loop.
CSE 6311 – Spring 2009 ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS Lecture Notes – Feb. 3, 2009 Instructor: Dr. Gautam Das notes by Walter Wilson.
CSC 413/513: Intro to Algorithms
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The Theory of NP-Completeness
The NP class. NP-completeness
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
More NP-Complete and NP-hard Problems
Chapter 10 NP-Complete Problems.
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
NP-Completeness (36.4-5) P: yes and no in pt NP: yes in pt NPH  NPC
Perfect Matchings in Bipartite Graphs
P and NP CISC4080, Computer Algorithms CIS, Fordham Univ.
NP-complete problems The Chinese University of Hong Kong Fall 2008
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
Intro to Theory of Computation
Intro to Theory of Computation
CS154, Lecture 16: More NP-Complete Problems; PCPs
ICS 353: Design and Analysis of Algorithms
Intro to NP Completeness
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
More NP-complete Problems
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Richard Anderson Lecture 29 NP-Completeness
Richard Anderson Lecture 28 NP Completeness
NP-Complete Problems.
CS 3343: Analysis of Algorithms
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
CSE 6408 Advanced Algorithms.
CS21 Decidability and Tractability
More on NP-completeness
Prove this problem is in NP
CS154, Lecture 16: More NP-Complete Problems; PCPs
CS21 Decidability and Tractability
More NP-complete problems
Umans Complexity Theory Lectures
CSE 589 Applied Algorithms Spring 1999
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
CHAPTER 7 Time complexity
Lecture 23 NP-Hard Problems
Presentation transcript:

NP-Completeness Yin Tat Lee CSE 421 NP-Completeness Yin Tat Lee

3-SAT ≤ 𝑝 Independent Set ≤ 𝑝 Vertex Cover ≤ 𝑝 Set Cover Cook-Levin Theorem Theorem (Cook 71, Levin 73): 3-SAT is NP-complete, i.e., for all problems 𝐴∈𝑁𝑃, 𝐴 ≤ 𝑝 3-SAT. (See CSE 431 for the proof) So, 3-SAT is the hardest problem in NP. What does this say about other problems of interest? Like Independent set, Vertex Cover, … Fact: If 𝐴 ≤ 𝑝 𝐵 and 𝐵 ≤ 𝑝 𝐶 then, 𝐴 ≤ 𝑝 𝐶 Pf: Just compose the reductions from A to B and B to C So, if we prove 3-SAT ≤ 𝑝 Independent set, then Independent Set, Clique, Vertex cover, Set cover are all NP-complete 3-SAT ≤ 𝑝 Independent Set ≤ 𝑝 Vertex Cover ≤ 𝑝 Set Cover

Steps to Proving Problem B is NP-complete Show B is NP-hard: State: ”Reduction is from NP-hard Problem A” Show what the map f is Argue that f is polynomial time Argue correctness: two directions Yes for A implies Yes for B and vice versa. Show B is in NP State what hint/certificate is and why it works Argue that it is polynomial-time to check.

Is NP-complete as bad as it gets? NO! NP-complete problems are frequently encountered, but there are worse: Some problems provably require exponential time. Ex: Does M halt on input x in 2|x| steps? Some require steps And some are just plain uncomputable

3-SAT ≤ 𝑝 Independent Set Map a 3-CNF to (G,k). Say k is number of clauses Create a vertex for each literal Joint two literals if They belong to the same clause (blue edges) The literals are negations, e.g., 𝑥 𝑖 , 𝑥 𝑖 (red edges) Set k be the # of clauses. 𝑥 1 ∨ 𝑥 3 ∨𝑥4 ∧ 𝑥 2 ∨ 𝑥 4 ∨𝑥3 ∧ 𝑥 2 ∨ 𝑥 1 ∨𝑥3 𝑥 1 𝑥 2 𝑥 2 Polynomial-Time Reduction 𝑥 3 𝑥 4 𝑥 1 𝑥 4 𝑥 3 𝑥 3

Correctness of 3-SAT ≤ 𝑝 Indep Set F satisfiable => An independent of size k Given a satisfying assignment, Choose one node from each clause where the literal is satisfied 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 4 ∧ 𝑥 2 ∨ 𝑥 4 ∨ 𝑥 3 ∧ 𝑥 2 ∨ 𝑥 1 ∨ 𝑥 3 Satisfying assignment: 𝑥 1 =𝑇, 𝑥 2 =𝐹, 𝑥 3 =𝑇, 𝑥 4 =𝐹 S has exactly one node per clause => No blue edges between S S follows a truth-assignment => No red edges between S S has one node per clause => |S|=k 𝑥 1 𝑥 2 𝑥 2 𝑥 3 𝑥 4 𝑥 1 𝑥 4 𝑥 3 𝑥 3

Correctness of 3-SAT ≤ 𝑝 Indep Set An independent set of size k => A satisfying assignment Given an independent set S of size k. S has exactly one vertex per clause (because of blue edges) S does not have 𝑥 𝑖 , 𝑥 𝑖 (because of red edges) So, S gives a satisfying assignment Satisfying assignment: 𝑥 1 =𝐹, 𝑥 2 =?, 𝑥 3 =𝑇, 𝑥 4 =𝑇 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 4 ∧ 𝑥 2 ∨ 𝑥 4 ∨ 𝑥 3 ∧ 𝑥 2 ∨ 𝑥 1 ∨ 𝑥 3 𝑥 1 𝑥 3 𝑥 4 𝑥 2

Yet another example of NP completeness Prove that Super Mario Bros is NP-complete. What do we need to show? The problem is in NP. Some NP complete problem is easier than Super Mario. Approach: 3SAT ≤ 𝑃 Super Mario

Yet another example of NP completeness Given a 3SAT, we need to create a level. We ignore the following issues: Need to consider the “crossing” coz the level is 2-D. Assume Mario can go both left or right.

Question 1: How to create this part?

Question 2: How to create this part?

So, what you need to prove? If the 3SAT is satisfiable, then indeed the level is solvable. Usually, this part is easy. This is basically due to the design of your reduction. If the level is solvable, then the 3SAT is satisfiable This part usually requires more argument. Need to prove no tricky way to solve the problem without solving the 3SAT.

More NP-completeness Subset-Sum problem (Decision version of Knapsack) Given n integers w1,…,wn and integer W Is there a subset of the n input integers that adds up to exactly W? O(nW) solution from dynamic programming but if W and each wi can be n bits long then this is exponential time

3-SAT PSubset-Sum Given a 3-CNF formula with m clauses and n variables Will create 2m+2n numbers that are m+n digits long Two numbers for each variable xi ti and fi (corresponding to xi being true or xi being false) Two extra numbers for each clause uj and vj (filler variables to handle number of false literals in clause Cj)

3-SAT PSubset-Sum i j C3=(x1 x2 x5) 1 2 3 4 … n 1 2 3 4 … m t1 1 0 0 0 … 0 0 0 1 0 … 1 f1 1 0 0 0 … 0 1 0 0 1 … 0 t2 0 1 0 0 … 0 0 1 0 0 … 1 f2 0 1 0 0 … 0 0 0 1 1 … 0 … …. u1=v1 0 0 0 0 … 0 1 0 0 0 … 0 u2=v2 0 0 0 0 … 0 0 1 0 0 … 0 … …. W 1 1 1 1 … 1 3 3 3 3 … 3

Graph Colorability Defn: Given a graph G=(V,E), and an integer k, a k-coloring of G is an assignment of up to k different colors to the vertices of G so that the endpoints of each edge have different colors. 3-Color: Given a graph G=(V,E), does G have a 3-coloring? Claim: 3-Color is NP-complete Proof: 3-Color is in NP: Hint is an assignment of red,green,blue to the vertices of G Easy to check that each edge is colored correctly

3-SAT P3-Color Reduction: We want to map a 3-CNF formula F to a graph G so that G is 3-colorable iff F is satisfiable

3-SAT P3-Color O F T Base Triangle

3-SAT P3-Color xn xn Variable Part: ... in 3-coloring, variable x2 colors correspond to some truth assignment (same color as T or F) ... x2 x2 x1 O x1 F T

3-SAT P3-Color xn xn ... x2 x2 x1 x1 F Clause Part: Add one 6 vertex gadget per clause connecting its ‘outer vertices’ to the literals in the clause

3-SAT P3-Color xn xn ... x2 x2 x1 x1 F O (xn  x2  x1) T F T F O Any satisfying statement has a T. We can color the corresponding vertex in the gadget F and in the triangle O. Other two, we just use O in the gadget and T F in the triangle. x1 F/T F T Any truth assignment satisfying the formula can be extended to a 3-coloring of the graph

3-SAT P3-Color xn xn ... x2 x2 x1 x1 F F (xn  x2  x1) T O Any 3-coloring of the graph colors each gadget triangle using each color

3-SAT P3-Color xn xn ... x2 x2 x1 x1 F F (xn  x2  x1) T O F Any 3-coloring of the graph has an F opposite the O color in the triangle of each gadget

3-SAT P3-Color xn xn ... x2 x2 x1 x1 F F (xn  x2  x1) T O F Any 3-coloring of the graph has T at the other end of the blue edge connected to the F