Department of Computer Science & Engineering

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Polynomial-time reductions We have seen several reductions:
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
NP-Completeness: Reductions
NP-Completeness More Reductions. Definitions P: is the class of all decision problems which can be solved in polynomial time, O(n^k) for some constant.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems.
NP and NP-completeness
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
NP-complete examples CSC3130 Tutorial 11 Xiao Linfu Department of Computer Science & Engineering Fall 2009.
Chapter 11: Limitations of Algorithmic Power
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
Complements of Languages in NP Osama Awwad Department of Computer Science Western Michigan University July 13, 2015.
Hardness Results for Problems
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Lecture 22 More NPC problems
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
CSC 413/513: Intro to Algorithms NP Completeness.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
NP-Algorithms Tractable vs Intractable Some problems are intractable: as they grow large, we are unable to solve them in reasonable time.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong The Cook-Levin.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CSC 413/513: Intro to Algorithms
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
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 NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The NP class. NP-completeness
More NP-Complete and NP-hard Problems
P & NP.
ICS 353: Design and Analysis of Algorithms
NP-completeness The Chinese University of Hong Kong Fall 2008
Presentation transcript:

Department of Computer Science & Engineering NP-complete examples CSCI3130 Tutorial 10 Chun-Ho Hung chhung@cse.cuhk.edu.hk Department of Computer Science & Engineering

Outline Review 2 problems P, NP, NPC Polynomial-time Reduction Double-SAT Dominating set http://en.wikipedia.org/wiki/Dominating_set_problem

Review P, NP, NPC Polynomial-time Reduction

P P is the class of all languages that have poly-time algorithm e.g., Shortest path on a directed graph, Sorting

NP NP is the class of all languages that have poly-time verifier A verifier – a Turing Machine, V, s.t. Given a potential x x ∈ L  V accepts input <x, s> for some s Solution s V runs in polynomial time

NP (con’t) While verifying a solution of a NP problem is easy (in poly-time), finding a solution could be more difficult An 3SAT instance - Find a satisfying assignment for Verifying Given an assignment, just evaluate the truth value Finding a solution? No efficient algorithm has been discovered yet f = (x1∨x2 ) ∧ (x2 ∨x3 ∨x4) ∧ (x1)

P versus NP Every language, L in P, L is also in NP Therefore Let Verifier = Poly-time TM that solves L Therefore P is contained in NP Note: L in NP does not imply that efficient algorithm that decides L does not exist NP P

NPC A language C is NP-complete if: What is a reduction…? C is in NP Every language L in NP, L poly-time reduces to C What is a reduction…?

Reduction The direction of the reduction is very important Saying “A is easier than B” and “B is easier than A” mean different things “A (polynomially) reduces to B” means “B is not easier than A”

Reduction (Con’t) Consider 2 problems: BFS on unweighted graph Shortest path on weighted graph Assume we have a TM, V, which solves 2) We can reduce 1) to 2): Given an instance of 1), convert it into an instance of 2): Copy the graph, add weight=1 to every edge in 2) Run this instance on V, output result These two “yes” instances corresponds to each other

Poly-Time Reduction How to show that a problem B is not easier than a problem A? Informally, if B can be solved efficiently, we can solve A efficiently Formally, we say A polynomially reduces to B if: Given an instance a of problem, x There is a polynomial time transformation to an instance of B, y = f(x) x is a “yes” instance if and only if y is a “yes” instance

Poly-Time Reduction (Con’t) Suppose A poly-time reduces to B Then there exists a poly-time TM, R, s.t., Given an instance of A, x, transforms it to an instance of B, y = f(x), and y is accepted  x is accepted

Poly-Time Reduction (Implication) Suppose A reduces to B If B is polynomial time solvable, then A is polynomial time solvable If A is not polynomial time solvable, then B is not polynomial time solvable Contrapositive acc Poly-time TM R TM for L’ x y rej

Poly-Time Reduction (Implication) Suppose A reduces to B Solving B cannot be easier than solving A Suppose A is “difficult” while B is “easy” However, by this reduction, you find a “easy” way to solve A Consequently, if A is NPC, then B must be NPC acc Poly-time TM R TM for L’ x y rej

Poly-Time Reduction - P versus NP To show P = NP, one could try to show that a NPC problem, C, can be solved in polynomial time. Why? Every problem in NP poly-time reduces to C If C can be solved in poly-time, so does each problem in NP Then NP = P!! But this is not that easy and it is counter-intuitive (to most people) too

P versus NP (Again) Most believe that P ≠ NP, because intuitively searching for a solution is more difficult than verifying a solution What does P = NP imply? Know how to verify a solution in poly-time  Know how to find a solution in poly-time (?!) Indeed we prefer P ≠ NP Encryption algorithms heavily rely on the assumption that P ≠ NP P = NP or P ≠ NP is still an open problem

Relations hard easy Is there any problem even harder than NP-C? Yes! e.g. I-go P easy

Methodology To show L is in NP, you can either Show that solutions for L can be verified in polynomial-time, or Describe a nondeterministic polynomial-time TM for L (Come back to this if we have enough time) To show L is NP-complete Show that L is in NP Poly-time reduce some NPC problem to L i.e., design a polynomial-time reduction from some problem we know to be NP-complete

