Relations and Functions Summary
Relations and Functions Summary
1 Relations
1
1.1 Inverse relations
2
Definition 6 Let n be a positive integer. We say x and y are congruent
modulo n, and write x ≡ y(mod n), provided n|(x − y) (or x − y is a multiple
of n)
> Denote “≡” as “is congruent to mod n”
≡ is an equivalence relation?
(i) is reflexive?
.
∀x ∈ Z, since x − x = 0..0 ⇒ x ≡ x(mod n).
(ii) is symmetric?
∀x, y ∈ Z, and x ≡ y(mod n) ⇒ x − y = kn ⇒ y − x = (−k)n ⇒ y ≡
x(mod n).
(iii) is transitive? (
x ≡ y(mod n)
∀x, y, z ∈ Z, suppose ⇒ x−y = kn and y −z = mn ⇒
y ≡ z(mon n)
x − z = (k + m)n ⇒ x ≡ z(mod n).
3
Example 6 Find the requested equivalence class:
a. R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)} on {1, 2, 3, 4}.
Find [1]?
a. Let R be “is-congruent-to-mod-5 ” on Z.
1.5 Partitions
P1
P3
P2
P4 P5
2 1 2 1
3 3
4
2 1 2 1 2 1
3 3 3
Example 9 How many possible equivalence relations are there on set {1,2,3,4}?
2 Functions
5
a) f = {(1, 2), (3, 4), (5, 6), (6, 7)}
⇒ is a function
b) g = {(1, 2), (1, 3), (3, 2)}
⇒ is not a function
Example 11
f ={(1, 1), (2, 3), (3, 4)}
⇔{f (1) = 1, f (2) = 3, f (3) = 4, f (4) is undef ined, . . .}
• as a set of pairs
f = {(1, 2), (2, 3), (5, 6)}
• as a chart
x f(x)
..
.
3 4
4 5
5 6
6 7
..
.
• Express function as a map
x1 y1
y2
x2
x3 y3
x4 y4
x5 y5
6
• Express function as a set-builder notation
f = {(x, y) : x, y ∈ Z, y = x2 }
i) The set of all possible first elements of the ordered pairs in f is called the
domain of f , denoted dom(f )
b) f = {(x, y) : x, y ∈ Z, y = x2 }
⇒ dom(f ) = Z, im(f ) = {0, 1, 4, . . . , n2 , . . .}
Example 13 Let A be the set of odd integers, B be the set of even integers.
The function f : A → B, defined by f (x) = x + 1
• f is one-to-one?
• f is onto?
7
Properties 1 Let f : A → B be a function.
a) f : Z → Z, f (x) = 2x
b) f : Z → Z, f (x) = x + 10
c) f : N → N, f (x) = x + 10
d) f : N → N defined by
(
x/2 if x is even
f (x) =
(x − 1)/2 if x is odd
2.4 Composition
Propositions 3 1. f −1 ◦ f 6= f ◦ f −1
2. If f : A → B is bijection then
• (f −1 ◦ f )(a) = a, ∀a ∈ A
• (f ◦ f −1 )(b) = b, ∀b ∈ B
8
Example 16 The follows are lists
(i) S=(0,1,2,3)
(ii) T=(-2,3,2,3,4)
(i) S={0,1,2,3}
(ii) T={3,2,4}
(iii) U = {x ∈ N : x ≤ 20 and 6|x}
(6|x means 6 is a divisor of x)
List Set
Object order 3 neglect
Object repetition 3 neglect
(i) Let A be a list (or set). |A| is denoted as the number of list (or set)
elements.
(ii) If A is a list, |A| is called the length of A.
(iii) If A is a set, |A| is called the cardinality of A.
(iv) ( )-empty list, ∅ - empty set.
Example 19 We have
a) S = {0, 1, 2, 3} ⇒ |S| = 4
b) T = {3, 2, 4} ⇒ |T | = 3
9
3.2 Equality of lists, sets
2) In addition, the two numbers on the list must be different. How many
such lists are possible?
n2 − n = n(n − 1)
3) In general, to make k-element lists where the entries in the list are in S
and pairwise different. How many such lists are possible?
n(n − 1)(n − 2) . . . (n − k + 1) denoted as (n)k
3.4 Subsets
10
> Notes:
(i) A ⊃ B ⇔ B ⊂ A
(ii) ∅ ⊂ A, ∀A
(iii) A ⊆ B means A is a subset or equal to B.
Example 20 We have
Answer: 8 subsets of A
∅, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}
> Notes:
3.6 Exercise 2
11
c) How many 4-element subsets of A are possible?
Solution:
3.8 Multisets
> All the set objects are enclosed in angle braces <,>.
Example 23 We have
a) S=<1,2,3>
b) T=<1,2,2,3,3,3>
c) V=<1,1,1,2,3>
12
Definition 18 (1) The cardinality of a multiset is the sum of multiplicities
of its elements.
S=<1,1,2,2,2,3,3> ⇒ |S| = 7
(2) Two multisets are said the same Iff they contain the same elements with
the same multiplicities.
(i) < 1, 1, 2, 3 >=< 1, 2, 3, 1 >
(ii) < 1, 2, 3, 3 >6=< 1, 2, 2, 3 >
Example 24 All the multisets with size 2 we can form from the elements in
{1,2,3} are:
f
< 1, . . . , 1, 2, . . . , 2, . . . , n, . . . , n > ←→e1 + e2 + . . . + en = k
| {z } | {z } | {z }
e1 e2 en
g
e1 + e2 + . . . + en = k ←→ ∗, . . . , ∗ | ∗, . . . , ∗ | . . . | ∗, . . . , ∗
| {z } | {z } | {z }
e1 e2 en
(n − 1) − bars and k − stars
> f and g are one-to-one correspondences.
(a) ( n1 ) =n
(b) ( 23 ) =4
(c) ( k1 )=1
13
n!
Properties 2 (i) ( nk ) = n+k−1 n
k , where k =
k!(n − k)!
(ii) ( nk )=( n−1 n
k )+( k−1 )
(iii) Let n be a positive integer and let k be a nonnegative integer. The equation
e1 + e2 + . . . + en = k
has ( nk ) solutions for which e1 , e2 , . . . , en are nonnegative integers.
4 Counting functions
14
4.1 Pigeonhole principle
Example 26 How many functions from {1, 2, 3} to {a, b} are possible where
Example 27 Given 5 distinct lattice points in the plane, at least one of the
line segments determined by these points has a lattice point as its midpoint.
4.3 Permutations
Example 28 Let A = {1, 2, 3, 4, 5} and f : A → A by f = {(1, 2), (2, 4), (3, 5), (4, 3), (5, 1)
is a permutation on A
15
> f is expressed in a matrix:
1 2 3 4 5
f=
2 4 5 3 1
(i) |Sn | = n!
(ii) ∀π, σ ∈ Sn , π ◦ σ ∈ Sn
(iii) ∀π ∈ Sn , π −1 ∈ Sn and π ◦ π −1 = ι where ι(i) = i ∀i = 1, 2, . . . , n
4.5 Transposition
16
1 2 3 4 5
Example 31 Let σ =
4 5 2 3 1
σ = (1, 4, 3, 2, 5)
= (1, 5) ◦ (1, 2) ◦ (1, 3) ◦ (1, 4)
(i) π −1 = τa ◦ τa−1 ◦ . . . ◦ τ1
(ii) If π is decomposed by another way such as
π = σ1 ◦ σ2 ◦ . . . ◦ σb ,
then a and b have the same parity.
Example 32 Let
1 2 3 4 5
σ=
4 5 3 2 1
Is σ even or odd?
4.7 Exercises
1. For each of the following relations defined on the set {1, 2, 3, 4, 5}, de-
termine whether the relation is reflexive, irreflexive, symmetric, antisym-
metric, and/or transitive.
a) R = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)}
b) R = {(1, 2), (2, 3), (3, 4), (4, 5)}
c) R = {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5)}
d) R = {(1, 1), (1, 2), (2, 1), (3, 4), (4, 3)}
17
e) R = {1, 2, 3, 4, 5} × {1, 2, 3, 4, 5}
2. For each of the following relations on the set of human beings, please
determine whether the relation is reflexive, irreflexive, symmetric, anti-
symmetric, and/or transitive.
a) has-the-same-last-name-as.
b) is-the-child-of.
c) has-the-same-parents-as (i.e., same mother and father)
d) is-married-to.
e) is-an-ancestor-of.
.
f) R = {(a, b)|a, b ∈ N, a|b} >(a|b ⇔ b..a)
.
g) R = {(a, b)|a, b ∈ Z, a − b..10}
3. Let us say that two integers are near one another provided the absolute
value of their difference is 2 or smaller (i.e., the numbers are at most 2
apart). For example, 3 is near to 5, 10 is near to 9, but 8 is not near to
4. Let R stand for this is-near-to relation. Please do the following:
a) Write down R as a set of ordered pairs. Your answer should look like
this:
R = {(x, y) : . . .}
b) Prove or disprove: R is reflexive.
c) Prove or disprove: R is irreflexive.
d) Prove or disprove: R is symmetric.
e) Prove or disprove: R is antisymmetric.
f) Prove or disprove: R is transitive.
4. For each of the following relations, find R−1 .
a) R = {(1, 2), (2, 3), (3, 4)}
b) R = {(1, 1), (2, 1), (3, 1)}
c) R = {(x, y) : x, y ∈ Z, x − y = 1}
d) R = {(x, y) : x, y ∈ N, x|y}
e) R = {(x, y) : x, y ∈ Z, xy > 0}
5. Which of the following are equivalence relations?
a. R = {(1, 2), (2, 3), (3, 1)} on set {1,2,3}.
b. | on Z (a|b ⇔ b is divisible by a).
c. ≤ on Z.
18
d. “Is-an-anagram-of” on the set of English words. (For example, STOP
is an anagram of POTS because we can form one from the other by
rearranging its letters.)
6. For each of the following equivalence relations, determine the number of
equivalence classes that relation has.
a. Congruence modulo 7 (for the integers).
b. Lives-in-the-same-province-as (for residents of Vietnam).
7. Write out all the possible two-letter “words” one can make using only the
vowels A, E, I, O, and U. How many of these have no repeated letter?
8. Airports have names, but they also have three-letter codes. E.g., the
Hanoi airport code is HAN, and the code FRA is for the Frankfurt airport
in Germany. How many different airport codes are possible?
9. A bit string is a list of 0s and 1s. How many length-k bit strings can be
made?
10. How many different anagrams (including nonsensical words) can be made
from each of the following?
1) DISCRETE
2) MATHEMATICS
3) INFORMATICS
11. Twelve people join hands for a circle dance. In how many ways can they
do this?
12. You wish to make a necklace with 20 different beads. In how many dif-
ferent ways can you do this?
13. One hundred people are to be divided into ten discussion groups with
ten people in each group. In how many ways can this be done?
14. Let A ={1,2,. . . , 100}. How many 10-element subsets of A consist of only
odd numbers?
15. How many partitions, with exactly two parts, can be made of the set
{1,2,3,4}?
Answer the same question for the set {1,2,3,. . . ,n}.
16. Let A be a 100-element set. Which is greater: the number of partitions
of A into 20 parts of size 5 or the number of partitions of A into 5 parts
of size 20?
19
17. Ten married couples are seated around a large circular table. In how
many different ways can they do this, assuming husbands and wives sit
next to one another? Please note that if everyone moves one (or more)
places to the left, the arrangement is not considered to be different.
18. Let A be the set {1,2,3,4,5}.
a) How many ways to partition A into two parts are possible?
b) How many ways to partition A into three parts are possible?
c) How many ways to partition A into four parts are possible?
d) How many possible equivalence relations are there on set A?
19. What multiset is encoded by the stars-and-bars notation *|||***?
20. Please calculate
a) ( 24 )
b) ( 53 )
20
g) What is g ◦ f ?
h) What is f ◦ g?
25. Let A={1,2,3,4} and B= {1,2,3}.
a) How many one-to-one functions from A to B are possible?
b) How many onto functions from A to B are possible?
c) How many function f from A to B are possible where f (1) ≥ 1?
26. Let A={1,2,3,4} and B= {1,2,3,4}.
a) How many functions from A to B are possible?
b) How many one-to-one functions from A to B are possible?
c) How many function f from A to B are possible where f(1) is even?
27. Let f and g be permutations on set {1,2,3,4,5,6}, they are defined as
follows:
1 2 3 4 5 6 1 2 3 4 5 6
f= g=
4 1 3 2 6 5 6 2 4 3 5 1
Decompose f into transpositions.
a) Find f −1 and g −1 .
b) Calculate f ◦ g and g ◦ f
c) Express f and g by using cycle notation.
d) Decompose f and g into transpositions.
e) Are f and g even or odd?
21