I want to find the grammar for the following context-free language:
$$L=\{w|\mbox{ the number of $a>$ the number of $b$ }\}$$
I tried the following :
\begin{align*} S&\rightarrow a|aK\\ K&\rightarrow\varepsilon |(ab)^*|a^*|bS \end{align*}
But it doesn't reach words with series of $b$ such as $aaaabbba$
Try, $$S \to AS'bS' | bS'AS' | A $$ $$S' \to AS'bS' | bS'AS' | A | \varepsilon$$ $$A \to a | aA$$
I constructed this by taking a CFG for $L = \{ w : |a| = |b| \}$, and adding an intermediate state for $a$'s.