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

Flat 01

Given FSM: Q={q0,q1,q2} E={0,1} 6: QxZ>Q 6(q0,0)=q0 6(q0,1)=q1 6(q1,0)=q2 6(q1,1)=q1 6(q2,0)=q2 6(q2,1)=q1 q0isinitial state F={q2} Merger Graph: Nodes are states of given FSM Directed edges show transitions on all inputs Self loops for no transition q0- 0,1->q1 q1- 0->

Uploaded by

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

Flat 01

Given FSM: Q={q0,q1,q2} E={0,1} 6: QxZ>Q 6(q0,0)=q0 6(q0,1)=q1 6(q1,0)=q2 6(q1,1)=q1 6(q2,0)=q2 6(q2,1)=q1 q0isinitial state F={q2} Merger Graph: Nodes are states of given FSM Directed edges show transitions on all inputs Self loops for no transition q0- 0,1->q1 q1- 0->

Uploaded by

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

FORMAL

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

FINITE STATE MACHINE


Multiple Choice Type guestions
of Finite State Machine of that WBUT 2007, 2010]
1. The basic limitation amount of information
a) cannot remember arbitrary large
it

b) cannot recognize grammars that are regular


it

that are not regular


c) it sometimes recognize grammars
d) all of these
Answer: (a)

2. A shift register is a WBUT 2010


Moore Mic c) Turing M/c d) All of these
a)Mealy Mic b)
Answer: (d)

3. FSM can recognize WBUT 2011]


of FSM on CFG
a) a grammar dependent on characteristic
b)

c) any unambiguous grammar d) only regular grammar

Answer: (d)

4.Which true of the following?


is WBUT 2013]
directed graph
a) Merger graph is directed graph b) Compatible graph is

c) Both are directed d) None of these


Answer: (6)

5.Compatible pairs are obtained from [WBUT 2014, 2015, 20171


a) Merger Graph b) Compatible Graph
c) Testing Table d) Testing Graph
Answer: (a)

A finite automata recognizes WBUT 2018]


a) Any Language b) Context Sensitive Language
c) Context Free Language d) Regular Language
Answer: (d)

7. Maximum number of statesof a DFA converted from a NFA with n states is


[WBUT 20181
a) n b) c) 2 d) None of these
Answer: (C)
JonS
8. Regular Expression is accepted by WBUT 2018]
Automata
a) Finite b) Push Down Automata
c) Turing Machine d) All of these
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

remember an arbitrary number of past input symbols, for example in recognizing


heeds to

d,n>0, cannot be implemented by sequential


machines. By the same reasoning, a
quential machine cannot multiply two arbitrary length binary strinj

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.

2:Check and determine whether the implied


is incompatible it no arc is drawn
between
pair are indeed

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

not contained; higher-order complete polygon, they constitute a maximal compatible.


n the merger graph the set of highest-order (ABCD) and the arcs (CF),
polygons are the

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)}

.a)A long sequence of pulses enters a synchronous sequential circuit, which is


whenever the sequence 1001 occurs.
uired to produce an output pulse z=1
Overlapping sequences are accepted.
)Draw a state
) Sele an
diagram
assignment and show the excitation and output tables. WBUT 2015]

FAT-5
POPULAR PUBLICATIONS

Answer:
a) i) O0 1/0

A
0/0 D)
O/0

0/0

ii)

PresentState Next State, Z


Inputx 0 Inputx=1|
A.0 B,O
A.0 CO
D,0 4,0
1,0 C1
Yiy2
YY =1x0x=1
x-0X=1
A0000 01 0 0
|B01 00 11

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:

1/0 070 170


1

0/0 1/0 0/0

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,

For i/p=0 For i/p= 1

0 0

0 0 0 0

D
Circuit:

DD qtuo 9ninoR
yiio o)ste to

FAT-8
FORMALLANGUAGE AND AUTOMATATHEORY

FINITE STATE MODELS


Multiple Choice Type
Questions
the correct stateme
ments:
1. Choose
a) moore and memealy machine are FSM [WBUT 2006, 2012]
any given Moore machine has an with output capability
any given Mealy machine has an equivalent Mealy machine
machine is not an FSM equivalent Moore machine
d) moore

Answer: (a), (6) and (c)

Which is true of the followingg?


a)Merger graph is a directed graph WBUT 2009
c) both are directed
Compatible graph is a directed graph d) None of these
Answer:(b)

3. Merger table is a substitute of


graph
WBUT 2009]
Merger b) Compatible graph
c) Minimized machine d) Finite state machine
Answer:(a)

4.The loop-free testing graph indicates that


a) the machine has finite memory
[WBUT
2010]
b) the machine has non-finite memoryy
c) the machine has finite states d) the machine has non-finite states
Answer: (a)

5. Input sequence of an information lossless machine can be determined from the


knowledge of WBUT 2010]
a) only output sequence
b) output sequence and initial state
c) output sequence, initial state and final state
d) initial state
Answer:(a)

5. Moore machine output depends on WBUT 2011]


a)input b) inputand present state
none of these
9 present state d)

Answer:(Cc)

associated with WBUT 2017]


In oore machine, output is
b) next state only
present state only
) present state and input d) none of these
Answer:(a)

FAT-9
POPULAR PUBLICATIONS

8,Numberof vertices of a Merger graph is WBUT 2018]


a) The number of state of the machine b) Number of compatible pairs
c) Number of statescombinations d) None of the above
Answer: (a)

9Number of vertices of a compatible graph


thenumber of statesof the machine
is

b) number of compatible
[WBUT 2018]
pairs
a)
c) number of statescombinations d) None of the above
Answer: (6)

Short Answer Type Questions


1. NS, Z
PS
C, 0

,
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

Next step merger table.

B
C

D x BE

E
A B C D
Final merger table

2. Minimize the following machine to standard form: [WBUT2006, 2008]


PS NS, Z
X= 0 X=1
E, 0 C, 0
C, 0 A, 0
B, 0 G,0
G,0 |A,
|B,0

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

B-(BD)(C)(AF)(E) (BD)goesto A on i/p=1


A goes to C but F goes to D on i/p=1
R=(BD)(CG)()(F)(E)|
Final partition.
=(BD)(CG) (4)(E)(F)
Let
(4)a
(BD)B
(CG)
(F)8
(F)0
Reduced machine
NS Z
PS X =0 X=1
a 6,0 Y,0
Y,0 a,0
B,0 7,0
0,1 B,0
8,0 Y0
3. do you
What. mean by Inverse machine? Write the definition of a lossless
machine. WBUT 2008]
Answer:
An inverse M is a machine which,when excited by the output sequence of a machine M,
produces (as its output) the input sequence to M, after at most a finite delay. Evidently, a
deterministic inverse can be constructed only if M is lossless, and it can be constructed so
that it
produces M's input sequence after just a finite delay if and only if Mis lossless or
finite order

