# Is {$a^{i}b^{j}c^{k} ~|~ i \neq j, i \neq k, j \neq k$} non-context-free?

Is the language {$a^{i}b^{j}c^{k} ~|~ i \neq j, i \neq k, j \neq k$} context-free or not?

I realized that I have encountered almost all variants of this question with different conditions about the relationship between i, j, and k, but not this one.

My guess is that it is not context-free, but do you have a proof?

• @Sariel: I hope that it is not a homework problem, because I do not know how to solve it. – Tsuyoshi Ito Sep 30 '10 at 19:57
• It looks like a homework problem, since some of the other variants that I mention are sufficiently easy to be homework problems. But this variant is not a homework problem. I would be glad if anyone can give me a link to any course site where this particular problem has been assigned as a homework, though. – Cem Say Sep 30 '10 at 19:58
• Can you explain why the standard techniques don't work? – Warren Schudy Sep 30 '10 at 23:01
• @Tsuyoshi... Yeh. You are right. Its harder than it looks. – Sariel Har-Peled Oct 1 '10 at 0:46
• Curiously, this language (and the use of Ogden's Lemma) can be found in Example 6.3 (p. 130) in the classical version of Hopcroft and Ullman's "Introduction to Automata Theory, Languages and Computation". – Dominik D. Freydenberger Sep 24 '11 at 7:41

Ogden's lemma should work:

For a given $p$ choose $a^i b^p c^k$ and mark all the $b$'s (and nothing else).

$i$ and $k$ are chosen such that for every choice of how many $b$'s are actually pumped there is one pumping exponent such that the number of $b$'s is equal to $i$ and one where it is equal to $k$.

That is $i$ and $k$ have to be from the set $\bigcap_{1 \leq n \leq p} \lbrace p-n + m*n \mid m \in \mathbb{N}_0\rbrace$.

I am quite sure but too lazy to formally prove that this set is infinite.

• Assuming that IN_0 means the set of nonnegative integers, the mentioned set is infinite because it contains p+im for i=0, 1, 2, …, where m is the least common multiple of {1, …, p}. – Tsuyoshi Ito Oct 1 '10 at 0:28
• Those who did not know Ogden’s lemma (like me) may find Wikipedia helpful. – Tsuyoshi Ito Oct 1 '10 at 0:32
• @Tsuyoshi: Yes, you're right. I didn't see this simple representation yesterday night. – Frank Weinberg Oct 1 '10 at 6:30
• This answer is featured on the community blog. – Aaron Sterling Oct 27 '11 at 12:05
• A similar proof is presented in this answer on cs.se. – Hsien-Chih Chang 張顯之 Jan 2 '14 at 18:44

If the relation between the three restrictions is "OR", then the language is CFL. The solution uses the fact that CFLs are closed under union. Clearly, the following are CFLs: $L_1=\{a^ib^jc^k \mid i\ne j,\ k\ge 0\}$, $L_2=\{a^ib^jc^k \mid i\ne k,\ j\ge 0\}$, $L_3=\{a^ib^jc^k \mid j\ne k,\ i\ge 0\}$ (if one is not convinced, one can look on $L_i$ as concatenation of CFL and regular language. For instance, $L_1$ is $\{a^ib^j\mid i\ne j \}$ concatenated to $\{c\}^*$.

The desired language is the union of the above $L=L_1\cup L_2\cup L_3$. So, it is CFL.

• This is wrong. For example, $aabcc\in L_1$ and hence in your $L$, but $aabcc\notin\lbrace a^ib^jc^k~|~i\neq j,i\neq k,j\neq k\rbrace$. – Dave Clarke May 26 '11 at 7:45
• You assume that »the relation between the three restrictions is "OR"«, but this is not the intended meaning. All of the restrictions have to hold (cf. Dave Clarke's counterexample), and then the language is not context-free (cf. the answer above). – DaniCL May 26 '11 at 14:49