Difference between revisions of "P versus NP"
Scrabbler94 (talk | contribs) m (→Overview) |
Scrabbler94 (talk | contribs) m (→Examples of P, NP, NP-complete problems: run time of brute-force subset sum) |
||
Line 43: | Line 43: | ||
*Given two positive integers <math>m</math> and <math>n</math> and a positive integer <math>d</math>, is it true that <math>d = \gcd(m,n)</math>? | *Given two positive integers <math>m</math> and <math>n</math> and a positive integer <math>d</math>, is it true that <math>d = \gcd(m,n)</math>? | ||
− | A classic example of a problem that is <math>NP</math>-complete but not known to be in <math>P</math> is the ''subset sum problem'': Given a list <math>S</math> of integers and a number <math>t</math>, all encoded in some base <math>b > 1</math>, is there some subset of numbers in <math>S</math> whose sum is <math>t</math>? For example, is there a subset of <math>\{-4,2,3,10,-8,7\}</math> whose sum is 14? The answer is ''yes,'' and it can be checked in polynomial time that the answer is ''yes'' (by giving the certificate <math>\{2,3,10,-8,7\}</math>, but this is a difficult problem to solve in general, and it is not known if subset sum is in <math>P</math>. | + | A classic example of a problem that is <math>NP</math>-complete but not known to be in <math>P</math> is the ''subset sum problem'': Given a list <math>S</math> of <math>n</math> integers and a number <math>t</math>, all encoded in some base <math>b > 1</math>, is there some subset of numbers in <math>S</math> whose sum is <math>t</math>? For example, is there a subset of <math>\{-4,2,3,10,-8,7\}</math> whose sum is 14? The answer is ''yes,'' and it can be checked in polynomial time that the answer is ''yes'' (by giving the certificate <math>\{2,3,10,-8,7\}</math>, but this is a difficult problem to solve in general as a brute force solution requires <math>O(2^n n)</math> computations, and it is not known if subset sum is in <math>P</math>. |
The following examples are NP-complete problems: | The following examples are NP-complete problems: |
Revision as of 14:11, 25 October 2017
versus is one of the greatest computability and complexity problems of modern mathematics, and one of the Millennium Problems. the class of decision problems (those whose answer is either "yes" or "no," as opposed to other classes such as counting problems) that can be solved by a deterministic algorithm in polynomial time. is the class of decision problems that can be solved by a non-deterministic algorithm in polynomial time. The versus question asks whether these two classes are the same, or whether there are problems in that are not in .
Since all modern computers (with the exception of a few quantum computers) are deterministic, non-deterministic algorithms are of theoretical, rather than practical, interest. However, the class can also be defined without reference to nondeterminism: This article is a stub. Help us out by expanding it.
Contents
[hide]Overview
The relation between the complexity classes and is one of the most important open problems in theoretical computer science and mathematics. The most common measurements are time (how many steps it takes to solve a problem as a function of input, usually expressed with big-O notation) and space (how much memory it takes to solve a problem). In such analysis, a model of the computer for which time must be analyzed is required. Typically, such models assume that the computer is deterministic - that, given the computer's present state and any inputs, there is only one possible action that the computer might take - and sequential - it performs actions one after the other, such as a deterministic Turing machine. These assumptions reflect the behaviour of all practical computers yet devised, even including machines featuring parallel processing.
A decision problem is a problem that admits a yes or no answer (as opposed to an optimization problem, such as "What is the length of the longest path from to ?"). More formally, a decision problem may be thought of as a language for which we wish to decide if a given word belongs to the language.
We say that an algorithm decides a language if, for all inputs , either accepts or rejects .
The class P
The class consists of all those decision problems (languages) that can be decided using a deterministic Turing machine in an amount of time that is polynomial in the size of the input. More formally, where is the set of languages decidable by an -time deterministic Turing machine.
The class NP
The class (for non-deterministic polynomial time) consists of all those decision problems that are decidable using a non-deterministic Turing machine. It is equivalent to the set of decision problems for which whose yes instances are efficiently verifiable in polynomial time using a certificate. Examples of problems in and are given below.
Importance
Arguably, the biggest open question in theoretical computer science concerns the relationship between those two classes:
Is equal to ?
In a 2002 poll of 100 researchers, 61 believed the answer is no, 9 believed the answer is yes, 22 were unsure, and 8 believed the question may be independent of the currently accepted axioms, and so impossible to prove or disprove.
The Clay Mathematics Institute has offered a USD $1,000,000 prize for a correct solution, as it has listed it as one of its Millenium Problems.
Arguments
It is easy to show that , as if we are given any , a polynomial-time verifier for , given input and a certificate , can simply ignore the certificate and decide if .
An important role in this discussion is played by the set of -complete problems (or ) which can be loosely described as the hardest problems in . More precisely, a language is NP-complete if both are true:
- Any language in NP has a polynomial-time reduction to (NP-hardness).
The main idea behind a polynomial-time reduction is this: If we knew how to decide in polynomial time, then any problem in can be converted into an instance of in polynomial time, and then we can use the algorithm that decides as a subroutine.
Examples of P, NP, NP-complete problems
The following problems are examples of problems in (i.e. ones we can answer in polynomial time as a function of input):
- Given a list of integers, is it sorted in non-decreasing order?
- Given a weighted, undirected graph and two vertices , does there exist a path from to of weight at most ?
- Given two positive integers and and a positive integer , is it true that ?
A classic example of a problem that is -complete but not known to be in is the subset sum problem: Given a list of integers and a number , all encoded in some base , is there some subset of numbers in whose sum is ? For example, is there a subset of whose sum is 14? The answer is yes, and it can be checked in polynomial time that the answer is yes (by giving the certificate , but this is a difficult problem to solve in general as a brute force solution requires computations, and it is not known if subset sum is in .
The following examples are NP-complete problems:
- SAT, 3-SAT (Boolean satisfiability)
- Subset sum
- Vertex cover
- Maximum clique in a graph
- Set cover
- Traveling salesman problem
The restriction to problems doesn't really make a difference; even if we allow more complicated answers, the resulting problem (whether ) is equivalent.