Solution,Theory of Automata & Formal Languages

advertisement
TAFL (NCS-402)
PUT-Set B
Solution
1. (a) Find an NFA without λ-transitions and with a single final state that accepts the
set {a} U {bn : n ≥1}
(b) Convert the following NFA to equivalent DFA.
First design the transition table and then apply the procedure of conversion.
Input=0
Input=1
p
q,s
q
q
r
q,r
r
s
p
s
p
(c) Construct NFA for (a/b)+ and derive DFA through subset construction algorithm.
Input=a
Input=b
q0
[q0,q1]
[q0,q1]
Final is [q0,q1]
[q0,q1]
[q0,q1]
(d) Define the language of a DFA. Design and explain each tuple of DFA which accepts
set of all strings containing exactly four 0s and at least two 1s over {0,1}.
Ans:
A language of DFA will be language if after scanning the complete input
language, we are able to reach a final state.
(e) A string β Є Σ* is called a prefix of a string α Є Σ* if α = βγ for some γ Є Σ*. For
example, all the prefixes of abaa are Λ, a, ab, aba, abaa. Let L the subset of Σ *,
be a language. By prefix(L), we denote the set of all prefixes of all strings in L.
If L = {aab, bab, abab}, what is prefix(L)?
Prefix(L)= { Λ, a, b, aa, ab, ba, aab, aba, bab, abab}.
(f) Minimize the states of the following finite automata by using My Hill Nerode
theorem, where the initial state is Q1, and the final state is Q6.
Present
state
Input = 0
Input = 1
 Q1
Q2
Q3
Q2
Q4
Q5
Q3
Q6
Q7
Q4
Q4
Q5
Q5
Q6
Q7
Q6
Q4
Q5
Q7
Q6
Q7
Ans:
Input=0
[q1,q2,q4]
[q3,q5,q7]
Final is q6
[q1,q2,q4]
q6
[q1,q2,q4]
Input=1
[q3,q5,q7]
[q3,q5,q7]
[q3,q5,q7]
2. Attempt any two parts:
(2x10=20)
(a) Write the decision properties of regular language. Write a regular expression for finite
automata shown below:
Ans:
A decision property for a class of languages is an algorithm that takes a formal
description of a language (e.g., a DFA) and tells whether or not some property holds. Decision
properties include- Membership problem, Emptiness, Finiteness (Elaborate).
Regular expression is 0* + 1*
(b) Construct DFA for the following regular expression:
((012)* + 021*)*
Ans: Apply Thompsons Construction or direct method.
(c) (i) Draw a Moore or Mealy machine that generates output ‘Yes’ when accepts a
set of strings from (0+1)* terminating in last two same symbols.
The transition table for Moore machine is as follows:
Present State
q0
q1
q2
q3
Next state on
0
q1
q2
q2
q1
Output
1
q0
q0
q3
q0
0
1
0
1
(ii) Prove that the language L={ 0n1m0m+n | m≥1and n≥1} is not regular.
Apply Pumping Lemma.
3. Attempt any two parts:
(2x10=20)
(a) Define Greibach Normal Form. Convert the following grammar into Greibach
Normal Form:
S → AB, A → BS | a, B → SA | b
(b) Consider the following CFG:
SAB / BC,
ABA / a, BCC / b, CAB / a
Apply CYK parsing algorithm to check membership of the string w = bbbaaa
The table for CYK parsing is as follows:
{S,A,C}
{Φ}
A
{Φ}
{Φ}
{B}
w= b
{S,A,C}
{Φ}
A
{Φ}
{B}
b
{S,A,C}
{Φ}
{S,A}
{B}
b
{S,A,C}
{B}
{A,C}
a
{B}
{A,C}
{A,C}
a
a
Since the first row contains the start symbol S, so the given string bbbaaa is a member of
the class of language generated by the given grammar.
(c) Write the closer properties of CFL. Prove that the language L = { a nbncn | n≥1} is
not CFL.
4. Attempt any two parts:
(2x10=20)
(a) What language is accepted by the NPDA, M = ({q0, q1, q2}, {a, b}, {a, b, z}, δ, q0, z,
{q2}) with transitions:
δ (q0, a, z ) = {(q1, a)/ (q2, λ)}, δ (q1, b, a) = {(q1, b)}, δ (q1, b, b) = {(q1, b)},
δ(q1, a, b) = {(q2, λ)}
(b) Define Push Down Automata (PDA). Construct a PDA accepting the language,
L={ a2nbn |n ≥ 1 }
Ans:
δ(q0,a,Z0) =
(q1,xZ0)
(c) Construct a context-free grammar G which accepts N(A), where
A = ({qo, q1}, {a, b}, {Zo, Z}, δ, qo, Zo, Ф)
and
δ is given by:
δ (qo, b, Zo) = {(qo, ZZo)}, δ (qo, ε, Zo) = {(qo, ε)}, δ (qo, b, Z) = {(qo, ZZ)}
δ (qo, a, Z) = {(q1, Z)}, δ (q1, b, Z) = {(q1, ε)}, δ (q1, a, Z0) = {(qo, Zo)}
Ans:
Let, G = (VN , {a, b}, P, S)
5. Attempt any two parts:
(2x10=20)
(a) Explain halting problem of a Turing machine. Design a Turing machine for the
following language:
L= { wwR | w is any string of 0’s and 1’s }
(b) What do you mean by Post Correspondence problem (PCP) and MPCP? Does the
PCP with two list x=(11, 110, 101) and y=(011, 10, 111) have a solution?
The Given sequence does not have any solution.
(c) Write short notes on the following:
(i) Church Thesis
(ii) Undecidability problem
(iii) Recursive and Recursively enumerable languages
(iv) Multi-head Turing Machine
Download