

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


(Realize that many different RegExs can describe the same regular language.)
(So if the length is less than 2 we have no restriction, I choose to enumerate the possibilities.)
= ε
0
1
∑*
∑*
∑*10 (Enumerating all possibilities)
= ε
∑
∑*
∑*
∑*10 (realized I could simplify)
= ε
∑
∑*(
Let's jot a few down: 1, 001, 010, 100, 00001, 00010, 00100, 01000, 10000, and so on
Now for the regular expression:
(00)010(00)
(Think about it, for the count of 1s to be even, then viewing the 1 as splitting those 0s, we have
then an even number of 0s both before and after OR we have an odd number of 1s both before
and after (to maintain the total overall even count of 0s.))
(Again the problem is to identify categories of possibilities. We need a 0; we need a 1; Anything
can be dispersed before and after those. We also need to make sure that at a minimum even if
we have exactly one 0 and one 1, the order could be 01 or 10. Hence the two regular expressions
below unioned together into one regular expression.
∑1∑0∑*
consecutive 0s.
I start by thinking about the minimal essence of what is required: the string may have no
sequences of 0s or just a single 0, or exactly two 0s. I write the regular expression for just that
part – ignoring the context in which this will be allowed.
(ε
0
Now I reason that 0 and 1 are allowed before and after this pattern, but with some restrictions so
that I do not allow inadvertently a sequence of more than two 0s. Before this pattern, certainly
any number of strictly 1s is allowed (that's 1*), but intermixed I could have a 0 as long as it is
guaranteed to be followed by a 1 so that concatenating that with our kernel part will not result in
a series of more than two 0s in sequence. Hence I have:
01)* (ε
0
00).
Using the same sort of reasoning I describe what is allowed after the kernel. And here is the
final RegEx:
01)* (ε
0
10)* (Admittedly this may not be the most elegant sol'n.)
both.)
a) let's deal with the "at most one 1" 010
0* 0*(ε
1)0*
b) now the "at least two 0s" ∑0∑0∑*
so since we are describe the language of all strings that belong in a or b, we use union:
0*(ε
1)0*
∑0∑0∑*
least two 0s.
Trying to use info of a & b from above will give a solution, albeit a convoluted line of reasoning:
i)
It is useful to find a & b as in problem 12, but in the end we seek the intersection of those regular
expressions a & b. Not the union.
Focusing on b) ∑0∑0∑* we observe that at most only one of the three ∑* is allowed to 010
while the other two are allowed to be 0*; otherwise we end up with too many 1s being allowed.
(And all 0s is okay.)
all 0s 000*
allowing the first ∑* yields (010)000 01000
allowing the second ∑* yields 00(010)00 0010
allowing the third ∑* yields 0000(010) 00010
Putting those three together we have now:
001
010
100)0*
ii)
Instead it may have been more productive just to think of this with a fresh mind. If at most one 1
is allowed and at least two 0s, then I can start enumerating the strings of this language taken in
order of length:
(None of zero length; none of length one)
and I realize others are the result of just interjecting more 0s within those string I have listed. So
I have the kernel of the RegEx.
001
010
and since that may have any number of 0s before or after it:
001
010
100)0*