Automata Lecture 03 RE
Automata Lecture 03 RE
Regular Expressions
L1 L2 = {s: s L1 or s L2}
Example
L* = L0 L1 L2 …
((0+1)(0+1))*+((0+1)(0+1)
(0+1))*
all strings whose length is even or a mutliple of 3
= strings of length 0, 2, 3, 4, 6, 8, 9, 10, 12, ...
((0+1)(0+1)+(0+1)(0+1)(0+1))*
strings that can be broken in blocks,
where each block has length 2 or 3
((0+1)(0+1)+(0+1)(0+1)(0+1))*
strings that can be broken in blocks,
where each block has length 2 or 3
(1+01+001)*(+0+00)
ends in at most two 0s
there can be at most two 0s between
consecutive 1s
00 0110010110 0010010
Writing regular expressions
• Write a regular expression for = {0, 1}
all strings with two consecutive 0s.
(0+1)*00(0+1)*
Writing regular expressions
• Write a regular expression for = {0, 1}
all strings that do not contain two consecutive 0s.
1110110101101010
some 1s at every 0 maybe a 0 at the end
the beginning followed by
one or more 1s
... every middle 0 followed by one or more 1s (011*)
1*(011*)*( + 0)
Writing regular expressions
• Write a regular expression for = {0, 1}
all strings with an even number of 0s.
(1*01*01*)*