So the original question is to get the complement of the regex 0*1*.
0*1* = {ε,0,1,00,01,11,000,001,011,111,...}, essentially any number of 0s followed by any number of 1s.
I made this DFA for 0*1*:
- Note: "↫" denotes a self-loop.
->((q1))↫0 ---1--> ((q2))↫1 ---0---> (∅)↫0,1
Then I did the complement by swapping the final states with the non final states, resulting in the empty set being the only final state:
-->(q1)↫0 ---1--> (q2)↫1 ---0---> ((∅))↫0,1
But now I'm confused, I've looked at countless examples online and I'm not sure how to convert this particular DFA to a regex, my main problem being that the final state is an empty set.
These are the computations I did:
For q1:
q1 = Ɛ + q1(0), because R=Q+RP is equal to R=QP*...
q1 = Ɛ(0*), because Ɛ(R)=R...
q1 = 0*
Then, for q2:
q2=q1(1)+q2(1), substitute q1 to get q2=0*(1)+q2(1), then...
q2=0*1(1)*
For ∅: (<-This is where I think things start to get shaky)
∅ = q2(0) + ∅(0) + ∅(1), can be reorganized ∅ = q2(0) + ∅(0 + 1), then substitute q2 and get ∅ = 0*1(1)*0 + ∅(0 + 1), then this can become:
∅ = 0*1(1)* 0(0 + 1)*
So I would consider the complement of the regex 0*1* to be 0*1(1)* 0(0 + 1)*. But that just doesn't seem right. Am I overcomplicating this? Please any help would be appreciated.
Edit 1: - Edited to fix typos
We start at state $A$.
$$\begin{array}{c|c|c} \text{State}&\text{Next}&\text{Goto}\\\hline A&0&A\\\hline A&1&B\\\hline B&0&C\\\hline B&1&B\\\hline C&0&C\\\hline C&1&C \end{array}$$
where states $A$ and $B$ are accepted.
In its complement, $C$ is accepted.
We have these paths from $A$ to $C$ forcing no repetition of states:
There's only one path.
This corresponds to the regex
0*11*0[01]*, which can be shortened to0*1+0.*assuming that.only matches0or1.