Designing Turing Machines Lecture 3 - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Designing Turing Machines Lecture 3

Description:

TM : Palindrome ... tape (followed by an infinite number of blanks), accept the language Palindrome. ... Example 2. TM : Palindrome ... – PowerPoint PPT presentation

Number of Views:834
Avg rating:3.0/5.0
Slides: 22
Provided by: Ram203
Category:

less

Transcript and Presenter's Notes

Title: Designing Turing Machines Lecture 3


1
Designing Turing MachinesLecture 3
  • Srinath Srinivasa
  • International Institute of Information
    Technology, Bangalore
  • sri_at_iiitb.ac.in

2
Objectives
  • To learn to build Turing machines for few simple
    problems
  • To observe some design principles for
    constructing Turing machines
  • To understand the concept of Universal Turing
    Machines

3
Design TM Example 1
  • TM 0n1n2n
  • Given a string of 0s, 1s and 2s on a tape
    (followed by an infinite number of blanks),
    accept the language 0n1n2n, where
  • ex 000111222_ _ _ _ _.

4
Design strategy
  • Pair 0s, 1s and 2s by stamping them appropriately
  • Stamp a 0 with X and the next 1 with Y and the
    next 2 with Z
  • Whenever a corresponding input is not found,
    reject the input
  • Stop and accept the input when there are no more
    0s, 1s and 2s after the last 2 has been paired.

5
Modularization of TMs
  • Designing complex TMs can be done using modular
    approach.
  • The main problem can be divided into sequence of
    modules.
  • Inside each module, there could be several state
    transitions.

6
Modularization of TMs
0-Stamper
1-Seeker
TM 0n1n2n
1-Stamper
2-Seeker
2-Stamper
0-Seeker
7
Example. TM 0n1n2n
Stamp the first 0 with X, then seek the first 1
and stamp it with Y, and then seek the first 2
and stamp it with Z and then move left.
8
Example. TM 0n1n2n
Move left until an X is reached, then move one
step right.
9
Example. TM 0n1n2n
Move right until the end of the input denoted by
blank( _ ) is reached passing through X Y Z s
only, then the accepting state SA is reached.
10
Example. TM 0n1n2n
These are the transitions that result in halting
states.
11
Example 2
  • TM Palindrome
  • Given a string of 0s and 1s on a tape (followed
    by an infinite number of blanks), accept the
    language Palindrome.
  • ex 1011101_ _ _ _ _.

12
Example 2. TM Palindrome
Stamp the first character (0/1) with _, then seek
the last character by moving till a _ is reached.
If the last character is not 0/1 (as required)
then halt the process immediately.
13
Example 2. TM Palindrome
If the last character is 0/1 accordingly, then
move left until a blank is reached to start the
process again.
14
Example 2. TM Palindrome
If a blank ( _ ) is reached when seeking next
pair of characters to match or when seeking a
matching character, then accepting state is
reached.
15
Example 2. TM Palindrome
  • s010101_ _ _
  • _s20101_ _ _
  • _0s2101_ _ _
  • . . . .
  • _0101s5_ _ _
  • _010s6_ _ _ _
  • _s60101_ _ _
  • _s00101_ _ _
  • . . . .
  • _ _ _ _ s5 _ _ _ _ _ _
  • _ _ _ _ sA _ _ _ _ _ _

16
Exercises
1. Design a TM to recognize a string of the
form anb2n. 2. Design a TM to recognize a string
of 0s and 1s where the number of 0s is not
twice as that of 1s.
17
Universal Turing Machine
A Universal Turing Machine (UTM) takes an
encoding of a TM, and the input data for that TM,
as its own inputs and behaves as that TM on the
given input data.
UTM
TM
?
i/p dataTM spec
i/p data
18
Universal Turing Machine
  • A TM spec could be as follows
  • TM (S,s0,H,T,d)
  • Suppose, Sa,b,c,d, s0a, Hb,d T0,1
  • (a,0)?(b,1,R) , (a,1)?(c,1,R) ,
  • (c,0)?(d,0,R) and so on
  • then TM spec
  • abcdabd01a0b1Ra1c1Rc0d0R.
  • where is delimiter
  • This spec along with the actual input data would
    be the input to the UTM.

19
Universal Turing Machine
This can be encoded in binary by assigning
numbers to each of the characters appearing in
the TM spec. The encoding can be as
follows 0000 0 0101 a 0001 1
0110 b 0010 L 0111 c 0011 R
1000 d 0100 So the TM spec given in
previous slide can be encoded as 0000.0001.0010.
0011.0100.0000.0001.0000.0010.0100 Hence TM
spec can be regarded just as a number.
20
Universal Turing Machine
  • Sequence of actions in UTM
  • Initially UTM is in the start state S0.
  • Load the input which is TM spec.
  • Go back and find which transition to apply.
  • Make changes, where necessary.
  • Then store the changes.
  • Then repeat the steps with next input.
  • Hence, the sequence goes through the cycle

21
Summary
  • Designing of TM can be done using modular
    approach, which can involve combining two or more
    TMs to form one TM.
  • Universal TM is like a processor and a TM is like
    an algorithm.
Write a Comment
User Comments (0)
About PowerShow.com