You are on page 1of 33

CSC331 Discrete Structures

and Logic
October, 2012
Topic C
Functions, sequences, and
relations
Topic C Functions, sequences,
and relations
Section 3.1 Functions
Section 3.2 Sequences and Strings
Section 3.3 Relations
Section 3.4 Equivalence Relations
Section 3.1 Functions
Given two sets X and Y, its Cartesian product XxY
is the set of all ordered pairs (x,y) where xeX and
yeY
In symbols X x Y = {(x, y) | xeX and yeY}
Let X and Y be sets. A function f from X to Y is a
subset of the Cartesian product X x Y having the
property for each xeX, there is exactly one yeY
with (x, y) e f. A function f from X to Y as f: X Y
The set X is called the domain of f
The set {y | (x, y) e f } is called the range of f.
Basic definitions
If x is an integer and y is a positive integer, we
define x mod y to be the remainder when x is
divided by y.
The floor of x, denoted , is the greatest integer
less than or equal to x. the ceiling of x, denoted ,
is the least integer greater than or equal to x.


Modulus operator
Let x be a nonnegative integer and y a positive
integer
r = x mod y is the remainder when x is divided
by y
Examples:
1 = 13 mod 3
6 = 234 mod 19
4 = 2002 mod 111
mod is called the modulus operator
One-to-one, onto, and bijection
A function f from X to Y is said to be one-to-one (or
injective) y e Y, there is at most one x e X with f(x)
= y
If f is a function from X to Y and the range of f is Y,
f is said to be onto Y (or an onto function or a
surjective function) .
A function that is both one-to-one and onto is
called a bijection.


One-to-one functions
A function f : X Y is one-to-one
for each y e Y there exists at most one x e X
with f(x) = y.
Alternative definition: f : X Y is one-to-one
for each pair of distinct elements x
1
, x
2
e X there
exist two distinct elements y
1
, y
2
e Y such that
f(x
1
) = y
1
and f(x
2
) = y
2
.
Examples:
1. The function f(x) = 2
x
from the set of real numbers to itself is
one-to-one
2. The function f : R R defined by f(x) = x
2
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 e Y there exists at least one x e X
with f(x) = y, i.e. Rng(f) = Y.
Example: The function f(x) = e
x
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) = x
3
is bijective from the set of real
numbers to itself.

Composition, Binary and Unary
Operator
Let g be a function from X to Y and let f be a
function from Y to Z. The composition of f with g,
denoted f g, is the function


from X to Z.
A function from X x X to X is called a binary
operator on X.
A function from X to X is called a unary operator on
X.





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.
Example: if f(x) = x
2
, then f
-1
(4) = \4 = 2, not a
unique value and therefore f is not a function.
However, if f is a bijective function, it can be
shown that f
-1
is a function.
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 e X.
Example: g(x) = x
2
-1, f(x) = 3x + 5. Then
f g(x) = f(g(x)) = f(x
2
-1) = 3(x
2
-1) + 5
= 3x
2
+ 2
Composition of functions is associative:
f (g h) = (f g) h,
But, in general, it is not commutative:
f g = g f.
Binary operators
A binary operator on a set X is a function f that
associates a single element of X to every pair of
elements in X, i.e. f : X x X X and f(x
1
, x
2
) e X
for every pair of elements x
1
, x
2
.

Examples of binary operators are addition,
subtraction and multiplication of real numbers, taking
unions or intersections of sets, concatenation of two
strings over a set X, etc.
Unary operators
A unary operator on a set X associates to
each single element of X one element of X.
Examples:
1. Let X = U be a universal set and P(U) the power
set of U. Define f : P(U) P(U) the function
defined by f (A) = A', the set complement of A in U,
for every A _ U. Then f defines a unary operator
on P(U).

Exponential and
logarithmic functions
Let f(x) = 2
x
and g(x) = log
2
x = lg x

f g(x) = f(g(x)) = f(lg x) = 2
lg x
= x
g f(x) = g(f(x)) = g(2
x
) = lg 2
x
= x

Therefore, the exponential and logarithmic
functions are inverses of each other.
Section 3.2 Sequences and strings
A sequence is an ordered list of numbers,
usually defined according to a formula: s
n
= a
function of n = 1, 2, 3,...
If s is a sequence {s
n
| n = 1, 2, 3,},
s
1
denotes the first element,
s
2
the second element,
s
n
the nth element
{n} is called the indexing set of the sequence.
Usually the indexing set is N (natural numbers)
or an infinite subset of N.
Examples of sequences
Examples:
1. Let s = {s
n
} be the sequence defined by
s
n
= 1/n , for n = 1, 2, 3,
The first few elements of the sequence are: 1, , 1/3, ,
1/5,1/6,
2. Let s = {s
n
} be the sequence defined by
s
n
= n
2
+ 1, for n = 1, 2, 3,
The first few elements of s are: 2, 5, 10, 17, 26, 37, 50,

Increasing and decreasing
A sequence s = {s
n
} is said to be
increasing if s
n
< s
n+1

decreasing is s
n
> s
n+1
,
for every n = 1, 2, 3,
Examples:
S
n
= 4 2n, n = 1, 2, 3, is decreasing:
2, 0, -2, -4, -6,

S
n
= 2n -1, n = 1, 2, 3, is increasing:
1, 3, 5, 7, 9,
Subsequences
A subsequence of a sequence s = {s
n
} is a
sequence t = {t
n
} that consists of certain
elements of s retained in the original order
they had in s
Example: let s = {s
n
= n | n = 1, 2, 3,}
1, 2, 3, 4, 5, 6, 7, 8,
Let t = {t
n
= 2n | n = 1, 2, 3,}
2, 4, 6, 8, 10, 12, 14, 16,
t is a subsequence of s


Sigma notation

If {a
n
} is a sequence, then the sum

m
E a
k
= a
1
+ a
2
+ + a
m
k

= 1
This is called the sigma notation, where the
Greek letter E indicates a sum of terms
from the sequence


Pi notation

If {a
n
} is a sequence, then the product

m
H a
k
= a
1
a
2
a
m
k=1

This is called the pi notation, where the
Greek letter H indicates a product of terms
of the sequence
Strings

Let X be a nonempty set. A string over X is a
finite sequence of elements from X.
Example: if X = {a, b, c}
Then o = bbaccc is a string over X
Notation: bbaccc = b
2
ac
3
The length of a string o is the number of elements of
o and is denoted by |o|. If o = b
2
ac
3
then |o| = 6.
The null string is the string with no elements and
is denoted by the Greek letter (lambda). It has
length zero.
Section 3.3 Relations
Given two sets X and Y, its Cartesian product
XxY is the set of all ordered pairs (x,y) where
xeX and yeY
In symbols XxY = {(x, y) | xeX and yeY}

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) = { xeX | (x, y) eR for some yeY}
The range of R is the set
Rng(R) = { yeY | (x, y) eR for some x eX}
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) eR for every xeX
R is symmetric if for all x, y eX such that (x,y)
eR then (y,x) eR
R is transitive if (x,y) eR and (y,z) eR imply
(x,z) eR
R is antisymmetric if for all x,yeX such that
x=y, if (x,y) eR then (y,x) eR

Order relations
Let X be a set and R a relation on X
R is a partial order on X if R is reflexive,
antisymmetric and transitive.
Let x,yeX
If (x,y) or (y,x) are in R, then x and y are
comparable
If (x,y) eR and (y,x) eR 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) e 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)}



Section 3.4 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.
Partitions
A partition S on a set X is a family
{A
1
, A
2
,, A
n
} of subsets of X, such
that
A
1
A
2
A
3
A
n
= X
A
j
A
k
= C for every j, k with j = k,
1 < j, k < n.
Example: if X = {integers}, E = {even
integers) and O = {odd integers}, then
S = {E, O} is a partition of X.

Partitions and equivalence relations
Theorem 3.4.1: Let S be a partition on a set X.
Define a relation R on X by xRy if x, y are in the
same set T for T e S. Then R is an equivalence
relation on X.
i.e. an equivalence relation on a set X corresponds to a
partition of X and conversely.
Equivalence classes
Let X be a set and let R be an equivalence
relation on X. Let a e X.
Define [a] ={ xeX | xRa }
Let S = { [a] | a e X }
Theorem 3.4.8: S is a partition on X.
The sets [a] are called equivalence classes
of X induced by the relation R.
Given a, b e X, then [a] = [b] or [a][b] = C
Set of equivalence classes
If R is an equivalence relation on a set X, define
X/R = {[a] | a e X }.

Theorem 3.4.16: If each equivalence class on a
finite set X has k elements, then X/R has |X|/k
elements, i.e. |X/R| = |X|/ k.

You might also like