Let us fix a finite alphabet Σ0 and consider a language L over it. Let us investigate first,
what it really means if L is recognizable within some time by a non-deterministic Turing machine. We will show that this is connected with how easy it is to “prove” for a word that it is inL.
Letfandgbe two functions withg(n)≥n. We say that the languageL0∈DTIME(g(n))
is awitnessof lengthf(n) and timeg(n) for languageLif we havex∈ Lif and only if there is a word y ∈ Σ∗
0 with |y| ≤ f(|x|) and x&y ∈ L0. (Here, & is a new symbol serving the
separation of the wordsxand y.) Theorem 6.2.1
• Every language L ∈NTIME(f(n))has a witness of lengthO(f(n))and timeO(n). • If languageLhas a witness of lengthf(n)and timeg(n)thenLis inNTIME(g(f(n) +
n+ 1)).
Proof. 6.2.1: LetT be the nondeterministic Turing machine recognizing the languageLin timef(n) with, say, two tapes. Following the pattern of the proof of Theorem 6.1.1, let us assign to each word xin Lthe description of a legal computation of T accepting xin time
f(|x|). It is not difficult to make a Turing machine deciding about a string of lengthN in
O(N) steps whether it is the description of a legal computation and if yes then whether this computation accepts the wordx. Thus, the witness is composed of the pairsx&y wherey is a legal computation acceptingx.
6.2.1 Let L0 be a witness of L with length f(n) and time g(n), and consider a deter-
ministic Turing machine S deciding L0 in time g(n). Let us construct a non-deterministic
Turing machineT doing the following. Ifxis written on its first tape then it first computes (deterministically) the value of f(|x|) and writes this many 1’s on the second tape. Then it writes symbol & at the end of x and makes a transition into its only state in which its behavior is nondeterministic. While staying in this state it writes a wordy of lengt at most
f(|x|) after the word x&. This happens as follows: while it reads a 1 on the second tape it has |Σ0|+ 1 legal moves: either it writes some symbol of the alphabet on the first tape,
moves right on the first tape and left on the second tape or it writes nothing and makes a transition into state START2.
From state START2, on the first tape, the machine moves the head on the starting cell, erases the second tape and then proceeds to work as the Turing machineS.
6.2. WITNESSES AND THE COMPLEXITY OF NON-DETERMINISTIC ALGORITHMS91 This machineT has an accepting legal computation if and only if there is a wordy∈Σ∗
0
of length at most f(|x|) for which S accepts word x&y, i.e. if x∈ L. The running time of this computation is obviously at mostO(f(|x|)) +g(|x|+ 1 +f(|x|)) =O(g(|x|+ 1 +f(x))). ¤
Corollary 6.2.2 For an arbitrary languageL ⊆Σ∗
0, the following properties are equivalent:
• Lis recognizable on a non-deterministic Turing machine in polynomial time.
• Lhas a witness of polynomial length and time.
Remark 6.2.1 We mention it without proof (even without exact formulation) that these properties are also equivalent to the following: one can give a definition of L in the formal axiom system of set theory such that, for a wordx∈ L, the statement “x∈ L” can be proved from the axioms of set theory in a number of steps polynomial in|x|.
We denote the class of languages having the property stated in Corollary 6.2.2 by NP. The languagesLwhose complement Σ∗
0\ Lis in NP form the class co−NP. As we mentioned
earlier, with these classes of languages, what is easy is not the solution of the recognition problem of the language, only the verification of the witnesses for the soluton. We will see later that these classes are fundamental: they contain a large part of the algorithmic problems important from the point of view of practice.
Figure 6.1 illustrates the relationship between the classes P, NP and co-NP. Note the similarity with Figure 3.1 in Chapter 2. There are, however, significant differences. First, we don’t know whether or not P fills the whole intersection NP∩co−NP. Second, we don’t know whether the difference NP\co−NP is empty or nonempty (i.e., it could be that NP = co−NP). We’ll discuss this issue later.
Many important languages are given by their witnesses—more precisely, by the language L0and functionf(n) in our definition of witnesses (we will see many examples for this later).
In such cases we are asking whether a given wordxis inL (i.e. , whether there is ay with |y| ≤f(n) andx&y∈ L0). Without danger of confusion, the wordy itself will also be called
thewitness word, or simply witness, belonging toxin thewitness language L. Very often, we are not only interested whether a witness word exists but would also like to produce one. This problem can be called thesearch problembelonging to the languageL. There can be, of course, several search problems belonging to a language. A search problem can make sense even if the corresponding decision problem is trivial. For example, every natural number has a prime decomposition but this is not easy to find.
P
NP
co-NP
Figure 6.1: The classes of NP and co-NP
Since every deterministic Turing machine can be considered non-deterministic it is obvious that
DTIME(f(n))⊆NTIME(f(n)).
In analogy with the fact that there is a recursively enumerable but not recursive lan- guage (i.e. , without limits on time or storage, the non-deterministic Turing machines are “stronger”), we would expect that the above inclusion is strict. This is proved, however, only in very special cases (e.g., in case of linear functions f, by Paul, Pippenger, Trotter and Szemeredi). Later, we will treat the most important special case, the relation of the