NP vs P - difference between veryfing and answering

  • Thread starter xeon123
  • Start date
  • Tags
    Difference
In summary: However, once someone hands you an assignment and says "I think this makes the expression true", then you can verify that answer in polynomial time.In summary, the difference between answering and verifying a problem in polynomial time is that answering means finding a solution in polynomial time, while verifying means checking a given solution in polynomial time. Just because we can verify a yes-or-no problem in polynomial time does not necessarily mean we can answer it in polynomial time.
  • #1
xeon123
90
0
Hi,

1. A yes-or-no problem is in P (Poynomial time) if it the answer can be computed in polynomial time.
2- A yes-or-no problem is in NP (Non-deterministic Poynomial time) if a yes answer can be verified in polynomial time.

I don't understand here the difference between answering and verifying a problem in polynomial time. If we can verify that a yes-or-no problem is in NP in polynomial time, doesn't means that it can be answered?
 
Mathematics news on Phys.org
  • #2
verifying: if you have a solution to a problem (like: can you solve a particular version of TSP in less then k meters?), can you then in polynomial time in the input parameters (in this case the number of nodes and arcs in the TSP network) check if it is indeed a solution that is shorter than k? - yes, that's easy.

computing: if you have a problem can you actually FIND the solution in polynomial time? No one knows for the above specified problem, but odds are you can't.
 
  • #3
xeon123 said:
Hi,

1. A yes-or-no problem is in P (Poynomial time) if it the answer can be computed in polynomial time.
2- A yes-or-no problem is in NP (Non-deterministic Poynomial time) if a yes answer can be verified in polynomial time.

I don't understand here the difference between answering and verifying a problem in polynomial time. If we can verify that a yes-or-no problem is in NP in polynomial time, doesn't means that it can be answered?

It's like reading a thread on this forum. Someone asks a math question. You (or I) think about it but we can't see the solution. Some clever poster comes along and shows a perfectly clear solution. We read it line by line and we're convinced.

So we see that in practice, verifying a solution is far easier than being the first one to find a solution. That's the difference. If P = NP then finding a solution is no more difficult than verifying one. Seems unlikely to be true, but if you have a proof that P != NP you'll become famous.
 
  • #4
A good example is the following two problems:

1) Find a factor of 123109824098231
You probably will not be able to solve this in the total amount of time you are willing to consider the difference between P and NP so don't sweat it

2) verify that 392321 is a factor of 123109824098231
Sure it's a little bit of nasty long division but you should be able to solve this in about a minute

This is possibly the simplest and clearest example of the difference between verifying and answering. The prime factorization of this number is 392321 * 313798711, so the only way you are going to factor it is by attempting thousands of divisions for prime numbers (there may be slightly faster algorithms but this is essentially as good as it gets)

These problems are not actually in P or NP because they aren't decision problems but you can convert this type of thing into a decision problem by tweaking the question a bit: does 123109824098231 have a factor which is smaller than 400000? The only way you can answer this is to try all the factorizations like when you were asked to find a factor, but once I say "try the number 392321", it's easy to check that the answer is yes.

This is also a good example of where if the answer is no it can be hard to prove... consider how you would convince me that 123109824098231 has no factors smaller than 300000 (for example, how would you prove that 392321 is prime and has no smaller factors? This is a hard question again)
 
  • #5
xeon123 said:
I don't understand here the difference between answering and verifying a problem in polynomial time. If we can verify that a yes-or-no problem is in NP in polynomial time, doesn't means that it can be answered?
First off, the oracle isn't just saying "yes". The oracle is saying "yes, because X". For example, consider the question "is there a way to assign values to the variables in a given boolean expression to make the expression true?" This is the satisfiability problem. Suppose the oracle answers "yes, because the expression is true when A is true, B is false, C is false, ...". Verifying whether the oracle truly did find an answer is just plug-and-chug. Doing what the oracle did is anything but plug-and-chug.

Second off, it's not just a matter of whether the question can be answered, period. The assumption is that the question can be answered. The issue here is a matter of speed. There are algorithms that do solve the satisfiability problem. None of these algorithms does so in polynomial time. The satisfiability algorithms instead take exponential time to find a solution to a given boolean expression.
 

1. What is the difference between verifying and answering a problem in NP vs P?

In computer science, NP (nondeterministic polynomial time) and P (polynomial time) are complexity classes that refer to the amount of time it takes for a computer to solve a problem. Verifying a problem in NP means determining whether a given solution is correct in polynomial time, while answering a problem in P means finding a solution to the problem in polynomial time. In other words, verifying a problem in NP is a quicker process than answering a problem in P.

2. Why is the difference between NP and P important?

The difference between NP and P is important because it helps us understand the complexity of various problems and how difficult they are to solve. NP problems are generally considered much harder to solve than P problems, and this has implications for fields such as cryptography and optimization algorithms.

3. Can NP problems be solved in polynomial time?

No, NP problems cannot be solved in polynomial time. The term "NP" stands for "nondeterministic polynomial time", indicating that verifying a solution can be done in polynomial time but finding a solution cannot. However, there are some NP problems that have known polynomial-time solutions, such as the traveling salesman problem.

4. What does it mean for a problem to be NP-complete?

A problem is considered NP-complete if it is in the NP complexity class and every other problem in NP can be reduced to it in polynomial time. This means that if a polynomial-time solution can be found for an NP-complete problem, it can be applied to all other NP problems, making it one of the most difficult types of problems to solve.

5. Are there any real-world applications for NP problems?

Yes, there are real-world applications for NP problems, such as in cryptography and optimization algorithms. For example, the RSA encryption algorithm relies on the difficulty of factoring large numbers, which is an NP problem. Additionally, many real-world optimization problems, such as scheduling and resource allocation, can be modeled as NP problems.

Similar threads

Replies
52
Views
2K
  • General Math
Replies
1
Views
1K
  • Quantum Physics
Replies
4
Views
733
  • Programming and Computer Science
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Programming and Computer Science
Replies
10
Views
3K
  • General Math
Replies
5
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
0
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
948
Replies
4
Views
661
Back
Top