edited by
1,600 views

2 Answers

1 1 vote

No. $L$ isn't Regular. $L$ is union of two infinite languages, $a^{n+2}b^n, $ $a^nb^{n+2}.$


Proof using Myhill-Nerode Theorem:

To formally prove that $L$ is Non-regular, we can make show an infinite set of distinghuishable strings $S = \{ a^n | n \geq 1 \}.$ In given set $S,$ every two strings are distinguishable w.r.t $L,$ as proven below:

Take any two different strings in $L;$ $a^k,a^m$ where $m > k.$ For these strings, $b^{m+2}$ works as the distinghishing extension. 

Since, an infinite set of distinghuishable strings exists w.r.t. $L$, so, $L$ is Not Regular (Myhill-Nerode theorem).


Proof using Pumping Lemma:

We will use Pumping lemma for regular languages to Prove that It is Not Regular.

Pumping lemma for Regular languages says

" If A languages is Regular,

then $\exists P \geq 1$, such that 

$\forall \,\,strings\,\,w \in L$, Where $|w| \geq P$

$\exists x,y,z$, such that $w = xyz$

and $|xy| \leq P$

and $y \neq \in$ i.e. $|y| \geq 1$

and $\forall q \geq 0$, $xy^qz \in L$

In Words, If $L$ is regular, then there’s some magic number $P$(Called Pumping length). And if I take any string $w$ that is at least as long $P$, then I can break it up into three parts $x, y, $and $z.$ Now, the length of $xy$ is less than or equal to $P$, and also the length of $y$ is greater than or equal to $1$ and less than or equal to $P$.

NOTE that The first line is If $L$ is regular This means that our theorem only applies if the language is regular. It doesn’t apply if $L$ is not regular. I know you don't agree. But hold on. I'll prove it to you.  

People say that We use the pumping theorem to show that a language isn’t regular. And It is indeed True. Then Why did I say the above line??

That's because Pumping lemma is a Proof by Contradiction. In other words, we assume $L$ is regular, then we show that it doesn’t satisfy the pumping theorem. This gives us a contradiction, so our initial assumption that $L$ is regular must be wrong.

So, Now let's consider the given language $L = \left \{ a^nb^k, |n-k| = 2 \right \}$

Let's Assume that $L$ is Regular.  

Now, Since we have assumed that $L$ is Regular, so, This means that there’s some ”magic number” $P$ for the language $L$, such that the all the things in the rest of the theorem are true. 

So, Let's take Pumping length as $P$ and now, Every String of length $\geq P$ must satisfy the rest of the conditions of the Pumping lemma. 

So, as Pumping lemma states, For all $w$, where $|w| \geq P$, i.e. Sufficiently Large Strings, $w$ can be split into three Parts $x,y,z$.

So, Let's take some sufficiently large string with $|w| \geq P$ (as All the Strings with length greater than or equal to $P$ must satisfy the condition..)

So, Let $w = a^pb^{p-2}$ . Now let's try to split $w$ in three parts $x,y,z$ such that $|xy| \leq P$, $y \neq \in$

Now, $y$ has to be in the part $a^p$ because $|xy| \leq P $ and $|y| \geq 1$. You can try taking $y$ from $a$ to $a^P$ but You can find that $xy^qz$, $\exists q \geq 0$, Will Not be in the language. 

So, We have shown that $L$ does not Satisfy the conditions of Pumping lemma. So, Our assumption that $L$ is Regular, was wrong. Hence, $L$ is Not regular.


$L$ is CFL. You can write it as Union of Two CFL languages as follows :

$\left \{a^nb^k:|n-k| = 2 \right \} = $ $\left \{a^nb^k:n-k = 2 \right \} $ $\cup \left \{a^nb^k:k-n = 2 \right \} $

You can find one more detailed explanation for another Non-regular language using Pumping lemma here in my answer : : https://gateoverflow.in/146637/prove-a-language-is-regular-using-pumping-lemma 

edited by
0 0 votes
It should be non regular.
edited by
Position:
Show:

Related questions

0 0 votes
1 answers 1 answer
1.7k
1.7k views
srestha asked May 24, 2018
1,695 views
Is it regular?$\left \{ \left ( 0^{n} \right )^{m}|n<m,n,m\geq 1 \right \}$
1 1 vote
1 1 answer
2.5k
2.5k views
sachin_27 asked Jun 1, 2022
2,489 views
identify language is regular or not L={wcw^r | w,c belongs to E*} E={a,b}if yes then why please explain
1 1 vote
1 answers 1 answer
2.3k
2.3k views
Isha Karn asked Oct 25, 2014
2,332 views
{ wxw | w belongs to {0,1}* , x belongs to {0,1}+ }
12 12 votes
1 answers 1 answer
3.2k
3.2k views
Utk asked Dec 30, 2015
3,186 views
Consider following languages :L1 = { wxwy | x,w,y $\in$(a + b)+ } ,L2 = { xwyw | x,w,y $\in$(a + b)+ } ,L3 = { wxyw | x, y, w $\in$(a+b)+ } How can we say that L1 , L2 ar...