100% found this document useful (1 vote)
102 views52 pages

Chapter 5: Relations, Functions, and Matrices: Tannaz R.Damavandi Cal Poly Pomona

This document covers binary relations and functions. It defines binary relations as subsets of ordered pairs between elements of two sets. It discusses types of relations such as one-to-one, one-to-many, many-to-one, and many-to-many. Properties of relations like reflexive, symmetric, transitive, and antisymmetric are explained. Closures of relations with respect to these properties are introduced. Partial orderings and equivalence relations are defined. Examples of relations between numbers and sets are provided to illustrate the concepts.

Uploaded by

CL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
102 views52 pages

Chapter 5: Relations, Functions, and Matrices: Tannaz R.Damavandi Cal Poly Pomona

This document covers binary relations and functions. It defines binary relations as subsets of ordered pairs between elements of two sets. It discusses types of relations such as one-to-one, one-to-many, many-to-one, and many-to-many. Properties of relations like reflexive, symmetric, transitive, and antisymmetric are explained. Closures of relations with respect to these properties are introduced. Partial orderings and equivalence relations are defined. Examples of relations between numbers and sets are provided to illustrate the concepts.

Uploaded by

CL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Chapter 5: Relations, Functions, and Matrices

Tannaz R.Damavandi
Cal Poly Pomona

Credit for some of the slides in this lecture goes to Dr.Fang Tang
Outline
2

• 5.1- Relations
• 5.2- Topological Sorting
• 5.3- Relations and Databases
• 5.4- Functions
• 5.5 - Order of Magnitude
• 5.6 - The Mighty Mod Function
• 5.7- Matrices
Section 5.1 – Relations
Binary relations
The parent-child, husband-wife, teacher-student and… are some examples of binary
relation on the set of people.
S= {Homer, Marge, Bart, Lisa, Maggie}
SxS = {(Homer, Marge), (Homer, Bart), (Homer, Lisa), (Homer, Maggie), (Marge, Homer),
(Marge, Bart), (Marge, Lisa), (Marge, Bart) , …}
Binary Relations
• A binary relation from a set S to a set T is a subset of ordered pairs (x, y) where x is an
element of S and y is an element of T.
The notation x r y implies that the ordered pair (x,y) satisfies the relationship r.

• Given a set S, a binary relation on a set S is a subset of S x S (a set of ordered pairs of elements
of S).

Example :
Let S = {1,2,4}. On the set S x S = {(1,1), (1,2), (1,4), (2,1), (2,2), (2,4), (4,1),(4,2), (4,4)}, a
𝑦 𝑦
relation r can be defined by x r y if and only if x= , abbreviated x r y  𝑥 = .
2 2
Thus {(1,2), (2,4)} is the set of ordered pairs satisfying r.
• A binary relation is a subset, and we see that
x r y  (x,y)  r

5
Examples
a) Let S ={1,2}. Then S x S = {(1,1),(1,2), (2,1),(2,2)}. Let r on S be given by
description x r y  x + y is odd. Then (1,2) ∈ r and (2,1) ∈ r. The ordered pair
(1,1) ∉ r because 1+1 is not odd. Similarly (2,2) ∉ r.

b) Let S ={1,2}. Then S x S = {(1,1),(1,2), (2,1),(2,2)}. If r is defined on S r = {(1,1) ,


(2,1)}, then 1 r 1 and 2 r 1 hold, but not for instance, 1 r 2 . Here r seems to
have no obvious verbal description.

c) Let S = {1,2,3} and T = {2,4,7}, Then the set { (1,2) , (2,4), (2,7)} consists of
elements from S x T . It is a binary relation from S to T.

6
Practice #1
For each of the following binary relations r on N, decide which of
the given ordered pairs belong to r .
 x r y  x = y+1; (2, 2), (2, 3), (3, 3), (3, 2)
(3, 2)  r
 x r y  x divides y; (2, 4), (2, 5), (2, 6)
(2, 4), (2, 6)  r
 x r y  x is odd; (2, 3), (3, 4), (4, 6), (5, 6)
(3, 4), (5, 6)  r
 x r y  x > y2; (1, 2), (2, 1), (5, 2), (6, 4), (4, 3)
(2, 1), (5, 2)  r

7
Relations on Multiple Sets
Given two sets S and T , a binary relation from S to T (also called
a binary relation on S x T ) is a subset of S x T. Given n sets S1 , S2
, …, Sn , n >2, an n-ary relation on S1 x S2 x …x Sn is a subset of S1
x S2 x …x Sn .

8
Types of Relations
• One-to-one:
if each first component and each
second component only appear once
in the relation.

• One-to-many:
if a first component is paired with
more than one second component.

9
Types of Relations (Cont’d)
• Many-to-one:
if a second component is paired with more than one
first component.

• Many-to-many:
if at least one first component is paired with more
than one second component and if at least one
second component is paired with more than one first
component.
10
Practice #2
Identify each of these relations on S, where
S = {2, 5, 7, 9} as one-to-one, one-to-many, many-to-one, many-
to-many:
 {(5, 2), (7, 5), (9, 2)}
Many-to one
 {(2, 5), (5, 7), (7, 2)}
One-to-one
 {(7, 9), (2, 5), (9, 9), (2, 7)}
Many-to many

11
Practice #3
Let ρ and σ be two binary relations on N defined x ρ y ↔ x=y and
x σ y ↔ x<y. Give verbal descriptions for first 3 parts and give a set description for last
part.

 What is the relation ρ ∪ σ?


x (ρ ∪ σ )y ↔ x≤ y
 What is the relation ρ’?
x ρ’ y ↔ x ≠ y
 What is the relation σ’ ?
x σ’ y ↔ x ≥ y
 What is the relation ρ ꓵ σ ?
ρꓵσ=∅
12
Properties of Relations
• Let r be a binary relation on a set S. Then:
 r is reflexive where every x is related to itself.
 (x) (xS  (x,x)r)
 r is symmetric – If x is related to y, then y is related to x.
 (x)(y) (xS ∧ yS ∧ (x,y)  r  (y,x) r)
 r is transitive – If x is related to y and y is related to z, then x is
related to z.
 (x)(y)(z) (xS ∧ yS ∧ zS ∧ (x,y)r ∧ (y,z)r  (x,z)r)
 r is antisymmetric – If x is related to y and y is related to x ,
then x = y.
 (x)(y) (xS ∧ yS ∧ (x,y)  r ∧ (y,x) r  x = y)

13
Example
Consider the relation of equality on S, (x, y)  r  x = y
– Is this relation reflexive?
• Yes, since for every element x in S, x = x
– Is this relation symmetric?
• Yes, since for every element x, y in S and if x = y, then y = x
– Is this relation antisymmetric?
• Yes. Since x = y and y = x, it is antisymmetric
– Is this relation transitive?
• Yes. Since if x = y and y = z, then x = z

14
Practice #4
Let S = (N). Define a binary relation r on S by A r B  A  B.

 Is it reflexive?
 Yes. Because every set is a subset of itself.
 Is it symmetric?
 No, since A  B doesn't imply B  A.
 Is it transitive?
 Yes. Because if A  B and B  C, then A  C.
 Is it antisymmetric?
 Yes, because if A  B and B  A, then A and B are equal sets.

15
Practice #5
Let S= {1,2,3}.
If a relation ρ on S is reflexive. What ordered pairs must belong to ρ?
(1,1),(2,2),(3,3)

If a relation ρ on S is symmetric. What ordered pairs must belong to ρ?


We cannot say. knowing that a relation is symmetric doesn’t by itself give information about any of the ordered
pairs that might belong to ρ. If we know that a relation is symmetric and we know some ordered pairs that
belong to the relation, then we know certain other pairs that must belong to the relation
If a relation ρ on S is symmetric and if (a , b)  ρ, then what other ordered pairs must belong to ρ?
(b , a)

If a relation ρ on S is antisymmetric and if (a , b) and (b, a) belong to ρ, what must be true?


a=b

Is the relation ρ ={(1,2)} on S transitive?


Yes. Why? Because the transitive property says if (x , y)  ρ ∧ (y, z)  ρ then (x,z)  ρ . In this case (1,2) is the only
element of ρ and (2,z) ∉ρ for any z in S. Therefore the antecedent of the implication is always false, and the
implication is true ; hence, ρ is transitive.
16
Closures of Relations
If a relation r on a set S fails to have a certain property, we may
be able to extend r to a relation r* on S that does have that
property. By “extend”, we mean that the new relation r* will
contain all the ordered pairs in r plus the additional ordered
pairs needed for desired property to hold. Thus r⊆ r* .

• If r* is the smallest such set, then r* is called the closure of r


with respect to that property.

17
Closures of Relations
Definition
• A binary relation r* on a set S is the closure of a relation r on
S with respect to property P if
1. r* has the property P
2. r  r*
3. r* is a subset of any other relation on S that includes r and has the
property P

18
Example
Let S = {1,2,3} and r = {(1,1),(1,2),(1,3),(3,1),(2,3)}
 ρ is not reflexive, not symmetric, and not transitive , i.e : (3,2) ∉ ρ
The closure of r with respect to reflexivity is:
r*= {(1,1),(1,2),(1,3),(3,1),(2,3),(2,2),(3,3)} and it contains r
The closure of r with respect to symmetry is:
r*={(1,1),(1,2),(1,3),(3,1),(2,3),(2,1),(3,2)}
The closure of r with respect to transitivity is:
r*={(1,1),(1,2),(1,3),(3,1),(2,3),(2,1),(3,2),(3,3), (2, 2)}

Does it make sense to look for antisymmetric closure of a relation on a set? Why or
why not?
No. If the relation is antisymmetric , then it is its own antisymmetric closure. If it is
not antisymmetric then there are two order paired (x,y) and (y,x) in the relation but
x≠ y. Adding more ordered pairs will not change this situation.
19
Partial Orderings & Equivalence Relations
A binary relation on a set S that is reflexive, antisymmetric and transitive is
called a partial ordering on S
• Example:
– On N, x r y  x  y
– On {0,1}, x r y  x = y2  r = {(0,0), (1,1)}

A binary relation on a set S that is reflexive, symmetric and transitive is


called an equivalence relation on S
• Example:
– On N, x r y  x + y is even
– On {1,2,3}, r = {(1,1),(2,2),(3,3),(1,2),(2,1)}

20
Predecessor and Successor
We denote an arbitrary, partially ordered set by (S, ≤); ≤ has some definite
meaning such as less than or equal to, is a subset of, divides, etc.

• if x ≤ y, then either x = y or x != y
– if x ≤ y but x != y, we write x < y and say that x is a predecessor of y, or y is
a successor of x
– a given y may have many predecessors, but if x < y and there is no z with
x < z < y, then x is an immediate predecessor of y

21
Example
Consider the relation “x divides y ” on {1, 2, 3, 6, 12, 18}.

a. Write the ordered pairs (x, y) of this relation.


• (1, 1), (1, 2),(2, 2), (1, 3), (3, 3), (1, 6), (6, 6), (1, 12), (12, 12), (1, 18), (18,
18), (2, 6), (2, 12), (2, 18), (3, 6), (3, 12), (3, 18), (6, 12), (6, 18)

b. Write all the predecessors of 6.


• 1, 2, 3

c. Write all the immediate predecessors of 6.


• 2,3

22
Hasse Diagram
• If S is finite, we can visually depict a partially ordered set (S, ≤) by using a Hasse diagram.
– Each element of S is represented by a dot, called a node, or vertex
– If x is an immediate predecessor of y, then the node for y is placed above the node for x
and the two nodes are connected by a straight line
• Example: “x divides y” on {1, 2, 3, 6, 12, 18}

• 1,2,3 and 6, they are all predecessors of 12 and 18 .


• 6 is immediate predecessor of 18 and 12.

23
Greatest/Least v.s. Maximal/Minimal
• Let (S, ≤) be a partially ordered set
– If there is a y  S with y ≤ x for all x  S, then y is a least element of the partially ordered
set.
– A least element, if exists, is unique.
– An element y  S is minimal if there is no x  S with x < y.
– In a Hasse diagram, a least element is below all others, while minimal element has no
elements below it.
• Similar definition apply for greatest element and maximal elements.
• A least element is always minimal and a greatest element is always maximal but the
converses are not true.
• Example: “x divides y” on {1, 2, 3, 6, 12, 18}
– 1 is both least and minimal.
– 12 and 18 are both maximal, but there is no greatest element. Why? Because greatest
element should be unique.
24
Practice #6
• Draw the Hasse diagram for the partial ordering “x divides y” on the set {3, 6, 9, 18,
54, 72, 108,162}.Name any least elements, minimal elements, greatest elements,
and maximal elements.

3,6 and 9 are predecessors of


18 but 6 and 9 are immediate
Predecessors while 3 is not.
54 is immediate predecessor for
162 and 108, while 3,6,9 and 18
are predecessors.

25
Partition of a Set
• A partition of a set is a collection of nonempty disjoint subsets of S whose union
equals S.

B5 B3 B2
B4

B1
B7 B6

• For r an equivalence relation on set S and x  S, then [x] is the set of all members of
S to which x is related, and it is called the equivalence class of x.
Thus [x] = {y | y  S ∧ x r y }

26
Partition of a Set (Cont’d)
• Since ρ is symmetric we have [x] = {y | y  S ∧ y r x } as well.
• Assume [x] = {x, y , z , w}
Then [x] = [y] = [z] = [w] = { x, y, z, w}
These are not distinct classes but the same classes with multiple names.
• An equivalence class can take its name from any of the element in it.

Theorem on equivalence relations and partitions


An equivalence relation ρ on S determines a partition of S, and a partition of a set S
determines an equivalence relation on S.
(Proof in the book; not covered in the class)

27
Example
• Equivalence class example:
– for r = {(a,a),(b,b),(c,c),(a,c),(c,a)}
– [a] = {a,c} = [c]
– [b] = {b}
b

a, c

28
Examples
What do the following partitions look like?
a) The equivalence relation on N given by x r y  x + y is even
N Evens
Odds

b) On {x | x is a student in a class}, x r y  x sits in the same row as y.

S Row 3
Row 2
Row 1

Row 5 Row 6
Row 4
29
Practice #7
Let S be the set of all books in the library. Let r be a binary relation on S defined by
x r y  “the color of x’s cover is the same as the color of y’s cover.”
a) Show that r is an equivalence relation on S.
Reflexive: x r x : “The color of x’s cover is the same as itself.”
Symmetric : If “the color of x’s cover is the same as the color of y’s cover” then “the color of y’s
cover is the same as the color of x’s cover. ”
Transitive : If “the color of x’s cover is the same as the color of y’s cover” and “the color of y’s
cover is the same as the color of z’s cover then “the color of x’s cover is the same as the color of
z’s cover. ”
b) Describe the resulting equivalence classes.
The equivalence classes are the sets of books with the same color of covers.

30
Conclusion: Types of Binary Relation
Partial orderings and Equivalence Relations
Type of binary Reflexive Symmetric Antisymmetric Transitive Important Feature
relation
Partial orderings Yes No Yes Yes Predecessors and
successors
Hasse Diagram
Equivalence Yes Yes No Yes Determines a
relation partition

31
Section 5.4 – Functions
Function Definitions
• Let S and T be sets. A function (mapping) f from S to T, f: S  T, is a subset of S x T
where each member of S appears exactly once as the first component of an ordered
pair.
– S is the domain of the function.
– T is the codomain of the function.
• If (s, t) belongs to the function, then
– t is denoted by f(s)
– t is the image of s under f
– s is a preimage of t under f
– f maps s to t

33
Example
Let 𝑓: ℤ → ℤ Where f be defined by : 𝑓 𝑥 = 𝑥 2

a. What is the image of -4 ? 𝑓 𝑥 = −42 = 16


b. What is the preimage of 9 ? 𝑥 = 9 = ±3

