l 30 nn pnp complete
TRANSCRIPT
-
8/12/2019 l 30 Nn Pnp Complete
1/58
P, NP Classes
-
8/12/2019 l 30 Nn Pnp Complete
2/58
Deliverables
Unsolvability
Satisfiability
Problem ClassificationReductions
NP-Complete and NP-HardCopyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
3/58
Easy Vs. Hard
Euler Circuit vs. Hamiltonian CircuitShortest Path vs. Longest Path
Minimum Spanning Tree vs. Dominating Set
Edge Cover vs. Vertex Cover
Min Cut vs. Max Cut
2-Dim Matching vs. 3-Dim Matching
2-Colorability vs. Colourability
2-Satisfiability vs. Satisfiability
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
4/58
We can categorize the problem spaceinto two parts
Solvable Problems
Unsolvable problems
Solvable and Unsolvable
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
5/58
Halting Problem
Given a description of a program and a finite input, decide wheththe program finishes running in a finite time or will run forever,given that input
The halting problem is famous because it was one of the firstproblems proved undecidable, which means there is no computeprogram capable of correctly answering the question for all possiinputs.
Given an polynomial , Does it has an integer solution
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
6/58
Diagonalization
In a small town of Sundargarh All those who dont know how tdo make-up go to the only beauty parlor of Sunaina in the towand those who know how to do make-up do it themselves.
Set of all Finite State Machines that dont accept itself will go t
Finite state machine that runs them
It is similar to the powerful idea of diagonalization
6/15/2012 Copyright @ gdeepak.com
-
8/12/2019 l 30 Nn Pnp Complete
7/58
-
8/12/2019 l 30 Nn Pnp Complete
8/58
-
8/12/2019 l 30 Nn Pnp Complete
9/58
All those algorithms that can be solved polynomial time with worst case running time O(nk). So these problems are regarded as tractabK can not be a variable, but has to be fixed.
A problem that can be solved polynomially in omodel can also be solved polynomially in othmodel.
P Class of Problems
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
10/58
P
Copyright @ gdeepak.com
Minimum Spanning TreeShortest PathSortingMin-MaxMax FlowConvex Hull
6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
11/58
Internal Structure of P
O(nk) K is fixed
O(n3)
O(n2)
O(n)
O(logn)
O(1)
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
12/58
Big Picture
Unsolvable
EXPSPACE
EXPTIME
PSPACE
NP
P
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
13/58
NP
Copyright @ gdeepak.com
Vertex CoverGraph ColoringTravelling Salesman
Max-Cut in a graphSteiner TreeSubgraph isomorphismDominating Set
6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
14/58
How many
There are thousands of known NP-complete probleKnown till now. There are definitely thousands of othwhich have not been explored yet. More and more coming into the net as the researchers prove the reductof a problem into already known NP-Complete Problem.
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
15/58
-
8/12/2019 l 30 Nn Pnp Complete
16/58
-
8/12/2019 l 30 Nn Pnp Complete
17/58
A Non deterministic algorithm for searching an elemex in a given set of elements A[1..n]
1. j= choice(1,n)
2. if A[j]=x then write (j); Success
3. else write(0); Failure
Non determinism
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
18/58
Algorithm Nsort For i=1 to n do B[i]=0;
for i=1to n do
{ j= choice(1,n);
if b[j]0 then failure(); B[j] = a[i] }
for i= 1 to n-1 do
if B[i] > B[i+1] then failure;
success();
Non determinsitic sorting
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
19/58
It is the set of all problems that can be solvedpolynomial time with non-deterministic concept.
However this concept only exists in theory. There areimplementations what so ever.
Non-deterministic Polynomial (NP)
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
20/58
A decision problem is that problem which can have otwo options as its solution space i.e. yes or no.
Whether x is a prime number is also a decision problthat will have answer yes or no.
For a Travelling salesperson problem the question twhether a tour of cost < k exists is a decision problem.
Decision Problems
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
21/58
So for many problems it will be like guess & vesituation.
We will guess a particular solution and then verify twhether this is the solution (yes) or not ( no)
If this guessing and verifying can be done in polynomtime with the help of a non deterministic concept thwe say that the problem is in NP
Guess & verify
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
22/58
Non Determinism
Non deterministic machine checks all of them at once Can be done hypothetically. Means we need exponen
number of parallel processors to do the same task ideterministic way in polynomial time.
So Non deterministic machine will take 3n If you have a good guess, then it can be done in
polynomial time, otherwise total number of guesses exponential.
6/15/2012 Copyright @ gdeepak.com
-
8/12/2019 l 30 Nn Pnp Complete
23/58
Satisfiability is the problem of determining if the variables given Boolean formula can be assigned in such a way asmake the formula evaluate to TRUE. Equally important idetermine whether no such assignments exist, which woimply that the function expressed by the formula is identic
FALSE for all possible variable assignments. In this latter case, we would say that the function
unsatisfiable; otherwise it is satisfiable.
To emphasize the binary nature of this problem, itfrequently referred to as Boolean or propositional satisfiabil
Satisfiability Problem
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
24/58
if f(x1,x2,xn) = True xi= 0 or 1 we have to find x1,x2,x3xn such that f(b1,b2,b3bn)=1 where b1= 0 or 1,b2= 0 or 1
bn = 0 or 1 2n different permutations, someone out of that can g
answer as 1 (true) guess
?f(1,0,1,0,0,1 ..,1,0) = 1 verify ( evaluate the function) ability to guess and verify in polynomial time
Satisfiability Problem
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
25/58
The complexity class P is contained in NP but the vversa has not been proved and proving whether p= remains the biggest research question.
Cook Formulated a question that is there any sinproblem in NP such that if we showed it to be in P, ththat would imply P=NP
COOK theorem
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
26/58
Given an instance x of a problem A, use a polynomtime reduction algorithm to transform it to instance yproblem B.
Run the polynomial time algorithm for B on instance y
use the answer for y as the answer for x.
reducibility
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
27/58
NP
These can do things in parallel as long as the resultanswers can be connected with OR and any one of this the answer.
Or in other words it can choose one of the possichoices at any point of time at the same time.
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
28/58
3-SAT
(x++ z) (x+ y + )
(p++)
.
. .
Mth clause
Copyright @ gdeepak.com
N different variables being used in m set of clauses
Whether there is a way to assign truth values todifferent variables so that whole formula is true
Total number of such possible assignments for nvariables 2n
So Total time will be 3m.2n
This was the first problem to be proved NP-Comple
6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
29/58
NP version
For every possible set of assignment to n-variables it will check th
truth value of the assignment. Either this or this or or that
The solutions can be checked with a combination of Ors and one them may be true if it has an assignment otherwise all will be fals
Theoretically can be done with 2n Parallel processors in polynom
deterministic time. Non deterministic machine will take 3m.
Well, if you are a good boy or GOD-boy and you can guess the thimagically, then you can guess in the first go and truth value can bdetermined in polynomial time. But, we are yet to find such a BO
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
30/58
SAT
(x) (x++ z)
(x+ )
(p+++t)
. .
.
Mth clause
Copyright @ gdeepak.com
N different variables being used in m set of clausesA clause can contain any number of variable whichwas fixed to 3 in 3-SATWhether there is a way to assign truth values to
different variables so that whole formula is trueTotal number of such possible assignments for nvariables 2n
6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
31/58
General SAT
SAT
3-SAT Claim is that if you can solve 3-SAT you can solve any
version.
Any three variable clause will remain as it is
(x++ z) (x++ z) (x+) (x++c) (x++ )
(p+++t) (p++) (++t)
(p+++t + u+v) (p++1) (1 ++L2)(2 +t+L3)(3 +u+v)
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
32/58
Solving 2-SAT
(x1 +x2) (x2+x3) (x1+x2) (x3 +x4) (x3+x5) (x4+x5) +x4).
Number of variables n = 5 and number of clauses m = 7. general, m n.)
Start by makingx1 TRUE. This makes the clause (x1 +x2) TR
accordingly, this clause may be removed. Under this assignmx2must be TRUE (i.e.,x2 must be FALSE) in order to satisfyclause (x1+x2). Makingx2 FALSE satisfies the clause (x2+as well, leaving only the shorter formula and so on
(x3 +x4) (x3+x5) (x4+x5) (x3+x4)6/15/2012 Copyright @ gdeepak.com
-
8/12/2019 l 30 Nn Pnp Complete
33/58
3-colorability SAT
Can you color a Graph in with 3 colors or Not. Let us say th3 colors to be used are Red, Yellow and Green.
For every node the logical relation has to be
(AR+ AG+ AY)
Similar Relation will be formed for every node with 3 clause
Copyright @ gdeepak.com
A B
C D
6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
34/58
3-colorability
6 logical relations has to be created using above rule
AR
AGG
AY
BR
BGG BY
Total 3n+6e clauses will be there in the corresponding 3-SArelation where n is the number of nodes and e is the numbeof edges
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
35/58
Reductions
SAT
3-SAT
Means SAT is at least as hard as 3-SAT or if I can solve 3-SAthen I can solve SAT also.
2-colorability
SAT (Useless Reduction)
Theoretically it means that if I can solve SAT, I can also solv2-colorability but that is already solved and is very easy usithe bipartite graph. So we never reduce an easy problem to hard problem.
So we try to solve a problem for many days, if it cannot besolved in a polynomial time then we try to reduce it to someNP-complete problem and the iterating like this between th
two stages.
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
36/58
-
8/12/2019 l 30 Nn Pnp Complete
37/58
Strongly Connected Components
Each strongly connected components can be collapsed ione. If all the complements are in different conneccomponents then 2-SAT has a true assignment.
M is NP-Complete if NP M and if M Q then Q is NComplete.
However if Q M that may not give us anything.
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
38/58
h
-
8/12/2019 l 30 Nn Pnp Complete
39/58
XY then YX
Independent Set problem: largest set of nodes which are not connected to each ot
Segment intersection: To find the number of lines that dont intersect with any otline.
We claim that maximum number of lines that dont intersect with each other is sas maximum independent set.
Copyright @ gdeepak.com
ed
c
b
a
e
c
d
a
b
6/15/2012
ll d i
-
8/12/2019 l 30 Nn Pnp Complete
40/58
All reductions are not easy
If we want to reduce independent set to segmentintersection, it will be an exponential reduction.
Copyright @ gdeepak.com6/15/2012
H d d i
-
8/12/2019 l 30 Nn Pnp Complete
41/58
How to do reduction
Experience
Feature extraction
Familiarity with both the problems
Boolean Algebra
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
42/58
-
8/12/2019 l 30 Nn Pnp Complete
43/58
SAT V t C
-
8/12/2019 l 30 Nn Pnp Complete
44/58
3-SAT Vertex Cover
Dotted is the vertex cover.
Copyright @ gdeepak.com
x y z
6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
45/58
3 SAT V t C
-
8/12/2019 l 30 Nn Pnp Complete
46/58
3-SAT Vertex Cover
It does not satisfies our equation.
Copyright @ gdeepak.com
x y z
6/15/2012
NP Complete
-
8/12/2019 l 30 Nn Pnp Complete
47/58
NP- Complete
It needs to be in NP
This problem is at least as hard as every other problemNP
Copyright @ gdeepak.com6/15/2012
Hamiltonian Circuit Problem
-
8/12/2019 l 30 Nn Pnp Complete
48/58
Hamiltonian Circuit Problem
ABCDEFG are the nodes
Guess: BDEFGCAB
I can check whether these are connected in this mannein polynomial time, if all the edges exist I say , yes andany edge is missing, I will say No and then make anothguess.
There are n! guesses
No body knows any better algorithm
Copyright @ gdeepak.com6/15/2012
Clique Problem
-
8/12/2019 l 30 Nn Pnp Complete
49/58
Clique Problem
Given a graph and a number k. In this graph can you fk or more nodes which are all connected to each other
Or find the max clique of a graph
If n is 3 or 4 then it is a polynomial algorithm, otherwik can go to n.
Copyright @ gdeepak.com6/15/2012
3D matching
-
8/12/2019 l 30 Nn Pnp Complete
50/58
3D matching
M F Martian
100 100 100
We can have n3 combinations of preferences
Guess 100 triples
Take your guess, for ever triple check if it is there in thpreferences then n*n3
How many guesses : exponential
Copyright @ gdeepak.com6/15/2012
Reduction
-
8/12/2019 l 30 Nn Pnp Complete
51/58
ReductionSorting Convex Hull
Sorting reduces to convex Hull
8 3 17
Reduction
8,64 3,9 17,
Solve convex hull
Solution to convex hull after again converting back will be solution to sorting
Reduction should be easy, not the bottom neck of your algorithm andweakest link of your chain
Reductions in the case of NP-complete problems should be polynomial reductions
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
52/58
NP-Hard
-
8/12/2019 l 30 Nn Pnp Complete
53/58
NP-Hard
Y is NP-Complete
1) Y belongs to NP2) For any X belonging to NP
X can be reduced in polynomial time to Y
If we remove the first condition then it is NP-Hard
Optimization version of the TSP where you say that find the optischedule instead of saying whether a Tour of less than K exists.
All problems in Complexity classes above NP-Complete are sometalso called NP-hard because they are more harder then any hproblem in NP.
6/15/2012 Copyright @ gdeepak.com
Conclusion
-
8/12/2019 l 30 Nn Pnp Complete
54/58
So we are able to correlate one problem which is NP hard w
the another problem which is also NP hard and so we canthat if one of them can be solved in polynomial time tanother can also be solved in polynomial time. Similarly it be proved for all problems in NP.
But the problem is that we donthave any polynomial solut
for any of the problems in NP included both discussed. Aalso there is almost no hope. Only thing we can say here is tit has not been proved that P=NP and neither it has bproved that P NP so that can give us a little hope to workand on.
Conclusion
Copyright @ gdeepak.com6/15/2012
Questions Comments and Suggestion
-
8/12/2019 l 30 Nn Pnp Complete
55/58
Questions, Comments and Suggestion
Copyright @ gdeepak.com6/15/2012
-
8/12/2019 l 30 Nn Pnp Complete
56/58
Question 2
-
8/12/2019 l 30 Nn Pnp Complete
57/58
Question 2
What would prove that X is NP-hard?
(A) Showing a polynomial-time reduction from 3-Sat to X
(B) Showing a polynomial-time reduction from X to 3-Sa
(C) Either of the above
(D) None of the above
Copyright @ gdeepak.com6/15/2012
Question 3
-
8/12/2019 l 30 Nn Pnp Complete
58/58
Question 3
3-SAT is
A) P
B) NP
C) NP Complete
D) NP Hard
Copyright @ gdeepak.com6/15/2012