Title: Computation Theory
1Computation Theory
- Introduction to Turing Machine
2Turing Machines
- Proposed by Alan Turing, 1936. England
- Turing Award
3Differences between finite automata and Turing
machine
- A Turing machine can both write on the tape and
read from it. - The read-write head can move both to the left and
to the right. - The tape is infinite.
- The special states for rejecting and accepting
take immediate effect.
4eg.
Consider a Turing machine M1 for testing
membership in the language Bww w?0,1
? 0 1 1 0 0 0 0 1 1 0 0 0 B ? X 1 1 0 0 0
0 1 1 0 0 0 B
? X 1 1 0 0 0 X 1 1 0 0 0 B ? X 1 1 0 0 0
X 1 1 0 0 0 B ? X X 1 0 0 0 X 1 1 0 0
0 B
? X X X X X X X X X X X X
B
5- M1 On input string w
- Scan the input to be sure that it contains a
single symbol. If not, reject. - Zig-zap across on either side to check on
whether these positions contain the same symbol.
If not, reject. Cross off symbols as they
checked. - If any symbols remain, reject otherwise accept.
6Formal definition of a Turing machine
- d QG? QGL,R
- transition function.
- d(q,a) (r,b,L)
r
b
7Def
- A Turing Machine is a 7-tuple (Q, S, G, S, q0,
qaccept, qreject), where Q, S, G are all finite
sets and - Q set of states,
- S the input alphabet NOT containing the special
blank symbol B, - G the tape alphabet, where B? G and S? G,
- dQG?QGL,R transition func.
- q0?Q is the start state,
- qaccept?Q is the accept state, and
- qreject?Q is the reject state, where qreject ?
qaccept
8- As a Turing machine computes, it may halt with
accept or reject, or it may never halt! - During computation, changes occur in
- the current state,
- the current tape contents, and
- the current head location.
- The above three items form a configuration of
the Turing machine.
9- Write uqv for the configuration where q is the
current state, uv is the current contents, the
current head location is the first symbol of v. - 1011qT0111
- Let C1 and C2 be two configurations. Say that C1
yields C2, if the Turing machine can legally go
from C1 to C2 in a single step.
qT
B
1
0
1
1
0
1
1
1
1
B
uaqibv yeilds uqjacv if d(qi,b)(qj,c,L) a,b?G,
u,v?G
10- uaqibv yields uacqjv if d(qi,b)(qj,c,R)
- qibv yields qjcv if the transition is right
moving. - We dont move the head out of bound!
- We dont have configuration uaqiB.
- Starting configuration q0w
- Accepting configuration the state is qaccept
- Rejecting configuration the state is qreject
11halting configurations
- A Turing machine M accepts input w if a seq. of
configurations C1, C2, , Ck exists where - C1 is the start conf. of M on input w,
- each Ci yields Ci1, and
- Ck is an accepting configuration.
- The collection of strings that M accepts is the
language of M, denoted L(M).
12- Def A language is Turing-recognizable if some
Turing machine recognizes it. - (or recursively enumerable)
- r.e.
- Def A language is Turing-decidable or decidable
if some Turing machine decides it. - (or recursive)
- r.
13eg.
Show a TM M that recognizes the language
A02nn?0
- MOn input string w
- Sweep left to right across the tape, crossing off
every other 0. - If in stage 1 the tape contained a single 0,
accept. - If in stage 1 the tape contained more than a
single 0 and the number of 0s was odd, reject. - Return the head to the left-hand and of the tape.
- Goto 1.
14- eg. (Element Distinctness problem)
- MOn input w
- 1. Place a mark on top of the leftmost tape
symbol. If - that symbol was not a , reject.
- 2. Scan right to the next and place a second
mark - on top of it. If no is encountered before a
blank - symbol, only x1 was present, so accept.
-
15- 3. By zig-zagging,compare the two strings to the
- right of the marked s .If they are equal
reject. - 4. Move the rightmost of the two marks to the
next - symbol to the right. If no symbol is
- encountered before a blank symbol, move the
- leftmost mark to next to its right.
- 5. Goto step 3.
16- eg. For ?a,b, design a Turing Machine that
accepts Lanbn n?1 - Sol
- Qq0,q1,q2,q3,q4,
- ?a,b
- ?a,b,x,y,B,
- q4accept state
-
17- ?(q0,a)(q1,x,R) ?(q1,a)(q1,a,R)
- ?(q1,y)(q1,y,R) ?(q1,b)(q2,y,L)
- ?(q2,y)(q2,y,L) ?(q2,a)(q2,a,L)
- ?(q2,x)(q0,x,R)
- ?(q0,y)(q3,y,R) ?(q3,y)(q3,y,R)
- ?(q3,B)(q4,B,R)
- q0aabb xq1abb xaq1bb xq2ayb q2xayb
- xq0ayb xxq1yb xxyq1b xxq2yy
- xq2xyy xxq0yy xxyq3y xxyyq3B
- xxyyBq4
18Variants of Turing machine
- 1. Multi-tape Turing Machines
- a Turing Machine with several tapes.
-
19- Thm Every multi-tape Turing machine has an
equivalent single tape Turing machine. - Pf
- Idea
-
0
1
0
1
0
B
M
a
a
a
B
b
a
B
S
0
1
0
1
0
a
a
a
b
a
B
20- Non-deterministic Turing Machines
- Thm Every non-deterministic TM has an equivalent
deterministic TM. - Pf
0
0
1
D
x
x
0
1
x
B
q
0
1
0
0
0
q
q
0
q
0
0
21- Initially tape 1 contains the input w, and tapes
2 and 3 are empty. - Copy tape 1 to tape 2.
- Use tape 2 to simulate N with input w on one
branch of its non-det. computation. Before each
step of N consult the next symbol on tape 3 to
decide which branch to move. If no symbol remains
or this choice is invalid goto step 4. If reject
also goto 4. - Increase the count on tape 3. go to step 2.
22- CorollaryA language is Turing-recognizable if
and only if some non-deterministic TM recognizes
it. - Corollary A language is decidable if and only
if some non-deterministic TM decides it
23Enumerators
- A TM with an attached printer.
- The language enumerated by an enumerator is the
collection of all the strings that it eventually
prints out.
Control
0
0
1
0
Work tape
Enumerator
24- Theorem A language is Turing-recognizable if and
only if some enumerator enumerates it. - Pf
- If an enumerator E that enumerates a language A,
a TM M recognizes A. - Mon input w
- Run E. Every time that E outputs an string,
Compare it with w. - If w ever appears in the output of E, accept.
25- If TM M recognizes a language A, we can construct
an enumerator E for A. -
- Let S1, S2, be a list of all possible strings
in ?. - EIgnore the input.
- Repeat the following for i 1, 2, 3,
- Run M for i steps on each input, S1, S2, , Si,
- If any computations accept, print out the
corresponding Si.
26Definition of algorithm
- Hilberts problems
- In 1900, mathematician David Hilbert delivered a
famous address at the International congress of
Mathematicians in Paris. - He proposed 23 mathematical problems.
- Hilberts tenth problem
- Design an algorithm that tests whether a
multi-variable polynomial has an integral root.
27The Church-Turing Thesis
-
- In 1970, Yuri Matijasevic, building on work of
Martin Davis, Hilary Putnam, and Julia Robinson,
Showed that no algorithm exists for testing
whether a poly. Has integral roots.
Intuitive notion of algorithms
Turing machine algorithms
Necessary to resolve Hilberts tenth problem
28- D P P is a polynomial with an integral root
- Hilberts tenth problem
- Is D decidable?
- A special case
- D1P P is a polynomial over x with an integral
root - D1 is decidable!
29- M1 The input is a polynomial P over x
Evaluate P with x to the values 0, 1, -1, 2,
-2, 3, -3, . If at any point the polynomial
evaluates to 0, accepts! - Problem 3.18 All the roots of P is between
-
- Thus, Di is decidable!