Week02 Relations and Functions
Week02 Relations and Functions
(Discrete Mathematics)
Relations
08/28/2023 2
Relations
• Whenever sets are being discussed, the
relationship between the elements of the sets
is the next thing that comes up.
• Relations may exist between objects of the
same set or between objects of two or more
sets.
Relations – Definition
08/28/2023 4
Relations – Example
Relation:
A (binary) relation R on set E is a subset of E×E.
Examples using E={0,1,2,3}:
• The relation is =
{(0,0), (1,1), (2,2), (3,3)}
• This relation is ≥.
{(0,0), (1,1), (1,0), (2,2), (2,1), (2,0), (3,3), (3,2), (3,1),
(3,0)}.
08/28/2023 5
Relations – On a Set
1. .1 1 2 3 4 R
X X X X 1
2. .2
X X 2
3. .3
X 3
4. .4
X 4
08/28/2023 6
Relations – Examples
1 Coordinate diagram:
Let A={1,2,3} and B={x , y}. Let R be a relation from
A to B defined as R={(1,y),(2,x),(2,y),(3,x)}
0 1 2 3
08/28/2023 8
Relations – Representations
2 Arrow diagram:
Let A={1,2,3} and B={x , y}. Let R be a relation from A
to B defined as R={(1,y),(2,x),(2,y),(3,x)}
1
x
2
3 y
08/28/2023 9
Relations – Representations
3 Matrix Representation:
Let A={1,2,3} and B={x , y}. Let R be a relation from A
to B defined as R={(1,y),(2,x),(2,y),(3,x)}
08/28/2023 10
Relations – Representations
4 Directed Graph:
Let A={0,1,2,3}
R={(0,0),(1,3),(2,1),(2,2),(3,0),(3,1)}
08/28/2023 11
Relations – Questions
08/28/2023 12
Relations – Properties
08/28/2023 13
Relations – Properties
08/28/2023 14
Relations – Properties
08/28/2023 15
Relations – Properties
08/28/2023 16
Relations – Properties
Example 2 Sol:
• R4, R5, and R6 are transitive. For each of these relations, we can show
that it is transitive by verifying that if (a, b) and (b, c) belong to this
relation, then (a, c) also does. For instance, R4 is transitive, because (3,
2) and (2, 1), (4, 2) and (2, 1), (4, 3) and (3, 1), and (4, 3) and (3, 2) are
the only such sets of pairs, and (3, 1), (4, 1), and (4, 2) belong to R4. You
should verify that R5 and R6 are transitive.
• R1 is not transitive because (3, 4) and (4, 1) belong to R1, but (3, 1) does
not. R2 is not transitive because (2, 1) and (1, 2) belong to R2, but (2, 2)
does not. R3 is not transitive because (4, 1) and (1, 2) belong to R3, but
(4, 2) does not.
08/28/2023 17
Relations – Properties
08/28/2023 18
R1= {(a, b) | a ≤ b},
R2={(a, b) | a > b},
R3={(a, b) | a = b or a = -b},
R4={(a, b) | a = b}, Relations – Examples
R5={(a, b) | a = b+1},
R6={(a, b) | a+b ≤ 3},
Example 6: Which of the relations from Example 5 are reflexive
and symmetric?
Sol: The reflexive relations from Example 5 are R1 (because a ≤
a, for all integer a), R3 and R4.
For each of the other relations in this example it is easy to
find a pair of the form (a, a) that is not in the relation.
The symmetric relations are R3, R4 and R6.
R3 is symmetric, for if a=b , then b=a .
R4 is symmetric, since a=b implies b=a.
R6 is symmetric, since a+b ≤ 3 implies b+a ≤ 3.
None of the other relations is symmetric.
08/28/2023 19
Relations – Examples
08/28/2023 20
Relations – Question
08/28/2023 21
Relations – Equivalence relations
08/28/2023 22
Relations – Example
08/28/2023 23
Functions
24
Definition of Functions
• Given any sets A, B, a function f from (or
“mapping”) A to B (f:AB) is an assignment of
exactly one element f(x)B
to each element xA.
25
Graphical Representations
• Functions can be represented graphically in
several ways:
f A B
• •
f • •
• • • y
a b •
•
•
• x
A
B Graph Plot
Like Venn diagrams
26
Some Function Terminology
• If f:AB, and f(a)=b (where aA & bB),
then:
– A is the domain of f.
– B is the codomain of f.
– b is the image of a under f.
– a is a pre-image of b under f.
• In general, b may have more than one pre-image.
– The range RB
27
Range vs. Codomain - Example
29
One-to-One Illustration
30
Onto (Surjective) Functions
31
Illustration of Onto
• Some functions that are or are not onto their
codomains:
•
• • • • • • • •
• • • • • • • •
• • • •
• • • •
• • • • • •
• • • •
Onto Not Onto Both 1-1 1-1 but
(but not 1-1) (or 1-1) and onto not onto
32
Bijections
• A function f is a one-to-one correspondence,
or a bijection, or reversible, or invertible, iff it
is both one-to-one and onto.
33