Language $A$ can also be represented as, $$A = \{ uvw \mid u,w \in \Sigma^*\text{ and, }v \in \Sigma^* 1 \Sigma^*\text{ and, }|u| = |w| \ge |v| \}$$
Language $B$ can also be represented as, $$B = \{ uvw \mid u,w \in \Sigma^*\text{ and, }v \in \Sigma^* 1 \Sigma^* 1 \Sigma^*\text{ and, }|u| = |w| \ge |v| \}$$
I have to prove that $A$ is CFL & $B$ is not a CFL.
To prove $A$ is CFL, I have to show that a CFG can be made.
I made a CFG for this equation:
$$L = \{ uv \mid u \in \Sigma^*\text{ and, }v \in \Sigma^* 1 \Sigma^*\text{ and, }|u| \ge |v| \}$$
which is,
$$ S \to XSX \mid T1 $$
$$ T \to XT \mid X $$
$$ X \to 0 \mid 1 $$
But I am not able to make a perfect CFG for $A$ after much trying although they seem both same ..
Can I prove $B$ is not a CFL maybe by using pumping lemma ?
Best Answer
18 April 2022: The answer given for $A$ was absurd, and I’ve deleted it.
9 May 2022: I’ve now added a correct answer in the blockquote below.
To show that $B$ is not context-free, use the pumping lemma with the word $s=0^{p+2}10^p10^{p+2}$, where $p$ is the pumping length. You’ll have $s=uvwxy$, where $|vwx|\le p$, $|vx|\ge 1$, and $uv^kwx^ky\in B$ for all $k\ge 0$, and you’ll have to consider several cases according to the possible decompositions of $s$. Note that since $|vwx|\le p$, at most two of the strings of $0$s can be pumped.