A machine is to be (information) lossless if the


knowledge ofthe initial state, the output
sequence, and the final state is sufficient to determine
uniquely the input sequence.
4. What is the basic difference between
Mealy machine and Moore machine?
WBUT 2009]
OR,
Define and compare Moore and
Mealy machines WBUT 2015]
FAT-12
FORMALLANGUAGE AND AUTOMATA THEORY

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

Block diagram of Moore Machine

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

transition function, and A: Q * A is the output function.


associated with the transition from state q on
The 2 function gives the output symbol
input symbol a, i.e.,
g,a)=z eA That is because sequential
Notice the six-tuple does not have a set of final states.

machines do not have final states


of the input string. The state
The
length of the output equal to the length
string
is
for finite
ransition
diagram for a Mealy
machine M
is almost identical to the diagram

on the edge by appending to


the input symbol, a
the output symbol is denoted
aulomata, machines are used to design
ES() followed by the output symbol. Sequential
Sequentialcircuits. aupn

FAT-13
POPULAR PUBLICATIONS

Input
Comb
Ckt

Present Output
State Comb
Ckt

Memory
Is Function of
Output
Present State AND Present

Input

Block diagram of Mealy Machine

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

the machine given below producees


5. response to an unknown input sequence,
In
machine if it is
the output sequence 1110000010. Find the input sequence to the
known that its initial state is A and final stateis F. WBUT 2009]
NS, z
PS x=0
B, 1
D, 1
,
x=1
B,
0
1

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

Output: 11 1 0000 010


Possible states F A BDEFDACEF
ABE
BC
But we know that the first state is A and since the first
output is 1, the next state is B.
Also, since the next output is 1, the next state is B or D. But we have found that this state

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

6. Is the following machine information lossless? If yes, find the order of


losslessness. WBUT 2009]
PS NS, z
X= 0 x=1
B A,0
C, 0
FAT-14
D,
B, 0
0
FORMALLANGUAGE AND AUTOMATA THEORY

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

The lower part of table is constructed from the


compatible pair of states of the
the testing
of table. In the lower part of the table all
upper part the the implied pairs have been taken
as a row heading.

Fig: Testing graph for machine M


From the lower part of the testing table it is clear that,
there
is
no compatible pair with

repeated entries. This is necessaryand sufficient for a machine to be lossless.


So clearly the given machine is
lossless.
Inthe above testing graph the length ofthe largest path
is =2.
Hence the
order of losslessness, =l+2=2+24
7. ConvertMealy Machine to Moore Machine. WBUT 2011, 2012, 2016]
0/Z

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

931 q30, Z2 921,Z1


The corresponding Moore Machine will be,
Present NS
State i/p=0i/p=1 Output
92 3
20 2
21 g2
g30 93 92 Z2
L931 q3 z
8. Design a two input two output sequence detectorwhich generates an output 1
every time the sequence 1001 is detected. And for all other cases output 0 is
generated. Overlapping sequences are also counted.
[Denote State Graph, StateTable and perform State assignment]
WBUT 2014,2015
Answer:
Before designing this circuit some clarifications regarding sequence detector is needed.

Let's assign the input string as 1001001.


We have to design the circuit such a way that it will take one input at a time. The inpu
is

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

called state assignment. As the number of states is four, only


two digit number is

sufficient to represent the


fourstates (2 4)
Let's assign

S, to 00
S to 01,

S, to 11,

S, to 10.

After doing this state assignmentthestate


PS(
X
NS ()
table becomes.

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

Minimize the machine using equivalent partitioning [WBUT 20151


Present state Next state, output
X =0 X =1
E,0 D,1
F,0 D, 0
E, 0 B,1
F0 B,,0
C,0 F,1
B, 0 C, 0
Answer:
Po (A,B,C.D,E,F)
P-(A,C,E) (B,D,F)
P (A,C,E) (B,D) (F)
P (A,C)(E) (B,D) (FF)
Say: (AC)a,EB,(BD),F8
The standard form of the reducedmachine is:
PS NS
X=0 X=1
B,0 2,1
a,0 8,1

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

Fig: State diagram

FAT-19
POPULAR PUBLICATIONS

State Table: From the previous state diagram, a state table as follows can easily be
constructed.

Next State, O/P


Present X=0 =1
State
S
S2
Si, 0
S3, 0
S2, 0
S2, 0
S3 S, 0 Sa, 0

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

Beginning state B and final state D is obtained


from one path with input string 10100010.
12.Design a two-input two-output
sequence detectorwhich generates an output 1
every time the sequence 1101 is
detected. And for all other cases output 0 is
generated. Overlapping sequences are also counted.
Answer: WBUT 2017]
The sequence is 1101. Wehave to start from S. If
we get input 0, then there is no
chance, so it is confined in Si producing
output 0. If we get input 1 then there is a chance
get 1101, so the control moves to S2 producing
output 0 (as we have not till got 1101
to

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

producing the output 1. As overlappingsequence is also accepted, the control moves to

2 S0 that by getting 101, the sequence detector can produce 1.

110 101

i di1

FAT-21
POPULAR PUBLICATIONS

The state diagram is givenbelow

0/0
1/1

0/0
1/0 1/0 0/0

1/0

0/0

Figure 1

The state table forthe


sequence detector,
PS
X 0
NS

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

that the following FSM


OR,
Show tha isinformation lossless of finite order:
PS NS,Z
X 0
C, 0
D, 0
A, 0 B, 0
D C,1 D,1
Table-5
find its order ofiinformation
Also losslessness. WBUT 2008]
Answer:

a)
We use the backward sequencing to get

A BB D 0 EFD A CEF
1 0 0 0 0
1 1
1

Hence, the input sequence is


0101000100
b)

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.

Now the present states of the inverse machine can be defined


by a set of triples, which is
denoted by (S),Z{t +1),Zt+2)) where St) is the possible states of the originàl
machine M and Z{ +1), Z( +2) are 2 outputs.
For the above machine we have the following triples:
(A,0,0) (B,0,1) (C.0,0) (D,1,0)
(A,1,1) (B,1,0) (C.0,1) (D,1,1)
The rest of the triples are not defined.

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

