0% found this document useful (0 votes)
17 views

Turing Machine

Uploaded by

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

Turing Machine

Uploaded by

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

Turing Machines

Introduction
A Turing machine (TM) is a finite-state
machine with an infinite tape and a tape head
that can read or write one tape cell and can
move left or right.
It normally accepts the input string, or
completes its computation, by entering a final
or accepting state.
 Tape is used for input and working storage
THE TURING MACHINE MODEL
Formal Definition of Turing Machine
Turing Machine is represented by-
M=(Q, Σ, Γ,δ,q0,b,F),
Where
Q is the finite state of states
Σ is the set of input symbols, not including b
Γ is the finite set of allowable tape symbols
δ is the next move function (transition function), a
mapping from
Q × Γ-> Q × Γ ×{L,R}
q0 in Q is the start state,
b a symbol of Γ is the blank, b does not belong to Σ
F is the set of final states.
Representation of Turing Machine
Turing machine can be represented by the
following ways:
Instantaneous Description
Transition Table
Transition Diagram
Now we will see how to design State Transition Diagram of Turing Machine for above problem:
Turing machine can work as Transducer as well as Acceptor.

NOTE: Turing machine can read as


well as write on the TAPE that is
the reason it can work as
TRANSDUCER.
TM for 1’s compliment
Q2. Design Turing machine as transducer for 2's
complement
Multi-track Turing Machine
Multi-track Turing machines, contain
multiple tracks
a single tape is assumed to be divided into
several tracks.
The only difference between the standard
TM and the TM with multiple tracks is the
set of tape symbols.
 In the case of the standard Turing
machine, tape symbols are elements of Γ ;
in the case of TM with multiple track, it is
Γ k where k is the number of tracks
Multi-track Turing Machine (contd..)
SUBROUTINES
Subroutines are used in computer languages, when
some task has to be done repeatedly. We can
implement this facility for TMs as well.
First, a TM program for the subroutine is written.
This will have an initial state and a 'return' state.
After reaching the return state, there is a temporary
halt.
 For using a subroutine, new states are introduced.
When there is a need for calling the subroutine,
moves are effected to enter the initial state for the
subroutine (when the return state of the subroutine
is reached) and to return to the main program of TM.
MULTITAPE TURING MACHINES
A Turing Machine with several tapes
Every Tape’s have their Controlled own R/W
Head
For N- tape TM M=(Q, Σ, ΓN,δ,q0,B,F)
we define δ : Q X ΓN ->Q X ΓN X { L , R} N
MULTITAPE TURING MACHINES
(contd..)

Finite Control

Tape 1

Tape 2

Tape 3

.
18
MULTITAPE TURING MACHINES (contd..)
Every language accepted by a multitape TM is
acceptable by some single-tape TM (that is,
the standard TM).
Suppose a language L is accepted by a k-tape TM
M.
We simulate M with a single-tape TM with 2k
tracks.
The second, fourth, ..., (2k)th tracks hold the
contents of the k-tapes. The first, third, ..., (2k - l)th
tracks hold a head marker (a symbol say X) to
indicate the position of the respective tape head.
Example: case k =2
Multi-tape TM Simulated by Standard
TM
NON DETERMINISTIC TURING MACHINES
 It is similar to DTM except that for any input symbol and
current state it has a number of choices

A string is accepted by a NDTM if there is a sequence of


moves that leads to a final state

The transition function δ: Q X Γ -> 2 Q X Γ X {L, R}


Nondeterministic Turing Machines
(NTM)
 The execution of an NTM is naturally represented by a
tree whose non-root nodes are all future
configurations

q0w

ID-1 ID-2

ID-3 ID-4 ID-5

ID-6 ID-7 ID-8 ID-9


Linear Bounded Automata
(LBA)
Linear Bounded Automata(contd..)
The input string w can be recognized by an
LBA if it can also be recognized by a Turing
machine using no more than kn cells of input
tape, where k is a constant specified in the
description of LBA.
The value of k does not depend on the input
string but is purely a property of the
machine.
 Whenever we process any string in LBA, we
shall assume that the input string is enclosed
within the endmarkers ¢ and $.
LBA and Context Sensitive Languages
The set of strings accepted by
nondeterministic LBA is the set of strings
generated by the context-sensitive grammars,
excluding the null strings.
If L is a context-sensitive language, then L is
accepted by a linear bounded automaton.
The converse is also true.
Recursive Enumerable
Language
Recursive Enumerable Language

For a given language if a Turing machine can be


designed then that language will be REL.

Halting Problem:
If TM answers YES for string belonging to language.
But for string not belonging to language TM can
either answer NO or it could go into infinite loop.

Then this is called Halting problem and such a


language is called Recursive Enumerable
Language.
Recursive Language
For a given language if a TM
can be designed which will halt
on below 2 decisions:

1.Whether String belongs to


language
2.Whether String does not
belong to language, then that
language will be recursive
language.
Decidable and Undecidable problems in Theory
of Computation

A problem is said to be Decidable if we can always


construct a corresponding algorithm that can answer the
problem correctly.
Suppose we are asked to compute all the prime numbers in
the range of 1000 to 2000. To find the solution of this
problem, we can easily devise an algorithm that can
enumerate all the prime numbers in this range.
In terms of a TM, a problem is said to be a Decidable
problem if there exists a corresponding TM, which halts on
every input with an answer- yes or no. It is also important
to know that these problems are termed as Turing
Decidable since a TM always halts on every input,
accepting or rejecting it.
Undecidable Problems
The problems for which we can’t construct an
algorithm that can answer the problem
correctly in finite time are termed as
Undecidable Problems. These problems may
be partially decidable but they will never be
decidable. That is there will always be a
condition that will lead the Turing Machine into
an infinite loop without providing an answer at
all.
We can understand Undecidable Problems
intuitively by considering Fermat’s Theorem,
a popular Undecidable Problem which states
that no three positive integers a, b and c for
any n>2 can ever satisfy the equation:
Examples –
• Whether a CFG generates all the strings or not?
As a CFG generates infinite strings, we can’t ever reach up to the last string and hence it is
Undecidable.
• Whether two CFG L and M equal?
Since we cannot determine all the strings of any CFG, we can predict that two CFG are
equal or not.
• Ambiguity of CFG?
There exist no algorithm which can check whether for the ambiguity of a CFL. We can only
check if any particular string of the CFL generates two different parse trees then the CFL is
ambiguous.
• Is it possible to convert a given ambiguous CFG into corresponding non-ambiguous CFL?
It is also an Undecidable Problem as there doesn’t exist any algorithm for the conversion of
an ambiguous CFL to non-ambiguous CFL.
• Is a language Learning which is a CFL, regular?
This is an Undecidable Problem as we can not find from the production rules of the CFL
whether it is regular or not.

Some more Undecidable Problems related to Turing machine:


• Membership problem of a Turing Machine?
• Finiteness of a Turing Machine?
• Emptiness of a Turing Machine?
• Whether the language accepted by Turing Machine is regular or CFL?
Post Correspondence Problem (PCP)
 The Post Correspondence Problem (PCP) is a well-known
decision problem in theoretical computer science and is
classified as **undecidable**. It was introduced by **Emil
Post** in 1946 and serves as a classic example of a problem
for which no algorithm can decide the solution in all cases.

 Definition**

 The PCP is defined as follows:

 Given two lists of strings over some alphabet \( \Sigma \):


 \[ A = [a_1, a_2, \dots, a_n] \]
 \[ B = [b_1, b_2, \dots, b_n] \]
Properties

 1. **Undecidability**:
 PCP is undecidable for arbitrary lists \( A \) and \( B \). This means
there is no general algorithm that can solve PCP for all instances.

 2. **Reduction to Other Problems**:


 The undecidability of PCP is often used to prove the undecidability
of other problems, such as problems involving Turing machines or
formal languages.

 3. **Modified PCP (MPCP)**:


 In the Modified PCP, a specific starting index \( i_1 \) is given, and
the problem asks whether there exists a solution sequence starting
with \( i_1 \).

 ---
Applications

- Proving undecidability in various areas of


theoretical computer science.
- Demonstrating concepts in formal
languages, automata theory, and
computation.

Let me know if you'd like an illustration of


