0

I need to find a grammar that generates the language composed by all words that have more $a$ than $b$ given an alphabet $\{a,b\}$

I tried the following production rules:

S->B
B->b | ABB | BAB | BAB | BBA
A->a

with this rules it's fairly simple to proof that all the words that the grammar generates are made up with more $a$ than $b$.

How can I proof that all words made up with more $a$ than $b$ can be generated that way?

wvxvw
  • 1,388
  • 9
  • 13
user1868607
  • 2,194
  • 13
  • 23
  • You don't really need the $A \to a$ rule (you could just write the $B \to aBB$ for example. also you have $B \to BAB$ twice. – wvxvw Sep 29 '15 at 23:07
  • That set of production rules implements a grammar accepting more bs than as, not vice versa. It's also rather redundant. You could just use the rule S -> a | aS | bSS | SbS | SSb. – TLW Oct 01 '15 at 02:20

0 Answers0