Does Reducing P or NP instance to NP-Complete make that instance also NP-Hard? - complexity-theory

If a Problem X lying in P or NP can be reduced to NP-Complete, is that problem X automatically an NP-Hard problem?

Quick reply: No, it does not.
Recall the definition of NP-hard problems.
A problem X is NP-Hard if every problem in NP can be polynomially
reduced to X.
If on the other hand a problem X can be polynomially reduced to some NP-complete problem Y, it means that Y is at least as hard as X, not the other way around.
Finally, if an NP-complete problem Z can be polynomially reduced to X, then indeed X is NP-hard as every problem W in NP can be reduced to Z and by combining the two reductions we can reduce W to X, so the definition is satisfied.
Q: If a Problem X lying in P or NP can be reduced to NP-Complete, is that problem X automatically an NP-Hard problem?
A: No
Q: If a Problem X lying in P or NP is such that an NP-Complete problem can be reduced to it, is that problem X automatically an NP-Hard problem?
A: Yes

Related

Can a problem be in NP but not NP-Complete or P?

I am looking at the graphs in:
https://en.wikipedia.org/wiki/P_versus_NP_problem
It seems like, there is gap between P and NP-complete. So are there a class of problems that are in NP but neither in P or NP-Complete.
In other words, do the classes P, NP-complete completely cover NP?
And if so, an example is appreciated.
If P = NP, the answer to your question is that all problems in NP are both in P and in NP-Complete.
If P != NP, the answer to your question is that there are problems known to be in NP, which are known not to be NP-complete but for which no polynomial-time algorithm is yet known. I say there is none yet known because if you knew (1) the problem is in NP and (2) the problem is not in P, well then you'd know P != NP, which we don't.

Is the NO-VERTEX-COVER in NP or not?

This is the reverse version of vertex cover problem. Consider a decision problem that asks whether, given a graph G = (V, E) and a nonnegative integer k, there does not exist a vertex cover of size no larger than k. Answer whether this problem is NP or not ? Please explain to me.
A short answer would be no (unless co-NP=NP).
Your decision problem, NO-VERTEX-COVER, is exactly the complement of the well-known VERTEX-COVER problem; the latter problem is NP-complete (and is, of course, in NP). Your problem NO-VERTEX-COVER is thus in co-NP. (Recall that a problem is in co-NP if and only if its complement is in NP.)
Because VERTEX-COVER, the complement of you problem, is NP-complete, it follows that unless co-NP=NP, the NO-VERTEX-COVER problem is not in NP. (This follows from a theorem that says that if co-NP is not equal to NP then no NP-complete problem is in co-NP.)

Why is TSP NP-hard while the Hamiltonian path NP-complete?

Why aren't these 2 problems, namely TSP and Hamiltonian path problem, both NP-complete?
They seem identical.
For a problem X to be NP-complete, it has to satisfy:
X is in NP, given a solution to X, the solution can be verified in polynomial time.
X is in NP-hard, that is, every NP problem is reduceable to it in polynomial time (you can do this through a reduction from a known NP-hard problem (e.g. Hamiltonian Path)).
There are two versions of the The Travelling Salesman Problem (TSP):
The optimization version (probably the one you are looking at), namely, find the optimum solution to the TSP. This is not a decision problem, and hence cannot be in NP, but it is however in NP-hard which can be proven via a Hamiltonian Path reduction. Therefore this isn't an NP complete problem.
The decision version - given an integer K is there a path through every vertex in the graph of length < K? This is a decision (yes/no) problem, and a solution can be verified in polynomial time (just traverse the path and see if it touches every vertex) and so it is in NP, but it is also in NP-hard (by an identical proof as above). Since it satisfies both requirements for NP-completeness, it is an NP-complete problem.
The definitions of NP-hardness and NP-completeness are related but different. Specifically, a problem is NP-hard if every problem in NP reduces to it in polynomial time, and a problem is NP-complete if it's both NP-hard and itself in NP.
The class NP consists of decision problems, problems that have a yes/no answer. As a result, TSP cannot be in NP because the expected answer is a number rather than yes or no. Therefore, TSP can be NP-hard, but it can't be NP-complete.
On the other hand, the Hamiltonian path problem asks for a yes/no answer, and it happens to be in NP. Therefore, since it's NP-hard as well, it's NP-complete.
Now, you can take TSP and convert it to a decision problem by changing the question from "what's the cheapest path?" to "is there a path that costs X or less?," and that latter formulation is in NP and also happens to be NP-complete.

Which of these languages is NP-complete?

