Complexity Theory: Formalising Algorithms
Complexity Theory: Formalising Algorithms
Complexity Theory: Formalising Algorithms
Formalising Algorithms
Complexity Theory
Lecture 2 To prove a lower bound on the complexity of a problem, rather
than a specific algorithm, we need to prove a statement about all
algorithms for solving it.
In order to prove facts about all algorithms, we need a
mathematically precise definition of algorithm.
http://www.cl.cam.ac.uk/teaching/1011/Complexity/
For our purposes, a Turing Machine consists of: A complete description of the configuration of a machine can be
given if we know what state it is in, what are the contents of its
• Q — a finite set of states;
tape, and what is the position of its head. This can be summed up
• Σ — a finite set of symbols, including ⊔. in a simple triple:
• s ∈ Q — an initial state; Definition
• δ : (Q × Σ) → (Q ∪ {a, r}) × Σ × {L, R, S} A configuration is a triple (q, w, u), where q ∈ Q and w, u ∈ Σ⋆
Computations Computations
Given a machine M = (Q, Σ, s, δ) we say that a configuration The relation →⋆M is the reflexive and transitive closure of →M .
(q, w, u) yields in one step (q ′ , w′ , u′ ), written A sequence of configurations c1 , . . . , cn , where for each i,
ci →M ci+1 , is called a computation of M .
(q, w, u) →M (q ′ , w′ , u′ )
The language L(M ) ⊆ Σ⋆ accepted by the machine M is the set of
if strings
• w = va ;
{x | (s, ⊲, x) →⋆M (acc, w, u) for some w and u}
′
• δ(q, a) = (q , b, D); and
• either D = L and w′ = v u′ = bu
or D = S and w′ = vb and u′ = u
A machine M is said to halt on input x if for some w and u, either
or D = R and w′ = vbc and u′ = x, where u = cx. If u is
(s, ⊲, x) →⋆M (acc, w, u) or (s, ⊲, x) →⋆M (rej, w, u)
empty, then w′ = vb⊔ and u′ is empty.
Decidability Example
A language L ⊆ Σ⋆ is recursively enumerable if it is L(M ) for some Consider the machine with δ given by:
M.
⊲ 0 1 ⊔
A language L is decidable if it is L(M ) for some machine M which
halts on every input. s s, ⊲, R rej, 0, S rej, 1, S q, ⊔, R
q rej, ⊲, R q, 1, R q, 1, R q ′ , 0, R
A language L is semi-decidable if it is recursively enumerable.
q′ rej, ⊲, R rej, 0, S q ′ , 1, L acc, ⊔, S
The formalisation of Turing machines extends in a natural way to With any Turing machine M , we associate a function rIN → IN
multi-tape machines. For instance a machine with k tapes is called the running time if M .
specified by: r(n) is defined to be the largest value R such that there is a string
• Q, Σ, s; and x of length n so that the computation of M starting with
configuration (s, ⊲, x) is of length R (i.e. has R successive
• δ : (Q × Σk ) → Q ∪ {a, r} × (Σ × {L, R, S})k
configurations in it) and ends with an accepting configuration.
Complexity Nondeterminism
For any function f : IN → IN, we say that a language L is in If, in the definition of a Turing machine, we relax the condition on
TIME(f (n)) if there is a machine M = (Q, Σ, s, δ), such that: δ being a function and instead allow an arbitrary relation, we
obtain a nondeterministic Turing machine.
• L = L(M ); and
• The running time of M is O(f (n)). δ ⊆ (Q × Σ) × (Q ∪ {a, r} × Σ × {R, L, S}).