$L$ is the context free grammar over $\{a, b\}$
$S \rightarrow aSb \; | \;bR \; |\;Ra$
$R \rightarrow bR \;|\;aR\;|\;\epsilon$
Briefly describe this CFG with English sentences and prove your description. Then give a CFG for the complement of $L$.
$\\$
I think the CFG is a language with equal amount of $a$ at the beginning and $b$ in the end, in the middle with a string that consists of $a$ and $b$, and either starts with $b$ or ends with $a$. But I'm not sure if it's correct nor do I know how to formally prove my description.
For the complement, I'm not sure how to design the CFG.
Is anyone able to solve this problem? Thanks.
Let $A = \{a,b\}$. Then the language $L$ is the least solution in $S$ of the system of equations \begin{align} S &= aSb + bR + Ra \\ R &= bR + aR + 1 \end{align} where $+$ denotes union and $1$ denotes the empty word. The second equation gives $R = (a+b)R + 1 = AR + 1$ and has $R = A^*$ as unique solution. Reporting in the first equation yields $S = aSb + bA^* + A^*a$. Setting $K = bA^* + A^*a$, it can be written as $S = aSb + K$, which leads the solution $$ L = \{ a^nub^n \mid n \geqslant 0 \text{ and } u \in K \} $$ For the second part, I have nothing to add to the excellent suggestion of Arthur Fischer.