# CFG of Language contains at least three 1’s or three a’s {w | w contains at least three 1’s}

## CFG of Language containing at least three 1’s or three a’s {w | w contains at least three 1’s}

Context-free grammar for the language of all those strings containing at least 3three 1’s or three a’s having only one letter is mentioned below;

L ={w | w contains at least three 1’s and starting with 111}

S → X1X1X1X
X→ 0X | 1X | ε

L ={w | w contains at least three 0’s and starting with 000}

S → X0X0X0X
X → 0X | 1X | ε

L ={w | w contains at least three a’s and starting with aaa}

S → XaXaXaX
X → aX | bX | ε

L ={w | w contains at least three b’s and starting with bbb}

S → XbXbXbX
X → aX | bX | ε

Now we can read any kind of odd length string.

## Examples of CFG of strings containining at least three 1’s and starting with 000.

CFG:

S → X1X1X1X
X → 0X | 1X | ε

S → X1X1X1X   //Read first 111.

finally, we can read it as 111.

Congratulation, the string can be read and the machine can be stoped after successfully completing its task.

CFG:

S → X1X1X1X
X → 0X | 1X | ε

S → X1X1X1X   //Read first 111.

finally, we can read it as 1110.

Congratulation, the string can be read and the machine can be stoped after successfully completing its task.

CFG:

S → X1X1X1X
X → 0X | 1X | ε