Reputation: 185
Consider the language {anbmcp | n <= p OR m <= p}
, create a CFG for this language.
I have started this with S -> aA | aB
, but am unsure how I should go about defining A or B. The "OR" seems quite difficult to incorporate into the language's definition as it doesn't seem necessary to track both n and m and compare them against p, yet I don't know which one I want to track
Upvotes: 0
Views: 637
Reputation: 3070
In order to maintain that constraint, for every 'a' you need to add a 'c'. Similarly for every 'b' you should add a 'c'.
A -> aAC | aC | B
B -> bB | bC
C -> cC | c
I could be wrong here. But that's how you should think while creating a CFG.
Upvotes: 2