628 views
1 votes
1 votes
S->AB | €,

A->aB,

B->Sb.

Give a verbal description of the language generated by this grammar.

2 Answers

Best answer
3 votes
3 votes

Given grammar :

         S  -->  A B  |  ϵ                                                                                                                                                                      A  -->  a B                                                                                                                                                                            B  -->  S b

Substituting B in A production and in S production ,we have :

         S  -->  aSbSb  |  ϵ                                                                                                                                                              

which is the production of our interest as far as generation of strings is concerned as A does not produce any strings on its own as there is no terminating production in A..

So considering  :      S  -->  aSbSb  |  ϵ    

After epsilon , minimal string generated   :   abb

Now we have 2 S's in the RHS of production , so we can substitute any of the 2 S's with epsilon or abb..So say first S is substituted with epsilon and second one with "abb" , we get the string generated : ababbb

If we do substitution other way , we get :  aabbbb

So we can see that it need not be the case that all a's followed by b's which is twice the number of a's..But this is for sure that the number of b's is twice the number of a's..

Bt in that also strings like : abbbba  , abbabb etc are not covered ..

Hence the description of the language that L = {an b2n | n >= 0} or L = {strings belonging to Σ* | number of b's = twice the number of a's}  is not true..

All we can say is the language being generated is a proper subset of  L = {strings belonging to Σ* such that number of b's = twice the number of a's} . 

selected by
1 votes
1 votes
This grammar can be simplified as:

S→aBB|λ

B→Sb

or even more simply, as

S→aSbSb|λ

This grammar produces the strings of the form $a^{n}b^{2n}$ , n ≥ 0,

i.e., it generates the language L(G) = {$a^{n}b^{2n}$ : n ≥ 0}

Using the simplified version, we can see that we always generate twice as many b’s as a’s.But it is in a limited form.

Each a has two matching b’s to its right.

Simply stated it is the set of strings over a and b such that each a has two matching b’s to its right.
edited by

Related questions

0 votes
0 votes
1 answer
1
pallaviamu asked Apr 22, 2018
395 views
Find L1/L2 forL1= L(a*baa*)L2= L(ab*)how come L(Mo) intersection L2= phi??
0 votes
0 votes
1 answer
2
Shubham Pande asked Jul 1, 2017
349 views
Is it true that for any nfa M = (Q,Σ,δ,q 0 ,F) the complement of L(M)is equal to the set {w ∈ Σ * : δ *(q 0 ,w) F= Ø}?
1 votes
1 votes
2 answers
3
Soumya29 asked Sep 18, 2018
972 views
Q- Prove or Disprove the following claim- $(L^R)^*=(L^*)^R$for all languages.
1 votes
1 votes
0 answers
4