Sei sulla pagina 1di 5

124ms Logic and Sets

Tutorial Sheet 2: Sets, predicates, and functions


Topics covered: sets, predicates, quantifiers, functions and relations.

1. If X = { a, b, c}, then

(a) Which of (i) a X, (ii) a X, (iii) { a} X, (iv) { a} X is true?


(b) List all the subsets of X.

2. If A = {1, 3, 5, 7, 9}, B = {2, 4, 6, 8, 10}, and C = {3, 4, 5, 6}, then:

(a) Suggest a suitable universal set, and draw a Venn diagram for this situation.
(b) Find each of A B, A C, B C, A ( B C ), ( A B) C, A \ B, and B \ C.
(c) Say which of the above sets is a subset of the other.

3. A directory contains a set of large files, L = { f 1, f 2, f 3}, and set of data files, D =
{d1, f 2, a1000}, and a set of text files T = {t1, t2, f 1, f 2}.
(a) Give a set expression for the set of large data files, and write the set out.
(b) Repeat for the set of text files which are not large.
(c) Repeat for the set of large data files which are plain text.
(d) Repear for the set of text files which are neither large nor data files.

4. Prove each of the following identities by means of Venn diagrams.

(a) A A0 = U
(b) A A0 =
(c) ( A B)0 = A0 B0
(d) A ( B C ) = ( A B) ( A C )
(e) ( A B) \ ( A B) = ( A \ B) ( B \ A)

5. Given that | A B| = | A| + | B| | A B|, show that

| A B C | = | A | + | B | + | C | | A B | | B C | | C A | + | A B C |.

6. Out of 60 computers, 25 run Windows and 40 run Linux. If each computer runs at least
one of these operating systems, how many run both?

7. Following a phone in survey survey on the use Web browsers and chat rooms of 135
people, the surveyors conclude that 69 of them use browsers, 84 of them use chat rooms
to some extent, while 60 use browsers but not chat rooms. Do you believe these results?

8. Out of 214 computers with viruses, each of which is infected with at least one of Magistr,
Badtrans and Hybrid, 79 have Magistr, 111 Badtrans, and 82 Hybrid. 16 have Magistr
and Badtrans, 29 Badtrans and Hybrid, and 22 have Magistr and Hybrid. (i) How many
have all three viruses? (ii) How many have exactly two? (iii) How many have just one
of these viruses?

1
9. A company who wanted to develop its internet presence had 27 of its employees each
investigate at least one of AOL, Demon, and BT. If 14 investigated AOL, 16 investigated
BT, and 8 investigated Demon, while 1 investigated AOL and Demon, 5 investigated
AOL and 5 investigated BT and Demon, how many investigated all three?
10. Of 46 malicious hackers, each of whom writes at least one of boot sector, parasitic and
macro viruses (see

http://www.uk.sophos.com/virusinfo/whitepapers/videmys.html

for explanations) 6 only write boot sector viruses, 9 only write parasitic viruses, and 27
will write macro viruses. How many will write boot sector and parasitic, but not macro
viruses?
11. How many subsets does a set containing n elements have?
12. Construct a membership table for each of the following expressions:
(a) ( X (Y Z ))0
(b) ( X Y ) ( X Y 0 )
(c) X (Y Z )0
(d) X (Y X 0 )
(e) ( X Y ) ( X ( Z Y 0 ))
(f) X Y ( X 0 Y 0 )
(g) ( X Y 0 ) Z 0
13. Establish each of the following equalities
(a) ( A ( B C ))0 = A0 ( B0 C 0 )
(b) ( A ( B C ))0 = ( A0 B0 ) C 0
(c) ( A B) ( A B0 ) = A
(d) A ( B C )0 = ( A B0 ) C 0
(e) A ( B A0 ) = A B
(f) A ( A B) = A B
(g) ( A B) ( A (C B0 )) = A ( B C )
(h) A B ( A0 B0 ) = U
(i) ( A0 B) ( A B0 ) =
(j) ( A B0 ) C 0 = A ( B C )0
(k) ( A B0 ) C 0 = ( A C 0 ) B0
(l) ( A B0 ) C 0 = ( A C 0 ) ( B C 0 )0
14. Sometimes we want to consider all those objects which are in just one of a pair of sets,
without being in both; the set equivalent of an exlusive or. Although this combination
is not one of the standard ones we work with, we can show by means of a truth table
that it has properties like those of union and intersection. To this end, define A B =
( A B ) \ ( A B ).

2
(a) Construct the membership table for A B.
(b) Show that A B = B A
(c) Show that A ( B C ) = ( A B) C

15. Use a hybrid membership/truth table to show that

(a) A B = B iff A B
(b) A B = A iff A B
(c) A B = B iff A B = A
(d) A ( B C ) C if B C

16. How many rows does a membership table for an expression involving n sets have?

17. Consider a universe, C consisting of all people in a courtroom. We have predicates J, L,


H, I, D, P, S and A given by: J ( x ) is true if x is a judge, L( x ) is true if x is a lawyer, H ( x )
is true if x is honest, I ( x ) is true if x is innocent, D ( x ) is true if x is a defendant , P( x ) is
true if x is a plaintiff, and S( x ) is true if x is sober.

