Académique Documents
Professionnel Documents
Culture Documents
0
Converting to Moore machine
1. There are 2 incoming transitions to q0
- q0 to q0 on input 1 with output n
- q2 to q0 on input 1 with output n q₁ / n
Since output is same, no need to split 1
0
2. There are 3 incoming transitions to q1
- q0 to q0 on input 0 with output n
- q1 to q1 on input 0 with output n q₀ / n
0 1
- q2 to q1 on input 0 with output n
Since output is same, no need to split
3. There is 1 incoming transition to q2 1
- q1 to q2 on input 1 with output y
No need to split q₂ / y
Grammar in GNF
S → 0CEBAA | 1CDBAA | 0BAA | 0AA
A → 0AD | 0
B → 0BD | 0
C → 0CE | 1CD | ε
D→0
E→1
1, E; ε
0, D; ε
ε, C; ε
1, C; CD
0, C; CE
0, B; ε
0, B; BD
0, A; ε
0, A, AD
0, S; AA
0, S; BAA
1, S; CDBAA
c Construct right linear grammar and left linear grammar for the regular 5M
expression 1(01)*0(0+1)*
Eliminating q1
a
a.b*.a
q₀ q₂
b.b*.b
a.b b.a
No more elimination possible.
The R.E. is
((a + ab) + ab*a . (ba)* . bb*b)* . ab*a . (ba + bb*b . (a + ab)* . ab*a)*
2 20
marks
i) RE
1*0(1+01*0)*
1 1 0
0
0
0
q₁
q₀ q₁
q₀ 1 1 q₂
0
1
ii) RE
(0 + 10*10*1)*
0
0 0
0 0
q₁ 10*1
q₀ 1 1 q₂ q₀ q₂
1
1
b Construct DFA for following NFA with ε-moves 10 M
ε-closure
State ε-closure
q0 {q0, q1}
q1 {q1}
q2 {q2, q3}
q3 {q3}
1
0 q₁
1
q₀ q₃
1 0, 1
1
q₂ 1
Q₁ Q₃ 1
1
0
0
Q₆ 0
0
Q₀
1 1 Q₇
1
Q₂ Q₄
0 1
1 0
Q₅
c Construct NFA with ε-moves for the regular expression ab*(a+b)* + ba* 6M
b a, b
q₁ q₂
ε
a
q₀
b q₃
OR
a
q₄ q₅
b
ε ε
ε ε
q₁ q₂ q₈
a
ε ε
q₀ q₆ q₇
b
b q₃
3 20
marks
Eliminating A → B
A → aA | aB | a
S→A|B|C
Eliminating S → A
S → aA | aB | a
Eliminating S → B
S → bB | b | ε
Eliminating S → C
S → cB | cC | c | ε
S → XA | XB | a |
YB | b |
ZB | ZC | c |
ε
A → XA | XB | a
B → YB | b | ε
C → ZB | ZC | c
X→a
Y→b
Z→c
Consider V0A0
We have the following transitions where A is on top of the stack
(c, A; ε), (a, A; AA), (b, A, BA)
So we get,
V0A0 → c | aV0A0V0A0 | bV0B0V0A0
Consider V0B0
We have the following transitions where B is on top of the stack
(d, B; ε), (b, B; BB), (a, B; AB)
So we get,
V0B0 → d | bV0B0V0B0 | aV0A0V0B0
Consider V0Z1
We have the following transitions where Z is on top of the stack
(b, Z; BZ), (a, Z; AZ), (ε, Z; ε)
So we get,
V0Z1 → bV0B0V0Z1 | aV0A0V0Z1 | ε
4 20
marks
b Design a DFA over {0, 1} which accepts all strings that contain substring ‘11’ 6M
and do not contain the substring ‘00’.
c Give the CFG for the following languages 4M
i) 0n 1n+p+k 0k
S → XYZ
X → 0X1 | ε
Y → 1Y | 1
Z → 1Z0 | ε
ii) S → aaSd | A
A → bbbAc | ε
5 20
marks
b Find the equivalent NFA with ε-moves accepting the regular language defined 5M
by the following grammar
S → 01S | 0A A → 10 | 1B | 00A B → 1S | 1B | ε
OR
Leftmost derivation
S => ABA
=> aABA ; A → aA
=> abABA ; A → bA
=> abaABA ; A → aA
=> ababABA ; A → bA
=> ababBA ;A→ε
=> ababbbbA ; B → bbb
=> ababbbbaA ; A → aA
=> ababbbba ;A→ε
Rightmost derivation
S => ABA
=> ABaA ; A → aA
=> ABa ;A→ε
=> Abbba ; B → bbb
=> aAbbba ; A → aA
=> abAbbba ; A → bA
=> abaAbbba ; A → aA
=> ababAbbba ; A → bA
=> ababbbba ;A→ε
6 20
marks
a Minimize the following DFA M = ({q0, q1, q2, q3, q4, q5}, {0,1}, δ, q0, {q3, q5}), 6M
where δ is given in the following table.
The DFA is
q1 on 0
q2 on 0 ?
q3 fnf fnf fnf
q4 on 0 ? ? fnf
q5 fnf fnf fnf ? fnf
States q0 q1 q2 q3 q4
c What do you understand by closure property? State the various set theoretic 4M
operations under which regular languages are closed. Give suitable example.
Closure properties
Regular languages remain regular when set-theoretic operations are
performed on them. We call such behaviours closure properties since any
number of such operations keep the result still within the class of regular
languages.
The various set-theoretic operations under which regular languages are closed
are as follows:
1. Union of Regular Languages
Set of binary number divisible by 4 is a regular language.
Set of binary number divisible by 6 is a regular language.
Their union, set of binary number divisible by 4 and 6 is also a regular
language.