Professional Documents
Culture Documents
1
CONSTRUCTION OF A REGULAR GRAMMAR
GENERATING T(M) FOR A GIVEN DFA M
2
3
4
5
BASIC DEFINITIONS AND EXAMPLE of GRAMMAR
6
7
8
Find the Derivation of below Grammar
9
10
11
12
13
14
15
16
17
AMBIGUITY IN CONTEXT-FREE GRAMMARS
18
19
20
Problem-02
21
22
23
24
Construction of Reduced Grammar
25
26
27
28
29
30
31
Example-02
32
33
34
ELIMINATION OF NULL PRODUCTIONS
35
ELIMINATION OF UNIT PRODUCTIONS
36
Chomsky's Normal Form (CNF)
G1 = {S → AB, S → c, A → a, B → b} is in CNF
G2 = {S → aA, A → a, B → c} is not in CNF
37
Convert the given CFG to CNF. Consider the given
grammar G1:
S → a | aA | B
A → aBB | ε
B → Aa | b
38
Solution
Step-01: As grammar G1 contains A → ε null production, its
removal from the grammar yields:
S → a | aA | B
A → aBB
B → Aa | b | a
39
Step-2: Now, as grammar G1 contains Unit production S → B,
its removal yield:
S → a | aA | Aa | b
A → aBB
B → Aa | b | a
40
Step-03: In the production rule S → aA | Aa, A → aBB and B →
Aa, terminal a exists on RHS with non-terminals. So we will
replace terminal a with X:
S → a | XA | AX | b
A → XBB
B → AX | b | a
X→a
41
Step-04: In the production rule A → XBB, RHS has more than
two symbols, removing it from grammar yield:
S → a | XA | AX | b
A → RB
B → AX | b | a
X→a
R → XB
42
Example-02
43
44
Push Down Automata
45
tape
tape head
stack head
finite
stack
control
a l p h a b e t
53
Example: PDA Cont…
The transitions:
δ(q0, a, Z0) = (q0, aZ0).
δ(q0, a, a) = (q0, aa).
δ(q , b, a) = (q , ε).
0 1
δ(q , b, a) = (q , ε).
1 1
54
Actions of the Example PDA
aaabbbε
q0
Z0
55
Actions of the Example PDA
aabbbε
q0
a
Z0
56
Actions of the Example PDA
abbbε
q0
a
a
Z0
57
Actions of the Example PDA
bbbε
q0
a
a
a
Z0
58
Actions of the Example PDA
bbε
q1
a
a
Z0
59
Actions of the Example PDA
bε
q1
a
Z0
60
Actions of the Example PDA
ε
q1
Z0
61
Actions of the Example PDA
qf
Z0
62
State Machine of PDA
63
PDA for Odd Palindrome
64
PDA for Even Palindrome
65
CFG to PDA (If not in GNF)
66
CFG to PDA (If in GNF)
67
68
69
70
71
72
73
Closure Properties of CFL
• Union
• Concatenation
• Kleene Star operation
74
Union
75
Concatenation
76
Kleene Star
77