I have a language $L$ = {$vabu$ | $v$,$u\in \{a,b\}^*$, $|vu|_a = 0$ $($mod $2)$$\}$
where $|vu|_a$ is number of $a$ in $vu$.
I came up with these rules:
$\sigma \rightarrow aa\sigma | ab\xi$
$\xi \rightarrow aa\xi | \epsilon$
This generates words in form: $(aa)^iab(aa)^j\epsilon$, but not all words in $L$ look like this.
How do I make sure that $b$s can be put anywhere in between $a$s in $v$ and $u$.
Edit: I think I found a solution.
$\sigma \rightarrow b\sigma$ | $a\alpha$ | $ab\gamma$
$\alpha \rightarrow b\alpha$ | $a\sigma$ | $ab\eta$
$\gamma \rightarrow b\gamma$ | $a\eta$ | $\epsilon$
$\eta \rightarrow b\eta$ | $a\gamma$