(a) Express the following using the language of predicate calculus, where it is un-
derstood that the people being discussed are in the courtroom. If any sentence is
ambiguous, give all possible symbolic versions.
i. All judges are sober.
ii. There is a dishonest lawyer.
iii. All lawyers are honest.
iv. All defendants are innocent.
v. Some plaintiffs are lawyers.
vi. Some defendants are dishonest lawyers.
vii. Anybody who is honest and a defendant is innocent.
viii. All defendants who are not sober are dishonest.
(b) Express the following in normal English:
i. x C : J ( x ) S( x )
ii. x C : H ( x ) L( x ) S( x )
iii. x C : P( x ) D ( x )
iv. x C : J ( x ) S( x )
v. x C : ( H ( x ) S( x ))
vi. x C : ( P( x ) D ( x )
(c) Give the negation of each statement in the above two parts of the question, both in
symbolic form and in natural English.

18. Consider the following argument

All the students in my class are intelligent and hard-working. All intelli-
gent students organize their time carefully. All hard-working students pass
the exam. Therefore all the students in my class organize their time carefully
and pass the exam.

3
Taking as universe U, the set of students in my class, consider the predicates I, H, O,
and P given by: I ( x ) is true if x is intelligent, H ( x ) is true if x is hard-working, O( x ) is
true if x organizes his time carefully and P( x ) is true if x passes the exam. Use these to
express the hypotheses and conclusion of the argument using the language of predicate
calculus.

19. Given the arguments

(a) Everybody in the room is bright or attentive. Everybody in the room


who is bright has the sense to take notes. Everybody who has the sense
to take notes can be well-prepared for the exam. Somebody in the room
cannot be well-prepared for the exam. Therefore, somebody in the room
is attentive.
(b) All lecturers are well-informed and helpful. All well-informed lectur-
ers prepare their classes well. Every lecturer who prepares his classes well
has appropriate handouts and keeps to time. All helpful lecturers keep
office hours. Everybody who has appropriate handouts and keeps office
hours runs the risk of being taken advantage of by students who dont turn
up to class. Therefore all lecturers run the risk of being taken advantage
of by students who dont turn up to class.
(c) All tutorial examples are complicated or artificial but helpful. All help-
ful tutorial examples can be attempted with profit. All tutorial examples
that can be attempted with profit are compulsory. Example 2 on sheet 3 is
not complicated. Therefore Example 2 on Sheet 3 is compulsory.

find a suitable universal set and predicates for each, and express the hypotheses and
conclusions in the language of predicate calculus.

20. Give appropriate pre- and post-conditions for a program segment that initialises all the
elements of the array a[1..N] to be zero.

21. Give appropriate pre- post-conditions for a program segment that puts the elements of
the array a[1..N] in decreasing order.

22. (Harder) Given apropriate pre- and post-conditions for a program segment that, given
an array a[1..N] produces an array b[1..M] containing the same elements as a but with
no duplicates.

23. Given the sets A = {1, 2, 3, 4}, B = { x, y, z, w} and C = { a, b, c}, and functions f : A
B defined by f (1) = y, f (2) = w, f (3) = z, f (4) = x, g : C A defined by g( a) = 2,
g(b) = 3, g(c) = 4, and h : A C defined by h(1) = a, h(2) = c, h(3) = a, h(4) = b:

(a) Express each of the functions by means of (i) an arrow diagram, and (ii) a set of
ordered pairs.
(b) Find the composition of each pair of functions when this composition makes sense.
(c) Classify all the functions above and all the compositions you have obtained as
injective, surjective, bijective, or none of these. Give the inverse of any bijective
function.

4
24. The function f : { a, b, c} {00, 01, 11, 10} given by f ( a) = 00, f (b) = 01, f (c) = 00 is
to be used as a means of representing character strings via binary strings.
(a) Is the function injective? Does this matter?
(b) Is the function surjective? Does this matter?
(c) How might you alter the function to make it more useful as a coding scheme?
25. (More mathematical) Consider each of the following functions. Show whether it is in-
jective, surjective, neither, or bijective. For the bijective functions, find the inverse.
(a) f : R R, f ( x ) = cos( x )
(b) f : R R, f ( x ) = 1 + x3
(c) f : R R, f ( x ) = 1 x2 + x3
2
(d) f : R R, f ( x ) = xe x
(e) f : R2 R, f ( x, y) = x + y
(f) f : R2 R2 , f ( x, y) = ( x + y, ey )
(g) f : R2 R2 , f ( x, y) = ( x, y3 xy)
(h) f : R2 R2 , f ( x, y) = ( x + y, x 2y)
(i) f : R2 R2 , f ( x, y) = ( x y, 2x 2y)
26. Sketch each of the following relations on {1, 2, 3, 4} { a, b, c, d}:
(a) {(1, a), (2, a), (3, a), (4, a)}
(b) {(1, a), (1, b), (2, c), (3, a), (4, a)}
(c) {(1, d), (2, b), (3, a), (4, c)}
(d) {(1, a), (2, c), (4, a)}
Explain which are functions, and classify the functions in terms of injectivity, surjectivity
and bijectivity.
27. Four lecturers, Albert, Bertha, Chesterton and Desdemona are involved in the teach-
ing of a degree programme in mathematics. Albert teaches algebra, logic and calculus.
Bertha teaches algebra, calculus and geometry. Chesterton teaches logic and differential
equations. Desdemona teaches algebra, geometry and differential equations.
Denoting by L the set of lecturers listed above, and S the set of subjects listed above,
give a relation on L S that encodes their teaching duties.
Find combinations of projection and inverse projection maps that calculate:
(a) the courses that Albert teaches.
(b) the lecturers who teach differential equations.
(c) those lecturers with a course in common with Desdemona.
(d) those courses taught by anybody who teaches differential equations.
(e) all courses taught by anybody teaching a course that Albert teaches.
(f) all those people teaching both algebra and logic.
RJL,124ms\tut2.tex

Potrebbero piacerti anche