1 Introduction To Complexity Theory: 1.1 Basic Notation
1 Introduction To Complexity Theory: 1.1 Basic Notation
denotes the set of all possible strings that can be composed from the symbols in , and
+
=
n+3 O(n), 4n
2
5n (n), and 3nlog n+2 (n). Also stricter variants
of O and are known. For any function f : IN IN, the set
o(f(n)) denotes the set of all functions g : IN IN with the property that lim
n
g(n)
f(n)
= 0;
and
(f(n)) denotes the set of all functions g : IN IN with the property that lim
n
f(n)
g(n)
= 0.
For example, it is also true that 2
n + 3 o(n) and 4n
2
5n (n), but 3n log n + 2 is
neither in o(n) nor in (n).
Although it is not correct from a formal point of view, one can often nd statements like
2
. q is the
current state of M,
1
2
is the string in
. In cases
where there is no risk of confusion, we will simply write instead of
M
or
instead of
M
. If
the Turing machine enters a state that has no following state, because is undened for it, the
Turing machine halts.
The language accepted by M, denoted L(M), is the set of those words in
that cause M
to enter a nal state. Formally,
L(M) = {w | w
and (q
0
, , w)
(p,
1
,
2
) for some p F and
1
,
2
} .
Given a TM accepting a language L, we assume without loss of generality that the TM halts
whenever the input is accepted. However, for words not accepted, it is possible that the TM
will never halt. If a Turing machine M halts on all inputs, we say that M decides L(M).
6
Multi-tape Turing machines
A multi-tape Turing machine consists of a nite control with k tape heads and k tapes; each
tape is innite in both directions (see Figure 2). On a single move, depending on the state of
the nite control and the symbol scanned by each of the tape heads, the machine can:
1. change state,
2. print a new symbol on each of the cells scanned by its tape heads, and
3. move each of its tape heads, independently, one cell to the left or right, or keep it stationary.
. . . . . .
. . . . . .
. . . . . .
finite control p
Figure 2: A multi-tape Turing machine.
Initially, the input appears on the rst tape, and the other tapes are blank. The rest is
a straightforward generalization of the denition of a single-tape TM. In the following, if we
simply speak about a Turing machine, we will always mean a multi-tape TM.
Recursively enumerable and recursive languages
A language that is accepted by a Turing machine is said to be recursively enumerable (r.e.). The
term enumerable derives from the fact that it is precisely these languages whose strings can be
enumerated (resp. listed) by a Turing machine. Recursively is a mathematical term predating
the computer, and its meaning is similar to what the computer scientist would call recursion.
Since, in contrast to Section 1.3, the term computationally enumerable is well-dened in the
context of Turing machines, we would now be able to study the problem whether all languages
are recursively enumerable. This, however, will be postponed to a later lecture.
An important subclass of the recursively enumerable languages are the so-called recursive
languages, which are those languages that have a Turing machine that decides it. Within
the recursive languages, languages are usually classied according to their time and/or space
requirements.
7
Time complexity
Consider some TM M. If for every input word of length n, M makes at most t(n) moves before
halting, then M is said to be a t(n) time-bounded Turing machine, or of time complexity t(n),
and the language accepted by M is said to be of time complexity t(n). The family of languages
of time complexity O(t(n)) is denoted by DTIME(t(n)). Such a family forms a complexity class.
The most important time complexity class is the class P that is dened as
P =
k1
DTIME(n
k
) .
Intuitively, P can be viewed as the class of all languages that can be solved eciently in a
deterministic way. If a language is in P, we say that it can be decided in (deterministic)
polynomial time.
Space complexity
If for every input word of length n, M visits at most s(n) cells before halting, then M is said to be
an s(n) space-bounded Turing machine, or of space complexity s(n), and the language accepted
by M is said to be of space complexity s(n). The family of languages of space complexity O(s(n))
is denoted by DSPACE(s(n)). The most important space complexity class is the class PSPACE
that is dened as
PSPACE =
k1
DSPACE(n
k
) .
If a language is in PSPACE, we say that it can be decided in (deterministic) polynomial space.
1.5 The probabilistic Turing machine
Apart from the basic, so-called deterministic Turing machine (DTM), other Turing machine
models have been constructed to include various characteristics. The most important of these
models are the probabilistic Turing machine, the nondeterministic Turing machine, and the
Quantum Turing machine
The single-tape probabilistic Turing machine (PTM) is dened similar to the single-tape
DTM:
M = (Q, , , , q
0
, B, F) ,
The only dierence is that is now a mapping from Q to 2
Q{L,N,R}
. That is, a move
does no longer have a unique outcome, but can have a set of outcomes that are equally likely
to be selected. Or, in other words, the PTM can have many dierent computational paths for
the same input. Thus, in contrast to the DTM presented previously, it can now happen that
for some PTM M and input x there are computations for which M started on x halts, and
computations for which M started on x does not halt. Furthermore, there may be computations
for which M started on x does accept, and for which M started on x does not accept. Single-
tape PTMs generalize to multi-tape PTMs in the same way as single-tape DTMs generalize to
multi-tape DTMs.
Several time complexity classes have been dened for (multi-tape) PTMs. We present the
two most important of these.
8
RP denotes the class of all languages L for which there is a polynomial time PTM so that
for every x L, Pr[M accepts x] 1/2, and
for every x L, Pr[M accepts x] = 0.
BPP denotes the class of all languages L for which there is a polynomial time PTM so
that
for every x L, Pr[M accepts x] 2/3, and
for every x L, Pr[M accepts x] 1/3.
It is not dicult to show that P RP BPP and that BPP PSPACE. BPP can be viewed
as the set of all languages that can be decided eciently by todays computers in polynomial
time. Important open problems are whether or not P = RP or RP = BPP.
1.6 The nondeterministic Turing machine
The (multi-tape) nondeterministic Turing machine (NTM) is dened in the same way as the
(multi-tape) PTM. The only dierence lies in how it accepts a word. We say that a NTM M
accepts input x if at least one computation of M started on x leads to a nal state. M decides a
language L if M halts on all inputs on all computational paths and accepts exactly those inputs
x with x L.
Time complexity
Consider some NTM M. If for every input word of length n, M makes at most t(n) moves
before halting, no matter which computational path it selects, then M is said to be a t(n)
time-bounded NTM, and the language accepted by M is said to be of nondeterministic time
complexity t(n). The family of languages of nondeterministic time complexity O(t(n)) is denoted
by NTIME(t(n)). The most important nondeterministic time complexity class is the class NP
that is dened as
NP =
k1
NTIME(n
k
) .
If a language is in NP, we say that it can be decided in nondeterministic polynomial time. It
is not hard to see that RP NP and that NP PSPACE. Furthermore, it is widely believed
that P = NP and NP = PSPACE, but nobody can prove it yet.
Space complexity
If for every input word of length n, M visits at most s(n) cells before halting, no matter which
computational path it selects, then M is said to be an s(n) space-bounded NTM, and the language
accepted by M is said to be of nondeterministic space complexity s(n). The family of languages
of nondeterministic space complexity O(s(n)) s(n) is denoted by NSPACE(s(n)). The most
important nondeterministic space complexity class is the class NSPACE that is dened as
NPSPACE =
k1
NSPACE(n
k
) .
9
If a language is in NPSPACE, we say that it can be decided with nondeterministic polynomial
space. Obviously, PSPACE NPSPACE.
1.7 The Quantum Turing machine
The Quantum Turing machine (QTM) is a Turing machine that can perform Quantum mechan-
ical operations. It will be described in more detail later. We only mention here that QP is the
class of all languages that can be decided by some Quantum Turing machine in polynomial time.
1.8 Turing machines as algorithms
Turing machines are ideal for solving string problems (such as, for instance, the problem given
in the assignment). But how about developing algorithms capable of attacking problems whose
instances are mathematical objects such as graphs, networks, and numbers? To solve such a
problem by a Turing machine, we must decide how to represent by a string an instance of the
problem. Once we have xed this representation, an algorithm for a decision problem can be
easily transformed into a Turing machine that decides the corresponding language. It should
be clear that every nite mathematical object can be represented by a nite string over an
appropriate alphabet. For example, elements of nite sets, such as the nodes of a graph, can
be represented as integers in binary. Pairs and k-tuples of simpler mathematical objects are
represented by using set brackets, and so on. Or, perhaps, a graph can be represented by its
adjacency matrix.
There is a wide range of acceptable representations of integers, nite sets, graphs, and other
elementary objects. All of these acceptable encodings have to be polynomially related. That is,
if A and B are both reasonable representations, then |A| should be at most polynomially larger
than |B|. Representing numbers in unary, for instance, is not an acceptable representation, since
it requires exponentially more symbols than the binary representation. For the mere question
of computability, representation is not an important issue, but in order to determine whether a
problem is eciently computable, the encoding has to be acceptable.
Having this in mind, we will work in the following with mathematical objects instead of
strings and with algorithms instead of Turing machines.
1.9 References
R. Gandy. The conuence of ideas in 1936. In: The Universal Turing Machine: A Half-
Century Survey, R. Herken (ed.), Oxford Press, Oxford, 1988, pp. 55-111.
J.E. Hopcroft and J.D. Ullman. Introduction to Automata Theory, Languages, and Com-
putation. Addison Wesley, Reading, 1979.
C.H. Papadimitriou. Computational Complexity. Addison Wesley, Reading, 1994.
10