0% found this document useful (0 votes)
205 views45 pages

Unit 5 TAFL

Uploaded by

Shivam Kumar
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)
205 views45 pages

Unit 5 TAFL

Uploaded by

Shivam Kumar
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/ 45

Turing Machine

UNIT 5

Unit: 5

TAFL

Course Details
(B Tech 4th Sem)

KCS - 402 TAFL Unit Number: 5


1
6/23/2023
Content

• Introduction
• Formal definition of Turing
machine
• TM Examples
• Universal Turing Machine
• Linear Bounded Automata
• Church’s Thesis
• Recursive Enumerable
• Halting Problem
• Post Correspondence Problem

6/23/2023 KCS - 402 TAFL Unit Number: 5 2


Course Objective

• Introduce concepts in automata theory and theory of computation

• Identify different formal language classes and their relationships

• Design grammars and recognizers for different formal languages

• Prove or disprove theorems in automata theory using its properties

• Determine the decidability and intractability of computational


problems

6/23/2023 KCS - 402 TAFL Unit Number: 5 3


Unit Objective

• To understand the designing of Turing Machine.


• To understand the Turing Thesis.
• To understand the Linear Bounded Automata.
• To understand the Turing Machine Halting Problem.
• To understand the Post Correspondence Problem.

KCS - 402 TAFL Unit Number: 5


6/23/2023 4
Prerequisite and Recap

Prerequisite:
• Basic review of model to perform different operations like
addition, subtraction, multiplication.

Recap:
• PDA is the machine which uses input tapes and stack for
performing operations.
• PDA are more powerful than FA.
• PDA can be converted to CFG.
• CFG can be converted to PDA.

KCS - 402 TAFL Unit Number: 5


6/23/2023 5
Unit 5 Syllabus

Turing Machines and Recursive Function Theory : Basic Turing Machine


Model, Representation of Turing Machines, Language Acceptability of
Turing Machines, Techniques for Turing Machine Construction,
Modifications of Turing Machine, Turing Machine as Computer of
Integer Functions, Universal Turing machine, Linear Bounded
Automata, Church’s Thesis, Recursive and Recursively Enumerable
language, Halting Problem, Post’s Correspondance Problem,
Introduction to Recursive Function Theory.

KCS - 402 TAFL Unit Number: 5


6/23/2023 6
Introduction (CO1, CO2, CO4)

Recap: In previous unit we have studied about Push Down Automata.

Prerequisite: Basic review of model to perform different operations like


addition, subtraction, multiplication.

Objective: To understand the formal definition of Turing Machine.

KCS - 402 TAFL Unit Number: 5


6/23/2023 7
Introduction (CO1, CO2, CO4)

Objective: To understand the formal definition of Turing Machine.

Turing machine was invented in 1936 by Alan Turing. It is an accepting


device which accepts Recursive Enumerable Language generated by
type 0 grammar.

There are various features of the Turing machine:

• It has an external memory which remembers arbitrary long


sequence of input.

• It has unlimited memory capability.

• The model has a facility by which the input at left or right on the
tape can be read easily.

KCS - 402 TAFL Unit Number: 5


6/23/2023 8
Formal definition of Turing machine

A Turing machine can be defined as a collection of 7 components:


Q: the finite set of states
∑: the finite set of input symbols
T: the tape symbol
q0: the initial state
F: a set of final states
B: a blank symbol used as a end marker for input
δ: a transition or mapping function.

• (q0, a) → (q1, X, R)
• That means in q0 state, if we read symbol 'a' then it will go to state
q1, replaced a by X and move ahead right(R stands for right).

KCS - 402 TAFL Unit Number: 5


6/23/2023 9
TM Example (CO1, CO2, CO4)

• Construct TM for the language L ={0n1n} where n>=1.

• We have already solved this problem by PDA. In PDA, we have a


stack to remember the previous symbol. The main advantage of the
Turing machine is we have a tape head which can be moved
forward or backward, and the input tape can be scanned.