34
Diagram Representation
• If A and B are finite sets, an arrow diagram shows a function f from A to B by drawing an
arrow from each element in A to the corresponding element of B

• Two properties must be held in the arrow diagram according to the definition of function:
– Every element of A has an arrow coming out of it.
– No one element of A has two arrows coming out of it that point to two different
elements of B. That means every member of A must have one and only one B value
associated with it. (This property doesn’t prevent a given value in B from appearing
more than once.)
• A binary relation that is one-to-many or many-to-many cannot be a function.

35
Practice #8
Which of the following are functions?
 f: S  T where S = T = {1, 2, 3}, f = {(1,1),(2,3),(2,1)}
 g: Z  N where g(x) = |x| (absolute value of x)
 h: N  N where h(x) = x – 4
 f: R  R where f(x) = 4x – 1
𝑥 + 3 𝑖𝑓 𝑥 ≥ 5
 g: N N where g is defined by g(x)=
𝑥 𝑖𝑓 𝑥 ≤ 5

For f: Z  Z where f(x) = x2


 what is the image of –4
16
 what are the preimages of 9
±3

36
Several Common Math Functions
• Floor function
– associates with each real number x the greatest integer less than or equal to x
– E.g. 2.8 = 2 , - 2.8 = -3

• Ceiling function
– associates with each real number x the smallest integer greater than or equal to x
– E.g. 2.8 = 3 , -2.8 = -2

• Modulo function f(x) = x mod n


– associates with x the remainder when x is divided by n
– we can write x = qn+ r, r is between [0, n-1]
– E.g. 10 mod 3 = 1

37
Functions With Multiple Variables
A function can include more than one variable. A function can be
defined as:
– f: S1  S2 …… Sn  T that associates with each ordered n-tuple
of elements (s1, s2, …, sn)
Example:
• f: ℤ  ℤ  ℤ is given by f(x,y) = x+y.
• Then f(-6,5) = -6+5 = -1
• f: ℤ  ℕ  {1, 2}  Z is given by f(x,y,z) = 𝑥 𝑦 + 𝑧.
• Then f(-4, 3, 1) = (−4)3 +1 = -64 +1 = -63

38
Range
Let f: S  T be an arbitrary function with domain S and codomain T.
Based on the definition of function:
– Every member of S has an image under f and all the images are
members of T.
– the set R of all such images is called the range of the function f.
– R⊆ T
Properties of Functions
1- Onto (Surjective) Function:
A function f: S  T is an onto, or surjective, function if the range of f equals the
codomain of f.

 To prove that a given function is onto, show that T⊆ R; then it will be true that R=T.
So, pick an arbitrary element in the codomain T and show that it has a preimage in
the domain.
 If we can produce one member of the codomain that is not the image of any member
of the domain, then we have proved that the function is not onto.

40
Example
Let f: ℚ  ℚ where f(x) = 3x + 2, is f onto?
let q ∈ ℚ , we want an x∈ ℚ such that f(x) = 3x + 2=q.
So x = (q-2)/3 is the only possible value and it is indeed a member of ℚ. Therefore, q is
the image of a member of ℚ under f, and f is onto.

Let g: ℤ  ℚ where g(x) = 3x + 2, is g onto?


No, it is not onto because there are many values q ∈ ℚ, for example 0, for which
the equation 3x+2 = q has no integer solution.

41
Properties of Functions (Cont’d)
2- One-to-one (Injective)
A function f: S  T is one-to-one or injective, if no member of T is the
image under f of two distinct elements of S.
• To prove a given function is injective: we assume that there are
elements s1 and s2 of S with f(s1) = f(s2) and then show that s1 = s2
• To disprove it: counterexample, where an element in the range has
two preimages in the domain

42
Example
Let g: ℝ  ℝ where g(x) = 𝑥 3 , is g one - to - one?
let x ,y ∈ ℝ , with g(x) = g(y), then 𝑥 3 = 𝑦 3 and 𝑥 = 𝑦. So g is one-to-one.

Let f: ℝ  ℝ where f(x) = 𝑥 2 , is f one – to - one?


