0% found this document useful (0 votes)
23 views10 pages

Jan-June 2025 Btcs 4 Sem v10 Btcs404 Btcs404 Unit5 Notes

The document provides an overview of Turing Machines, including their definition, components, and types such as multi-tape and non-deterministic Turing Machines. It discusses the concepts of time and space complexity, language acceptance and decidability, and provides examples of designing Turing Machines for specific tasks. Additionally, it addresses undecidable languages and the halting problem, illustrating the limitations of Turing Machines in decision-making.

Uploaded by

ved26raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views10 pages

Jan-June 2025 Btcs 4 Sem v10 Btcs404 Btcs404 Unit5 Notes

The document provides an overview of Turing Machines, including their definition, components, and types such as multi-tape and non-deterministic Turing Machines. It discusses the concepts of time and space complexity, language acceptance and decidability, and provides examples of designing Turing Machines for specific tasks. Additionally, it addresses undecidable languages and the halting problem, illustrating the limitations of Turing Machines in decision-making.

Uploaded by

ved26raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

KALINGA UNIVERSITY

Department of Computer Science


Unit – 5
COURSE: BTCSAIML SEM/Year: 4th Sem
SUBJECT: TOAFL (BTCS 404)

Turing Machine:
 A Turing Machine is an accepting device which accepts the languages (recursive
enumerable set) generated by type 0 grammars. It was invented in 1936 by Alan Turi
Definition
 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.
 A state register stores the state of the Turing machine. After reading an input symbol
is replaced with another symbol, its internal state is changed, and it moves from one
to the right or left. If the TM reaches the final state, the input string is accepted,
otherwise rejected.
 A TM can be formally described as a 7-tuple (Q, X, Ʃ, δ, q0, B, F) where:
o Q is a finite set of states
o X is the tape alphabet
o Ʃ is the input alphabet
o δ is a transition function; δ : Q × X → Q × X × {Left_shift, Right_shift}.
o q0 is the initial state
o B is the blank symbol
o F is the set of final states
Comparison with the previous automaton:
 The following table shows a comparison of how a Turing machine differs from Finite
Automaton and Pushdown Automaton.
Machine Stack Data Structure Deterministic?
Finite Automation NA Yes
Pushdown Automation Last in First Out (LIFO) No
Turing Machine Infinite Tape Yes
Example of Turing Machine:
 Turing Machine M = (Q, X, Ʃ, δ, q0, B, F) with
o Q = {q0, q1, q2, q3}
o X = {a, b}
o Ʃ = {1}
o q0 = {q0}
o B = blank symbol
o F = {qf}
o δ is given by:
Tape Alphabet Present State ‘q0’ Present State Present State
Symbol ‘q1’ ‘q2’
a 1Rq1 1Lq0 1Lqf

1
b 1Lq2 1Rq1 1Rqf

 Here the transition 1Rq1 implies that the write symbol is 1, the tape moves right, and
the next state is q1. Similarly, the transition 1Lq 2 implies that the write symbol is 1,
the tape moves left, and the next state is q2.
Time and Space Complexity of a Turing Machine:
 For a Turing machine, the time complexity refers to the measure of the number of
times the tape moves when the machine is initialized for some input symbols and the
space complexity is the number of cells of the tape written.
 Time complexity all reasonable functions: T(n) = O(n log n)
 TM's space complexity: S(n) = O(n)
Accepted Language and Decided Language:
 A TM accepts a language if it enters into a final state for any input string ‘w’. A
language is recursively enumerable (generated by Type - 0 grammar) if it is accepted
by a Turing machine.
 A TM decides a language if it accepts it and enters into a rejecting state for any input
not in the language. A language is recursive if it is decided by a Turing machine.
 There may be some cases where a TM does not stop. Such TM accepts the language,
but it does not decide it.
Designing a Turing Machine:
 The basic guidelines of designing a Turing machine have been explained below with
the help of a couple of examples.

Example 1: Design a TM to recognize all strings consisting of an odd number of a’s.


Solution:
 The Turing machine M can be constructed by the following moves:
o Let q1 be the initial state.
o If M is in q1; on scanning α, it enters the state q2 and writes B (blank).
o If M is in q2; on scanning α, it enters the state q1 and writes B (blank).
 From the above moves, we can see that M enters the state q1 if it scans an even
number of α’s and it enters the state q2 if it scans an odd number of α’s. Hence q2 is
the only accepting state.
 Hence, M = {{q1, q2}, {1}, {1, B}, δ, q1, B, {q2}}
 Here δ is given by:
Tape Alphabet Symbol Present State ‘q1’ Present State ‘q2’
α BRq2 BRq1
Example 2: Design a Turing Machine that reads a string representing a binary number and
erases all leading 0’s in the string. However, if the string comprises of only 0’s, it keeps one
0.
Solution:
 Let us assume that the input string is terminated by a blank symbol, B, at each end of
the string.
 The Turing Machine, M, can be constructed by the following moves:
o Let q0 be the initial state.

2
o If M is in q0, on reading 0, it moves right, enters the state q 1 and erases 0. On
reading 1, it enters the state q2 and moves right.
o If M is in q1, on reading 0, it moves right and erases 0, i.e., it replaces 0’s by
B’s. On reaching the leftmost 1, it enters q 2 and moves right. If it reaches B,
i.e., the string comprises of only 0’s, it moves left and enters the state q3.
o If M is in q2, on reading either 0 or 1, it moves right. On reaching B, it moves
left and enters the state q 4. This validates that the string comprises only of 0’s
and 1’s.
o If M is in q3, it replaces B by 0, moves left and reaches the final state qf.
o If M is in q4, on reading either 0 or 1, it moves left. On reaching the beginning
of the string, i.e., when it reads B, it reaches the final state qf.
 Hence, M = {{q0, q1, q2, q3, q4, qf}, {0, 1, B}, {1, B}, δ, q0, B, {qf}}.
 Here, δ is given by:
Tape alphabet Present Present Present Present Present
symbol state ‘q0’ state ‘q1’ state ‘q2’ state ‘q3’ state ‘q4’
0 BRq1 BRq1 0Rq2 - 0Lq4
1 1Rq2 1Rq2 1Rq2 - 1Lq4
B BRq1 BLq3 BLq4 0Lqf BRqf

Multi-tape Turing Machine:


 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. At first, 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.

 Multi-tape Turing machine can be formally described as a 6-tuple (Q, X, B, δ, q0, F)


where:
o Q is a finite set of states
o X is the tape alphabet
o B is the blank symbol
o δ is a relation on states and symbols where
δ: Q x Xk → Q x (X x {Left_shift, Right_shift, No_shift })
where there is k number of tapes
o q0 is the initial state
o F is the set of final states

3
 Note: Every Multi-tape Turing machine has an equivalent single-tape Turing
machine.

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. It accepts recursively enumerable
languages like a normal single-track single-tape Turing Machine accepts.
 Multi-track Turing machine can be formally described as a 6-tuple (Q, X, Ʃ, δ, q 0, F)
where:
o Q is a finite set of states
o X is the tape alphabet
o Ʃ is the input alphabet
o δ is a relation on states and symbols where
o δ(Qi, [a1, a2, a3, ....]) = (Qj, [b1, b2, b3, ....], Left_shift or Right_shift)
o q0 is the initial state
o F is the set of final states.
 Note: For every single-track Turing Machine S, there is an equivalent multi-track
Turing Machine M such that L(S) = L(M).
Non-deterministic Turing Machine:
 In a Non-Deterministic Turing Machine, for every state and symbol, there are a group
of actions the TM can have. So, here the transitions are not deterministic. The
computation of a non-deterministic Turing Machine is a tree of configurations that
can be reached from the start configuration.
 An input is accepted if there is at least one node of the tree which is an accept
configuration, otherwise it is not accepted.
 If all branches of the computational tree halt on all inputs, the non-deterministic
Turing Machine is called a Decider and if for some input, all branches are rejected,
the input is also rejected.
 Non-deterministic Turing machine can be formally defined as a 6-tuple that are:
(Q, X, Ʃ, δ, q0, B, F) where:
o Q is a finite set of states
o X is the tape alphabet
o Ʃ is the input alphabet
o Transition function δ: Q x X → P(Q x X x {Left_shift, Right_shift}).
o q0 is the initial state
o B is the blank symbol
o F is the set of final states
Semi-Infinite Tape Turing Machine:
 A Turing Machine with a semi-infinite tape has a left end but no right end. The left
end is limited with an end marker.

 It is a two-track tape:

4
o Upper track: It represents the cells to the right of the initial head position.
o Lower track: It represents the cells to the left of the initial head position in
reverse order.

 The infinite length input string is initially written on the tape in contiguous tape cells.
The machine starts from the initial state q0 and the head scans from the left end
marker ‘End’.
 In each step, it reads the symbol on the tape under its head. It writes a new symbol on
that tape cell and then it moves the head either into left or right one tape cell. A
transition function determines the actions to be taken.
 It has two special states called accept state and reject state. If at any point of time it
enters into the accepted state, the input is accepted and if it enters into the reject state,
the input is rejected by the TM. In some cases, it continues to run infinitely without
being accepted or rejected for some certain input symbols.
 Note: Turing machines with semi-infinite tape are equivalent to standard Turing
machines.
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
 The computation is restricted to the constant bounded area. The input alphabet
contains two special symbols which serve as left end markers and right end markers
which mean the transitions neither move to the left of the left end marker nor to the
right of the right end marker of the tape.
 A linear bounded automaton can be defined as an 8-tuple (Q, X, Ʃ, q0, ML, MR, δ, F)
where:
o Q is a finite set of states
o X is the tape alphabet
o Ʃ is the input alphabet
o q0 is the initial state
o ML is the left end marker
o MR is the right end marker where MR ≠ ML
o δ 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.
o F is the set of final states.
 A deterministic linear bounded automation is always context-sensitive and the linear
bounded automation with empty language is undecidable.
Language Decidability:
 A language is called decidable or recursive if there is a Turing machine which accepts
and halts on every input string w. Every decidable language is Turing Acceptable.

5
 A decision problem P is decidable if the language L of all yes instances to P is
decidable.
 For a decidable language, for each input string, the TM halts either at the accept or the
reject state as depicted in the following diagram:

Example 1: Find out whether the following problem is decidable or not: Is a number ‘m’
prime?
Solution:
 Prime numbers = {2, 3, 5, 7, 11, 13, ...}
 Divide the number ‘m’ by all the numbers between ‘2’ and ‘√m’ starting from ‘2’.
 If any of these numbers produce a remainder zero, then it goes to the “Rejected state”,
otherwise it goes to the “Accepted state”. So, here the answer could be made by ‘Yes’
or ‘No’.
 Hence, it is a decidable problem.
Example 2: Given a regular language L and string w, how can we check if wϵ L?
Solution:
 Take the DFA that accepts L and check if w is accepted.

 Some more decidable problems are:


o Does DFA accept the empty language?
o Is L1 ∩ L2 = ϕ for regular sets?
Note:
1. If a language L is decidable, then its complement L' is also decidable.

6
2. If a language is decidable, then there is an enumerator for it.
Undecidable Language:
 For an undecidable language, there is no Turing Machine which accepts the language
and makes a decision for every input string w (TM can make decision for some input
string though).
 A decision problem P is called “undecidable” if the language L of all yes instances to
P is not decidable. Undecidable languages are not recursive languages, but sometimes,
they may be recursively enumerable languages.

Example:
 The halting problem of Turing machine
 The mortality problem
 The mortal matrix problem
 The Post correspondence problem, etc.
Turing Machine Halting Machine:
 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.
 Proof: At first, we will assume that such a Turing machine exists to solve this
problem and then we will show it is contradicting itself. We will call this Turing
machine as a Halting machine that produces a ‘yes’ or ‘no’ in a finite amount of
time. If the halting machine finishes in a finite amount of time, the output comes as
‘yes’, otherwise as ‘no’. The following is the block diagram of a Halting machine:

 Now we will design an inverted halting machine (HM)’ as:


o If H returns YES, then loop forever.
o If H returns NO, then halt.
 The following is the block diagram of an ‘Inverted halting machine’:

7
 Further, a machine (HM)2 which input itself is constructed as follows:
o If (HM)2 halts on input, loop forever.
o Else, halt.
 Here, we have got a contradiction. Hence, the halting problem is undecidable.

 L= {<M> | L (M) ϵ P} is undecidable when p, a non-trivial property of the Turing


Rice Theorem:

machine, is undecidable.

 Property 1: If M1 and M2 recognize the same language, then either <M1><M2> ϵ L


 If the following two properties hold, it is proved as undecidable:

or <M1> <M2> ∉ L
 Property 2: For some M1 and M2 such that <M1> ∈ L and <M2> ∉ L
 Proof:

o Let us assume <X1> ϵ L such that L(X1) = φ and <X2> ∉ L.


o Let there are two Turing machines X1 and X2.

 For an input ‘w’ in a particular instant, perform the following steps:


o If X accepts w, then simulate X2 on x.
o Run Z on input <W>.

o If X accepts w, then L(W) = L(X2) and <W> ∉ P


o If Z accepts <W>, Reject it; and if Z rejects <W>, accept it.

o If M does not accept w, then L(W) = L(X1) = f and <W> ϵ P


 Here the contradiction arises. Hence, it is undecidable.
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 i 1, i2, …. ik,
where 1 ≤ ij ≤ n, the condition xi1 …. xik = yi1 … = yik satisfies.
 Example 1: 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
M 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.

8
 Example 2: Find whether the lists M = (ab, bab, bbaaa) and N = (a, ba, bab) have a
Post Correspondence Solution?
 Solution:
x1 x2 x3
M ab bab bbaaa
M a ba bab
 In this case, there is no solution because: | x2x1x3 | = | y2y1y3 | (Lengths are not same).
 Hence, it can be said that this Post Correspondence Problem is undecidable.
Universal Turing Machines:
 Turing machines are abstract computing devices. Each Turing machine represents a
particular algorithm. Hence we can think of Turing machines as being "hard-wired".

 Is there a programmable Turing machine that can solve any problem solved by a
"hard-wired" Turing machine? The answer is "yes", the programmable Turing
machine is called "universal Turing machine".
 Basic Idea: The Universal TM will take as input a description of a standard TM and
an input w in the alphabet of the standard TM, and will halt if and only if the standard
TM halts on w.
The Church - Turing Thesis:
 Intuitive notion of an algorithm: a sequence of steps to solve a problem.
 Questions: What is the meaning of "solve" and "problem"?
 Answers:
o Problem: This is a mapping. Can be represented as a function, or as a set
membership "yes/no" question.
o To solve a problem: To find a Turing machine that computes the function or
answers the question.
 Church-Turing Thesis:
o Any Turing machine that halts on all inputs corresponds to an algorithm, and
any algorithm can be represented by a Turing machine. This is the formal
definition of an algorithm. This is not a theorem - only a hypothesis.
o In computability theory, the Church–Turing thesis (also known as the Church-
Turing conjecture, Church's thesis, Church's conjecture, and Turing's thesis) is
a combined hypothesis ("thesis") about the nature of functions whose values
are effectively calculable; i.e. computable.
o In simple terms, it states that "everything computable is computable by a
Turing machine."
Recursive and Recursively Enumerable Languages:
 Remember that there are three possible outcomes of executing a Turing machine over
a given input. The Turing machine may:
o Halt and accept the input;
o Halt and reject the input; or
o Never halt.
 A language is recursive if there exists a Turing machine that accepts every string of
the language and rejects every string (over the same alphabet) that is not in the
language. Note that, if a language L is recursive, then its complement -L must also be
recursive. (Why?)

9
 A language is recursively enumerable if there exists a Turing machine that accepts
every string of the language, and does not accept strings that are not in the language.
(Strings that are not in the language may be rejected or may cause the Turing machine
to go into an infinite loop.)
 Clearly, every recursive language is also recursively enumerable. It is not obvious
whether every recursively enumerable language is also recursive.

10

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy