# Simplifying regular expressions

This is the homework question:

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

$$\{((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?

-
How did you get the expression? –  saadtaame Feb 4 '13 at 22:03
My head. It could be wrong... –  jsan Feb 4 '13 at 22:07
I mean, what line of reasoning did you follow? That could help simplify the expression. –  saadtaame Feb 4 '13 at 22:08
Well basically it's split in 4 parts. Each part assures that the last letter of each iteration cannot be the the same as the first, so that there could never be an 'aa', 'bb', 'cc'. The last part is a string of length 1 (either a, b, or c). Hope this clarifies, and thanks. –  jsan Feb 4 '13 at 22:14
I agree with the above comments: It isn't enough if the result is "right", you must be able to convince your TA (and yourself too) that it is right. The reasoning behind the construction is an integral part of your solution. –  vonbrand Feb 4 '13 at 23:10

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.
If the $w_i's$ are allowed to be $\epsilon$, you will get successive $c's$. If not, you can't start your regex with $c$ because it starts with $w_1$ which, in turn, starts with $a$ or $b$! –  saadtaame Feb 4 '13 at 23:01
Oh, just allow $c w_1 c w_2 c \ldots$ to start (and for symmetry to end in a $w_n$ or $c$) –  vonbrand Feb 4 '13 at 23:07
And BTW, consider that the $a b$ words can end in $a$ or $b$ (they could be even or odd length). –  vonbrand Feb 4 '13 at 23:11