Computability and Complexity Notes
Introduction
This is the course notes for Computability and Complexity by Prof. Dr. Peter Zaspel at Jacobs University Bremen.
Computability Theory
The Church-Turing Thesis
There exists
- an intuitive idea of an algorithm and
- a formalization via DTM/NTM/RAM
The hypothesis that both are equal is called Church-Turing Thesis.
Turing Machines
-
Formal definition of a TM:
- A Turing machine is a 7-tuple, , where are all finite sets and
- is the set of states
- is the input alphabet not containing the blank symbol
- is the tape alphabet, where and
- is the transition function
- is the start state
- is the accept state, where
- is the reject state.
- A Turing machine is a 7-tuple, , where are all finite sets and
-
Configuration of a TM:
- Let M be a TM, and . The setting is a configuration of the TM, where
- is the current tape content to the left of the head
- is the current state
- is the current tape content below () and to the right of the head (being terminated by blanks )
- Let M be a TM, and . The setting is a configuration of the TM, where
-
A configuration yields a configuration if M can legally move from to in a single step.
- Leftward move: yields iff
- Rightward move: yields iff
- L-move, left tape end: yields iff
- R-move, left tape end: yields iff
-
Characterization of configuration:
- Start configuration: , i.e. head is at leftmost end of tape
- Accepting configuration:
- Rejecting configuration:
- Halting configuration: accepting or rejecting configuration
- Remark: there’s exactly one accepting/rejecting state, but there can be many accepting/rejecting configurations.
-
Accepted input and recognized language:
- M accepts if a sequence of configurations exists, such that
- is the start configuration
- yields
- is the accepting configuration
- The language of M is . We say L is recognized by M.
- M accepts if a sequence of configurations exists, such that
-
Turing-recognizable or recursively enumerable language, if some TM recognizes it.
-
M halts on if a sequence of configurations exists, such that
- is the start configuration
- yields
- is the halting configuration
-
Decider: if it halts on all inputs . A decider M that recognizes L is said to decide L.
-
Decidable/Recursive/Turing-decidable language: if there exists a TM (i.e. a decider) that decides it.
Variants of Turing Machines
- All variants have the same power as a standard TM.
Mutlitape TM
-
The definition differs from the standard TM that:
-
For every multitape TM M, there exits a single-tape TM S that recognizes the same language.
-
Turing-recognizable iff some multitape TM recognizes it.
Nondeterministic TM
-
The definition differs from the standard TM that:
-
For definition of yielding configurations, it differs from the standard TM that we need to change from to . (One config can yield several or no config.)
-
Exactly the same definition for accepted input and recognized language.
-
For every NTM N, there exists a deterministic (single-tape) TM S that recognizes the same language.
-
Turing-recognizable iff some NTM recognizes it.
-
Nondeterministic decider: if all branches halt on all inputs.
Random Access Machine
-
k - command counter; a - accumulator; c - register; x - input; - position on input; y - output.
-
Some commands:
- read:
- print a:
-
Input tape: read-only and read once, can only move to the right
-
Program: finite sequence of commands.
-
There exists a RAM that terminates and outputs 1 whenever a TM M accepts. The RAM terminates and outputs 0 whenever M rejects.
-
Let R be an RAM. For an arbitrary input x it outputs y(x). There exists a multi-tape TM that accepts the input x after writing y(x) on one of its tapes.
-
TMs and RAMs have the same expressive power.
Decidability
Decidable Languages
-
The language is decidable. (The problem of testing whether a given DFA accepts a given string is decidable.)
-
The language is decidable. (Convert to NFA to DFA.)
-
The language is decidable. (Convert R to DFA.)
-
The language is decidable. (No accept states are marked.)
-
The language is decidable. (Build C that’s empty iff A=B. Use on C.)
-
The language is decidable. (Convert G to CFG in Chomsky Normal Form; enumerate all derivations within 2n-1 steps.)
-
The language is decidable. (Mark all terminal symbols. Follow the rules until no new variables are marked. If the start symbol is not marked, accept.)
-
But is not decidable.
-
Every context-free language L is decidable. (Build a TM with CFG G with )
Undecidability of
-
The language is undecidable. (Proof by diagonalization. A TM D() that accept if M doesn’t accept , which leads to contradiction.)
-
The language is Turing-recognizable. (Build TM U. Simulate M on w. If M accepts, U accepts. If M rejects, U rejects.) (U is an instance of Universal TM) (U can run forever.)
-
Sets:
- A and B have the same size/cardinality if there exists a bijective function f with .
- A is countable if it’s either finite or has the same size as . Otherwise it’s uncountable.
- The set of rational numbers is countable.
- The set of real numbers is uncountable. (Proof by diagnolization.)
-
There exist languages that are not Turing-recognizable.
- Fixing a non empty alphabet , the set of all TMs over is countable. (M can be mapped to binary strings, which are countable (enumerate).)
- The set of all infinite binary sequences is uncountable. (Proof by diagnolization.)
- Fixing a non-empty alphabet , the set of all languages over is uncountable. (Construct a bijection between the set of all languages of and to have the characteristic string. The latter is uncountable, the former is also uncountable.)
- The set of TMs is countable but the set of languages is uncountable. So there are languages not described by TMs.
A Turing-Unrecognizable Language
-
L is co-Turing-recognizable if is Turing-recognizable.
-
A language is decidable iff it’s Turing-recognizable and co-Turing-recognizable. (Run two TMs in parallel.)
-
The language is not Turing recognizable. (L is undecidable L not Turing recognizable not Turing recognizable not Turing recognizable)
Reducibility
-
The language is undecidable. (Proof by contradiction. Assume there’s a decider R for . Construct a decider for (“R rejects, reject” eliminates the loop case.))
-
A Computable function f there exists some TM M, on every input w, halts with just f(w) on its tape.
-
A is mapping reducible to B () if there’s a computable function f between them. f is called a reduction from A to B.
-
If and B is decidable, A is decidable.
-
If and A is undecidable, B is undecidable.
-
We can also prove to be undecidable by finding a reduction from . ()
-
The language is undecidable.
-
If and B is Turing-recognizable, A is Turing-recognizable.
-
If and A is not Turing-recognizable, B is not Turing-recognizable.
-
The language is not Turing-recognizable. (Proof by ( rejects everything and accepts if M accepts w.))
Complexity Theory
Time Complexity
Measuring Complexity
-
The running time or time complexity of M is the function f(n)’s maximum number of steps that M uses on any input of length n. (Worst case.)
-
Big O and small o:
- Big O - there exists a number c and
- Small o - for any c > 0 there exists
-
Polynomial bound and exponential bound:
- Polynomial bound -
- Exponential bound -
-
The time complexity class TIME(t(n)) is the set of all languages that are decidable by an O(t(n)) time single-tape DTM.
-
For every t(n) time deterministic multi-tape TM there exists an equivalent time deterministic single-tape TM.
- This only gives existence. But there can be better implementations.
-
The running time of nondeterministic decider N is the maximum number of steps f(n) uses on any branch.
-
For every t(n) NTM there exists an equivalent time DTM. (By BFS.)
The Class P
-
-
The PATH problem/language is The language . (BFS)
-
. (Euclidean algorithm to find the gcd (log depth, unary -> O(n)).)
-
Every context-free language is in P. (DP.)
The Class NP
-
The nondeterministic time complexity class NTIME(t(n)) is the set of all languages that are decidable by an O(t(n)) time NTM.
-
-
-
A verifier for a language A is a deterministic decider that takes as input such that it holds: iff there exists c such that is accepted by . c is called certificate.
-
is a polynomial time verifier if it has a polynomial running time in the size of its input. A is called polynomially verifiable if there exists a polynomial time verifier for it.
-
An alternative definition for NP: NP is the class of languages for which there exist polynomial time verifiers.
-
There exists a polynomial time verifier for A iff there exists a nondeterministic polynomial time TM that recognizes A.
-
A Hamiltonian path in G is a directed path that goes through each node exactly once. .
-
A clique is a subgraph such that there exist edges between all paris of nodes. A k-clique is a clique with k vertices.
-
Polynomial Time Reducibility
-
A is polynomial time (mapping) reducible to B () if there’s a polynomial time computable function such that iff .
-
If and , then .
NP-completeness
-
A language B is NP-complete if:
- and
- for all
-
If B is NP-complete and , then .
-
If B is NP-complete and for a , then C is also NP-complete.
-
F is satisfiable if F has at least one model.
-
Cook-Levin: is NP-complete. The proof:
-
is NP-complete.
-
For all boolean formulas F in CNF there exists a boolean formula in 3CNF such that F is satisfiable iff is satisfiable. can be built from F in polynomial time.
-
CLIQUE is NP-complete. (Proof )
Hierarchy Theorems
-
Time constructible: f(n) at least . f is time constructible if a computable function exists that maps the string (the unary representation) to the binary representation of f(n) in time . (output could also be unary.) (normal functions are all time constructible)
-
Let f be a time-constructible function. There exists a language A that’s decidable in but not decidable in time . (By increasing the time complexity by more than a logarithm of it, we increase the size of the time complexity class.)
-
Let be time-constructible and , then
-
For and at least in , it holds
-
.
-
. (Even if P=NP, there are problems of exponential runtime.)
Space Complexity
Measuring Space Complexity
-
Space complexity is the maximum number of tape cells that are scanned by M for an arbitrary input o length n.
-
SPACE(f(n)) is the set of all languages decided by DTM.
-
.
-
NSAPCE is the set of all languages decided by NTM.
-
The language .
-
f(n) at least . F is space constructible if a computable function exists that maps the string (the unary representation) to the binary representation of f(n) in space .
-
Savitch’s Theorem: .
- Proof: Instead of calculating all branches, ask whether start config yields accepting config and check recursively, which leads to space reuse.
PSPACE and Related Classes
-
(deterministic)
-
(non-deterministic)
-
-
and and .
-
PSPACE-complete if:
- and
- for all (only poly-time reduction; using poly-space would be as hard as the full class)
-
The language is PSPACE-complete.
-
(one of this subsets have to be a proper subset due to )
References
-
Introduction to the Theory of Computation by Michael Sipser
-
Course slides/notes from Prof. Dr. Peter Zaspel at Jacobs University Bremen.