Example Proving a problem being NPC

Double-SAT Problem: Goal: Double-SAT = {<φ> | φ is a Boolean formula with at least two satisfying assignments} Goal: Show that Double-SAT is NP-Complete

Double-SAT (Proof Sketch) Steps: Show that Double-SAT ∈ NP Show that Double-SAT is not easier than a certain NPC problem For the NPC problem, we choose SAT i.e., we want to poly-time reduce Double-SAT to SAT Show the correspondence of “yes” instance between reduction

Double-SAT - (1) NP It is trivial to see that Double-SAT ∈ NP Given 2 assignments for φ, and verify whether both of them satisfy φ We can just evaluate the truth value in poly-time

Double-SAT - (2) Reduction On input φ(x1, . . . , xn): 1. Introduce a new variable w 2. Output formula φ’(x1, . . . , xn, y) = φ(x1, . . . , xn) ∧ ( w ∨ w ). acc R TM for L’ x y rej SAT Double-SAT x ∈ L y ∈ L’ TM accepts

Double-SAT - (3) Correspondence x ∈ L  y ∈ L’  : Suppose there is an satisfying assignment, X, for φ(x1, . . . , xn), we can find two satisfying assignments for φ’(x1, . . . , xn, w): Assignment 1 = {X, w=True} Assignment 2 = {X, w=False} φ’(x1, . . . , xn, w) = φ(x1, . . . , xn) ∧ ( w ∨ w ) For {xi}, assign X, then this part = True No matter what w is, this part = True

Double-SAT - (3) Correspondence x ∈ L  y ∈ L’ : We use contrapositive i.e., to show x ∉ L ⇒ y ∉ L’ Indeed, if x ∉ L, φ(x1, . . . , xn)=False Then, no matter what the value of y is φ’(x1, . . . , xn, y)=False

Dominating Set Problem: Goal: Dominating-set = {<G, K> | A dominating set of size K for G exists} Goal: Show that Dominating-set is NP-Complete

Dominating Set (Definition) Problem: Dominating-set = {<G, K> | A dominating set of size (at most) K for G exists} Let G=(V,E) be an undirected graph A dominating set D is a set of vertices that covers all vertices i.e., every vertex of G is either in D or is adjacent to at least one vertex from D

Dominating Set (Example) Size-2 example : {Yellow vertices} e

Dominating Set (Proof Sketch) Steps: Show that Dominating-set ∈ NP. Show that Dominating-set is not easier than a NPC problem We choose this NPC problem to be Vertex cover Reduction from Vertex-cover to Dominating-set Show the correspondence of “yes” instances between the reduction

Dominating Set - (1) NP It is trivial to see that Dominating-set ∈ NP Given a vertex set D of size K, we check whether (V-D) are adjacent to D i.e., for each vertex, v, in (V-D), whether v is adjacent to some vertex u in D

Dominating Set - (2) Reduction Reduction - Graph transformation Construct a new graph G' by adding new vertices and edges to the graph G as follows: T G G’ <G,k> ∈ L Vertex-cover Dominating-set <G’, k> ∈ L’

Dominating Set - (2) Reduction Reduction - Graph transformation (Con’t) For each edge (v, w) of G, add a vertex vw and the edges (v, vw) and (w, vw) to G' Furthermore, remove all vertices with no incident edges; such vertices would always have to go in a dominating set but are not needed in a vertex cover of G We skip the discussion of this subtle part in the followings T G G’ <G,k> ∈ L Vertex-cover Dominating-set <G’, k> ∈ L’

[Recap] Vertex cover A vertex cover, C, is a set of vertices that covers all edges i.e., each edge is at least adjacent to some node in C 1 2 3 4 {2, 4}, {3, 4}, {1, 2, 3} are vertex covers

Dominating Set – Graph Transformation Example w v z u vz wu vw zu vu G' v w z u G

Dominating Set - (3) Correspondence A dominating set of size K in G’  A vertex cover of size K in G  Let D be a dominating set of size K in G’ Case 1): D contains only vertices from G Then, all new vertices have an edge to a vertex in D D covers all edges D is a valid vertex cover of G

Dominating Set - (3) Correspondence A dominating set of size K in G’  A vertex cover of size K in G  Let D be a dominating set of size K in G’ Case 2): D contains some new vertices (vertex in the form of uv) (We show how to construct a vertex cover using only old vertices, otherwise we cannot obtain a vertex cover for G) For each new vertex uv, replace it by u (or v) If u ∈ D, this node is not needed Then the edge u-v in G will be covered After new edges are removed, it is a valid vertex cover of G (of size at most K)

Dominating Set - (3) Correspondence A dominating set of size K in G’  A vertex cover of size K in G  Let C be a vertex cover of size K in G For an old vertex, v ∈ G’ : By the definition of VC, all edges incident to v are covered v is also covered For a new vertex, uv ∈ G’ : Edge u-v must be covered, either u or v ∈ C This node will cover uv in G’ Thus, C is a valid dominating for G’ (of size at most K)

Dominating Set - (3) Correspondence vw v w v w vz wu vu z u z u zu Vertex-cover in G Dominating-set in G'

End Any questions? (There should be some)