• The simple logic which we will apply is read out each '0' mark it by
A and then move ahead along with the input tape and find out 1
convert it to B. Now, repeat this process for all a's and b's.

• Now we will see how this Turing machine work for 0011.

KCS - 402 TAFL Unit Number: 5


6/23/2023 10
TM Example

• The simulation for 0011 can be shown as below:

• Now, we will see how this turing machine will works for 0011.
Initially, state is q0 and head points to 0 as:

KCS - 402 TAFL Unit Number: 5


6/23/2023 11
TM Example

• The move will be δ(q0, 0) = δ(q1, A, R) which means it will go


to state q1, replaced 0 by A and head will move to the right
as:

• The move will be δ(q1, 0) = δ(q1, 0, R) which means it will not


change any symbol, remain in the same state and move to the
right as:

KCS - 402 TAFL Unit Number: 5


6/23/2023 12
TM Example

• The move will be δ(q1, 1) = δ(q2, B, L) which means it will go


to state q2, replaced 1 by B and head will move to left as:

• Now move will be δ(q2, 0) = δ(q2, 0, L) which means it will not


change any symbol, remain in the same state and move to left
as:

KCS - 402 TAFL Unit Number: 5


6/23/2023 13
TM Example

• The move will be δ(q2, A) = δ(q0, A, R), it means will go to


state q0, replaced A by A and head will move to the right as:

• The move will be δ(q0, 0) = δ(q1, A, R) which means it will go


to state q1, replaced 0 by A, and head will move to right as:

KCS - 402 TAFL Unit Number: 5


6/23/2023 14
TM Example

• The move will be δ(q1, B) = δ(q1, B, R) which means it will not


change any symbol, remain in the same state and move to
right as:

• The move will be δ(q1, 1) = δ(q2, B, L) which means it will go


to state q2, replaced 1 by B and head will move to left as:

KCS - 402 TAFL Unit Number: 5


6/23/2023 15
TM Example

• The move δ(q2, B) = (q2, B, L) which means it will not change


any symbol, remain in the same state and move to left as:

• Now immediately before B is A that means all the 0?s are


market by A. So we will move right to ensure that no 1 is
present. The move will be δ(q2, A) = (q0, A, R) which means it
will go to state q0, will not change any symbol, and move to
right as:

KCS - 402 TAFL Unit Number: 5


6/23/2023 16
TM Example

• The move δ(q0, B) = (q3, B, R) which means it will go to state


q3, will not change any symbol, and move to right as:

• The move δ(q3, B) = (q3, B, R) which means it will not change


any symbol, remain in the same state and move to right as:

KCS - 402 TAFL Unit Number: 5


6/23/2023 17
TM Example

• The move δ(q3, Δ) = (q4, Δ, R) which means it will go to state


q4 which is the HALT state and HALT state is always an accept
state for any TM.

• The same TM can be represented by Transition Diagram:

KCS - 402 TAFL Unit Number: 5


6/23/2023 18
Universal Turing Machine (CO1, CO2, CO4)

Recap: Till now we have studied about Turing Machine.

Prerequisite: Basic review of model to perform different operations


like addition, subtraction, multiplication.

Objective: To understand the Universal Turing Machine.

KCS - 402 TAFL Unit Number: 5


6/23/2023 19
Universal Turing Machine (CO1, CO2, CO4)
Objective: To understand the Universal Turing Machine.

• A Turing Machine is the mathematical tool equivalent to a digital


computer.
• It was suggested by the mathematician Turing in the 30s, and has been
since then the most widely used model of computation in computability
and complexity theory.
• The model consists of an input output relation that the machine
computes.
• The input is given in binary form on the machine's tape, and the output
consists of the contents of the tape when the machine halts.

KCS - 402 TAFL Unit Number: 5


6/23/2023 20
Universal Turing Machine
• What determines how the contents of the tape change is a finite state
machine (or FSM, also called a finite automaton) inside the Turing
Machine.
• The FSM is determined by the number of states it has, and the transitions
between them.
• At every step, the current state and the character read on the tape
determine the next state the FSM will be in, the character that the
machine will output on the tape (possibly the one read, leaving the
contents unchanged), and which direction the head moves in, left or right.
• The problem with Turing Machines is that a different one must be
constructed for every new computation to be performed, for every input
output relation.
• This is why we instroduce the notion of a universal turing machine (UTM),
which along with the input on the tape, takes in the description of a
machine M.
• The UTM can go on then to simulate M on the rest of the contents of the
input tape. A universal turing machine can thus simulate any other
machine.
6/23/2023
KCS - 402 TAFL Unit Number: 5
21
Linear Bounded Automata (CO1, CO2, CO4)

Recap: Till now we have studied about Turing Machine and Universal
Turing Machine.

Prerequisite: Basic review of model to perform different operations


like addition, subtraction, multiplication.

Objective: To understand the Linear Bounded Automata.

KCS - 402 TAFL Unit Number: 5


6/23/2023 22
Linear Bounded Automata (CO1, CO2, CO4)
Objective: To understand the Linear Bounded Automata.

A linear bounded automaton is a multi-track non-deterministic Turing


machine with a tape of some bounded finite length.

• Length = function (Length of the initial input string, constant c)


Here,
• Memory information ≤ c × Input information

• Link: https://www.youtube.com/watch?v=kFH4X69L1JU

KCS - 402 TAFL Unit Number: 5


6/23/2023 23
Linear Bounded Automata

A linear bounded automaton can be defined as an 8-tuple (Q, X, ∑, q0,


ML, MR, δ, F) where −
• Q is a finite set of states
• X is the tape alphabet
• ∑ is the input alphabet
• q0 is the initial state
• ML is the left end marker
• MR is the right end marker where MR ≠ ML
• δ is a transition function which maps each pair (state, tape symbol)
to (state, tape symbol, Constant ‘c’) where c can be 0 or +1 or -1
• F is the set of final states

KCS - 402 TAFL Unit Number: 5


6/23/2023 24
Church’s Thesis (CO5)

Recap: Till now we have studied about Turing Machine, Universal


Turing Machine and Linear Bounded Automata.

Prerequisite: Basic review of model to perform different operations


like addition, subtraction, multiplication.

Objective: To understand the importance of Church Thesis in Theory


of Computation.

KCS - 402 TAFL Unit Number: 5


6/23/2023 25
Church’s Thesis (CO5)
Objective: To understand the importance of Church Thesis in Theory of
Computation.

• In 1936, Alonzo Church created a method for defining functions called the
λ-calculus. Within λ-calculus, he defined an encoding of the natural
numbers called the Church numerals.

• Also in 1936, before learning of Church's work, Alan Turing created a


theoretical model for machines, now called Turing machines, that could
carry out calculations from inputs by manipulating symbols on a tape.

• A Turing machine is an abstract representation of a computing device.

• It is more like a computer hardware than a computer software.

• Link: https://www.youtube.com/watch?v=EEfNU8AoA-8

KCS - 402 TAFL Unit Number: 5


6/23/2023 26
Church’s Thesis (CO5)

• The Church-Turing thesis concerns an effective or mechanical


method in logic and mathematics.

• A method, M, is called ‘effective’ or ‘mechanical’ just in case:

• M is set out in terms of a finite number of exact instructions


(each instruction being expressed by means of a finite
number of symbols);

• M will, if carried out without error, always produce the


desired result in a finite number of steps;

KCS - 402 TAFL Unit Number: 5


6/23/2023 27
Church’s Thesis (CO5)

• M can (in practice or in principle) be carried out by a human being


unaided by any machinery except for paper and pencil;
• M demands no insight or ingenuity on the part of the human being
carrying it out.
• They gave an hypothesis which means proposing certain facts.
• The Church’s hypothesis or Church’s turing thesis can be stated as:
• The assumption that the intuitive notion of computable functions
can be identified with partial recursive functions.
• This statement was first formulated by Alonzo Church in the 1930s
and is usually referred to as Church’s thesis, or the Church-Turing
thesis.
• However, this hypothesis cannot be proved.

KCS - 402 TAFL Unit Number: 5


