KEMBAR78
Introduction to NP Completeness | PPT
1
NP-Completeness
November 28, 2003
Young Eun Kim and Gene Moo Lee
Department of Computer Science & Engineering
Korea University
2/30
Contents
• Introduction and Motivation
• Background Knowledge
• Definition of NP-Completeness
• Examples of NP-Complete Problems
• Hierarchy of Problems
• How to Prove NP-Completeness
• How to Cope with NP-Complete Problems
• Conclusion
3/30
Introduction (1/2)
• Some Algorithms we’ve seen in this class
– Sorting – O(N log N)
– Searching – O(log N)
– Shortest Path Finding – O(N2
)
• However, some problems only have
– Exponential Time Algorithm O(2N
)
– So What?
Why? What? How?
4/30
Introduction (2/2)
N 10 20 30 40 50 60
O(N) .00001
second
.00002
second
.00003
second
.00004
second
.00005
second
.00006
second
O(N2
) .0001
second
.0004
second
.0009
second
.0016
second
.0025
second
.0036
second
O(N3
) .001
second
.008
second
.027
second
.064
second
.125
second
.216
second
O(N5
) 1
second
3.2
seconds
24.3
seconds
1.7
minutes
5.2
minutes
13.0
minutes
O(2N
) .001
second
1.0
second
17.9
minutes
12.7
days
35.7
years
366
centuries
O(3N
) .059
second
58
minutes
6.5
years
3855
centuries
2*108
centuries
1013
centuries
Why? What? How?
5/30
Motivation
• Traveling Salesman Problem (n = 1000)
• Compute 1000!
– Even Electron in the Universe is a Super Computer,
– And they work for the Estimated Life of the Universe,
– WE CANNOT SOLVE THIS PROBLEM!!!
– This kind of problems are NP-Complete.
Why? What? How?
6/30
Background Knowledge
To understand NP-Completeness, need to
know these concepts
1. Decision and Optimization Problems
2. Turing Machine and class P
3. Nondeterminism and class NP
4. Polynomial Time Reduction
(Problem Transformation)
Why? What? How?
7/30
Decision and Optimization Problems
• What is the Shortest Path from A to B?
– This is an Optimization Problem.
• Is there a Path from A to B consisting of at
most K edges?
– This is the related Decision Problem.
We consider only Decision Problems!
Why? What? How?
8/30
Turing Machine and Class P
(1/3)
Church – Turing Thesis
“Computer ≡ Turing Machine”
Alan Turing(1912-1954)
(www.time.com)
Why? What? How?
9/30
Turing Machine and Class P
(2/3)
A Turing machine
is a 7-tuple (Q, ∑, Γ, δ, q0, qaccept, qreject).
Why? What? How?
10/30
Turing Machine and Class P
(3/3)
P : the class of problems that are
decidable in polynomial time on a
Turing machine
Sorting, Shortest Path are in P!
Why? What? How?
11/30
Nondeterminism and Class NP (1/2)
• A Nondeterministic Turing machine is a Turing
machine with the transition function has the form
δ : Q * Γ  P(Q * Γ * {L, R}).
• NTM guess to choose the answer nondeterministically
Why? What? How?
12/30
Nondeterminism and Class NP (2/2)
• NP : the class of problems that are decidable in
polynomial time on a nondeterministic Turing
machine
• Solutions of problems in NP can be checked
(verified) in polynomial time.
• If a Hamiltonian path were discovered somehow,
we could easily check if the path is Hamiltonian.
– HAMPATH is in NP! Also Sorting is in NP!
Why? What? How?
13/30
Class P and NP
• P = the class of problems where
membership can be decided quickly.
• NP = the class of problems where
membership can be verified quickly.
Why? What? How?
14/30
Polynomial Time Reduction
Traveling Salesman Problem5-CliqueMap Coloring
Traveling Salesman Problem
 5-Clique  Map Coloring
Why? What? How?
15/30
Definition of NP-Completeness
A problem B is NP-complete
if it satisfies two conditions:
1. B is in NP, and
2. Every problem A in NP is polynomial
time reducible to B. (NP-Hard)
Why? What? How?
16/30
Meaning of NP-Completeness
• NP: Nondeterministic Polynomial
• Complete:
– If one of the problems in NPC have an
efficient algorithm, then all the problems
in NP have efficient algorithms.
Why? What? How?
17/30
Examples of NP-Completeness
• Satisfiability (SAT)
• Traveling Salesman Problem (TSP)
• Longest Path (vs. Shortest Path is in P)
• Real-Time Scheduling
• Hamiltonian Path (vs. Euler Path is in P)
Why? What? How?
18/30
Where are we?
Background Knowledge
Definition of NP-Completeness
Examples of NP-Complete Problems
• Hierarchy of Problems
• How to Prove NP-Completeness
• How to Cope with NP-Completeness
19/30
Hierarchy of Problems (1/2)
P NP PSPACE = NPSPACE EXPTIME⊆ ⊆ ⊆
Conjectured Relationships
EXPTIME
NPSPACE
NP P
UNDECIDABLE
Why? What? How?
20/30
Hierarchy of Problems (2/2)
NP
P
Which one is correct?
An efficient algorithm on a
deterministic machine does not
exist.
An efficient algorithm on a
deterministic machine is not
found yet.
P = NP
Why? What? How?
21/30
How to prove NP-Completeness(1/3)
• If B is NP-complete and B C for C in NP,∝
then C is NP-complete.
B C
NP-complete NP-complete
Then, we need at least one NP-complete problem!
Why? What? How?
22/30
How to prove NP-Completeness(2/3)
Cook’s Theorem
“Satisfiability Problem (SAT) is
NP-complete.”
- the first NP-complete
problem!
Stephen Cook
(www.cs.toronto.edu)
Why? What? How?
23/30
I’m also NP
Complete!
How to prove NP-Completeness(3/3)
any NP
problem
can be reduced to...
SAT
new NP
problem
can be reduced to...
Proved by
Cook
New Problem
is “no easier”
than SAT
Why? What? How?
24/30
NP-Complete Problems Tree
SAT
3-SAT Graph 3-Color
3-DM
Exact Cover Planer 3-color
Vertex Cover
Subset-Sum
HAMPATH Clique
Partition
Integer
Programming
IndependentTSP (Salesman)
Why? What? How?
25/30
How to Cope with NP-Completeness
I. HEURISTIC ALGORITHM
To find a solution within a reduced search-space.
II. APPROXIMATION ALGORITHM
To find approximately optimal solutions.
III. QUANTUM COMPUTING
To use the spins of quantum with the speed of
light. (bit 0, 1 spin-up (0), spin-down (1))
Why? What? How?
26/30
Heuristic Algorithm
• In NP-Complete Problems,
we have to check exponential possibilities.
• By Heuristic, reduce the search space.
• Example: Practical SAT problem Solvers
– zChaff, BerkMin, GRASP, SATO, etc.
Why? What? How?
27/30
Approximation
• Hard to find an exactly correct solution
in NP-complete problems
• By Approximation,
find a nearly optimal solution.
• Example: finding the smallest vertex covers
(we can find a vertex cover never more than
twice the size of the smallest one.)
Why? What? How?
28/30
Quantum Computation
• Bit 0 and 1 
Spin Up and Spin
Down
• Speed of electron
 Speed of light
Why? What? How?
Digital Comp.  Quantum Comp.
29/30
Conclusion
When a hard problem is given,
we can prove that a problem is NP-complete,
just by finding a polynomial time reduction.
After proving,
we can solve the problem in these ways:
Heuristic Algorithm, Approximation
Algorithm and Quantum computing.
30/30
Thank You for Listening.
Any Question?

