Professional Documents
Culture Documents
Semantik - Berechenbarkeit - Komplexitätstheorie - Teil 11 Komplexitätstheorie
Semantik - Berechenbarkeit - Komplexitätstheorie - Teil 11 Komplexitätstheorie
28.6.20
1. Motivation
2. First example
A well-known example for the consideration of effort to solve a problem is the
travelling salesman problem:
A salesman living in Deggendorf visits several customers in different cities and
tries to find the best (e.g. shortest or fastest) way to visit all of them. The following
picture shows the (fictional) highway connections between these cities (without
the distances).
Is this problem solvable?
What approach can be taken to find the best way?
Obviously the problem can easily be solved in a naïve way. The salesman starts
in Deggendorf. From Deggendorf Berlin, München and Hamburg can be reached.
From Berlin Hamburg and Regensburg and Deggendorf can be reached and so
on. It all combinations are tried out the best way can be found. The problem is the
number of possible combinations that is increasing “dramatically” with the number
of cities and connections between them. If the situation gets more complex, i.e.
more cities and different ways between them, the number of possible ways to visit
all customers makes an analytical solution impossible. The reason is here the
exponentially increasing runtime.
The question if the traveling salesman problem can be solved with an effort
“below exponential” is not yet answered.
3. Theoretical Approach
This chapter gives some ideas how to bring the problem of complexity in a formal
context.
Definition:
Let f : be a total function over the natural numbers. ( including 0)
The class TIME(f (n)) is the set of all languages A where a deterministic multi-tape
Turing Machine M exists with A = T(M) (i.e. M comes to an end with an input out
of A) and time(M(x)) f (|x|) words x.
(timeM(x) is the number of calculation steps performed by M with input x, |x| is the
length of x)
This definition allows to classify the effort to solve a problem1 using a Turing
Machine. (A more practical definition is given with the classes O(f(n)) below.)
Definition:
P := { A | Turing Machine M and a polynom p with T(M) = A and time M(x) p(|x|))
1
„language can be replaced by „problem“
Intuitively spoken, P contains all problems that can be solved by “efficient“
algorithms (efficient = max. polynomial effort).
Definition:
Let f, g : be functions ( including 0)
One writes f(n) O(g(n)) if and only if there is a positive constant c such that
for all sufficiently large values of n, the value of f(n) is at most c multiplied by
the value of g(n).
f(n) O(g(n)) c , n0 : f(n) c * g(n) n n0
Remark: The ‘O‘ stands here for “Order“ (in German “Ordnung“)
This still rather formal definition can be applied to problems and algorithms in a
more simplified way where c is set to 1 and g is a rather simple function.
For the relation between polynomial effort and exponential effort the following
(mathematical) relation is important:
In terms of the definition above, this means that for a given natural number l there
is a n0 and a natural number c so that nl ≤ c * qn n n0
Spoken in words, this means that any exponential function (basis > 1) grows faster than
any polynomial if the exponent n exceeds a limit value.
Example:
• Let l be 5 and q be 2 then n5 ≤ 2n for n 25
Using the above O-notation definition both problems and algorithms can be
analyzed related to their runtime. The analysis does not provide a concrete
runtime (e.g. runtime in seconds2) but describes how the runtime changes with
changes in the input size.
Examples:
sorting algorithms: quicksort O(n log(n)) (in „normal cases“), bubblesort
O(n2)
There is no known algorithm to solve the Travelling-Salesman-Problem
with polynomial runtime
The Travelling-Salesman-Problem can be solve with algorithms in
exponential runtime, i.e. O(cn), with c > 1.
2
A concrete runtime would make sense for an existing computer but not for a theoretical consideration.
n describes here the „size“ of the input
O(1) 1 1000000
The table shows the effort for “exponential problems” increases “dramatically”
with the input size and cannot be handled any more in a reasonable time. E.g.
to solve the Travelling-Salesman-Problem with 20 cities takes 1000000 steps.
In the chapter with the theory of Turing Machines there was a short
presentation about non-deterministic Turing Machines. This definition can also
be used to define a problem class in the theory of complexity:
Definition:
Now we define the class of all languages that are accepted by
nondeterministic Turing Machines with polynomial runtime limitation:
let f: ( including 0) a total function.
The class NTIME(f (n)) consists of all languages A for that a non-deterministic
multi-tape Turing Machine M exists with A = T(M) and ntimeM(x) f(|x|) for all
words x.
Definition:
Complexity class NP
NP := NTIME(p(x))
p polynomial
Remark:
obviously P NP
but it is unknown P NP
The SAT-problem can be solved with exponential effort, but it can be decided
with polynomial effort if a set of values satisfies the boolean formula, i.e. SAT
is element of NP (it is even NP-complete).
The class NP contains (intuitively) all problems, for that a possible solution can
be guessed and the correctness of the guessing can be determined with
polynomial effort.
(the name NP comes from nondeterministic polynomial. This means that a
nondeterministic Turing Machine can guess a possible result and find out with
polynomial effort, if this is a solution or not)
This leads to the question if there are problems where it is more complex to
find a solution than to evaluate if a possible solution is correct, i.e. P NP ?
3
in this case the formula is satisfiable, therefor the name SAT
Reducability
x A f(x) B
If A p B then
B P A P (i.e. if B can be calculated with polynomial effort that A can
be calculated with polynomial effort)
B NP A NP (i.e. if B is in the class of the most complex problem then
A is in the same class)
TMB has polynomial runtime p(|x|), f has polynomial runtime q(|x|), this means
that TMA has polynomial runtime p(|x|) + q(|x|), as p and q are polynoms.
Remark: Here also the word “language” can be replaced by the word
“problem”.
Instead of …