# Using the Pumping Lemma to show that the language $a^n b a^n$ is not regular

I've seen a lot couple of questions regarding the pumping lemma that are pretty similar to each other and this one is unfortunately not the exception. Most likely will be this question marked as a duplicate. But I guess there's no harm in asking.

I was trying to show using the pumping lemma that this language is not regular:

$${ L = \{a^n b a^n \mid n \in{\mathbb N}\} }$$

I've tried the following, although I'm not sure of what I'm doing:

I've tried also to follow the example in this question

$$w = xyz$$ $$xyz = a^p b^p a^p$$ $$|w| = 3p$$ $$3p > p$$

$$|xy| \leq{p}$$

$$|y| \geq{p}$$

but here is as far as I come. A thing that I don't understand is $b$ doesn't have an $n$ exponent like in $a$. Is it ok what I did by placing a $p$ exponent on $b$?

I would appreciate any help in this matter.

• $a^pb^pa^p \notin L$, unless $p = 1$. – Guildenstern May 21 '14 at 16:37
• I think you're on the right track. If you let $w = a^pba^p$, then you consider all the cases for what $y$ can be (which you have restricted with the pumping length $p$), and then you show that all of these possibilities for $y$ produce strings not in $L$, contradicting the PL. – Guildenstern May 21 '14 at 16:45
• As an aside, the Myhill-Nerode criterion is easy to use here. For example, the words $a^n$ are pairwise inequivalent (consider the effect of $ba^n$). – Yuval Filmus May 21 '14 at 20:06
• There's a series of statements but no connection between them. A proof is more than a series of truths, it needs "logical flow"! – Raphael May 26 '14 at 10:27

According to your question, you can't put a $p$ as exponent on $b$ (at least $p = 1$ like @Guildenstern said) because that string wouldn't be in your language $L$. Putting $p = 1$ wouldn't be correct too because you should never give values to the pumping lenght.

You must always choose a string in $L$, for example $a^pba^p$ if you pump correctly you will have less $a$'s in one side than the other side.

(A very different matter is the number $k$ which is used to pump in $y^k$, maybe you are confusing the $p$ over $b$ with that)

The given language is $${ L = \{a^n b a^n \mid n \in{\mathbb N}\} }$$

This is how you prove that it's not regular language:

1. You assume that it is regular language, which means it can be pumped.

2. You pick a string from the language which has a length atleast p.

3. You show that this string can't be pumped, meaning our assumption was incorrect.

Now, tell me how on the Earth do you think the string $a^pb^pc^p$ belongs to the language $L$? Certainly, you can't pick this string to prove $L$ is not regular. Pick a string from $L$.

Proof:
Pick $a^pbc^p$ where p is pumping length. The length of this string is 2p+1,so it's a valid candidate.

Now, you need to divide the string in $xyz$ satisfying all three condition of pumping lemma. As $|xy| \le p$ and $|y| \ge 1$, the $y$ must contain $a$.

Now, pump with $xyyz$ or $xyyyz$. The resulting string won't be in $L$ (if $y$ contains only $a$, pumped string would have more $a$ than $c$. if $y$ contains other characters too, the pumped string won't contain $abc$ in order distinctly).