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.
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.
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 a
s.
So that gives the result:
b*a*
I think your expression is equivalent to this.