# Polynomial hierarchy

In computational complexity theory, the polynomial hierarchy (sometimes called the polynomial-time hierarchy) is a hierarchy of complexity classes that generalize the classes P, NP and co-NP to oracle machines. It is a resource-bounded counterpart to the arithmetical hierarchy and analytical hierarchy from mathematical logic.

## Definitions

There are multiple equivalent definitions of the classes of the polynomial hierarchy.

1. For the oracle definition of the polynomial hierarchy, define
${\displaystyle \Delta _{0}^{\mathsf {P}}:=\Sigma _{0}^{\mathsf {P}}:=\Pi _{0}^{\mathsf {P}}:={\mathsf {P}},}$

where P is the set of decision problems solvable in polynomial time. Then for i ≥ 0 define

${\displaystyle \Delta _{i+1}^{\mathsf {P}}:={\mathsf {P}}^{\Sigma _{i}^{\mathsf {P}}}}$
${\displaystyle \Sigma _{i+1}^{\mathsf {P}}:={\mathsf {NP}}^{\Sigma _{i}^{\mathsf {P}}}}$
${\displaystyle \Pi _{i+1}^{\mathsf {P}}:={\mathsf {coNP}}^{\Sigma _{i}^{\mathsf {P}}}}$
where ${\displaystyle {\mathsf {P}}^{\rm {A}}}$ 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 classes ${\displaystyle {\mathsf {NP}}^{\rm {A}}}$ and ${\displaystyle {\mathsf {coNP}}^{\rm {A}}}$ are defined analogously. For example, ${\displaystyle \Sigma _{1}^{\mathsf {P}}={\mathsf {NP}},\Pi _{1}^{\mathsf {P}}={\mathsf {coNP}}}$, and ${\displaystyle \Delta _{2}^{\mathsf {P}}={\mathsf {P^{NP}}}}$ is the class of problems solvable in polynomial time with an oracle for some NP-complete problem.
2. For the existential/universal definition of the polynomial hierarchy, let L be a language (i.e. a decision problem, a subset of {0,1}*), let p be a polynomial, and define
${\displaystyle \exists ^{p}L:=\left\{x\in \{0,1\}^{*}\ \left|\ \left(\exists w\in \{0,1\}^{\leq p(|x|)}\right)\langle x,w\rangle \in L\right.\right\},}$
where ${\displaystyle \langle x,w\rangle \in \{0,1\}^{*}}$ is some standard encoding of the pair of binary strings x and w as a single binary string. L represents a set of ordered pairs of strings, where the first string x is a member of ${\displaystyle \exists ^{p}L}$, and the second string w is a "short" (${\displaystyle |w|\leq p(|x|)}$) witness testifying that x is a member of ${\displaystyle \exists ^{p}L}$. In other words, ${\displaystyle x\in \exists ^{p}L}$ if and only if there exists a short witness w such that ${\displaystyle \langle x,w\rangle \in L}$. Similarly, define
${\displaystyle \forall ^{p}L:=\left\{x\in \{0,1\}^{*}\ \left|\ \left(\forall w\in \{0,1\}^{\leq p(|x|)}\right)\langle x,w\rangle \in L\right.\right\}}$
Note that De Morgan's laws hold: ${\displaystyle \left(\exists ^{p}L\right)^{\rm {c}}=\forall ^{p}L^{\rm {c}}}$ and ${\displaystyle \left(\forall ^{p}L\right)^{\rm {c}}=\exists ^{p}L^{\rm {c}}}$, 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
${\displaystyle \exists ^{\mathsf {P}}{\mathcal {C}}:=\left\{\exists ^{p}L\ |\ p{\text{ is a polynomial and }}L\in {\mathcal {C}}\right\}}$
${\displaystyle \forall ^{\mathsf {P}}{\mathcal {C}}:=\left\{\forall ^{p}L\ |\ p{\text{ is a polynomial and }}L\in {\mathcal {C}}\right\}}$
Again, De Morgan's laws hold: ${\displaystyle {\mathsf {co}}\exists ^{\mathsf {P}}{\mathcal {C}}=\forall ^{\mathsf {P}}{\mathsf {co}}{\mathcal {C}}}$ and ${\displaystyle {\mathsf {co}}\forall ^{\mathsf {P}}{\mathcal {C}}=\exists ^{\mathsf {P}}{\mathsf {co}}{\mathcal {C}}}$, where ${\displaystyle {\mathsf {co}}{\mathcal {C}}=\left\{L^{c}|L\in {\mathcal {C}}\right\}}$. The classes NP and co-NP can be defined as ${\displaystyle {\mathsf {NP}}=\exists ^{\mathsf {P}}{\mathsf {P}}}$, and ${\displaystyle {\mathsf {coNP}}=\forall ^{\mathsf {P}}{\mathsf {P}}}$, where P is the class of all feasibly (polynomial-time) decidable languages. The polynomial hierarchy can be defined recursively as
${\displaystyle \Sigma _{0}^{\mathsf {P}}:=\Pi _{0}^{\mathsf {P}}:={\mathsf {P}}}$
${\displaystyle \Sigma _{k+1}^{\mathsf {P}}:=\exists ^{\mathsf {P}}\Pi _{k}^{\mathsf {P}}}$
${\displaystyle \Pi _{k+1}^{\mathsf {P}}:=\forall ^{\mathsf {P}}\Sigma _{k}^{\mathsf {P}}}$
Note that ${\displaystyle {\mathsf {NP}}=\Sigma _{1}^{\mathsf {P}}}$, and ${\displaystyle {\mathsf {coNP}}=\Pi _{1}^{\mathsf {P}}}$. This 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. The analytic hierarchy is also defined in a similar way to give a hierarchy of subsets of the real numbers.
3. An equivalent definition in terms of alternating Turing machines defines ${\displaystyle \Sigma _{k}^{\mathsf {P}}}$ (respectively, ${\displaystyle \Pi _{k}^{\mathsf {P}}}$) as the set of decision problems solvable in polynomial time on an alternating Turing machine with k alternations starting in an existential (respectively, universal) state.

