NP-Hard Nattee Niparnan.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Introduction to Algorithms NP-Complete
Complexity Classes: P and NP
 2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of.
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 and NP Complete. Definitions A problem is in the class P if there is a polynomial time solution to the problem A problem is in the class NP if there.
Department of Computer Science & Engineering
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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 
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
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.
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 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
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.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
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.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
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
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
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.
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.
CSC 172 P, NP, Etc.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
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 Lecture 26 NP-Completeness
Advanced Algorithms Analysis and Design
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
ICS 353: Design and Analysis of Algorithms
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Prabhas Chongstitvatana
The Theory of NP-Completeness
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Lecture 23 NP-Hard Problems
Presentation transcript:

NP-Hard Nattee Niparnan

Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult for computer to solve (run the derived algorithm) the problem?

Basic Intuition Easy problem = Anything we can solve within O( T(x) ) where T(x) is polynomial Hard problem = Anything else… (maybe) More questions Is there something unsolvable? How to know whether the problem is hard?

Unsolvable Problem

Unsolvable Formally, it’s called undecidable But let’s say unsolvable for now Something that we can’t have algorithm for it Example: Halting Problem

Halting Problem Input: Given a program P and its input S Output: “Yes” when P finishes “No” when P loops forever To have an algorithm for halting problem The algorithm must be able to correctly answer this question for every P and S

