0% found this document useful (0 votes)
79 views28 pages

2.7 Turing Machines

Uploaded by

siva.e2022cse
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)
79 views28 pages

2.7 Turing Machines

Uploaded by

siva.e2022cse
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/ 28

Module II:

Introduction to Turing Machines

R19CS301 - Automata Theory and Session by:


Compiler Design Dr. S. Sampath Kumar, ASP/CSE

04 October 2024 Module II: Introduction to Turing Machines 1


2 04 October 2024

Agenda
TURING MACHINE – An Introduction
Structure of TM
Comparison with the Previous Automation
Definition of Turing Machine
Types of Turing Machines
Multi-Tape/Head Turing Machine
Multi-track Turing Machine
Techniques for Turing Machines Construction
Module II: Introduction to Turing Machines
3 04 October 2024

Module II: Context Free Grammar and Languages


CFG – Parse Trees – Ambiguity in Grammars and Languages –
Definition of the Pushdown Automata – Languages of Pushdown
Automata – Pumping Lemma for CFL - Introduction to Turing
Machines.

Module II: Introduction to Turing Machines


4 04 October 2024

Course Outcomes:
CO # Outcome K Level

Design and analyze Finite Automata and regular expression for any given
CO1 K3
Regular language
Understand and apply concepts of Context-Free Grammars, Push-Down
CO2 Automata, and Turing machines to analyze computational problems and K3
language ambiguities
Demonstrate proficiency in Lexical Analysis, including defining tokens,
CO3 K2
recognizing tokens, and utilizing tools like Lex

CO4 Analyze and construct different parsers K3

Design efficient code generators and optimize code using techniques like
CO5 K2
peep-hole optimization, DAGs, and basic block optimization.

Module II: Introduction to Turing Machines


5 04 October 2024

TURING MACHINE - An Introduction


A Turing Machine is an accepting device which accepts the
languages (recursively enumerable set) generated by type 0
grammars.
 It was invented in 1936 by Alan Turing.
 A Turing Machine (TM) is a mathematical model which
consists of an infinite length tape divided into cells on which
input is given.
 It consists of a head which reads the input tape.

Module II: Introduction to Turing Machines


6 04 October 2024

An Introduction (Cont..,)
A state register stores the state of the Turing machine. After
reading an input symbol, it is replaced with another symbol,
its internal state is changed, and it moves from one cell to
the right or left.
 If the TM reaches the final state, the input string is accepted,
otherwise rejected.

Module II: Introduction to Turing Machines


7 04 October 2024

What does a TM do?


Determine if an input x is in a language.
➢ Eg:Answer if the answer of a problem P for the
instance x is “yes”.
Compute a function
➢ Eg: Given an input x, what is f(x)?

Module II: Introduction to Turing Machines


8 04 October 2024

Structure of TM:
Finite set of states

CONTROL Start state


UNIT
A single halt state

TAPE Move left or right one cell at a


HEAD time

TAPE

Store input for the TM


Can be of any length Module II: Introduction to Turing Machines
Can read from and write on tape
9 04 October 2024

Comparison with the other automation


 The following table shows a comparison of how a Turing
machine differs from Finite Automaton and Pushdown
Automaton.
Machine Storage Deterministic

Finite Automaton No Yes

Pushdown Automaton Stack No

Turing Machine Infinite Tape Yes

Module II: Introduction to Turing Machines


10 04 October 2024

How does a TM work?


❖ At the beginning,
TM is in the start state (initial state)
Its tape head points at the first cell
The tape contains , following by input
string, and the rest of the tape contains .

Module II: Introduction to Turing Machines


11 04 October 2024

How does a TM work?


❖For each move, a TM
 Reads the symbol under its tape head
 Accordingto the transition function on the
symbol read from the tape and its current state,
the TM:
➢ Write a symbol on the tape
➢ Move its tape head to the left or right one cell or not
➢ Changes its state to the next state
Module II: Introduction to Turing Machines
12 04 October 2024

When does a TM stop working?


❖ TM stops working,
 When it gets into the special state called halt state (halts).
➢ The output of the TM is on the tape.
 when the tape head is on the leftmost cell and is moved
to the left. (hangs)
 when there is no next state. (hangs)

Module II: Introduction to Turing Machines