6/23/2023 28
Recursive Enumerable (CO1, CO2, CO4)

Recap: Till now we have studied about Turing Machine, Universal


Turing Machine, Linear Bounded Automata and Church Thesis.

Prerequisite: Basic review of model to perform different operations


like addition, subtraction, multiplication.

Objective: To understand the Recursive Enumerable Language.

KCS - 402 TAFL Unit Number: 5


6/23/2023 29
Recursive Enumerable (CO1, CO2, CO4)
Objective: To understand the Recursive Enumerable Language.

• RE languages or type-0 languages are generated by type-0


grammars.
• An RE language can be accepted or recognized by Turing machine
which means it will enter into final state for the strings of language
and may or may not enter into rejecting state for the strings which
are not part of the language.
• It means TM can loop forever for the strings which are not a part of
the language.
• RE languages are also called as Turing recognizable languages.

• Link: https://www.youtube.com/watch?v=KJD_F-QGLmo

KCS - 402 TAFL Unit Number: 5


6/23/2023 30
Halting Problem (CO1, CO2, CO4)

Recap: Till now we have studied about Turing Machine, Universal


Turing Machine, Linear Bounded Automata, Church Thesis and
Recursive Enumerable Language.

Prerequisite: Basic review of model to perform different operations


like addition, subtraction, multiplication.

Objective: To understand the Halting Problem in theory of


computations.

KCS - 402 TAFL Unit Number: 5


6/23/2023 31
Halting Problem (CO1, CO2, CO4)
Objective: To understand the Halting Problem in theory of computations.

• Input − A Turing machine and an input string w.


• Problem − Does the Turing machine finish computing of the string w in a
finite number of steps? The answer must be either yes or no.

• Link for Further Explanation:


• https://www.youtube.com/watch?v=mx1mnyagfdM&list=PL4B084328ED81F3AF

KCS - 402 TAFL Unit Number: 5


6/23/2023 32
Post Correspondence Problem (CO1, CO2,
CO4)

Recap: Till now we have studied about Turing Machine, Universal


Turing Machine, Linear Bounded Automata, Church Thesis, Recursive
Enumerable Language and Halting Problem.

Prerequisite: Basic review of model to perform different operations


like addition, subtraction, multiplication.

Objective: To understand the importance of post correspondence


problem.

KCS - 402 TAFL Unit Number: 5


6/23/2023 33
Post Correspondence Problem (CO1, CO2,
CO4)
Objective: To understand the importance of post correspondence problem.

The Post Correspondence Problem (PCP), introduced by Emil Post in 1946, is


an undecidable decision problem. The PCP problem over an alphabet ∑ is
stated as follows −

• Given the following two lists, M and N of non-empty strings over ∑


• M = (x1, x2, x3,………, xn)
• N = (y1, y2, y3,………, yn)
• We can say that there is a Post Correspondence Solution, if for some
i1,i2,………… ik, where 1 ≤ ij ≤ n, the condition xi1 …….xik = yi1 …….yik satisfies.

• Link for further explanation :


• https://www.youtube.com/watch?v=YSr5zmVqZLI

KCS - 402 TAFL Unit Number: 5


6/23/2023 34
Post Correspondence Problem

Problem:
Find whether the lists M = (abb, aa, aaa) and N = (bba, aaa, aa)
have a Post Correspondence Solution?

Solution:
x1 x2 x3
M Abb aa aaa
N Bba aaa aa
• Here,
• x2x1x3 = ‘aaabbaaa’
• and y2y1y3 = ‘aaabbaaa’
• We can see that
• x2x1x3 = y2y1y3
• Hence, the solution is i = 2, j = 1, and k = 3.

KCS - 402 TAFL Unit Number: 5


6/23/2023 35
Daily Quiz

1. Design a TM to compute the function f(n)=n2


2. Explain Church’s Thesis.
3. Define Post Correspondence Problem and Modified Post
Correspondence Problem.
4. Design a TM to accept the language “ The set of strings with
an equal number of 0’s and 1’s.
5. Design a right shift TM over an alphabet{0,1}
6. Write short note on Halting Problem.

