0% found this document useful (0 votes)
11 views7 pages

Lecture 10

This document introduces Turing machines and discusses their properties. It defines a Turing machine as a 7-tuple consisting of states, alphabets, a transition function, initial/accept/reject states. A Turing machine has a tape that is read and written to by a tape head. Computations involve transitions between configurations based on the transition function. A language is Turing recognizable if a Turing machine can recognize strings in the language. The document provides an example of a Turing machine that decides the language of strings of 0s whose length is a power of 2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Lecture 10

This document introduces Turing machines and discusses their properties. It defines a Turing machine as a 7-tuple consisting of states, alphabets, a transition function, initial/accept/reject states. A Turing machine has a tape that is read and written to by a tape head. Computations involve transitions between configurations based on the transition function. A language is Turing recognizable if a Turing machine can recognize strings in the language. The document provides an example of a Turing machine that decides the language of strings of 0s whose length is a power of 2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Introduction and Motivation

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

Turing Machines Schematic of a Turing Machine


A Turing Machine is a finite state machine
Finite control
augmented with an infinite tape. input
a a b a c _ _ _
The tape head can go in both directions. It can
read and write from/to any cell of the semi- The tape head can go in both directions. It can
infinite tape. read and write from/to any cell of the semi-
Once the TM reaches an accept (reject resp.) infinite tape. The _ symbol marks the input’s
state it accepts (rejects resp.) immediately. end.
3 4
TM – A Formal Definition TM – A Formal Definition
A Turing Machine is a 7-tuple (Q, Σ, Γ,δ , q0 , qaccept, , qreject) , A Turing Machine is a 7-tuple (Q, Σ, Γ,δ , q0 , qaccept, , qreject) ,
where: where:
1. Q is a finite set called the states. 6. qaccept ∈Q is the accept state, and
2. Σ is the input alphabet not containing the 7. qreject ∈Q is the reject state.
blank symbol , _ .
3. Γ is the tape alphabet, _ ∈ Γ and Σ ⊂ Γ .
4. δ : Q × Γ →Q × Γ ×{L, R} is the transition function.
5. q0 ∈ Q is the start state.
5 6

The Transition Function - Domain The Transition Function - Range


Let M be a Turing machine defined by The range of the transition function are triples of
(Q, Σ, Γ,δ , q0 , qaccept, , qreject) . at any given time M is in the type (q' , γ ' , d ) , where q' is M’s next state, γ ' is
some state, q ∈Q , and its head is on some tape the symbol written on the tape cell over which
square containing some tape symbol γ ∈ Γ . the head was at the beginning of the transition
The transition function δ : Q × Γ →Q × Γ ×{L, R}, (namely γ is replaced with γ ' ) and d ∈{L, R} is
depends on the machine state q and on the the direction towards which the tape head has
tape symbol γ . made a step.

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

Configurations Configurations – Special Cases


Configuration C1 of M yields Configuration C2 , if Configuration qi bv yields q j cv , if the head is at the
M can legally go from C1 to C2 in a single step. beginning of the tape and the transition is left-
For example: moving, because the head cannot go off the
Assume that a, b, c ∈ Γ , u, v ∈ Γ*, and qi , q j ∈Q . left-hand end of the tape.
We say that uaqi bv yields uq j acv, if δ (qi , b) = (q j , c, L), Configuration uaqi is equivalent to uaqi _ , because
for a leftward movement of the head. the empty part of the tape is always filled out
We say that uaqi bv yields uacq j v , if δ (qi , b) = (q j , c, R), with blanks.
for a rightward movement of the head.

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

Computation Outcomes Turing Recognizers


A Computation of a Turing machine M may result The collection of strings that M accepts is the
in three different outcomes: language of M , denoted L(M ) .
1. M may accept – By halting in qaccept . A language is Turing Recognizable if there exists a
2. M may reject – By halting in qreject . Turing machine that recognizes it.
3. M may loop – By not halting for ever.
Note: When M is running, it is not clear whether
it is looping . Meaning M may stop eventually
but nobody can tell.
15 16
Turing Deciders An Example
n
Since it is hard to tell whether a running machine Consider the language L = 0 2 | n > 0 containing
 
is looping, we prefer machines that halt on all strings of 0-s whose length is an integral power
inputs. These machines are called deciders. of 2.
A decider that recognizes a language L is said to Obviously, the language L is neither regular nor
decide L. CFL (why?).
A language is Turing decidable if there exists a In the next slide we present a high level
Turing machine that decides it. description of TM M 2 to decide L. The
description format follows the text book.

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

M 2 is presented. _→R _→L

Note: Σ = {0} , Γ = {0, x, _} . q1 q2 q3


0 → _, R 0 → 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

You might also like