CSCE 235
Homework
Assignment 4 (with Programming) – Solution
Assigned: February 6, 2009
Due: 12:30 p.m. February 16,
2009
Set Basics
1. (10 points) List all members of the following sets.
(a) ![]()
(b) ![]()
(c)
where
is the set of all
positive numbers
(d)
where
is the set of all
positive numbers
(e)
where
is the set of all
positive numbers
Solution
(a)
![]()
(b)
When n = 0,
;
n = 1,
;
n = 2,
;
n = 3,
;
n = 4,
.
{ 0, 0, 6, 24, 60 }
(c)
When n is even,
is 1, and thus
. When n is
odd,
is -1, and thus
. Thus,
= {1, 3}.
(d) The valid n values are 2, 4, 6, 8, and 10. So, we have {1/4, 1/16, 1/36. 1/64, 1/100 }.
(e) The valid n values are 2, 3, 5, 7, 11, and 13. So we have { 2, 3, 5, 7, 11, 13 }.
![]()
2. (10 points) Consider the following six subsets of Z. (Definition:
Z = the set of all integers = ( …, -3, -2, -1, 0,
1, 2, 3, …}.)
A = { 2m + 1 |
m Î Z }
B = { 2n + 3 |
n Î Z }
C = { 2p -3 | p
Î Z }
D = { 3r + 1 | r
Î Z }
E = { 3s + 2 | s
Î Z }
F
= { 3t
- 4 | t Î Z
}
Which
of the following statements are true and which are false? Show your reasons.
(a) A = B
(b) A = C
(c) B = C
(d) D = E
(e) D = F
(f) E = F
Solution
First, let us enumerate the members of each
set.
A = { 2m + 1 |
m Î Z } = { …, -5, -3, -1, 1, 3, 5, 7, …}
B = { 2n + 3 |
n Î Z } = { …, -3, -1, 1, 3, 5, 7, 9, …}
C = { 2p - 3 | p Î Z } = { …, -9, -7, -5, -3, -1, 1, 3,
…}
D = { 3r + 1 |
r Î Z } = { …, -8, -5, -2, 1, 4, 7, 10, … }
E = { 3s + 2 |
s Î Z } = { …, -7, -4, -1, 2, 5, 8, 11, … }
F
= { 3t
- 4 | t Î Z
} = { …, -13, -10, -7, -4, -1, 2, 5,
… }
( …, -3, -2, -1, 0, 1, 2, 3, …}.)
(a) A
= B. This is true.
(b)
A = C.
This is true.
(c)
B = C.
This is true.
(d)
D = E.
This is false.
(e) D = F. This is true.
(f) E = F. This is true.
Note that there are several ways to approach this question. The above is basically enumerating the members of each set and then just comparing the sets. Another way is as follows:
(a) Consider x in A. Then x = 2m + 1. Or, x = 2m - 2 + 2 + 1 = 2(m
– 1) + 2 + 1 = 2(m – 1) + 3.
Since m Î Z,
m-1 Î Z
too. And thus, we can rewrite the
equation as x = 2n + 1 for n Î Z, or A = { 2n + 3 | n Î Z }. And now, A = B.
The proofs for (b)-(f) are similar to the
above.
![]()
Set Operations
3. Application of
Knowledge (21 points) Consider an alphabet Σ = {
a, b }. It has only two letters. A word (or w) is any finite
string of letters that you can form out of the alphabet. For example, abba is a word formed
using only the letters from the alphabet Σ. The collection of all words is called a language,
and is denoted as
. For example,
= {
ε, a, aa, ab, ba, bb, aaa, aab, abb, bbb, bba, baa, …}. And
is an infinite
set! The symbol ε denotes the empty
word or null word.
Now, suppose Σ = { a, b }; A = {a, b, aa, bb, aaa, bbb }; B = {
: length(w) ≥ 2}; and C = {
: length(w) ≤ 2}. (Hint: Don’t forget the empty word ε,
which has a length of zero!) List all
members of the following:
(a) ![]()
(b) ![]()
(c) ![]()
(d) ![]()
(e) ![]()
(f) ![]()
(g) power set of Σ
Solution
First, we list B = { ab, aa, ba, bb, aaa, aab, abb, bbb, bba, baa, …}.
Then, we list C = { ε, a, b, aa, ab, ba, bb }.
(a)
= { a, b, bb, aa }
(b)
= { aaa, bbb }
(c)
= { ε, ab, ba }
(d)
= { ε, ab, ba, aaa, bbb }
(e)
= {
aa, bb, aaa, bbb }
(f)
= { aa, ab, ba, bb }
(h) The set Σ = { a , b }. So the power set of Σ is { {}, {a}, {b}, {a, b} }.
![]()
4. (15 points) True or False (if false, show an example; if true, explain):
(a)
for
all A, B, and C.
(b) If
A = B, then
is
.
(c)
for
all A and B.
(d)
whenever
.
(e)
for
all A and B.
Solution
(a) False. For example, suppose A = {1}, B
= {1,2}, and C = {4}. Then
=
= {1}, and
=
={1, 4}. So, the two sets are different.
(b) True. If A = B is true, then
. Thus, we have
. According to the
identity laws, the intersection of a set and its complement is an empty
set.
(c) False. For example, suppose A = {1}, and B
= {2}.
equals
to
= {1, 2}. But that is
different from B.
(d) True. According to the identity laws,
. So, we have
. Since
,
!
(e) False. Suppose U = {1,2,3,4,5}, A
={1,2}, and B = {2,3}. So
= {3,4,5} and
= {1,4,5}. And given
the two sets, we know that
= {4, 5}. Now,
= {2}, and
= {1, 3, 4, 5}.
Therefore
for all A and
B.
![]()
5. (9 points) Prove the following formally, without using Venn diagrams:
(a) (5 points)
for any sets of A,
B, and C.
(Hint: Use the fact
.)
(b) (4
points) If
and
, then
.
Solution
(a) Using
the fact
,
Using the set
distributive law, we have
. Using the De
Morgan’s law, we have
. And with this, we
can use the same fact again:
. Thus, we have shown
that
for any sets of A,
B, and C.
(b) To
show “if
and
, then
”, consider an element x in A,
. If
, then x is also a member of B,
. Similarly, if
, then x is also a member of C,
. So, if
and
, then
and
. Thus,
. Therefore, if
and
, then
.
![]()
Binary Relations
6. (20 points) Determine whether or not each of the
binary relations
defined on the given
sets A are reflexive, symmetric, or transitive. If a relation has a certain property, prove
this is so; otherwise, provide a counterexample to show that it does not. Determine also whether a relation is equivalence.
(a)
A = { 3, 4 };
= { (3, 3), (4, 4)}
(b)
A is the set of all humans;
if and only if
where
means “a is the parent of b.”
(c)
A is the set of integers, Z;
if and only if
is even.
(d)
A is the set of cross products of integers, Z×Z;
if and only if
.
(e)
A is the set of all humans;
if and only if
where
means “a and b are both fans of the same
musician.” Assume that a human may be a
fan of more than one musician.
Solution
(a) Reflexive, since both (3,3) and (4,4) are part of the relation.
Symmetric, since we cannot find a counter example such as “(3, 4) and no (4, 3).”
Transitive, since we cannot find a counter example such as “(3, 4) & (4, 3) and no (4, 4).”
The relation is reflexive, symmetric, and transitive. It is an equivalence.
(b)
Not Reflexive, since a person cannot be a parent
of himself or herself.
does
not exist.
Not Symmetric,
since if
, then
does not exist. If a person a is
a parent of another person b, then that person b cannot be a
parent of the person a.
Not
Transitive, since if
, and
,
does not exist. If a person a is
a parent of another person b, and that person b is a parent of
yet another person c, then a is the grandparent of c. a cannot be
the parent of c.
Not Equivalence, since the relation does not satisfy all the above three properties.
(c) Not Reflexive, since, for example, 1*1 = 1 which is odd. So, (1,1) is not part of the relation.
Symmetric. If
, then that means
is even. By the commutative law of mathematics,
=
. So, if
is even, then
is also even. So, if
, then we are guaranteed to have
.
Transitive. If
is even, and
is also even, then we
know that all a, b, and c are even. Thus, ac must also be even. As a result, we can conclude that if
and
, then
.
Not Equivalence, since the relation does not satisfy all the above three properties.
(d)
Reflexive, since
. This is because
is always true.
Symmetric,
since
is always true. This is because
always yields the same
result as
.
Transitive.
Suppose we have
such that we know
and
. If we add c – m to
, we have
. Since
, we can transform the equation to
. Then we can reduce
the equation to
. Thus, we have an element
. Since for every pair
,
is also in
. The relation
is transitive.
Equivalence. The relation satisfies all three of the above properties.
(e) A is the set of all humans;
if and only if
where
means “a and b are both fans of the same
musician.” Assume that a human may be a
fan of more than one musician.
Reflexive,
since
is always part of the
relation. If I am a fan of Eric Clapton,
then I am also a fan of Eric Clapton.
Symmetric,
since if
, then
too.
Not transitive. For example, suppose there are three
fans: Adam, Belle, and Charlie. Adam is a fan of Britney Spears; Belle is a
fan of Britney Spears and YoYo Ma.
Charlie is a fan of YoYo Ma. So,
we have
, and
; but we do not have
! Adam and Charlie do
not have a common musician that they are fans of.
Not Equivalence, since the relation does not satisfy all the above three properties.
![]()
7. (24 points) Given the following relations:
.
.
.
.
Solution
First, let us look at the four relations.
. Since a sum of two
numbers is odd only when one of the number is odd and the other is even, we
know that
consists of (1, 2),
(1,4), (3,6), and so on.
. Similarly, a sum of
two numbers is even only when (a) both numbers are even or (b) both numbers are
odd. So, we know that
consists of (1,1),
(2,2), (3,1), (5,9), and so on.
. Since a product of
two numbers is odd only when both numbers are odd, we know that
consists of (1,1),
(3,5), (9,17), and so on.
. For a product of
two numbers to be even, one of the numbers must be even. So, we know that
consists of (1,4),
(2,3), (10,2), and so on.
List 5 members for each of the following sets; if not possible, explain.
(a)
This is an empty
set.
requires one of the
numbers to be even;
requires both to be
even. So, the intersection is empty.
(b)
5 members: (1,4), (2,3), (10,2), (3,6), (2,2)
(c)
5 members: (2,2),
(2,4), (4,6), (4,4), (4,8)
(d)
5 members: (1,4),
(2,3), (10,2), (9,17), (1,1)
(e)
Since
and
do not intersect,
=
. So, 5 members:
(1,2), (1,4), (3,6), (5, 6), (6, 5)
(f)
As we see from the
answer to part (c), we know that
and
intersect. So, out of
the members for
, we need to filter out members that also satisfy
. To satisfy
, basically the two numbers have to be even or both have to
be odd. The latter case cannot exist
within
. So, we only have to
make sure that we filter out all members that have both numbers even. So, 5 members: (1,4), (2,3), (3,2), (5,6),
(2,9).
(g)
This is exclusive
or.
requires one even
number and one odd number.
requires at least one
even number. And since
is a subset of
. So, to be exclusive,
we consider for
only the members that
have two even numbers. 5 members: (2,2),
(4,2), (10,2), (2,6), (4,4).
(h)
This is exclusive
or.
requires either both
even numbers or both odd numbers.
requires both numbers
to be odd. So, once again, we have a
scenario where
is a subset of
. To be exclusive, we
only consider the members that have two even numbers. 5 members: (2,2), (4,2), (10,2), (2,6),
(4,4).
![]()
Equivalence Relations and Partitions
8. (6 points)
Let A be the set of all students in the CSCE235 class. For
, define
when a is
taller than or as tall as b. Is
an equivalence
relation? Why?
Note that
is a binary relation
on A×A such that
{(a,b)
: a is as taller than or as tall as b
}.
Now, we have to show that whether
is reflexive,
symmetric and transitive to prove whether
an equivalence
relation. First, every student is as
tall as him or herself. So, the relation
is reflexive. Second, if (a,b),
then it is possible for (b,a) to not be true. That is, if person a is taller than b, then b cannot be taller than a.
Thus, we now know that the relation is not symmetric. And thus,
is not an equivalence
relation.
![]()
9. (15 points) A partition of a set A is a collection of disjoint nonempty subsets of A whose union is A. These disjoint sets are called cells (or blocks). Suppose that A has the following cells: m, n, o, and p.
(a) What
is
?
(b) What
is
?
(c) Is
? Why?
(d) What
is
?
(e) What
is
?
(a)
since all cells are disjoint.
(b)
since all cells are disjoint.
(c)
is true. The “exclusive
or” is the same as “or” when the two sets involved are disjoint.
(d)
.
(e)
. This is because the
intersection of the two cells is an empty set and the complement of an empty
set is the set itself.
![]()
Programming
10. (50 points) Toolbox.
Implement a relation-based toolbox to determine whether a binary
relation is reflexive, symmetric, or transitive.