Introduction to CS Theory
-
Upload
kadeem-mullen -
Category
Documents
-
view
30 -
download
1
description
Transcript of Introduction to CS Theory
Introduction to CS Theory
Lecture 15 – Turing MachinesPiotr [email protected]
Our Models of Computation So Far
Models of computation Finite automata Pushdown automata
Restrictions FA
Finite memory Left-to-right access to
input PDA
Infinite memory… … but accessible only
in a stack form Left-to-right access to
input
Unrestricted model of computation? Turing machine
δ, q
…0 0 1 1 0 0 0
Church-Turing Thesis
Church-Turing Thesis A language can be
solved by an algorithm if and only if it can be accepted by a Turing machine that terminates on every output.
How to validate Church-Turing Thesis? Many models of
algorithms Unrestricted grammars Lambda calculus RAM machines … all equivalent to
Turing machines
Can Church-Turgin thesis be proven?
Turing machines were, at the time, the most convincing model
Definition
Turing machine M is a quintuple M = (Q, Σ, Γ, q0, δ) where:
Q – finite set of states, assumed not to contain the two halting states, ha and hr.
Σ is the input alphabet and Γ is the tape alphabet. Σ Γ. Γ does not contain the special blank symbol Δ
q0 – the initial state δ – the transition function
δ: Q (Γ {Δ}) (Q {ha, hr}) (Γ {Δ}) {R, L, S}
δ is a total funciton (i.e., your machine should not get stuck in a non-halting state without knowing what to do)
Transition of a TM
δ(q, X) = (p, Y, D) means: If the machine is in state
q, scanning symbol X, then:
Change state to p Replace symbol X with
symbol Y Move the tape according
to the direction D (L – left, R – right, S – stay)
Questions What happens if the
machine “falls off” the left side of the tape?
Do we really need the “S” move?
Example Strings of length 2n
Turing machine for the palindromes language
Configurations
Configuration of a Turing machine Contents of the tape Position of the head Current state
Notation (q, xay) means that
Machine in state q The head is at the last
symbol of the string xa
The head is followed by string y, followed by an infinte number of blank symbols
Initial configuration (q0, Δx) x – machines’s input
string
Given a Turing machine T, we define relation (q,xay) (p,zbw) If the latter can be
obtained in one step from the former
Languages Accepted by TMs
Definition. Let M = (Q, Σ, Γ, q0, δ)
and let x Σ*
x is accepted by M if
(q0, Δx) * (ha, yaz)
for some y,a, z
A string can be rejected if: M ends up in state hr, or M runs forever on x
Notation L(M) – language
accepted by a Turing machine M
If a language is accepted by a Turing machine then we say that it is recursively enumerable
The set of all languages accetped by Turing machines is called RE
If a language is accepted by a Turing machine that halts on all inputs then we say that it is recursive
Examples
Give a Turing machine for the following language
{ aibici | i ≥ 0 }
Computing a Function on a TM
Definition Let M = (Q, Σ, Γ, q0, δ) be a TM Let f: Σ* Γ* be a total function We say that M computes f if for each x in Σ* it holds
that(q0, Δx) * (ha,Δf(x))
Example Give a TM that computes f(1n) = 12n
Power of Turing Machines
We can add extra features to a Turing machine 2-way infinite tape More than one tape Random access to the
memory Nondeterminisms 2-dimensional tape
Example: Try to simulate these
features (or prove that simulation is possible)
None of the extra features strengthens the model!
Languages and Decision Problems
Decision problem Name Input
the mathematical entities about whose properties we ask
Question A well-defined yes/no
question
Language A set of strings Languages encode
decision problems
Example Name: Connectivity Input: Graph G, vertices
s and t Question: Are vertices s
and t connected in G
Languages and Decision Problems
Our two fundamental questions What decision problems
can and cannot be solved?
What decision problem can and cannot be solved efficiently
We focus on languages
Chomsky Hierarchy
Models of computation Regular languages /
finite automata Context-free
languages / push-down automata
Turing machines
Hierarchy of Languages
Finite languages
Context-freelanguages
Recursive languages
All languages
Undecidable Languages
Can everything be solved on a computer? Recursive languages Recursively enumerable
languages do they really exist?
Two proofs… Counting… And an example of a
language