How can I construct a grammar that generates this language? Construct a grammar that generates L:
L = {a^n b^m c^k|k>n, k>m}
I believe my productions should go along this lines:
S-> ABCC
A-> a|aBC|BC
B-> b|bBC
C-> c|Cc
CB->BC
The idea is to start with 2 c and keep always one more c, and then with C->c|Cc ad as much c as i want. How can my production for C remember the numbers of m and n.
One option would be the following: generate a string in which every time you generate a
c
, you eithera
to pair it with,b
to pair it with, ora
and ab
to pair it with.This starts off here:
(Note that this is partially incomplete). Here, X expands out to a series of
c
's on one side of the string that are paired on the other side of the string withA
s andB
s. The productions forA
s andB
s are there to ensure that they're reordered into the proper order before being expanded.One case this doesn't consider is what happens if you have a string of the form ancn+k, but that can be fixed as follows:
Hope this helps!