Context free grammar question i have two context free grammar questions and I don't know how to do them. 


*

*$$\{(a^n)b(c^n) \mid n >0 \}$$ I'm having trouble with this one because I don't know how to account for $a$ or $b$ not having empty set.

*$$\{(a^n)(b^m)(c^n) \mid n,m \ge 0\}$$ 

In general, strings of the form $a^nb^n$ for $n > 0$ are derived from productions of the form $A \rightarrow aAb$. So a context-free grammar generating the language $a^nb^n$ for $n \geq 0$ will have produtions $A \rightarrow \lambda$ and $A \rightarrow aAb$. The second production will generate the leading and trailing $a$'s and $b$'s, while the $\lambda$-production will terminate a derivation. If the $\lambda$-rule is replaced with another rule, say $A \rightarrow u$, then the language generated by the grammar will be $a^nub^n$, because every derivation in the grammar will terminate with $A \rightarrow u$. Given that $A \rightarrow aAb$ generates $a^nAb^n$ for $n \geq 0$, you need to find an appropriate $u$ that will terminate derivations in the grammar to generate $a^nb^n$ for $n > 0$.
For the second language, again begin with the fact that $A \rightarrow aAc$ has partial derivations of the form $a^nAc^n$ for $n \geq 0$. Instead of terminating derivations with a single application of a rule $A \rightarrow u$ for some string $u$, we want to terminate derivations with a rule that allows the derivation of a finite number of $b$'s. In other words, we want a rule that derives $B \Rightarrow^* b^m$ for $m \geq 0$. You should know how to write such a rule, because you're presumably covered right and left-regular grammars.
