12

I thought all regular languages could be expressed with regular expressions (if a language is regular, it can be expressed with regex), but I have been told that you need all three of the regular operations (concatenation, union, and star) for that to hold.

For example, I have been told that if I can only use the union and concatenation regex operations (2 out of the 3), there would be a regular language I can't describe with just those two.

Same with just Kleene star and union. What are some examples of this?

Raphael
  • 73,212
  • 30
  • 182
  • 400
user3295674
  • 383
  • 4
  • 14

3 Answers3

19

With only union and concatenation, you can't describe any infinite language. The union and concatenation can only produce finitely many strings. With only union and the Kleene star, you can't describe a language such as $L = \{ab\}$, because there's no way to concatenate an expression generating only $a$ with an expression generating only $b$. With only concatenation and the Kleene star, you can't describe a language such as $L = \{a,b\}$.

D.W.
  • 167,959
  • 22
  • 232
  • 500
DylanSp
  • 865
  • 6
  • 15
11

A perhaps more interesting question is that of star height. The other answer mentions that if you can't use star, then you can only generate finite languages. What if you are not allowed to nest stars (so something like $(a^*b^*c)^*$ is not allowed)? What if you are only allowed to nest stars two levels deep? $d$ levels deep? It turns out that for every $d$ there are regular expressions expressible in nesting $d$ but not in nesting $d-1$. The link contains some examples.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
4

Another interesting case arises by allowing complementation as a possible operation. Using union, concatenation and complement (but no star), one can obtain the language $A^*$ as the complement of the empty language. One can also obtain languages like $(ab)^*$ and $(a(ab)^*b)^*$ (not so easy to see if you don't know the trick), but there is no way to obtain $(aa)^*$.

If one now allows to use star, but not nested stars, then it is an open problem (for at least 45 years) to know whether one can obtain all regular languages. This question is known as the generalized star height problem. It is similar to the star height problem mentioned by Yuval Filmus, with the difference that complementation is now allowed.

J.-E. Pin
  • 6,219
  • 21
  • 39