3

This is the homework question:

$ \{w \in \{a, b, c\}^* : \text{(no symbol occurs twice in succession in w)}\} $

This is my answer:

$$\{((abc)^*| (acb)^*| (ab)^* | (ac)^*)^* | (bac)^* | (bca)^* | (ba)^* | (bc)^*)^* | ((cab)^* | (cba)^* | (ca)^* | (cb)^*)^* | ((\epsilon +a) | (\epsilon + b) | (\epsilon+c)) \} $$

Is there a way to simplify this expression?

Raphael
  • 73,212
  • 30
  • 182
  • 400
jsan
  • 207
  • 3
  • 7

1 Answers1

4

Let's solve this exercise "by induction". Suppose first that the alphabet is only $a,b$. In this case, the only possible words are $ababab\ldots$ and $bababa\ldots$, and you can write a simple regular expressions for them. Now take such a word over the alphabet $a,b,c$. You can break it apart as $w_1 c w_2 c w_3 c \ldots$, in which $w_i \in \{a,b\}^*$. We already have a regular expression describing the $w_i$, so we can write one for the language in question. This approach is general, and you can apply it to any alphabet size.

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