CSCI3255: Math Foundations of CS
Homework Chapter 3, page 1
October 2002
3.1/111, 17, 18
1.
Find all strings in
L
((
a
+
b
)*
b
(
a
+
ab
)*) of length less than four.
Length 0: none, since there must be at least one
b
.
Length 1:
b
Length 2:
ab
,
bb
,
ba
(
aa
is not possible)
Length 3:
aab
,
aba
,
abb
,
baa
,
bab
,
bba
,
bbb
.
(
aaa
is not possible)
2.
Does the expression ((0+1)(0+1)*)*00(0+1)* denote the language of strings
w
such that
w
has at least
one pair of consecutive zeros?
This requires you to understand basic things about regular expressions.
x x
* represents one or more
x
’s.
So (0+1)(0+1)* represents items, each one of which is either a 0 or a 1.
So this is all strings of zeros and
ones of length 1 or greater.
But when you apply * to this expression, you are now including
λ
making
the expression ((0+1)(0+1)*)* the same as (0+1)*.
So the expression as a whole represents any string
that consists of 0’s and 1’s with a 00 somewhere in it.
Therefore the answer to this question is YES.
3.
Show that
r
= (1 + 01)*(0 + 1*) also denotes the language of strings
w
such that
w
has no pair of
consecutive zeros.
Find two other expressions for this language.
It should be clear that (1 + 01)* forces every 0 to be followed by a 1, which is usually necessary for this
language.
The only exceptions are a 0 at the very end of the string, or any string that has no 0’s (all 1’s).
So this expression DOES represent the language in question.
Other possibilities might be
(1 + 01)*(0 +
λ
) + 1*
or
(1 + 01)* + (1 + 01)*0 + 1*
4.
Find a regular expression for {
a
n
b
m
:
n
≥ 3,
m
is even}.
n
≥ 3 can be represented by the expression (
aaa
)
a*
or, more, simply
aaaa*
and
m
is even can be
represented by the expression
(
bb
)*.
So, overall, the expression
aaaa
*(
bb
)* would represent this
language.
5.
Find a regular expression for {
a
n
b
m
: (
n
+
m
) is even}.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '10
 Icamarra
 Formal language, Regular expression, Regular language, Formal grammar

Click to edit the document details