tags:

views:

117

answers:

1

alt text

There's a question on my exercise sheet to find the complement of r = (a|b)*ab(a|b)*

I've come up with a solution, but I'm not sure if it's correct. Please help me to check, and correct my errors.

Thanks in advance.

+4  A: 

I'm assuming that a and b are the only allowed symbols.

Your original expression matches any string that contains ab. The complement is any string that does not contain ab. In other words if there is an a the next character must be another a or the end of the string. If a b occurs it must be before all as.

So that gives the result:

b*a*

I think your expression is equivalent to this.

Mark Byers