No, it is not. Because, for example, f(2) = f(-2) = 4.

Let h: ℕ  ℕ where h(x) = 𝑥 2 , is h one – to - one?


Yes , because if x and y are nonnegative integers with h(x)= h(y), then 𝑥 2 = 𝑦 2 ;
because both x and y are nonnegative integers.

43
Properties of Functions (Cont’d)
3- Bijective
A function f: S  T is bijective (a bijection), if it is both surjective and
injective.
Example:
g: ℝ  ℝ where g(x) = 𝑥 3 , is a bijection, as proved in previous examples.

f: ℝ  ℝ where f(x) = 𝑥 2 , is not a bijection, because it is not one- to –one as


proved previously.

44
In General

45
Composition of Functions
Let f: S→ T and g: T→ U. Then the composition function, g◦f, is a function from S
to U defined by (g◦f)(s) = g(f(s)).
• Function f is applied first, and then function g
• It is not always possible to take any two arbitrary functions and compose them
since the domain and the ranges have to be compatible.
• Note that composition preserves the properties of being onto and being one-to-
one.
• Composition on two bijections is a bijection.

46
Examples
ℝLet f: ℝ  ℝ be defined by f(x) = x2 and g: ℝ  ℝ be defined by g(x) = x
– What is the value of (g f) (2.3) ?
• g(f(2.3)) = g(5.39) = 5

– What is the value of (f  g) (2.3) ?


• f(g(2.3)) = f(2) = 4
Note :Order is important in function composition.

• The following functions map R to R. Give an equation describing the composition


functions f  g and g  f in each case:
f(x) = 3x2, g(x) = 5x
– f  g = f(g(x)) =3(5𝑥)2 g  f= g(f(x)) =5(3𝑥 2 ) = 15𝑥 2
47
Inverse Functions
Let f be a function, f: S → T. If there exists a function g: T → S such that
g ◦ f = 𝑖𝑆 and f ◦ g = 𝑖𝑇 , then g is called the inverse function of f denoted by 𝑓 −1 .

Explanation:
Bijective functions have another property: Let f: S→ T be a bijection. Because f is onto, every t ∊ T
has a preimage in S. Because f is one-to-one, that preimage is unique. We can associate with each
element t of T a unique member of S, namely, s ∈ S such that f(s)=t. This association describes a
function g: T → S. The domains and codomains of g and f are such that we can form both g ◦ f :
S→S and f ◦ g : T→T. If s ∈ S , then
(g ◦ f)(s) = g(f(s)) = g(t) = s. Thus, g ◦ f maps each element of S to itself. Such a function is called
identity function. And denoted as : g ◦ f = 𝑖𝑆 .

48
Example
f: ℝ  ℝ given by f(x) = 3x + 4 is a bijection. Describe 𝑓 −1 .

−1 𝑥−4
𝑓 =
3

49
Practice #9
For each of the following bijection f: ℝ  ℝ, find 𝑓 −1 .

𝑥
a. 𝑓 𝑥 = 2𝑥 𝑓 −1 (𝑥) =
2

b. 𝑓 𝑥 = 𝑥 3 𝑓 −1 (𝑥) = 3
𝑥

𝑥+4
c. 𝑓 𝑥 = 𝑓 −1 (𝑥) = 3𝑥 − 4
3

50
Theorem on Bijection and Inverse Function

Let f: S  T. Then f is a bijection if and only if f –1 exists.

51
Summary of Function Terminologies
Term Meaning
function A function f from set S to set T is a relationship between elements of S and elements of
T where each element of S is related to a unique element of T. It is denoted by f: S 
T.
domain Starting set for a function
codomain Ending set for a function
image Point that results from a mapping
preimage Starting point for a mapping
range Collection of all images of a domain
onto (surjective) Range is the whole codomain; every codomain element has a preimage
one-to-one (injective) No two elements in a domain map to the same place
bijection One-to-one and onto
identity function Maps each element of set to itself
inverse function For a bijection, a new function that maps each codomain element back where it came
from

52

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy