9 votes 9 votes Give a context-free grammar $G$ that generates $L = \{0^i1^j0^k \mid i + k = j\}$. Prove that $L = L(G)$. Theory of Computation descriptive isi2013-pcb-cs context-free-grammar theory-of-computation + – go_editor asked Jun 1, 2016 • edited Feb 20, 2018 by kenzou go_editor 924 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 15 votes 15 votes $L=\{0^i1^j0^k\mid j=i+k,i,j,k\geq 0\} =\{\epsilon,0110,011100,001110,\ldots\}$ Now, $L=\{0^i1^{i+k}0^k\mid i,k\geq 0\}$ Here, CFG will be: $S \rightarrow S_1S_2$ $S_1 \rightarrow 0S_11\mid\epsilon$ $S_2 \rightarrow 1S_20\mid\epsilon$ srestha answered Jun 1, 2016 • edited Jun 15, 2018 by Milicevic3306 srestha comment Share Follow See all 3 Comments See all 3 3 Comments reply shekhar chauhan commented Jun 18, 2016 reply Follow Share why did you consider this condition in question i ,j ,k >=0 .it is not given anywhere . you could have considered i ,j ,k >=1 also. 1 votes 1 votes shekhar chauhan commented Jun 18, 2016 reply Follow Share L={0^i 1^i+k 0^k | i,k≥0} and please explain how did you get this from strings 0 votes 0 votes Aboveallplayer commented Aug 1, 2016 reply Follow Share @sekhar turn the grammar to an easier one 0i1j0k and j=i+k now 0i1i+k1k can be written as 0i1i1k0k then proceed 5 votes 5 votes Please log in or register to add a comment.