As an exercise we were supposed to find a grammar $G$ that generates language $L(G) = \{w \in \{a,b\}^* \mid |w|_a = |w|_b\}$. That was not so hard, I found a grammar which I think is correct:
$S \longrightarrow bA \mid aB$
$A \longrightarrow a \mid aS \mid bAA$
$B \longrightarrow b \mid bS \mid aBB$
Though then I found out that this grammar is ambiguous.
So the question is, is there any context free grammar generating language $L$ that is not ambiguous? I've read that there is no algorithm to determine whether a grammar is ambiguous. So if there is such grammar, how can we prove it is? Or is there any way to transform my grammar $G$ to become unambiguous?