Use closure properties for the language $L=\{a^kb^l:|k-l| \leq 100 \}$

61 Views Asked by At

Given the language $$L=\{a^kb^l:|k-l| \leq 100 \}$$ I have to show that $L$ is regular or context free using closure properties. I have done the following: The language is regular. Let $k>l$, then the language is $L=\{a^kb^l: k-l \leq 100\}=\{a^kb^l: k \leq 100+l\}$. The language $\{a^kb^l: k > 100+l\}=\{a^+\} \cdot \{a^{100}\} \cdot \{a^lb^l\}$,that is regular as concatenation of these regular languages, is the complement of the language $L$. So since regular languages are closed under complement, $L$ is regular. Then we do the same for $k<l$. Can we show this in that way?

1

There are 1 best solutions below

1
On BEST ANSWER

$L$ is context-free but not regular.

To show that it is not regular, use pumping lemma as usual.

To show that it is context free, you can show that for all $i\in[-100,100]$, the language $$L_i=\{a^kb^l: k-l=i\}$$ is context-free (for instance explicit a grammar), and then use $$L=\bigcup_{-100\leq i\leq 100} L_i.$$