machine and finally the third member is the present output of M.


e state
Machine-M
table
of the correspondinginverse machine is shown below:

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

(B,0,1) (D,1,0),0 (D.1,).00


(B,1,0)(C.0,0),1(C.0,1),1
FAT-23
POPULAR PUBLICATIONS

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

eincompletely specified machines shown in Table-2 find a


minimum-state
reduced machine containing the original one. WBUT 2007]

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,

Write down all


compatiblepair in respective cell.
An 'x is inserted in cell where the states have conflicting outputs. Here A andD
have conflicting output. Similarly AE, BD, BE having conflicting output.
Insert a check mark in cell CE because state E contain State C.
Cross those cells having incompatible pair. Here cell BF contain incompatible

pair DF so ignored the cell BF.

(CE)
Compatibility Graph
AC)

(BC)
(CF)\
(AB)

(EF)
? (AF)

(DE) (CD)

he set {(AB),(AC), (BC), (CD), (EF)}


> {(ABC), (CD), (EF)} is a minimal cover of
the above
machine
Table determine whether or Rotis
a)For the followingfindmachine shown
the shortest output sequence produced by
in
two-eWarent
Ssless. If it is losSy,
with the same initial and final states. If it is lossless, deteroine ils
Sequences
order.

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:

(A,0,0) (B,0,1) (C,0,0) D1.0)


The
(A,1,1) (B,1,0) (C.0,1) t(D,11)t
restof the triples are not defined.
Thus the inverse machine has
present states defined by the eight triples shown above.
Now the next state of the inverse machine can also be defined by 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

4. a) What do you mean by k-equivalent states? 2009, 2011] WBUT


b) Minimize the following machine by partitioning the distinguishablestates:
Present
state
ilp=0
Next State
ilp=1
A
olp NextState o/p
0 D 1

0 D
0
0 B

c) Give definition of lossy and lossless machine. WBUT 2009]


Answer:

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.

(AC)>P (E)-> (BD)>R (F)-> S and (GH) T


FAT-27
POPULAR PUBLICATIONS

The minimal machine is:

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)

Merger Tale CompatibilityGraph

B (AB) (CF) (AC)


C CF EF EF) (BC)
(BE)
D BE
(CD)
E x (AD)

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

e al What isinformation lossless machine?


der the machine shown WBUT 2010]
b) Consider inthe following table: WBUT 2010, 20141
Present State Next State
X =0 X=1
A 1
E, 0
C,1
B,1
D, 0 A, 0
C, 0 B, 0
B,1 A, 0
Is this machine information losslessof finite order? If yes, find the order
Answer:
() A machine is to
be (information)
lossless if the knowledge of the initial state, the
output sequence, and the final state is sufficient to determine uniquely the input

sequence
(b)Step
1: Check each row of the
state table for an appearance of two identical next-

state entries associatedwith the same output symbol.


Here (AC) is a compatible pair, since both A and C are the output 1-successors of A.

Similarly, the pairs (AD) and (BC) are compatiblepairs.

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

Testing table of machine M


PS
A
0 Z1
(AC)
B E B
C 0
(AD)
(BC)
B
AC
AD
BC (AEXDE)
AE (AB)BC)
DE (ABXAC)
AB (AB)(BC) Testing graph for M
machine

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

C,0 A,1 B,0


C, 0 D, 1
- E,1B,
A, 0O
i) Draw the merger graph.
ii) Draw the merger table.
B, 0 B,0
fii) Draw the compatibility graph.
iv) Find the minimal closed covering with
justification.
Answer:
Step 1: First draw the merger graph of machine.

(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.

8.Convertthe following Mealy machine to equivalentMoore machine.


Present State /P=0 WP=1
Next State OIP Next State O/P
qo q1 q2
q1 13
q2 g4 g3
g3 q1 g4
q4 q2 q4
[WBUT2014, 2017]
Answer:
State Output
0

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

Moore Machine Table


Presen State NextState Output
r=0
o 421
10

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)

(BC) (CD) (AC)


(BD) (CD)

(CD) (DD)
(discarded)

FAT-34
FORMALLANGUAGE AND AUTOMATA THEOKL

Graph;
Testing
AB
BC

AC BD
CD

AD

Here, in this testing graph, no we can say


loop so, it is a finite memory machine.
Order ()E Maximum length path ()+1
.Here,

(ABBCACAD BD CD)

max. path length is 6


u=6+1=7 (Ans.)

FAT-35
POPULAR PUBLICATIONS

STRUCTURE OF SEQUENTIAL MACHINES


Short Answer Type Questions
1. the following machine
Is information lossless? If yes, find the order of
losslessness. WBUT 2011]
NS,z
X=0 X=1
A,0 B, 0
C,0 |D,0
| C1
D D, 1
B,I A,1
Answer
Test of information losslessness
NS, t
PS
A
x=0
A, 0
x1
B,0
B C, 0 D, 0
C D, 1
C,1
D B, 1
A, 1
The first
step of this testing procedure is to check each row of the transition
table,
whether there is two identical next state
entries associated with the same output symbol.
From the above table it is clear that, there is no identical next state
entries.
Now we have to construct the output successor table.
Testing table for Machine-M
PS
A
Z0
(AB)
B (CD)
C (CD)
D (AB)
AB (AB)(CDD)
CD (AB)(CD)
AC
AD
BC
BD
The lower part of the testing table is constructed from the
compatiblepair of states of the
upper part of the table. In the lower
part of the table all the
as a row heading. impliedpairs have been taken

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

what is the order of definiteness? Justify.

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

Long Answer Type guestions


1. Consider the machine given below WBUT 2010
Next State
Present State
XD 0 X=1Z
G
HC
0
0
B
Drive the closed
Answer:
GH
partitions.
E
A
G

C
Construct an-lattice for it.
B

First we.determinetsis for every pair of states:


1.
A,BA,B;C,D;E.G;A.B:C.D;E,G;F,H; Ta
2. A.CAC:D,H;G,F; A,C;D.H:G,F;F.E:C,F;A,G;B,D;A,C.E,F,G;B,D, H;>A,
C.E,F.G:B,D.H;D,H,B.G.A;G.F,B,D;A,B,C.D,E,F,G,H;> T()
3. A,DA,D;D.F;G.F;A.D;G,F:B,D,G,F;A,B,D,G.F;A.C.D,F,G;B,D,G.E,F;
A.B.C D.E,F,G;A,B.CD.F.G,H;AB,C.D,E,F.G,H; ()
4. AEA,E;B,D;B,G; A.E;B,D,G;A.C.F;B,E,F;A,B,C.D,E,F.G,HT(O
5. A,FA.F:D,G;A.F:DG;B,F;A,B,F:D.G:C.D,G:D,E, G;A,B,F:C.D.G,E;A,
B,F.H:A,B,F. H;C.D.E,G;
6 A,GA,G:A,D;B.G;A,B,D,G;A,C.D,F;B,E.F,G;A,B,C,D,E,F,G;D,C.HF,B,
G,A.E;AB,C.D,E,F,G,H: T()
7. A,HA,H;D,E;C.G;A,H:D,E;C.G;B.F; T
8. B,CB.C;C.H:E.F;B,C;C.H;E.F;E,H;C,F;B,D;B, G;B.C.D,E,F,G.H;C.H.F.B
,G.A,E;AB.C.D,E,F,G,H; T()
9. B,D>B.D;C.F;E.F;BD;C,E,F;B,G.H:B.D.F: >B.C.D,E,F,G3.H;
C.H.F,B,G,A,E;A,B,C.D,E, F,G.H; rI)
10.
B,EB,E;B,C; B,E;B,C:C.H;E,F;>B.C,E,F,H;B,C,E,G,H;E,F,D,B,C:B.C.D
E.F.G,H; C.H,F.B.G,A.E;>A,B,C,D,E,F,G,H, rO
11.
B,FB.F;C,G;D,E; >B,F;C,G;D.E;A,H; T
12.
B.G-B.G:A.CBEB.GA.CB.E:DHF.GB.C;A.B.C.E,F.G;D,H:;A,B,C.D.
GH;A,B,C.D.E,F, G,H; m(I)
13.
B,HB,H;C,E;>BH;C,E;B,F;B,F,H;C,E;C,E.G:C.D,E >B,F,H;C.D,E,G
B,F,H;C,D,E,G;A,B,F,H:A,B.F.H:C.D,E.G:te
14. C.D-CD;H,F:>C,D:H.F;G.E:->C.D;H,F;G.E,AB:
15.
C,E>C,E;B,H;B,F;>C.E;B.F.H;C,E,G;C,D,E; >B.F,H:C.D,E,G;>B,F.H.C,D.E
,G;A,B,F,H;>A,B,F,H;C,D,E,G;
16. C,FC,F:G,H;D,F;>C.D,F;G,H;F,G.H;F,D
>r
C.DF,G,H;A,E,F.G.H;B,C.D.F
A,B,C,D,E,F,G,H; r()

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

EA,B,c.D,E, F,G,H;> r()


D.HD,H;E,F;C,F;9D,H;C,E,F;B,G,H;B,D,F;>B,C,D,E,F,G,H;C,H,F,B,G,A,
23

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; C,D; E,G; F,H

-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;

A,H:B,F; C,G; D,E

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)

3. DFA has WBUT 2008]


a) single final state b) more than one initial states
unique path
c) (for a set of inputs) to the final state d) all of these
Answer:(c)

4. What the highest type number to the grammar given by the following
is

production rules SAa, Ac|Ba,


B-abc [WBUT2008]
a) zero b) one c) two d) three

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)

an NFA with n statescan have maximum WBUT 2009]


DFA converted from 2" states d) C, states
n states c)
a) b)n!states
Answer:(c)

[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)

A0. DFA has a transition function [WBUT2011]


a) Ox to b) Ox2 to
2 c) both (a) and d)none of these
Answer: (a)

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)

12.Can a DFA simulate NFA? [WBUT2012]


a) no b) yes c) sometimes d) depends on DFA
Answer: (b)

13. Let N be an NFA with n states


and let M be the minimized DFA with m states
recognizing the same language. Which of the following is NECESSARILY true2
a) ms2" b) n Sm WBUT 2014, 2015]
c) M has one accept state d) m 2
Answer: (a)

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)

17. An automata isalan.... device.


acceptor only
a)
WBUT 2016]
b)acceptor /rejector
c) rejector only
d) generating
Answer: (b)

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:

Short Answer Type


Questions
the
theMealy Machine (given below)to a Moore
Convert
1. Machine. WBUT 2008]
Present Next State ip-0
State Next State ilp=1
State Output State Output
Q2
Q
Q3
Q4 Q
Answer:

The Mealy machine constructed form transition diagram is

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

a Mealy machine which is equivalent to the Moore machine


2. Construct given
below:
[WBUT2009
NS
PS
x=0x =1

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.

4. Design an NFA which accepts setof all binary


stringscontaining 1100 or 1010 as
substrings.
Answer: WBUT 2009, 2010, 2016]

9-
5. Draw the transition
diagram of a finite state automaton that
over {0, 1) accepts all strings

a) having odd number of 0's


b) having even number of 0's and even number of 1's.
WBUT 2010]

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.

output we can constuct dfa machine, but it is not

-
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.

7. Convert the following NFA to DFA. WBUT 2010]


Start 01
O1

Answer:
State/e

92
1611 iof

FAT-45
POPULAR PUBLICATIONS

NFA
Q

90-9195 l4.4

l9o-949 l90,4,9] 4,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

above diagram, the transition table will be formed as:


According
Present i/p
state 0

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:

10. a) Give DFA which reads stringsfrom


a,b} and with aaa.
b) Construct a DFA equivalent to
M={{4.4}.{0,1},84,-{4}.8 is given by the
state table.
WBUT 2012]
Statel
g1
91 q0,q1
Answer:
a)

b)

qo, q1

A5Suming q to be the finalstate.

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

12. Define NFA. Construct equivalentDFA from the given NFA.


Next State
Present State
0 1q2
qg0
q1
q0,q1
q2 01
91
q1 q2
WBUT 2014, 2015, 20171
Answer:
Inautomata theory, a non-deterministic
finite automaton (NFA), or non-deterministic
finite state
machine, is a machine
finite state
that (1)does not require input symbols for
state transitions and (2) is capable of transitioning to zero or two or more states for a

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.)

(9o. 919: (91-9)

(49)
DPoP
2
FAT-48
FORMALLANGUAGEAND AUTOMATATHEOK

0.91,92

Construct Finite Automata equivalent to the


13. Regular Expression.
LFabaa+bb)(a+b)*b. wBUT 2014]
Answer:

-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

called the states, is a finite set called the alphabet, 8 Qx -Q


isthe transition
Tunction, q0EQis thestart state, and FEQ is the states.
setof accept

2 part:

Go
16. Construct a minimum state table given below:
automaton fromthe transition
PS X=0 X=l
42
42

2 4

93, 94, 9, are final states.


WBUT 2016]
Answer:
Inthefinite automata,thestates are
4,4.42,4.4.95 Name thissetas
9rign9
S
S,:140 41,4444
All of the states are 0
equivalents.
In the finite automata,there are two types of states; final, state and non-final states. So,
divide the set ofstates into two parts, Q and Q.

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,

they cannot be divided. So in the next step,

S:{{4o {a,,4.3,141,44.}}
S,
and S, are equivalent.

n are the same, there no need of further advancement.


(n-1) and
As is
step step

In minimized automata,the number of states is 3.


the

The minimized finite automata is presented in tabular format asfollows:


Next State

State I/P=0 I/P=1

Dut914, and ,4 do not exist

automata, but they


under the column of present
are subset of the states.
state. They are not
In the next state
of the minimized finite
table becomes
Slates
the subsetsby proper state,themodified
Oumns, by replacing
Next State

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

Basic String largest suffix of


String
Basic Pending Possible basic string
State
C0 possible

A,1
01 B,0 00
D 010 C,1 011

0101 D,0 0100


01011 E,0 01010
F.O
010110
010111
FI
&FAT-53
POPULAR PUBLICATIONS

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.

The minimal machine is therefore


PS NS, Z
X=0X=1
,
B,0
B, 0
B,0
D, 0
0 A,
C.
A, 0
E,0
A, 1
0

2. a) Find a reduced grammar equivalentto the grammar WBUT 2009]


SaAa, A > bBB,B->ab, CaB.
Answer:
Clearly C is a useless symbol. Eliminating C, we get,
SaAa, A bBB, B ab
Now we replace all occurrences ofB on rhs of production using B ab, getting:
Sata, A bab ab
Now we similarly substitute A, getting

which
Sa ba ba ba
is the equivalent reduced grammar.

b) Explain the concept of 2-way finite automata.


WBUT 2009]

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.

3. a) What do you mean by Distinguishableand


Indistinguishable state?

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

for states which are indistinguishable


classes in the original
identifyingequivalent
machine and then assigningone state per class in the reduced machine.

b) Use Nerode Theorem to minimize the following finite automata:


Myhill
0
[WBUT 2011, 2012]

START

FAT-55
POPULAR PUBLICATIONS

Answer

Next we can seethat delta (a,0) b,and delta (d,0)


= g b and (b, g) is marked, so, (a, b)
gets marked too. Similarly we can mark,

the next round we can find that delta (d,1)=g and


In delta (g. 1) e where, (g. e) is

marked. So, (d,N will be marked. Similarly we can mark

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,

4.a)Construct a DFA from the NFA given below:


State/ /P

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

The following arethe states that have been renamed.


[Qo=S
Q Q:]= A
Q Qs. Qd =B
Qo Q4]=C
Q. Qd=D
03=F
Q G
Q=E
b)

-QoC
FAT-57
POPULAR PUBLICATIONS

5. Minimize the following machine


by applying Myhill-Nerodetheorem.
PS NS
A
XB a X =b
E

C
D
H

H H

WBUT 2013]
Answer:

Fig: 1

There is no unreachable state in Fig. 1 so we can directly apply Myhill-Nerode theorem


as follows:

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

Step 1:Now build the matrix labeling the


"p"rows A,B,C.. and labeling the "q"column
A.B. and put the dashes on the diagonal and below the diagonal

ABCDEF G H
B
C
D

F
G

Step 2: Now mark X


H

at (p, q) in upper
-- Fig:

triangle such
2
that P in F (Final states) and q in

Q-F) or (non-final states) as subscript of p


is lower than the subscript of qorp in

(Q-F) and q in F and p is lower than

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

Now mark x in the


given in Fig: 3.

H
matrix

4 BC D
D

Fig: 3
Step 3: Mark 'x' and '0'in the matrix:

First we are considering Q-F


Q-F={4,B,E,H,1}, so ordered pair of

(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

r=O(p.a),s =o(g.a), if (r, s)


is X or x then (p. 9) will bex.
If (,s) is neither X nor x
then (p, q) will be '0'.

for(4,B),r=6(4.a) =B, s=6(B,a) =C


It can be check from matrix in Fig. 3 that (B,C)is xso(A,B) will be x.
for(4,E),r =&(4,a) =B,s =6(E,a)=F
(B,F) is also
x so (A,E) will be x
for (4,H),r =ö(4,H)=B,s =S(H,a) =H
(B,H)is not x but it is x so (4,H) will be x:

for(4,1),r=o(4,a)= B,s =8(1,a)=I


(B,1) is notx but it is
xso (4,1) will be x.
for(B,H).r=6(B,a) =C,s =8(H,a) =H
x so (B,H) will be x.
(C,H) is
for (B,1).r =6(B,a)=C,s =6(1,a)=1
x so (B,1) will be x.
(C,1) is
for(E,H),r =ô(E,a)=F,s =6(H,a) =H
FAT-60TA
FORMALLANGUAGEANDAUTOMATA THEOKI
xso
(F.H)
is
(E,H) will be x.
=F,s =
(F.1)
for (E.1).r=d(E,a)
is so(E,1) will be x.
)=1
6(1,a)=1

for(H,1).r=o{H,a)= H,s =8(1,a)=1


neither X nor x so
(H.1) is (H,1) will be "O".

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

for(D,G),r=8(D,a) =l,s =S(G,a)=H


is also "0"entry.
(D,G)
for (F,G).r=6(F.a) =H,s =6(G,a) =H
(H,H) is dash so (F,G) will be "0"entry
Rest of the entries in upper triangle will be "0". Now fill the "x and "0" in matrix given
in
Fig. 3.
DEFGH x

Fig:
4

FAT-61
POPULAR PUBLICATIONS

The "0"at (B,E) means (B,E) is a state in minimum machine.

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

