$B$ - set of palindroms such that number of $1s$ is equal to number of $0s$. Every palindrom $\in \{0,1\}^*$
And my task let me that $B$ is not CFG. But I don't agree with it.
Because of the fact that $\#_0(w)=\#_1(w)$ I conlude that $B$ is set of palindroms such that their length is even, so:
$B=\{ww^r|w\in \{0,1\}^*\}$
A show CFG for this language $B$:
$S\rightarrow 1S1|0S0|\epsilon$
What's up my dear friends ?
2026-03-26 22:16:11.1774563371
On
prove that set of palindroms such that $\#_0(w)=\#_1(w)$ is not CFG
947 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
2
On
The context free grammar you're given does not correspond to the definition of $B$ because $11$ is generated by grammar but it's not an element of $B$. Actually the definition meant by the question is : $$B=\{ww^r|w\in \{0,1\}^*,|w|_1=|w|_0\}$$ which is more complicated but can be done using the pumping Lemma, the idea behind the proof:
We choose a palindrome with $2p$ $1$’s and $2p$ $0$’s such that the $1$’s are all at the middle. We pump it by deleting the repeated strings. Because there are so many $1$s, the deleted strings cannot have $0$s from both side, so they either take $0$s from one side and leave the string asymmetric or take only $1$s and leave the string with an unequal amount of $0$s and $1$s.
Hint:
I hope thos helps $\ddot\smile$