Lecture 10
Lecture 10
Introduction to Computability
Theory In this lecture we introduce Turing Machines
and discuss some of their properties.
Lecture10: Turing Machines
Prof. Amos Israeli
1 2
7 8
Turing machine – A Computation Configurations
Computation of M always starts at state q0 , and A configuration of a Turing machine M is a concise
the input is on the leftmost n cells where n is description M’s state and tape contents. It is
the input’s length. The tape’s head is over the written as C=uqv . and its meaning is:
tape’s cell 0 – the leftmost cell. 1. The state of M is q.
Computation of M ends either when it reaches 2. The content of M’s tape is uv , where u resides
qaccept ∈Q - this is an Accepting Computation. Or on the leftmost part of the tape.
when it reaches qreject ∈Q - this is a Rejecting 3. The head of M resides over the leftmost (first)
Computation. symbol of v.
4. The tape cells past the end of v hold blanks.
9 10
11 12
Computations Computations
The start Configuration of M on input w is q0 w, Accepting and rejecting configurations are halting
which indicates that M is at its initial state, q0 , configurations.
it’s head is on the first cell of its tape and the A TM M accepts word w if there exists a
tape’s content is the input w. computation (a sequence of configurations) of
Any configuration in which of M reaches state M, C1, C2 ,...,Ck satisfying:
qaccept , is an accepting configuration. 1. C1 = q0 w is the starting state of M on input w.
Any configuration in which M reaches state 2. For each i,1 ≤ i < k , Ci yields Ci +1 , and
qreject ,is a rejecting configuration.
3. Ck is an accepting configuration.
13 14
17 18
An Example Explanation
M 2 = “On input string w: M 2 works as follows:
1. Sweep the tape left to right, crossing every Each iteration of stage 1 cuts the number of
second 0. 0-s in half. As the sweeps across its tape on
2. If in stage 1 the tape has a single 0, accept. stage 1 it “calculates” whether the number
3. If in stage 1 the tape has an odd number of of 0-s it sees is odd or even. If the number of
0-s greater than 1, reject. 0-s is odd and greater than 1, the input
4. Return the head to the left-hand end of the length cannot be a power of 2, so it rejects.
tape. If the number of 0-s is 1, the input length is
5. Go to stage 1. “ a power of 2 and it accepts.
19 20
0→L
An Example An Example x→L
q5
x→R
In the following slide the transition function of x→R
_→R
_→R
0→R 0 → x, R
x→R
qaccept
qreject q4
_→R
21 22 x→R
Example2 Example2
Consider the language L = w# w | w ∈ {0,1}* .
{ } Repeat this procedure until all the string w is
A simple method to check whether a string w scanned. If an unexpected character is found,
is in L is: Read the first character of w, store it, reject. Otherwise, accept.
and mark it off. Then scan w until the character
In the next slide we present a high level
# is found, if the first character past # is equal
description of TM M 1 to decide L. The
to the stored character, cross it and go back to
the last crossed character, On the tape’s description format follows the text book.
beginning.
23 24
Example2 Example2
M 1 = “On input string w: In the following slide the transition function of
1. Store the leftmost symbol on the tape and M 2 is presented.
cross it out by writing x. Note:
2. Go right past #, if # not found, reject. 1. Σ = {0,1, #} , Γ = {0,1, # , x, _} .
3. compare the leftmost non x symbol to the
stored symbol. If not equal, reject. 2. In this description, state qreject and all its
4. Cross out the compared symbol. Return the incoming transitions are omitted. Wherever
head to the left-hand end of the tape. there is a missing transition, it goes to qreject .
5. Go to stage 1. “
25 26
0,1 → R x→R
Example2
q3 #→ R
q5 Note: states q2 and q3 “store” the bit 0, while
0,1 → L
1 → x, R 1 → x, L states q4 and q5 “store” the bit 1.
x→R
0,1, x → L In other words: These two segments are
identical, but when the merge each segments
q1 q8 qaccept q6 q7
#→ R _→R #→ L uses the value it stored.
0,1 → R x→R x→R
0 → x, R 0 → x, L
q2 q4
#→ R
27 28