What is np hard np complete




















You can easily verify that on a sheet of paper while without the witness given, proving that is not prime would be difficult without using a computer. We didn't say anything about how an appropriate witness can be found. This is the non-deterministic part. The Turing machine cannot possibly look at more symbols of the witness. NP is a superset of P why? It is not known whether there exist languages that are in NP but not in P. Integer factorization is not a language per se.

However, we can construct a language that represents the decision problem associated with it. If you have an algorithm to decide FACTOR, it can be used to compute a full factorization with only polynomial overhead by performing a recursive binary search for each prime factor. All of this can be done in polynomial time. Remember, again, that it is the length of the encoding that counts and that is logarithmic in n.

And you have broken a significant portion of today's cryptography. For every language in NP , there is a brute-force algorithm that decides it deterministically. It simply performs an exhaustive search over all witnesses. Note that the maximum length of a witness is bounded by a polynomial. To address your final question, we need to introduce reduction. Reductions are a very powerful concept of theoretical computer science. Reducing one problem to another basically means solving one problem by means of solving another problem.

For example, let A be the language that contains all graphs encoded as adjacency matrix that contain a triangle. A triangle is a cycle of length 3. Let further B be the language that contains all matrices with non-zero trace. The trace of a matrix is the sum of its main diagonal elements. Then A is polynomial-time many-one reducible to B. To prove this, we need to find an appropriate transformation function f.

In this case, we can set f to compute the 3 rd power of the adjacency matrix. This requires two matrix-matrix products, each of which has polynomial complexity. It contains all boolean formulas that can be satisfied.

How would you prove that? Once that one NP -complete language was known, it was relatively simple to show the NP -completeness of other languages via reduction.

This is the only paper in this answer that I actually recommend you should read. Unlike the others, it is not hard to understand and gives a very good idea of how proving NP -completeness via reduction works. Finally, a short summary. To see this, make yourself clear that no non-trivial language can be reduced to a trivial one and there are trivial languages in P as well as non-trivial languages in NP. This is a not very interesting corner-case, though.

This is an important distinction because it means that the asymptotic complexity of an algorithm depends on the encoding used for the input. This week, a new record for the largest known Mersenne prime was achieved. It can be encoded in different ways. All these strings encode the same number and given any of these, we can easily construct any other encoding of the same number.

You can replace decimal encoding with binary, octal or hexadecimal if you want to. It only changes the length by a constant factor. The naive algorithm for testing primality is only polynomial for unary encodings. The Lucas-Lehmer primality test is the best known algorithm for Mersenne primes M p with p an odd prime but it is still exponential in the length of the binary encoding of the Mersenne exponent p polynomial in p.

If we want to talk about the complexity of an algorithm, it is very important that we are very clear what representation we use. In general, one can assume that the most efficient encoding is used. That is, binary for integers. Note that not every prime number is a Mersenne prime so using the Mersenne exponent is not a general encoding scheme. In theoretical cryptography, many algorithms are formally passed a completely useless string of k 1 s as the first parameter.

The algorithm never looks at this parameter but it allows it to formally be polynomial in k , which is the security parameter used to tune the security of the procedure. For some problems for which the decision language in binary encoding is NP -complete, the decision language is no longer NP -complete if the encoding of embedded numbers is switched to unary.

The decision languages for other problems remain NP -complete even then. The latter are called strongly NP -complete. The best known example is bin packing. It is also and perhaps more interesting to see how the complexity of an algorithm changes if the input is compressed. For the example of Mersenne primes, we have seen three encodings, each of which is logarithmically more compressed than its predecessor.

In , Hana Galperin and Avi Wigderson have written an interesting paper about the complexity of common graph algorithms when the input encoding of the graph is compressed logarithmically. For these inputs, the language of graphs containing a triangle from above where it was clearly in P suddenly becomes NP -complete.

And that's because language classes like P and NP are defined for languages , not for problems. P problems : problems that can be solved in polynomial time. Contains problems which can be efficiently solvable. NP problem : problems that can be verified in polynomial time. For example:Travelling salesman, circuit designing.

NP problems are kind of like puzzles like sudoku. Given a correct solution for the problem we can check our solution very fast but if we actually try to solve it it might just take forever. Now, P vs NP actually asks if a problem whose solution can be quickly checked to be correct, then is there always a fast way to solve it. Thus writing in mathematically terms: is NP a subset of P or not? Now coming back to NP complete: these are the really hard problems of the NP problems.

NP hard: problems that can't be even checked in the polynomial time are np hard. For example, choosing the best move in chess is one of them. Sign up to join this community.

The challenge of the problem is that the traveling salesman wants to minimize the total length of the trip. In TSP, we find a tour and check that the tour contains each vertex once. Then the total cost of the edges of the tour is calculated. Finally, we check if the cost is minimum. This can be completed in polynomial time. Hence, an instance of TSP is constructed. Now, suppose that a Hamiltonian cycle h exists in G. It is clear that the cost of each edge in h is 0 in G ' as each edge belongs to E.

Therefore, h has a cost of 0 in G '. Thus, if graph G has a Hamiltonian cycle, then graph G ' has a tour of 0 cost. This means that if someone gives us an instance of the problem and a certificate sometimes called a witness to the answer being yes, we can check that it is correct in polynomial time. Integer factorisation is in NP.

This is a decision problem because the answers are yes or no. Intuitively this means that we can solve Y quickly if we know how to solve X quickly. This is the problem wherein we are given a conjunction ANDs of 3-clause disjunctions ORs , statements of the form. The proof of this is technical and requires use of the technical definition of NP based on non-deterministic Turing machines. This is known as Cook's theorem. What makes NP-complete problems important is that if a deterministic polynomial time algorithm can be found to solve one of them, every NP problem is solvable in polynomial time one problem to rule them all.

Intuitively, these are the problems that are at least as hard as the NP-complete problems. Note that NP-hard problems do not have to be in NP , and they do not have to be decision problems. But since any NP-complete problem can be reduced to any other NP-complete problem in polynomial time, all NP-complete problems can be reduced to any NP-hard problem in polynomial time.

Then, if there is a solution to one NP-hard problem in polynomial time, there is a solution to all NP problems in polynomial time. The halting problem is an NP-hard problem. This is the problem that given a program P and input I , will it halt? This is a decision problem but it is not in NP. It is clear that any NP-complete problem can be reduced to this one.

As another example, any NP-complete problem is NP-hard. My favorite NP-complete problem is the Minesweeper problem. This one is the most famous problem in computer science, and one of the most important outstanding questions in the mathematical sciences. In fact, the Clay Institute is offering one million dollars for a solution to the problem Stephen Cook's writeup on the Clay website is quite good.

It's clear that P is a subset of NP. The open question is whether or not NP problems have deterministic polynomial time solutions. It is largely believed that they do not. The best book on the subject is Computers and Intractability by Garey and Johnson. I've been looking around and seeing many long explanations.

Here is a small chart that may be useful to summarise:. I also found this diagram quite useful in seeing how all these types correspond to each other pay more attention to the left half of the diagram. P Polynomial Time : As name itself suggests, these are the problems which can be solved in polynomial time. NP Non-deterministic-polynomial Time : These are the decision problems which can be verified in polynomial time.

That means, if I claim that there is a polynomial time solution for a particular problem, you ask me to prove it. Then, I will give you a proof which you can easily verify in polynomial time. These kind of problems are called NP problems. Note that, here we are not talking about whether there is a polynomial time solution for this problem or not.

But we are talking about verifying the solution to a given problem in polynomial time. If we can solve these problems in polynomial time, we can solve any NP problem that can possibly exist. Note that these problems are not necessarily NP problems.

That means, if we can solve these problems, we can solve any other NP problem and the solutions to these problems can be verified in polynomial time.

Can be written as the product of two other numbers bigger than 1? These are examples of questions that share a common trait. It may not be obvious how to efficiently determine the answer, but if the answer is 'yes', then there's a short and quick to check proof. In the first case a non-trivial factorization of 51; in the second, a route for walking the bridges fitting the constraints. A decision problem is a collection of questions with yes or no answers that vary only in one parameter.

Now, some decision problems lend themselves to efficient, if not obvious algorithms. On the other hand, for many decision problems, it's not obvious how to get the answer -- but if you know some additional piece of information, it's obvious how to go about proving you've got the answer right.

But if, for example, somebody told you that 61 is a divisor of , simple long division is a efficient way to see that they're correct. The complexity class NP is the class of decision problems where the 'yes' answers have short to state, quick to check proofs.

One important point is that this definition doesn't say anything about how hard the problem is. If you have a correct, efficient way to solve a decision problem, just writing down the steps in the solution is proof enough.

Algorithms research continues, and new clever algorithms are created all the time. A problem you might not know how to solve efficiently today may turn out to have an efficient if not obvious solution tomorrow. With all these advances, one really has to wonder: Is this bit about having short proofs just an illusion? Maybe every decision problem that lends itself to efficient proofs has an efficient solution? Nobody knows. Perhaps the biggest contribution to this field came with the discovery a peculiar class of NP problems.

By playing around with circuit models for computation, Stephen Cook found a decision problem of the NP variety that was provably as hard or harder than every other NP problem. An efficient solution for the boolean satisfiability problem could be used to create an efficient solution to any other problem in NP.

Soon after, Richard Karp showed that a number of other decision problems could serve the same purpose. These problems, in a sense the "hardest" problems in NP, became known as NP-complete problems. Of course, NP is only a class of decision problems. Many problems aren't naturally stated in this manner: "find the factors of N", "find the shortest path in the graph G that visits every vertex", "give a set of variable assignments that makes the following boolean expression true".

Though one may informally talk about some such problems being "in NP", technically that doesn't make much sense -- they're not decision problems.

Some of these problems might even have the same sort of power as an NP-complete problem: an efficient solution to these non-decision problems would lead directly to an efficient solution to any NP problem.

A problem like this is called NP-hard. The easiest way to explain P v. NP and such without getting into technicalities is to compare "word problems" with "multiple choice problems".

When you are trying to solve a "word problem" you have to find the solution from scratch.



0コメント

  • 1000 / 1000