Give a regular expression for the language L over the alphabet {0,1} whose complement is represented by the regular expression 0*
i think that the answer is 1^+ but i cannot prove it please help
Give a regular expression for the language L over the alphabet {0,1} whose complement is represented by the regular expression 0*
i think that the answer is 1^+ but i cannot prove it please help
First of all, Daniel is correct that the answer is "all the words that contain at least a single 1". But how can you prove it?
The complement of a regular expression can be most easily built using the finite automation representation. See the following image:
The left box shows the DFA for 0*
. To build its complement, all you need to do is make all non-accepting states accepting states and vice versa. This is done in the right image.
Now, you're halfway there, but now you need to build a regular expression from it. This is surely explained in your textbook or equivalent, but if you don't find it, here is a pdf which describes the algorithm.
Using the algorithm provided, with (A = state 1) and (F = state 2), you get:
R_11^0 = ɛ|0
R_12^0 = 1
R_21^0 = (empty set)
R_22^0 = ɛ|0|1
Moving on to R_ij^1, you get:
R_11^1 = (ɛ|0) | (ɛ|0)(ɛ|0)*(ɛ|0) = (ɛ|0)* = 0*
R_12^1 = 1 | (ɛ|0)(ɛ|0)*1 = 1 | 0+1 = 0*1
R_21^1 = (empty set) | (empty set)(ɛ|0)*(ɛ|0) = (empty set)
R_22^1 = (ɛ|0|1) | (empty set)(ɛ|0)*1 = (ɛ|0|1)
And the final stage:
R_11^2 = 0* | (0*1)(0|1)*(empty set) = 0*
R_12^2 = 0*1 | (0*1)(ɛ|0|1)*(ɛ|0|1) = (0*1)(0|1)* = 0*1(0|1)* <------- !!! HERE !!!
R_21^2 = (empty set) | (ɛ|0|1)(ɛ|0|1)*(empty set) = (empty set)
R_22^2 = (ɛ|0|1) | (ɛ|0|1)(ɛ|0|1)*(ɛ|0|1) = (ɛ|0|1)
Now, you can find the regex by looking at all the results which have a starting state as their first index and an accepting state as their last index. In our example, state 1 (A) is the only start state and state 2 (F) is the only accepting state, so your result is R_12^2
:
0*1(0|1)*
In plain English, that's:
So in other words, it's all the words which contain at least one one.
The complement of the language (^0*$
) contains the empty word and all words consisting only of zeros. Therefore the language contains all words not consisting of only zeros, that is containing at least a single one. Hence the regular expression for the language is ^.*1.*$
. Taking into account the alphabet and making the one in the regular expression the first one this is equivalent to ^0*1(0|1)*$
.
The complement of a regular expression can be determined by making an NFA out of the regex, then converting it into a DFA (if possible make it a minimal DFA). Use Arden's theorem to find the regex for non-final states and that is your complement of the language.