493 views
1 votes
1 votes
S →  AB/a

A → BC/b

B → aB/C

C → aC/B


How do we remove useless symbols and productions from this grammar?

While solving, i found that the useful symbols are {a,b,S,A}

Hence, we must delete B,C

But don’t know how to proceed

2 Answers

1 votes
1 votes

Every variable should derive some terminal strings and every variable should be reachable from Start symbol, then the symbol is Useful.

Useful: {a,b,S,A}

Useless: {B,C}

Now delete B and C on LHS wherever B,C exist.

S → a

A → b

 Now we can’t reach to A from S, so delete A also.

S → a is the answer

 

0 votes
0 votes
w(s)= {s}, W(s)= {S}

W(A)= {A}, W(A)= {A}

W(B)= {B}, W(B)= {B,C}

W(C)= {C}, W(C)= {C,B}

Therefor the reduced grammar is:

P’ = {S—> AB, S→ a, A→ BC, A→ b, B→ aB, B→ ac, C→ aC, C→aB}

Related questions

1 votes
1 votes
1 answer
1
shikharV asked Nov 29, 2015
433 views
The given answer to the problem is 1 ('a'). But I think that strings 'a+a' & 'a*a' can also be derived from the grammar. Please correct me if I am wrong.
2 votes
2 votes
3 answers
2
2 votes
2 votes
1 answer
3
shekhar chauhan asked Jun 4, 2016
666 views
A >AA+/AA*/ais it eligible to be used by SR parse.If we apply SR parse on this grammar then what will be the order of activation Record in Stack
10 votes
10 votes
2 answers
4
ShiveshRoy asked May 8, 2016
9,103 views
$\textbf{Eliminating indirect left-recursion}$Indirect left-recursion$S\rightarrow Aa|b$$A\rightarrow Ac| Sd |\in$