Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

NP (complexity)

From Wikipedia, the free encyclopedia
Complexity class used to classify decision problems
This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(October 2015) (Learn how and when to remove this message)
Unsolved problem in computer science
P =? NP{\displaystyle {\mathsf {P\ {\overset {?}{=}}\ NP}}}
More unsolved problems in computer science
Euler diagram forP, NP,NP-complete, andNP-hard set of problems. Under the assumption that P ≠ NP, the existence of problems within NP but outside bothP and NP-complete wasestablished by Ladner.[1]

Incomputational complexity theory,NP (nondeterministic polynomial time) is acomplexity class used to classifydecision problems. NP is theset of decision problems for which theproblem instances, where the answer is "yes", haveproofs verifiable inpolynomial time by adeterministic Turing machine, or alternatively the set of problems that can be solved in polynomial time by anondeterministic Turing machine.[2][Note 1]

The first definition is the basis for the abbreviation NP; "nondeterministic, polynomial time". These two definitions are equivalent because the algorithm based on the Turing machine consists of two phases, the first of which consists of a guess about the solution, which is generated in a nondeterministic way, while the second phase consists of a deterministic algorithm that verifies whether the guess is a solution to the problem.[3]

The complexity classP (all problems solvable, deterministically, in polynomial time) is contained in NP (problems where solutions can be verified in polynomial time), because if a problem is solvable in polynomial time, then a solution is also verifiable in polynomial time by simply solving the problem. It is widely believed, but not proven, thatP is smaller than NP, in other words, that decision problems exist that cannot be solved in polynomial time even though their solutions can be checked in polynomial time. The hardest problems in NP are calledNP-complete problems. An algorithm solving such a problem in polynomial time is also able to solve any other NP problem in polynomial time. If P were in fact equal to NP, then a polynomial-time algorithm would exist for solving NP-complete, and by corollary, all NP problems.[4]

The complexity class NP is related to the complexity classco-NP, for which the answer "no" can be verified in polynomial time. Whether or notNP = co-NP is another outstanding question in complexity theory.[5]

Formal definition

[edit]

The complexity class NP can be defined in terms ofNTIME as follows:

NP=kNNTIME(nk),{\displaystyle {\mathsf {NP}}=\bigcup _{k\in \mathbb {N} }{\mathsf {NTIME}}(n^{k}),}

whereNTIME(nk){\displaystyle {\mathsf {NTIME}}(n^{k})} is the set of decision problems that can be solved by anondeterministic Turing machine inO(nk){\displaystyle O(n^{k})} time.

Equivalently, NP can be defined using deterministic Turing machines as verifiers. AlanguageL is in NP if and only if there exist polynomialsp andq, and a deterministic Turing machineM, such that

Background

[edit]

Manycomputer science problems are contained in NP, like decision versions of manysearch and optimization problems.

Verifier-based definition

[edit]

In order to explain the verifier-based definition of NP, consider thesubset sum problem:Assume that we are given someintegers, {−7, −3, −2, 5, 8}, and we wish to know whether some of these integers sum up to zero. Here the answer is "yes", since the integers {−3, −2, 5} corresponds to the sum(−3) + (−2) + 5 = 0.

To answer whether some of the integers add to zero we can create an algorithm that obtains all the possible subsets. As the number of integers that we feed into the algorithm becomes larger, both the number of subsets and the computation time grows exponentially.

But notice that if we are given a particular subset, we canefficiently verify whether the subset sum is zero, by summing the integers of the subset. If the sum is zero, that subset is aproof orwitness for the answer is "yes". An algorithm that verifies whether a given subset has sum zero is averifier. Clearly, summing the integers of a subset can be done in polynomial time, and the subset sum problem is therefore in NP.

The above example can be generalized for any decision problem. Given any instance I of problemΠ{\displaystyle \Pi } and witness W, if there exists averifier V so that given the ordered pair (I, W) as input, V returns "yes" in polynomial time if the witness proves that the answer is "yes" or "no" in polynomial time otherwise, thenΠ{\displaystyle \Pi } is in NP.

The "no"-answer version of this problem is stated as: "given a finite set of integers, does every non-empty subset have a nonzero sum?". The verifier-based definition of NP doesnot require an efficient verifier for the "no"-answers. The class of problems with such verifiers for the "no"-answers is called co-NP. In fact, it is an open question whether all problems in NP also have verifiers for the "no"-answers and thus are in co-NP.

In some literature the verifier is called the "certifier", and the witness the "certificate".[2]

Machine-definition

[edit]

Equivalent to the verifier-based definition is the following characterization: NP is the class ofdecision problems solvable by anondeterministic Turing machine that runs inpolynomial time. That is to say, a decision problemΠ{\displaystyle \Pi } is in NP wheneverΠ{\displaystyle \Pi } is recognized by some polynomial-time nondeterministic Turing machineM{\displaystyle M} with anexistential acceptance condition, meaning thatwΠ{\displaystyle w\in \Pi } if and only if some computation path ofM(w){\displaystyle M(w)} leads to an accepting state. This definition is equivalent to the verifier-based definition because a nondeterministic Turing machine could solve an NP problem in polynomial time by nondeterministically selecting a certificate and running the verifier on the certificate. Similarly, if such a machine exists, then a polynomial time verifier can naturally be constructed from it.

