8

$L_1=\{a^ku \mid u \in \{a,b\}^* $ and $u$ contains at least $k$ a's, for $k\geq 1\}$.

If it is regular, I haven't found its regular expression or any closure property to prove it.

If not, it seems pumping theorem holds for it...

Also, what about the language where the above "at least" is changed to "at most"?

Raphael
  • 73,212
  • 30
  • 182
  • 400
goldfrapp04
  • 265
  • 2
  • 5

2 Answers2

10

Take $k=1$. No need to go further, any more $a$ can be absorbed by $u$ without risk.

So you need $u$ to have at least 1 $a$ and only $a$'s or $b$'s. Therefore, $L_1$ is described by $a(a|b)^*a(a|b)^*$ and is regular.

For the side question (at most $k$ $a$'s, let's call that language $L_2$), you can reason in a similar fashion to get $u$ as small as possible. For simplicity let's consider $L_3$ the intersection of $L_2$ with the one denoted by $a^*ba^*$. You have $L_3=\{a^k b a^j, k \geq j\}$. Intersection with its reverse yields $\{a^kba^k\}$ which is not regular, therefore $L_2$ is not regular either since regular languages are closed under intersection and reversal.

Khaur
  • 491
  • 2
  • 14
6

They way I read the question for the first time, I understood $k$ to be a fixed parameter. Define the following languages, for $k\ge 1$:

$$L_k = \{ a^ku \mid u\in \{a,b\}^* \text{ and $u$ has at least $k$ $a$'s }\}$$

$$\tilde L_k = \{ a^ku \mid u\in \{a,b\}^* \text{ and $u$ has at most $k$ $a$'s }\}$$

The difference is that for any $L_k$, $k$ is only one specific fixed value (while one can understand $L_1$ to be the union for any $k\ge1$).

Still, those languages are regular. A regular expression for the first might be $a^kb^*\underbrace{ab^*\ldots ab^*}_{k \text{ times}}(a+ b)^*$. A regular expression for the second may be $a^kb^*\Big(a+ab^*a + ab^*ab^*a + \ldots + \underbrace{ab^*ab^*\ldots a}_{k-1\ a\text{'s}}\Big)b^*$. It is not too hard to come up with NFAs for both languages.


This gives a very nice example about (infinite) unions of regular languages: although $L_k, \tilde L_k$ are regular for any $k$, and although regular languages are closed for unions, when we take their infinte unions (abusing notations!): $$ L_1 = \bigcup_k L_k \qquad L_2 = \bigcup_k \tilde L_k$$ $L_1$ is regular, while $L_2$ is not!
(where $L_1$ is defined in the OP's question, and $L_2$ is the like $L_1$ but with "at most")

Ran G.
  • 20,884
  • 3
  • 61
  • 117