I need to find the production rules for the following language:
$L = \{u \in \{a, b\}^* \mid |u|_a = |u|_b\}$
Well, the first thing I could come up with is
$S \to aSb | \epsilon$
But this only covers the situation where all symbols $a$ precede $b$.So I tried to add all rules containing only one symbol of $a$, $b$, and one non-terminal symbol on the right-side:
$S \to aSb|bSa|abS|baS|Sab|Sba|\epsilon$
Do you think this would work?
I used this website CFG Developer and entered my productions, and for the string "bbbbaaaaabababbabababbaa" the output is false, meaning that the string cannot be produced by the mentioned rules.
Does anyone know where the mistake is?