Halting is undecidable Let us assume that there is an algorithm for the problem Let’s say bool A(P,S) is a function that solve this problem We construct another function kb.cpp bool Kaboom(x) { if (A(x,x)) { while (true) do ; } else { printf(“wow….”); }

kb.cpp X X A X yes loops forever no

Kaboom What is the result of Kaboom(kb.cpp) ?

P and NP

Hard vs Easy Which problem is hard? Which problem is easy? Given problem A and B, which one is easier? This revolves around the concept of “reducability”

Reduction Problem reduction: solve problem A by transform it into B Example: Finding kth smallest element can be solved by simply sort the input Hence, kth smallest element transformed into “sorting” problem Maximal Bipartite Matching can be solved by network flow

Polynomially Reducable Let X be an instance of problem A Let f(X) be a function that transform the instance X of problem A into an instance of problem B If f(X) uses polynomial time to the size of X, we say that A is polynomially reducible to B

Comparing “hardness” of problem Given an instance of problem A If that instance of A can be transformed into an instance of problem B (A is reducable to B) Which one is harder? A or B?

P and NP Class of problems P NP set of problems that we have polynomial time algorithm or better NP Informal: “exponent time”; set of problems that we have exponential time algorithm or better More formal: “polynomially verifiable”; set of problems that we can verify whether its answer is correct in polynomial time (given right evidence) Actual: “non-deterministically provable”; set of problems that can be solved by non-deterministic turing machine i.e., every problem we have seen so far

Example NP P P NP MSS, Sorting, Shortest Path, MST MSS, Sorting, Shortest Path, MST is also NP TSP, 01-knapsack, graph coloring, longest path And much more NP P

More Example Shortest Path Is in P, Is in NP Given a weighted graph G and two vertices u,v, find shortest path from u to v Input: a graph G and two vertices u and v Output: a path Is in P, Dijkstra’s algorithm runs in P Is in NP given a graph and a path, we can verify that the part is the shortest path By running Dijkstra ourselves and compare the length with the given path

More Example Graph isomorphism Is in NP Given two graphs, decides whether they are isomorphic Input: two graphs Output: YES or NO Is in NP Can be verify if a mapping is given

Hard vs Easy again P contains solely easy problems NP has easy problems + something else Believe to be hard problems

Hard = NP? No, something in NP is easy No, something hard is not in NP Try graph non-isomorphism The verifiable definition for NP is when the answer is “YES”

Reduction

Decision Problem We consider only decision problem Decision problem For simplicity Decision problem Limiting output to only “YES” and “NO” Ex, Given a graph G, does it has Euler circuit? Given a list of integers, is their GCD 1? Given a list of 3D boxes, do they intersect?

Functional and Optimization Problem Function Problem Output is a function Optimization Problem Is a function problem Output is the best instance of the given function Ex: MSS, Shortest Path,

Equivalence to Decision Problem All function problems can be reduced to decision problem For polynomial output Using polynomial time Example TSP Function: Ask for the minimal path Decision: Ask whether there exist a Hamilton path with sum weight less than or equal to X Do binary search on the value of X Eventually, we know the minimal X and hence the minimal path Decision problem is everything!

Finally, the NP-Hard More definition NP-Hard NP-Complete A problem such that all problems in NP is polynomially reducible to NP-Complete An NP-Hard that is in NP

Decidable NP NP-Hard NPC P

Reduction Example

Boolean expression in CNF clause literal Variable : x y z compliment: x , not x

SAT Problem A decision problem Given a Boolean expression in CNF (and of or-clause), can it be evaluated as true by assigning some value to the variable

Cook’s Theorem SAT problem is NP complete It is in NP, because given assignment, we can check whether it is true in P time All problem in NP can be reduced to SAT Because, essentially, all Turing machines can be described by a Boolean expression

Reduction

Hamiltonian Path  Hamiltonian Cycle Hamiltonian Cycle Problem Given a graph G Is there exists a Hamiltonian cycle Hamiltonian Path Problem Given a graph G and two of its vertices s and t Is there exists a path starting at s and ends at t that contains all vertices of G?

Reduction

Correctness Let G’ be the reduced instance of Hamiltonian cycle When G’ has solution Since x has only two neighbors, s and t Just “cut” the cycle at x When G’ does not has solution Show instead that when G has soltuion, G’ must has solution Does reduction use polynomial time? yes

SAT  3SAT 3SAT = SAT that each clause does not has more than 3 literals (variables + constants) A stricter version of SAT Subset of SAT Seems to be easier than SAT?

Reduction Add new variables y1,…yk-3 Rewrite SAT as 3SAT Simply convert every clause having more than 3 lieteral to something else (that is 3SAT) Assume that there is a clause where k > 3 Change it to Add new variables y1,…yk-3

Correctness When I’ be the instance of 3SAT while I be the original intance of SAT When I’ can be made true, I must can be made true When the right side evaluate to true, at least one of ai is true When I’ cann’t be true, I mustn’t can be made true Conversely, When I can be made true, I’ must can be made true When I can be made true, at least one of ai is true, we must set y such that the entire is true Simply set y1,…,yi-2 as true and the rest as false

3SAT  INDEPENDENT SET Independent Set Given a graph G and a number g Is there exists a set of g vertices that is not adjacent (pairwisely) Drastically differs from 3SAT

Reduction Assume that we have 3SAT instance called S Convert it into a graph G Each literal is a vertex There is an edge connecting Every vertex from the same clause Every pair of a literal and its complement Solve the independent set Use g as the number of clause

Example

Correctness If G has solution, S must be satisfiable Since each clause is maximally connected, not more than one vertex per corresponding clause is selected Since g equals to the number of clause, it is not possible for any clause not to have its corresponding vertex selected Since it is not possible for x and not x to be selected at the same time, the assigment is consistent If G has no solution, S must not be satisfiable Contrapositive again, if S can be satisfied, G has solution Very simple…

SAT  Clique Clique Given a graph G Is there exists a subgraph of size k that is complete

Reduction Given an instance of SAT, S Construct a graph C Vertex: There is a vertex for every literal in every clause Edge: Vertices in the same clause is not adjacent Vertices from different clauses are always adjacent Except for any pair of vertex of a literal and its compliment Almost the inverse of 3SAT  independent set Draw them in columns Solve the clique of C use K = number of clauses in S

Example S = G -x x y -y y -z -z z

Correctness If C has solution, G must be satisfiable The clique cannot be larger than k The clique must contain exactly one vertex in each column Simply assign the associated variable as true If some variable does not appear in the clique, just assign any value If C has no solution, G mustn’t be satisfiable Again, use contrapositive, if G is satisfiable, C has solution Simply choose a vertex corresponding to the one that is true in each clause The selected vertices forms clique, since the only case when they won’t have an edge is when they are compliment

More detail on all problem to SAT We first do CIRCUIT SAT  SAT CIRCUIT SAT (CSAT) Input: a boolean expression chained together Output: YES / NO whether the expression can be satisfied

Reduction Convert CSAT to SAT Is this correct?

Cook’s theorem Every problem in NP can be reduced to SAT

NP-C There is, effectively, only one NP-C Since it is NP-Hard Everything in NP can be reduced to it Including any other NP-C

Final Step Every problem is simply a turing machine Simply a logic circuit Hence, everything is circuit sat  sat