Wednesday 28 August 2013

If G=({ S}, {0,1}, { S → OS1, S → ^}, S) then find L(G), the language generated by G.

Solution: Since S  ^ is a production, S  ^.  This implies that ^  L(G).
Now, for all n  1, we can write the following:
 0S1  00S11 …   0nS1n  0n1n.
Therefore, 0n1n   L(G). 
In the above derivation, at every step, S  0S1 is applied, except in the last step where S  ^ is applied.  
Therefore, {0n1n  n ≥ 0}  L(G).
Now suppose w  L(G).  So we should start the derivation of w with S.
If we are applying S  ^ first, then we will get w = ^.
Otherwise, the first production that we need to apply is S  0S1. 
However, at any stage we can apply S → ^ to obtain the terminating string.  Therefore w can be derived in the following form.
S  0nS1n � 0n1n, for some n ≥ 1, That is L(G)  {0n1n | n ≥ 0}.
Hence L(G) = {0n1  n ≥ 0}.

No comments:

Post a Comment