C,D,F,G}| (H.1 {H.1

So minimized machine is
(H H.
4 M
B,E N
{C,D,F.G) P

6. Find equivalent
--0 {H,1

Fig: 5 Minimized DFA


partitions and minimize thefollowing Finite State Machine

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

Find the equivalent D.F.A without e-transition.


Answer:

State a
Qo {Q1
Q {Q1 Q1. Qal
Q1,101. Q,Qs
Q1. Q2,Q3} {Qi} Q1. Q2 Qs}

So the equivalent D.F.A. is

q1,92,9s

8. Stateand prove Arden's theorem in regular expression. WBUT 20171


OR,
State and prove Erden's Theorem. WBUT 2018]
Answer:
out a regular expression of a Finite Automaton,
In order to find we use Arden's Theorem
alongwith the properties
of regular expressions.
Statement
Let P and Q be two regular expressions.
IfP does not containnull string, then R=Q+RP has a unique solutión that is R= QP*
Proof
R Q+(Q + RP)P [Afterputting the yalue R Q+RP]
=Q+QP +RPP
When we pút the value of R recursively again and again, we getthefollowingequation
R Q+QP +QP +QP..
R Q (e+P+P +P+...)
R QP* [As P* represents (e +P+P2+P3 +....)]
Hence, proved.

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:

Using Arden's theorem


R=Q+ RP, R=QP*
.Here,
4E+g,0+9,0+g,0
4o 401+4,1+4,1
940
4431
E+q40+9,0 +
40901+41+4
9 41+9s11 +9,1
9o 901+9,011+ q,1
9941+4(1+911)
9-41(1+01 1)
=C+4,0+4,0+9
96+9,10+g,0+4
91E+9,010+9,00+4
FAT-65
POPULAR PUBLICATIONS

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:

. NFA over ={0,1

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:

to the equation R=Q+RP is


solution WBUT 2007, 2013, 20171
a) R=QP b) O=RP c) P RO d) R=PQ
AnSwer: (a)

Which of the following sets is regular? [WBUT2007, 2012]


a)a:i=n,
n>=1} b)a:p isaprime
c) ww:w is in
a,b}*} d)an>=1
Answer: (d)

4The value of
L(o*) is WBUT 2007]
a) c){} d) none of these

Answer: (c)

the set of all strings overx, yending


5.The regular expression representing
WBUT 2007, 2012]
with xox
beginning with y is
b) x+y)*x c) x+y)*x d) y(x)x
a)xx(x+y)'
Answer: (d)

. Regular expression (a|b) (al b)

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)

the set of all


over (0, 1) denotes
of
the following regular expressions WBUT 2008]
ngs not containing 100 as a sub-string?
strin
d) 0'(10+1)
a) c)0*1*01
o(10) b) 0°1010
Answer:
(d)

FAT-67
POPULAR PUBLICATIONS

8. Which of the following is


regular? WBUT 2008]
Stringsof 0's, whose length is a perfect square
a)
b) Stringsof all palindromes made
up of 0's & 1's
c) Stringsof 0's, whose
length is a prime number
d) Strings of odd number of zeroes
Answer: (d)

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)

11.Which of the following is correct? [WBUT 2010, 2016]


a) Language can be
derived from the FA
b) Regular expressions can be derived from the FA
c) FA can be derived from the language
d) Both (a) & (b)
Answer: (d)

12. The following production rules of a regular grammar generates a language L


SaS/bSlalb
The regularexpression for Lis
WBUT 2011
a) a+b b)(a+b) c)
(a+b)(a+b) d) (aa +bb)a*b
Answer: (b)

13. The basic limitation of FSM is that


a) it remember arbitrary large amount of information
can't WBUT 2012, 2016]
b) it sometimes recognize grammar that is not
regular
c) it sometimes fails to recognize grammar that is
regular
d) all of these
Answer: (a)

14. What is the RE for the language set


strings with at least one 1, one2 and one
3?
1+2+3 [WBUT 2012]
a)
Answer: (b)
b) 11 22* 33 c) 1 23 dboth (a) and (b)
15. The logic of pumping lemma is a good example1aleviep9
of
a)The pigeon-hole principle [WBUT 2013]
b) the divide and
c) Recursion conquer technique
d) Iteration
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:

ich string is not accepted


Which stri by the following FSA?
17. WBUT 2013]

a) 00111
b) 00110 c) 01010 11010
d)

Answere(a)

sets are closed under


16. Regular WBUT 2014, 2015]
a) Union b) Concatenation
c) Kleene Closure d) All of the above

Answer: (d)

19. Regular grammar


is WBUT 20171
a) context
free grammar b) context sensitive grammar
c) non-contextgrammar d) none of these
Answer: (a)

20. Regular expression is accepted by WBUT 2017]


a) Finite automata b) Mealy machine
c) Pushdown automata d) all of these

Answer: (d)

A Pumping Lemma for Regular Expression


is used to prove that WBUT 2018]
a) Certain sets are Regular
b) Certain sets are not Regular
produce Regular Expression
ertain Regular Grammar Expression
Certain Regular Grammar does not produce Regular
Answer: (6)

Short Answer Type Questions


a
procedure to convert regular
1.Whatis a regular expression? Give a complete convert
exDree Using that procedure
expression into its equivalent NFA WBUT 2003]
NFA.
(10)111)+0]1 into its equivalent
OR,
What is
WBUT 2013]
regular expression?
FAT-69
POPULAR PUBLICATIONS

Answer:
Let

i)=(10)
i)-(+11)
ii) =(+0)
iv) r=rl1
v)=0lr
Corresponding nfa of regular expression r is

Corresponding nfa of regular expression r2 is

In this way the final nfa is

2. State Myhill-Nerode theorem.


WBUT 2005, 2007, 2008, 2010]
State Myhill-Nerode theorem with
OR
the definition and
Invariance. of equivalent relation

Answer: WBUT 2013]

Statement of the Theorem


The Myhill-Nerode Theorem says the
followingthree statements are
equivalent:

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.

nnty and wxy znumber is also


accepted by M. If y consists of only a's or only b's the w2
tnot have the same of a's as b's. If y contains both a's and b's, then w2 Will
b's. In either case
have a's followed w does not belong to L, which is contradiction.
not regular.
Thus Lis

4Prove thatfollowing identity: r(s+t)=rs +rt WBUT 2007]


Answer:
Suppose R, S and T denote the languages for r, s, and t, respectively.

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.

5. Construct a regular grammar G generating the regular set represented by

P=a b(a+b)* WBUT 2007, 2010, 2016]


Answer:
Construct a regular grammar G generally
the regular set represented by

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

