np completeness piyush kumar. today reductions proving lower bounds revisited decision and...
Post on 18-Jan-2018
216 Views
Preview:
DESCRIPTION
TRANSCRIPT
NP CompletenessPiyush Kumar
Today• Reductions• Proving Lower Bounds revisited• Decision and Optimization Problems• SAT and 3-SAT• P Vs NP• Dealing with NP-Complete Problems
– Average Case / Heuristics / Approx. Alg.
Convex Hulls and Sorting• What are convex hulls?
• Given a program for computing convex hulls, can we use it to sort ?
Reduction from Sorting to CH– Given n real values xi , generate n 2D
points on a parabola, e.g. (xi,xi2).
– Compute the (ordered) convex hull of the points.
– The order of the convex hull points is the numerical order of the xi.
Reduction from Sorting to CH• Does this imply a lower bound on
computation of convex hulls?
• (nlgn) ?• Sorting p CH• p : Can also be read as
– “No harder to solve than”
Polynomial time reductions• If P is polynomial-time reducible
to Q, we will use the notation P p Q
• P p Q and Q p R– Implies P p R
Review : P, NP• Set of problems : P, NP• P = Can be solved in polynomial
time• NP = You can verify the solution
in polynomial time• P NP ?• P = NP ? (Probably not?)
definitions• NP-Hard : For all R in NP, R p T
– Implies T is NP-Hard• NP-Complete
– T is both in NP and NP-Hard
Definitions : Revisited• NP-Hard
– If you can solve it, you can solve everything in NP
• NP-Complete – NP-Hard and in NP
• NP : Non-Deterministic Polynomial time. ( Guess and verify )
P
NP
NP-complete
NP-hard
Primality testingSemidefinite programming…
Hamilton cycle, Independent Set, Vertex Cover,Graph 3-coloring,Satisfiability…
Factoring …
Halting Problem
Assuming P NP
Decision Vs Optimization• Decision Problem: computational problem
with intended output of “yes” or “no”, 1 or 0
• Optimization Problem: computational problem where we try to maximize or minimize some value
• Introduce parameter k and ask if the optimal value for the problem is a most or at least k. Turn optimization into decision
Decision Vs Optimization• Optimization Problem: TSP• Decision problem
– Is their a tour of length < k?
• Simplification: Worry only about decision problems. The class P, NP, NPC, NPH all constitute of only decision problems.
Cook’s Theorem• Theorem (Cook 1970) SAT is NP-Complete.
– CNF-SAT is also NP-Complete.
• Corollary 3-SAT is NP-Complete.
• Proof of Corollary
– How do we prove it?
– Recall the defn of NP-Complete
Proving NP Completeness• What steps do we have to take to
prove a problem P is NP-Complete?– A problem P is NP-complete if
1. it is in NP2. B NP, B p P (it is NP-Hard)
– Idea for condition 2 : • Use a known NP-Complete problem Q.
– Show Q p P. • By transitivity of p, we are done• B NP, B p Q p P• Hence : B NP, B p P
Algorithm for P
Reduction R R(x)
Input for P
Output for P
yes/no
Output for Q
x
Input for Q
Reduction revisited: (Q P)
Algorithm for solving Q
3-SAT is NP-Complete• 3-SAT is in NP (Trivial)
• We will pick Q to be CNF-SAT
• To show : CNF-SAT P 3-SAT.
• Let ∏ be the given CNF formula. We want to transform ∏ to an instance of 3-CNF.
• Idea: Transform each clause of ∏ so that it is 3-CNF
CNF-SAT to 3-SAT• If less than 3 literals, repeat them.
– Replace (a1 a2) by (a1 ∨ a2 ∨ a2)
• If 3 literals, leave it as it is.
CNF-SAT to 3-SAT• 4 literals : Replace (a1 a2 a3 a4) by (a1 a2
z) (z a3 a4)
• In general, replace (a1 a2 ak) by (a1 a2 z1) (z1 a3 z2) (z2 a4 z3) (zk-3 ak-1 ak)– z1 , , zk-3 : new variables– This is analogous to the 4 literal case, just
applied multiple times with more variables.
3-SAT is NP-Complete• 3-SAT is in NP• CNF-SAT P 3-SAT
– Since we can transform an input to the CNF-SAT problem in polynomial time to the 3-SAT problem solver and get a solution to CNF-SAT. Hence CNF-SAT is ‘no harder to solve than’ 3-SAT.
Other NP-Complete Problems• Hamiltonian Cycle• Of size k?
– Vertex cover : A vertex cover of G is a set C V such that all edges of E have at least one endpoint in C.
– Clique : Find in a given graph G, if there is a size k clique?
Other NP-Complete Problems• Set Cover : Given n sets, are there
k sets out of these whose union is the same as the union of n sets?
• Subset Sum : Given a set of integers, and another integer k; Is there a subset of them that sum upto k?
Toy Problem• TSP is NP-Complete
– Decision Version: Does a TSP with cost < k ?
– Is TSP in NP?– What problem should we pick to
prove this?
Approximation Algorithms• For some NP-Complete problems,
there are polynomial time algorithms that give near optimal solutions.
Vertex cover
Vertex cover• VC is NP-Complete
– (can be reduced from 3-SAT)
Approximation Alg for VC1. S 2. E E[G]3. while E 4. let (u,v) be am arbitrary edge in E5. S S {u,v}6. remove from E every edge
incident on either u or v7. return S
example
2-Factor : Proof• The vertex cover output by the
approximation algorithm is no more than twice the size of the optimal vertex cover.
• Why?
top related