Introduction to NP Completeness

  • 1.
    1 NP-Completeness November 28, 2003 YoungEun Kim and Gene Moo Lee Department of Computer Science & Engineering Korea University
  • 2.
    2/30 Contents • Introduction andMotivation • Background Knowledge • Definition of NP-Completeness • Examples of NP-Complete Problems • Hierarchy of Problems • How to Prove NP-Completeness • How to Cope with NP-Complete Problems • Conclusion
  • 3.
    3/30 Introduction (1/2) • SomeAlgorithms we’ve seen in this class – Sorting – O(N log N) – Searching – O(log N) – Shortest Path Finding – O(N2 ) • However, some problems only have – Exponential Time Algorithm O(2N ) – So What? Why? What? How?
  • 4.
    4/30 Introduction (2/2) N 1020 30 40 50 60 O(N) .00001 second .00002 second .00003 second .00004 second .00005 second .00006 second O(N2 ) .0001 second .0004 second .0009 second .0016 second .0025 second .0036 second O(N3 ) .001 second .008 second .027 second .064 second .125 second .216 second O(N5 ) 1 second 3.2 seconds 24.3 seconds 1.7 minutes 5.2 minutes 13.0 minutes O(2N ) .001 second 1.0 second 17.9 minutes 12.7 days 35.7 years 366 centuries O(3N ) .059 second 58 minutes 6.5 years 3855 centuries 2*108 centuries 1013 centuries Why? What? How?
  • 5.
    5/30 Motivation • Traveling SalesmanProblem (n = 1000) • Compute 1000! – Even Electron in the Universe is a Super Computer, – And they work for the Estimated Life of the Universe, – WE CANNOT SOLVE THIS PROBLEM!!! – This kind of problems are NP-Complete. Why? What? How?
  • 6.
    6/30 Background Knowledge To understandNP-Completeness, need to know these concepts 1. Decision and Optimization Problems 2. Turing Machine and class P 3. Nondeterminism and class NP 4. Polynomial Time Reduction (Problem Transformation) Why? What? How?
  • 7.
    7/30 Decision and OptimizationProblems • What is the Shortest Path from A to B? – This is an Optimization Problem. • Is there a Path from A to B consisting of at most K edges? – This is the related Decision Problem. We consider only Decision Problems! Why? What? How?
  • 8.
    8/30 Turing Machine andClass P (1/3) Church – Turing Thesis “Computer ≡ Turing Machine” Alan Turing(1912-1954) (www.time.com) Why? What? How?
  • 9.
    9/30 Turing Machine andClass P (2/3) A Turing machine is a 7-tuple (Q, ∑, Γ, δ, q0, qaccept, qreject). Why? What? How?
  • 10.
    10/30 Turing Machine andClass P (3/3) P : the class of problems that are decidable in polynomial time on a Turing machine Sorting, Shortest Path are in P! Why? What? How?
  • 11.
    11/30 Nondeterminism and ClassNP (1/2) • A Nondeterministic Turing machine is a Turing machine with the transition function has the form δ : Q * Γ  P(Q * Γ * {L, R}). • NTM guess to choose the answer nondeterministically Why? What? How?
  • 12.
    12/30 Nondeterminism and ClassNP (2/2) • NP : the class of problems that are decidable in polynomial time on a nondeterministic Turing machine • Solutions of problems in NP can be checked (verified) in polynomial time. • If a Hamiltonian path were discovered somehow, we could easily check if the path is Hamiltonian. – HAMPATH is in NP! Also Sorting is in NP! Why? What? How?
  • 13.
    13/30 Class P andNP • P = the class of problems where membership can be decided quickly. • NP = the class of problems where membership can be verified quickly. Why? What? How?
  • 14.
    14/30 Polynomial Time Reduction TravelingSalesman Problem5-CliqueMap Coloring Traveling Salesman Problem  5-Clique  Map Coloring Why? What? How?
  • 15.
    15/30 Definition of NP-Completeness Aproblem B is NP-complete if it satisfies two conditions: 1. B is in NP, and 2. Every problem A in NP is polynomial time reducible to B. (NP-Hard) Why? What? How?
  • 16.
    16/30 Meaning of NP-Completeness •NP: Nondeterministic Polynomial • Complete: – If one of the problems in NPC have an efficient algorithm, then all the problems in NP have efficient algorithms. Why? What? How?
  • 17.
    17/30 Examples of NP-Completeness •Satisfiability (SAT) • Traveling Salesman Problem (TSP) • Longest Path (vs. Shortest Path is in P) • Real-Time Scheduling • Hamiltonian Path (vs. Euler Path is in P) Why? What? How?
  • 18.
    18/30 Where are we? BackgroundKnowledge Definition of NP-Completeness Examples of NP-Complete Problems • Hierarchy of Problems • How to Prove NP-Completeness • How to Cope with NP-Completeness
  • 19.
    19/30 Hierarchy of Problems(1/2) P NP PSPACE = NPSPACE EXPTIME⊆ ⊆ ⊆ Conjectured Relationships EXPTIME NPSPACE NP P UNDECIDABLE Why? What? How?
  • 20.
    20/30 Hierarchy of Problems(2/2) NP P Which one is correct? An efficient algorithm on a deterministic machine does not exist. An efficient algorithm on a deterministic machine is not found yet. P = NP Why? What? How?
  • 21.
    21/30 How to proveNP-Completeness(1/3) • If B is NP-complete and B C for C in NP,∝ then C is NP-complete. B C NP-complete NP-complete Then, we need at least one NP-complete problem! Why? What? How?
  • 22.
    22/30 How to proveNP-Completeness(2/3) Cook’s Theorem “Satisfiability Problem (SAT) is NP-complete.” - the first NP-complete problem! Stephen Cook (www.cs.toronto.edu) Why? What? How?
  • 23.
    23/30 I’m also NP Complete! Howto prove NP-Completeness(3/3) any NP problem can be reduced to... SAT new NP problem can be reduced to... Proved by Cook New Problem is “no easier” than SAT Why? What? How?
  • 24.
    24/30 NP-Complete Problems Tree SAT 3-SATGraph 3-Color 3-DM Exact Cover Planer 3-color Vertex Cover Subset-Sum HAMPATH Clique Partition Integer Programming IndependentTSP (Salesman) Why? What? How?
  • 25.
    25/30 How to Copewith NP-Completeness I. HEURISTIC ALGORITHM To find a solution within a reduced search-space. II. APPROXIMATION ALGORITHM To find approximately optimal solutions. III. QUANTUM COMPUTING To use the spins of quantum with the speed of light. (bit 0, 1 spin-up (0), spin-down (1)) Why? What? How?
  • 26.
    26/30 Heuristic Algorithm • InNP-Complete Problems, we have to check exponential possibilities. • By Heuristic, reduce the search space. • Example: Practical SAT problem Solvers – zChaff, BerkMin, GRASP, SATO, etc. Why? What? How?
  • 27.
    27/30 Approximation • Hard tofind an exactly correct solution in NP-complete problems • By Approximation, find a nearly optimal solution. • Example: finding the smallest vertex covers (we can find a vertex cover never more than twice the size of the smallest one.) Why? What? How?
  • 28.
    28/30 Quantum Computation • Bit0 and 1  Spin Up and Spin Down • Speed of electron  Speed of light Why? What? How? Digital Comp.  Quantum Comp.
  • 29.
    29/30 Conclusion When a hardproblem is given, we can prove that a problem is NP-complete, just by finding a polynomial time reduction. After proving, we can solve the problem in these ways: Heuristic Algorithm, Approximation Algorithm and Quantum computing.
  • 30.
    30/30 Thank You forListening. Any Question?

Editor's Notes

  • #2 Good Morning, everyone! My name is Gene Moo Lee. Let’s start our presentation. We are going to talk about NP-Completeness.
  • #3 This is the contents of our presentation. First, we will see why we have to study NPC. Then with background knowledge, we will formally define NPC. Then I will give you some examples of it. That is my part, and my partner Kim Young Eun will show you where NPC locates in the whole hierarchy of problems. And see how to prove a problem is NPC, and how to cope with that kind of problems.
  • #4 So far in our class, we’ve seen many algorithms to solve problems. Here are some of them. In these problems like sorting, searching, shortest path finding, we know algorithms with these time complexity. But unlike these problems, there are some problems that only have exponential time algorithm. So what? Let’s go to next page.
  • #5 Here is a table considering the time complexity. As you see here with polynomial time complexity, the time is very small. But if you see here with exponential time complexity with n is 50 or 60, the time is just too long!! 366 centuries!!
  • #6 Let’s take a look at a example of Traveling Salesman Problem with 1000 cities. In this problem, we want to know the shortest cycle with visiting all the 1000 cities one time. Then in the algorithm we know, we have to compute 1000 factorial cases! However, even if all the electron in the universe is super computes, and they work for the estimated life of the universe, We cannot compute 1000 factorial!. This kind of problems are called NP-Complete.
  • #7 To understand NPC, we have to know these concepts first. First, decision problems and optimization problems. Then Turing Machine and class P. Nondeterminism and class NP. Last, polynomial time reduction, also known as problem transformation.
  • #8 First, Decision problems and optimization problems. Let’s see this problem. What is the shortest path from A to B? This is an example of optimization problems. Next, is there a path from A to B consisting of at most k edges? This is the related decision problem of the problem above. But in the theory of NPC, we could only consider decision problems. So to think about optimization problems, we will think about the related decision problems.
  • #9 Next thing to know is Turing Machine, This handsome man is Alan Turing, who is one of the most famous computer scientist. By his theory, Computer and Turing machine have equal power to compute. So in the theory of NPC, we emulate the power of actual computers by Turing machines.
  • #10 This is the definition of Turing machine. And this is the conceptual picture of it. With its finite state control rule, a Turing machine reads input and write outputs to a tape and moves head to the right or left. After reading and writing, it can accept or reject in some situation just like finite automata.
  • #11 After we know what is a Turing machine, then we can define the class P. P is the class of problems that are decidable in polynomial time on a Turing machine. So Sorting and Shortest Path are in P. In the definition, “polynomial time” means that the problem can be easily solved in our real computers.
  • #12 Now, let’s look at a revised version of Turing machine. You know how a NFA is different from a DFA. In a given moment, NFA can change its state into many states. Same to the Turing machine. A NTM can compute many things simultaneously. As you see in this picture, NTM has a guessing module to guess the answer.
  • #13 Then we can define the class NP. NP is the class of problems that are decidable in polynomial time on a NTM. The meaning is this. If we have a solution of the problem, then the NTM can determine whether the solution is right or wrong. For example, in the case of Hamiltonian Path problem, say we discover a HAMPATH somehow. Then we can easily see if the answer is right. So HAMPATH is in NP. Also a DTM is also a NTM, so all the problems in P is also in NP. P is a subset of NP!
  • #14 Here we briefly explain P and NP again. In the problems in P, we can solve the problems with efficient algorithm in polynomial time. In the problems of NP, if the solution is given, then we can check if the solution is right in polynomial time.
  • #15 The last thing to know NPC is polynomial time reduction. This concept indicates that some problems are connected each other. Let’s look at this example. First, Traveling Salesman Problem can be described like this. Next, 5-Clique can be shown like this. We can see that those two problems are pretty similar to each other. Also, Map Coloring problem is also similar to those. Then we say that TSP can be reduced to 5-Clique. And 5-Clique can be reduced to Map Coloring.
  • #16 Now we can define NPC. A problem B is NPC if B is in NP and all problems can be reduced to the problem B. All problem satisfying the second condition are called NP-Hard. So all NPC problems are NP-Hard. But not all NP-hard problems are NPC.
  • #17 This is the underlying meaning of NPC. NP indicates Nondeterministic Polynomial. Complete means that if one of the problems in NPC have an efficient algorithm, then all problems in NP have efficient algorithms. So theoretically the problems in NPC are really concentrated by scholars.
  • #18 Here are some examples of NPC. SAT problem is this. “Given a formula, is there a truth assignment that makes the formula true?” And TSP, we’ve seen it. Longest Path is to find the longest path from A to B. Also real-time scheduling in Operating System is NPC. HAMPATH, too. This is all for me. And my partner will cover the rest of our presentation.
  • #19 My partner explained you the definition of NPC, and gave some examples of those. Now I will show you where NPC are located in the hierarchy of problems. And I will explain how to prove a problem is NPC, and how to cope with NPC problems. Then make a conclusion.
  • #20 All the problems in this world can be sorted by two catagories. That is, undecidable problem, decidable problems. And undecidable problems have hierarchy. It is described here. Exponential-time space contains NPSPACE, and NPSPACE have NP problems. And the set of P problems is contained in the set of NP problems.
  • #21 Let’s see the relationship of NP and P problems. There can two relationships like here. The first one means that an efficient algorithm on a deterministic machine does not exist. On the contrary, the second one means that an efficient algorithm on a deterministic machine is not found yet. But no one know which one is correct yet.
  • #22 Now, we’re going to see how to prove NP-completeness. If B is NP-complete and B is reducible to C in NP, then C is NP-complete. But before using this method, the NP-complete problem is necessary.
  • #23 We can get the first NP-complete problem by Cook’s theorem. Stephen Cook proved that SAT is NP-complete. So he enables us to find another NP-complete problems. The detailed proving process is abbreviated.
  • #24 Now we will trace how to prove NP-completeness using Cook’s theorem. First, any NP problems can be reduced to SAT. This is proved by Cook. And SAT can be reduced to a new NP problems. Then, the found NP problem becomes NP-complete.
  • #25 Using the way of proving NP-completeness in the previous page, we can find many NP-complete problems. It is illustrated here. SAT is NP-complete problem, and SAT is reduced to these two NP problems, then those are NP-complete problems. We use this process repeatedly, then many NP-complete problems are found like here.
  • #26 Even though we proved that a problem is NP-complete, the problem will not disappear. So we have to find alternatives to resolve the problem. Here we propose three ways to cope with NP-complete problems.
  • #27 The first one is Heuristic Algorithm. NP-complete problems require to check exponential possibilities. But this algorithm reduces the search space. So, the number of checking is lowered. As a result, the possibility to find an answer is increased.
  • #28 The second way of solving the NP-complete problems is using approximation algorithm. This algorithm is designed to find nearly optimal solution, not to find the best answer. If you try to find the exactly right answer, it will be difficult. So, this algorithm let us to solve a NP-complete problem a little bit easily. As an example, finding a vertex cover which has less than twice the size of the smallest one can be selected.
  • #29 The another one of coping with NP-complete problems is using a quantum computer. A quantum computer uses quantum’s spins. That is, spin up as bit 0 and spin down as bit 1. Moreover, quantum moves with the speed of light. So processing power, amount of work done in a specific time is increased compared to that of a digital computer. As a result, NP-complete problem requiring hundreds of years can be solved in a few seconds.
  • #30 Now we are in the conclusion. We learned that when a hard problem is given, we can prove that a problem is NP-complete by a polynomial time reduction. And after being proved, the problem is solved by some ways, Heuristic Algorithm, Approximation algorithm, and quantum computing.
  • #31 Here is the end of our presentation. Do you have any question?