## Relations between classes in the polynomial hierarchy

Commutative diagram equivalent to the polynomial time hierarchy. The arrows denote inclusion.

The definitions imply the relations:

${\displaystyle \Sigma _{i}^{\mathsf {P}}\subseteq \Delta _{i+1}^{\mathsf {P}}\subseteq \Sigma _{i+1}^{\mathsf {P}}}$
${\displaystyle \Pi _{i}^{\mathsf {P}}\subseteq \Delta _{i+1}^{\mathsf {P}}\subseteq \Pi _{i+1}^{\mathsf {P}}}$
${\displaystyle \Sigma _{i}^{\mathsf {P}}={\mathsf {co}}\Pi _{i}^{\mathsf {P}}}$

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. If any ${\displaystyle \Sigma _{k}^{\mathsf {P}}=\Sigma _{k+1}^{\mathsf {P}}}$, or if any ${\displaystyle \Sigma _{k}^{\mathsf {P}}=\Pi _{k}^{\mathsf {P}}}$, then the hierarchy collapses to level k: for all ${\displaystyle i>k}$, ${\displaystyle \Sigma _{i}^{\mathsf {P}}=\Sigma _{k}^{\mathsf {P}}}$. In particular, if P = NP, then the hierarchy collapses completely.

The union of all classes in the polynomial hierarchy is the complexity class PH.

## Properties

 Unsolved problem in computer science:${\displaystyle {\mathsf {PH}}{\overset {?}{=}}{\mathsf {PSPACE}}}$(more unsolved problems in computer science)

The polynomial hierarchy is an analogue (at much lower complexity) of the exponential hierarchy and arithmetical hierarchy.

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.

If the polynomial hierarchy has any complete problems, then it has only finitely many distinct levels. Since there are PSPACE-complete problems, we know that if PSPACE = PH, then the polynomial hierarchy must collapse, since a PSPACE-complete problem would be a ${\displaystyle \Sigma _{k}^{\mathsf {P}}}$-complete problem for some k.

Each class in the polynomial hierarchy contains ${\displaystyle \leq _{\rm {m}}^{\mathsf {P}}}$-complete problems (problems complete under polynomial-time many-one reductions). Furthermore, each class in the polynomial hierarchy is closed under ${\displaystyle \leq _{\rm {m}}^{\mathsf {P}}}$-reductions: meaning that for a class C in the hierarchy and a language ${\displaystyle L\in {\mathcal {C}}}$, if ${\displaystyle A\leq _{\rm {m}}^{\mathsf {P}}L}$, then ${\displaystyle A\in {\mathcal {C}}}$ as well. These two facts together imply that if ${\displaystyle K_{i}}$ is a complete problem for ${\displaystyle \Sigma _{i}^{\mathsf {P}}}$, then ${\displaystyle \Sigma _{i+1}^{\mathsf {P}}={\mathsf {NP}}^{K_{i}}}$, and ${\displaystyle \Pi _{i+1}^{\mathsf {P}}={\mathsf {coNP}}^{K_{i}}}$. For instance, ${\displaystyle \Sigma _{2}^{\mathsf {P}}={\mathsf {NP}}^{\mathsf {SAT}}}$. In 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.

Kannan's theorem states that for any k, ${\displaystyle \Sigma _{2}}$ is not contained in SIZE(nk).

Toda's theorem states that the polynomial hierarchy is contained in P#P.

## Problems in the polynomial hierarchy

• An example of a natural problem in ${\displaystyle \Sigma _{2}^{\mathsf {P}}}$ is circuit minimization: given a number k and a circuit A computing a Boolean function f, determine if there is a circuit with at most k gates that computes the same function f. Let C be the set of all boolean circuits. The language
${\displaystyle L=\left\{\langle A,k,B,x\rangle \in {\mathcal {C}}\times \mathbb {N} \times {\mathcal {C}}\times \{0,1\}^{*}\left|B{\text{ has at most }}k{\text{ gates, and }}A(x)=B(x)\right.\right\}}$

is decidable in polynomial time. The language

${\displaystyle {\mathit {CM}}=\left\{\langle A,k\rangle \in {\mathcal {C}}\times \mathbb {N} \left|{\begin{matrix}{\text{there exists a circuit }}B{\text{ with at most }}k{\text{ gates }}\\{\text{ such that }}A{\text{ and }}B{\text{ compute the same function}}\end{matrix}}\right.\right\}}$
is the circuit minimization language. ${\displaystyle {\mathit {CM}}\in \Sigma _{2}^{\mathsf {P}}(=\exists ^{\mathsf {P}}\forall ^{\mathsf {P}}{\mathsf {P}})}$ because L is decidable in polynomial time and because, given ${\displaystyle \langle A,k\rangle }$, ${\displaystyle \langle A,k\rangle \in {\mathit {CM}}}$ if and only if there exists a circuit B such that for all inputs x, ${\displaystyle \langle A,k,B,x\rangle \in L}$.
• A complete problem for ${\displaystyle \Sigma _{k}^{\mathsf {P}}}$ is satisfiability for quantified Boolean formulas with k alternations of quantifiers (abbreviated QBFk or QSATk). This is the version of the boolean satisfiability problem for ${\displaystyle \Sigma _{k}^{\mathsf {P}}}$. In this problem, we are given a Boolean formula f with variables partitioned into k sets X1, ..., Xk. We have to determine if it is true that
${\displaystyle \exists X_{1}\forall X_{2}\exists X_{3}\ldots f}$
That is, is there an assignment of values to variables in X1 such that, for all assignments of values in X2, there exists an assignment of values to variables in X3, ... f is true? The variant above is complete for ${\displaystyle \Sigma _{k}^{\mathsf {P}}}$. The variant in which the first quantifier is "for all", the second is "exists", etc., is complete for ${\displaystyle \Pi _{k}^{\mathsf {P}}}$.