What is the context-free grammar for $0^{n}1^{2n+1}0^{n}$

426 Views Asked by At

context free grammar for $0^{n}1^{2n+1}0^{n}$

I've tried several different methods to find it but I can't figure out how to make both sides opposite to each other...please help I've been working on this for hours.

1

There are 1 best solutions below

6
On

You should try to prove that this language is not a CFG using the pumping lemma.

Proof sketch

The pumping lemma states that $\exists$ p such that all strings s : |s| > p contain "pumpable" constituents so that s = uvwxy so that
1) |vwx| $\le $ p
2) |vx| $\ge$ 1
3) uv$^k$wx$^k$y is a valid string in the language for all k
Consider the string s = $0^p 1^p 1 1^p 0^p$. Clearly |s| > p and s is in the language
Claim 1: The string vx must have equal number of 0 and 1, and neither u nor y should contain p zeros. otherwise 3) would be violated
Claim 2: If vx contain equal number of 0 and 1 in total then its impossible that |vwx| $\le$ p

Claim 1 and Claim 2 prove that its impossible to find "pumpable" uvwxy for string s which has length greater than p. which violates the pumping lemma.