Designing CFG that accepts $b^m a^n$ ($m ≤ n$) I am trying to design a CFG that generates the language $\{a^k b^m a^n a^k \mid m \leq n\}$. However, I am having trouble with the $b^m a^n$ where $m \leq n$. How do I solve this?
You can write this language as
$$
\{ a^k b^m a^m a^\ell a^k \mid k,m,\ell \in \mathbb{N} \}.
$$
This description easily lends itself to conversion into a context-free grammar.