FOR FREE CONTENT

IDENTIFY LANGUAGE FROM GRAMMAR

 

Example 4Construct the language generated from the given grammar

G1 = ({S}, {a}, {S}, {P})

P:  S → aS | λ

 

Solutions:

There are two productions S → aS and S → λ combines to gather in the given grammar.

 

For S → λ (We can get only empty string λ)

 

 

[∴ ω . λ = ω . λ = ω.]  

Every time we use the production S → λ to get the string like a, aa, aaa, aaaa..

So, which type of string we can get from this grammar L(G1) = {λ, a, aa, aaa, aaaa…..}

i.e. Any string generated by only ‘a’ including a0 = λ. 

 

Here L(G1) = {an | n  0} = {λ, a, a2, a3, a4 ....}  = a* (set of all string generated by ‘a’ including λ. )

 

This grammar G = ({S}, {a,b}, {S}, {P})  , P: S → aS | λ for  a*

 

If we slightly change the production, we can get the grammar of a+= {a, a2, a3, a4 ....}

G2 = ({S}, {a}, {S}, {P})

P:  S → aS | a from this production it is clear that we never get λ i.e. language does not contain any λ.

 

i.e. (set of all strings generated by ‘a’ excluding λ) 

Here,

 

(set of all strings generated by ‘a’ excluding λ)

This grammar G = ({S}, {a, b}, {S}, {P}), P:  S → aS | ab for a+