I was searching the difference between NP and NP-complete problems. I came upon this great answer in StackOverflow by Jason. About NP-complete problems, he said
An NP problem X for which it is possible to reduce any other NP problem Y to X in polynomial time. Intuitively this means that we can solve Y quickly if we know how to solve X quickly. Precisely, Y is reducible to X if there is a polynomial time algorithm f to transform instances x of X to instances y = f(x) of Y in polynomial time with the property that the answer to x is yes if and only if the answer to f(x) is yes.
My question is: which one is the NP-complete problem, X or Y?
The NP-complete language is X. The idea is that you can start with an arbitrary NP language Y and, in polynomial time, reduce it to X.
Formally, the definition of NP-completeness is as follows: A language X is called NP-complete iff
X &in; NP. That is, X can't be "harder" than the "hardest NP problem," since X is itself a member of NP.
For any Y &in; NP, there is a polynomial-time mapping reduction from Y to X. That is, X is "at least as hard" as any problem in NP, since a polynomial-time algorithm for X gives a polynomial-time algorithm for Y. The fact that Y is polynomial-time reducible to X is sometimes denoted Y ≤p X, by the way.
That said, it is possible to reduce any NP-complete language to any other NP-complete language, so if Y polynomial-time reduces to X and X is NP-complete, it is possible (but not necessary) for Y to be NP-complete. However, it is known that if Y reduces in polynomial time to X, that Y has to be an element of NP.
Hope this helps!
Both or neither. This process is called Karp reduction and the point is that any NP-complete problem can be transformed into any other NP-complete problem in polynomial time.
NP-complete problems are only a subset of NP problems however. (As of our current understanding, they are the same thing if P=NP.)

How to prove that a problem is NP complete?

I have problem with scheduling. I need to prove that the problem is NP complete. What can be the methods to prove it NP complete?
To show a problem is NP complete, you need to:
Show it is in NP
In other words, given some information C, you can create a polynomial time algorithm V that will verify for every possible input X whether X is in your domain or not.
Example
Prove that the problem of vertex covers (that is, for some graph G, does it have a vertex cover set of size k such that every edge in G has at least one vertex in the cover set?) is in NP:
our input X is some graph G and some number k (this is from the problem definition)
Take our information C to be "any possible subset of vertices in graph G of size k"
Then we can write an algorithm V that, given G, k and C, will return whether that set of vertices is a vertex cover for G or not, in polynomial time.
Then for every graph G, if there exists some "possible subset of vertices in G of size k" which is a vertex cover, then G is in NP.
Note that we do not need to find C in polynomial time. If we could, the problem would be in `P.
Note that algorithm V should work for every G, for some C. For every input there should exist information that could help us verify whether the input is in the problem domain or not. That is, there should not be an input where the information doesn't exist.
Prove it is NP Hard
This involves getting a known NP-complete problem like SAT, the set of boolean expressions in the form:
(A or B or C) and (D or E or F) and ...
where the expression is satisfiable, that is there exists some setting for these booleans, which makes the expression true.
Then reduce the NP-complete problem to your problem in polynomial time.
That is, given some input X for SAT (or whatever NP-complete problem you are using), create some input Y for your problem, such that X is in SAT if and only if Y is in your problem. The function f : X -> Y must run in polynomial time.
In the example above, the input Y would be the graph G and the size of the vertex cover k.
For a full proof, you'd have to prove both:
that X is in SAT => Y in your problem
and Y in your problem => X in SAT.
marcog's answer has a link with several other NP-complete problems you could reduce to your problem.
Footnote: In step 2 (Prove it is NP-hard), reducing another NP-hard (not necessarily NP-complete) problem to the current problem will do, since NP-complete problems are a subset of NP-hard problems (that are also in NP).
You need to reduce an NP-Complete problem to the problem you have. If the reduction can be done in polynomial time then you have proven that your problem is NP-complete, if the problem is already in NP, because:
It is not easier than the NP-complete problem, since it can be reduced to it in polynomial time which makes the problem NP-Hard.
See the end of http://www.ics.uci.edu/~eppstein/161/960312.html for more.
In order to prove that a problem L is NP-complete, we need to do the following steps:
Prove your problem L belongs to NP (that is that given a solution you can verify it in polynomial time)
Select a known NP-complete problem L'
Describe an algorithm f that transforms L' into L
Prove that your algorithm is correct (formally: x ∈ L' if and only if f(x) ∈ L )
Prove that algo f runs in polynomial time
First, you show that it lies in NP at all.
Then you find another problem that you already know is NP complete and show how you polynomially reduce NP Hard problem to your problem.
Get familiar to a subset of NP Complete problems
Prove NP Hardness : Reduce an arbitrary instance of an NP complete problem to an instance of your problem. This is the biggest piece of a pie and where the familiarity with NP Complete problems pays. The reduction will be more or less difficult depending on the NP Complete problem you choose.
Prove that your problem is in NP : design an algorithm which can verify in polynomial time whether an instance is a solution.

Resources