Title: Sets, Functions and Relations
1Sets, Functions and Relations
2Self introduction
- You can call me Isaac
- Im responsible for the tutorials of the first 3
weeks and the first classwork - If you have questions, you may email me at
wsfung_at_cse.cuhk.edu.hk - Or come to SHB 115
3What is a set?
- Q Give me one element of each of the following
sets? - The set of English letters,
- the set of English words that starts with d
and ends with e, - the set of all natural numbers,
- the set of all 8 digit telephone numbers,
- the set of factors of 30030,
- the set of integers x N100ltxlt120,
- The order of elements does not matter
- e.g. a, b, c is the same set as b, a, c
- Q If A (Jennifer, Ken, John, May) is a
sequence of people who are ordered by their ages,
is A just the same as the set Jennifer, Ken,
John, May? - The set 1, 2, 3, 3 is same as the set 1, 2, 3
- Q If I want to record the number of times my
friends visit my home, can I do this by just
adding his/her name into a set every time he/she
visits me?
4What can be in a set?
- A set may contain infinitely many elements
- e.g. the set of real numbers
- Q Give me another set that has infinitely many
elements - A set can also contain zero element
- e.g. the empty set,
- Q Can you give me another set that has zero
elements? - Types of elements doesnt matter,
- e.g. S 11/13, red, CSC2110, (10,10)
- A set can also be an element of some other set
- e.g. X 1, 1,2, 1,2,3
- Suppose A1, B2, C3
- Q Is A, B, C the same as 1, 2, 3?
- How many elements are there in the set 1,
2 ? - What about A A X?
5How can we specify a set?
- We can specify a set by
- listing all the members of the set, e.g. 1, 2,
3 - Q Could you list all the elements of the set of
integers? - stating the properties of the set members,
- e.g. X x Z x is even
- Q Try specifying the sets of Fibonacci numbers
- (take home exercise)
- the results of set operations on some other sets
- e.g. A is the set of all quadrilaterals whose
four sides have equal length (rhombus), B is the
set of quadrilaterals which have two adjacent
angles equal to (trapezium), C is the set of
quadrilaterals such that the 2 pairs of opposite
sides are parallel, so what is ,
and ?
6How can we specify a set?
- Q What is the complement of the positive even
integers? - (if the universe is 1. positive integers, 2.
even integers, 3. integers) - Q If X has been defined to be the set of
right-angled triangles and Y is the set of
isosceles triangles, you are asked to specify the
set of all right-angled isosceles triangles,
which method would you prefer to use? - Q Suppose Ma,b,c,d,e, Nb,d, Pc,e,
Qb,c - Express a,e in terms of these 4 sets using
only basic set operations
7Venn Diagram
- When we work with just 2 or 3 sets, it is often
useful to draw the Venn diagram - Suppose the blue circle represents a set A and
the red circle represents a set B - Try to find the regions corresponding to the
complement of A, A B, - A B, A\B
- Try to derive the De Morgans law
- and
8Venn Diagram, continued
- Suppose the red circle represents the set of
multiples of 4, the blue circle represents the
multiples of 15 and the yellow circle represents
the multiples of 10. - Try to figure out the meaning of each region
- Try to derive the distributive laws
- ,
9Subsets of a set
- e.g. the set of prime numbers is a subset of the
natural numbers, - the set of core courses is a subset of all the
courses, - a set is a subset of itself,
- the empty set is a subset of any set,
- the intersection of two sets A and B is always a
subset of A and B, - A and B are always subsets of the union of A and
B - Q Is the set of even numbers a subset of the
composite numbers? - Q Let x and y be two integers. If F is the set
of factors of the largest common factor of x and
y, is F a subset of the union of the set of
factors of x and the set of factor of y? - Q Let A1,2,3,4,5,6, B1,2,3,4,6,
C1,3,4,5,6, D3,4 - Give me a subset of A that is not a subset of B
and C but not contains D as its subset
10Subsets of a set, cont.
- X Y (X and Y contain the same elements)
- if and only if X Y and X Y (can you see
why?) - e.g. the set of multiples of 10 equals the
intersection of the set of multiples of 2 and 5 - Q Let x and y be two integers
- If s is the smallest common multiples of x and
y, does the set of factors of s equal the union
of the set of factors of x and the set of factors
of y? - The power set of a set X, Pow(X) is the set of
all the subsets of X - e.g. Let X1, 2, 3. Pow(x) ,1, 2,
3, 1,2, 2,3, 3,1, 1,2,3 - Q Give me the power set of the power set of 0,
1 - Q Give me a set whose power set has only one
element
11What is a function?
- e.g. the identity function, f(x)x
- e.g. the set membership function of a set X,
-
-
- e.g. is a function whose domain and
codomain are sets of functions - e.g. let x be a student ID,
- f(x)name of the student who has this student
ID - e.g. currency conversion formula,
- suppose x is the price of something in HK,
- f(x)the value of x in US
f
image of x
x
domain
codomain
12What is not a function?
g
- e.g. g(x)1/x is not a total function if the
domain is , as 1/0 is undefined - Q Is f(x)log(x) a total function if the
domain is the set of real numbers larger than 0? - e.g. Define f(x)y if y2x
- f(x) is not a function as 22(-2)24,
- the element 4 has two images 2 and -2 under f
- e.g. Let X be a set,
- f(X)an element of X,
- f(X) is not a functon as X may have no elements
or X can have more than one elements
x
What is g(x)?
domain
codomain
X is not mapped to some element in the codomain
h
y
x
h(x)y or h(x)z?
z
domain
codomain
X is mapped to two elements in the codomain
13Surjective functions
- Roughly speaking, if a function is surjective,
then each element in the codomain will have AT
LEAST one arrow pointing to it - e.g. f(x)sin(x), domain , codomain
-1, 1 - f(x) is surjective
- Q Is f(x) still surjective if the codomain is
? - e.g. f(x)1, domain , codomain 1
- f(x) is surjective but it is not surjective if
we add anything other than 1 to its codomain - e.g. Suppose f(x)x1 and the codomain is the
set of even numbers - Q If f(x) is surjective, what should be the
domain of f(x) - Q If there are more elements in the codomain
than in the domain, can this function be
surjective?
14Injective functions
- If a function is injective, then each element in
the codomain can have AT MOST one arrow pointing
to it - e.g. f(x)course code of course x, domainset
of courses, - codomainset of course code
- f(x) is injective as no two courses share one
course code - e.g. f(x)cos(x), codomain-1, 1
- f(x) is not injective if the domain is
- but f(x) is injective if the domain is
- Q If a function is injective, can it be true
that there are more elements in the domain than
in the codomain?
15Bijection and inverse
- A function f is a bijection if it is total,
surjective and injective - e.g. f(x)x1 is a bijection between the set of
even numbers and the set of odd numbers - e.g. f(x)-x is a bijection between the set of
positive numbers and the set of negative numbers - If there is a bijection between 2 sets A and B,
the sizes of A and B are the same - e.g. We can construct a bijection between the set
of English letters and the set 1,2,,26 to
count the number of letters - e.g. We can construct a bijection between the set
of natural numbers and the set of rational
numbers to count the size of a infinite set - Q Try constructing a bijection between the set
of natural numbers and the set of positive
rational numbers - If we reverse the direction of the arrows in a
bijection, we get a new function, which is called
the inverse of the original function. - Q What is the inverse of f(x)(x-2)3?
- Q Does f(x)(x-2)2 have an inverse?
16Composite functions
- A composite function is a function formed by
cascading 2 functions - e.g. f(x) (sin(x))2 can be viewed as the
composite of two functions h(y) and g(x) where
h(y) y2 and g(x) sin(x) - When we write ,
- actually we means
- When we want to evaluate f(x) we just pass the
input x to g and then pass the output of g as the
input of h, and finally we return the output of h
as the output of f
17Composite functions, cont.
h
g
Q Is f(x) a total function if both g(x) and h(y)
are total functions? Assume f(x), g(x), h(y) are
all total functions. Is f(x) bijective if both
g(x) and h(x) are bijective? Are both g(x) and
h(x) bijective if f(x) is bijective?
- Graphically, we may join the graphs of the
functions g and h to form the graph representing f
f
g
h
x
g(x)
f(x)h(g(x))
18Functions vs Relations
- In a function, each element in the domain is
associated with one element in the codomain - What if we want to associate each student with
the course he/she has taken? A student may have
taken gt1 course - One approach is to model this by a function whose
domain is the set of students and the codomain is
the set of all possible combinations of courses
(notice that the set of combinations of courses
can be much larger than the set of all courses) - Besides, the elements in the codomain are sets of
courses. However what we want to model is the
relationship between students and courses instead
of relationship between students and set of
courses
1130, 1500, 2100
Student A
2100, 2510, 3150
Student B
Student C
1500, 3150, 3160
19Functions vs Relations, cont.
- It is more natural to associate the students with
the courses they take - This requires us to allow each student to be
associated with more than one courses - We call such a mapping a relation
Using this approach, it is much easier to answer
questions like Who have taken 2100? Are there
any courses taken by both students A and B? Are
there any students who have taken both 2100 and
3150?
1130
Student A
1500
2100
Student B
2510
3150
Student C
3160
20Some special relations
- Here we only consider binary relations -
relations between two objects - You should have seen many binary relations before
and many of them describe relations between 2
elements of the same set - e.g. a b, a lt b, equal to and smaller than
are relations between pairs of real numbers - e.g. P ? Q if and only if are relation between
pairs of propositions - e.g. Alice is a relative of Bob is a relation
between two people - e.g. John is a friend of Mary is also a
relation between two people
21Graphs of relations
- When a binary relation is defined between
elements of the same set, we can use another type
of diagram to represent this relation - In this type of diagram, we have only one set of
points representing elements of the set. If two
elements (x, y) are in the relation, we draw an
arrow pointing from x to y (notice that the order
matters, e.g. 2gt1, the converse 1gt2 is not true) - e.g.
1
2
The is a friend of relation among some people
The defeats relation among some football teams
22More examples
3
4
5
Each point represents a person, and the arrows
corresponds to the has the same surname relation
Can you observe some of the properties of
diagrams 2, 3, 4? Can you tell what do they have
in common with diagram 5?
23Equivalence relations
- Notice that the elements in the diagram are
divided into some disjoint subsets. Elements in
the same subset have arrows pointing to each
other (and themselves) but there are no edges
crossing from one subset to another subset - There are many relations which have diagrams
similar to the diagram in the last example - e.g. The is similar to relation on triangles,
all equilateral triangles are similar - e.g. The equals relation on rational numbers,
2/3 4/6 - e.g. The has the same remainder when divided by
7 relation on integers, 3 mod 7 10 mod 7 - Q How many disjoint subsets are there in this
relation? - We call these relations Equivalence relations
24Partition of a set
- If two sets A and B do not share any common
elements, i.e. , we say that
they are disjoint - Suppose X1, X2, , Xn are subsets of a set X. If
- Their union is equal to X, and
- Every pair of them are disjoint
- Then we say that X1, X2, , Xn form a partition
of X - Refer back to the diagram in example 5. If the
relation is a equivalence relation, we can form a
partition by the following procedures - Let each element form a subset which contains
only this element - Whenever there is an arrow pointing from an
element x to an element y, combine the subset
containing x and the subset containing y - Continue until there is no arrow crossing two
subsets - The resulting collection of subsets is a
partition of the set - This partition has the properties highlighted in
the last slide - We call a subset in this partition, an
equivalence class - e.g. The even and odd numbers form two
equivalence classes - under the relation having the same remainder
when divided by 2
25Symmetry, Transitivity and Reflexivity
- You may observe that there are some properties
that are shared by example 5 and examples 2, 3
and 4 - In examples 2 and 5, whenever there is an arrow
pointing from an element x to an element y, then
there is an arrow pointing from y to x. - We say that such a relation is a symmetric
relation - In examples 3 and 5, for any three elements x, y
and z, whenever there is an arrow pointing from x
to y and an arrow from y to z, then there must be
an arrow from x to z - We say that this relation is a transitive
relation - In examples 4 and 5, every element in the set has
an arrow pointing from itself to itself - We say that this relation is a reflexive
relation - In fact, a relation is a equivalence relation if
and only if it is symmetric, transitive and
reflexive
26More relations
- Which of these relations are symmetric, reflexive
or/and transitive? - x lt y, x y (x, y are numbers)
- X Y, X and Y are disjoint (X,Y are sets)
- A is married to B (A, B are people)
- p is orthogonal to q (p, q are straight lines)
- P ? Q, P -gt Q (p, q are propositions)
- Someone can travel from x to y by walking and
taking lift but not leaving a building - (x, y are rooms)
- X and Y star in the same film (X, Y are
actors/actresses) - X is the ancestors of Y (X, Y are people)
- x and y do not have common factors (x, y are
integers)
- Are the following relations equivalence
relations? If yes, what are the equivalence
classes? - x and y have the same age/sex
- (x and y are people)
- There are lectures of x and y on the same day of
the week (x, y are courses) - x and y are partners in the same project group
(x, y are students taking CSC2110) - x and y are married (x, y are people)
- x and y are sibling (brother or sister) of each
other (x, y are people)
27Tips and feedback
- For each concept mentioned in this tutorial, try
to find your own examples - The diagram representations (the Venn diagram,
the diagrams of functions/relations) are usually
more concrete and easy to understand - We will discuss the classwork next week
- Take a look at it first and ask me next time if
you have questions - Some topics like the club strangers problem,
the halting problem, uncountability of real
numbers may be a bit more difficult, let me know
if you want more explanation