SlideShare a Scribd company logo
DMI-ST. JOHN THE BAPTIST UNIVERSITY
LILONGWE, MALAWI
Module Code: 055CS62
Subject Name: Theory of computation
Unit IV Detail Notes
School of Computer Science
Module Teacher: Fanny Chatola
Syllabus
Turing Machine Model, Representation of Turing Machines, Language Acceptability by Turing Machines,
Design of TM, Description of TM, Techniques for TM Construction, Variants of Turing Machines,
The Model of Linear Bounded Automata , TM & Type 0 grammars, TM‘s Halting Problem.
Turing machine:
Informal Definition:
We consider here a basic model of TM which is deterministic and have one-tape. There are many variations, all
are equally powerfull.
The basic model of TM has a finite set of states, a semi-infinite tape that has a leftmost cell but is infinite to the
right and a tape head that can move left and right over the tape, reading and writing symbols.
For any input w with |w|=n, initially it is written on the n leftmost (continguous) tape cells. The infinitely many
cells to the right of the input all contain a blank symbol, B whcih is a special tape symbol that is not an input
symbol. The machine starts in its start state with its head scanning the leftmost symbol of the input w. Depending
upon the symbol scanned by the tape head and the current state the machine makes a move which
consists of the following:
• writes a new symbol on that tape cell, •
moves its head one cell either to the left or to the right and
• (possibly) enters a new state.
The action it takes in each step is determined by a transition functions. The machine continues computing (i.e.
making moves) until
• it decides to "accept" its input by entering a special state called accept or final state or
• halts without accepting i.e. rejecting the input when there is no move defined.
On some inputs the TM many keep on computing forever without ever accepting or rejecting the input, in which
case it is said to "loop" on that input
Formal Definition :
The ID (instantaneous description) of a TM capture what is going out at any moment i.e. it contains all the
information to exactly capture the "current state of the computations".
It contains the following:
• The current state, q
• The position of the tape head,
• The constants of the tape up to the rightmost nonblank symbol or the symbol to the left of the head,
whichever is rightmost.
Note that, although there is no limit on how far right the head may move and write nonblank symbols on the
tape, at any finite
time, the TM has visited only a finite prefix of the infinite tape.
The Halting Problem
The input to a Turing machine is a string. Turing machines themselves can be written as
strings. Since these strings can be used as input to other Turing machines. A “Universal Turing
machine” is one whose input consists of a description M of some arbitrary Turing machine, and
some input w to which machine M is to be applied, we write this combined input as M + w. This
produces the same output that would be produced by M. This is written as
Universal Turing Machine (M + w) = M (w).
As a Turing machine can be represented as a string, it is fully possible to supply a Turing
machine as input to itself, for example M (M). This is not even a particularly bizarre thing to do for
example, suppose you have written a C pretty printer in C, then used the Pretty printer on itself.
Another common usage is Bootstrapping—where some convenient languages used to write a
minimal compiler for some new language L, then used this minimal compiler for L to write a new,
improved compiler for language L. Each time a new feature is added to language L, you can
recompile and use this new feature in the next version of the compiler. Turing machines sometimes
halt, and sometimes they enter an infinite loop.
A Turing machine might halt for one input string, but go into an infinite loop when given
some other string. The halting problem asks: “It is possible to tell, in general, whether a given
machine will halt for some given input?” If it is possible, then there is an effective procedure to look
at a Turing machine and its input and determine whether the machine will halt with that input. If
there is an effective procedure, then we can build a Turing machine to implement it. Suppose we
have a Turing machine “WillHalt” which, given an input string M + w, will halt and accept the string
if Turing machine M halts on input w and will halt and reject the string if Turing machine M does not
halt on input w. When viewed as a Boolean function, “WillHalt (M
Theorem
Turing Machine “WillHalt (M, w)” does not exist.
Proof: This theorem is proved by contradiction. Suppose we could build a machine “WillHalt”.
Then we can certainly build a second machine, “LoopIfHalts”, that will go into an infinite loop if
and only if “WillHalt” accepts its input:
Function LoopIfHalts (M, w):
if WillHalt (M, w) then
while true do { }
else
return false;
We will also define a machine “LoopIfHaltOnItSelf” that, for any given input M, representing a
Turing machine, will determine what will happen if M is applied to itself, and loops if M will halt in
this case.
Function LoopIfHaltsOnItself (M):
return LoopIfHalts (M, M):
Finally, we ask what happens if we try:
Func tion Impos sible:
return LoopIfHaltsOnItself (LoopIfHaltsOnItself):
This machine, when applied to itself, goes into an infinite loop if and only if it halts when
applied to itself. This is impossible. Hence the theorem is proved.
Implications of Halting Problem
Programming
The Theorem of “Halting Problem” does not say that we can never determine whether or not
a given program halts on a given input. Most of the times, for practical reasons, we could eliminate
infinite loops from programs. Sometimes a “meta-program” is used to check another program for
potential infinite loops, and get this meta-program to work most of the time.
The theorem says that we cannot ever write such a meta-program and have it work all of the
time. This result is also used to demonstrate that certain other programs are also impossible.
The basic outline is as follows:
(i) If we could solve a problem X, we could solve the Halting problem
(ii) We cannot solve the Halting Problem
(iii) Therefore, we cannot solve problem X
A Turing machine can be "programmed," in much the same manner as a computer is
programmed. When one specifies the function which we usually call d for a Tm, he is really writing
a program for the Tm.
1. Storage in finite Control
The finite control can be used to hold a finite amount of information. To do so, the state is
written as a pair of elements, one exercising control and the other storing a symbol. It should be
emphasized that this arrangement is for conceptual purposes only. No modification in the definition
of the Turing machine has been made.
Example
Consider the Turing machine
Solution
2.
Multiple Tracks
We can imagine that the tape of the Turing machine is divided into k tracks, for any finite k. This
arrangement is shown in Fig., with k = 3. What is actually done is that the symbols on the tape are
considered as k-tuples. One component for each track.
Example
The tape in Fig. can be imagined to be that of a Turing machine which takes a binary input
greater than 2, written on the first track, and determines if it is a prime. The input is surrounded by ¢
and $ on the first track.
Thus, the allowable input symbols are [¢, B, B], [0, B, B ], [1, B, B ], and [$, B, B]. These
symbols can be identified with ¢, 0, 1, and $, respectively, when viewed as input symbols. The blank
symbol can be represented by [B, B, B ]
To test if its input is a prime, the Tm first writes the number two in binary on the second track
and copies the first track onto the third track. Then, the second track is subtracted, as many times as
possible, from the third track, effectively dividing the third track by the second and leaving the
remainder. If the remainder is zero, the number on the first track is not a prime. If the remainder is
nonzero, increase the number on the second track by one.
If now the second track equals the first, the number on the first track is a prime, because it cannot
be divided by any number between one and itself. If the second is less than the first, the whole
operation is repeated for the new number on the second track. In Fig., the Tm is testing to determine
if 47 is a prime. The Tm is dividing by 5; already 5 has been subtracted twice, so 37 appears on the
third track.

More Related Content

PPTX
Turing machine
PDF
CS.15.Turing.pdf
PPTX
Theory of Automata and formal languages Unit 5
PPTX
Automata Theory - Turing machine
PPT
Unit-3_TOC theory of computation subj.ppt
PPTX
Turing machine
PPTX
TURING MACHINE.pptxTURING MACHINE.pptxTURING MACHINE.pptx
PPTX
souraj Toc.pptx
Turing machine
CS.15.Turing.pdf
Theory of Automata and formal languages Unit 5
Automata Theory - Turing machine
Unit-3_TOC theory of computation subj.ppt
Turing machine
TURING MACHINE.pptxTURING MACHINE.pptxTURING MACHINE.pptx
souraj Toc.pptx

Similar to theory of computation notes for school of engineering (20)

PPTX
What is turing machine full described PPT for all learners
DOCX
churchthesis.docx turing machine and undecidability
PPTX
Turing Machine presentation for Theory of Computation
PDF
Turing machine seminar report
PPTX
Turing Machine
PPTX
Class 36: Halting Problem
PPTX
Formal Languages of Automata theory: Turing Machines
PPT
1LECTURE 9TuringMachines.ppt
PPTX
Turing machine-TOC
PPT
TuringMachines.ppt
PPTX
TuringMachines-myppt.pptx
PDF
Self-Replication and the Halting Problem
PPT
TuringMachineS FOUNDATION OF DATA SCIENCE
PPT
THEORY OF COMPUTATION PROCESS AND MECHANISUMS
PPT
TuringMachineS FOUNDATION OF DATA SCIENCE
PPT
THEORY OF COMPUTATION PROCESS AND MECHANISUMS
PDF
Turing Machine
PPT
Turing Machine
PPT
Turing machines 1
PPTX
Turing machine and Halting Introduction
What is turing machine full described PPT for all learners
churchthesis.docx turing machine and undecidability
Turing Machine presentation for Theory of Computation
Turing machine seminar report
Turing Machine
Class 36: Halting Problem
Formal Languages of Automata theory: Turing Machines
1LECTURE 9TuringMachines.ppt
Turing machine-TOC
TuringMachines.ppt
TuringMachines-myppt.pptx
Self-Replication and the Halting Problem
TuringMachineS FOUNDATION OF DATA SCIENCE
THEORY OF COMPUTATION PROCESS AND MECHANISUMS
TuringMachineS FOUNDATION OF DATA SCIENCE
THEORY OF COMPUTATION PROCESS AND MECHANISUMS
Turing Machine
Turing Machine
Turing machines 1
Turing machine and Halting Introduction
Ad

More from FIONACHATOLA (18)

PPTX
ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
PPT
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
PPTX
business intelligence and analytics notes
PPTX
VOICE OVER INTERNET PROTOCOL(VOIP) notes
PPTX
PC HARWARE AND TROUBLE SHOOTING INTRODUCTION
PDF
Unit I Data structure and algorithms notes
PDF
UG_B.Sc._Information Technology_129 14_Office Automation Lab.pdf
PPT
computer Hardware and trouble shooting Basics
PPTX
Introduction to Email, internet protocols
PPTX
Introduction to Internet Protocol ADDRESS.pptx
PPTX
introduction to OSI MODEL-WPS Office.pptx
PDF
computer system organization and architecture
PDF
computer fundamentals -e- notes for IT & CS
DOCX
theory of computation notes for school of engineering
DOCX
theory of computation notes for school of engineering
DOCX
theory of computation notes for school of engineering
DOCX
theory of computation notes for school of engineering
DOCX
in computer data structures and algorithms
ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
business intelligence and analytics notes
VOICE OVER INTERNET PROTOCOL(VOIP) notes
PC HARWARE AND TROUBLE SHOOTING INTRODUCTION
Unit I Data structure and algorithms notes
UG_B.Sc._Information Technology_129 14_Office Automation Lab.pdf
computer Hardware and trouble shooting Basics
Introduction to Email, internet protocols
Introduction to Internet Protocol ADDRESS.pptx
introduction to OSI MODEL-WPS Office.pptx
computer system organization and architecture
computer fundamentals -e- notes for IT & CS
theory of computation notes for school of engineering
theory of computation notes for school of engineering
theory of computation notes for school of engineering
theory of computation notes for school of engineering
in computer data structures and algorithms
Ad

Recently uploaded (20)

PPTX
UNIT 4 Total Quality Management .pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Welding lecture in detail for understanding
PPTX
Sustainable Sites - Green Building Construction
PPT
Mechanical Engineering MATERIALS Selection
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Geodesy 1.pptx...............................................
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT
Project quality management in manufacturing
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Digital Logic Computer Design lecture notes
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
573137875-Attendance-Management-System-original
UNIT 4 Total Quality Management .pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Welding lecture in detail for understanding
Sustainable Sites - Green Building Construction
Mechanical Engineering MATERIALS Selection
R24 SURVEYING LAB MANUAL for civil enggi
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Geodesy 1.pptx...............................................
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Project quality management in manufacturing
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Digital Logic Computer Design lecture notes
Internet of Things (IOT) - A guide to understanding
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
573137875-Attendance-Management-System-original

theory of computation notes for school of engineering

  • 1. DMI-ST. JOHN THE BAPTIST UNIVERSITY LILONGWE, MALAWI Module Code: 055CS62 Subject Name: Theory of computation Unit IV Detail Notes School of Computer Science Module Teacher: Fanny Chatola
  • 2. Syllabus Turing Machine Model, Representation of Turing Machines, Language Acceptability by Turing Machines, Design of TM, Description of TM, Techniques for TM Construction, Variants of Turing Machines, The Model of Linear Bounded Automata , TM & Type 0 grammars, TM‘s Halting Problem.
  • 3. Turing machine: Informal Definition: We consider here a basic model of TM which is deterministic and have one-tape. There are many variations, all are equally powerfull. The basic model of TM has a finite set of states, a semi-infinite tape that has a leftmost cell but is infinite to the right and a tape head that can move left and right over the tape, reading and writing symbols. For any input w with |w|=n, initially it is written on the n leftmost (continguous) tape cells. The infinitely many cells to the right of the input all contain a blank symbol, B whcih is a special tape symbol that is not an input symbol. The machine starts in its start state with its head scanning the leftmost symbol of the input w. Depending upon the symbol scanned by the tape head and the current state the machine makes a move which consists of the following: • writes a new symbol on that tape cell, • moves its head one cell either to the left or to the right and • (possibly) enters a new state. The action it takes in each step is determined by a transition functions. The machine continues computing (i.e. making moves) until • it decides to "accept" its input by entering a special state called accept or final state or • halts without accepting i.e. rejecting the input when there is no move defined. On some inputs the TM many keep on computing forever without ever accepting or rejecting the input, in which case it is said to "loop" on that input Formal Definition :
  • 4. The ID (instantaneous description) of a TM capture what is going out at any moment i.e. it contains all the information to exactly capture the "current state of the computations". It contains the following: • The current state, q • The position of the tape head, • The constants of the tape up to the rightmost nonblank symbol or the symbol to the left of the head, whichever is rightmost. Note that, although there is no limit on how far right the head may move and write nonblank symbols on the tape, at any finite time, the TM has visited only a finite prefix of the infinite tape.
  • 5. The Halting Problem The input to a Turing machine is a string. Turing machines themselves can be written as strings. Since these strings can be used as input to other Turing machines. A “Universal Turing machine” is one whose input consists of a description M of some arbitrary Turing machine, and some input w to which machine M is to be applied, we write this combined input as M + w. This produces the same output that would be produced by M. This is written as Universal Turing Machine (M + w) = M (w). As a Turing machine can be represented as a string, it is fully possible to supply a Turing machine as input to itself, for example M (M). This is not even a particularly bizarre thing to do for example, suppose you have written a C pretty printer in C, then used the Pretty printer on itself. Another common usage is Bootstrapping—where some convenient languages used to write a minimal compiler for some new language L, then used this minimal compiler for L to write a new,
  • 6. improved compiler for language L. Each time a new feature is added to language L, you can recompile and use this new feature in the next version of the compiler. Turing machines sometimes halt, and sometimes they enter an infinite loop. A Turing machine might halt for one input string, but go into an infinite loop when given some other string. The halting problem asks: “It is possible to tell, in general, whether a given machine will halt for some given input?” If it is possible, then there is an effective procedure to look at a Turing machine and its input and determine whether the machine will halt with that input. If there is an effective procedure, then we can build a Turing machine to implement it. Suppose we have a Turing machine “WillHalt” which, given an input string M + w, will halt and accept the string if Turing machine M halts on input w and will halt and reject the string if Turing machine M does not halt on input w. When viewed as a Boolean function, “WillHalt (M Theorem Turing Machine “WillHalt (M, w)” does not exist. Proof: This theorem is proved by contradiction. Suppose we could build a machine “WillHalt”. Then we can certainly build a second machine, “LoopIfHalts”, that will go into an infinite loop if and only if “WillHalt” accepts its input: Function LoopIfHalts (M, w): if WillHalt (M, w) then while true do { } else return false; We will also define a machine “LoopIfHaltOnItSelf” that, for any given input M, representing a Turing machine, will determine what will happen if M is applied to itself, and loops if M will halt in this case. Function LoopIfHaltsOnItself (M): return LoopIfHalts (M, M): Finally, we ask what happens if we try: Func tion Impos sible: return LoopIfHaltsOnItself (LoopIfHaltsOnItself): This machine, when applied to itself, goes into an infinite loop if and only if it halts when applied to itself. This is impossible. Hence the theorem is proved. Implications of Halting Problem Programming The Theorem of “Halting Problem” does not say that we can never determine whether or not a given program halts on a given input. Most of the times, for practical reasons, we could eliminate infinite loops from programs. Sometimes a “meta-program” is used to check another program for potential infinite loops, and get this meta-program to work most of the time. The theorem says that we cannot ever write such a meta-program and have it work all of the time. This result is also used to demonstrate that certain other programs are also impossible. The basic outline is as follows: (i) If we could solve a problem X, we could solve the Halting problem (ii) We cannot solve the Halting Problem
  • 7. (iii) Therefore, we cannot solve problem X A Turing machine can be "programmed," in much the same manner as a computer is programmed. When one specifies the function which we usually call d for a Tm, he is really writing a program for the Tm. 1. Storage in finite Control The finite control can be used to hold a finite amount of information. To do so, the state is written as a pair of elements, one exercising control and the other storing a symbol. It should be emphasized that this arrangement is for conceptual purposes only. No modification in the definition of the Turing machine has been made. Example Consider the Turing machine Solution 2. Multiple Tracks We can imagine that the tape of the Turing machine is divided into k tracks, for any finite k. This arrangement is shown in Fig., with k = 3. What is actually done is that the symbols on the tape are considered as k-tuples. One component for each track. Example The tape in Fig. can be imagined to be that of a Turing machine which takes a binary input greater than 2, written on the first track, and determines if it is a prime. The input is surrounded by ¢ and $ on the first track. Thus, the allowable input symbols are [¢, B, B], [0, B, B ], [1, B, B ], and [$, B, B]. These
  • 8. symbols can be identified with ¢, 0, 1, and $, respectively, when viewed as input symbols. The blank symbol can be represented by [B, B, B ] To test if its input is a prime, the Tm first writes the number two in binary on the second track and copies the first track onto the third track. Then, the second track is subtracted, as many times as possible, from the third track, effectively dividing the third track by the second and leaving the remainder. If the remainder is zero, the number on the first track is not a prime. If the remainder is nonzero, increase the number on the second track by one. If now the second track equals the first, the number on the first track is a prime, because it cannot be divided by any number between one and itself. If the second is less than the first, the whole operation is repeated for the new number on the second track. In Fig., the Tm is testing to determine if 47 is a prime. The Tm is dividing by 5; already 5 has been subtracted twice, so 37 appears on the third track.