Answers to Homework #3

Answers to Homework #3
CSCI 2670 Introduction to Theory of Computing, Fall 2016
Due Tuesday September 27, 2016
The First Midterm date: Tuesday November 4, 2016
This homework assignment is about conversion between NFAs and regular
expressions, Pumping lemma, and non-regular languages.
Grading:
point distribution: 1: 30 points, 2: 30 points, 3: 15 points, 4: 15 points, 5: 10 points.
1
1. Question 1.21 (a) and (b) on page 86 (about converting DFAs to regular expressions).
Answers:
Answers are not unique depending on the order of states being removed.
(a) (15 points)
(b) (15 points)
2. Question 1.28 (a) and (b) on page 88 (about converting regular expressions to NFAs).
Answers:
(a) a(abb)∗ ∪ b (15 points)
Steps:
(1) build an NFA for a;
(2) build an NFA for b;
(3) build an NFA for ab by concatenation of (1) and (2);
(4) build an NFA for abb by concatenation of (3) and (2);
(5) build an NFA for (abb)∗ by star on (4);
(6) build an NFA for a(abb)∗ by concatenation of (1) and (5);
(7) build an NFA for a(abb)∗ ∪ b by union of (6) and (2).
(b) a+ ∪ (ab)+ (15 points)
Because a+ = aa∗ ,
Steps:
(1) build an NFA for a;
(2) build an NFA for a∗ by star on (1);
(3) build an NFA for a+ , which is aa∗ , by concatenation of (1) and (2);
(4) build an NFA for b;
(5) build an NFA for ab by concatenation of (1) and (4);
(6) build an NFA for (ab)∗ by star on (5);
(7) build an NFA for (ab)+ , which is (ab)(ab)∗ , by concatenation of (5) and (6)
(8) build an NFA for a+ ∪ (ab)+ by union of (3) and (7)
3. Use the Pumping Lemma to prove that language
L = {ww−1 : w ∈ {0, 1}∗ }
is not a regular language, where w−1 represents the reverse of string w.
Proof: (15 points)
We use proof by contradiction. That is to assume the L is regular.
Then by the Pumping lemma, there is an integer p.
We choose a string s = 0p 110p . We know that s ∈ L because s = ww−1 , where
w = 0p 1 and w−1 = 10p .
The length |s| = p + 1 + 1 + p = 2p + 2 > p. According to the lemma, s can be written
as concatenation of x, y, x, i.e., s = xyz for some x, y, z, and consequences:
(1) xy i z ∈ L for every i ≥ 0;
(2) |y| > 0;
(3) |xy| ≤ p.
Now by (3), xy have to be a string of all 0’s. So y is a string of all 0’s. In addition,
because of (2), y contains at least one 0 symbol. So we let y = 0k for some k ≥ 1 and
x = 0l for some l ≥ 0. Therefore, z = 0p−k−l 110p .
On one hand, using (1), we choose i = 2, we have xy 2 z ∈ L.
On the other hand, however, xy 2 z = 0l y 2 z = 0l (0k )2 z = 0l (0k )2 0p−k−l 110p = 0l+2k 0p−k−l 110p =
0p+k 110p
Because k ≥ 1, xy 2 z, which is 0p+k 110p , is not in the form of ww−1 for any w.
So we have xy 2 z 6∈ L. This leads to a contradiction.
Thus the assumption that L was regular was incorrect. L is thus proved to be non
regular.
4. Use the Pumping Lemma to prove that language
Sum = {0i 10j 1i+j : integers i ≥ 0, j ≥ 0}
is not a regular language.
Proof: (15 points)
The proof goes very similar to the proof for Q4. The critical part is to choose string
s. Some good candidates are
0p 10p 12p , 0p 101p+1 , 0p 11p
where the first string has i = j = p, the second has i = p, j = 1, and the third
i = p, j = 0.
All these examples have 0p as a prefix in a chosen string s because this would give a
y that contains all 0’s when the Lemma is applied. This makes argument in the proof
easier.
5. Question 1.30 on page 88 (to describe the error in a ”proof” that 0∗ 1∗ is not a regular
language).
Answer: (10 points)
First, here is the ”proof”:
The Proof is by contradiction. Assume that 0∗ 1∗ is regular. Let p be the pumping
length for 0∗ 1∗ given by the lemma. Choose string s to be 0p 1p . We know that s is a
member of 0∗ 1∗ , but by Example 1.73 shows that s cannot be pumped. Thus you have
a contradiction. So 0∗ 1∗ is not regular.
We examine example 1.73 (page 80), which gives a proof that language B = {0n 1n |n ≥
0} is not regular. It concludes that 0p 1p cannot be pumped with respect to the
language B, not with respect to language 0∗ 1∗ . Actually, pumped strings from
0p 1p are all belong to language 0∗ 1∗ .