0

During the formal language exam, the professor allowed to find a CFG to following language: $\{a^m b^n c^p d^q, m\neq n\wedge p\neq q\}(1)$, because neither he saw a solution (He passed a test without resolve it before!!!) to $L=\{a^m b^n c^m d^n, m\neq n\}(2)$. First language I can resolve in seconds, but I cannot visualizate how to ensure $m=p, n=q$ and to ensure $m\neq n$.

For $(1)$ I only need to construct a CFG to $\{a^m b^n, m\neq n\}$ twice. But for $(2)$ I need to ensure $a^m b^n$ substring is correlated with $c^m d^n$ substring. Someone can see how to build the $(2)$ CFG?

  • What have you tried? Please see our reference questions, e.g., http://cs.stackexchange.com/q/265/755 and http://cs.stackexchange.com/q/18524/755, try applying the techniques there, and then edit your question to show what you got when you try using those techniques. – D.W. Jul 04 '15 at 09:12
  • 1
    Maybe it is not CF, and no grammar can be found. There are ways of proving a language is not CF. – babou Jul 04 '15 at 10:44
  • Think of what a pushdown automaton would have to do to recognize strings in this language: It's easy to keep track of the number of $a$s using the stack; it's also easy to keep track of the number of $b$s; now what do you do when you start to see $c$s and need to match them with the $a$s? The $a$ counters are stuck on the bottom of the stack where you can't get to them. This, of course, isn't a proof that the language isn't context-free, but it should give a clue that it isn't. – Rick Decker Jul 04 '15 at 20:37

0 Answers0