how to construct or solve a PCP!
Quiz time(M)
Which of the following is a limitation of
Turing machines?
Inability to solve undecidable problems
Dependence on external inputs
Inability to perform parallel computations
What is the significance of the transition
function in a Turing machine?
Defines the next state based on current state
and input symbol
Controls the movement of the tape head
Determines the halting condition of the
machine
Which of the following statements about
Turing machines is true?
Turing machines can solve any computable
problem
Turing machines are physical devices
Turing machines operate at constant time
complexity
What is the role of the head in a Turing
machine?
Reads and writes symbols on the tape
Controls the execution of instructions
Stores intermediate results
Which of the following components are part
of a Turing machine?
Tape
Head
Registers
Input/Output devices
What is the significance of the Halting
Problem in relation to Turing Machines?
It is undecidable whether a Turing Machine
will halt on a given input
Turing Machines always halt on every input
The Halting Problem can be solved in
polynomial time
h of the following is NOT a component of a
Turing Machine?
Input/Output devices
Infinite tape
Finite control
Head
What is the role of the head in a Turing
Machine?
Reads/Writes symbols on the tape
Stores intermediate results
Controls the flow of execution
Which of the following languages can be
recognized by a Turing Machine?
Regular Languages
Context-Free Languages
Recursively Enumerable Languages
All
What is the difference between a
deterministic and non-deterministic Turing
Machine?
a. A deterministic Turing Machine has more
states than a non-deterministic Turing Machine
b. A deterministic Turing Machine follows a
single path of computation, while a non-
deterministic Turing Machine can explore
multiple paths simultaneously
What is the purpose of the transition function
in a Turing Machine?
Defines the behavior of the machine based on
its current state and input symbol
Determines the halting condition
Controls the movement of the tape head
UNIT 1
What is the definition of a finite automaton?
a. A mathematical model of computation
b. A type of computer
c. An infinite machine
d. A physical device
Ans a
Which of the following are examples of
regular languages?
a. a^n b^n c^n
b. Anbncn
c. aab*
d. none
What is the difference between DFA and
NFA?
a. DFA has a single unique transition for each
input symbol and state
b. NFA can have multiple transitions for the
same input symbol and state
c. NFA cannot recognize regular languages
d. DFA can have epsilon transitions
Which of the following statements about
Moore machine is true?
a. Moore machine outputs depend only on the
current state
b. Moore machine outputs depend only on the
input symbol
c. Moore machine outputs depend on both
current state and input symbol
d. Moore machine has no output function
What is the purpose of using regular
expressions in finite automata?
a. To handle complex computations
b. To simulate non-deterministic behavior
c. To create infinite loops in automata
d. To describe patterns that define regular
languages
Which of the following is an example of a
regular language?
Anbn
Anbncn
a*b*
All of above
What is the role of epsilon transitions in
NFA?
a. Allow the NFA to move to another state
without consuming any input
b. Force the NFA to accept all inputs
c. Make the NFA deterministic
d. Limit the NFA to a single final state
Which of the following is a characteristic of
regular languages?
a. Closed under union
b. Closed under complement
c. Closed under concatenation
d. All of above
What is the main goal of deterministic finite
automata (DFA)?
a. Output depends on the current state
b. Have multiple transitions for the same input
symbol and state
c. Accept all possible inputs
d. Recognize or reject strings based on a
defined set of rules
Which of the following is a property of
regular languages?
a. Require non-deterministic behavior
b. Can be recognized by finite automata
c. Can have infinite number of states
What is the purpose of transition functions in
finite automata?
a. Define how the automaton moves from one
state to another based on input symbols
b. Generate random outputs
c. Control the number of states in the
automaton
d. Determine the final state of the automaton
Which of the following is a characteristic of
non-deterministic finite automata (NFA)?
a. Can have epsilon transitions
b. Always has a unique transition for each
input symbol and state
c. Outputs depend only on the current state
d. None of above
What is the difference between NFA and DFA
in terms of memory usage?
a. NFA uses less memory than DFA
b. Both use the same amount of memory
c. DFA uses less memory than NFA
d. Memory usage depends on the input size
Which of the following operations are closed
under regular languages?
a. Union
b. Intersection
c. Complementation
d. All of above
What is the purpose of the transition function
in a finite automaton?
a. Generate random outputs
b. Control the acceptance of strings
c. Determine the initial state of the automaton
d. Define how the automaton moves between
states based on input symbols
Which of the following statements about
regular expressions is true?
a. Regular expressions can describe infinite
sets of strings
b. Regular expressions are equivalent to
context-free grammars
c. Regular expressions cannot represent
patterns
d. None of above.
What is the primary difference between a
deterministic finite automaton (DFA) and a
non-deterministic finite automaton (NFA)?
a. DFA can recognize non-regular languages
b. NFA has a fixed number of states
c. DFA has a unique transition for each input
symbol and state
d. NFA can have multiple transitions for the
same input symbol and state
What is the role of epsilon transitions in a
non-deterministic finite automaton (NFA)?
a. Force the NFA to accept all inputs
b. Make the NFA deterministic
c. Allow the NFA to move to another state
without consuming any input
Which of the following statements about
Moore machines is correct?
a. Moore machine outputs depend only on the
input symbol
b. Moore machine outputs depend on both
current state and input symbol
c. Moore machine has no output function
d. None of above
What is the main goal of using regular
languages in the context of formal language
theory?
a. To describe and recognize patterns in
strings efficiently
b. To create complex computational models
What does the ^ metacharacter signify in
a regular expression?
a) Matches any character
b) Matches the beginning of the string c)
Matches the end of the string
d) Negates the character class
Part 1: Regular Expressions (10
questions)
Which symbol matches zero or one
occurrence of the preceding character in
a regular expression?
a) +
b) *
c) ?
d) ^
What regular expression matches a
string that starts with "abc" and ends
with "xyz"?
a) abc.*xyz
b) abc^xyz$
c) (abc|xyz)
d) [abc]xyz
Which character class matches any
single lowercase letter?
a) [a-z] b) [A-Z]
c) \w
How can you match a literal dollar sign
($) in a regular expression?
a) $
b) \$
c) \dollar
d) [$]
What is the purpose of backreferences in
regular expressions?
a) To repeat a specific character or group
(Already covered by *, +, ?)
b) To match a previously captured substring
c) To define character classes
d) To escape special characters
Which regular expression matches a
valid US phone number (format XXX-XXX-
XXXX)?
a) \d{3}-\d{3}-\d{4}
b) [0-9]{3}-[0-9]{3}-[0-9]{4}
c) [A-Za-z]{3}-\d{3}-\d{4}
d) \w{3}-\w{3}-\w{4}
Which regular expression matches a
valid US phone number (format XXX-XXX-
XXXX)?
a) \d{3}-\d{3}-\d{4}
b) [0-9]{3}-[0-9]{3}-[0-9]{4}
c) [A-Za-z]{3}-\d{3}-\d{4}
d) \w{3}-\w{3}-\w{4}
In a transition system, what does an edge
labeled with ε (epsilon) represent?
a) An input symbol
b) A null move (transition without consuming
an input)
c) An end-of-string marker
d) An error state transition
What are some applications of regular
expressions?
a) Text validation (e.g., email addresses, phone
numbers)
 b) Data extraction from text files
c) Pattern matching in bioinformatics
d) All of the above
E) a,d
The pumping lemma for regular languages
states that for any regular language L,
there exists a pumping length p such that...
a) All strings in L longer than p can be pumped to
create a new string not in L.
b) All strings in L can be divided into three
substrings that can be repeated to create new
strings in L.
c) Only strings shorter than p can be pumped to
create new strings in L.
d) The language is finite.
1. Which of the following correctly describes
the solution to the equation R = Q + RP for a
regular language R and regular expressions P
and Q according to Arden's theorem?
a. - a) R can have any regular expression
representation.
- b) R has multiple solutions, depending on the
specific P and Q.
- c) R is always the concatenation of P and its
Kleene star (P*).
- d) R is the union of Q and any regular
1. The Myhill-Nerode theorem establishes a
connection between...
- a) Regular languages and context-free
languages.
 - b) Regular languages and finite automata.
 - c) Context-free languages and pushdown
automata.
 - d) Pushdown automata and Turing
machines.
According to the Myhill-Nerode theorem, a
language L is regular if and only if...
\a) It can be described by a context-free
grammar.
- b) It has a finite number of distinct prefixes.
- c) The equivalence relation induced by
indistinguishability of states has a finite
number of equivalence classes –
- d) It can be recognized by a Turing machine.
3. What is an equivalence class in the
context of the Myhill-Nerode theorem?
pen_spark-
a) A set of states in a finite automaton that
have the same outgoing transitions for all
symbols.
 - b) A set of strings in a language L that have
the same prefixes
 - c) A set of symbols that can be used to
construct strings in L.
 - d) A set of finite automata that recognize
How can the Myhill-Nerode theorem be used to
prove that a language is not regular?
a. - a) By showing that the language has an infinite
number of prefixes.
- b) By demonstrating that the language cannot be
described by a regular expression.
- c) By constructing a finite automaton with an
infinite number of states that recognizes the
language.
- d) If the language has a finite number of
equivalence classes induced by indistinguishability of
states, it's not regular.
The Myhill-Nerode theorem has applications
in...
a) Minimizing finite automata.
b) - b) Proving the closure properties of
regular languages.
- c) Parsing context-free grammars.
- d) Converting regular expressions to finite
automata.
How does the Myhill-Nerode theorem help in
minimizing finite automata?
a) By identifying redundant states that have
the same behavior.
b) - b) By reducing the number of transitions in
the automaton.
- c) By converting the automaton to a
nondeterministic form.
- d) By increasing the number of states to
handle more complex languages.
What is the relationship between the number of
states in a minimal DFA for a regular language L
and the number of equivalence classes induced
by the Myhill-Nerode theorem for L?
a) There is no direct relationship.
- b) The number of states in the DFA is always
greater than the number of equivalence classes.
- c) The number of states in the DFA is always
less than or equal to the number of equivalence
classes.
- d) The two quantities are always equal.

You might also like