Flat 01
Flat 01
LANGUAGE &
AUTOMATA THEORY
State Machine
Rinite
State Models
2
Finite
of Sequential
9
Structure Machines
36
Finite Automation
41
dlosureProperties of Regular Sets
67
Free Grammars
Context
81
Pushdown Automation
101
Closure Properties of CFLs
109
Turing Machine
112
NOTE
WBUT course structure and syllabus of 4th semester has been changed from
2012
Formal
Language & Automata Theory (4 Sem, CS) has been redesigned. Taking
3pecial care of this matter we are providing the relevant WBUT solutions of old
rormal
Language & Automata Theory, from 2006 to 2011 along with the complete
uons of new university papers also, so that students can get an idea about
soluti
university
questions patterns.
POPULAR PUBLICATIONS
Answer: (d)
FAT-2
FORMALLANGUAGE ANDAUTOMATA
THEORY
Short Answer
Type
ang Questions
sequence of pulses
1.ntiall circ
circuit, which is enters a
sequential required to two-input,
1 produce an outputtwo-output synchronous
quence 1111 occurs. Overlapping pulse Z 1
$eui01011111
input the sequences are
required output is
Draw a state diagram. 00000011....
whenever
accepted; for exa
the
xample, if the
Selectthe assignment and show the
excitation and output
tables
Answer: O/0 [WBUT 2004, 2008]
0/0
1/0
1/0
O/0
0/0
Present State
Next Z
State,
Input x=0 Inputx= 1
A,0 B,0
A,0 C.0
A,0 D,O
A,0 C,1
YY
YY
|
x=0 x=
A00 00 01
B01 00 11
C11 00 10 0
D1000 11
2.What are the limitations of sequential circuit? WBUT 2009]
Answer:
A sequential circuit can only represent a finite-state machine. In such a machine, an
arbitrarily long sequence of input symbols is bound to create a periodic output with a
period not more than the number of states in the machine. Thus, computations which
Define Deterministic Finite Automata. What do you mean by NFA with -moves.
WBUT 2018]
FAT-3
POPULAR PUBLICATIONS
Answer:
Definition of DFA:
DFA is a 5-tuple.
(,2, 8, 9o, F)
finite set ofstates
finiteset of alphabets
Stransition function
:xQ0
0startstable
F sets of final states
NFA with A-moves:
Let be finite set.
Let 2 be a finite set of symbols.
be transition function defined as,
QxEU{2}>2
obea state in Q2
and 4 be asubsetof Q.
.A is set
ofacceptingstates.
So, NFA with 2-moves, is a 5-tuple
{0, E, 4o 6, A
Basically, any NFA is also a NFA with 1-move
|
Long Answer Type Questions
1. Draw the Merger graph, Merger Table, Compatibilitygraph and then minimize the
following: [WBUT2011,20161
Present Next State, p o/
State ilp 0
ilp= 1
C, 1
ilp =
E,1
ilp
1
2 B,
3
E, 0
F,0
B,1
F, 0 A, 0 D, 1
C, 0 B,0e rC, 1
Answer: puees asana
Step 1: Draw the arc of compatible pair. Compatible pair means that two state
present
entries of the next state should not conflict.
Here AB, BC, EF, etc are non-conflicting pair.
FAT-4
FORMALLANGUAGE AND AUTOMATA
THEORY
lhor hands DE is a
conflicting pair,
On othe because output of I
state
next state output
of I, is 1
whereas E contain
is
conflicting i.e. B
consist
0.
the
n-compatiblepai
Similarly CE, DF are also
these are conflicting
the merger graph
Note: now displays all
possible pair of state and
aDair ofstateis compatibleonly
Since
if its
implied
their
implied pair, and
pair is.
S S compatibles. A pair
is Written space of an
interrupted arc,
vertices
the entry (S,S)
and In such
is crossed
acase,if
and
arc is ignored. off, the,
corresponding
the condition for compatible (BF)to be that
Here (CE)be compatible, but since there is
is
arc drawn between C and E, (CE) is
and the arc between B and F
incompatible
Thus states B and F are is
ignored. incompatible.
Next, it is necessary to
check whether thee
of (BF) does not invalidate
compatibility any other
implied
space
pair,
that
of another
is, if
interrupted
(BF) is
arc,
not written
and so on. The
in the F -
interrupted
arcs which remain in graph,after all the (AB)
implied pairs have been verified to be compatible Co
are as solid ones.
regarded
The merger graph of Machine reveals the M (BE)
existence of
compatiblepairs:
(AB),(AC)(AD), (BC),(BD),(BE),(CD),(CF),(EF
In order to find a minimal set of
compatibles, which
covers original machine and can be used as a basis for the
construction of the minimal
machine, it is often useful to find the set of maximal
compatibles Recall that a compatible
is maximal if it is not contained in
any other compatible. In terms of the merger graph,
we are looking for complete polygons which are not contained within
any higher-order
polygons. [A complete polygon is one in which all possible (n-3) n/2 diagonals exist,
n is number of sides in the polygon.] Since the states covered by a complete
where the
polygon
are all pair wise compatible they constitute a compatible; and if the polygon is
BE, and
(EF) Generally, after a complete polygon of order n has been found, all
of order n-l contained in it can be the triangles (ABC),
Ygons ignored., Consequently,
ec, are not considered. Thus the followingset of maximal compatibles for machine Mis:
(ABCD),(BE),(CF),(EF)}
FAT-5
POPULAR PUBLICATIONS
Answer:
a) i) O0 1/0
A
0/0 D)
O/0
0/0
ii)
C1110 00 0 0
D10 00 11 0
3. Convert the followingMealy machines Moore machine.
into
a/0
wBUT 2015]
b/1
b/0
a/l
a/0
lo
b/1
AFAT-6
FORMALLANGUAGE AND AUTOMATA THEORY
Answer:
Q, 0 Q1,0
Q.
1
Q 1
4.Draw sequence detector diagram, table, k-map and circuit forthe sequence 0101
a 1 as output after every 0101 sequence.
which generates Consider overlapping of
sequences. [WBUT 2018]
Answer:
Sequence detector:
01010101
00010 101
i/p:
o/p:
0/0
Diagram
Next State
Present State
I/P =0 I/P=1
B,0 A, 0
B B, 0 C, 0
C D, 0 C, 0
D A, 0 C, 1
Table
FAT-7
TA
POPULAR PUBLICATIONS
K-map:
Let A00, B 01, C 10, D11 Next State
Present State
i/p 0 i/p 1
00
A 00 01,
B 01 0 1, 10,
C 10 1 1, 10
D 01, 10,
0 0
0 0 0 0
D
Circuit:
DD qtuo 9ninoR
yiio o)ste to
FAT-8
FORMALLANGUAGE AND AUTOMATATHEORY
Answer:(Cc)
FAT-9
POPULAR PUBLICATIONS
b) number of compatible
[WBUT 2018]
pairs
a)
c) number of statescombinations d) None of the above
Answer: (6)
,
A E, 1
B C,0
B,-C,0
E A,-
D B, 0 E,Table-1
E E, 0 A
For the incompletely specified machine shown' in table-1, find a minimum state
reduced machine containingthe original one. WBUT 2004, 2008, 2012]
Answer:
Compatible pairs=AB, AD,BC,BD, BE, CD, CE, DE
1. 2.
B
(CE)
(CE)
(CE)
(CE)
(BE)
D -(BE)
D
ME)-
3.
C
Final merger graph
D (BE)
FAT-10
FORMALLANGUAGE AND AUTOMATA THEORY
Graph AB
Compatibility
CD
BE
table
Merger
B
B
CE C
C
D
D CE CEBE BE
E
E
B C D A B D
B
C
D x BE
E
A B C D
Final merger table
Answer:
G E0
D, 0
D, 0
G, 0
Let's do the
partitioning process.
FAT-11
POPULAR PUBLICATIONS
Partitions Reasonn
P,=(ABCDEFG)
on
E has o/ p=1 p=0 i
R=(4BCD FG) (E)
B-(BCDG)(AF)(E) (AF)goesto E ip =0 on
Answer:
Machine
Mooreation of FA
Moore is that its
output is limited to a
binary signal "accept/don't
Thelimitatio the output is chosen accept
in which
in whic. from some other
alphabet and in which the output
Models with the state is called Moore
machine.
isassociated is a SIN-tuple
Moore machine (Q2,4,0,,9) where Q, ,8 and qo are as in a
A
A the output
is the alphabet and is a mapping from
is
Q to A
DDFA. d with each state. Any Moore machine
with
givingthe output
givesoutput A(9%) in response to input
ssOciated
The DFA may be viewed as a, special case of a Moore machine, where the output
is {0, 1} and state q is
"accepting"if and only if
2(q)=1.
phabet
Input
Comb
Ckt
Present
State
Comb Output
Ckt
Memory
Output Is Only a Function
of Present State
Mealy Machine
A Mealy machine is a sequential machine in which output is associated
with each state
transition.
of the vending machine example, presented in class, is that of a Mealy
The output
machine.
where Q is a finite set of
A machine is a six-tuple M=(Q2, A,2,q0), non-empty
Mealy
states,
is the input alphabet,
A is the output alphabet, : Q2 Q is the state
FAT-13
POPULAR PUBLICATIONS
Input
Comb
Ckt
Present Output
State Comb
Ckt
Memory
Is Function of
Output
Present State AND Present
Input
OR Part also:
Moore vs. Mealy Machine
Moore Machine: Output only depends on present state
state and the present input.
Mealy Machine: Output depends on both the present
E, 1
A, 0 E,0
0
B,
F,0 D, 1
D, 0 A, 1
Answer:
by tracing backwards from state F. We see that the only F,
best solved
0
This problem is
entry is for E and x0. Hence the second-last state is E. Proceeding similarly. We get
is B
or E. Hence, the state is B. So, the state transition are
ABB> D> E>FD> AC EF
Hence, the input string is: 0101000110
D, 1 C,1
B, 1 A,1
Answer:
first step of this testing procedure is to check each row of the transition table,
ther there is two identical next state entries associated with the same output symbol.
W the above table it is clear that, there is no identical next state entries.
From the
construct the output successortable.
Now we have
for Machine-M
Testing
table
PS z0(AB)
(CD)
DAB (AB)(CD)
(CD)
(AB)
CD (AB)(CD)
AC
AD
BC
BD
O/Z
O/Z
START
1/Z
/Z
0/Z
FAT-15
POPULAR PUBLICATIONS
Answer:
transition diagram
Melay machine
is
be
According to the above diagram the will
NS, z
PS
i/p=0 ip1
9L 92,Z1} q,Z1}
92 2,Z2) g,Zi
L93 q,Za){2, Z1)
ilp=0
q1 192,Z1
NS, 2 ilp=1
fg3, 21
920 20,Z2 93, Z1
21 q20 Z2 3,Z1
930 30,Z2 921, Z1
can be either 0' or 1 (two types of input). The output will bealso two types, either
or 1. The circuit can store (memorize) the input string up to four clock puisco
( to )
Ifthe input string is placed according to clock pulses, the
output is as follows:
VP
O/P 0 0
0 0 1
1
0 0
0
FAT-16
firs ut at is and NDAUTOMATA
The
I asthereis noFORMALLANGUAGE THEORY
equal
to
However at time
roduced at
01.So
100 the
from
inputfrom
output will be 0.
theinput
to
occur
inputssequence does not
Similarcases
fortheinputs
puts upto1
to
, the
time At becomes
time 1, and r, 1001,hence nce the output is 1
nectively.
Therefore, the
1001,hence output 1s l
theinput
output 0' is string from
produced. At t,
to are 0010 and 0100, ,
,
produced. As the clock
and from t, to pulse the input strimg
1,, this is called output 1' at t, is
overlapping overlapped from to
condition.
10000
In this casethe state
diagram is to be drawn
first
accordingthe
following process
0/0
1/0
0/0
0/0
1/0
1/0
1/1
In state
1001. Hence
S,, input may be either
0 or 1'. If
given input 0', there is no chance to
loops on it
S with output 0'. Ifthe input is 1', there is a chance to
get
1001 then machine moves to get
S, producing output '0.
In
S, again the input may be either 0' or 1'.
Ifit is 1', the input becomes 11.
no chance to get 1001 There is
by taking previous inputs. But
again there is a chance to
by considering the given get 1001
input1', Hence it will be in state
will be loss of
S,.(If it goes to S, then there
clock pulse, i.e., from
1., one extra
S
by taking input '1', again it has to come to
S
input, i.e., one clock pulse is needed and hence the
output will not be in
right pattem).
Ifthe inputis *0', the input becomes 10-by
and there is chance considering the previous input
to get 1001, so it will
come to S,
In
S, if it
gets input 0', the input becomes 100 by considering the previous
input and it
has a chance to get 1001, so it can shift to S,. But if it
gets '0', it has no chance to
get
1001 a chance to
consideting the previous input, but there is
get 1001 by considering the
So S, as we know by
Biven input '1'. will shift to
it
getting "T' in S, the machine comes
to
S.
s, if it
gets 0', the input will become 1000, but it does not match with 1001.
n
nerefore, it has to start from the beginning i.e., S. As overlapping condition is
TAFAT-17
POPULAR PUBLICATIONS
accepted,
hence from the last 1' of 1001 if it gets 001 only, it will give an output 1
Therefore, it will go to S,
State table:
A state table can easily be constructed from the abovestate diagram.
PS NS, O/P
0
S S,0 S,,0
S S,0 S,,0
S S,,0 S,,0
S S,0 S,1
State assignment:
The states must be assigned to some binary numbers to make a digital circuit. This is
S, to 00
S to 01,
S, to 11,
S, to 10.
1
OP(F)
00 00 O1 0
01 11 01 0
10 01 0
10 00 01 0 1
The digital function can easily be derived from this state assignmenttable:
Y=Xy
X0 01 X 0
0
1
1
Y=X+
Z=Xyy
00
0
00 00
01
1 00
00
011.
1
11 10 11 0 0
00 10 0 10 01
FAT-18A
FORMALLANGUAGE AND AUTOMATA THEORY
8,0
,0 a,1
10.
Design a two-input two-output sequence detectorwhich generates an output 1
every time 1010 is detected. And for all other cases
the sequence output 0'is
Overlapping sequences are also counted. Draw only state table and
generated.
state diagram.
WBUT 2016]
Answer:
The input string 1010100 is placed according to the clock pulses, and it looks like the
following
0
10010
UVP 1 1 0 1 0 0
O/P 0 0 0 1 0 1 0 Fig: Overlapping Sequence
And the output becomes as given earlier. Overlapping portion is 10, as shown
figure. The state diagram is in following: 1/0
1/0
0/0 /0
O/0
1/0 0/1
0/0
FAT-19
POPULAR PUBLICATIONS
State Table: From the previous state diagram, a state table as follows can easily be
constructed.
S Sa, 0 S2, 0
11. Find the string which is applied on state D'
producing output string 10011110
and final state'D'forthemachine given below:
NS, ol p
PS
x=0 x=1
A, 1 C,1
B E, 0 B,
C
1
D, 0 A, 0
DE
C, 0
B, 1
B, 0
A, 0
WBUT 2016]
Answer
First we need to prove the machine is information lossless. For this we need to
construct
a machine is information then and
testing table for infornmation lossless. If the lossless
only a single input string can be foundfor a single beginning state and single final state.
The testing table forinformation lossless:
NS
(AC)
B
AC
D
E A (AD
(BC)
B
AD
BC (AEXDE)|
AE (AB BC)
DE (AB)(AC)
AB L(ABYBC)
The testing table does not contain any repeated entry. The machine is information lossless
machine.The output successor table for the givenmachine:
FAT-20
FORMALLANGUAGEAND UTOMATA THEORY
PS NS,i/p
A Z
(A,0). C,
B 0 1)
B, 1
D
(D,0),(A,1)
(C,0),(B,1)
A,1 B, 0
is as follows:
Transition
10
O/0 D
1/0
A
1/1 O/1
1/1
as
input).
In S2
ifwe get 0 thenthere is a chance to get 1101 considering the last 1, so the
control will be confined in S2
producing output 0. In S2 if we get 1 then there is a chance
toget 1101 so the control moves to S3 producing output 0.
In
S is a chance to achieve the string 1101,so
we get 0, there the control moves to S4
if
producing the output 0. But in S3 if we get 1 then there is no chance to get the string
so in this case we have to start again
1101,
0
from the beginning i.e., S. In also, if we S
get
then there is no chance of achieving the input
1101 so the control moves to e
Deginning producing output 0,but if we get then the string 1101
1 is achieved, thus
110 101
i di1
FAT-21
POPULAR PUBLICATIONS
0/0
1/1
0/0
1/0 1/0 0/0
1/0
0/0
Figure 1
Si,0
O/P
S2, 0
S
Long Answer Type
S3, 0
Sa,0
S, 0
S2,0
S, 0
S2,1
Questions
1.
a) In response to an unknown inputsequence, the machine of table-4 produces
theoutput sequence 1 1 10000010.
Find the input sequence to the machineif it isknown that its initial state is A and
final state is F.
NS, Z
X0 X=1
C, 0
D,1 B,
B,0
A E, 0
F, 0
D,0
Table-4
Find the minimal
b)
inverse machine of the machine given in table-5. [WBUT 2004
NS, Z
PS x =0 x =1
|C, 0 D,1
D,0 C, 1
A, 0 B, 0
D C,1 D,1 Table-5
FAT-22
FORMALLANGUAGEAND AUTOMATA THEO
a)
We use the backward sequencing to get
A BB D 0 EFD A CEF
1 0 0 0 0
1 1
1
D C,1 DI
Machine-M
This machine of order 3. If we know the initial state and the
is loss less
values of three
which
are produced due to
we
outputs, transition from this initial
Successive
state, then
can determine the first input to the machine.
hus the inverse machine has present states defined by the eight triples shown above.
Now thenext state of the inverse machine can also be defined by triples.
triple is the state to which the machine M will go consuming
The first member of this
the
first
input symbol.
Ihe second member is nothing but the third member of the present state of the inverse
NS,X
PS
(A,0,0)
z=0
(C.0,0).0
z=1 (C.0,1),0
(A,1,1)(D,1,0),1 (D,1,1),1
C.0,0)(A,0.0),0 (B,0,1),1
(C.0,1) (B,1,0),1 (A,1,1),0
D1,0)(C.0,0).0 (C,0,1),0
D.1.1) D.1,0),1 (D.1.1),1
2. a) Fvd the equivalence partition for the machine shownin Table. Showa
standard lorm of the corresponding reduced machine and find minimum-length a
sequence that distinguishesstate A from stateB. WBUT 2007, 2012, 2015]
PS NS, Z
X= 0 X 1
B,1 H,1
F,1 D, 1
D, 0
C, 0
D, 1
C,1
C,1 D, 1
C, 0 A, 1
Answer
Po-(A BCDEFGH)
Pi-(ABEFG)(CDH)
P2(A B) (E F G)(CDH)
P(A) B)(EFG) (CDH)
P (A)(B)(E F G) (C D) (H)
P (A)B)(EF G)(C D) (H)Final equivalent partition
Let a =
(A.) B (B),Y= (E F G),
8-(CD),e(H).
Hence the standard form machine is
Ps NS,Zz
X=0 x=1
B. 1 E, 1
B Y.1,1
8, 0 8,1
8 8,0
E8, 1, 1
There areno or 2-length sequencethat
1-length distinguishes A and B.
The sequence000 distinguishes A and B
In stateA,theoutput is 111
In state B,the output is 110
FAT-24
FORMALLANGUAGEAND AUTOMATA THEORY
2
Table
PS NS, Z
E, 0 B, 0
F,0 A, 0
E, C,0
D F, 1 D, 0
B,0
Answer:
EF
C BC EF,
AC
EF
CD,
Procedure
X CF
CD
BC,
(CE)
Compatibility Graph
AC)
(BC)
(CF)\
(AB)
(EF)
? (AF)
(DE) (CD)
FAT-25
POPULAR PUBLICATIONS
PS NS, Z
X =0X=1
A, 0 B, 0
B C
C,0 D, 0
D,1
D C, 1
B,1 A, 1
b) Design a minimal inverse of the machine shownin Table WBUT 2007]
PS NS, Z
X =0X= 1
C,0 D, 1
C D, 0
A, 0 B,0
C,1 |D,1
C, 1
Answer:
a) As another illustration, the above test is applied to machine Mo of Table (i). This
shown to be lossless of order 3,since its testing graph (Fig. a) is loop-free and
is
machine
the longest path is of length 1.
(AD BC BD
D
Fig: Testing graph for machine M
PS
Table (i):
x=0
A,0
Machine
NS, z
x=
B,0
M
1
Table (i):Testing table for
PS
B
(AB)
(CD)
0 0 B,0
D, 0
B C
C, 0 D, 0 C,1
C D, 1
C1 D
AB
A,1
D B, 1
A,1 (AC)(AD)
(BC)(BD)
CD CAC)(AD)
(BC(BD)
(b) we have the following triples:
FAT-26
FORMALLANGUAGE AND AUTOMATA THEOKL
The
first membe of this triple is the state to which the machine MIwill go consuming the
input symbol.
first
member is
nothing but the third
The second member of the present state of the inverse
and inally the third
fina member is the
achine present output of M.
maate table ofthe corresponding inverse machine is shown below:
Machine-M'
PS NS,X
z=0 z=1
(A,0,0)
(C.0,0),0(C.0,1),0
(A,1,1) (D,1,0),1 (D,1,1),1
(B.0,1) (D.1,0),0
(D,1,).0
(B.1,0)(C.0,0),1 (C0,1),1
(C.0,0)(A,0,0),0 (B,0,1),1
(C.0,1) (B.1,0),1(A,1,1).0|
(D,1,0) (C,0,0),0 (C.0,1)0
(D,1,1) |D,1,0),1|(D,1,1),1
0 D
0
0 B
a)
Two states S, and S
of a finite state machine are said to be K equivalent it there
Cxists No
input sequence of length K or less that produces different outputs depending
upon whether S, or S, is the initial state.
b) Initial
partition P (ABCDEFGH)
of states= P
Fartition
1-distinguishable =(ACEXBDFXGH)
Fartition
of 2-distinguishable states P =(ACXEXBD(FXGH)
Fartition of 3-distinguisbable states =P = None
0,minimal
et uus
Let
map:
machine has 5 states.
PS
= Q,0
T, 0
NSZ
0 X=1
R, 1
S,0
S, 0 R,
R, 0 P,0
P,1 T,0
c) A machine M is said to be
(information) lossless if the knowledge
of
the initial state,
the output sequence and the final state is sufficient to determine unequally the input
sequence.
A machine that is not lossless is said to be lossy.
5. Draw the merger graph, merger table, compatibility graph and then minimize the
following machine: WBUT 2009]
Next State, olp Next State, o/p
Present state
i/p=0ilp=l i/p 2 i/p=3
A C,1 E,1 B, 1
|E,0
F, 0
B,1
F,0 A, 0
|C, B,0 C,1
Answer:
Merger Graph
-(CE)
(AB)(CD) (BF)
(BE)
CF)
CE AB
CD
A B C D E
FAT-28
ORMALLANGUAGEAND AUTOMATA THEOI
bility
the compatibility graph, we get of
From {(AB), (CD), (EF)} as a closed
cl covering
compatibles.
Machine
Minimal
PS i/p 0
NS, Z
(AB)>a y,0
i/p=1 ip=2 ilp=3
B,1 a,1
(CD)A Y,0
a,l
(EF) B- Y,0 a,0 B.1
sequence
(b)Step
1: Check each row of the
state table for an appearance of two identical next-
Step 2: If no identical entries appear,the next step is to construct the output successor
table.
These pairs are used as row headings for the lower part of the testing table. Pairs (AE)
row headings, and so on. Note
and (DE), which are
implied by (BC), are now made
that
contrary to the testing procedure for finite output memory, the testing table for
information losslessness does not necessarily include all distinct pairs of states, but only
the
compatible ones.
FAT-29
z
POPULAR PUBLICATIONS
The graph G of machine Mis derived from the lower halfof the testing table.
testing
The testing table does not contain any compatible pair
consisting of repeated entries.
So the machine is information lossless.
7.Consider the
followingmachine: WBUT 2010]
Present State Next State
(BC)
(ac)
186)
AD
The set of maximal compatibles derives from the merger graph contain four members and
is given by {(ACD),(BC),(BE),(DE)}
FAT-30
FORMALLANGUAGEAND AUTOMATA
The compatible pairs and
Step2:and since a set
their
impliedpairs are btained by the merger
,
of states is a usually obte
graph,
tible, then for a given compatible if and only if pair ofstates in
that
every pa
set is compar the set the
of compatibles. of compatible pairs
irs defines uniquely
entire set
from the above merger graph, an arc leads from
of vertex (AD) to vertex (BE) because
ompatibility (BE) is
implied by that of
(AD). No arcs emanate SInc
(AO since
nanate from (AC)
is
no other ompatible implied by it, and so on.
,(40)
(8C)
co
DE
Step 3:Select closed subgraph in the compatible
graph.
State
4 State Redesignated
Output
0,1
0,
1
0
0, 1
Redesignated
0, 1 10 9
0,1
42 0
420 921
93
0,1
oFAT-31
POPULAR PUBLICATIONS
920 40 3 0
40
0
10 440
40 921 40 0
41 921 40
9. Consider the
following state table
Present state Next state, Output
11 12
E, 0 B, 0
A, 0
C, 0
D,0
C, 1 C,0
D, - B, 0
a)Draw the merger graph.
b) Draw the merger table.
c) Draw the compatibility graph.
d) Find the minimal machine which covers that machine. WBUT 2015]
Answer:
a)
(DE)
(EF)
(AC) (BC)
BC) BC
EF DE CD
CD
EF) CF
FAT-32A
FORMALLANGUAGEANDAUTOMATA THEORY
b,c)
& Refer to Question No. 2(b)
ofLong Answer
a mini Type Questions.
nstruct inimum state
table isgivenbelow:
tab automata
nsition equivalentto a
given automata M which
State [WBUT 2018]
input
42 45
o 6
Answer:
6
State input
b
2
92
94
45
4 46
95 4
. Partition
algorithm is applied-
Po(9 9 99 9 9s 4)
P=Po
Dere not any state has same outputs and also no same state transition.
S0, the
given m/c is itself the minimized one.
onstruct the merger table, merger graph, compatibility graph and minimal
machine forthe [WBUT 2018]
following Machine
NS, z
E, 0 B, 0
B F, 0 A, 0
C E, C, 0
FAT-33
POPULAR PUBLICATIiONS
D F, 1 D, 0
E C, 1 C,0
D, B, 0
Answer:
Refer to Question No. 9(a), (b), (c) & (d)of Long Answer Type Question.
12. Construct
testing table, testing graph for the following machine and test
whether it has
finite memory orNot,if yes then findthe order. WBUT 2018]
PS NS,Z
x =0 x=1
B, 0 D, 0
C,0 C, 0
C D, 0 A, 0
D D, 0 A,
Answer
PS
x =0
Z
NS,
X=1
B,
0 D, 0
Testing Table:
PS
D C
0/0
D,
C, 0
D, 0
0/1
0 A, 0
1/0
C, 0
A.1
1/1
A B D
B
D A
D D A
(AB) (BC) (CD)
(AC) (BD) (AD)
(AD) (BD)
(CD) (DD)
(discarded)
FAT-34
FORMALLANGUAGE AND AUTOMATA THEOKL
Graph;
Testing
AB
BC
AC BD
CD
AD
(ABBCACAD BD CD)
FAT-35
POPULAR PUBLICATIONS
ei2e9ri9linis
FAT-36
FORMAL LANGUAGEAND AUTOMATA THEORY
0
(AB
BC BD
Fig.: Testing graph for machine M
Ceom the lower part of the testing table it is clear
that, there is no compatiblepair with
reneated
entries. This is necessaryand sufficient
for a machine to be lossless.
the given machine is lossless.
So clearly
the abovetesting graph the length l= 2.
In
of thelargest path is
Hence the order
of losslessness, u=l+2
2.Test whether the following machine
is definite or not
WBUT 2011]
i synchronization tree
by using
i) by using repeated derivation of contracted table
m) the machine is definite,
if
Present State
Next State
a 0= a1
Answer:
Level
(ABCD)
(AC) (BD)
0
2
(A) C) (B)
(BD)
0
t is
dos (B)
clear that the tree is termi ated by rule 2. So machine is definite machine.
Herek 3
herefore order of the is 3.
definiteness
FAT-37
t
POPULAR PUBLICATIONS
C
Construct an-lattice for it.
B
FAT-38
FORMALLANGUAGEAND AUTOMATA
THEOKI
17.
8.
C,G;A.H:B,F;9C,G;A,H;B,F;D,E;> T
A.E:A,B,CD,E,F,G,H; T(I) D,9B.C.D,E,F,G,H;C,H,F,B,G,
CH:C.F;E,H;C,E,F,H;B,E,G.H;B,C,D,F;>B,C,D,E,F,G,H;C,H,F,B,G,
ED,E;B,F;>D,I
19.
D,E;B,F;C,G;>D,E;B,F;C.G;A,H;T
>A.B,C,D,E,F,
DED,F;F,G;F,D;7D,F,G;A,F,G;B,D,F;>A,B,D,F.G;C,D,
D;
A,F,G:G,E,F,B,
a1 G;D,C,H,F,B,G,A;>A,B.C.D,E, F,G,H;> T()
>C.D,G,E;A,B,F,H; T
D.GD,G;A,F}B,F;7D,G;A,B,F;>D,G;A,B,F;C,D,G;D,E,G;>C,D,G,E;A,B,F
22
E.F-E,F;B,D;B,G>E,F;B,D,G;A,C,F;B,E,F;>A,B,C,D,E,
AB,C,D,E, F,G,H; F,G;D,C.H,F,B,G.A
T()
4
25, E.G-E,G;A,B;E,G;A,B;C.D;>E,G;A,B;C,D;F,H; T,
E.HE,H;B,E;B,C;>E,H;B,C,E;B,C,H;B.E,F;>B,C.E,F,H;B,C.E,G.H;>B,C E
26.
F.G.H:CH,B,G,A,E;E,F,B,D,B,C;>A,B,C,D,E, F,G,H; T()
F.GF,G;A,G;B,D;A,F,G;B,D;A,D,G;B.D,G;C,F;E,F;>A,B,C,D,E, F,G;D,C,
HF,B,G,A;9A,B,C.D,E,F,G,H; r()
27.
F.HF,H;C,D;E,G;9FH;C,D:E,G;A,B; T
28.
T()
-4.B,FHC,D,E,G
,
G,HG,H;A,E;B,C;9G,H;A,E;B,C;B,D;B,G;C,H;E,F;A,B,C,D,E,F,G,H;
Parallel
Decomposition of Machine:
tTT 4,B,F,H; C,D,E,G
PS NS Z1
x=0 X=I
A,Ba b
C,D b d
EG
F,Hd
a
c b
a
Machine M
PS NS
x-0 x=l
A.H-a8
B,F2 0
C,G
D.E8B 0
FAT-39
POPULAR PUBLICATIONS
Machine Mb
T(I)
Z Z.Z
TT(0)
(a) T-Lattice
M
Schematic
M, with
diagram of machine
parallel components
2to1smm
-2(d
FAT-40
FORMALLANGUAGEAND AUTOMATA THEORY
FINITE AUTOMATION
Multiple Choice Type Questions
be recognized by any FSM because
.Palindromes cannot WBUT 2007, 2012]
a) an FSM cannot remember arbitrary, large amount of information
an FSM cannot deterministically fix the mid-point
b)
is whether the second
c) even orthe mid-point known, an FSM cannot find
half of the string matches the first half
all of these
d)
Answer:(C)
121fS is the number of states in NDFA then equivalentDFA can have maximum of
WBUT 2008
a) S states b) S-1 state c) 2'states d) 2-1 states
Answer:(c)
4. What the highest type number to the grammar given by the following
is
Answer: (d)
number of states in an
5. Givenan arbitrary NDFA with n states, the maximum
DFA is at least [WBUT2008]
equivalent minimized these
c) n! d) None of
a) n b) 2"
Answer: (d)
[WBUT 2010]
The production grammar {S>aSbb, Sabb} is
b) type-2 grammar
a) type-3 grammar grammar
c) type-1 d) type-0
grammar
Answer:(a)
WBUT 2010
0.The reduced grammar of S AB a, Aa is
Saa
S>a c) S >a d)
a) b) SalA
A>a Aa
Answer:(c)
FAT-41
POPULAR PUBLICATIONS
9.Which of the following grammars generates strings with any number of 1's?
a) S1A, A->6 b) S>1S, S>E WBUT 2010
c) SS1,S >E d) (b) & (c)
Answer: (d)
11 If Qis the number of states in the NFA, the equivalentDFA can have maximum
mumber of states WBUT 2011
a) b) -1 c) 20-1 d) 2
Answer: (d)
14. The string 1101 does not belong to the set represented by
[WBUT 2014, 2015, 20171
a) 110(0+1) b) 1(0+1)*101
c) (10)(01)*(00+11)* d) (00+(11)*01)
Answer: (c)
15. A=(a +b)*a and B=b(a+b)* then A intersection B will be WBUT 2016
a) (a+b)*ab b) ab(a+b)* c) a(a+b)*b d) ba+b)'a
Answer: (d)
16. The string 1101 does not belong to the set represented by
WBUT 2016]
a) 110*(0+1) b) 1(0+1)*101
c)(10)(01)* (00+11)* d) 00+(11)*o
Answer: (d)
FAT-42
FORMALLANGUAGEAND AUTOMATA THEOK
auivalence ispossible between two
finite
18.
-leve valence above k -levele automata
exist between them
WBUT 2016]
level equivalence up to k-1 level
b)if all alreadyexist
b)
contain at least k number of states
if both
k number of
both contain exact states
(6)
Answer:
1/1
/0
0/0
0/1
O/1
0/0 1/1
Mealycircuit
he equivalent Moore circuit is given by
FAT-43
POPULAR PUBLICATIONS
42
Answer:
NS,
x=0 x=1
0 ,0 41
431 41
21 .0
9941
3. State the difference between DFA and NFA.
WBUT 2009, 2010]
Answer
In a DFA, these can be no
there can be at most one
e transitions. Also, for a given state q and a symb
ae
entry. An NFA does not have any of the above restrictions.
9-
5. Draw the transition
diagram of a finite state automaton that
over {0, 1) accepts all strings
FAT-44
FORMALLANGUAGE AND
AUTOMATA THEOKY
Answer:
a)(101*)*+1*
o
b) (0*1*0*!*)*
OE
0
EO
00
6. State the differencebetween DFA and NFA.
Answer:
WBUT 2010, 2018]
1, The transition function for nfa ie delta is multi valued where as for dfa it is single
valued.
Checking membership is easy with dfa where as it.is difficult for nfa
of nfa is very
Construction
easy where as for dfa it is difficult
3.
4.
Space required for dfa is more where for nfa it is less
5.
Backtracking is allowed in dfa, but it is not possible in every casi in nfa.
-
6. For every input and
possible to
construct an nfa machine for
every input and output.
1. There is only 1 final state in nfa but there can be more then final state in
1 dfa.
Answer:
State/e
92
1611 iof
FAT-45
POPULAR PUBLICATIONS
NFA
Q
90-9195 l4.4
DFA
8. Construct a DFA diagram from the NFA given below: WBUT 2011, 2012]
0/1
START
Answer:
The NFA diagram:
to the
8-883
start
1 {91,92
2 2
go, 91 go,91 fq1.92
92
FAT-46
FORMALLANGUAGEAND AUTOMATA
to the abovetable THEO
according the DFA
Now,
diagram will be,
O/1
The DFA
Diagram
a NFA with
Construct Eor A transition for
r=(11+0) (00+1). WBUT 2011, 2012]
Answer:
b)
qo, q1
FAT-47
TA
POPULAR PUBLICATIONS
11. Design a Finite automata that accepts set of strings that every ends with
string
00 over alphabet (0, 1). WBUT 2013]
Answer:
FA that accepts set that every string ends with 00 over alphabet 10,1
ofstrings
given start state and input symbol. This distinguishes it from a deterministic finite
automaton (DFA), in which all transitions areuniquely determined and in which an input
symbol is required for all state transitions. Although NFA and DFA have distinct
definitions, all NFAs can be translated to equivalent DFAs using the subset construction
algorithm, Le., constructed DFAs and their corresponding NFAs recognize the
same formal language. Like DFAs, NFAs only recognize regular languages.
)
State table
(o41) (9)
(40.9) (o4 92) (9.9.)
(49)
DPoP
2
FAT-48
FORMALLANGUAGEAND AUTOMATATHEOK
0.91,92
-00-
14. Convert the following NFA into an equivalentDFA. WBUT 2016]
NS
a1
PS
a=0
92
Answer:
NS
PS
a=0 a=1
(4o 41 (4o4)
9o919) (4o 4)
(o9) o43-93)
Go9os41,4 4o494) (4o4:4%)
o4,.4)14)(go9a9)
9042,4
FAT-49
Q
POPULAR PUBLICATIONS
a=0
0 o-41 4o-91-43
a=1 a=
a=0 a=1
o 92
a=0
la=1
Go-92 93
a-
15. Define DFA. Derive the DFA for the
regular language 0(0+1)*1 forthe symbols
-{0,1. WBUT 2016
Answer:
I part:
A deterministic finite automaton
(DFA) a 5-tuple. (Q,2,8,o,F), where. Qis a finite set
is
2 part:
Go
16. Construct a minimum state table given below:
automaton fromthe transition
PS X=0 X=l
42
42
2 4
FAT-50
2-TAT
FORMALLANGUAGE AND AUTOMATA THEOI
-40-49 ,=l4,4..9,}
S:{{4o94:}.{9,,4.9,}}
he belonging to the same subset are
states
1-equivalent because they are in the same Set
tring length 1. The states to belonging different subsets are
Eor input 0 and 1, 90 goes to q, and q,, 1-distinguishable.
Forinput respectively. Both of the states belong to the
subset. For
and 42 with 0 and
input 1, the next states are
q,,93, and 424
esnectively. For both of the states, for
resp input 0, the next state belongs to one subset, and
the next state belongsto another
farinput 1,
subset. So, g
can be distinguished from
and 9
The next states
with 0 and for states q,4,, and
input 1
g,belong to the same subset. So,
cannot be divided
they
Slla1.4:9,94,}}
g is the single state in the subset. So, it cannot be divided.
For states 4 and q with input 0 and 1, forboth of the cases, one state belongs to one
subset and anotherstate belongs to anothersubset. So, they cannotbe divided.
The next states with input 0 and 1 for states 93,94 and 4, belong to the same subset. So,
S:{{4o {a,,4.3,141,44.}}
S,
and S, are equivalent.
I/P=0 /P=1
State
FAT-51
POPULAR PUBLICATIONS
As 4 is the beginning state of the original finite automata, {9.} will be the
beginning
minimized finite automata. As g,,4, and q, are the final states of the original
finite automata,the set of the states containing any of the states as element is final state.
Here, all the states are contained in a single set is the final
f4,4,4,) and, therefore, it
state. By replacing
{9%} as A, fq,4,) as B, and fq,.4.4,} as C, the modified minimized
finite automata becomes,
Next State
A
State I/P=0
B
B
I/P=1
B
C
The diagram of the minimized finite automata isgivenin following
transitional figure.
0
0,1
17. What is Find the
Homomorphism? homomorphic image of L=aa,aba where
h is defined as h(a) =ab and WBUT 2018]
h(6)= bbc.
Answer:
1s Part:
Homomorphism:
A homomorphism is a map between two algebraic structures of the same type, that
preserves the operations of the structures.
f:AB where two sets A, B having same structure.
Then,say* is
a binary operation.
s*)=f()*10)
for every pair of (x,y)e 4
2nd Part:
L={aa, aba
where
h(a)= ab, h(b) =bbc
h(a a)=h(a) h(a)= ab
h(a b a)=h(a) h{b) h(a)= ab bbe ab
Homomorphic image of L is
sab ab, ab bbe ab
FAT-52
ORMAL LANGUAGE AND AUTOMATA THEOKI
Long Answer Type
Design a Questions
2-input
1.
am and generates an2-outputofMealy machine, which takes as nary
Snd
fou in
the input stream. output 1
only when a
sequence of the
input a44
Design should be patter
Answer: clearly justified. BUT
[WVB 2007, 20401
2010
The required Mealy machine
given
is below:
PS NS,Z
X=0
B, 0
X=1
A,0
B,0 C,0
D, 0 A,
D
0
B, 0 E, 0
D, 0 F
Justification ofDesign
B, 0 A, 0
The forward moving
Also
(i.e.,
are
A B C D EF) transitions can be
trivially
justified. justified 1 transitions from states C
A, and F to state A
because this
indicates the sequence has been broken and scanningmust
completely begin again from
state A.
We note that the sequence starts with a 0 and upon receiving the first 0, the state is B.
Hence, the sequence breaks in any state B,
if D
or F upon receiving a 0, we should count
this 0 as the first possible symbol of the
input and begin from state B.
Getting a 0 in the state E is a special case. State E is reached upon receiving the
subsequence 0101. If a 0 is received, sequence is 01010, the last three symbols of
the
which (i.e. 010) is the first three symbols of the sequenceto be recognized. But the state
which is reached upon receiving subsequence 010 is D. Hence the 0 transition from state
E should be state D.
1/0
1/0
0/0
1/0
O/0
1 1/0
0/0
0/0
0/0
State recognizing
A,1
01 B,0 00
D 010 C,1 011
From the Mealy machine above find the equivalent Moore machine. [WBUT20071
D)
Answer
only when
there 1S a transition
The Mealy machine designed in part a) produces output 1
into state F.
Hence the equivalent Moore machine is:
PS NS Output
X-0 X=1
B A 0
c) Check whether the Mealy machine you obtained is a minimal one or not. Give
proper justification to your answer. [WBUT 2007]
Answer:
The designed Mealy machine is NOT minimal. If we begin with the initial partition
PO (ABCDEF), we will get P1 (ABCDF)E)because only instate E we get output 1.
Thereafter, states D, C and B. form independent sets but states A and F are
indistinguishable.
which
Sa ba ba ba
is the equivalent reduced grammar.
FAT-54
FORMALLANGUAGE AND AUTOMATA 1TH
RY
Answer:
one-way (deterministic) finite
to the next automata,after every state
input, 1.e., to the transition, the input
the "right"or to 'right. In a two way
either to the "left". finite automata,the "head
move
More formally:
A2DFA is a quintuple M =(0.
2,5,qo, F)whereis a finite set of input symbols,
ois a finite set of states, 90 E is a "start state" and
FcO
sis a map from Q2 to
Qx{L,R. If 6q,a) =(p,L), then
is a set of
acceptingstates
in state 4, scanning
mbol a, the 2DFA enters state
p
8(q, a) =(p,R), u
and moves its head "left", if
oDFA enters state p and moves "right".
A 2DFA accepts a string if it moves
right" beyond the last symbol, at the same time
entering an accepting state.
It can be proved that if L is a language
accepted by a 2DFA then L is a
regular set.
Answer:
WBUT 2011, 2012, 2016]
Two distinct states, Si, and S,
of a machine M
are distinguishable if and only
if there
exists at least one finite
inputsequence which, when applied to M, causes different output
sequences, depending on whether S, or S, is the initial state.
The sequence which distinguishes these states is called a distinguishing sequence of the
pair
(5,S)
Ifno distinguishing sequence exists
for the pair (S,S then the states are said to be
indistinguishable.
The principle of state minimization ofa machine is based on the principle of
finite state
START
FAT-55
POPULAR PUBLICATIONS
Answer
Here fa} is
h g
completelydistinguishable state.
Hence the indistinguishable states are (e, g), (f,h), (e, h), (b, f), (b, d). This can be refined
to get indistingujshable sets of states as:
{e, b, f}, {e, g}, {d, h}
We get the minimized DFA as shown in figure,
Qo Qo,Q3
Q (FinalState Q
b)Construct 2, NFA
forthe regularexpression (0+1)
1(0+1). [WBUT 2013]
FAT-56
AH
FORMAL LANGUAGE AND AUTOMATA THEORI
Answer:
om the
DFA from th NFA:Here
Nulltransitions arereplaced
by New (N)states
States
Input
0
Qo {Qo.Q3) (Q.Q
{Q3 Q N
Q4
{Q Qt
{Qo.Qa}
Qr {Qd
(Qo.Q3) {Qo.Q4.Q)
{Qo.Qi;
{Qo.Q3,Qd
Qo.Q3, Qd
(Qo.Q.Qd {0o,Q.Qd
LQo.Q.Qd {Qo.Q3,Q {Qo.Q4.Q
E
We can
eliminate this
-QoC
FAT-57
POPULAR PUBLICATIONS
C
D
H
H H
WBUT 2013]
Answer:
Fig: 1
0-{4,B,CD, E,F,G, H, 1}
2la,b}
Initial state A
F={C,D,F,G}
0-F}={A,B, E,H,I}
We use an ordered Fx F ={(C,D).(C,F).(C,G),(D,
F).(C,G).(F.G)
and
(-F)x(0-F)={(4,B),(4,E).(4,H).(4./).(B, E).(B.H).(B,/).
(E,H).(E,1).(H.)}
FAT-58
FORMALLANGUAGEAND AUTOMATA THEOKI
table will be following:
Transition
A b
E
B
D
C H
*D H
E F G
*F H
*G
H
H
H
I H
ABCDEF G H
B
C
D
F
G
at (p, q) in upper
-- Fig:
triangle such
2
that P in F (Final states) and q in
F=C,D,F,G}
-F-{4,B,E,H,I}
lower than
x(O-F) or (O-F)xF such that q
is
p
),(G,1).(G,.H).
CE),(C, H),(C,/). (D,E),(D,H)(D,1).(F,H).(F,
D).(B,P).(B,G),.(E,F),(E,G)}
4.c).(4,D).(4.F), (4.G).(B,C),(B,
FAT-59
POPULAR PUBLICATIONS
H
matrix
4 BC D
D
Fig: 3
Step 3: Mark 'x' and '0'in the matrix:
(0-F)x(0-F)={(4.B).(4.E), (4,H),(4,1).(B.E).(B,H).(B.1).(E, H)
(E./).(H.1)}
* Now we will select (p, q) from (Q-F) x (Q-F) and find (r.s) as
Now considerF={C,D,F,G}
of F x F
Ordered pair ={(C,D),(C,F),(c,G).
(D,F).(D,G) (F,G)}
for (C,D).r =ô(C,a)=H,s =8(D,a) =I
(H.1) is neither x nor x so (C,D) will be "0".
for (C,F),r= 6(C,a) =H,s =6(F,a)=H
dash so
(H,H)
is
(C,F) will be"0".
for (C,G).r= o(C,a)=H,s =8(G,a)= H
is dash so is "0".
(H,H) (C,G)
for (D,F),r= S(D,a)=I,s =8(F,a)-H
is dash so check also neither x nor x so "0"etry.
(1,H) (H,I), it is
(D,F) is
Fig:
4
FAT-61
POPULAR PUBLICATIONS
So if resulting
minimum machine is M=
O-({4).{B, E},{C,D,F,G),{H.1})
F-((C.D,F,G})
A'=A
Now consider Fig. 1
(given DFA) and draw the transition table for minimum machine as
s({4).a)={BE
Since 6(4,a) =B in given DFA, B is in {B,E} state of minimized machinery on the same
way, the transition table for M' is
4 B,E}
{B,E}
C.D,F.G){c.D.F,G}
B,E
So minimized machine is
(H H.
4 M
B,E N
{C,D,F.G) P
6. Find equivalent
--0 {H,1
PS NS,Z
X=0 X=1
A B,0 H, 1
C,0 G, 1
B,0
F,1 C,1
B,1 C,
G C,1 B,1
D, 1
B,1
B,1
A,1
WBUT 2014]
FAT-62
FORMALLANGUAGEAND AUTOMATA
the
thefollowing THEOKI
Minimize incompletelyspecified
PS machine.
NS, z
B C,
A, 1
E A, 1
E,0
Answer: WBUT 2014, 2017]
1" Part:
Equivalence partitions are
Po (ABCDEFGH)
Pi (ABC) (DEFGH)
P ((ABC)((DH) (EFG))
P ((A)(BC))((D)(H))(EFG)))
P= (A)(BC))(D)(H)(EFG))
Minimization: We know that
So. P= (A)(BC)(D) (A))equivalent
(EFG))
partition is unique.
is the
one state of the minimized unique combination. Here,
represents every single set
machine.
Let us rename these
partitions for
simplification.
Rename (A)as Si, (BC) as S2,
(D) as S3, (H) as S4 and
(EFG) as S(A) with input 0 goes
S
to (B) and so there
will be a transaction from
Si to S2 with
to (H)and so there will
be a transaction from input 0. (A) with input goes
1
Si to S4 with
goes to (BC) for input 0. There will be a input 1. (BC) with input 0
transaction from S2 to
input
1
goes to (FG). There will be a transaction S, for input 0. (BC) with
from S,to Ss for
By this process, the whole table of input 1.
the minimized
The minimized machine is constructed.
machine becomes
Next State, z
Present State
S(A)
X=0
S2,0
X=
S4,1
S2(BC) S2,0 Ss, 1
S(D) Ss.1 S, 1
SA(H) S, 1 S1,1
2nd
S(EFG) S2,,1 S2,1
Part:
P=
(ABCDE)
P=(AB)(CDE)
This is the
final
partition.
Henceminimized
machine is
NS, Z
S=
S=
PS
(AB)
(CDE)
S,1
S2,0
O-
Si,1
S
FAT-63
POPULARPUBLICATIONS
(
7. Consider the N.F.A given by the following diagram WBUT 2015]
Qo
State a
Qo {Q1
Q {Q1 Q1. Qal
Q1,101. Q,Qs
Q1. Q2,Q3} {Qi} Q1. Q2 Qs}
q1,92,9s
FAT-64
FORMALLANGUAGE ANDAUTOMATA THEORY
uct Finite Automata equivalent to
9. Construct the Regular
*b. Expression
L-ab(a+b)(ab) WBUT 20171
Answer:
-0-0-O
O
Find the regular expression corresponding to the following figure:
10,
[WNBUT 2018]
Answer:
9+911+011)*010+q,1(1+011)*00+9,
9+9(1:(1+011)* 010+1(1+011)*00+ 6)
9(11+011)*010+1(1+011)*00+6)
(1+(1+011)*010+1(1+011)*00)
99,1 4,01=q,1(1+011)*01
=(1(1+011)*010+1(1+011) *00)*1(1+011)*01
Final regular expression:
(4.+96)=((1+(1+011)*010+1(1+01)*00)*1(1+011) (Ans.)
)(c+01) (Ans
11. Design an NFA which accepts set of all binary strings containing 1100 or 1010
as substrings. WBUT 2018]
Answer:
Regular expression
(0+1)
1100(0+1)
with 1100 or 1010
+(0+1)'1010(0+1
as substring.
01) 0+1
Bo-00-3O0
L8 o-o-O-0-8-0
MIC (0+1)'1100(0+1) +(0+1) 1010(0+1)
qxa1supe pniwolic
e tuaOO
s as 00t pet
(d
-T
FAT-66
FORMALLANGUAGE AND AUTOMATA THEOKI
e JRE
CLOSUR PROPERTIES OF REGULAR SETS
Multiple Choice Type
Questions
ina is
Lemma
generally used for
is proving whether [WBUT2006, 2016]
grammar regular
Va) a given
hl a given
grammaris not regular
given grammars are equivalent or not
c)two
none of these
d)
(b)
Answer:
4The value of
L(o*) is WBUT 2007]
a) c){} d) none of these
Answer: (c)
a)a, b, ab,aa
denotes the set
b)a,b, ba,bb}
c)a,b}
WBUT 2007, 2012]
d)aa,ab,ba, bb}
ASwer: (d)
FAT-67
POPULAR PUBLICATIONS
9. a
(a+b) is equivalentto (atb wBUT 2009,2013]
a) a'+b b) (ab) a'b
c) d) None ofthese
Answer: (d)
10.Consider the
following regular expression: R=(ab+abb) *bbab
Which of the following is not in the set denoted
by R? WBUT 2010]
a) ababab b) ababbabbbab c) abbbab d) abbabbbab
Answer: (a)
FAT-68
FORMALLANGUAGEAND AUTOMATA THIEOKI
ch
Whi
ofthe following strings can be
obtained by the
16. language L={a'b|i2l}
a) aaabbbbbb
b) aabbb WBUT 2013]
c) abbabbba d) aaaabbbabb
(a)
Answer:
a) 00111
b) 00110 c) 01010 11010
d)
Answere(a)
Answer: (d)
Answer: (d)
Answer:
Let
i)=(10)
i)-(+11)
ii) =(+0)
iv) r=rl1
v)=0lr
Corresponding nfa of regular expression r is
FAT-70
FORMAL LANGUAGE AND AUTOMATA THEORY
cet L, a subsetof Sigma star, is
accepted by a DFA. (We know this meand
is a regular language.)
is the union of some of the
2 nect to concatenation)
equivalence
equivalence
classes of a right
relation of finite index.
invariant (Witn
resp
relation RL be
Let equivalence
equivaler defined by: x RL z
y if and only
3.
ar. XZ €L exactly when yz eL Then RL is
if for all
E
star, offinite index.
at the language L={o"l|n> 0}is not regular. WBUT 2006, 2007, 2012]
Answer: exists a finite state
L r
is regular. There automationm which
w =a'bk . Then accepts L. Suppose
Suppos
k states.
Let w> By the pumping Lemma w =xyz where y 1s
k.
Now,L(s+ t)=SUT.
=
Hence L(r(s+t)) R(S U T)=RS U RT [fromSettheory]L(rs+rt)
Hence L(r(s +t)) =L(rs +rt).QED.
P=a+b(a+b)*
We construct the DFA corresponding to P using the construction is given the following
figure.
-0
^ moves
DFA with
FAT-71
POPULAR PUBLICATIONS
After eliminating
(a,b), P,
O5
DFA
DFA straight away,
A} where P
without
is
moves
given by
AaA 4aA
4bA 4b4
Ab Aa
Gis required regular
A b
grammar
[oo), 10 U{o'U10
Show that R is a right invariant. WBUT 2007, 2014, 2015
Answer:
IfR is a right-invariant the for all x, y, z xRyxzRyz.
I la has the nul-string, [O]a has only the string 0 and [00]R has strings 00, 000,
Clearly.
0000, etc.
Suppose x and y are in [ JR. Then, x=y null. Hence xz z and yz
= z and zRz is
trivially true.
Suppose xand y are in [0]R. Then x= y=0. If is from [ ]R. then z= null, i.e., xz =x and
z
yz= y. Hence z
xzRyz. If is from [0JR, then z
0. Thus, xz= 00 and yz 00. Hence xz= =
yz implying that xzRyz. Finally, if z is from [00]R, z has at least two 0-s. Therefore xz as
well as yz have at least three zeroesand hence both
belong to [00]R. i.e., xz R yz.
Suppose x and y are in [00]R. Then both x and y have at least two 0-s. Hence irrespective
of what z is, xz as well as yz will have at least two 0-s and thus both belong to
[00]R
Thus xzRyz.
So we see that for all cases xRy-> xzRyz. Thus R is right invariant.
7. The set L=
{a'b'c'where i, j, k are integerand i, j, k21). Is Lregular?
answer. Justify your
Answer:
WBUT 2008]
Suppose L is regular
Let n be given by pumping lemma.
FAT-72
Let
aaaa.
w
abb..
..abb... bb....bbb.
-i-s
p
k
FORMAL LANGUAGE AND
.bcc...cC.....
AUTOMATATEO
Re broken
up as shown l>0
ce zE L, r20 by pumping
lemma.
Henc k p <n n
=pts*P+q+r=s*P+(p+q+
*
r)=(s+ 1)*P
Since (s+ 1) P is not a prime, y is not in L, leading to a contradiction. So L is not
regular.
Answer:
anyz E L with
a2n
Canbe
decomposer as Jai tis h
Zuvw
with
uvS n,
FAT-73
POPULAR PUBLICATIONS
and 21,
such that z-uv'w,
is also in L for all i=0,1,2,..
The two commonest ways to use the Pumping Lemma to prove a language is
NOT
regular are:
show that there is no possible n for the (there. exists n), this is usually
accomplishedby showing a contradiction such as (n+1)(n+1) <n*ntn
show there is no way to partition z into u, v and w such that uv'w is in L
b) L {a"'b"n> 0}
LetL be regular. Let "adversary"choose n.
=
We choose z a"b". Obviously,|z|>=n
Now,
let
adversary
choose decomposition z=uvw such that uv <=n and v]> 0.
We note that whateverbe the decomposition, the string uv consists only of 0-s and v has
at least one 0. Therefore, for i>
1, uv'has more 0-s than uv and hence the string uv'w
has
more 0-s at the beginning than there are 1-s at the end, allowing us to conclude that
uv'w
is not in L. Hence L is not
regular. QED.
Note: Similar logic can be applied to
prove the languages
L= {a"bn> 0,k> n} non-regular.
10. What are Kleene Closure and Positive Closure? Give example for both.
[WBUT 2011, 2012]
OR,
What is
Klenne's star? Give example. What is positive closure? Give example.
R-s. Thus, R* =eRRR RRR|, where the vertical bar means A Positive
disjunction.
closure, denoted by R+, is defined to be the expression on the other hand is obtained by
one
concatenating or more R-s. Thus, R+=ER\RR|RRR.
Example:
Suppose R=a|bb Then,
R*=clalbbjaal abb|bba|
bbbb
R+=alblaa|abb|bal bbbl
FAT-74
FORMALLANGUAGEAND AUTOMATA THEORY
the Regular Expression for
Give the DFA
11.
using Arden
Theorem.
WBUT 2011, 2012, 2016)
START
Answer:
equations are
+0. +0.48-0
The state
(1)
+90+9,0 21-yt-1.+1.43-
q+91+9,1
59,0
(2)
3) 0-
Suhstituting
4+9(+01)(4)
6)in (2)we get:
2 1:t0
R=Q+RP,then R=OP
Weknow
+PR
that if
from (4),
Hence,
-1+01)
6) and (5)
6)
in (1)
R
Substituting
We get:
21(+on
4E+4,0+9,00
E+4(0+1(1+01)*00) At0.+0 02
orq,=e(0+1(1+01)*00)*
(0+1(1+01)*00)
0+
=A+
001+0DD
At
Which is the RE forthe given transition diagram. (0+oo1+0)
12.
Using Pumping Lemma show that L={a"b'":n>0} is not regular.
FAT-75
POPULAR PUBLICATIONS
13. What will be regular expression over the alphabet {a, b), for the
language
L=ja"b" :n>=4,m <=3? wBUT 2013]
Answer:
The regular expression over the
alphabet {a, b}, for the language
ogsugnE) Tstu
FAT-76
FORMALLANGUAGEANDAUTOMATA THEOI
Long AnswerType
guestions
struct a state
minimum
automaton
1.transition table is given below: equivalentto a given
automation
WBUT 2007]
State Input
a b
46
Answer:
92
93
94
xxx x
9o qi 92 93 4 9s
Since all states are distinguishable, the DFA is
already minimized.
the regular
b) Find
expression corresponding to the following figure: WBUT 2007]
Answer:
O'1
(o'1') o1
La)What is regular (WBUT 2009, 2010, 2018]
language?
Answer
A
regul defined over a finite alphabet such that ever
is a formal language
ingarlanguage
Strin
in the
languagecan be
FAT-77
POPULARPUBLICATIONS
i) (aa)*b(bb)*
ii) bb*abb*
Answer:
The state
96+9,0+q,0
441+g,1+4,1
equations are
1 ...(2)
94,0 ..3)
Substituting (3) in (2) we get:
9 911+9(1+01) 4)
We know that if R= Q+ RP, then R=OP
Hence, from
42q,1(1+01)
(4),
4 +g,0+9,00
6+9,(0+1(1+01)*00)
FAT-78
FORMAL LANGUAGE AND AUTOMATA THEORI
1(1+01)*0o)
orq,=(0+1
(0+1(1+01)*00)
isthe RE
for the given
transition
Which diagram.
etruct the minimum state automata
3Constru equivalent to given automata
ta M defined
below:
WBUT 20101
states
45
92 96
92 o
5 s
92
96
g2 g6
Cq indicates that q2 is the final state)
Answer:
94
95
6
97
90 92 94 95 6
h9.)-4-9,).{4.}.{9,}.{a.) B
A B CD E C*
D E
not Construct
Using Pumping lemma prove that L={ai21 is regular. Finite
FAT-79
POPULAR PUBLICATIONS
Answer:
Suppose L in and we get a contradiction. Let n be the number in FA
regular of states
0
accepting L.
Consider
as
>0.
a
This means
Sn,|Sn. Therefore
'
:|=lx|+3|y|+|=1>la|+|1l+1=l
=|z|=|x|+|»|+|z|<|v:
yx+3|+|s +n
1.e. n
+nsr +3n+3n+1
Hence, y'z strictly lies between n' and (n+1) but it is not equal to any one of them.
Thus ay'z in not perfect case and so
xy'z eL. But by pumping lemma ay'zeL. This
is a contradiction.
0 Deouborq istit 1
ogidns 0u
FAT-80
FORMALLANGUAGE AND AUTOMATA THEOKI
CONTEXT FREE
GRAMMARS
Multiple Choice Type
9uestions
A grammar in CNF may contain
a) A>B b) A- BC
productions Iike
WBUT 2007]
Answer: (6)
c) A-aB d) A->aBCD
2. L=a"'b'c", wherene1} is
WBUT 2009
regular
a)
c) context sensitive but not
contextfree but not regular
context free b)
d) none of these
Answer: (c)
Answer: (d)
tree for some sentence is said to
than one parse
Abe grammar that produces more WBUT 2011]
unambiguous d) regular
a)
contiguous b) ambiguous
Answer: (b)
FAT-81
POPULAR PUBLICATIONS
Answer: (d)
Answer: (b)
12. Consider the grammar S aSAble
AbAlE
The grammar generates the stringsof the form a'b for some i, j20. What is the
conditions of the values ofi andj?
a) =j i
b)j s 2i c)j22i
s[WBUT2014, 2015]
d) iSj
Answer: (d)
13. Which of the following common in both CNF & GNF? WBUT 2014, 2015, 2017]
(NT)(Single T) (String
a) of NT) b) (NT) (Singleof exactly two NT)
c)(NT) (Stringof NT) d) (NT) (SingleT)
Answer: (d)
4-Ww"We{0,1)"
L=}{W #Ww We
{0,1},where # is a special symbol
L, {ww|w e(0.1)*}
Which one of the following is true? WBUT 2014, 2015, 20171
a) is a deterministic CFL
b) L,is a deterministic CFL
Lis a CFL, but not a deterministic
c) CFL
d) Lis a detèrministic CFL
Answer: (b)
FAT-82
FORMALLANGUAGE AND AUTOMATA THEORY
15. A context
free
grammar is not closed
a) Product under
WBUT 2016]
c) Complementation b) Union
Answer: (c) d) Kleen star
Context sensitive
a) deterministicpush
grammar can be
recognized by
down machine WBUT 2016]
b) non-deterministicpush down machine
c) FSM
d) linearly bounded memory
machine
Answer:(d)
8.CFLType
is
a) 0 language.
WBUT 2018]
b) Type 1
2
c) Type d) Type 3
Answer: (c)
FAT-83
POPULAR PUBLICATIONS
H BD
Show that
b) Consider G whose productions are SaAS/a, A SbA/SS/ba.
whose yield
Saabbaa by constructing a derivation tree, by right most derivation,
is aabbaa.
[WBUT 2008]
Answer:
SaAS
aSbAS
aabAS
aabbaS
aabbaa (proved).
L={0'12"|li=j orj=k).
Answer:
SABB
A 0A|0
B1B212
5. Let G be a gramm WBUT 2009, 2010]
i) leftmostderivation
ii) rightmost
derivation
il)
FAT-85
POPULARPUBLICATIONS
c)
permitted.
L(G)=L(G)
For Step-0, we need to add a rule Y>b. So we start the main process ofconversion of
the grammar to with the rules:
GNF
SABYa
AaaA|B
FAT-86
FORMAL LANGUAGE AND AUTOMATA THEORY
B-bBY
Y-b
There no immediate
is
left
recurstion in the
We select the order
S,4,B,Y, Clearlythere grammar.
is no need
So.the final grammar in GNF is for nonterminal
Yb substituuron
B bBY
Aaa4|bBY
S aaBY bBY BY|a
AA4
4A,4 b
4,44la
The grammar is already in CNF.
Round-1
AA,4,
4444|la4|b
4441a
Round-2
44444|a4,4|b4,
But this requires removal of left recursion
Aa 42|b4,Z|a44,|b4,
ZA444,2|4444
A444la4lb
444a
FAT-87
POPULAR PUBLICATIONS
Round-3
4a
Z
4,2|b4,Z|a4,4,|b4,
aA AZA,A4,Z
bA,ZA,4,4,Z
a444442
bA,4,A4,Z|
a4 4ZA 444
bA,ZA,44
aA A4,44
bAy444
4a dsZA,A|b4,ZA2
as4d4bd,d,4a4|b
Aa4 4ZA|b4,ZA| a4,4,4bA,4,a
The grammar is now in GNF
WBUT 2013]
Answer:
Let us assume CFG G=(V,,V,P, S)
V={S,A,B,non terminals
V={a,b,c}. terminals
P (production defined as follows:
S rule) is
AB
A>aAbb/e
BCB/6
10.Construct grammar of the following.
the language a1 bmcn, where 1+m=n [WBUT 2014]
a) Construct the grammar for
b) all even integers up to 998. WBUT 2014, 2017]
Answer:
a) S->aAc;A->bBclaAcl epsilon; B->bBclepsilon
b) S->ABAAB|024|618; A->0|1|2/314151617/8/9; B->024|618
FAT-88
FORMALLANGUAGEAND AUTOMATA THEORY
Answer:
SAAJa
ASSb
AAAS |b JaS
AaSZ bZ |as|b
ZASZ epsilon
So the GN
saSZA |bZA |aSA |bA Ja
AaSz |bZ|aS |b
ZaSZSz|bZSZ| |
aSSZ bSz
12. a) What is
parse tree?
b) Consider the CFG WBUT 2015]
S-aaB
A-bBbl &
B- Aa
Find the Parse tree for the string aabbababa.
Answer:
a) A parse tree is an entity which represents the
structure of the derivation of a terminal
from some non-terminal(not
string
necessarily the start symbol).The definition is as in
the book. Key
For each
For each rule
o E
A
,
features to define
there is
e,
are the root E
a tree
there is
V and yield E 2 ofeach tree.
with rooto and no children; yield is o
atree with root A and one child
its
e; its
yield is e
If t1,
t2 ,Cnare parse trees with roots ri, r2,
n and respective
yields Y1,
Y2 Yn and A rr.r is a production, then there is a parse
tree with root
Yn
A whose children are t,
tz ta Its root is
Aand its yield
isY1Y2
FAT-89
POPULAR PUBLICATIONS
i)
left most derivation
rightmost derivation
SaB | ||
ba, B b bS aBB. WBUT 2016]
14. What do you mean by unit production? Remove unit productions from the
rammar
SAB,A >a,B->C, CD,D>b. WBUT 2017]
Answer:
Part:
A unit production is a production A B where both A and B are non-terminals. Unit
2. Forevery non-unit
1.Add production
production,
4ato
B a
the
repeat the following step
grammar
3. Eliminate A B from the grammar
2Part:
There are 2 unitproductions in the grammar
BC
CD
FAT-90
FORMALLANGUAGE AND AUTOMATA THEORY
Cor production
mar. Now we Dthere isD->b,so we add
have B
>C, so we add a Cb and delete C>Dtrom
the grammar
production B->b and remove B
the final
Now weget grammar freeof
unit production
SAB as-
Aa
B-b
Cbwe can see
that C is an
Now
unreachablesymbol and so
rammar,we remove C from the to get a completelyreduced
CFG.Thus the final CFG is
SAB
Aa
.
Bb
15. Construct grammar of the
following:
For the
language ab",where n>=0.
Answer: WBUT 2017
LG)={ab,aabb, aaabbb,
G {N,T,P,S,}
N= {S.A,B}
T {a,b}
Sstartingsymbol =S
P SaA, A >aA|bB ,B bB|E
16. Define Left Linear and Right linear grammar. Construct grammar for the
following FA:
WBUT 20171
Answer:
b
Part:
I
Left Linear Grammar: In a
are in the form
efi grammar, ifall productions
A Baor A->a, where A,BEVw and ae, then the
grammar is called
Left
Linear
Grammar. Example: Aa|Bb|b
FAT-91
POPULAR PUBLICATIONS
in the form-
In a grammar, ifall productions are
Right Linear Grammar:
AaB or 4 a,
where A,Be VN and ae,
then the grammar is called Right
2nd Part:
The grammar G can be formally written as a 4-tuple (N,T, S, P) where
N= {S,A,B,C};N is a set ofvariables or non-terminal symbols
SAalB
BA|bb
Aalbc|B
are present
Here, three unitproductions
SB, A B, BA
SAal4|bb
Balbc|B|bb
Aalbc| A|bb
We can remove the void
B->B
So, Balbc|bb
SAa a|be
4a bela|be bb
|bb
production
Same productions
. Final productions
|Balbe|bb
are
can be removed.
SAalalbc|bb (Ans.)
4-albe bb
FAT-92
1AA
FORMAL LANGUAGE AND AUTOMATA THEOK
LLong Answer Type
guestions
Let G be the grammar
1.
(1) S aß
(2) SbA
3) A >a
> aS
.
(4) A
AbAA
(6)
(6)
(7)
B
B bS
b
(8) B aBB
SaBaa BB B BBaaabBB
aaa b bSB5 aaa b b aBB
aaa
6 aaa bb a bBB
FAT-93
POPULAR PUBLICATIONS
B B
2. a) EE+E|E'E|a. Prove that the CFG with this production rule isambiguous.
Remove the ambiguity from this grammar. WBUT 2008]
Answer:
b) SAB;Aa, BCIb,CD;D-E,Ea.
remove the unit production.
L=(a bIn2
0).Find
a CFG to generate L WBUT 2008]
Answer:
Here unit productions are:
BC
CD,
DE.
And original non-unit productions are:-
SAB,
A a,
Bb,
Ea.
Next right side of all unit production replace only terminal symbol so the productions are
SAB,
Aa,
B-b,
FAT-94
FORMALLANGUAGE AND AUTOMATA THEORY
Ea.
the comple
Then productions are:
SAB,
Aa,
B-a b
Ea.
w= a" b" E L
Suppose
Then awba bEL
Hence required CFG is:
Sawb.
3. a) Convert grammarsto Greibach Normal Form
(GNF). [WBUT 2009]
) SaSa aSb le
i) SaSB aSbse
Answer:
speaking, none of the given grammars can be
Strictly
SaSA
SaSB
SE
Aa
Bb
i) The given grammar
b) Find a reduced
is incomplete sincethere
[WBUT2009,2014,2017
SaAa,A >bBB,B- ab,Caß.
Answer:
Clearly C isa uselesssymbol. Eliminating C, we get,
S aAa, A bBB, >> ab B
Now we replace all occurrencesof B on rhs of production using B >ab, getting:
Sada, A>bab ab
Now we substitute A, getting
similarly
S a ba ba ba
which is the equivalentreduced grammar
FAT-95
POPULARPUBLICATIONS
L={a'bc"d"|m, n 0
i) >
Hi) L-{a'b|n *m
b) Convert the following grammar to CNF
SaAlB/Cla
aB/E
BaA
CcCD
D abd [WBUT 2013]
c) Define non-generating and non-reachable symbols with example. WBUT 2013]
Answer:
a)i)Consider Lpwe:w=
For example otto e Lot madamimadam e Lp
In finish languagee.g. saippuakauppias eL ("soap-merchant"
2. P
3. P 1
4.
P 0PO
5. P 1P
0 and 1 are terminals
P is a variable (or nonterminal, or syntactic category)
P is in this grammar also the start symbol.
1-5 are productions (orrules)
FAT-96i
FORMALLANGUAGEAND AUTOMATATHEOR
S
ABC
aAblab
B cBd
cd
C
aCd|aDd
D bDebe
Let's
look at parsing the string aabbccdd.
C d
a
(a)
(6)
From this we see that there are two leftmost derivations:
SAB>aAbB>aabbB>aabbcBd>aabbccdd
m Im Im
And
Im m
S-CaCd>aaDdd>aabDcddaabbccdd
m Im
m m
It can be shown that every grammar for L behaves like the one above. The language L is
inherently ambiguous.
L=a'b"|n+m
lfn#m,then two cases are possible
Case-1
n>m
L=a'b:n>m
fG be the CFG
for L language
G,=(VV,PS)
={a,b
Productions
P are
SAS,
FAT-97
POPULAR PUBLICATIONS
SaS,b/e
AaA/a
2
Case
n m
L=01:n<m
If G, be the CFG for L
G,=(V"V,P', s")
V=la.b}
P are
S SB
Sas,b/s
B bB/b
Bycombining (G, & G,) we can write CFG forthe above.
S S/S where Sisthe start symbol.
b)SaA/BICla
AaB /E
BaA
CCCD
D abd1
CNFS>GAIC,B/CCICC
Ca
C
ACB/,E
B>CA
CCCD
CC
CXD
X >C.C
DCC,C
Cb
Cd
DYC
YCC
FAT-98
FORMALLANGUAGEAND
AUTOMATA THEOI
inition of non-generatingand
c)De
SAB
aA
a non-reachable
symbols with example.
A
B>b
iable is non-generaung if it does not
A variable
wample A is
non-generatingsymbol.
derive any
string of terminals. In the
abov
A variableis non-reachableifthe start
symbol does not derive a which
that variable. string contains
If Yw, A symbol y is
unreachable if w
example
B is unreachable after string does not contain y. In the above
deleting
ng
non-generating symbol A from production.
production.
Prove that Context Free
Languages arenot closed under
intersection.
L ={a"b"c":n 20 m 20}
and L={a'b c"n20 m 20
There are several ways one can show that Ll and L2 are context-free.
for Ll For instance, a
is
grammar
S S1S2
$2 aSi b|2
$2 cSi
Alternatively, we note that Ll is the concatenation of two context-freelanguages, so it
is context-free. But
L1 L2 {an bn cn n20},
which is not context-free. Thus, the familyof
context-free languages is not closed under
intersection.
6.
a) E->E+E|E*Ela. Prove that the CFG with this production rule is
ambiguous.
Remove the ambiguity from this grammar. WBUT 2018]
Answer:
Part:
E-E+E E* Ela
Say, string is:
a+a*a
FAT-99
POPULAR PUBLICATIONS
Derivation Tree2
Derivation Tree 1
So,more than one derivation tree forthe string generated from the grammar.
The givengrammar isambiguous.(Ans.)
2nd Part:
Removing ambiguity:
EE+T|T
TT*FIF
FEla
b) S- AB; A->a; B->Clb,C->D; D->E,E->a
Remove the unit production. WBUT 2018]
Answer:
Refer Question No. 2(b) r'Part of Long Answer Type Questions.
FAT-100