Title: Chapter 5
1Chapter 5 Relations and Functions
25.1 Cartesian Products and Relations
- Definition 5.1 For sets A, B ? U, the Cartesian
product, or cross product, of A and B is denoted
by A ? B and equals (a, b) a ? A, b ? B. - We say that the elements of A ? B are ordered
pairs. The following properties hold - For (a, b), (c, d) ? A ? B, we have (a, b) (c,
d) if and only if a c and b d. - If A, B are finite, it follows from the rule of
product that A ? B A ? B. We will have
A ? B B ? A, but not have A ? B B ? A. - Although A, B ? U, it is not necessary that A ? B
? U. - If n ? Z, n ? 3, and A1, A2, , An ? U, then the
(n-fold) product of A1, A2, , An is denoted by
A1?A2??An and equals (a1,a2,,an) ai ?Ai ,
1?i?n. - The elements of A1?A2??An are called ordered
n-tuples. - If (a1,a2,,an), (b1,b2,,bn) ? A1?A2??An, then
(a1,a2,,an) (b1,b2,,bn) if and only if ai
bi, for all 1?i?n.
3Example 5.1 and 5.2 page 218.
4Definition 5.2
- For sets A, B ? U, any subset of A ? B is called
a relation from A to B. Any subset of A ? A is
called a binary relation on A.
5Example 5.5 page 220.
6Lemma
- For finite sets A, B with A m and B n,
there are 2mn relations from A to B, including
the empty relation and A ? B itself. There are
also 2nm (2mn) relations from B to A, one of
which is also ? and another of which is B ? A.
7Example 5.6 page 220
8Example 5.7 page 220221. (note on infix
notation for a relation!)
9Observations
- For any set A ? U, A?? ?. (If A?? ??, let (a, b)
? A ? ?. Then a?A and b??. Impossible!) Likewise,
? ?A?.
10Theorem 5.1
- For any sets A, B, C ? U A ? (B ? C) (A ? B)
? (A ? C) A ? (B ? C) (A ? B) ? (A ? C) (A ?
B) ? C (A ? C) ? (B ? C) (A ? B) ? C (A ? C) ?
(B ? C)
115.2 Functions Plain and One-to-One
- Definition 5.3 For nonempty sets A, B, a
function, or mapping, f from A to B, denoted fA
? B, is a relation from A to B in which every
element of A appears exactly once as the first
component of an ordered pair in the relation. - We often write f(a)b when (a, b) is an ordered
pair in the function f. For (a,b)?f, b is called
the image of a under f, whereas a is a preimage
of b. - The definition suggests that f is a method for
associating with each a ? A the unique element
f(a)b?B. Consequently, (a,b), (a,c)?f implies
bc.
12Example 5.9 page 223.
13Definition 5.4
- For the function fA ? 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. (See Fig 5.4)This diagram
suggests that a may be regarded as an input that
is transformed by f into the corresponding
output, f(a).)
14(No Transcript)
15Example 5.10 page 223224.
16Example 5.10
17Example 5.10
18Lemma
- If A a1,a2,,am and B b1,b2,,bn, then a
typical function fA ? B can be described by
(a1,x1), (a2,x2), , (am,xm). We can select any
of the n elements of B for x1 and then do the
same for x2 (so that the same element of B may be
selected for both x1 and x2). We continue this
selection process until one of the n elements of
B is finally selected for xm. In this way, using
the rule of product, there are nm BA
functions from A to B.
19Definition
- Definition 5.5 A function fA ? B is called
one-to-one, or injective, if each element of B
appears at most once as the image of an element
of A. - If fA ? B is one-to-one, with A, B finite, we
must have A ? B. - For arbitrary sets A, B, fA ? B is one-to-one if
and only if for all a1,a2 ? A, f(a1) f(a2) ?
a1a2.
20Example 5.13 page 226.
21Example 5.14 page 226.
22Lemma
- With A a1,a2,,am, B b1,b2,,bn, and m?n,
a one-to-one function fA ? B has the form
(a1,x1), (a2,x2), , (am,xm), where there are n
choices for x1 (that is, any element of B), n 1
choices for x2 (that is, any element of B except
the one chosen for x1), n 2 choices for x3, and
so on, finishing with n (m 1) n m 1
choices for xm. - By the rule of product, the number of one-to-one
functions from A to B is n(n 1)(n 2)(n m
1) n!/(n m)! P(n, m) P(B, A).
23Definition 5.6
- If fA ? B and A1 ? A, then f(A1)
b?Bbf(a), for some a?A1, and f(A1) is
called the image of A1 under f.
24Example 5.15 page 227.
25Example 5.16 page 227.
26Theorem 5.2
- Let fA ? B, with A1, A2 ? A. Thenf(A1 ? A2)
f(A1) ? f(A2) f(A1 ? A2) ? f(A1) ? f(A2) f(A1
? A2) f(A1) ? f(A2) when f is injective. - Definition 5.7 If fA ? B and A1 ? A, then
fA1A1 ? B is called the restriction of f to A1
if fA1(a) f(a) for all a ? A1. - Definition 5.8 Let A1 ? A and fA1 ? B. If gA ?
B and g(a) f(a) for all a ? A1, then we call g
an extension of f to A.
27Example 5.17 page 228.
28Example 5.18 page 228
295.3 Onto Functions Stirling Numbers of the
Second Kind
- Definition 5.9 A function fA ? 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.
30Example 5.19 page 231.
31Example 5.20
32Example 5.21
33Example 5.22 page 231232.
34Example 5.23
35Lemma
- For finite sets A, B with A m and B n,
there are - onto functions from A to B.
36Example 5.24 page 232.
- ( calculate the distribution of 7 different
objects into 4 distinct containers with no
container left empty!)
37Example 5.25 page 233
38Lemma
- For m ? n there are ways
to distribute m distinct objects into n numbered
(but otherwise identical) containers with no
container left empty. - Removing the numbers on the containers, so that
they are now identical in appearance, we find
that one distribution into these n (nonempty)
identical containers corresponds with n! such
distributions into the numbered containers.
39- So the number of ways in which it is possible to
distribute the m distinct objects into n
identical containers, with no container left
empty, is - This will be denoted by S(m, n) and is called a
Stirling number of the second kind. We note that
for A m ? n B, there are n!?S(m, n) onto
functions from A to B.
40Table 5.1
41Theorem 5.3
- Let m, n be positive integers with 1 lt n ? m.
ThenS(m1, n) S(m, n-1) nS(m, n).
42Example 5.28 page 235.
435.4 Special Functions
- Definition 5.10 For any nonempty sets A, B, any
function fA?A ? B is called a binary operation
on A. If 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.) - Definition 5.11 A function gA ? A is called a
uniary, or monary, operation on A.
44Example 5.29 page 238.
45Definition 5.12
- Let fA?A ? B that is, f is a binary operation
on A. f is said to be commutative if f(a, b)
f(b, a) for all (a, b) ? A?A. - When B?A (that is, when f is closed), f is said
to be associative if for all a, b, c ? A, f(f(a,
b), c) f(a, f(b, c)).
46Example 5.32 page 239.
47Example 5.32 page 239
48Definition 5.13
- Let fA?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 a?A.
49Example 5.34 page 240.
50Theorem 5.4
- Let fA?A ? B be a binary operation. If f has an
identity, then that identity is unique.
51Definition 5.14
- For sets A and B, if D ? A?B, then ?AD ? A,
defined by ?A(a,b) a, is called the projection
on the first coordinate. - Then ?BD ? B, defined by ?B(a,b) b, is called
the projection on the second coordinate.
52Example 5.36 page 241.
53Lemma
- Let A1, A2, , An be sets, and with and m?n. If
D ? A1?A2??An , then the function defined by
is the projection of D on the i1th, i2th,, imth
coordinates. The elements of D are called
(ordered) n-tuples an element in ?(D) is an
(ordered) m-tuple. (These projections arise in a
natural way in the study of relational
databases.)
54Example 5.38 page 242. (applications to
relational databases)
55(No Transcript)
565.5 The Pigeonhole Principle????
- In mathematics one sometimes finds that an almost
obvious idea, when applied in a rather subtle
manner, is the key needed to solve a troublesome
problem. - The Pigeonhole Principle If m pigeons occupy n
pigeonholes and m gt n, then at least one
pigeonhole has two or more pigeons roosting in
it.
57(No Transcript)
58Example 5.39 page 245.
59Example 5.41 page 245.
60Example 5.43 page 246
61Example 5.45 page 246.
62Example 5.47 page 247.
63Example 5.48 page 248
645.6 Function Composition and Inverse Functions
- In this section we study a method for combining
two functions into a single function. Then we
develop the concept of the inverse (of a
function) for functions. - Definition 5.15 If fA ? B, then f is said to be
bijective, or to be a one-to-one correspondence,
if f is both one-to-one and onto.
65Example 5.50 page 250.
66Definition
- Definition 5.16 The function IA A ? A, defined
by IA(a) a for all a ? A, is called the
identity function for A. - Definition 5.17 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.
67Example 5.51 page 250.
68Example 5.52 page 250251.
69Definition 5.18
- If 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.
70Example 5.53 page 251.
71Example 5.54 page 251.
- For any f A ? B, we observe that f ? IA f IB
? f.
72Theorem 5.5
- Let f A ? B and g B ? C. If f, g are
one-to-one, then g?f is one-to-one. If f, g are
onto, then g?f is onto.
73Example 5.55 page 252.
74(No Transcript)
75Theorem 5.6
- If f A ? B, g B ? C, and h C ? D, then (h?g)?f
h?(g?f).
76Definition 5.19
- If f A ? A, we define f1 f, and for n ? Z,
fn1f?(fn). - Example 5.56 page 253.
77Definition 5.20
- For sets A, B ? U, if ? is a relation from A to
B, then the converse of ?, denoted ?c, is the
relation from B to A defined by ?c (b, a)(a,
b) ? ?.
78Example 5.57 page 254.
79Definition 5.21
- If f A ? B, then f is said to be invertible if
there is a function g B ? A such that g?f IA
and f?g IB.
80Example 5.58 page 254.
81Theorem 5.7
- If a function f A ? B is invertible and a
function g B ? A satisfies g?f IA and f?g
IB, then this function g is unique. Note As a
result of this theorem we shall call the function
g the inverse of f and shall adopt the notation g
f-1. Theorem 5.7 also implies that f-1 fc.
Whenever f is an invertible function, so is the
function f-1, and (f-1)-1 f.
82Theorem 5.8
- A function f A ? B is invertible if and only if
it is one-to-one and onto.
83Example 5.59 page 255.
84Theorem 5.9
- if f A ? B, g B ? C are invertible functions,
then g?f A ? C is invertible and (g?f) -1
f-1?g-1.
85Example 5.60 page 255
86Definition 5.22
- if f A ? B and B1 ? B, then f-1 (B1) x ?
Af(x) ? B1. The set f-1 (B1) is called the
preimage of B1 under f.
87Example 5.62 page 256
88Example 5.63 page 257.
89(No Transcript)
90Example 2.63
91Example 2.63
92Example 2.64
93Theorem 5.10
- If f A ? B and B1, B2 ? B, then f-1(B1 ? B2)
f-1 (B1) ? f-1 (B2) f-1 (B1 ? B2) f-1 (B1) ?
f-1 (B2) and
94Theorem 5.11
- Let f A ? B for finite sets A and B, where A
B. Then the following statements are
equivalent (a) f is one-to-one (b) f is onto
and (c) f is invertible.
955.7 Computational Complexity
- For a searching algorithm, how long does it take
for a success or fail search? To measure this we
seek a function f(n), called the time-complexity
function of the algorithm. We expect that the
value of f(n) will increase as n increases.
96Definition 5.23
- Let f, g Z ? R. We say that g dominates f (or f
is dominated by g) if there exist constants m ?
R and k ? Z such that f(n) ? mg(n) for all
n ? Z, where n?k. Note When f is dominated by
g we say that f is of order (at most) g and we
use what is called bigOh notation to designate
this. We write f ? O(g), where O(g) is read
order g or bigOh of g. As suggested by the
notation f ? O(g), O(g) represents the set of
all functions with domain Z and codomain R that
are dominated by g.
97Example 5.65 page 262.
98Example 5.67 page 263.
99Example 5.68 page 264.
100Complexity
- Some of the most important of these orders are
listed in Table 5.11.
1015.8 Analysis of Algorithms
102- In Fig 5.17 we have graphed a log-linear plot for
the functions associated with some of the orders
given in Table 5.11.
103- The data in Table 5.12 provide estimates of the
running times of algorithms for certain orders of
complexity.