Is this language context-free?$ (a^i b^j c^k | i=k-j, i>0, k>0, j>0)$

145 Views Asked by At

I would like to know if this language is context-free:

$$(a^ib^jc^k \mid i=k-j, i>0, k>0, j>0)$$

I believe that it fulfils the pumping lemma (if $v=b^n$ and $x = c^n$, which would add the same amount of $b$'s and $c$'s every pump, thus keeping the condition fulfilled) but I can't find a way to write a context-free grammar to generate it. Is it really context-free? Or am I missing something here?

2

There are 2 best solutions below

3
On

$$ S \rightarrow aS_1c,$$ $$ S_1 \rightarrow aS_1c | B,$$ $$ B \rightarrow bBc | bc.$$

Should work, I think.

0
On

Just build a stack state machine that has 5 states: A, B, C, pass, fail. Start with a machine that matches A+B+C+. Then just add the appropriate stack to it: if you see an 'A' or 'B', push it, if you see a 'C', pop the stack to check non empty. Advance, Pass, or Fail as appropriate.