CFG: more a's than b's

CFG: more a's than b's

Post by kevarouz » Tue, 18 Nov 2003 12:39:31


How do you create a CFG to represent a language of more a's than b's??
I tried something like this but its incorrect...

S -> aB
S -> bA
A -> a
A -> aS
A -> bAa
B -> aB
B -> bA

Is there a systematic way to construct the language? From what I've
learned so far it seems like guesswork to come up with the right
solution :(

Thanks,
Kevin