I have a context-free grammar defined by the production S:
S → aSbS ∣ bSaS ∣ ε
I need to prove that the CFG "G" can be defined as a language L(G) where
L(G) = {w ∈ {a, b}∗ ∶ na(w) = nb(w)}.
Where na(w) = number of a's in w, and nb(w) is the number of b's in w
How can I go about proving something like this? Is there a method?
Without giving the answer away.