Recursively Enumerable Sets and Turing Machines, Decidability
Recursively Enumerable Sets and Turing Machines, Decidability
Recursively Enumerable
Sets and Turing Machines,
Decidability
LEARNING OBJECTIVES
Turing
machine
Control unit
A Turing machine is a kind of state machine, which is much more
powerful in terms of languages it can recognize. At any time, the
machine is in any one of the finite number of states. Instructions
for a turing machine include the specification of conditions, under
which the machine will make transitions from one state to other.
5.38 | Unit 5 • Theory of Computation
•• A TM (turing machine) consists of Tape, Head, control unit. 2. LOOP (TM): It is the set of all strings, w ∈ ∑* ∋ if
•• Tape: A tape is divided into a sequence of numbered the tape initially contains w and the TM is then run,
cells, Each cell contains a symbol and cells that have not then the TM loops forever (infinite loop).
been written before are assumed to be filled with a blank 3. Reject (TM): It is the set of all strings w ∈ ∑* ∋, any
symbol (B). The set of symbols of tape is denoted by . of the following 3-cases arise.
The tape is assumed to be arbitrarily extensible to the left
Case I: T here may be a state and a symbol under the tape
as well as to the right.
head, for which δ does not have a value.
•• Head: In a single step, a tape head reads the contents of a
Case II: If the head is reading the left most cell (i) contain-
cell on the tape (reads a symbol), replaces it with some other
ing the symbol x, the state of TM is say q, then δ
characters (writes a symbol) and repositions itself to the
(q, x) suggests a move to the left of the current
next cell to the right or to the left of the one it has just read
cell. However as there is no cell to the left, no
or does not move (moves left or right or does not move).
move is possible.
•• Control unit: The reading from the tape or writing into
Case III: If TM enters an infinite loop or if a TM rejects a
the tape is determined by the control unit. It contains a
given string w, because of above two cases, TM
finite set of states, Q. The states are:
crashes (terminates unsuccessfully).
1. Initial state, q0
2. Halt state, h: This is state in which TM stops all
further operations. There can be one or more halt Languages Accepted by a TM
states in a TM.
3. Other states. •• The language accepted by TM is the set of accepted
strings w ∈ ∑*.
Note: A TM on entering the halt state stops making moves
•• Formally, let M = (Q, ∑, , δ, q0, B, h) be a TM. The lan-
and whatever string is there on the tape, will be taken as the
guage accepted by M denoted by L(M) is defined as, L(M)
output, irrespective of whether the position of head is at the
= {w/w∈ z* and if w = a1… an then, (qo, ε, a1, a2, …an) (h,
end or in the middle of the string on the tape.
b, …, bi-1, bj bn) for some b1, b2 … bn ∈ N* ∋}
Transition Diagram of TM L(M) = {W: qo w ├ *x1hx2}
•• There are three types of turing machine related
Reads a symbol
a → b, L languages:
p q writes a symbol
Turing Acceptable language: A language, L over
1.
Move Right (R)
a → b, R some alphabet is said to be turing acceptable language
p q Move Left (L) if there exists a TM, M ∋ L = L(M )
No Move (N) Turing Decidable Language: A language L over
2.
∑ i.e., L ⊆ ∑* is said to be turing decidable, if both
Specification of TM languages, L and its complement ∑* - L are turing
acceptable.
5-Tuple specification:
Recursively Enumerable Language: A language L
3.
TM = (state1, Read symbol, write symbol, L/R/N, state 2).
is recursively enumerable, if it is accepted by a TM.
7 - Tuple specification of TM:
A TM, M is represented as a 7-tuple: Example 1: Let M be a turing machine has M = (Q, , ∑,
M = (Q, ∑, , δ, q0, B, h) where δ, S, B, F ) with Q = {qo, q1, q2, q3, q4}, ={a, b, X, Y, #},
Q → Finite set of states ∑ = {a, b}, S = q0, B = #, δ given by:
∑ → Finite set of non-blank symbols
→ Set of tape characters a b X Y #
qo → qo ∈ Q, initial state q0 (q1, X, R) - - (q3, Y, R)
B → Blank character q1 (q1, a, R) (q2, Y, L) - (q1, Y, R)
h → h ⊆ Q, final state
q2 (q2, a, L) - (q0, X, R) (q2, Y, L)
δ → Transition function, Q × → Q × x {L, R, N}
q3 - - - (q3, Y, R) (q4, #, R)
String classes in TM q4 - - - - -
Every TM, over the alphabet ∑, divides set of input string w Which of following is true about M ?
into three classes: (A) M halts on L having ‘baa’ as substring
1. Accept (TM): It is the set of all strings w ∈ ∑* ∋ if the (B) M halts on L having ‘bab’ as substring
tape initially contains w and the TM is then run, then (C) M halts on L = {an bn/n ≥ 1}
TM ends in a halt state. (D) M halts on L not having ‘bbaa’ as substring.
Chapter 3 • Recursively Enumerable Sets and Turing Machines, Decidability | 5.39
a1 a2 ai an B
1 2 3 k
Finite
control
B
•• An offline TM is a multi tape TM, whose input tape is Combining turing machines
read only. The input is surrounded by end markers, ¢ on If TM1 and TM2 are turing machines, then we can combine
left and $ on right. The TM is not allowed to move the these machines and create a Turing machine which will first
input tape head off the region between ¢ and $. behave like TM1 and TM2.
To combine two turing machines follow below steps:
Multi stack machine
1. Change all states in TM2, so that they do not conflict
•• A deterministic two stack machine is a deterministic TM with the state names in TM1.
with a read only input and two storage tapes. 2. Change all halts in TM1’s transition table to the new
name of the start state of TM2.
Note: 3. Append TM2’s transition table to the foot of TM1’s
•• All these types of TM’s does not add any language transition table.
accepting power and all these are equivalent to the basic •• If TM1 and TM2 are combined in this way, we will write
model. it as TM1 → TM2.
•• Any language accepted by a 2-PDA can be accepted by
some TM and any language accepted by a TM can be So this new machine starts off in the initial state of TM1,
accepted by some 2-PDA. Accepting power of a TM = operates as per TM1 until TM1 would halt then it launches
accepting power of a computer. TM2 and operates a TM2, until TM2 would halt.
•• Any language accepted by a PDA with n stacks (n ≥ 2),
can also be accepted by some TM.
Recursively Enumerable languages
Example 2: Consider the following statement about L:
1. L is accepted by multi-tape turing machine M1. •• A language L over the alphabet ∑ is called ‘recursively
2. L is also accepted by single tape turing machine M2. enumerable’ if there is a TM, M that accept every word in
L and either rejects or loops for every word in language
Which of following statement is correct? L′, the complement of L.
(A) Acceptance by M2 is slower by O (n2) Accept (M) = L
(B) Acceptance of M2 is slower by O (n) Reject (M) + Loop (M) = L′.
(C) Acceptance of M2 is faster by O (n) •• When TM, M is still running on some input of recursively
enumerable languages, it is not decided that M will even-
(D) Acceptance of M2 is faster by O (n2)
tually accept, if let it run for long time or M will run for-
Solution: (A) ever (in loop).
While simulating multi-tape TM on a single tape TM the Recursive language
head has to move at least 2k cells per move, where k is the
•• A language is said to be recursive, if there exists a TM
number of tracks on single tape TM. Thus for k moves,
which will halt and accept when presented with any input
∑ i =1 2i = 2k 2.
k
string w ∈∑*, only if the string is in the language other-
Which means quadratic slow down? wise will halt and reject the string.
Thus, acceptance of multi-tape is faster by O(n2). •• Thus, for turing decidable language L, there is a TM
which halts for a large number of inputs w belonging to L.
•• A TM that always halts is known as a decider or a
Universal turing machine
total turing machine and is said to decide the recursive
A Universal turing machine is a turing machine that can language. The recursive language is also called as recur-
simulate an arbitrary turing machine on arbitrary input. sive set of decidable.
•• The machine consists of an input output relation to the •• A language accepted by a TM is said to be recursively
machine computes. enumerable language. The subclass of recursively enu-
merable sets are said to be recursive sets or recursive
•• The input is given in binary form on the machine tape and
language.
the output consists of the contents of the tape when the
machine halts. Note:
•• The contents of the tape will change based on the Finite •• All recursive languages are also recursively enumerable.
State Machine (FSM) inside the TM. •• There may be languages which are recursively enumer-
•• The problem with TM is that a different machine will be able but not recursive.
constructed for every new computation to be performed. •• Set of all possible words over the alphabet of the recur-
•• A UTM can simulate any other machine. sive language is a recursive set.
Chapter 3 • Recursively Enumerable Sets and Turing Machines, Decidability | 5.41
•• Set of all possible words, over the alphabet of the recur- •• These languages cannot be defined by any effective
sive enumerable language, is a recursively enumerable set. procedure.
For any non-empty ∑, there exist languages that are not
Recursively Enumerable.
Infinite table for all i and j is:
Recursively enumerable
j →
1 2 3 4
Recursive 0 1 1 0
1
2 1 1 0 0
RE but not recursive
i 3 0 0 1 0
Undecidability of the universal languages That’s means, a machine M1, which can tell whether any
•• The universal language, Lu is a recursively enumerable other TM will halt on particular input does not exist. Hence
language but not recursive. halting problem is unsolvable.
Recursively
Regular sets DCFL’S CFL’S CSL’S Recursive sets enumerable sets
(1) Union Y N Y Y Y Y
(2) Concatenation Y N Y Y Y Y
(4) Intersection Y N N Y Y Y
(5) Complementation Y Y N Y Y N
(6) Homomorphism Y N Y N N Y
(8) Reversal Y N Y Y Y Y
(9) Substitution Y N Y Y N Y
Exercises
Practice Problems 1 4. A language is given as INFINITEDFA= {<A>: A is a
Directions for questions 1 to 15: Select the correct alterna- DFA and L (A) is an infinite language}. Which of fol-
tive from the given choices. lowing is true?
(A) Un-decidable (B) Decidable
1. The TM M over ∑ = {1} is given below (C) Trivially decidable (D) None of above.
1/1, R 5. A TM designed over an alphabet {0, 1, #}, where 0
1/1, R indicates blank, which takes a non-null string of 1’s and
b/1, R q1 #‘s and transfer’s the right-most symbol to the left-most
q0 b/b, L end contains-states. (Ex: 000#1#1#1000 … becomes
b/b, L
0001#1#1#000)
q2 (A) 4 (B) 3
(C) 6 (D) 5.
1/b, L 6. Which of following statements are true?
q3 (i) Let K, L be decidable languages. The concatenation
q4
b/b, R 1/1, L of languages, K, L is also decidable language.
(ii) Let L be Turing recognizable language. Then the
What does M generate? complement, L1 is also Turing recognizable language.
(A) The output is total recursive multiplication (A) (i) and (ii) (B) Only (ii)
function. (C) Both are false (D) Only (i)
(B) The output is addition of two integers. 7. Let Ti: denote i th TM. Given, X determines whether X∈
(C) The output is subtraction of two integers. S, Where the set S is defined inductively as follows: If
(D) The output should be w1w2 if input = (w1w2) a pair u ∈ S, then u2 + 1, 3u + 2 and u! are all members of
of words. S. Which of following is true about the given decision
2. Consider language, problem?
(A) Decidable (B) Un-decidable
A = {<M>: M is a DFA which doesn’t accept any string
(C) Trivially decidable (D) No solution.
containing odd number 1’s}
8. Fermat’s last theorem asserts that there are no integer
Which of following is true about A?
solution (x, y, z, n) to equation xn + yn = zn satisfying x, y
(A) A is Trivially decidable (B) A is undecidable
> 0 and n > 2. Which of the following is true regarding
(C) A is decidable (D) None of these
the halting problem?
3. Consider EQCFG= {<G1G2>: G1, G2 are CFGs and L (G1) (A) Decidable
= L (G2)}. Which of following is true about EQCFG? (C) Un-decidable
(A) Recognizable (B) Co-Recognizable (C) Trivially decidable
(C) Un-recognizable (D) None of the above. (D) May or may not have solution.
Chapter 3 • Recursively Enumerable Sets and Turing Machines, Decidability | 5.45
9. The TM, T is designed as 11. Consider three problems, P1, P2 and P3. It is known that
0/0, R P1 has polynomial time solution, P2 is NP-complete
0/x, R 0/x, R
q0 q1 q2 y/y, R and P3 is in NP. Which one of the following is true?
y/y, R (A) P3 has polynomial time solution if P1 is polyno-
x/x, R 1/y, L mial time reducible to P3.
q5
B y/y, L (B) P3 is NP-complete if P3 is polynomial time reduc-
B x/x, L ible to P2.
y/y, R q4 q3
0/0, L (C) P3 is NP complete if P2 is reducible to P3
q6
(D) P3 has polynomial time complexity and P3 is re-
ducible to P2.
Which of following is true? 12. Let FHAM be the problem of finding a Hamiltonian
(A) T halts on 0n1n, n ≥ 0 cycle in a graph G and DHAM be the problem of deter-
(B) T halts on (01) (0n 1n), n ≥ 0 mining if a Hamiltonian cycle exists in a graph. Which
2 2
(C) T halts on 0 n 1n , n ≥ 0 one of the following is true?
(D) T halts on 02n1n , n ≥ 0 (A) Both FHAM and DHAM are NP-hard.
10. Design TM, which reads an input and starts inverting (B) FHAM is NP-hard, but DHAM is not.
0’s to 1’s till the first 1. The first 1 also inverted. After it (C) DHAM is NP-hard but FHAM is not.
has inverted first 1, it read the next symbols and keeps (D) Neither DHAM nor FHAM is NP-hard.
them as they are till the next 1. After encountering 1, it
starts repeating the cycle by inverting the symbol till 13. The solution for the system of post correspondence
next 1. It halts when it encounters a blank symbol? problem, A = {ba, abb, bab}, B = {bab, bb, abb} is
(A) 1312212 (B) 15234434
(A) q0 0/1, R
q1 (C) 1311322 (D) No solution.
B/B, R B/B, R x → x, R x → x, R
* → *, R b → x, R
q2 0 1 2
a → x, R c → x, R
(C) 1/0, R 1/1, R
0/1, R * → *, R a → a, R
q0 q1
6 3
b → x, R c → x, R
0/0, R c → x, R
B/B, R 8 7 4
b → b, R
a → a, L B → B, R
q2 c → c, L
b → b, L 5
(D) 0/1, R 0/0, R x → x, L
1/0, R
q0 q1
Which of following is true about M?
1/1, R
M is designed for a n b n c n, n ≥ 0
(A)
B/B, R B/B, R 2 3 4
M is designed for a n b n c n , n ≥ 0
(B)
q2 M is designed for an bn+1 cn+2, n ≥ 0
(C)
(D)
M is designed for an bn cn, n > 0
5.46 | Unit 5 • Theory of Computation
11. Consider three decision problems p1, p2 and p3. It is (A) 1312213 (B) 2113
known that p1 is decidable, p2 is undecidable. Which (C) 3112 (D) No solution.
one of following is true? 14. Given a Turing machine M, a state ‘q‘and a string ‘w’.
(A) p3 is decidable if p1 is reducible to p3 To determine whether M ever reaches state q when
(B) p3 is undecidable if p3 is reducible to p2 started with input w from its initial state is?
(C) p3 is undecidable if p2 is reducible to p3 (A) Decidable
(D) p3 is decidable if p3 is reducible to p2’s complement. (B) Un-decidable
12. Which one of following is not decidable? (C) Trivially decidable.
(A) Given a TM, M, a string S, and an integer K, M ac- (D) Can not be determined.
cepts S with in K-steps. 15. Given a Turing machine, M to determine whether M ever
(B) Equivalence of two given Turing machines. moves its head to the left when started with input W is:
(C) Language accepted by a given DFSA is non-empty. (A) Decidable
(D) Language accepted by a CFG is non-empty. (B) Un-decidable
13. What is the solution for the correspondence system (C) Trivially decidable.
with two lists x = {b, bab3, ba} and y = {b3, ba, a} (D) Can not be determined.
(D) If A ≤m B and B is not recursively enumerable III. L*1 ∩ L2 is context - free
then A is not recursively enumerable. IV. L1 ∪ L 2 is context - free
9. Let <M> be the encoding of a Turing machine as a (A) I only (B) I and III only
string over ∑ = {0, 1}. Let L = {<M>|M is a Turing (C) I and IV only (D) I, II and III only
machine that accepts a string of length 2014}. Then, L 14. Consider the following languages. [2016]
is
L1= {<M> | M takes at least 2016 steps on some
(A) Decidable and recursively enumerable input},
(B) Undesirable but recursively enumerable L2= {<M> | M takes at least 2016 steps on all inputs}
(C) Undesirable and not recursively enumerable and
(D) Decidable but not recursively enumerable L1= {<M> | M accepts e}
10. For any two languages L1 and L2 such that L1 is con- where for each Turing machine M, <M> denotes a
text-free and L2 is recursively enumerable but not specific encoding of M. Which one of the following is
recursive, which of the following is/are necessarily TRUE?
true? [2015] (A) L1 is recursive and L2, L3 are not recursive
I. L1 (complement of L1) is recursive (B) L2 is recursive and L1, L3 are not recursive
II. L 2 (complement of L2) is recursive (C) L1, L2 are recursive L3 is not recursive
(D) L1, L2, L3 are recursive
III. L1 is context-free
IV. L1 ∪ L2 is recursively enumerable 15. Let A and B be finite alphabets and let # be a symbol
outside both A and B. Let f be a total function from A*
(A) I only (B) III only
to B*. We say f is computable if there exists a turning
(C) III and IV only (D) I and IV only
machine M which given an input x in A*, always halts
11. Consider the following statements. with f(x) on its tape. Let Lf denote the language {x #
I. The complement of every Turning decidable lan- f(x)| x ∈ A*}. Which of the following statements is
guage is Turing decidable. true: [2017]
II. There exists some language which is in NP but is (A) f is computable if and only if Lf is recursive.
not Turing decidable. (B) f is computable if and only if Lf is recursively
enumerable.
III. If L is a language in NP, L is Turing decidable.
(C) If f is computable then Lf is recursive, but not
Which of the above statements is/are true? [2015] conversely.
(A) Only II (B) Only III (D) If f is computable then Lf is recursively enumer-
(C) Only I and II (D) Only I and III able, but not conversely.
12. Let X be a recursive language and Y be a recursively
16. Let L(R) be the language represented by regular
enumerable but not recursive language. Let W and Z
expression R. Let L(G) be the language generated by
be two languages such that y reduces to W, and Z
a context free grammar G. Let L(M) be the language
reduces to x (reduction means the standard many-
accepted by a Turing machine M. Which of the fol-
one reduction). Which one of the following state-
lowing decision problems are undecidable? [2017]
ments is TRUE? [2016]
I. Given a regular expression R and a string w, is w
(A) W can be recursively enumerable and Z is recur-
∈ L(R)?
sive.
II. Given a context-free grammar G, is L(G) = Ø ?
(B) W can be recursive and Z is recursively enumer-
III. Given a context-free grammar G, is L(G) = ∑*
able.
for some alphabet ∑ ?
(C) W is not recursively enumerable and Z is recur-
IV. Given a Turing machine M and a string w, is w ∈
sive.
L(M)?
(D) W is not recursively enumerable and Z is not re-
(A) I and IV only (B) II and III only
cursive.
(C) II, III and IV only (D) III and IV only
13. Consider the following types of languages: L1:
Regular, L2: Context - free, L3: Recursive, L4: 17. The set of all recursively enumerable languages is:
Recursively enumerable. Which of the following is / [2018]
are TRUE? [2016] (A) Closed under complementation.
I. L3 ∪ L4 is recursively enumerable (B) Closed under intersection.
(C) A subset of the set of all recursive languages.
II. L 2 ∪ L3 is recursive (D) An uncountable set.
Chapter 3 • Recursively Enumerable Sets and Turing Machines, Decidability | 5.49
18. Consider the following problems. L(G) denotes the (IV) Given and NFA N, whether there is a determin-
language generated by a grammar G. L(M) denotes istic PDA P such that N and P accept the same
the language accepted by a machine M. language.
(I) For an unrestricted grammar G and a string w, Which one of the following statements is correct?
whether w ∈ L(G) [2018]
(II) Given a Turing machine M, whether L(M) is reg- (A) Only I and II are undecidable
ular (B) Only III is undecidable
(III) Given two grammars G1 and G2, whether L(G1) (C) Only II and IV are undecidable
= L(G2) (D) Only I, II and III are undecidable
Answer Keys
Exercises
Practice Problems 1
1. D 2. C 3. B 4. B 5. D 6. D 7. A 8. D 9. D 10. D
11. C 12. A 13. D 14. A 15. C
Practice Problems 2
1. B 2. D 3. B 4. B 5. A 6. B 7. C 8. B 9. D 10. B
11. C 12. B 13. B 14. B 15. A