CSCE 235
Homework
Assignment 4 (with Programming)
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
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? Justify your answers.
(a) A = B
(b) A = C
(c) B = C
(d) D = E
(e) D = F
(f) E = F
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 Σ
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.
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
.
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.
7. (24 points) Given the following relations:
.
.
.
.
List 5 members for each of the following sets and justify; if not possible, explain.
(a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)
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? Justify your answer.
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
?
Programming
10. (50 points) Toolbox. Implement a relation-based toolbox to
determine whether a binary relation is reflexive, symmetric, or
transitive. Your program should be able
to read in a text file similar to the following. Each line represents the members of one
binary relation. So, in the above
example, the binary relation R1 has 5 members, i.e., { (a,a), (b,c), (c,b),
(b,b), (c,c) }. Thus, for R1, it is reflexive, symmetric, and
transitive.
5 a a b c c b b
b c c
6 a b b c c d d
c b d d d
8 j m m j g b a m m a b g g l l g
END
Your
output should look like this:
reflexive
symmetric transitive
n-reflexive
n-symmetric n-transitive
n-reflexive
symmetric n-transitive
END
Your program will be tested with an
input file with the specified format but with different data. (On our
course website, there is a C and a Java program on how to read data from a
file. If you choose to use any of these
programs, please clearly acknowledge the use in your documentation.) Write your program with good documentation
and style. Hand in your program before
12:30 p.m., February 16 to our class Handin account. If your program is complicated and involves
multiple files, please also include a README file on how to run it. I expect that a single program file will be
sufficient for this problem.
CSE
Web Handin
Registration
You have to register with Handin
before you use it for the first time. To register, choose the
"Register" link from the menu on the left. Input your CSE username
along with a password (NOT your CSE password) on the registration page, and
click the "Register" button at the bottom of the page to finish the
process. You will then receive mail on CSE to confirm your registration.
Handing In
To hand in an assignment, go to CSE235 class's handin
web page (http://cse.unl.edu/~cse235/handin)
and fill out the form on that page. Use your CSE username and your Handin password. Be sure to choose the correct assignment
to hand the files in under, and choose the files you wish to hand in with the
file choosers at the bottom. If you need to hand in more files than there are
selection boxes, hand them in two (or more) separate batches. For example, if
you need to hand in the files file1.c,
file2.c, file3.c, file4.c, file5.c, and file6.c, but handin only lets you hand in
five files at a time, hand in file1.c
through file5.c as one group and file6.c by itself. After each handin you will be shown a list of all of the files you
have handed in up to that point.
Checking a previous handin
If ever you want to check the status of a previous handin
("Did I really hand in those files?"), you can go to your class's handin page and choose "Check Status" from the handin choices. After making that choice, filling in your
username and password, and choosing an assignment to check up on, click the
Submit button at the bottom of the page. You will then be presented with a list
of all of the files you have handed in for that particular assignment, along
with their sizes and the time/day you handed them in.
Changing your password
Changing your password on occasion can be a good idea.
To change your password, choose the "Password" link from the menu on
the left. Fill out the "Change user password" form with your
username, current password, and the new password you would like. The change
will take effect immediately after you submit it, and you will also be sent a
piece of email on CSE confirming the change.
Forgotten password
If you forget your password, Handin
can send it to you at your CSE email address. To receive your password, choose
the "Password" link from the menu on the left and fill out the
"Send user password" form with your username. After you submit the
form you will receive mail on CSE with your Handin
password.