On the concept of P, NP and NPC

Source: Internet
Author: User
Tags value of pi

Just read "The beauty of mathematics", suddenly saw Bayesian network learning is NPC problem, and then in the brain recalled the difference between NP, NPC, and then read the wiki, others blog record as follows.

—————— Preface

The following is transferred from Msn-space


This may be one of the biggest pitfalls of many oier.
You will often see the online "How do you do this, this is not NP problem", "This only search, this has been proved to be NP problem" and so on. As you know, the NP problem that most people are talking about at this point actually refers to NPC. They did not understand the concept of NP problems and NPC problems. NP problem is not the kind of "only search" problem, NPC problem is. OK, okay, basically this misunderstanding has been clarified. The following is about what is P, what is NP, what is NPC, and if you are not very interested, you can not read it. Next you can see how big a mistake it is to think of NP as NPC.
Let's start with a few words to explain the complexity of the time. Time complexity does not mean how much time it takes for a program to solve a problem, but how quickly the program needs to grow when the scale of the problem expands. That is, for a computer with high-speed processing data, the efficiency of processing a particular data does not measure the quality of a program, but should be seen when the scale of the data is larger to hundreds of times times, whether the program runs the same time, or hundreds of times times slower, or tens of thousands of times times slower. No matter how big the data is, program processing time is always so many, we say that the program is very good, with O (1) time complexity, also known as the constant degree of complexity, the size of the data has become how much, the time has become how long, the program's time complexity is O (n), such as the number of N to find the maximum value , but like bubble sort, insert sort, data expands twice times, time slows 4 times times, belong to O (n^2) complexity. There are some algorithms for the exhaustive class, the time required to increase the length of the geometric order, which is O (a^n) exponential complexity, or even O (n!) The factorial level of complexity. There is no complexity of O (2*n^2) because the previous "2" is a factor that does not affect the entire program's time growth at all. In the same way, the complexity of O (n^3+n^2) is the complexity of O (n^3). Therefore, we would say that an O (0.01*n^3) program is less efficient than O (100*n^2), although the former is better than the latter when n is very small, but the latter time increases slowly with the scale of the data, and the complexity of O (n^3) will far exceed O (n^2). We also say that the complexity of O (n^100) is less than the complexity of O (1.01^n).
Easy to see, the complexity of the preceding categories is divided into two levels, the latter of which is far more complex than the former: O (1), O (log (n)), O (n^a), etc., we call it the complexity of the polynomial level, because its size n appears in the base position, the other is O (a^n) and O (n!) Type of complexity, it is non-polynomial level, its complexity of the computer is often unable to bear. When we solve a problem, the algorithm we choose usually needs to be polynomial-level complexity, non-polynomial-level complexity takes too much time, and often times out, unless the size of the data is very small.
Naturally, people will think of a problem: will all the problems can be found in the complexity of the polynomial-level algorithm? Unfortunately, the answer is no. Some problems are even impossible to find a correct algorithm, which is called"Non-solvable problem"(undecidable decision problem). The halting problem is a well-known non-solvable problem and has been specifically introduced and proven in my MSN space. For example, the output from 1 to N of the full array of n number. No matter what method you use, your complexity is factorial, because you have to use factorial time to print out the results. Some people say that such a "problem" is not a "normal" problem, the formal problem is to let the program solve a problem, output a "YES" or "NO" (this is called a decision-making problem), or what is the optimal value (this is called the optimization problem). So, according to this definition, I can also cite a problem that is unlikely to have a polynomial-level algorithm: Hamilton Loop. The question is this: give you a diagram asking if you can find a path that passes through each vertex once and then once (no omission or repetition) and finally comes back (the route that satisfies this condition is called the Hamilton Loop). This problem has not yet found a polynomial-level algorithm. In fact, this question is the NPC question we are going to talk about later.
The following introduces the concept of P-class issues:If a problem can be found in a polynomial time to solve its algorithm, then this problem belongs to the P problem. P is the first letter of the English word polynomial. What questions are P-type problems? Usually Noi and Noip do not issue topics that do not belong to the P class. Some of the information we often see is the question of P. The simple truth is that a non-polynomial-level time-out program with a poor lift does not cover any valuable algorithms.
Then the concept of NP problem is introduced. This is a bit difficult to understand, or easy to understand mistakes. To emphasize here (back to the misunderstanding I tried to clarify),NP problem is not a non-P class problem. NP problem refers to the problem of validating a solution in polynomial time. Another definition of NP problem is that you can guess the problem of a solution in polynomial time. Let's say that my RP is good, and I can guess when I need an enumeration in my program. Now someone has a problem asking for the shortest path, whether there is a route less than 100 units in length from the start to the end. It is based on the data to draw a good picture, but how can not be counted out, so asked me: You see how to choose the least way to go? I said, I rp very good, certainly can give you casually point a very short way out. Then I just scribble a few lines and say this one. The man added up the weights as I pointed out, hey, God, the path length is 98, smaller than 100. So the answer comes out, there is a path smaller than 100. People will ask him how to do this, he can say, because I found a smaller than 100 solution. In this problem, finding a solution is difficult, but validating a solution is easy. Verify that a solution requires only O (n) time complexity, that is, I can spend O (n) time to add up the length of the path I guess. So, as long as my RP good, guess, I will be able to solve this problem in polynomial time. I guess the solution is always the best, not to meet the test instructions plan will not come to deceive me to choose it. This is the NP problem. Of course there is not the problem of NP, that you guessed to understand but useless, because you can not in polynomial time to verify it. The example I want to cite below is a classic example of a problem that has not yet been able to validate a solution in polynomial time. It is clear that the Hamilton Circuit mentioned earlier is NP-hard because it is very easy to verify that a path is passing through each vertex exactly. But I'm going to replace the question with this: Is there no Hamilton circuit in a diagram? This problem cannot be verified in polynomial time, because unless you have tried all the way, you dare not conclude that it "has no Hamilton circuit".
The NP problem is defined because it is usually only NP problems that can find the polynomial algorithm. We do not expect a polynomial-level algorithm to solve a problem in which a solution is not available. It is believed that readers soon understand that the most difficult problem in informatics"NP problem" is actually discussing the relationship between NP problem and P-type problem.。
Obviously, all P-class problems are NP-related. In other words, to solve a problem in polynomial way, it is necessary to validate the solution of a problem by polynomial-Since the positive solution is all out, verify that any given solution is only needed to compare it. The point is that people want to know if all NP problems are P-type. We can use the view of the collection again to illustrate. If all P-class problems are classified as a set P, and all NP problems are classified into another set NP, then it is obvious that p belongs to NP. Now, all the research on NP is focused on one question: Is there a P=NP? Usually the so-called "NP problem" is actually a word: proving or overthrowing P=NP.
NP problem has always been the pinnacle of information science. The peak, meaning is very compelling but difficult to solve. In the study of information science, this is an ultimate problem that takes a lot of time and energy and is not solved, like the great unification in physics and the Goldbach conjecture in mathematics.
So far the problem has been "gnawing". However, a general trend, a broad direction is there. It is generally believed that P=NP is not tenable, that is to say, most people believe that there is at least one NP problem with an algorithm that cannot have polynomial-level complexity. People are so convinced that there is a reason for P≠NP, that is, in the process of studying NP problem, we find a kind of very special NP problem called np-complete problem, also called NPC problem. C is the first letter of the English word "complete". It is the presence of NPC that makes people believe in P≠NP. The following will take a lot of time to introduce NPC issues, and you can see how the NPC problem makes P=NP so incredible.
To illustrate NPC issues, we first introduce a concept--the reducibility, which is called "attribution" in some of the data.
To put it simply,a problem A can be reduced to the meaning of question B is that it can be solved by problem B's solution a, or, problem a can "become" question B. An example of this is given in the introduction to algorithms. For example, there are two problems: solving a unary-once equation and solving a unary two-second equation. Then we say that the former can be reduced to the latter, meaning to know how to solve a one-yuan two-time equation then it is possible to solve the unary-once equation. We can write two programs corresponding to two questions, then we can find a "rule", according to this rule to solve the one-dimensional equation of the input data of the program, used in the solution of a two-time equation of the program, two programs always get the same results. The rule is that the corresponding coefficients of the two equations are constant, and the two-time term coefficients of the two-order equation are 0. By following this rule the previous question is converted to the latter one, and the two questions are equivalent. Similarly, we can say that Hamilton circuit can be reduced to TSP (travelling salesman problem, travel salesman problem): In Hamilton Circuit problem, two point is connected to the two point distance is 0, two point is not directly connected to the distance of 1, The problem then turns into whether there is a 0-length path in the TSP problem. Hamilton Circuit exists when and only if there is a 0-length loop in the TSP problem.
"problem A can be reduced to question B" has an important visual meaning: B's time complexity is higher or equal to the time complexity of a. In other words, problem A is not more difficult than problem B. It's easy to understand. Since problem a can be solved with problem B, if the time complexity of B is lower than the time complexity of a, then A's algorithm can be improved to B's algorithm, the time complexity is the same. Just as solving a two-time equation is harder than solving a unary one, because the method of solving the former can be used to solve the latter.
It is clear that the Covenant has an important nature:The reduction of the transitive。 If problem a can be reduced to question B, question B can be reduced to question C, then problem a must be reduced to question C. This is a very simple truth and it is not necessary to elaborate.
Now again, the standard concept of the Covenant is not difficult to understand: if you can find such a law of change, the input of any program a can be converted to the input of program B according to this law, so that the output of the two programs is the same, then we say that problem a can be reduced to problem B.
Of course, what we call "Polynomial-time" refers to "polynomial" (reducible), that is, the method of transforming input can be done in polynomial time. The process of the reduction is meaningful only when it is done in polynomial time.
Well, from the definition of the Covenant we see that one problem is reduced to another, the complexity of time increases, and the scope of application of the problem increases. Through constant reduction of some problems, we are able to search for algorithms that are more complex, but have a wider range of applications, instead of low complexity, but only for a small class of problems. Recalling the aforementioned P and NP problems, associating with the transfer of the Covenant, naturally, we would like to ask, if constantly to go up, and constantly find to "take all" a number of small NP problems of a slightly more complex NP problem, then finally whether it is possible to find a time of the highest complexity, and can be "all-in-one" All the NP problems of such a super NP problem? The answer is sure.In other words, there is such a NP problem that all NP problems can be reduced to it. In other words, as long as the problem is solved, all NP problems are solved. The existence of this problem is incredibly, and even more incredible,This problem is more than one, it has many, it is a kind of problem. This kind of question is the legendary NPC question, namely np-complete question. The emergence of NPC problem has made the research of NP problem get a leap-forward development. We have reason to believe that NPC is the most complex problem. Back to the beginning of the full text, we can see that people want to express a problem without a polynomial efficient algorithm should say that it "belongs to NPC problem." At this point, my goal has finally reached, I have the NP problem and NPC issues have been differentiated. So far, this article has written nearly 5000 words, I admire you can still see here, at the same time also admire oneself can write here.
the definition of NPC question is very simple. The problem of meeting the following two conditions is NPC. First, it has to be a NP problem, and then all NP problems can be reduced to it. Proving that one problem is NPC is also very simple. Proving that it is at least a NP problem and proving that one of the known NPC problems can be reduced to it (by the transitive nature of the Covenant, the second of the NPC's problem definitions is also met; As for the first NPC question, which follows), it can be said that it is a NPC problem.
Since all NP problems can be reduced to NPC problem, so long as any one NPC problem found a polynomial algorithm, then all the NP problem can be solved with this algorithm, NP is equal to P. So it's amazing to find a polynomial algorithm for NPC. Therefore, former Wencai said, "It is the NPC problem that makes people believe in P≠NP." We can do thisintuitive to understand that NPC problems currently do not have a polynomial effective algorithm, can only use the number of points or even factorial level of complexity of the search。

By the way, np-hard problem.Np-hard problem is a problem, it satisfies the NPC question definition of the second article but not necessarily to meet the first (that is, the np-hard problem is wider than the NPC problem). The Np-hard problem is also difficult to find the polynomial algorithm, but it does not include in our research scope, because it is not necessarily NP problem. Even if the NPC problem finds a polynomial-level algorithm, the Np-hard problem may still not get the polynomial-level algorithm. In factbecause Np-hard relaxes the constraints, it is likely to be more difficult to solve than the time complexity of all NPC problems.
Don't think NPC questions are a piece of paper. NPC problem is there. It is true that a very specific problem belongs to NPC. It will be introduced later.
The following is an introduction to the logic circuit problem. This is the first NPC question. The question of other NPCs is the problem. Therefore, the problem of logic circuit is the "originator" of NPC class problem.
A logic circuit problem is a problem: given a logic circuit, ask if there is an input to make the output true.
What is a logic circuit? A logic circuit consists of several inputs, an output, several "logic gates" and a dense line. Take a look at the following example, and you'll understand without explaining it.
┌───┐
│ Input 1├─→┐┌──┐
└───┘└─→┤│
│or├→─┐
┌───┐┌─→┤││┌──┐
│ Input 2├─→┤└──┘└─→┤│
└───┘│┌─→┤and├──→ output
└────────┘┌→┤│
┌───┐┌──┐│└──┘
│ Input 3├─→┤not├─→────-┘
└───┘└──┘
This is a simpler logic circuit, when input 1, input 2, input 3 is True, True, False or False, True, FALSE, the output is true.
Is there a logic circuit in which output cannot be true anyway? Yes. Here is a simple example.
┌───┐
│ Input 1├→─┐┌──┐
└───┘└─→┤│
│and├─→┐
┌─→┤││
│└──┘│┌──┐
│└→┤│
┌───┐││and├─→ output
│ Input 2├→─┤┌──┐┌→┤│
└───┘└→┤not├→──┘└──┘
└──┘
In the above logic circuit, the output is false regardless of the input. We say that this logic circuit does not exist a set of inputs that make the output true.
Back to the above, given a logic circuit, ask if there is an input to make the output true, which is the logic circuit problem.
Logic circuit problem belongs to NPC problem. There is a strict proof of this. It obviously belongs to the NP problem, and can directly prove that all NP problems can be reduced to it (do not think that the NP problem has an infinite number of problems will prove insurmountable difficulties). Proving that the process is quite complex, it probably means that the input and output of any NP problem can be converted into the input and output of the logic circuit (think of the internal computer is just some 0 and 1 operations), so for a NP problem, The problem is converted in order to find an input that satisfies the result as true (that is, a workable solution).
With the first NPC problem, a whole bunch of NPC questions came up, because proving a new NPC problem only requires a known NPC problem to be reduced to it. Later, Hamilton Loop became NPC problem, TSP problem also became NPC problem. It is now proved that there are many problems with NPC, and any NP problem can be solved perfectly if any one finds a polynomial algorithm. So it is because of the NPC problem that P=NP becomes unbelievable. There are a lot of interesting things to P=NP and we need to dig further. Climbing the pinnacle of this information science is the ultimate goal of our generation. What we need to do now, at least, is not to confuse the concept.--------------------------------------------------------------------------1. Problems with solutions but no algorithms:
For example Pi Pi after the decimal point whether there is a continuous 1 million 0. Because PI is an objective real number, the value of pi is determined, so the solution of this problem is also present. Either Yes or no, although we do not know what he is, but he is objective, not change with time, not with people's understanding and change. But there is no algorithm to calculate the answer to this question. Of course, you can use a benzene method to solve the problem, is to constantly calculate the value of the PI after the decimal point, if found that there are 1 million consecutive 0, then the answer to this question is yes, but if not found, we must continue to calculate, and can never stop ~ ~, So the benzene method is not called the algorithm at all, because he does not satisfy the condition that the algorithm terminates within a finite step. So the problem is that there is no algorithm (at least for the time being, it may be possible to find some method in number theory later on whether there is a continuous K 0 after the decimal point, or the distribution of the value after the decimal point of the Pi from the perspective of probability, etc.).

2. No solution and no algorithm problem:
For example, given any proposition, is there an algorithm to judge whether the proposition is true or false? This is the famous Turing stop problem. If there is this algorithm, then we just find this algorithm can once and for all, and no matter what the new proposition, can be used to verify the algorithm, immediately know that the proposition is really false, so that we have mastered the ultimate truth of the whole universe:). But Turing has proved that such an algorithm does not exist, and this problem is not solved. (The main use of the Cantor diagonal deletion method is to prove that the real and natural numbers unequal potential of the kind of diagonal deletion method)

3. Computable and non-computable:
According to the Turing-Church thesis:
1. The computable problem is the problem that can be calculated by the Turing, (Turing's definition)
2. The computable problem is the problem that can be calculated using the Lamda calculus system (Church definition)

Figure Lingqiu Odd proposition is not so much a theorem as the definition of an algorithm. Because the algorithm itself is an imprecise concept, in the end what is the algorithm, there has been no definite definition. The Turing-Church thesis gives the formal definition of the algorithm mathematically.

Turing said: "All Turing's computational problems are algorithmic (that is, computable), and all problems with algorithms can be calculated using Turing." The thesis itself is impossible to prove, it is like the law of the speed of light in physics, is a natural law, can not be logically proved, can only be tested by experiments. At present, the Turing proposition is also the same as the speed of light, through the test of history and time, now even if the development of quantum computers, or not to get rid of the Turing machine constraints, quantum computers can calculate the problem is common Turing machines can calculate the problem, but the computational efficiency is different.

The two examples of non-computational problems have been said before, one isExamples of pi, the other isTuring stop problem。

4. Provable and non-provable
In a kilometer system, there are several kilometers, some derivation rules, in the system to prove the theorem, is from the axiom, the use of these rules to derive a new theorem. If we can finally get the proposition we need to prove, then the proposition is true; if we finally get a proposition that contradicts the proposition we need to prove, then we have to prove that the proposition is false.

If all the theorems in the system are regarded as nodes in the graph, if the I1,i2 from the theorem,.. Ik derives theorem J According to the rules of the system, then joins a i1,i2 to J from the,... ik. So the whole axiom system is constructed into a graph. The proving process of theorem is in fact a "proof tree" which reaches the node of the target proposition in the axiom system from the point of the axiom representation. Thus the proof of the theorem is similar to the path in graph theory (BTW, which is the basic principle of theorem automation proof).

The Super genius Goethe-Institut, at the age of 25, presented the famous Goethe's incompleteness theorem. The theorem states: In any axiomatic system, there is a contradiction, the system is incomplete.
The so-called contradiction is that it can prove that proposition A is set up, it can also prove that proposition A's proposition is set up, which is contradictory.
The so-called incompleteness, refers to the existence of some propositions in the system, can not prove that it is set up, can not prove that it does not. It is as if there are some outliers in a diagram that are never accessible from the basic Axiom node.

In the process of proving "incompleteness theorem", Goethe constructs a theorem which can not be proved to be true pseudo. To be more troublesome, I have simplified it to the following simple form according to my own understanding:

Proposition A = "proposition A is not tenable"

Now ask if Proposition A is set up. If proposition A is established, the proposition A should not be established according to the content of proposition A, and if proposition A is not established, then proposition A should be set up according to the content of Proposition A.

This example is not rigorous, because it actually confuses the grammatical and semantic levels. But I think this example can be a simplified version of the Goethe example. Goethe's example is much more rigorous and complex than this, but in essence it is similar and takes advantage of the paradox of logic.

Russell and other people advocated the solution of this paradox is to give predicate logic hierarchical, resulting in the first order predicate logic, second-level predicate logic and so on. Like the example above,Russell believes that the content of proposition A describes the nature of proposition a itself, which is beyond the scope that proposition a can express, and argues that such a is not a legitimate proposition.

On the concept of P, NP and NPC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.