1

I need help with deciding if $L$ is context-free.

$$L = \{a^pb^{q+r}c^sd^{q+t}e^{p+r} \mid p, q, r, s \ge 0\ , s > t\}$$

Can be rewritten into:

$$L = \{a^pb^qb^rc^sd^qd^te^pe^r \mid p, q, r, s \ge 0\ , s > t\}$$

When we see the first occurrence of $c$, we push the $c$:s onto the stack. But we can't make difference between $d^q$ and $d^t$, so comparing $s < t$ is impossible when popping the $d$:s.

Hence $L$ is not Context-Free.

Is my reasoning right ?

Luke Mathieson
  • 18,373
  • 4
  • 60
  • 87
mrjasmin
  • 586
  • 1
  • 5
  • 12

3 Answers3

4

Hint: rewrite $L$ as $L = \{a^p b^r b^q c^s d^t d^q e^r e^p \mid p,q,r,s \ge 0, s>t\}$.

Does $L$ now look like something you can generate with a CFG?

Raphael
  • 73,212
  • 30
  • 182
  • 400
Shitikanth
  • 696
  • 1
  • 4
  • 13
1

You reasoning is not correct, and not only because you reach the wrong answer.

You argued for one representation of the language that it can't be faithfully checked by one (idea for) a push-down automaton. However, in order to show that a language is not context-free you have to show that no PDA can accept the language in any representation.

There are techniques to approach this task; see our reference question. Always try these if you think a language is not context-free. If you are not able to apply those techniques, you may figure out how to build a PDA or a grammar along the way -- or you have a really tough language at your hands.

Raphael
  • 73,212
  • 30
  • 182
  • 400
0

If we rewrite L as

$$L = \{a^pb^qb^rc^sd^td^qe^pe^r \mid p, q, r, s \ge 0\ , s > t\}$$

If we then look at the case where $$q = 0$$ and $$s, t > 0$$

We take this example string $$z = abcccddee$$ which belongs to L.

This string can be accepted by a PDA and the comparison $$s > t$$ can be done by pushing all the c:s and then popping the d:s.

L is context-free because we showed that a PDA exists for SOME representation of the language.

Is my reasoning right ?

mrjasmin
  • 586
  • 1
  • 5
  • 12