0

I've been unable to find any examples of context-free grammars that have nesting and inequalities.

For instance, I am trying to write the CFG for:

{aibjckdl : (i < l) ^ (j < k)}

So, for {aidl : (i < l)}, the CFG would simply be:

S -> aSd | dS | d

It would be similar for b and c. But I cannot figure out how to nest the two grammars. Any similar examples or pointers would be helpful.

James
  • 1
  • 1

1 Answers1

0

In my opinion here you have answer to your question :

S -> Ad | aSd | Sd
A -> Ac | c | bAc

The concept behind this grammar is : First create a part of expression which has a and d satisfying a condition given and then put between a's and d's an expression which is satisfying conditions for b's and c's.

Marcin Możejko
  • 39,542
  • 10
  • 109
  • 120