Let G={(4, 4).


-moves, we get the

(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

6. Let R be an equivalence relation in


{0 with the followingequivalence classes:

[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

0has less 1's than 2's, thus leading to a contradiction.


W 00.01122 2
Letr

&Show that L =ia|P 1s prime is not regular


WBUT 2009
Answer:
is
L- (a:P Prime}
Let Lbe regular.
Let "adversary"choose
n.
Letz a, where P> n. Clearly lz|>=n.
Let adversary choose a decomposition uvw
satisfying the conditions of pumping lemma.
Letlul p. v=q and wl=r
So we have:
q0
ptqn
ptqtr P
Bypumping lemma, uv'w.is in L. In particular, let us choose i= q and let y uv w.
By pumping lemma, y should be in
L.
Thus yl= p +g q +r
ByFermat's theorem, q=s*P+qforsomeintegers.
Hence:

=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.

3.a) the pumping lemma for regular language.


State [WBUT 2010]
Sing pumping lemma prove that the set L ={01|i 21 is not regular.

Answer:

rormal statement of the Pumping Lemma


Lbe there exists some n such that
Regular Language. Then
a infinite positive integer

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.

Answer: WBUT 2016]


For a Regular R, Kleene closure, denoted
expression by R*, is defined to be the
expression obtained by concatenating zero or more

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.

[WBUT 2011, 2012]


Answer:
Let L be
regular. Let "adversary choos
z = a'b". Obviously, z] >=n
Wechoose
Now,let adversary choose decomposition z=
uvw.such that luv| =
r and vl> 0.
uv consists only of 0-s and v has
We note that whatever be the decomposition, the string
least one 0.
Therefore, for i> 1, uv has more 0-s than hence the
a uv and string uv'w has
ore 0-s at the beginning than there are 1-s at the end, allowing us to conclude that uv'w
not in L. Hence L is not regular. QED.
nole:
Similar logic can be applied to prove the languages

L {a"b n>0, k> n} non-regular.

FAT-75
POPULAR PUBLICATIONS

Suppose L is regular. There exists a finite state automationm which accepts L.


Suppose
M has k states. Let W = a*b. Then wl> k. By the pumping Lemma w xyz where
y is
not empty and w2
xyz is also accepted by M. If y consists ofonly a's or only b's the
will not have the same number of a's as b's.
If y contains both a's and b's, then w
w
will
have a's followed b's. In either case
w does not belong to L, which is contradiction.
Thus L is not regular.

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

L=}a"b" :n>=4,m<=3{ is as follows :Separateinto cases m 0, 1, 2, 3. Generate 4


or more a's, followed by the requisite number of b's.
So, the regular expression for the following languageis
aaaaa ( +b +bb + bbb).

14. Construct the language for the P


grammar G=({S(a,b), S, P), with given
by
SaSb
S1 WBUT 2018]
Answer:
G=(S, a,b}, S, P) with P given by
SaSb,S>1.
SaS >a>b ab
SaSbaaS bb aa>bb > aabb
Sa Sb >aa Sbb-aaa Sbbb >aaabbb
So, the Language is"Equal no. of a's followed by equal no. of b's with Null".
L(G)={a'b"; n20 (Ans.)

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

a) Accepted by some NFA/DFA


b) Described by a regular expression
c) Generated by a Regular (i.e.
Type-3) Grammar.

Find regular expressions over


b Y={a, b} forthe languages defined as follows:
)LI={ab :m>0
i) L2 a"bn20,mn20
i) L3 {b"ab" :m>0,
n> 0 [WBUT 2009, 2010, 2018]
Answer:
i) Not possible since the language is not regular.

i) (aa)*b(bb)*
ii) bb*abb*

c) Find the regular expression for followingtransition graph.


WBUT 2009, 2010]
OR,
Construct the regularexpression
corresponding to the state diagram given below:
WBUT 2013]

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),

(3)and (5)in (1)


5) 5mmst pn
Substituting
We get: 18Ugsi erit otnsisvi

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

nutomata equivalent to the Regular Expression.


L=abaa+bb)(a+b)"b. WBUT 2014

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.

Let w=a. Then w=n>n by pumping lemma we can write


w=xyz with
ay|Sn and

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.

5. Using Pumping lemma prove that


L={a'b" |n21is notregular. WBUT 2017]
Answer:
At first, we assume that L is regular and n is the number of states.
Let w ab. Thus |w=2ii.
By pumping lemma,let w= xyz, where lxyl si.
Let x=a", y=a', and z =a'b, where p
+qtr=n, p0,q#0,r#0. Thus lyl# 0.
Let k 2. Then xy z=a'aa'b'.

Number of a =(p+2q +r)=(ptq+r)+q=ntq


Hence, xyz=a"b. Since q 0, xy is not ofthe form a'b z
z
Thus, xy is not in L. Hence L is not regular.

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)

3.Which of the following productions is in CNF? WBUT 2009]


a) SaA b) SA AS S>AB these
c) d) All of
Answer: (c)

4. Which is more suitablefor an Ambiguous Grammar?


WBUT 2009
ambiguities can be removed
a) All
b) Ambiguity can be removed by setting priority
c) Only inherent ambiguity can be removed
d) There is no suitable rule for removing ambiguity
Answer: (c)

5.The class of CFG is not closed under WBUT 2011]


a) concatenation b) intersection
c) union d) repeated concatenation
Answer: (b)

6. Consider the CFG WBUT 2011]


X>XY
X zX1bXla
YYa Yb/b the CFG
Any string of terminals, which can be generated by
b) ends with a
a) has at least one b
d) has at least 2 a's
c) has no consecutive a's or b's

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

8.A CFG, S>aS/bS/alb, is equivalentto WBUT 2011]


(a+b)(a+b) d) all of these
a) (a+b)' b) (a+b)
(a+b) c)
Answer: (b)

9.(P+-7 WBUT 2012]


a)P+) b) P+ c)(PO) d) both (a) and (c)

Answer: (d)

10. Which of the following production is in CNF? WBUT 2013]


a)
Answer:
SaA b)SA AS c)S AB d) All of these
(c)

11. Consider the following language: L =}a'b'c'a"|n21

Lis WBUT 2013]


a) CFL but not regular b) CSL but not CFL
Regular
c) d) Type 0 language but not type 1

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)

14.Consider the languages:

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)

17, Which of the


following is most
a) Regular general phase structured
grammar?
c) PDA b) Context sensitive WBUT 2016
d) none of these
Answer:(b)

8.CFLType
is
a) 0 language.
WBUT 2018]
b) Type 1
2
c) Type d) Type 3
Answer: (c)

ShortAnswer Type 9uestions


1. Convert the following context free
grammar into an equivalent CNF:
SaAbB grammar in

A abAB/aAAla WBUT 2006, 2007, 2010]


BbBaAlaBB/b
Answer:
Let us assume that a and b may be represented as C and D
respectively.
So, the
products areas follows-
SCABD
A-CDAB|CAAJa
B DBCACBB|b
Ca
D--b

