0% found this document useful (0 votes)
57 views3 pages

Homework Solutions 1

This document contains the solutions to homework problems about formal language theory from a foundations of computer science course. It defines various sets and languages, then solves problems involving set operations on those languages like union, intersection, concatenation, Kleene star and plus operations. It proves properties of Kleene star and plus, showing they are equal if and only if the empty string is in the set.

Uploaded by

Johnny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views3 pages

Homework Solutions 1

This document contains the solutions to homework problems about formal language theory from a foundations of computer science course. It defines various sets and languages, then solves problems involving set operations on those languages like union, intersection, concatenation, Kleene star and plus operations. It proves properties of Kleene star and plus, showing they are equal if and only if the empty string is in the set.

Uploaded by

Johnny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CS 341: Foundations of Computer Science II

Prof. Marvin Nakayama

Homework 1 Solutions

1. We are given the sets

C = {ε, aab, baa},


D = {bb, aab},
E = {ε},
F = ∅.

(a) D ∪ C = {ε, bb, aab, baa}


(b) C ∪ F = {ε, aab, baa} = C
(c) C × D = { (ε, bb), (ε, aab), (aab, bb), (aab, aab), (baa, bb), (baa, aab) }
(d) C ∩ D = {aab}
(e) D ◦ C = {bb, aab, bbaab, bbbaa, aabaab, aabbaa}
(f) C ◦ E = {ε, aab, baa}
(g) D◦D◦D = {bbbbbb, aabbbbb, bbaabbb, bbbbaab, aabaabbb, aabbbaab, bbaabaab,
aabaabaab}
(h) P(C) = { ∅, {ε}, {aab}, {baa}, {ε, aab}, {ε, baa}, {aab, baa}, {ε, aab, baa} }
(i) D − C = {bb}
(j) C + = {ε, aab, baa, aabaab, aabbaa, baaaab, baabaa, aabaabaab, . . .}
(k) F ∗ = {ε}
(l) E ⊆ C since every element of E is also in C.
(m) D 6⊆ C since bb ∈ D but bb 6∈ C.
(n) ˆ C is closed under reversal since εR = ε ∈ C, (aab)R = baa ∈ C, and
(baa)R = aab ∈ C.
ˆ D is not closed under reversal since (aab)R = baa 6∈ D.
ˆ E is closed under reversal since εR = ε ∈ E.

2. (a) It is not true in general that w ∈ S. For example, suppose that w = aa,
S = {a}, and T = {a, aa}. Then note that T = S ∪ {aa}, and S ∗ = T ∗ =
{ε, a, aa, aaa, . . .}, but aa 6∈ S.
(b) It must be the case that w ∈ S ∗ . Note that w ∈ T , so w ∈ T ∗ since any word in
T is also in T ∗ because T ⊂ T ∗ . But since T ∗ = S ∗ , we must have that w ∈ S ∗ .

1
3. (a) Let S = {ε, a}. Then S ∗ = {ε, a, aa, aaa, . . .} and S + = {ε, a, aa, aaa, . . .},
so S ∗ = S + .
(b) Let S = {a}. Then S ∗ = {ε, a, aa, aaa, . . .} and S + = {a, aa, aaa, . . .}, so
S ∗ 6= S + .
(c) Let S = {ε, a, aa, aaa, . . .}. Then S ∗ = {ε, a, aa, aaa, . . .}, so S = S ∗ .
(d) Let S = {a}. Then S ∗ = {ε, a, aa, aaa, . . .}, so S 6= S ∗ .
(e) Let S = {ε}. Then S ∗ = {ε}, so S ∗ is finite.
4. (a) Recall that for any set A, we let |A| denote the number of elements in A. Let
Σ1 = {a, b, . . . , z, A, B, . . . , Z} be the set of upper-case and lower-case Roman
letters, and note that |Σ1 | = 52. Let Σ2 = {0, 1, 2, . . . , 9}, which is the set
of Arabic numerals, and note that |Σ2 | = 10. Let Σ3 = Σ1 ∪ Σ2 . Since
Σ1 ∩ Σ2 = ∅, |Σ3 | = |Σ1 | + |Σ2 | = 62.
Let Li be all of the strings of length i in L0 . Note that L1 consists of all 1-letter
strings in L0 , so L1 consists of all the single letters in Σ1 , and |L1 | = 52. Also,
L2 consists of all 2-letter strings in L0 , and if w ∈ L2 , then the first letter of w is
from Σ1 , and the second letter of w is from Σ3 , so |L2 | = 52 × 62. In general
Li consists of all words that have first letter from Σ1 and the remaining i − 1
letters from Σ3 , so |Li | = 52 × 62i−1 .
Note that
L0 = L1 ∪ L2 ∪ · · · ∪ L8 .
Also, Li and Lj are disjoint for i 6= j, so
8
X
|L0 | = |L1 | + |L2 | + · · · + |L8 | = 52 × 62i−1 .
i=1

(b) Note that L ⊂ L0 , so we must have that |L| ≤ |L0 |. In the previous part, we
showed that |L0 | < ∞, so we must have that |L| < ∞.
5. Recall the definitions
S ∗ = { x1 x2 · · · xk | k ≥ 0 and each xi ∈ S },
S + = { x1 x2 · · · xk | k ≥ 1 and each xi ∈ S },
where the concatenation of k = 0 strings is ε, so we always have ε ∈ S ∗ .
Before we prove what is required, we first show that S + ⊆ S ∗ . If w ∈ S + , then the
definition of S + ensures that there exists k ≥ 1 and strings x1 ∈ S, x2 ∈ S, . . . ,
xk ∈ S such that w = x1 x2 · · · xk . Because this k also satisfies k ≥ 0, using the
same x1 , x2 , . . . , xk shows that w ∈ S ∗ . As w ∈ S + was arbitrary, we then have that
S + ⊆ S ∗.
Recall that two sets are equal if and only if each is a subset of the other. Thus,
because S + ⊆ S ∗ , we have that S ∗ = S + if and only if S ∗ ⊆ S + . Thus, proving that
S ∗ = S + if and only if ε ∈ S is equivalent to proving that S ∗ ⊆ S + if and only if
ε ∈ S. Establishing this requires proving two things:

2
ˆ If S ∗ ⊆ S + , then ε ∈ S; and
ˆ If ε ∈ S, then S ∗ ⊆ S + .

To prove the second part, suppose that ε ∈ S, which implies that ε ∈ S + . Consider
any w ∈ S ∗ , and we need to show that w ∈ S + . Because w ∈ S ∗ , the definition of S ∗
implies that w = x1 x2 · · · xk for some k ≥ 0 and each xi ∈ S. If k = 0, then w = ε,
and we have that w ∈ S + , as noted earlier. If k ≥ 1, then the same x1 , x2 , . . . , xk
show that w ∈ S + . Hence, we have proven that ε ∈ S implies that S ∗ ⊆ S + .
The first part is logically equivalent to its contrapositive: If ε 6∈ S, then S ∗ 6⊆ S + .
To prove the contrapositive, suppose that ε 6∈ S. Then ε 6∈ S + because we cannot
concatenate a strictly positive number of nonempty strings to end up with ε. But
ε ∈ S ∗ , so we have that ε 6∈ S implies that S ∗ 6⊆ S + , completing the proof.

You might also like