I have homework which is about CFGs, their simplification, and their normalized forms. I have also seen some examples on the internet, but unfortunately, I could not solve the below question.
All the binary numbers, in which the $i$th character is equal to the character which is located in $i + 2$ th position, and the length of these strings is at least $2$.
My problem is with positions, and how to show them using our grammar. My idea was to have $S$ as our initial state, and then have a production like this:
$S\Rightarrow A|B$
And then $A$ be for all the strings which start by $0$, and $B$ be for all the strings which start by $1$. But I will be really grateful for your help.
We can divide this language into 4 groups, and then use a union between them. The first 2 bits can be 00, 01, 10, or 11. So we need 4 states besides the initial state.
$S \Rightarrow 00A|01B|10C|11D$
And then we add 4 productions:
$A \Rightarrow 0A|ɛ$
$B \Rightarrow 01B|0|ɛ$
$C \Rightarrow 10C|1|ɛ$
$D \Rightarrow 1D|ɛ$