Let us asume that AA be E, BB be F, CA be G and DB be H. So the productions are:


SGH
A-GH
B--GH
Ca
D-b
EAA
F-BB
G-CA

FAT-83
POPULAR PUBLICATIONS

H BD

What do you mean by a sub-treeof a derivation tree? [WBUT 2008]


2. a)
Answer: node of the
for any
A subtree of a derivation tree a partial derivation tree such that,
is

of its children are also in the subtree, or


none of them are.
subtree, either all

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).

3. Reduce the following grammars to WBUT 2008]


GNF
SA0,A0B,B0A, B1
Answer:
As is already
it in GNF form, so there is no requirement for converting it into GNE.

4. Write the CFG forthe language WBUT 2008, 2012]

L={0'12"|li=j orj=k).
Answer:
SABB
A 0A|0
B1B212
5. Let G be a gramm WBUT 2009, 2010]

s0B|14,A0 0S| 1A4, B 11s 0BB


For the string 00110101, find

i) leftmostderivation
ii) rightmost
derivation

ii) derivation tree


OR,
ConVert the following Context-freegrammar into an equivalentgrammar in CNF
S14/0B
A>1AAI0S/0
B-0BB/1S/1 [WBUT 2011]
Answer:
i) S0B 00BB 00180011S00110B 001101S
0011010B00110101
FAT-84
FORMALILANGUAGEA AND AUTOMATA THEORY
it) S08 00BB
00B1S00B10B
00B1010B>00B10101 00110101 00B101S

il)

6. Let G be the grammar


SaB/ba, A >alaS/bAA, WBUT 2011]
B->blbSlaBB
Forthe string aaabbabbba, find
a) leftmost derivation
b) rightmost derivation
c) parse tree.
Answer:
a) SaB aaBB
aaaBBBaaabBBaaabbSB
aaabbaBB>aaabbabB => aaabbabbS= aaabbabbba

b) SaB aaBB aaBbS


aaBbba aaaBBbba
aaaBb Sbba aaaBbaBbba =>
aaaBbabbbà aaabbabbba

FAT-85
POPULARPUBLICATIONS

c)

7.What is Griebach Normal Form (GNF)forContext Free grammar?


Convert the following grammar into GNF WBUT 2011, 2012, 2016]
SABbla
A>aaA/B
B->bAb
Answer:
A Context Free Grammar is said to be in Greibach Normal Form if each rule in the

grammar has one of the following forms:


1.Aad4,4
2. A a
where, AA EVyi=1,2. andae
If
e
symbol) is
belongs
also
to
the language
of
thegrammar, the rule Ae (where S is the start

permitted.

Greibach's Theorem: Every Context Free Language can be


gener- ated by a Context
Free Grammar which is in GreibachNormal Form GNF.
The above theorem implies that givena grammar G (which
generatesthe language L(G),
the grammar can be converted to an
equivalent grammar G' which is in GNF such that

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

8, Find a GNF grammarequivalent to the


44,4 following CFG: WBUT 2012
44,4|b
444a
Answer:
Given:

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

9. Find the Context Free Grammarforthe following language L={a'b"c":n,m>=0

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

11. Convert the following grammar into GNF.


SAAla
A SS/b
WBUT 2014, 20171

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

13. Let G bethe grammar


For the string aaabbabbba find:
i)

i)
left most derivation

rightmost derivation
SaB | ||
ba, B b bS aBB. WBUT 2016]

ii) parse tree


Answer:
i)SaB aaBBaaaBBB aaabbBaaabbaBB- aaabbabBaaabbabbS
aaabbabbba
i)SaB aaBB aaBbS=>aaBbba aaaBBbba
aaaBbSbba aaaBba Bbba aaa Bbabbba aaabbabbba

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

productions are redundantand hence should be removed.


Repeat the following steps while there is a unit production
1. Select a unit production AB, such that there exist a production B >a,where
a is a terminal

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

Linear Grammar. Example: AaA|bB|b

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

T= {a,b}; T is a set of terminal symbols


S, Starting Symbol (S)
P Production rules for terminals and non-terminals-S aA|bS, A> aC|bB,
BaS|bC, C6
from the following grammar: WBUT 2018]
17. Remove the UNIT productions
SAalB
BA|bb
Aalbc| B
Answer
Remove unit production,

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.

SaB lbA WBUT 2006, 2009]


A a/aS/bAA
Bb/bS/ aBB
Find eft
left mostderivation forthe
string aaabbabbba.
a) leftmost
derivation
b) rightmost derivation
tree.
c) parse
Answer:
Let us number
the rules

(1) S aß
(2) SbA
3) A >a
> aS

.
(4) A
AbAA
(6)

(6)

(7)
B
B bS
b
(8) B aBB

a) The left-most derivation (With labeled with rule number) is:

SaBaa BB B BBaaabBB
aaa b bSB5 aaa b b aBB
aaa

6 aaa bb a bBB

aaa bb a bb S aaa bb a bbb Aaaa bb a bbba


b) Saß aaBB Bbba aaaB Bbba
aaBbS>aa
aaaBbSbba>aaaBba Bbba aaaBbabbba= aaabbabbba

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

to the languages of both the


converted to GNE since belongs 6
productions
grammars. However, we continue
and adding it to the by ignoring the S>8
converted grammar.
i) The converted grammar in GNF is

SaSA
SaSB
SE
Aa
Bb
i) The given grammar

b) Find a reduced
is incomplete sincethere

grammar equivalent to the grammar


are
,
NO B productions given.

[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

4. a) Construct CFG for the following: WBUT 2013, 2016]


i) Palindrome for binary numbers

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"

Let ={0,1} and suppose regular.


Lpowere
Let n be given by the pumping lemma. Then 0'10" eL In reading 0" the FA must
make a loop. Omit the loop; contradiction.

Let's define Lpat inductively:

Basis: 6,0, and 1 are palindromes.


Induction:If w isa palindrome,so are 0w0 and Iwl.
Circumscription: Nothing else is a palindrome.
CFG's is
aformal mechanism fordefinitions such as the onefor Lpa
1.

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)

i) A CFL L is inherently ambiguous if all grammars for L areambiguous.


Example: Consider,L ={a'b'c"d" :n21,m21{a"b"c"d":n21,m21
A grammar for L is

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.

i) CFG for the following is


given below:

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.

Answer: WBUT 2014, 2017]


Consider the two languages

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy