R. Johnsonbaugh, Discrete Mathematics 5th edition, 2001

advertisement
CS1110 - Discrete Mathematics
MODULE :- 5
1. Relations
 Given two sets X and Y, its Cartesian product XxY
is the set of all ordered pairs (x,y) where xX and
yY
 In symbols XxY = {(x, y) | xX and yY}
 A binary relation R from a set X to a set Y is a
subset of the Cartesian product XxY
 Example: X = {1, 2, 3} and Y = {a, b}
 R = {(1,a), (1,b), (2,b), (3,a)} is a relation between X
and Y
Domain and Range
Given a relation R from X to Y,
 The domain of R is the set
 Dom(R) = { xX | (x, y) R for some yY}
 The range of R is the set
 Rng(R) = { yY | (x, y) R for some x X}
 Example:
 if X = {1, 2, 3} and Y = {a, b}
 R = {(1,a), (1,b), (2,b)}
 Then: Dom(R)= {1, 2}, Rng(R) = (a, b}
Example of a relation
 Let X = {1, 2, 3} and Y = {a, b, c, d}.
 Define R = {(1,a), (1,d), (2,a), (2,b), (2,c)}
 The relation can be pictured by a graph:
Properties of relations
Let R be a relation on a set X
i.e. R is a subset of the Cartesian product XxX
 R is reflexive if (x,x) R for every xX
 R is symmetric if for all x, y X such that (x,y) R
then (y,x) R
 R is transitive if (x,y) R and (y,z) R imply (x,z)
R
 R is antisymmetric if for all x,yX such that xy, if
(x,y) R then (y,x) R
Example:
Consider the relation  on the set N.
 This relation is reflexive because for any nonnegative
integer x, x  x.
 It is also transitive because for any nonnegative integers
x,y, and z, if x  y and y  z, then x  z.
 The relation is not symmetric; 3  4 does not imply 4 
3.
 The relation is antisymmetric since for any nonnegative
integers x, and y, if both x  y and y  x, then y = x.
Types of binary relations
 one-to-one
Each first component and each second component appears only
once in the relation.
S
T
 one-to-many
Some first component S1 appears more than once; that is, one S1,
is paired with more than one second component.
S
T
 many-to-one
Some second component S2 appears more than once; that is, one
S2, is paired with more than one first component.
S
T
 many-to-many
At least one first component S1 is paired with more than one
second component, and at least one second component S2 is
paired with more than one first component.
S
T
Order relations
Let X be a set and R is a relation on X, R is a
partial order on X if R is reflexive,
antisymmetric and transitive.
Let x,yX
 If (x,y) or (y,x) are in R, then x and y are
comparable
 If (x,y) R and (y,x) R then x and y are
incomparable
If every pair of elements in X are comparable,
then R is a total order on X
Inverse of a relation
Given a relation R from X to Y, its inverse R-1
is the relation from Y to X defined by
R-1 = { (y,x) | (x,y)  R }
Example: if R = {(1,a), (1,d), (2,a), (2,b), (2,c)}
then R -1= {(a,1), (d,1), (a,2), (b,2), (c,2)}
Equivalence relations
Let X be a set and R a relation on X
 R is an equivalence relation on X  R is
reflexive, symmetric and transitive.
 Example: Let X = {integers} and R be the
relation on X defined by: xRy  x - y = 5. It is
easy to show that R is an equivalence relation
on the set of integers.
2. Functions
 Let X and Y be two non-empty
sets. A function f from X to Y is
an association of every element
of X to an unique element in Y.
We write this as f : X g Y
 Example:
Dom(f) = X = {a, b, c, d},
Y = {1, 2, 3, 4, 5},
Rng(f) = {1, 3, 5}
Y is called the co-domain of f.
f(a) = f(b) = 3, f(c) = 5, f(d) = 1.
Domain and Range
 Domain of f = X
 Range of f =
{ y | y = f(x) for some x X}
 A function f : X  Y assigns to
each x in Dom(f) = X a unique
element y in Rng(f)  Y.
 Therefore, no two pairs in f have
the same first coordinate.
Examples of Functions
One-to-one Functions
 A function f : X  Y is one-to-one 
for each y  Y there exists at most one x  X with
f(x) = y.
 Alternative definition: f : X  Y is one-to-one  for
each pair of distinct elements x1, x2  X there exist
two distinct elements y1, y2  Y such that f(x1) = y1
and f(x2) = y2.
Examples:
 1. The function f(x) = 2x from the set of real numbers to itself is oneto-one
 2. The function f : R  R defined by f(x) = x2 is not one-to-one,
since for every real number x, f(x) = f(-x).
Onto Functions
A function f : X  Y is onto 
for each y  Y there exists at least one x  X with
f(x) = y, i.e. Rng(f) = Y.
 Example: The function f(x) = ex from the set of real
numbers to itself is not onto Y = the set of all real
numbers. However, if Y is restricted to Rng(f) = R +,
the set of positive real numbers, then f(x) is onto.
Bijective Functions
A function f : X Y is bijective  f is one-to-one
and onto.
 Examples:
 1. A linear function f(x) = ax + b is a bijective function from
the set of real numbers to itself
 2. The function f(x) = x3 is bijective from the set of real
numbers to itself.
Inverse Function
 Given a function y = f(x), the inverse f
-1
is the set
{(y, x) | y = f(x)}.
 The inverse f -1 of f is not necessarily a function.
(4) = 4 = ± 2, not a
unique value and therefore f is not a function.
 Example: if f(x) = x2, then f
-1
 However, if f is a bijective function, it can be
shown that f -1 is a function.
Exponential and Logarithmic Functions
 Let f(x) = 2x and g(x) = log
2
 f ◦ g(x) = f(g(x)) = f(lg x) = 2
x = lg x
lg x
=x
 g ◦ f(x) = g(f(x)) = g(2x) = lg 2x = x
 Therefore, the exponential and logarithmic
functions are inverses of each other.
Composition of Functions
 Given two functions g : X  Y and f : Y  Z, the
composition f ◦ g is defined as follows:
f ◦ g (x) = f(g(x)) for every x  X.
Example: g(x) = x2 -1, f(x) = 3x + 5. Then
f ◦ g(x) = f(g(x)) = f(3x + 5) = (3x + 5)2 - 1
 Composition of functions is associative:
f ◦ (g ◦h) = (f ◦ g) ◦ h,
 But, in general, it is not commutative:
f ◦ g  g ◦ f.
Download