# Write the Context free Grammar

What will be the context-free grammar of $$B= A_1.A_2$$ when $$A_1 = \{0^n1^n|n\geq 0\}$$ $$A_2 = \{1^n0^n|n \geq 0\}$$ Also verify using a string.

if the Grammar for $$A_1$$: $$S_1 \rightarrow 0S_11 | \varepsilon$$

$$A_2$$: $$S_2 \rightarrow 1S_20 | \varepsilon$$

I am stuck with the value of $$S \rightarrow$$ ?

• We are not here to do your homework. Please show that you have tried solving this by yourself, and ask precisions on the steps you are blocked. Apr 4 '21 at 10:50
• Nathaniel I am not asking you to do my homework, I did this using union I am stuck with concatenation, I have created separate grammars for A1 and A2 which are A1:S1 → 0S11 | ε and A2: S2 → 1S20 | ε I am stuck with the value of S → ? Apr 4 '21 at 11:14
• You should edit your post to show what you have done, not write it in the comments. Apr 4 '21 at 11:15

Your grammars for $$A_1$$ and $$A_2$$ seem correct. Since you want to compute the concatenation of $$A_1$$ and $$A_2$$, you just need to express this fact with the start symbols of $$A_1$$ and $$A_2$$.
$$S \rightarrow S_1S_2$$ is a way to do it.
You can check by computing the derivation that creates the word $$001110$$.
• No, the first steps should be $S \rightarrow S_1S_2 \rightarrow 0S_11S_2 \rightarrow$… Apr 4 '21 at 13:31