Professional Documents
Culture Documents
Those symbols that do not participate in derivation of any string are called
useless symbols.
Ex.5
Ex. 2 A -> xyz / Xyzz
G=({S,A,B,C},{a,b,d},P,{S}) X -> Xz / xYz
S -> aaB |aaS Y -> yYy / Xz
B -> ab|b Z -> Zy / z
•Unit Production
S → XY, X → a, Y → Z | b, Z → M, M → N, N → a
S->AB,
B->a|b
A->a
•Null Production
Ex.1 S → ASA | aB | b, A → B, B → b | ∈
Ex.2
S → ABAC, A → aA/∈, B → bB | ∈, C->c
S->ABAC
Removing A → ∈ from the given grammar
S->ABAC|BAC|ABC|BC
A->aA|a
B->bB| ∈
C->c
Removing B-> ∈ from the grammar
S->ABAC|BAC|ABC|BC|AAC|AC|C
A->aA|a
B->bB|b
C->c
Removing Unit production S->C
S->ABAC|BAC|ABC|BC|AAC|AC|c
A->aA|a
B->bB|b
C->c
CNF
CHOMSKY NORMAL FORM(CNF): A CFG is in Chomsky Normal Form if the
Productions are in the following forms −
• A → a (Non-terminal -> one terminal)
• A → BC ( Non-terminas -> string of exactly two non-terminals)
where A, B, and C are non-terminals(N) and a is terminal(T).
Step 1 − If the start symbol S occurs on some right side, create a new start
symbol S’ and a new production S’→ S.
Step 2 − Remove Null productions.
Step 3 − Remove unit productions.
Step 4 − Replace each production A → B1…Bn where n > 2 with A → B1C where C
→ B2…Bn. Repeat this step for all productions having two or more symbols in the
right side.
Step 5 − If the right side of any production is in the form A → aB where a is a
terminal and A, B are non-terminal, then the production is replaced by A →
XB and X → a. Repeat this step for every production which is in the form A → aB.
Ex.: Change the following grammar in CNF: S->1A/0B, A->1AA/0S/0, B->0BB/1
Type-1 - CSG
Type-2 - CFG
Type-3 - RG