I have the following problem:
Construct a grammar that only generates the strings that belong to the language $L$ where: $$ L = \{ a^x b^{x-y} c^y \mid x > y > 0 \text{ and }(x + y) \text{ is even} \} $$
From which I deduced that:
- $x$ and $y$ have to both be either odd or even for their sum to be even.
But how to I proceed in generating the grammar. This language is a bit confusing to me.
I think i found a context-free grammar that does this. Let $S$ be the start symbol.
Some explanations: 1. is to ensure that $y>0$, there has to be at least one $c$. 2. Increase both $x$ and $y$ by $1$. 3. Increase $x$ by 2, ensuring that there is at least one $b$ (because $x>y$). 4. Increase $x$ by 2, if necessary. We cannot increase by one, because $x,y$ need to have the same parity.