In this light, we can define co-NP dually as the class of decision problems recognizable by polynomial-time nondeterministic Turing machines with an existential rejection condition. Since an existential rejection condition is exactly the same thing as auniversal acceptance condition, we can understand theNP vs. co-NP question as asking whether the existential and universal acceptance conditions have the same expressive power for the class of polynomial-time nondeterministic Turing machines.

Properties

[edit]

NP is closed underunion,intersection,concatenation,Kleene star andreversal. It is not known whether NP is closed undercomplement (this question is the so-called "NP versus co-NP" question).

Why some NP problems are hard to solve

[edit]

Because of the many important problems in this class, there have been extensive efforts to find polynomial-time algorithms for problems in NP. However, there remain a large number of problems in NP that defy such attempts, seeming to requiresuper-polynomial time. Whether these problems are not decidable in polynomial time is one of the greatest open questions incomputer science (seeP versus NP ("P = NP") problem for an in-depth discussion).

An important notion in this context is the set ofNP-complete decision problems, which is a subset of NP and might be informally described as the "hardest" problems in NP. If there is a polynomial-time algorithm for evenone of them, then there is a polynomial-time algorithm forall the problems in NP. Because of this, and because dedicated research has failed to find a polynomial algorithm for any NP-complete problem, once a problem has been proven to be NP-complete, this is widely regarded as a sign that a polynomial algorithm for this problem is unlikely to exist.

However, in practical uses, instead of spending computational resources looking for an optimal solution, a good enough (but potentially suboptimal) solution may often be found in polynomial time. Also, the real-life applications of some problems are easier than their theoretical equivalents.

Equivalence of definitions

[edit]

The two definitions of NP as the class of problems solvable by a nondeterministicTuring machine (TM) in polynomial time and the class of problems verifiable by a deterministic Turing machine in polynomial time are equivalent. The proof is described by many textbooks, for example, Sipser'sIntroduction to the Theory of Computation, section 7.3.

To show this, first, suppose we have a deterministic verifier. A non-deterministic machine can simply nondeterministically run the verifier on all possible proof strings (this requires only polynomially many steps because it can nondeterministically choose the next character in the proof string in each step, and the length of the proof string must be polynomially bounded). If any proof is valid, some path will accept; if no proof is valid, the string is not in the language and it will reject.

Conversely, suppose we have a non-deterministic TM called A accepting a given language L. At each of its polynomially many steps, the machine'scomputation tree branches in at most a finite number of directions. There must be at least one accepting path, and the string describing this path is the proof supplied to the verifier. The verifier can then deterministically simulate A, following only the accepting path, and verifying that it accepts at the end. If A rejects the input, there is no accepting path, and the verifier will always reject.

Relationship to other classes

[edit]
icon
This sectionneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources in this section. Unsourced material may be challenged and removed.(May 2025) (Learn how and when to remove this message)
A representation of the relation amongcomplexity classes
Inclusions of complexity classes includingP, NP,co-NP,BPP,P/poly,PH, andPSPACE

NP contains all problems inP, since one can verify any instance of the problem by simply ignoring the proof and solving it. NP is contained inPSPACE—to show this, it suffices to construct a PSPACE machine that loops over all proof strings and feeds each one to a polynomial-time verifier. Since a polynomial-time machine can only read polynomially many bits, it cannot use more than polynomial space, nor can it read a proof string occupying more than polynomial space (so we do not have to consider proofs longer than this). NP is also contained inEXPTIME, since the same algorithm operates in exponential time.

co-NP contains those problems that have a simple proof forno instances, sometimes called counterexamples. For example,primality testing trivially lies in co-NP, since one can refute the primality of an integer by merely supplying a nontrivial factor. NP and co-NP together form the first level in thepolynomial hierarchy, higher only than P.

NP is defined using only deterministic machines. If we permit the verifier to be probabilistic (this, however, is not necessarily a BPP machine[6]), we get the classMA solvable using anArthur–Merlin protocol with no communication from Arthur to Merlin.

The relationship betweenBPP andNP is unknown: it is not known whetherBPP is asubset ofNP,NP is a subset ofBPP or neither. IfNP is contained inBPP, which is considered unlikely since it would imply practical solutions forNP-complete problems, thenNP =RP andPHBPP.[7]

NP is a class ofdecision problems; the analogous class of function problems isFNP.

The only known strict inclusions come from thetime hierarchy theorem and thespace hierarchy theorem, and respectively they areNPNEXPTIME{\displaystyle {\mathsf {NP\subsetneq NEXPTIME}}} andNPEXPSPACE{\displaystyle {\mathsf {NP\subsetneq EXPSPACE}}}.

Other characterizations

[edit]

