8

Is the language $ L = \{0^n 1^m \mid n \text{ and } m \text{ are co-prime}\}$ context-free ?

I guess that it's not context free because it seems too complicated for a PDA to decided whether 2 numbers are co-prime or not.

I tried using the pumping lemma to no avail.

Any help would be gladly appreciated.

Edit:

Here is one of my failed attempts with the pumping lemma:

Let $N$ be a constant. Take a prime $p$ such that $p > N!$ and then take the word $z = 0^p 1^{p+N!} \in L$. Let $ z = uvwxy $ be a decomposition of $z$ satisfying the conditions in the pumping lemma.

If $ vx $ contains only zeros then $ |vx| = k $ is an integer between $1$ and $N$. Define $m$ as $m = N!/k$. For $i = m+1$ the word $ uv^iwx^iy = 0^{p+N!}1^{p+N!} \not\in L $

However, I've failed to find such an integer $i$ for the other decomposition cases.

Robert777
  • 747
  • 6
  • 15

1 Answers1

4

Ridiculous that I didn't see this earlier...

The proof that the language (call it $\mathcal{L}$) isn't context free is by contradiction. Assume $\mathcal{L}$ is context free, by the pumping lemma for CFGs there is a constant $N$ such that each string $\sigma \in \mathcal{L}$ such that $\lvert \sigma \rvert \ge N$ it can be written $\sigma = u v x y z$ with $v y \ne \epsilon$ such that for all $k \ge 0$ the string $u v^k x y^k z \in \mathcal{L}$. Take $m, n$ different primes (such that $\gcd(m, n) = 1$) and $m, n > 2N$, and take $\sigma = 0^m 1^n$. The pumped string will be $0^{m + k a} 1^{n + k b}$ for some constants $a$, $b$, not both zero, and such that $a < m$ and $b < n$ (we have $a, b \le N < m / 2, n / 2$ by the way $m$, $n$ were selected). The case of one of them zero was covered by OP, so consider $a, b \ne 0$. Now:

$$ \begin{align*} m + k a &\equiv 0 \pmod{n} \\ n + k b &\equiv 0 \pmod{m} \end{align*} $$

This has a unique solution $k^*$ modulo $m n$ by the chinese remainder theorem (we have $a < n$, and as $n$ is prime, $\gcd(a, n) = 1$; similarly $b$ and $m$), and thus we can write: $$ \begin{align*} m + k^* a &\equiv 0 \pmod{mn} \\ n + k^* b &\equiv 0 \pmod{mn} \end{align*} $$ i.e., $m n \mid \gcd(m + k^* a, n + k^* b)$. Contradiction.

vonbrand
  • 14,204
  • 3
  • 42
  • 52