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
  • 72,336
  • 29
  • 179
  • 389
jsan
  • 207
  • 3
  • 7
  • How did you get the expression? – mrk Feb 04 '13 at 22:03
  • My head. It could be wrong... – jsan Feb 04 '13 at 22:07
  • 1
    I mean, what line of reasoning did you follow? That could help simplify the expression. – mrk Feb 04 '13 at 22:08
  • 1
    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 04 '13 at 22:14
  • 2
    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 04 '13 at 23:10
  • Sketching an automaton and writing a system of equations then solving it using Arden's lemma could yield a concise result. – mrk Feb 04 '13 at 23:38
  • Try a structured approach: come up with an NFA and convert it. Minimising regular expressions may be hard. – Raphael Feb 05 '13 at 10:18
  • Did no one notice that simplify is not a well defined concept? What is a simple regular expression? – Dan Feb 05 '13 at 14:08

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
  • 276,994
  • 27
  • 311
  • 503
  • 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$! – mrk Feb 04 '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 04 '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 04 '13 at 23:11
  • 1
    @saadtaame You're right, a few details are missing. After all, it's not me who has to write the solution to the exercise. – Yuval Filmus Feb 05 '13 at 00:13
  • @YuvalFilmus Right. – mrk Feb 05 '13 at 00:16