Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
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 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
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
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
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.
P, NP, and NP-Complete Suzan Köknar-Tezel.
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.
MCS312: NP-completeness and Approximation Algorithms
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
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.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
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.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
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
More NP-Complete and NP-hard Problems
Chapter 10 NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Prabhas Chongstitvatana
The Theory of NP-Completeness
Lecture 23 NP-Hard Problems
Presentation transcript:

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

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

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 bool Kaboom(x) { if (A(x,x)) { while (true) do ; } else { printf(“wow….”); } kb.cpp

A X X X loops forever yes no

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

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 k th smallest element can be solved by simply sort the input Hence, k th 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 Which one is harder? A or B?

P and NP Class of problems P 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 P MSS, Sorting, Shortest Path, MST NP MSS, Sorting, Shortest Path, MST is also NP TSP, 01-knapsack, graph coloring, longest path And much more NP P P

More Example Shortest Path 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 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”

Decision Problem We consider only 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 problem 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

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

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

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 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 y 1,…y k-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 a i 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 a i is true, we must set y such that the entire is true Simply set y 1,…,y i-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 = C x y -z -x -y z -z y

Correctness If C has solution, S 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, S mustn’t be satisfiable Again, use contrapositive, if S 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 problems 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?

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

Your Turn Independent Set  clique Independent Set = set that vertices does not adjacent Clique = set that vertices always adjacent Independent Set  vertex cover Independent Set = largest set that vertices does not adjacent Vertex cover Given a graph and a number k Is there exists a set of k vertices to which every edge in the graph incident