6/23/2023 KCS - 402 TAFL Unit Number: 5 36


Daily Quiz (Continued)

7. Define Basic model of Turing Machine.


8. Explain the techniques for Turing Machine construction.
9. Explain Church’s Thesis.
10. Design a TM to compute the function f(n)=n2
11. Define Post Correspondence Problem and Modified Post
Correspondence Problem.
12. Write short note on Universal Turing Machine.
13. When a language is said to be recursive or recursively
enumerable.
14. Write short note on Halting Problem.
15. Design a right shift TM over an alphabet{0,1}.

6/23/2023 KCS - 402 TAFL Unit Number: 5 37


MCQ s
1. Find the odd one :

a. Multiple track
b. Subroutines
c. Recursion
d. Shifting over

2. Which operation is not a part of TM?

a. Enter Accepting State


b. Enter Non Accepting state
c. Enter infinite loop and never halts
d. None of the above
6/23/2023 KCS - 402 TAFL Unit Number: 5 38
MCQ s (Continued)
3. Which of the statement is not true for TM?

a. Computers of functions on non negative numbers


b. Language Recognition
c. Generating devices
d. None

4. A finite control of TM is used in order to hold a finite amount of


data. Say True or False:

a. TRUE
b. FALSE
c. May Be
d. Cant Say
6/23/2023 KCS - 402 TAFL Unit Number: 5 39
MCQ s (Continued)
5. Find the odd one :
a. Multiple track
b. Subroutines
c. Recursion
d. Shifting over

6. Which operation is not a part of TM?


a. Enter Accepting State
b. Enter Non Accepting state
c. Enter infinite loop and never halts
d. None of the above

6/23/2023 KCS - 402 TAFL Unit Number: 5 40


MCQ s (Continued)
7. Which of the statement is not true for TM?
a. Computers of functions on non negative numbers
b. Language Recognition
c. Generating devices
d. None

8. X is a simple mathematical model of a computer. X has unrestricted and


unlimited memory. X is a FA with R/W head. X can have an infinite tape
divided into cells, each cell holding one symbol.
Name X?
a. NDFA
b. PDA
c. TM
d. None of the above

6/23/2023 KCS - 402 TAFL Unit Number: 5 41


Expected Questions for University Exam

1. Design a TM to reverse a string over an alphabet {0,1}.


2. Design a TM to check whether a string over {a,b}contains
equal number of a’s and b’s.
3. Design a TM that replace every occurrence of abb by baa.
4. Design a TM for addition of Unary numbers.
5. Design a TM for subtraction of a Unary numbers.

6/23/2023 KCS - 402 TAFL Unit Number: 5 42


Summary

• Turing machines use an infinite tape divided into a number of


rectangular cells and a tape head that can read and write symbols
and can move in both the directions left and right.
• The input for a transition function of a TM are current state and
current tape symbol.
• The output of the transition function are the state in which TM has
to be after reading the current tape symbol.

6/23/2023 KCS - 402 TAFL Unit Number: 5 43


References

1. Aho, Hopcroft and Ullman, The Design and Analysis of Computer


Algorithms, Addison Wesley.
2. Aho, Sethi, Ullman, Compilers Principles, Techniques and Tools,
Pearson Education, 2003.
3. Hopcroft and Ullman, Introduction to Automata Theory, Languages
and Computation, Addison Wesley.
4. Kohavi, ZVI, Switching And Finite Automata Theory, Tata McGraw-
Hill, 2006.
5. Lewis and Papadimitriou, Elements of the Theory of Computation,
Prentice-Hall.
6. Martin, Introduction to Languages and the Theory of Computation,
McGraw-Hill, 2nd edition,1996.
7. Mishra, KLP, Chandrasekaran, N. Theory of Computer Science,
(Automata, Languages and Computation) PHI, 2002.

6/23/2023 KCS - 402 TAFL Unit Number: 5 44


6/23/2023 KCS - 402 TAFL Unit Number: 5 45

You might also like