I am given the language:
$L = $ {${a^{n+m} b^{m+k}a^kb^n | m,n,k > 0 }$}
And i am asked to design a Context Free Grammar for this language. Can anyone help me in this one? Like if there is a step by step guide that i should follow? I am new and i don't know many things about CFG's. Please if you think that my question is too general please don't down-vote, please tell me where to go, like find a tutorial somewhere because i have seen a few in YouTube and i didn't find anything that would help me in this kind of CFG. Thanks.
I would start by grouping the expression into $a^n (a^m b^m) (b^k a^k) b^n$. This reduces the pattern to $a^n$ plus a string of the form $a^m b^m$ plus a string of the form $b^k a^k$ plus $b^n$.
You can specify a string of the form $a^m b^m$ by considering "adding $a$ to the left and $b$ to the right" as one step, and use the specification to be strings you can build using that step any times to the empty string. Explicitly:
$$T \to aTb ~|~ \epsilon$$
The other steps to building $L$ can be done similarly.