3

I'm reading my textbook and it claims that the regular expression $c^*(b \cup (ac)^*)^*$ defines the language $L$ over $\{a,b,c\}$ which consists of all strings that do not contain the substring $bc$.

However, I'm failing to see how that language would contain strings such as $bbbaaa$ or $aaabbb$. Am I missing something or is that regular expression incorrect? The expression I come up with was $ \left( \left( \left( a \cup b \right) ^*a \right) ^* \left( c \cup a \right) ^* \right) ^*b^* $

Raphael
  • 73,212
  • 30
  • 182
  • 400
user7461
  • 33
  • 3

2 Answers2

7

I checked an older edition of Sudkamp, and it had the same example. Actually the expression is $c^*(b\cup ac^*)^*$, which has a different bracketing. Your $(ac)^*$ specifies strings of the form $acac\dots ac$, whereas Sudkamp has $ac^*$ which means strings like $acc\dots c$.

It follows the arguments of the answer by Raphael, but backwards. Any sequence of $c$'s is either at the beginning of the string, or else it cannot be preceeded by $b$ because there is an explicit $a$ in the expressing.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109
4

Here is how you can make sure there is a mistake in the book:

  1. Use the algorithm from the book to transform the regular expression into an NFA.
  2. Optional: determinise the automaton, using the algorithm from the book.
  3. Run your example through the automaton and note whether it accepts.

Provided you followed the conversion algorithm correctly and the word is not accepted, there is a mistake in the book: either the claim you quote is wrong or one of the algorithms is wrong.

Spoilers: as mentioned in the comments, the regular expression does not describe the claimed language. The author's epxression enforces "every $a$ is followed by a $c$", which is stronger than the claim.

Your expression looks quite complicated. All you need to do is ensure that every $b$ is followed by $a$, $b$ or the end of the word!

$(b^*a \mid c )^*b^*$

You can also build a suitable automaton -- basically, start with one that accepts everything and modify it to move to a dead state upon reading $bc$ -- and convert it to a regular expression. Perform whatever construction you can more easily prove correct.

Raphael
  • 73,212
  • 30
  • 182
  • 400