P (complexity)
Template:Short description Template:DMCA 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.Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. The related class of function problems is FP.
Several natural problems are complete for P, including st-connectivity (or reachability) on alternating graphs Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. 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,Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. although this belief (the hypothesis) remains unproven. Another open problem is whether NP = co-NP; since P = co-P,Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. 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.Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found.
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.Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found.
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,Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. Immerman ascribes this result to VardiLua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. and to Immerman 1982.Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found.
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.Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found.
It was published in 2001 that PTIME corresponds to (positive) range concatenation grammars.[2]
P can also be defined as an algorithmic complexity class for problems that are not decision problemsLua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. (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
KozenLua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. 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 paperLua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. was in a 1967 proceedings of a 1966 conference, while Cobham'sLua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. was in a 1965 proceedings of a 1964 conference and Edmonds'sLua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. was published in a journal in 1965, though Rabin makes no mention of either and was apparently unaware of them).[3] 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,Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found.Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. 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
Page Template:Reflist/styles.css has no content.
- ^
- ^ Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found., citing Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. for the proof.
- ^ Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found. was mentioned in Lua error in package.lua at line 80: module 'Module:Footnotes/anchor_id_list' not found.
References
Page Template:Refbegin/styles.css has no content.
- Page Module:Citation/CS1/styles.css has no content.Agrawal, Manindra; Kayal, Neeraj; Saxena, Nitin (2004). "PRIMES is in P" (PDF). Annals of Mathematics. 160 (2): 781–793.
- Page Module:Citation/CS1/styles.css has no content.Bellantoni, Stephen; Cook, Stephen A. (1992). "A new recursion-theoretic characterization of the polytime functions". Computational Complexity. 2: 97–110. doi:10.1007/BF01201998.
- Page Module:Citation/CS1/styles.css has no content.Bertsch, Eberhard; Nederhof, Mark-Jan (October 2001). "On the Complexity of Some Extensions of RCG Parsing" (PDF). Proceedings of the Seventh International Workshop on Parsing Technologies (IWPT 2001). Beijing, China. pp. 66–77.
- Page Module:Citation/CS1/styles.css has no content.Cai, Jin-Yi; Sivakumar, D. (April 1999). "Sparse Hard Sets for P: Resolution of a Conjecture of Hartmanis". Journal of Computer and System Sciences. 58 (2): 280–296. doi:10.1006/jcss.1998.1615.
- Page Module:Citation/CS1/styles.css has no content.Cobham, Alan (1965). "The Intrinsic Computational Difficulty of Functions". In Bar-Hillel, Yehoshua (ed.). Logic, Methodology and Philosophy of Science: Proceedings of the 1964 International Congress. Amsterdam: North-Holland. pp. 24–30.
- Page Module:Citation/CS1/styles.css has no content.Cook, Stephen A. (1971). "The Complexity of Theorem-Proving Procedures". Proceedings of the Third Annual ACM Symposium on Theory of Computing. ACM. pp. 151–158. doi:10.1145/800157.805047.
- Page Module:Citation/CS1/styles.css has no content.Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford (2001). "Section 34.1: Polynomial time". Introduction to Algorithms (2 ed.). MIT Press and McGraw–Hill. pp. 971–979. ISBN 0-262-03293-7.
- Page Module:Citation/CS1/styles.css has no content.Edmonds, Jack (1965). "Paths, Trees, and Flowers". Canadian Journal of Mathematics. 17 (3): 449–467. doi:10.4153/CJM-1965-045-4.
- Page Module:Citation/CS1/styles.css has no content.Gautschi, Walter (1994). Mathematics of Computation, 1943–1993: a Half-Century of Computational Mathematics: Mathematics of Computation 50th Anniversary Symposium, August 9–13, 1993, Vancouver, British Columbia. Providence, RI: American Mathematical Society. pp. 503–504. ISBN 978-0-8218-0291-5.
- Page Module:Citation/CS1/styles.css has no content.Hopcroft, John E.; Motwani, Rajeev; Ullman, Jeffrey D. (2001). Introduction to Automata Theory, Languages, and Computation (2 ed.). Boston: Addison-Wesley. ISBN 978-0201441246.
- Page Module:Citation/CS1/styles.css has no content.Immerman, Neil (1982). "Relational Queries Computable in Polynomial Time". Proceedings of the Fourteenth Annual ACM Symposium on Theory of Computing (STOC '82). pp. 147–152. doi:10.1145/800070.802187.
Revised version in Information and Control, 68 (1986), 86–104
- Page Module:Citation/CS1/styles.css has no content.Immerman, Neil (1987). "Languages That Capture Complexity Classes". SIAM Journal on Computing. 16: 760–778. doi:10.1137/0216051.
- Page Module:Citation/CS1/styles.css has no content.Immerman, Neil (1999). Descriptive Complexity. New York: Springer-Verlag. ISBN 978-0-387-98600-5.
- Page Module:Citation/CS1/styles.css has no content.Johnsonbaugh, Richard F.; Schaefer, Marcus (2004). Algorithms. Pearson Education. ISBN 0-02-360692-4.
- Page Module:Citation/CS1/styles.css has no content.Kallmeyer, Laura (2010). Parsing Beyond Context-Free Grammars (PDF). Springer Science & Business Media. pp. 5, 37. ISBN 978-3-642-14846-0.
- Page Module:Citation/CS1/styles.css has no content.Kozen, Dexter C. (2006). Theory of Computation. Springer. ISBN 978-1-84628-297-3.
- Page Module:Citation/CS1/styles.css has no content.Papadimitriou, Christos H. (1994). Computational complexity. Reading, Mass.: Addison–Wesley. ISBN 978-0-201-53082-7.
- Page Module:Citation/CS1/styles.css has no content.Pocklington, H. C. (1910–1912). "The determination of the exponent to which a number belongs, the practical solution of certain congruences, and the law of quadratic reciprocity". Mathematical Proceedings of the Cambridge Philosophical Society. 16: 1–5.
- Page Module:Citation/CS1/styles.css has no content.Rabin, Michael O. (1967). "Mathematical theory of automata". Mathematical Aspects of Computer Science. Proceedings of Symposia in Applied Mathematics. Vol. 19. American Mathematical Society. pp. 153–175. doi:10.1090/psapm/019.
- Page Module:Citation/CS1/styles.css has no content.Sipser, Michael (2006). "Section 7.2: The Class P". Introduction to the Theory of Computation (2nd ed.). Course Technology Inc. pp. 256–263. ISBN 978-0-534-95097-2.
- Page Module:Citation/CS1/styles.css has no content.Stockmeyer, Larry J. (October 1976). "The Polynomial-Time Hierarchy". Theoretical Computer Science. 3 (1): 1–22. doi:10.1016/0304-3975(76)90061-X.
- Page Module:Citation/CS1/styles.css has no content.Vardi, Moshe Y. (1982). "The Complexity of Relational Query Languages". STOC '82: Proceedings of the fourteenth annual ACM symposium on Theory of computing. pp. 137–146. doi:10.1145/800070.802186.
- Page Module:Citation/CS1/styles.css has no content.Wegener, Ingo (2005). Complexity Theory | Exploring the Limits of Efficient Algorithms (Textbook). Springer-Verlag. doi:10.1007/3-540-27477-4. ISBN 978-3-540-21045-0.
External links
- Page Module:Citation/CS1/styles.css has no content.StackOverflow. "Complexity theory - Why is co-P = P". Stack Overflow. Retrieved 15 November 2025.
- Complexity Zoo: Class P
- Complexity Zoo: Class P/poly