Smallest strings possible are:
all of which have
where gives the number of a’s in string and gives the number of b’s in string . Assume holds. Show if is true is also true, where is string with substring inserted. Subsequent insertions of S1 into strings produced, either add zero a’s and zero b’s or two a’s and one b .
,generating the language of strings with twice as many.
Thecontext free grammar is,
The generated language is proved correct using induction.
Case when zero a’s and zero b’s are inserted.
Case when two a’s and one b are inserted.
Therefore, all strings generated using the grammar contain twice as many a’s as b’s.