FOR FREE CONTENT

Identify the language from the given grammar

 

Example 3Construct the language generated from the given grammar

G = ({S, A}, {a, b}, {S}, {P})

 P:   S → Ab            

       A → aAb | λ   

      

Solutions:

P:    S → Ab

       A → aAb | λ   an bn | n ≥ 0      [For details see example 1]   

 

From production A → aAb | λ, we will get an bn | n ≥ 0

Then,

A → an bn | n ≥ 0

S → an bn b | n ≥ 0 [We replace A by an bn | n ≥ 0 at production S → Ab]

S → an bn+1  | n ≥ 0

 

 

Follow the next examples:

  1. Example 1:  S→aSb|λ
  2. Example 2: S→aSb|ab
  3. Example 4: S→aS|λ
  4. Example 5: S→aS|bS|λ