CFG for $\{a^i b^j : 2 i<j\}$ [duplicate]
-
16-10-2019 - |
Pergunta
This question already has an answer here:
So I have a question:
Give a CFG for $\{a^i b^j : 2 i<j\}$
And this is my approach:
$S\to AB$
$A\to aAb\mid \varepsilon$
$B\to b \mid bB$
A confirmation, or correction, along with how you tested(and tips for testing future of my problems) will be greatly appreciated thanks.
Solução
You can derive $aabbb$ which is not in the language, so your grammar is wrong.
How did I find this? I observed that $A \Rightarrow^* a^ib^i$ and $B \Rightarrow^* b^j$ for all $i \geq 0$, $j > 0$. It's clear that this is wrong, and I looked for the smallest counter-example.
You need to ensure that more than double as many $b$'s as $a$'s are generated.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a cs.stackexchange