Chap. 5 Relations and Functions
Cartesian ProductFor sets A, B the Cartesian product, or cross product, of A and B is denoted by A╳B and equals {(a, b)|a∈A, b∈B}.
e.g. Let A={2, 3, 5}, B={5, 6}. Then,a) A╳B={(2,5), (2,6), (3,5), (3,6), (5,5), (5,6)}.b) B╳A={(5,2), (5,3), (5,5), (6,2), (6,3), (6,5)}.c) B2=B╳B=d) B3=B╳B╳B={(a,b,c)|a,b,c∈B};for instance, (5,5,6)∈B3.
{(5,5), (5,6), (6,5), (6,6)}.
Binary RelationFor sets A, B, any subset of A╳B is called a (binary) relation from A to B. Any subsetof A╳A is called a (binary) relation on A.
e.g. Let A={2, 3, 5}, B={5, 6}. Which one of the following is a relation from A to B?a) ∅.b) {(3,5), (3,6), (5,6)}.c) {(2,5), (2,6), (6,5)}.d) A╳B.
O
O
O
X
Number of Relationse.g. Let A={2, 3, 5}, B={5, 6}. How many relations are from A to B?
26
.
2 22 22 2
The number of relations from A to B is
|A╳B|
Number of Relations (2)
Theorem 5.1For any sets A, B, C ⊆U, A╳(B∩C)=(A╳B)∩(A╳C)
pf. 1. It suffices to show for all a, b∈U,(a,b)∈A╳(B∩C) ⇔ (a,b)∈(A╳B)∩(A╳C) 2. (a,b)∈A╳(B∩C)⇔ a∈A and b∈B∩C ⇔ a∈A, b∈B and a∈A, b∈C ⇔ (a,b)∈A╳B and (a,b)∈A╳C ⇔ (a,b)∈(A╳B)∩(A╳C)
Theorem 5.1 (2)For any sets A, B, C ⊆U, a)A╳(B∩C)=(A╳B)∩(A╳C)b)A╳(B⋃C)=(A╳B)⋃(A╳C)c)(A∩B)╳C=(A╳C)∩(B╳C)d)(A⋃B)╳C=(A╳C)⋃(B╳C)
FunctionFor nonempty sets A, B, a function, or mapping, f from A to B, denoted f: A→B, is arelation from A to B in which every element of A appears exactly once as the first component of an ordered pair in the relation.
e.g. Let A={2, 3, 5}, B={5, 6}. Which of the following is a function from A to B?a) {(2,5), (3,6), (5,5)}.b) {(2,5), (2,6), (3,5), (5,5), (5,6)}.c) {(2,6), (3,5)}.
O
XX
Domain and RangeFor the function f: A→B, A is called the domain of f and B the codomain of f.The subset of B consisting of those elements that appear as second components in the ordered pairs of f is called the range of f and is also denoted by f(A) because it is the set of images (of the elements of A) under f.
Domain Codomain
Range
Domain and Rangee.g. Let A={2, 3, 5}, B={5, 6, 7}. f={(2,5), (3,6), (5,5)}. Then, the domian of f is {2, 3, 5}, the codomain of f is {5, 6, 7}, and the range of f is {5, 6}.
Number of Functionse.g. Let A={2, 3, 5}, B={5, 6}. How many functions are from A to B? sol. The number of functions from A to B is 23.
Number of Functions (2)
One-to-One FunctionA function f: A→B is called one-to-one, or injective, if each element of B appears atmost once as the image of an element of A.
e.g. Let A={2, 3, 5}, B={5, 6, 7, 8}. Which of the following is a one-to-one function from A to B?a) {(2,5), (3,6), (5,7)}.b) {(2,5), (3,6), (5,6)}.
OX
Example 5.13Given the function f: R→R where f(x)=3x+7 for all x∈R. Show that the given function f is one-to-one.
sol. 1. It suffices to showf(x1)=f(x2) ⇒ x1=x2 for all x1, x2 ∈ R.2. f(x1)=f(x2)
⇒ 3x1+7= 3x2+7 ⇒ x1=x2
Number of One-to-One Functionse.g. Let A={2, 3, 5}, B={5, 6, 7, 8}. How many one-to-one functions are from A to B? sol. The number of one-to-one functions from A to B is 4╳3╳2.
Number of One-to-One Functions
The Image of a SubdomainIf f: A→B and A1 ⊆ A, then f(A1)={b∈B|b=f(a) for some a∈A1}, and f(A1) is called the image of A1 under f.
e.g. For A={1, 2, 3, 4, 5} and B={w, x, y, z}, let f: A→B be given by f={(1, w), (2, x), (3, x), (4, y), (5, y)}. Then for A1={1, 2}, A2={2, 3, 4, 5}, what are f(A1) and f(A2)?f(A1)={f(a)|a ∈A1}=f(A2)={f(a)|a ∈A2}= {x, y}.
{w, x};
Theorem 5.2Let f: A→B, with A1, A2 ⊆ A. Thenf(A1∩A2) ⊆ f(A1)∩f(A2)
pf. 1. It suffices to show for all b∈B,b∈f(A1∩A2) ⇒ b∈f(A1)∩f(A2)2. b∈f(A1∩A2)⇒ b=f(a) for some a∈A1∩A2
⇒ b=f(a) for some a∈A1 and b=f(a) for some a∈A2
⇒ b∈f(A1) and b∈f(A2) ⇒ b∈f(A1)∩f(A2)
RemarkLet f: A→B, with A1, A2 ⊆ A. Thenf(A1∩A2)⊇f(A1)∩f(A2)
pf. 1. It suffices to show for all b∈ B,b∈f(A1∩A2) ⇐ b∈f(A1)∩f(A2)2. b∈f(A1∩A2)⇐ b=f(a) for some a∈A1∩A2
⇐ b=f(a) for some a∈A1 and b=f(a) for some a∈A2
⇐ b∈f(A1) and b∈f(A2)⇐ b∈f(A1)∩f(A2)
X
?
??
?
123
x
y
A1
A2
RemarkLet f: A→B, with A1, A2 ⊆ A. Thenf(A1∩A2)⊇f(A1)∩f(A2).
123
x
y
A1
A2
f(A1∩A2) = {x}.f(A1)∩f(A2) = {x, y}.
RemarkLet f: A→B, with A1, A2 ⊆ A. Then,when does f(A1∩A2)⊇f(A1)∩f(A2) hold?
pf. 1. It suffices to show for all b∈ B,b∈f(A1∩A2) ⇐ b∈f(A1)∩f(A2)2. b∈f(A1∩A2)⇐ b=f(a) for some a∈A1∩A2
⇐ b=f(a) for some a∈A1 and b=f(a) for some a∈A2
⇐ b∈f(A1) and b∈f(A2)⇐ b∈f(A1)∩f(A2)
if f is one-to-oneX
123
x
y
A1
A2
Theorem 5.1 (2)Let f: A→B, with A1, A2 ⊆ A. Thena) f(A1∪A2) = f(A1)∪f(A2)b) f(A1∩A2) ⊆ f(A1)∩f(A2)c) f(A1∩A2) = f(A1)∩f(A2) when f is one-to-one
Onto FunctionA function f: A→B is called onto, or surjective, if f (A)=B—that is, if for all b∈B there is at least one a∈A with f(a)=b.
e.g. Which of the following is a onto function?(a) f1: A→B defined by f1={(1,z), (2,y), (3,x), (4,y)}, where A={1, 2, 3, 4} and B={x, y, z}.(b) f2: R→R defined by f(x)=x3.(c) f3: Z→Z defined by f(x)= 3x+1.
OX
O
Number of Onto Functionse.g. Let A={w, x, y, z}, B={1, 2, 3}. How many onto
functions are from A to B? 1. Number of functions from A to B is2. Number of functions from A to {1, 2} is3. Number of functions from A to {1} is4. Then, we have number of onto functions from A
to B is 34-3·24-3·14.5.
34.24.
The functions from A to {1} is also counted in the number of functions from A to {1, 2} and in the number of functions from A to {1, 3}.
14.
Number of Onto Functions
34-3·24+3·14- 0=36.
no 1 no 2
no 3
U: A {1, 2, 3}no 1: A {2, 3}no 2: A {1, 3}no 3: A {1, 2}no 1,2: A {3}no 1,3: A {2}no 2,3: A {1}no 1,2,3: A { }
The number of onto functions from A to B is|U|-|no 1no 2no 3|= |U|-(|no 1|+|no 2|+|no 3|-(|no 1,2|+|no 1,3|+|no 2,3|)+|no 1,2,3|)=
C(3,2) C(3,1)C(n,n-1)
Let |A|=m, |B|=n.1· 1·
C(3,3) C(3,0)C(n,n) C(n,n-2) C(n,n-3)n n-1 n-2 n-3
4
m
Number of Onto Functions
Example 5.26How many ways are there to distribute four distinct objects into three distinguishable containers, with no container empty?
36because the number of ways to distribute four distinct objects into three distinguishable containers, with no container empty is equal to the number of onto functions from A={w, x, y, z} to B={1, 2, 3}.
Example 5.26 (2)How many ways to distribute four distinct objects into three identical containers, with no container empty?
The following distributions become identical.1) {a, b}1 {c}2 {d}3 2) {a, b}1 {d}2 {c}3
3) {c}1 {a, b}2 {d}3 4) {c}1 {d}2 {a, b}3
5) {d}1 {a, b}2 {c}3 6) {d}1 {c}2 {a, b}3,Therefore, the number of ways is 36/3!.
Stirling Number of the Second Kind
63+301╳3=966301+350╳4=1701⇒ S(m+1,n)=S(m,n−1)+nS(m, n).
Theorem 5.3Let m, n be positive integers with 1<n≤m. Then
S(m+1,n)=S(m,n−1)+nS(m, n).
1. The number of distributions to place a1, a2, …, am+1 in n identical containers with none left empty (N1) is equal to the number of distributions to place a1, a2, …, am+1 in n identical containers with none left empty in which am+1 is in a container by itself (N2) plus the number of distributions to place a1, a2, …, am+1 in n identical containers with none left empty in which am+1 is not in a container by itself (N3) .
2. 3. 4. n times the number of distributions to place a1, a2, …,
am in n identical containers with none left empty
N1= N2= S(m,n−1).S(m+1,n).N3=
=nS(m,n).
N1=N2+N3.
Unary and Binary OperationsFor any nonempty sets A, B, any function f:
A╳A→B is called a binary operation on A.A function g: A→A is called a unary, or
monary, operation on A.
e.g. (a) The function h: R+→R+ defined by
h(a)=1/a is a unary operation on R+.(b) The function f: Z╳Z→Z defined by f(a, b)=a−b is a binary operation on R.
Closed Binary OperationIf B⊆A, then the binary operation is said to
be closed (on A). (When B⊆A we may also say that A is closed under f.)
e.g. Which of the following binary operation is closed?
(a) f: Z╳Z→Z, defined by f(a, b)=a−b.(b) g: Z+╳Z+→Z, defined by g(a, b)=a−b.
OX
Commutative Binary OperationLet f : A╳A→B. Then f is said to be
commutative if f(a, b)=f(b, a) for all (a, b)∈A╳A.
e.g. Which of the following binary operation is commutative?
(a) Let U be a universe, and let A, B⊆U. f: P(U)╳P(U)→P(U) defined by f(A, B)=A∪B.
(b) f: Z╳Z→Z, defined by f(a, b)=a−b.O
XWhy are they not U?
Number of Closed Binary Operations
Let A = {a, b, c, d}. The number of closed binary operations is 416.
4 44 44 44 44 44 4
4 44 4
# of f(a,a)
# of f(a,b)
# of f(a,c)
# of f(a,d)# of
f(b,a)
# of f(b,b)
# of f(b,c)
# of f(b,d)# of
f(c,a)
# of f(c,b)
# of f(c,c)
# of f(c,d)# of
f(d,a)
# of f(d,b)
# of f(d,c)
# of f(d,d)
(a,a)(a,b)(a,c)(a,d)(b,a)(b,b)(b,c)(b,d)(c,a)(c,b)(c,c)(c,d)(d,a)(d,b)(d,c)(d,d)
a
b
c
d
Number of Commutative Closed Binary Operations
Let A= {a, b, c, d}. The number of commutative closed binary operations is 410.
4 11 14 14 14 44 1
4 44 4
IdentityLet f: A╳A→B be a binary operation on A. An
element x∈A is called an identity (or identity element) for f if f(a, x)=f(x, a)=a, for all a∈A.
e.g. For the (closed) binary operation f : Z╳Z→Z, where f(a, b)=a+b,
what is an identity? why?
0f(a, 0)=a+0=a=0+a=f(0, a).
Number of Closed Binary Operations with Identities
If A={x, a, b, c, d}, how many closed binary operations on A have x as the identity?
Ans: 516.5 55 55 55 55 55 55 55 5
Number of Commutative Closed Binary Operations with Identities
If A={x, a, b, c, d}, how many commutative closed binary operations on A have x as the identity?
Ans: 510.5 11 15 15 15 55 15 55 5
THEOREM 5.4Let f: A╳A→B be a binary operation. If f has
an identity, then that identity is unique.
pf. 1. It suffices to showx1, x2∈A are identities of f ⇒ x1=x2.2. Because x1 is identity of f, f(x1, x2)=x2.3. Because x2 is identity of f, f(x1, x2)=x1.4. This implies x1=x2.
The Pigeonhole PrincipleIf m pigeons occupy n pigeonholes and
m>n, then at least one pigeonhole has two or more pigeons roosting in it.
e.g. An office employs 13 file clerks, so at least two of them must have birthdays during the same month.
Example 5.43Prove that if 101 integers are selected from the set
S ={1, 2, 3, . . . , 200}, then there are two integers such that one divides the other.
pf. 1. For each x∈S, we may write x=2ky, with k ≥ 0, and gcd(2,y)=1.
2. y ∈T={1, 3, 5, . . . , 199}, where |T|=100.3. By the pigeonhole principle there are two
distinct integers of the form a=2my, b=2ny for some (the same) y∈T .
4. a and b are the desired two integers.
Example 5.44Any subset of size 6 from the set S {1, 2, 3, . . . ,
9} must contain two elements whose sum is 10.
pf. 1. Here the pigeons constitute a six-element subset of {1, 2, 3, . . . , 9}, and the pigeonholes are the subsets {1, 9}, {2, 8}, {3, 7}, {4, 6}, {5}.
2. When the six pigeons go to their respective pigeonholes, they must fill at least one of the two-element subsets whose members sum to 10.
One-to-One CorrespondenceIf f : A→B, then f is said to be bijective, or to
be a one-to-one correspondence, if f isboth one-to-one and onto.
e.g. Let A={1, 2, 3, 4} and B={w, x, y, z}. Which of the following function is a one-to-one correspondence?
(a) f={(1, w), (2, x), (3, y), (4, z)}. (b) f={(w, 1), (x, 2), (y, 3), (z, 4)}.(c) f={(1, w), (2, x), (3, y), (4, y)}.(d) f={(1, w), (2, x), (3, y), (3, z)}.
O
XO
X
Identity FunctionThe function IA: A→A, defined by IA(a)=a for
all a∈A, is called the identity function for A.
If f, g: A→B, we say that f and g are equal and write f=g, if f(a)=g(a) for all a ∈ A.
Composite FunctionIf f : A→B and g: B →C, we define the composite
function, which is denoted g◦f: A→C, by (g◦f )(a)=g(f(a)), for each a ∈ A.
e.g. Let A={1, 2, 3, 4}, B={a, b, c}, and C={w, x, y, z} with f : A→B and g: B →C given by f={(1, a), (2, a), (3, b), (4, c)} and g={(a, x), (b, y), (c, z)}. Then,
(g◦f)(1)= (g◦f)(2)= (g◦f)(3)= (g◦f)(4)= So, g◦f=
{(1, x), (2, x), (3, y), (4, z)}.
g(f(1))=g(a)=x.g(f(2))=g(a)=x.g(f(3))=g(b)=y.g(f(4))=g(c)=z.
THEOREM 5.5Let f: A→B and g: B →C. If f and g are one-
to-one, then g◦f is one-to-one.
pf. 1. It suffices to show(g◦f)(a1)=(g◦f)(a2) for a1, a2∈A ⇒ a1=a2.2. (g◦f)(a1)=(g◦f)(a2)
⇒ g(f(a1))= g(f(a2)) ⇒ f(a1))= f(a2) ⇒ a1=a2
because g is one-to-one. because f is one-to-one.
THEOREM 5.5 (2)Let f: A→B and g: B →C. If f and g are onto, then
g◦f is onto.
pf. 1. It suffices to showz∈C there exists⇒ x∈A such that g(f(x))=z.2. z∈C
⇒ there exists y∈B such that g(y)=z
⇒ there exists x∈A such that f(x)=y
⇒ there exists x∈A such that g(f(x))=z.
because g is onto.
because f is onto.
THEOREM 5.6Let f: A→B, g: B →C, and h: C →D, then (h◦g)◦f =
h◦(g◦f).
pf. 1. Since the two functions have the same domain, , and codomain, , it suffices to show
((h◦g)◦f)(x) = (h◦(g◦f))(x) for every x∈A.A D
THEOREM 5.62. (g◦f)(x)=g(f(x)).3. (h◦(g◦f))(x) = h(g(f(x))).4. Similarly, ((h◦g)◦f)(x) = h(g(f(x))).
Converse of RelationFor sets A, B, if R is a relation from A to B,
then the converse of R, denoted Rc, is therelation from B to A defined by Rc={(b, a)|(a,
b)∈R}.
e.g. With A={1, 2, 3, 4}, B={w, x, y}, and R={(1,w), (2,w), (3,x)}. Then,
Rc= {(w, 1), (w, 2), (x, 3)}.
Invertible FunctionIf f: A→B, then f is said to be invertible if
there is a function g: B→A such thatg◦f=IA and f◦g=IB.
e.g. Let f: R→R be defined by f(x)=2x+5. Find the invertible function of f.
Let g: R→R be the invertible function of f. Then, g(f(x))=IA(x)=x.
⇒ g(2x+5)=x.⇒ g(2x+5)=((2x+5)-5)/2.⇒ g(x)=(x-5)/2.
THEOREM 5.7If a function f: A→B is invertible and a
function g: B→A satisfies g◦f=IA andf◦g=IB, then this function g is unique.
pf. 1. Let h: B→A be another function with h◦f=IA and f◦h=IB. It suffices to show
h=g.2. h=h◦IB
=h◦(f◦g)=(h◦f )◦g=IA◦g=g.
THEOREM 5.8
A function f: A→B is invertible if and only if it is one-to-one and onto.
THEOREM 5.8 (Proof of only if part)
f is invertible ⇒ f is one-to-one and onto (f: A→B).
pf. 1. Let g be the invertible function of f. To show f is one-to-one, it suffices to show
a1, a2∈A with f(a1)=f(a2) ⇒ a1=a2.2. f(a1)=f(a2)⇒ g(f(a1))=g(f(a2))
⇒ a1=a2
3. To show f is onto, it suffices to show for any b∈B, b=f(a) for some a∈A.4. g(b)∈A and f(g(b))=b because f◦g=IB.5. Therefore, g(b) is the desired a.
because g◦f=IA.
THEOREM 5.8 (Proof of if part)f is invertible ⇐ f is one-to-one and onto (f: A→B).
pf. 1. It suffices to showthere is a function g: B→A such that g◦f= and
f◦g= . 2. Since f is onto, for each b∈B there is an a∈A
with f(a)=b.3. Define the function g: B→A by g(b)=a.4. g is unique because f is one-to-one.5. Clearly, g(f(a))=g(b)=a, implying g◦f=IA.6. And, f(g(b))=f(a)=b, implying f◦g=IB.
IA
IB
THEOREM 5.9If f: A→B, g: B →C are invertible functions, then
g◦f: A→C is invertible and (g◦f)−1 = f−1◦g−1.
pf. 1. f and g each are one-to-one and onto by Theorem 5.8.2. g◦f is one-to-one and onto by3. g◦f is invertible by4. Suppose that f(a)=b and g(b)=c, where a∈A,
b∈B, and c∈C.5. Clearly, (g◦f)−1(c)=a=f-1(b)=f-1(g-1(c)), implying (g◦f)
−1 = f−1◦g−1.
Theorem 5.5.Theorem 5.8.
PreimageIf f: A→B and B1⊆B, then f−1(B1)={x∈A|f
(x)∈B1}. The set f−1(B1) is calledthe preimage of B1 under f .
e.g. Let A={1, 2, 3, 4, 5, 6} and B={6, 7, 8, 9, 10}. If f: A→B with f={(1, 7), (2, 7), (3, 8), (4, 6), (5, 9), (6, 9)}, then
for B1={6, 8}⊆B, f−1(B1)={3, 4}.
Remark: Here, f is not necessary to be invertible.
Example 5.63
What is f-1[-5,-5]?
Example 5.63
Sol: f-1[-5,-5]= [-4/3,10/3].
Theorem 5.10
Proof of (b): 1. It suffices to show for a∈A, a∈f-1(B1⋃B2) ⇔ a∈f-1(B1)⋃f-1(B2).2. a∈f-1(B1⋃B2)⇔ f(a)∈B1⋃B2
⇔ f(a)∈B1 or f(a)∈B2
⇔ a∈f-1(B1) or a∈f-1(B2)⇔ a∈f-1(B1)⋃f-1(B2).
Theorem 5.11
1.By Theorem 5.8, (a) and (b) ⇔ (c). It suffices to show
2. (Proof of (a) (b)). If ⇒ f is one-to-one, |A|= .Then =|B|, implying f is onto.3. (Proof of (b) ⇒ (a)). If f is onto, =|B|.Then =|A|, implying f is one-to-one.
(a) ⇔ (b).|f(A)|
|f(A)||f(A)|
|f(A)|