Lecture 18:
Introduction to NP completeness
- this class has focused on algorithms for problems that can be solved in polynomial time, the class P.
Draw class P
Examples of problems in P - and harder similar problems
shortest path - longest path (not necessarily DAG)
minimum spanning tree - traveling salesman
Horn SAT - 3SAT
linear programming - integer programming
independent set (given graph and integer g, find g vertices with no edges between them)
on trees - independent set on graphs
- For the next few classes, we will concentrate on a larger class of problems, called NP - problems that can be solved in polynomial time on a *non-deterministic* computer.
Draw NP
- We will see that the class NP has some surprising properties: First, that it has problems that are in a precise sense the hardest problems in NP - if you can solve one efficiently, you can solve them all efficiently
- the complement of a problem in NP might not be IN np. The complement of NP problems is in general the class co-NP. We can't yet prove that P not equal NP, but it is generally believed that are different. Fermats last theorem.
Draw co-NP
- There is a yet larger set of problems - those that require exponential time to solve. It is unknown whether NP=EXP TIME, but it is generally believed that they are different!
Draw EXP time
Finally, the picture can be further refined. Suppose you consider problems that can be solved in polynomial time on a regular computer augmented with a special "oracle" that can solve any NP or co-NP problem. This gives us a new class in between NP, co-NP, exp time, called "P^NP".
Draw P^NP
Why do we care about NP?
- Many problems we care about solving are NP complete.
- Even though all known exact algorithms for these problems require exponential time, researchers work to keep the exponent low --
Draw dog leg
- Much work on incomplete and approximate algorithms for such problems
- incomplete define
- approximate
2 Preliminaries:
1. Search vs. Decision problems
- What is the shortest path in a graph? Vs. Does a graph have a shortest path of length less than 20?
Ditto for longest path
- Convert search to decision problem by binary search.
2. Reduction
FIGURE (page 245)
Using reductions:
A-->B
hardness goes this way -->
efficient algorithms go this way <--
Examples of reductions
SAT --> CNF
define CNF
brute force approach: why blows up
reduction:
1. push in negations
2. push in OR by introducing new variables:
(A & B) v (C & D)
-->
E v A
E v B
~E v C
~E v D
**************************
CNF --> 3 CNF
split long clauses using new variables
(A v B v C v D)
--->
(A v B v E)
(C v D v ~E)
**************************
Formal definition of NP
- Let S be a search problem and S_d its corresponding decision problem.
1. Given S AND a proposed solution I, there
is a polynomial time algorithm that
that verifies that I solves S
2. S_d can be solved by a NON-deterministic polynomial time algorithm:
if GUESS then
else
where
if correct answer is "yes", then SOME sequence of guesses exist that
will lead the algorithm to output YES
if correct answer is "no", then NO sequence of guesses exist that
will lead the algorithm to output YES