unambiguous expression for binary string

614 Views Asked by At

i have to find a regular expression that says

S is the set of all binary strings where the length of each block of 0s is divisible by 5.

this is what i got

1*(000001)*

but I'm not sure if its unambiguous, can someone correct me if I'm wrong?

1

There are 1 best solutions below

0
On

As commented, the expression $1^*(0^51^*)^*$ is an expression for your language. To show that it is unambiguous, take a decomposition of a generic string $x=uv$ where $u\in 1^*$ and $v\in (0^51^*)^*$ this decomposition is unique because $v$ is either empty or it starts with a $0$ so $v$ should be the whole prefix of $1$'s. The inside of the Kleene star is also unambiguous, and the intersection of the two concatenated regular expressions is empty so they should be unambiguous.

A general way to check unambiguity is considering the automaton associated to the regular expression. Checking that there is only one way to strings are generated. Notice that your graph should look like a line, so there is no way to have different paths to get the same string.