13 04 October 2024

Definition of Turing Machine:


A TM can be formally described as a 7-tuple
M = (Q, ∑, Γ, δ, q0, B, F) where −
 Q: finite set of states
 ∑: finite set of input alphabet
 Γ: tape alphabet which always include blank symbol.
 δ: transition function;
δ : Q × Γ → Q × Γ × {Left_shift, Right_shift}.
 q0: the initial state (q0 ∈ Q)
 B : the blank symbol
 F: a set of the final state (F ⊆ Q) Module II: Introduction to Turing Machines
14 04 October 2024

Types of Turing Machines


 Multi-Tape / Head Turing Machine
 Multi-track Turing Machine

Module II: Introduction to Turing Machines


15 04 October 2024

Multi-Tape / Head TM:


 Multi-tape Turing Machines have multiple tapes where each
tape is accessed with a separate head.
 Each head can move independently of the other heads.
 Initially the input is on tape 1 and others are blank.
 Atfirst, the first tape is occupied by the input and the other
tapes are kept blank.
 Next, the machine reads consecutive symbols under its
heads and the TM prints a symbol on each tape and moves
its heads.
Module II: Introduction to Turing Machines
16 04 October 2024

Multi-Tape/Head TM:

Module II: Introduction to Turing Machines


17 04 October 2024

Multi-track Turing Machine:


 Multi-track
Turing machines, a specific type of Multi-tape
Turing machine, contain multiple tracks but just one tape
head reads and writes on all tracks.
 Here, a single tape head reads n symbols from n tracks at
one step.
 Itaccepts recursively enumerable languages like a normal
single-track single-tape Turing Machine accepts.

Module II: Introduction to Turing Machines


18 04 October 2024

Multi-track Turing Machine:

Module II: Introduction to Turing Machines


19 04 October 2024

Techniques for Turing Machines Construction


 Designing a Turing machine to solve a problem is an
interesting task.
 It is somewhat similar to programming.
 Given a problem, different Turing machines can be
constructed to solve it.

Module II: Introduction to Turing Machines


20 04 October 2024

Techniques for Turing Machines Construction


 Storage in State
 Multi Tracks
 Checking off Symbols
 Subroutine

Module II: Introduction to Turing Machines


21 04 October 2024

Storage in the State


A Turing machine has a finite number of states in its CPU.
 However, the number of states is not always small (like 6).
 Like a Pentium chip we can store values in it -- as long as
there are only finite number of them.
 For example all real computers have registers but there are
only a fixed number of them, AND each register can only
hold one of a fixed (and finite) number of bits.

Module II: Introduction to Turing Machines


22 04 October 2024

Multi Tracks
 Think of tape symbols as vectors with k components.
 Each component chosen from a finite alphabet.
 Makes the tape appear to have k tracks.
 Let input symbols be blank in all but one track.

Module II: Introduction to Turing Machines


23 04 October 2024

Multi Tracks

Module II: Introduction to Turing Machines


24 04 October 2024

Checking off Symbols


 We use one track of the tape to mark that some symbols
have been read without changing them.
 Example
Consider a Turing machine for accepting
L ={ w#w#w, w ∈ {a, b}∗ }

Module II: Introduction to Turing Machines


25 04 October 2024

Subroutine
 Justas a computer program has a main procedure and
subroutines, the TM can also be programmed to have a
main TM and TMs which serve as subroutines.
 Suppose we have to make n copies of a word w.
 Input is #w# and the output is #w# w| ww{z. . . w}

Module II: Introduction to Turing Machines


26 04 October 2024

Module II: Introduction to Turing Machines


27 04 October 2024

References
 J.E.Hopcroft, R.Motwani and J.D Ullman, ―Introduction to
Automata Theory, Languages and Computations, Second
Edition, Pearson Education, 2003.
 H.R.Lewis and C.H.Papadimitriou, ―Elements of the theory of
Computation, Second Edition, PHI, 2003.
 J.Martin,
―Introduction to Languages and the Theory of
Computation, Third Edition, TMH, 2003.
 Micheal Sipser, ― Introduction of the Theory and
Computation, Thomson Brokecole, 1997

Module II: Introduction to Turing Machines


28 04 October 2024

Module II: Introduction to Turing Machines

You might also like