In terms ofdescriptive complexity theory, NP corresponds precisely to the set of languages definable by existentialsecond-order logic (Fagin's theorem).

NP can be seen as a very simple type ofinteractive proof system, where the prover comes up with the proof certificate and the verifier is a deterministic polynomial-time machine that checks it. It is complete because the right proof string will make it accept if there is one, and it is sound because the verifier cannot accept if there is no acceptable proof string.

A major result of complexity theory is that NP can be characterized as the problems solvable byprobabilistically checkable proofs where the verifier uses O(logn) random bits and examines only a constant number of bits of the proof string (the classPCP(logn, 1)). More informally, this means that the NP verifier described above can be replaced with one that just "spot-checks" a few places in the proof string, and using a limited number of coin flips can determine the correct answer with high probability. This allows several results about the hardness ofapproximation algorithms to be proven.

Examples

[edit]

P

[edit]

All problems inP, denotedPNP{\displaystyle {\mathsf {P\subseteq NP}}}. Given a certificate for a problem inP, we can ignore the certificate and just solve the problem in polynomial time.

Integer factorization

[edit]

The decision problem version of theinteger factorization problem: given integersn andk, is there a factorf with 1 <f <k andf dividingn?[8]

NP-complete problems

[edit]
Main article:List of NP-complete problems

EveryNP-complete problem is in NP.

Boolean satisfiability

[edit]

TheBoolean satisfiability problem (SAT), where we want to know whether or not a certain formula inpropositional logic withBoolean variables is true for some value of the variables.[9]

Travelling salesman

[edit]

The decision version of thetravelling salesman problem is in NP. Given an input matrix of distances betweenn cities, the problem is to determine if there is a route visiting all cities with total distance less thank.

A proof can simply be a list of the cities. Then verification can clearly be done in polynomial time. It simply adds the matrix entries corresponding to the paths between the cities.

Anondeterministic Turing machine can find such a route as follows:

  • At each city it visits it will "guess" the next city to visit, until it has visited every vertex. If it gets stuck, it stops immediately.
  • At the end it verifies that the route it has taken has cost less thank inO(n) time.

One can think of each guess as "forking" a new copy of the Turing machine to follow each of the possible paths forward, and if at least one machine finds a route of distance less thank, that machine accepts the input. (Equivalently, this can be thought of as a single Turing machine that always guesses correctly)

Abinary search on the range of possible distances can convert the decision version of Traveling Salesman to the optimization version, by calling the decision version repeatedly (a polynomial number of times).[10][8]

Subgraph isomorphism

[edit]

Thesubgraph isomorphism problem of determining whether graphG contains a subgraph that is isomorphic to graphH.[11]

See also

[edit]

Notes

[edit]
  1. ^Polynomial time refers to how quickly the number of operations needed by an algorithm, relative to the size of the problem, grows. It is therefore a measure of efficiency of an algorithm.

References

[edit]
  1. ^Ladner, R. E. (1975)."On the structure of polynomial time reducibility".J. ACM.22:151–171.doi:10.1145/321864.321877.S2CID 14352974. Corollary 1.1.
  2. ^abKleinberg, Jon; Tardos, Éva (2006).Algorithm Design (2nd ed.). Addison-Wesley. p. 464.ISBN 0-321-37291-3.
  3. ^Alsuwaiyel, M. H.:Algorithms: Design Techniques and Analysis,p. 283.
  4. ^William Gasarch (June 2002)."The P=?NP poll"(PDF).SIGACT News.33 (2):34–47.doi:10.1145/1052796.1052804.S2CID 18759797. Retrieved2008-12-29.
  5. ^Kleinberg, Jon; Tardos, Éva (2006).Algorithm Design (2nd ed.). Pearson/Addison-Wesley. p. 496.ISBN 0-321-37291-3.
  6. ^"Complexity Zoo:E".Complexity Zoo. Archived fromthe original on 2020-11-11. Retrieved23 March 2018.
  7. ^Lance Fortnow,Pulling Out The Quantumness, December 20, 2005
  8. ^abWigderson, Avi."P, NP and mathematics – a computational complexity perspective"(PDF). Retrieved13 Apr 2021.
  9. ^Karp, Richard (1972)."Reducibility among Combinatorial Problems"(PDF).Complexity of Computer Computations. pp. 85–103.doi:10.1007/978-1-4684-2001-2_9.ISBN 978-1-4684-2003-6.
  10. ^Aaronson, Scott."P=? NP"(PDF). Retrieved13 Apr 2021.
  11. ^Garey, Michael R.; Johnson, David S. (1979).Computers and Intractability: A Guide to the Theory of NP-Completeness. W.H. Freeman.ISBN 0-7167-1045-5.

Further reading

[edit]

External links

[edit]
Considered feasible
Suspected infeasible
Considered infeasible
Other complexity classes
Class hierarchies
Families of classes
General
Theorems
(list),
paradoxes
Logics
Traditional
Propositional
Predicate
Set theory
Types
ofsets
Maps,
cardinality
Theories
Formal
systems

(list),
language,
syntax
Example
axiomatic
systems

(list)
Proof theory
Model theory
Computability
theory
Related
Retrieved from "https://en.wikipedia.org/w/index.php?title=NP_(complexity)&oldid=1327595395"
Category:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp