P (complexity): Difference between revisions
imported>Oneequalsequalsone →Relationships to other classes: add npspace |
imported>Marc Schroeder |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{short description|Class of problems solvable in polynomial time}} | {{short description|Class of problems solvable in polynomial time}} | ||
{{use dmy dates|date=November 2025}} | |||
In [[computational complexity theory]], '''P''', also known as '''PTIME''' or '''[[DTIME]]'''(''n''<sup>O(1)</sup>), is a fundamental [[complexity class]]. It contains all [[decision problem]]s that can be solved by a [[deterministic Turing machine]] using a [[polynomial]] amount of [[computation time]], or [[polynomial time]]. | In [[computational complexity theory]], '''P''', also known as '''PTIME''' or '''[[DTIME]]'''(''n''<sup>O(1)</sup>), is a fundamental [[complexity class]]. It contains all [[decision problem]]s that can be solved by a [[deterministic Turing machine]] using a [[polynomial]] amount of [[computation time]], or [[polynomial time]]. | ||
| Line 20: | Line 21: | ||
==Notable problems in P== | ==Notable problems in P== | ||
P is known to contain many natural problems, including the decision versions of [[linear programming]], and finding a [[maximum matching]]. In 2002, it was shown that the problem of determining if a number is [[prime number|prime]] is in P. | P is known to contain many natural problems, including the decision versions of [[linear programming]], and finding a [[maximum matching]]. In 2002, it was shown that the problem of determining if a number is [[prime number|prime]] is in P.{{sfn|Agrawal|Kayal|Saxena|2004}} The related class of [[function problem]]s is [[FP (complexity)|FP]]. | ||
Several natural problems are complete for P, including [[st-connectivity|''st''-connectivity]] (or [[reachability]]) on alternating graphs | Several natural problems are complete for P, including [[st-connectivity|''st''-connectivity]] (or [[reachability]]) on alternating graphs {{sfn|Immerman|1999}} The article on [[P-complete|P-complete problems]] lists further relevant problems in P. | ||
==Relationships to other classes== | ==Relationships to other classes== | ||
[[Image:Complexity subsets pspace.svg|300px|thumb|right|A representation of the relation among complexity classes]] | [[Image:Complexity subsets pspace.svg|300px|thumb|right|A representation of the relation among complexity classes]] | ||
[[File:Complexity-classes-polynomial.svg|thumb|Inclusions of complexity classes including | [[File:Complexity-classes-polynomial.svg|thumb|Inclusions of complexity classes including P, [[NP (complexity)|NP]], [[co-NP]], [[BPP (complexity)|BPP]], [[P/poly]], [[PH (complexity)|PH]], and [[PSPACE]]]] | ||
A generalization of P is [[NP (complexity)|NP]], which is the class of [[decision problem]]s decidable by a [[non-deterministic Turing machine]] that runs in [[polynomial time]]. Equivalently, it is the class of decision problems where each "yes" instance has a polynomial size certificate, and certificates can be checked by a polynomial time deterministic Turing machine. The class of problems for which this is true for the "no" instances is called [[co-NP]]. P is trivially a subset of NP and of co-NP; most experts believe it is a proper subset, | A generalization of P is [[NP (complexity)|NP]], which is the class of [[decision problem]]s decidable by a [[non-deterministic Turing machine]] that runs in [[polynomial time]]. Equivalently, it is the class of decision problems where each "yes" instance has a polynomial size certificate, and certificates can be checked by a polynomial time deterministic Turing machine. The class of problems for which this is true for the "no" instances is called [[co-NP]]. P is trivially a subset of NP and of co-NP; most experts believe it is a proper subset,{{sfn|Johnsonbaugh|Schaefer|2004|page=458}} although this belief (the <math>\mathsf{P} \subsetneq \mathsf{NP}</math> hypothesis) [[P versus NP problem|remains unproven]]. Another open problem is whether NP = co-NP; since P = co-P,{{sfn|StackOverflow}} a negative answer would imply <math>\mathsf{P} \subsetneq \mathsf{NP}</math>. | ||
{{ | |||
P is also known to be at least as large as [[L (complexity)|L]], the class of problems decidable in a [[logarithm]]ic amount of [[Memory space (computational resource)|memory space]]. A decider using <math>O(\log n)</math> space cannot use more than <math>2^{O(\log n)} = n^{O(1)}</math> time, because this is the total number of possible configurations; thus, L is a subset of P. Another important problem is whether L = P. We do know that P = AL, the set of problems solvable in logarithmic memory by [[alternating Turing machine]]s. P is also known to be no larger than [[PSPACE]], the class of problems decidable in polynomial space. PSPACE is equivalent to NPSPACE by [[Savitch's theorem]]. Again, whether P = PSPACE is an open problem. To summarize: | P is also known to be at least as large as [[L (complexity)|L]], the class of problems decidable in a [[logarithm]]ic amount of [[Memory space (computational resource)|memory space]]. A decider using <math>O(\log n)</math> space cannot use more than <math>2^{O(\log n)} = n^{O(1)}</math> time, because this is the total number of possible configurations; thus, L is a subset of P. Another important problem is whether L = P. We do know that P = AL, the set of problems solvable in logarithmic memory by [[alternating Turing machine]]s. P is also known to be no larger than [[PSPACE]], the class of problems decidable in polynomial space. PSPACE is equivalent to NPSPACE by [[Savitch's theorem]]. Again, whether P = PSPACE is an open problem. To summarize: | ||
| Line 43: | Line 43: | ||
Another generalization of P is [[P/poly]], or Nonuniform Polynomial-Time. If a problem is in P/poly, then it can be solved in deterministic polynomial time provided that an [[advice (complexity)|advice string]] is given that depends only on the length of the input. Unlike for NP, however, the polynomial-time machine doesn't need to detect fraudulent advice strings; it is not a verifier. P/poly is a large class containing nearly all practical problems, including all of [[Bounded-error probabilistic polynomial|BPP]]. If it contains NP, then the [[polynomial hierarchy]] collapses to the second level. On the other hand, it also contains some impractical problems, including some [[undecidable problem]]s such as the unary version of any undecidable problem. | Another generalization of P is [[P/poly]], or Nonuniform Polynomial-Time. If a problem is in P/poly, then it can be solved in deterministic polynomial time provided that an [[advice (complexity)|advice string]] is given that depends only on the length of the input. Unlike for NP, however, the polynomial-time machine doesn't need to detect fraudulent advice strings; it is not a verifier. P/poly is a large class containing nearly all practical problems, including all of [[Bounded-error probabilistic polynomial|BPP]]. If it contains NP, then the [[polynomial hierarchy]] collapses to the second level. On the other hand, it also contains some impractical problems, including some [[undecidable problem]]s such as the unary version of any undecidable problem. | ||
In 1999, [[Jin-Yi Cai]] and D. Sivakumar, building on work by [[Mitsunori Ogihara]], showed that if there exists a [[sparse language]] that is P-complete, then L = P. | In 1999, [[Jin-Yi Cai]] and D. Sivakumar, building on work by [[Mitsunori Ogihara]], showed that if there exists a [[sparse language]] that is P-complete, then L = P.{{sfn|Cai|Sivakumar|1999}} | ||
[[File:Randomised Complexity Classes 2.svg|alt=Diagram of randomised complexity classes|thumb|upright=1.25|P in relation to probabilistic complexity classes ([[ZPP (complexity)|ZPP]], [[RP (complexity)|RP]], co-RP, [[BPP (complexity)|BPP]], [[BQP]], [[PP (complexity)|PP]]), all within [[PSPACE]]. It is unknown if any of these containments are strict.]] | [[File:Randomised Complexity Classes 2.svg|alt=Diagram of randomised complexity classes|thumb|upright=1.25|P in relation to probabilistic complexity classes ([[ZPP (complexity)|ZPP]], [[RP (complexity)|RP]], co-RP, [[BPP (complexity)|BPP]], [[BQP]], [[PP (complexity)|PP]]), all within [[PSPACE]]. It is unknown if any of these containments are strict.]] | ||
| Line 52: | Line 52: | ||
Polynomial-time algorithms are closed under composition. Intuitively, this says that if one writes a function that is polynomial-time assuming that function calls are constant-time, and if those called functions themselves require polynomial time, then the entire algorithm takes polynomial time. One consequence of this is that P is [[low (complexity)|low]] for itself. This is also one of the main reasons that P is considered to be a machine-independent class; any machine "feature", such as [[random access]], that can be simulated in polynomial time can simply be composed with the main polynomial-time algorithm to reduce it to a polynomial-time algorithm on a more basic machine. | Polynomial-time algorithms are closed under composition. Intuitively, this says that if one writes a function that is polynomial-time assuming that function calls are constant-time, and if those called functions themselves require polynomial time, then the entire algorithm takes polynomial time. One consequence of this is that P is [[low (complexity)|low]] for itself. This is also one of the main reasons that P is considered to be a machine-independent class; any machine "feature", such as [[random access]], that can be simulated in polynomial time can simply be composed with the main polynomial-time algorithm to reduce it to a polynomial-time algorithm on a more basic machine. | ||
Languages in P are also closed under reversal, [[Intersection (set theory)|intersection]], [[Union (set theory)|union]], [[concatenation]], [[Kleene closure]], inverse [[homomorphism]], and [[Complement (complexity)|complementation]]. | Languages in P are also closed under reversal, [[Intersection (set theory)|intersection]], [[Union (set theory)|union]], [[concatenation]], [[Kleene closure]], inverse [[homomorphism]], and [[Complement (complexity)|complementation]].{{sfn|Hopcroft|Motwani|Ullman|2001|pages=425–426}} | ||
==Pure existence proofs of polynomial-time algorithms== | ==Pure existence proofs of polynomial-time algorithms== | ||
| Line 58: | Line 58: | ||
==Alternative characterizations== | ==Alternative characterizations== | ||
In [[descriptive complexity]], P can be described as the problems expressible in [[FO(LFP)]], the [[first-order logic]] with a [[least fixed point]] operator added to it, on ordered structures. | In [[descriptive complexity]], P can be described as the problems expressible in [[FO(LFP)]], the [[first-order logic]] with a [[least fixed point]] operator added to it, on ordered structures. In Immerman's 1999 textbook on descriptive complexity,{{sfn|Immerman|1999|p=66}} [[Neil Immerman|Immerman]] ascribes this result to [[Moshe Vardi|Vardi]]{{sfn|Vardi|1982}} and to Immerman 1982.{{sfn|Immerman|1982}} | ||
In 1992 an alternative characterization of [[FP (complexity)|FP]]<ref><math>P \subsetneq FP</math></ref> was given by Bellantoni and [[Stephen Cook|Cook]], who define polynomial-time computable functions using a safe recursion scheme, providing a machine-independent, structural definition within the framework of [[implicit computational complexity]].{{sfn|Bellantoni|Cook|1992}} | |||
P can also be defined as an algorithmic complexity class for problems that are not decision | It was published in 2001 that PTIME corresponds to (positive) [[range concatenation grammars]].{{refn|{{harvtxt|Kallmeyer|2010|pp=5, 37}}, citing {{harvtxt|Bertsch|Nederhof|2001}} for the proof.}} | ||
P can also be defined as an algorithmic complexity class for problems that are not [[decision problem]]s{{sfn|Wegener|2005|p=35}} (even though, for example, finding the solution to a [[2-satisfiability]] instance in polynomial time automatically gives a polynomial algorithm for the corresponding decision problem). In that case P is not a subset of NP, but <math>P \cap DEC</math> is, where <math>DEC</math> is the class of decision problems. | |||
==History== | ==History== | ||
[[Dexter Kozen|Kozen]] | [[Dexter Kozen|Kozen]]{{sfn|Kozen|2006|p=4}} states that [[Alan Cobham (mathematician)|Cobham]] and [[Jack Edmonds|Edmonds]] are "generally credited with the invention of the notion of polynomial time," though [[Michael O. Rabin|Rabin]] also invented the notion independently and around the same time (Rabin's paper{{sfn|Rabin|1967}} was in a 1967 proceedings of a 1966 conference, while Cobham's{{sfn|Cobham|1965}} was in a 1965 proceedings of a 1964 conference and Edmonds's{{sfn|Edmonds|1965}} was published in a journal in 1965, though Rabin makes no mention of either and was apparently unaware of them).{{refn|{{harvtxt|Cobham|1965}} was mentioned in {{harvtxt|Cook|1971}}}} Cobham invented the class as a robust way of characterizing efficient algorithms, leading to [[Cobham's thesis]]. However, [[Henry Cabourn Pocklington|H. C. Pocklington]], in a 1910 paper,{{sfn|Pocklington|1910–1912}}{{sfn|Gautschi|1994|pp=503–504}} analyzed two algorithms for solving quadratic congruences, and observed that one took time "proportional to a power of the logarithm of the modulus" and contrasted this with one that took time proportional "to the modulus itself or its square root", thus explicitly drawing a distinction between an algorithm that ran in polynomial time versus one that ran in (moderately) exponential time. | ||
==Notes== | ==Notes== | ||
| Line 71: | Line 73: | ||
==References== | ==References== | ||
{{refbegin|2}} | |||
* {{cite journal | |||
| last1=Agrawal | |||
| first1=Manindra | |||
| author-link1=Manindra_Agrawal | |||
| last2=Kayal | |||
| first2=Neeraj | |||
| last3=Saxena | |||
| first3=Nitin | |||
| title=PRIMES is in P | |||
| journal=Annals of Mathematics | |||
| url=https://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf | |||
| volume=160 | |||
| issue=2 | |||
| pages=781–793 | |||
| year=2004 | |||
}} | |||
* {{cite journal | |||
| last1 = Bellantoni | |||
| first1 = Stephen | |||
| last2 = Cook | |||
| first2 = Stephen A. | |||
| authorlink2 = Stephen Cook | |||
| title = A new recursion-theoretic characterization of the polytime functions | |||
| journal = Computational Complexity | |||
| volume = 2 | |||
| pages = 97–110 | |||
| year = 1992 | |||
| doi = 10.1007/BF01201998 | |||
}} | |||
* {{cite conference | |||
| last1=Bertsch | |||
| first1=Eberhard | |||
| last2=Nederhof | |||
| first2=Mark-Jan | |||
| chapter=On the Complexity of Some Extensions of RCG Parsing | |||
| title=Proceedings of the Seventh International Workshop on Parsing Technologies (IWPT 2001) | |||
| date=October 2001 | |||
| location=Beijing, China | |||
| pages=66–77 | |||
| chapter-url=https://mjn.host.cs.st-andrews.ac.uk/publications/2001d.pdf | |||
}} | |||
* {{cite journal | |||
| last=Cai | |||
| first1=Jin-Yi | |||
| author-link1=Jin-Yi_Cai | |||
| last2=Sivakumar | |||
| first2=D. | |||
| title=Sparse Hard Sets for P: Resolution of a Conjecture of Hartmanis | |||
| journal=[[Journal of Computer and System Sciences]] | |||
| volume=58 | |||
| issue=2 | |||
| pages=280–296 | |||
| date=April 1999 | |||
| doi=10.1006/jcss.1998.1615 | |||
| doi-access=free | |||
}} | |||
* {{cite book | |||
| last=Cobham | |||
| first=Alan | |||
| author-link=Alan Cobham (mathematician) | |||
| year=1965 | |||
| chapter=The Intrinsic Computational Difficulty of Functions | |||
| publisher=North-Holland | |||
| location = Amsterdam | |||
| editor-last = Bar-Hillel | |||
| editor-first=Yehoshua | |||
| editor-link=Yehoshua Bar-Hillel | |||
| title=Logic, Methodology and Philosophy of Science: Proceedings of the 1964 International Congress | |||
| pages=24–30 | |||
}} | |||
* {{cite conference | |||
| last = Cook | |||
| first = Stephen A. | |||
| author-link = Stephen Cook | |||
| title = The Complexity of Theorem-Proving Procedures | |||
| book-title = Proceedings of the Third Annual ACM Symposium on Theory of Computing | |||
| publisher = ACM | |||
| year = 1971 | |||
| pages = 151–158 | |||
| doi = 10.1145/800157.805047 | |||
| doi-access=free | |||
}} | |||
* {{cite book | |||
| last1=Cormen | |||
| first1=Thomas H. | |||
| author-link1=Thomas_H._Cormen | |||
| last2=Leiserson | |||
| first2=Charles E. | |||
| author-link2=Charles_E._Leiserson | |||
| last3=Rivest | |||
| first3=Ronald L. | |||
| author-link3=Ron_Rivest | |||
| last4=Stein | |||
| first4=Clifford | |||
| author-link4=Clifford_Stein | |||
| title=[[Introduction to Algorithms]] | |||
| edition=2 | |||
| publisher=MIT Press and McGraw–Hill | |||
| year=2001 | |||
| isbn=0-262-03293-7 | |||
| pages=971–979 | |||
| chapter=Section 34.1: Polynomial time | |||
}} | |||
* {{cite journal | * {{cite journal | ||
| last = Edmonds | first = Jack | author-link= | | last=Edmonds | ||
| year = 1965 | | first=Jack | ||
| title = Paths, | | author-link=Jack_Edmonds | ||
| journal = Canadian Journal of Mathematics | | year=1965 | ||
| volume = 17 | | title=Paths, Trees, and Flowers | ||
| pages = 449–467 | | journal=Canadian Journal of Mathematics | ||
| doi = 10.4153/CJM-1965-045-4}} | | volume=17 | ||
| issue=3 | |||
| pages=449–467 | |||
| doi = 10.4153/CJM-1965-045-4 | |||
}} | |||
* {{cite book | |||
| last=Gautschi | |||
| first=Walter | |||
| title=Mathematics of Computation, 1943–1993: a Half-Century of Computational Mathematics: Mathematics of Computation 50th Anniversary Symposium, August 9–13, 1993, Vancouver, British Columbia | |||
| publisher=American Mathematical Society | |||
| location=Providence, RI | |||
| year=1994 | |||
| pages=503–504 | |||
| isbn=978-0-8218-0291-5 | |||
}} | |||
* {{cite book | |||
| last1=Hopcroft | |||
| first1=John E. | |||
| author-link1=John_Hopcroft | |||
| last2=Motwani | |||
| first2=Rajeev | |||
| author-link2=Rajeev_Motwani | |||
| last3=Ullman | |||
| first3=Jeffrey D. | |||
| author-link3=Jeffrey_Ullman | |||
| title=Introduction to Automata Theory, Languages, and Computation | |||
| edition=2 | |||
| publisher=Addison-Wesley | |||
| location=Boston | |||
| year=2001 | |||
| isbn=978-0201441246 | |||
}} | |||
* {{cite conference | |||
| last=Immerman | |||
| first=Neil | |||
| author-link=Neil_Immerman | |||
| chapter=Relational Queries Computable in Polynomial Time | |||
| title=Proceedings of the Fourteenth Annual ACM Symposium on Theory of Computing (STOC '82) | |||
| pages=147–152 | |||
| year=1982 | |||
| doi=10.1145/800070.802187 | |||
| quote=Revised version in Information and Control, 68 (1986), 86–104 | |||
}} | |||
*{{cite journal | |||
| last = Immerman | |||
| first = Neil | |||
| author-link=Neil_Immerman | |||
| title = Languages That Capture Complexity Classes | |||
| journal = SIAM Journal on Computing | |||
| volume = 16 | |||
| pages = 760–778 | |||
| year = 1987 | |||
| doi = 10.1137/0216051 | |||
}} | |||
* {{cite book | |||
| last=Immerman | |||
| first=Neil | |||
| author-link=Neil_Immerman | |||
| title=Descriptive Complexity | |||
| year=1999 | |||
| publisher=Springer-Verlag | |||
| location=New York | |||
| isbn=978-0-387-98600-5 | |||
}} | |||
* {{cite book | |||
| last1=Johnsonbaugh | |||
| first1=Richard F. | |||
| author-link1=Richard_Johnsonbaugh | |||
| last2=Schaefer | |||
| first2=Marcus | |||
| title=Algorithms | |||
| publisher=Pearson Education | |||
| year=2004 | |||
| isbn=0-02-360692-4 | |||
}} | |||
* {{cite book | |||
| last=Kallmeyer | |||
| first=Laura | |||
| title=Parsing Beyond Context-Free Grammars | |||
| publisher=Springer Science & Business Media | |||
| year=2010 | |||
| pages=5, 37 | |||
| isbn=978-3-642-14846-0 | |||
| url=http://mjn.host.cs.st-andrews.ac.uk/publications/2001d.pdf | |||
}} | |||
* {{cite book | |||
| last=Kozen | |||
| first=Dexter C. | |||
| author-link=Dexter_Kozen | |||
| title=Theory of Computation | |||
| publisher=Springer | |||
| year=2006 | |||
| isbn=978-1-84628-297-3 | |||
}} | |||
* {{Cite book | * {{Cite book | ||
| last= | | last=Papadimitriou | ||
| year = | | first=Christos H. | ||
| | | author-link=Christos Papadimitriou | ||
| | | title=Computational complexity | ||
| | | year=1994 | ||
| | | publisher=Addison–Wesley | ||
| | | location=Reading, Mass. | ||
| pages = | | isbn=978-0-201-53082-7 | ||
}} | |||
* {{cite journal | |||
| last=Pocklington | |||
| first=H. C. | |||
| author-link=Henry Cabourn Pocklington | |||
| year=1910–1912 | |||
| title=The determination of the exponent to which a number belongs, the practical solution of certain congruences, and the law of quadratic reciprocity | |||
| journal=[[Mathematical Proceedings of the Cambridge Philosophical Society]] | |||
| volume=16 | |||
| pages=1–5 | |||
}} | |||
* {{cite conference | * {{cite conference | ||
| last = Rabin | first = Michael O. | author-link = Michael O. Rabin | | last = Rabin | ||
| | | first = Michael O. | ||
| | | author-link = Michael O. Rabin | ||
| series = Proceedings of Symposia in Applied Mathematics | | chapter = Mathematical theory of automata | ||
| volume = 19 | | title = Mathematical Aspects of Computer Science | ||
| year = 1967 | | series = Proceedings of Symposia in Applied Mathematics | ||
| pages = 153–175 | | volume = 19 | ||
| publisher = American Mathematical Society | | year = 1967 | ||
| doi = 10.1090/psapm/019}} | | pages = 153–175 | ||
* | | publisher = American Mathematical Society | ||
* {{ | | doi = 10.1090/psapm/019 | ||
* {{ | }} | ||
* {{Cite book | |||
| last=Sipser | |||
| first=Michael | |||
| author-link=Michael Sipser | |||
| title=Introduction to the Theory of Computation | |||
| edition=2nd | |||
| year=2006 | |||
| publisher=Course Technology Inc | |||
| isbn=978-0-534-95097-2 | |||
| chapter= Section 7.2: The Class P | |||
| pages= 256-263 | |||
}} | |||
* {{cite journal | |||
| last = Stockmeyer | |||
| first = Larry J. | |||
| author-link = Larry Stockmeyer | |||
| title = The Polynomial-Time Hierarchy | |||
| journal = [[Theoretical Computer Science (journal)|Theoretical Computer Science]] | |||
| volume = 3 | |||
| issue = 1 | |||
| pages = 1–22 | |||
| date = October 1976 | |||
| doi = 10.1016/0304-3975(76)90061-X | |||
| doi-access=free | |||
}} | |||
*{{cite conference | |||
| last = Vardi | |||
| first = Moshe Y. | |||
| author-link=Moshe Vardi | |||
| title = The Complexity of Relational Query Languages | |||
| book-title = STOC '82: Proceedings of the fourteenth annual ACM symposium on Theory of computing | |||
| year = 1982 | |||
| pages = 137–146 | |||
| doi = 10.1145/800070.802186 | |||
}} | |||
* {{cite book | |||
| last=Wegener | |||
| first=Ingo | |||
| author-link=Ingo_Wegener | |||
| title=Complexity Theory {{!}} Exploring the Limits of Efficient Algorithms | |||
|type= Textbook | |||
| publisher=Springer-Verlag | |||
| year=2005 | |||
| doi=10.1007/3-540-27477-4 | |||
| isbn=978-3-540-21045-0 | |||
}} | |||
{{refend}} | |||
==External links== | ==External links== | ||
* {{sep | |||
| 1= computational-complexity | |||
| 2= Computational Complexity Theory | |||
| 3= Dean, Walter | |||
| 4= Fall 2021 | |||
}} | |||
* {{cite web | |||
| author=StackOverflow | |||
| title=Complexity theory - Why is co-P = P | |||
| website=Stack Overflow | |||
| url=https://stackoverflow.com/questions/40405347/why-is-co-p-p | |||
| access-date=2025-11-15 | |||
}} | |||
* {{CZoo|Class P|P#p}} | * {{CZoo|Class P|P#p}} | ||
* {{CZoo|Class P/poly|P#ppoly}} | * {{CZoo|Class P/poly|P#ppoly}} | ||
Latest revision as of 02:36, 16 November 2025
Template:Short description Template:Use dmy dates In computational complexity theory, P, also known as PTIME or DTIME(nO(1)), is a fundamental complexity class. It contains all decision problems that can be solved by a deterministic Turing machine using a polynomial amount of computation time, or polynomial time.
Cobham's thesis holds that P is the class of computational problems that are "efficiently solvable" or "tractable". This is inexact: in practice, some problems not known to be in P have practical solutions, and some that are in P do not, but this is a useful rule of thumb.
Definition
A language L is in P if and only if there exists a deterministic Turing machine M, such that
- M runs for polynomial time on all inputs
- For all x in L, M outputs 1
- For all x not in L, M outputs 0
P can also be viewed as a uniform family of Boolean circuits. A language L is in P if and only if there exists a polynomial-time uniform family of Boolean circuits , such that
- For all , takes n bits as input and outputs 1 bit
- For all x in L,
- For all x not in L,
The circuit definition can be weakened to use only a logspace uniform family without changing the complexity class.
Notable problems in P
P is known to contain many natural problems, including the decision versions of linear programming, and finding a maximum matching. In 2002, it was shown that the problem of determining if a number is prime is in P.Template:Sfn The related class of function problems is FP.
Several natural problems are complete for P, including st-connectivity (or reachability) on alternating graphs Template:Sfn The article on P-complete problems lists further relevant problems in P.
Relationships to other classes
A generalization of P is NP, which is the class of decision problems decidable by a non-deterministic Turing machine that runs in polynomial time. Equivalently, it is the class of decision problems where each "yes" instance has a polynomial size certificate, and certificates can be checked by a polynomial time deterministic Turing machine. The class of problems for which this is true for the "no" instances is called co-NP. P is trivially a subset of NP and of co-NP; most experts believe it is a proper subset,Template:Sfn although this belief (the hypothesis) remains unproven. Another open problem is whether NP = co-NP; since P = co-P,Template:Sfn a negative answer would imply .
P is also known to be at least as large as L, the class of problems decidable in a logarithmic amount of memory space. A decider using space cannot use more than time, because this is the total number of possible configurations; thus, L is a subset of P. Another important problem is whether L = P. We do know that P = AL, the set of problems solvable in logarithmic memory by alternating Turing machines. P is also known to be no larger than PSPACE, the class of problems decidable in polynomial space. PSPACE is equivalent to NPSPACE by Savitch's theorem. Again, whether P = PSPACE is an open problem. To summarize:
Here, EXPTIME is the class of problems solvable in exponential time. Of all the classes shown above, only two strict containments are known:
- P is strictly contained in EXPTIME. Consequently, all EXPTIME-hard problems lie outside P, and at least one of the containments to the right of P above is strict (in fact, it is widely believed that all three are strict).
- L is strictly contained in PSPACE.
The most difficult problems in P are P-complete problems.
Another generalization of P is P/poly, or Nonuniform Polynomial-Time. If a problem is in P/poly, then it can be solved in deterministic polynomial time provided that an advice string is given that depends only on the length of the input. Unlike for NP, however, the polynomial-time machine doesn't need to detect fraudulent advice strings; it is not a verifier. P/poly is a large class containing nearly all practical problems, including all of BPP. If it contains NP, then the polynomial hierarchy collapses to the second level. On the other hand, it also contains some impractical problems, including some undecidable problems such as the unary version of any undecidable problem.
In 1999, Jin-Yi Cai and D. Sivakumar, building on work by Mitsunori Ogihara, showed that if there exists a sparse language that is P-complete, then L = P.Template:Sfn
P is contained in BQP; it is unknown whether this containment is strict.
Properties
Polynomial-time algorithms are closed under composition. Intuitively, this says that if one writes a function that is polynomial-time assuming that function calls are constant-time, and if those called functions themselves require polynomial time, then the entire algorithm takes polynomial time. One consequence of this is that P is low for itself. This is also one of the main reasons that P is considered to be a machine-independent class; any machine "feature", such as random access, that can be simulated in polynomial time can simply be composed with the main polynomial-time algorithm to reduce it to a polynomial-time algorithm on a more basic machine.
Languages in P are also closed under reversal, intersection, union, concatenation, Kleene closure, inverse homomorphism, and complementation.Template:Sfn
Pure existence proofs of polynomial-time algorithms
Some problems are known to be solvable in polynomial time, but no concrete algorithm is known for solving them. For example, the Robertson–Seymour theorem guarantees that there is a finite list of forbidden minors that characterizes (for example) the set of graphs that can be embedded on a torus; moreover, Robertson and Seymour showed that there is an O(n3) algorithm for determining whether a graph has a given graph as a minor. This yields a nonconstructive proof that there is a polynomial-time algorithm for determining if a given graph can be embedded on a torus, despite the fact that no concrete algorithm is known for this problem.
Alternative characterizations
In descriptive complexity, P can be described as the problems expressible in FO(LFP), the first-order logic with a least fixed point operator added to it, on ordered structures. In Immerman's 1999 textbook on descriptive complexity,Template:Sfn Immerman ascribes this result to VardiTemplate:Sfn and to Immerman 1982.Template:Sfn
In 1992 an alternative characterization of FP[1] was given by Bellantoni and Cook, who define polynomial-time computable functions using a safe recursion scheme, providing a machine-independent, structural definition within the framework of implicit computational complexity.Template:Sfn
It was published in 2001 that PTIME corresponds to (positive) range concatenation grammars.Template:Refn
P can also be defined as an algorithmic complexity class for problems that are not decision problemsTemplate:Sfn (even though, for example, finding the solution to a 2-satisfiability instance in polynomial time automatically gives a polynomial algorithm for the corresponding decision problem). In that case P is not a subset of NP, but is, where is the class of decision problems.
History
KozenTemplate:Sfn states that Cobham and Edmonds are "generally credited with the invention of the notion of polynomial time," though Rabin also invented the notion independently and around the same time (Rabin's paperTemplate:Sfn was in a 1967 proceedings of a 1966 conference, while Cobham'sTemplate:Sfn was in a 1965 proceedings of a 1964 conference and Edmonds'sTemplate:Sfn was published in a journal in 1965, though Rabin makes no mention of either and was apparently unaware of them).Template:Refn Cobham invented the class as a robust way of characterizing efficient algorithms, leading to Cobham's thesis. However, H. C. Pocklington, in a 1910 paper,Template:SfnTemplate:Sfn analyzed two algorithms for solving quadratic congruences, and observed that one took time "proportional to a power of the logarithm of the modulus" and contrasted this with one that took time proportional "to the modulus itself or its square root", thus explicitly drawing a distinction between an algorithm that ran in polynomial time versus one that ran in (moderately) exponential time.
Notes
<templatestyles src="Reflist/styles.css" />
Script error: No such module "Check for unknown parameters".
References
<templatestyles src="Refbegin/styles.css" />
- Script error: No such module "Citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
External links
- Template:Sep
- Script error: No such module "citation/CS1".
- Template:CZoo
- Template:CZoo