30
$\begingroup$

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?

$\endgroup$
  • 11
    $\begingroup$ @Sariel: I hope that it is not a homework problem, because I do not know how to solve it. $\endgroup$ – Tsuyoshi Ito Sep 30 '10 at 19:57
  • 3
    $\begingroup$ 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. $\endgroup$ – Cem Say Sep 30 '10 at 19:58
  • 2
    $\begingroup$ Can you explain why the standard techniques don't work? $\endgroup$ – Warren Schudy Sep 30 '10 at 23:01
  • 3
    $\begingroup$ @Tsuyoshi... Yeh. You are right. Its harder than it looks. $\endgroup$ – Sariel Har-Peled Oct 1 '10 at 0:46
  • 3
    $\begingroup$ 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". $\endgroup$ – Dominik D. Freydenberger Sep 24 '11 at 7:41
28
$\begingroup$

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.

$\endgroup$
  • 5
    $\begingroup$ 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}. $\endgroup$ – Tsuyoshi Ito Oct 1 '10 at 0:28
  • 11
    $\begingroup$ Those who did not know Ogden’s lemma (like me) may find Wikipedia helpful. $\endgroup$ – Tsuyoshi Ito Oct 1 '10 at 0:32
  • 2
    $\begingroup$ @Tsuyoshi: Yes, you're right. I didn't see this simple representation yesterday night. $\endgroup$ – Frank Weinberg Oct 1 '10 at 6:30
  • 1
    $\begingroup$ This answer is featured on the community blog. $\endgroup$ – Aaron Sterling Oct 27 '11 at 12:05
  • $\begingroup$ A similar proof is presented in this answer on cs.se. $\endgroup$ – Hsien-Chih Chang 張顯之 Jan 2 '14 at 18:44
-4
$\begingroup$

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.

$\endgroup$
  • 5
    $\begingroup$ 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$. $\endgroup$ – Dave Clarke May 26 '11 at 7:45
  • 4
    $\begingroup$ 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). $\endgroup$ – DaniCL May 26 '11 at 14:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.