P and NP A
decision problem is a problem that takes as input some
string w over an alphabet Σ, and outputs "yes" or "no". If there is an
algorithm (say a
Turing machine, or a
computer program with unbounded memory) that produces the correct answer for any input string of length
n in at most
cnk steps, where
k and
c are constants independent of the input string, then we say that the problem can be solved in
polynomial time and we place it in the class P. Formally, P is the set of languages that can be decided by a deterministic polynomial-time Turing machine. Meaning, :\mathsf{P} = \{ L : L=L(M) \text{ for some deterministic polynomial-time Turing machine } M \} where :L(M) = \{ w\in\Sigma^{*}: M \text{ accepts } w \} and a deterministic polynomial-time Turing machine is a deterministic Turing machine
M that satisfies two conditions: •
M halts on all inputs
w and • there exists k \in N such that T_M(n)\in O(n^k), where
O refers to the
big O notation and ::T_M(n) = \max\{ t_M(w) : w\in\Sigma^{*}, |w| = n \} ::t_M(w) = \text{ number of steps }M\text{ takes to halt on input }w. NP can be defined similarly using nondeterministic Turing machines (the traditional way). However, a modern approach uses the concept of
certificate and
verifier. Formally, NP is the set of languages with a finite alphabet and verifier that runs in polynomial time. The following defines a "verifier": Let
L be a language over a finite alphabet, Σ.
L ∈ NP if, and only if, there exists a binary relation R\subset\Sigma^{*}\times\Sigma^{*} and a positive integer
k such that the following two conditions are satisfied: • {{tooltip|2=For all strings x in Σ*, x is in L if and only if there is a y in Σ* such that (x, y) is in R and the length of y is polynomial in the length of x|1=For all x\in\Sigma^{*}, x\in L \Leftrightarrow\exists y\in\Sigma^{*} such that (
x,
y) ∈
R and |y|\in O(|x|^k)}}; and • the language {{tooltip|2=L[R], consisting of x followed by y with a delimiter in the middle"|1=L_{R} = \{ x\# y:(x,y)\in R\} over \Sigma\cup\{\#\}}} is decidable by a deterministic Turing machine in polynomial time. A Turing machine that decides
LR is called a
verifier for
L and a
y such that (
x,
y) ∈
R is called a
certificate of membership of
x in
L. Not all verifiers must be polynomial-time. However, for
L to be in NP, there must be a verifier that runs in polynomial time.
Example Let :\mathrm{COMPOSITE} = \left \{x\in\mathbb{N} \mid x=pq \text{ for integers } p, q > 1 \right \} :R = \left \{(x,y)\in\mathbb{N} \times\mathbb{N} \mid 1 Whether a value of
x is
composite is equivalent to of whether
x is a member of COMPOSITE. It can be shown that COMPOSITE ∈ NP by verifying that it satisfies the above definition (if we identify natural numbers with their binary representations). COMPOSITE also happens to be in P, a fact demonstrated by the invention of the
AKS primality test.
NP-completeness There are many equivalent ways of describing NP-completeness. Let
L be a language over a finite alphabet Σ.
L is NP-complete if, and only if, the following two conditions are satisfied: •
L ∈ NP; and • any
L′ in NP is polynomial-time-reducible to
L (written as L' \leq_{p} L), where L' \leq_{p} L if, and only if, the following two conditions are satisfied: • There exists
f : Σ* → Σ* such that for all
w in Σ* we have: (w\in L' \Leftrightarrow f(w)\in L); and • there exists a polynomial-time Turing machine that halts with
f(
w) on its tape on any input
w. Alternatively, if
L ∈ NP, and there is another NP-complete problem that can be polynomial-time reduced to
L, then
L is NP-complete. This is a common way of proving some new problem is NP-complete. ==Claimed solutions ==