I want to prove that the language $L = \{ a^{n}(ab)^{{n}^{2}}b^{n} \mid n \geq 0 \}$ is not context-free by using Parikh's theorem.

My first assumption is that the $(ab)^{{n}^{2}}$ part cannot be written as a subset of linear vectors. From this it follows that $\psi(L)$ is not semi-linear.

My problem is to show that by a formal proof.

  • $\begingroup$ Welcome to Computer Science! What have you tried? Where did you get stuck? We do not want to just hand you the solution; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. See here for tips on asking questions about exercise problems. If you are uncertain how to improve your question, why not ask around in Computer Science Chat? $\endgroup$
    – Raphael
    Commented Jan 14, 2017 at 16:03

1 Answer 1


If $L$ were context-free then, applying the homomorphism mapping both letters to $a$, also the following language would be context-free: $$ L' = \{ a^{2n^2+2n} : n \geq 0 \}. $$ According to Parikh's theorem, a unary language is context-free iff the corresponding subset of $\mathbb{N}$ is eventually periodic. Yet the sequence $2n^2+2n$ has arbitrarily long gaps, since $2(n+1)^2+2(n+1)-2n^2-2n = 4n+4$. Therefore the set $\{2n^2+2n : n \geq 0\}$ is not eventually periodic, and so $L'$ is not regular or context-free.

  • $\begingroup$ Thank you for the answer! Can you tell me (or give me reference for) what is means that a corresponding subset must be periodic and why it must fulfill that condition for context-free languages? $\endgroup$
    – xvzwx
    Commented Jan 14, 2017 at 17:09
  • $\begingroup$ A subset $S$ of $\mathbb{N}$ is eventually periodic if there exist $n_0,p \geq 1$ such that for all $n \geq n_0$, we have $n \in S$ iff $n+p \in S$. The subset corresponding to a unary language has to be eventually periodic due to Parikh's theorem. $\endgroup$ Commented Jan 14, 2017 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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