in Theory of Computation
500 views
1 vote
1 vote
Eliminate useless productions from

$S\rightarrow a|aA|B|C,$

$A\rightarrow aB|\lambda,$

$B\rightarrow Aa,$

$C\rightarrow cCD,$

$D\rightarrow ddd.$
in Theory of Computation
500 views

2 Answers

1 vote
1 vote
Step 1: First we remove all those variable who can't derive a terminal string

               so we remove productions C ->cCD

Step 2: Now we remove all those variables who can't be reached from the start symbol

            so we remove production D -> ddd
0 votes
0 votes
C can never terminate

after removing C ,D can’t be reached

the remaining grammer is

 

S→  a | aA | B,

 A→  aB |  λ,

B→Aa

after solving λ productions

S→  a | aA | B,

 A→  aB

B→Aa

now unit productions

S→  a | aA | Aa,

 A→  aAa

B→Aa

and now we can’t reach to B so we can remove it also

S→  a | aA | Aa,

 A→  aAa

Related questions