In computational complexity theory, the polynomial hierarchy (sometimes called the polynomial-time hierarchy) is a hierarchy of complexity classes that generalize the classes NP and co-NP.[1] Each class in the hierarchy is contained within PSPACE.The union of the classes in the hierarchy is denoted PH.Classes within the hierarchy have complete problems (with respect to polynomial-time reductions) that ask if quantified Boolean formulae hold, for formulae with restrictions on the quantifier order.There are multiple equivalent definitions of the classes of the polynomial hierarchy.For the oracle definition of the polynomial hierarchy, define where P is the set of decision problems solvable in polynomial time.is the set of decision problems solvable in polynomial time by a Turing machine augmented by an oracle for some complete problem in class A; the classesis the class of problems solvable in polynomial time by a deterministic Turing machine with an oracle for some NP-complete problem.Similarly, define Note that De Morgan's laws hold:, where Lc is the complement of L. Let C be a class of languages.Extend these operators to work on whole classes of languages by the definition Again, De Morgan's laws hold:The classes NP and co-NP can be defined as, where P is the class of all feasibly (polynomial-time) decidable languages.The polynomial hierarchy can be defined recursively as Note thatThis definition reflects the close connection between the polynomial hierarchy and the arithmetical hierarchy, where R and RE play roles analogous to P and NP, respectively.An alternating Turing machine is a non-deterministic Turing machine with non-final states partitioned into existential and universal states.to be the class of languages accepted by an alternating Turing machine in polynomial time such that the initial state is an existential state and every path the machine can take swaps at most k – 1 times between existential and universal states.[4] If we omit the requirement of at most k – 1 swaps between the existential and universal states, so that we only require that our alternating Turing machine runs in polynomial time, then we have the definition of the class AP, which is equal to PSPACE.The definitions imply the relations: Unlike the arithmetic and analytic hierarchies, whose inclusions are known to be proper, it is an open question whether any of these inclusions are proper, though it is widely believed that they all are.[6] In particular, we have the following implications involving unsolved problems: The case in which NP = PH is also termed as a collapse of the PH to the second level.The case P = NP corresponds to a collapse of PH to P. The question of collapse to the first level is generally thought to be extremely difficult.Most researchers do not believe in a collapse, even to the second level.It is known that PH is contained within PSPACE, but it is not known whether the two classes are equal.One useful reformulation of this problem is that PH = PSPACE if and only if second-order logic over finite structures gains no additional power from the addition of a transitive closure operator over relations of relations (i.e., over the second-order variables).[8] If the polynomial hierarchy has any complete problems, then it has only finitely many distinct levels.-complete problem for some k.[9] Each class in the polynomial hierarchy containsFurthermore, each class in the polynomial hierarchy is closed underIn other words, if a language is defined based on some oracle in C, then we can assume that it is defined based on a complete problem for C. Complete problems therefore act as "representatives" of the class for which they are complete.The Sipser–Lautemann theorem states that the class BPP is contained in the second level of the polynomial hierarchy.Toda's theorem states that the polynomial hierarchy is contained in P#P.