Theory of Computation Practice Questions
Theory of Computation Practice Questions
Theory of Computation Practice Questions
(b) Let S = {⟨M⟩| M is a DFA that accepts w^R whenever it accepts w}. Show that S is
decidable.
Solution: We are mapping this problem into Equivalence of DFA that is decidable.
Let S = {(M) | M is a DFA that accepts w R whenever it accepts w}. We show that S is
decidable.
Given (M), which represents an automata M, we can construct an automata N such that L(N) =
L(M)R, that is, N accepts a word w if and only if M accepts wR.
Clearly, (M) ∈ S if and only if L(M) = L(N). Since Equivalence of DFA is decidable, there is an
algorithm deciding whether (M, N) ∈ Equivalence of DFA.
1. If (M, N) ∈ Equivalence of DFA, we have L(M) = L(N). Therefore, (M) ∈ S.
2. If (M, N)!∈ Equivalence of DFA, we have L(M) != L(N). Therefore, (M)!∈ S.
3. You are given a push down automata P with one state. Determine whether the following
problem is decidable, recognizable or unrecognizable? “Is L(P) = Σ*?” Note: Σ* represents
language of all strings.
Solution:
Let DFA = {<A>: A is a DFA and L(A) is an infinite language}
To show that DFA is DECIDABLE, meaning to construct a TM M that decides DFA. This
means that for all DFAs A we want.
1. If L (A) is an infinite language then M(A) accepts.
2. If L (A) is a finite language then M(A) rejects.
Proof: Given (A) where A is a DFA, we want to be able to determine whether the number of
strings that A accepts is finite or infinite. TM M (DFA) decides the language
A (DFA) = {(A, w):A is a DFA and A accepts w}
One way to approach the design of a TM M to decide DFA is, on input hAi, start a loop over all
w ∈ Σ ∗ , with an iteration of the loop running M(DFA)((A, w)) to test whether or not w ∈ L(A).
The problem with this is that there are infinitely many w and our machine will not halt.
Justification:
Suppose A is a DFA with p states and alphabet Σ. Let
B (A) = {w ∈ Σ∗: w ∈ L(A) and p ≤ |w| ≤ 2p}
Then L (A) is infinite if and only if B (A)!= ∅. This means that to test whether or not L (A) is
infinite, we need only test whether or not B (A) is empty. The latter can be done using the
machine M (DFA) since B(A) is a finite set.
Construction:
M = On input (A), where A is a DFA
Let p be the number of states in DFA (A)
Let Σ be the alphabet of DFA (A)
For each string w ∈ Σ∗ such that p ≤ |w| ≤ 2p do:
1. Run M(DFA)((A, w))
2. If it accepts then accept
EndFor
Reject
4. You are given two Turing Machine X and Y. Determine whether the following problem
is decidable, recognizable or unrecognizable? “Can one Turing Machine recognize the
complement of the language that is recognized by the other Turing Machine?”
Solution: Let two machines X and Y.
If a language S = {a^n | n>0} over Σ= {a,b} is recognized by machine X and by taking its
complement
S’ = {b^n | n>0} that runs on machine Y will be recognized by Y.
Hence proved.
5. Find a language such that both the language and its complement are non-recognizable.
You will have to prove their unrecognizability.
Solution: This language is UN-RECOGNIZABLE
L= {⟨M1,M2⟩∣ M1,M2 Turing machines and L(M1)=L(M2)}
Proof:
It’s possible that both the language L and its complement L’ can be unrecognizable over the set
Σ={0,1} if L accepts all 1’s and L’ accepts all 0’s then by taking union of both the languages we
get M=1L+OL’ and this language M is Un-recognizable.