79
Relations & Functions Discrete Mathematics (MA 2333) Faculty of Science Telkom Institute of Technology Bandung - Indonesia

Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Relations & Functions

Discrete Mathematics (MA 2333)Faculty of Science Telkom Institute of TechnologyBandung - Indonesia

Page 2: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Let A and B be sets. A binary relation from A to B is subset of A × B.

Notation: R ⊆ (A × B). The notation used for a binary relation is a R b or (a, b) ∈ R, which means a is related to boleh by relation Ra R b or (a, b) ∉ R means a is not related to b by relation R. Set A is called domain of R, and set B is called range of R

Relations

Page 3: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Relations

ExampleA = {2,3,5}, B = {4,6,9,10,15} A × B = {(2,4), (2,6), (2,9), (2,10), (2,15), (3,4), (3,6), (3,9), (3,10), (3,15), (5,4), (5,6), (5,9), (5,10), (5,15)}Relation R defined by :

(a, b) ∈ R if a divides bR = {(2,4), (2,6), (2,10), (3,6), (3,9), (3,15), (5,10), (5,15)}

This example show that R ⊆ (A × B)(2,4) ∈ R(3,10) ∉ R

Page 4: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Relations

Relations from a set A to itself are of special interestA relation on the set A is a relations A to A.A relation on set A is a subset of A ×A.

Page 5: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

RelationsLet A = {1, 2, 3, 4}Relation R defined by :

(a, b) ∈ R if a divides b, a,b ∈ AR = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)}

Page 6: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Representing Relations

Ordered PairExample

A = {2,3,5}, B = {4,6,9,10,15}

Relation R defined by :(a, b) ∈ R if a divides b

R = {(2,4), (2,6), (2,10), (3,6), (3,9), (3,15), (5,10), (5,15)}

Page 7: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Representing Relations

Arrows DiagramA = {2,3,5}, B = {4,6,9,10,15}

Relation R defined by :(a, b) ∈ R if a divides b

Page 8: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Representing Relations

TableThe first column represents the domain, the second column represents range

A B

2 4

2 6

2 10

3 6

3 9

3 15

5 10

5 15

A = {2,3,5}, B = {4,6,9,10,15}

Relation R defined by :(a, b) ∈ R if a divides b

Page 9: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Representing Relations

MatrixLet R be the relation that relate set A = {a1, a2, …, am} and B = {b1, b2, …, bn}. Relation R can be represented using matrix M = [mij]

b1 b2 … bn

⎥⎥⎥⎥

⎢⎢⎢⎢

mnmm

n

n

m mmm

mmmmmm

a

aa

L

MMMM

L

L

M

21

22221

11211

2

1

⎩⎨⎧

∉∈

=RbaRba

mji

ji

ij ),(,0),(,1

M =

Page 10: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Representing RelationsMatrix (Cont)

A = {2,3,5}, B = {4,6,9,10,15}

Relation R defined by :(a, b) ∈ R if a divides b

⎥⎥⎥

⎢⎢⎢

110001011001011

M =

Page 11: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Representing Relations4. Directed GraphDirected graph is defined to represent a relation on a set (not between two sets) Every element of the set is represented by a vertex and every ordered pair is represented by an edge (arc)Let A = {1, 2, 3, 4}Relation R defined by :

(a, b) ∈ R if a divides b, a,b ∈ AR = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)}

Page 12: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Relations Representations4. Directed Graph (Cont)

1 2

4 3

Page 13: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

ReflexiveA relation R on a set A is called refexive if (a, a) ∈ R for every element a ∈ A.A relation on A is reflexive if every element of A is related to itself

Page 14: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Example . Let A = {1, 2, 3, 4}, and relation R defined by : (a,b) ∈R if a ≥ b and a,b ∈ AHence, R = {(1, 1), (2, 1), (2, 2), (3, 1), (3, 2), (3, 3), (4, 1), (4, 2), (4,3), (4,4)} It is seen that (1,1), (2,2), (3,3), (4,4) are element of R. Therefore R is reflexive

Example . Let A = {1, 2, 3, 4}, and relation R defined by : (a,b) ∈R if a > b and a,b ∈ A

Relasi R = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4,3)} is not reflexive because (1,1), (2,2), (3,3), (4,4) are not element of R

Example . Relation “divides” on set of positive integers is reflexive, because every positive integers divide on itself, so that (a, a)∈R for every a ∈ A.

Page 15: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Reflexive relation has matrix which main diagonal elements is 1, or mii = 1, for i = 1,2,..,n When a reflexive relation is represented using directed graph, there will always be loop in every vertex

⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢

11

11

O

Page 16: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

TransitiveA relation R on set A is called transitive if (a, b) ∈ Rand (b, c) ∈ R, then (a, c) ∈ R, which a, b, c ∈ A.

Example. Let A = {1, 2, 3, 4}, and relation Rdefined on A, a. R = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} is transitive

Page 17: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

(a,b) (b,c) (a,c)(3,2) (2,1) (3,1)

(4,2) (2,1) (4,1)

(4,3) (3,1) (4,1)

(4,3) (3,2) (4,2)

See table below :

Page 18: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

R = {(1, 1), (2, 3), (2, 4), (4, 2) } is not transitive because

(2, 4) and (4, 2) ∈ R, but (2, 2) ∉ R, (4, 2) and (2, 3) ∈ R, but (4, 3) ∉ R.

Relation R = {(1, 1), (2, 2), (3, 3), (4, 4) } is transitif

Relation R = {(1, 2), (3, 4)} transitive because there is not (a, b) ∈ R and (b, c) ∈ R so that (a, c) ∈ R.

Relation that contain only one element, R = {(4, 5)} alaways transitive

Page 19: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Example . Relation “divides” on set of positive integers is transitive. Suppose a divides b, and b divides c. Then there are exist positive integers m and n, so that b = ma dan c = nb. Therefore c = nma, then a divides c. So, relation “divides” is transitive

Page 20: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

When transitive relation represented in the form of matrix, transitive relation does not have particular characteristics on its matrix Transitive property on directed graph is described by a condition : if there is an edge from a to b and b to c, there will be directed edge from a to c

Page 21: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Symmetric and anti-symmetricA Relation R on a set A is called symmetric if for every a, b ∈ A, if (a, b) ∈ R, then (b, a) ∈R

Relation R on a set A is not symmetric if (a, b) ∈ R while (b, a) ∉ R.

Page 22: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

A Relation R on a set A is called anti-symmetric if for every a, b ∈ A, if (a, b) ∈ R, and (b, a) ∈R, then a = bNotice that the term symmetric is not the antonym for the term antisymmetric

Page 23: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Example . Let A = {1, 2, 3, 4}, and relation R below defined on set A, then

R = {(1, 1), (1, 2), (2, 1), (2, 2), (2, 4), (4, 2), (4, 4) } is symmetric because (1, 2) and (2, 1) ∈ R, (2, 4) and (4, 2) ∈ R. R is not anti-symmetric R = {(1, 1), (2, 3), (2, 4), (4, 2) } is not symmetric because (2, 3) ∈ R, but (3, 2) ∉R. R is not anti symmetricR = {(1, 1), (2, 2), (3, 3) } is anti-symmetric because 1 = 1 dan (1, 1) ∈ R, 2 = 2 and (2, 2) ∈ R, and 3 = 3 and (3, 3) ∈R. R is symmetric.

Page 24: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Example. Relation “divides” on set of positive integers is not symmetric because if a devidesb, b is not divides a, except if a = b. For example, 2 divides 4, but 4 is not devides 2. Therefore (2, 4) ∈ R but (4, 2) ∉ R. Example. Relation “divides” anty-symmetric because if a divides b and b divides a, then a = b. For example, 4 divides 4. therefore, (4, 4) ∈R and 4 = 4.

Page 25: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Symmetric relation has matrix which elements under the main diagonal are the reflection of the elements above the main diagonal, or mij = mji = 1, for i = 1, 2, …, n :

⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢

0

10

1

Symmetric relation when represented in the by directed graph, has characteristics of : if there is an edge from a to b,there will be an edge from b to a

Page 26: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Properties of Binary Relations

Anti-symmetric relation has matrix which elements characteristic is : if mij = 1 with i ≠ j, then mji = 0. In other words, the matrix of the anti-symmetric relation meets the condition of : is one of mij = 0 or mji = 0 if i≠ j

⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢

01

100

1

Characteristic of a directed graph of an anti-symmetric relation is that there will never be two edges with different directions between two different vertices

Page 27: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Inverse of Relation

Let R is a relation from set A to set B. Inverse of relation R, denoted by R–1, is a relation from B to A which defined by

R–1 = {(b, a) | (a, b) ∈ R }

Page 28: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Inverse of RelationExample. Let P = {2, 3, 4} and Q = {2, 4, 8, 9, 15}. If we define relation R from P to Q by : (p, q) ∈ R if p divides q, so we obtain

R = {(2, 2), (2, 4), (4, 4), (2, 8), (4, 8), (3, 9), (3, 15) }

R–1 is relation from Q to P with (q, p) ∈ R–1 if qis p

then we obtainR–1 = {(2, 2), (4, 2), (4, 4), (8, 2), (8, 4), (9,

3), (15, 3) }

Page 29: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Inverse of RelationIf M is a matrix representing a relation R

⎥⎥⎥

⎢⎢⎢

001101100000111

⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢

010010101101001

then matrix which representing relation R–1, is obtained by finding transpose of matrix M

M =

N = M T =

Page 30: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Combining RelationsSinc relations from A to B are subsets of A x B, two relations from A to B can be combined any way two sets can be combined If R1 and R2 are relations from A to B, then R1 ∩ R2, R1 ∪ R2, R1– R2, and R1 ⊕ R2 are also relation from A to B.

Page 31: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Combining RelationsExample. Let A = {1, 2, 3} and B = {1, 2, 3, 4}. Relation R1 = {(1, 2), (3, 3), (4, 4)}Relation R2 = {(1, 1), (1, 2), (1, 3), (1, 4)}

R1 ∩ R2 = {(1, 1)}R1 ∪ R2 = {(1, 1), (2, 2), (3, 3), (1, 2), (1, 3), (1, 4)} R1 − R2 = {(2, 2), (3, 3)} R2 − R1 = {(1, 2), (1, 3), (1, 4)} R1 ⊕ R2 = {(2, 2), (3, 3), (1, 2), (1, 3), (1, 4)}

Page 32: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Combining Relations

Suppose that the relations R1and R2 on set A are represented by the following matrices

⎥⎥⎥

⎢⎢⎢

011101001

⎥⎥⎥

⎢⎢⎢

001110010

R1 = R2 =

M R1 ∪ R2 = MR1 ∨ MR2 =

⎥⎥⎥

⎢⎢⎢

011111011

MR1 ∩ R2 = MR1 ∧ MR2 =

⎥⎥⎥

⎢⎢⎢

001100000

Page 33: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Composition of Relations

Let R be the relation from set A to set B, and let S be relation from set B to set C. The composition of R and S, is denoted by S ο R, is relation from A to C which is defined by:

S ο R = {(a, c) ⏐ a ∈ A, c ∈ C, for a,b ∈ B, (a, b) ∈ R and (b, c) ∈ S}

Page 34: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Composition of Relations

Example. Let R = {(1, 2), (1, 6), (2, 4), (3, 4), (3, 6), (3, 8)} is relation from set {1, 2, 3} to set {2, 4, 6, 8} and S = {(2, u), (4, s), (4, t), (6, t), (8, u)} is relation from set {2, 4, 6, 8} to set {s, t, u}. Then composition of relation R and S isS ο R = {(1, u), (1, t), (2, s), (2, t), (3, s), (3, t), (3, u)}

1

2

3

2

4

6

8

s

t

u

Page 35: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Composition of Relations

If relation R1 and R2 are represented by matrices MR1 dan MR2, then matrix representing the composition of the two relations are

MR2 ο R1 = MR1 ⋅ MR2

It is done by changing product with “∧”(operator AND) and by changing the addition with “∨” (operator OR)

Page 36: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Composition of Relations

Example. Let relations R1 and R2 defined on set A are represented by matrices

⎥⎥⎥

⎢⎢⎢

000011101

⎥⎥⎥

⎢⎢⎢

101100010

⎥⎥⎥

⎢⎢⎢

∧∨∧∨∧∧∨∧∨∧∧∨∧∨∧∧∨∧∨∧∧∨∧∨∧∧∨∧∨∧∧∨∧∨∧∧∨∧∨∧∧∨∧∨∧

)10()10()00()00()00()10()10()00()00()10()11()01()00()01()11()10()01()01()11()10()01()01()00()11()11()00()01(

⎥⎥⎥

⎢⎢⎢

000110111

The matrix representing R2 ο R1 isMR2 ο R1 = MR1 . MR2

R1 = R2 =

= =

Page 37: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Equivalence Relations

A relation on a set A is called an equivalence relation if it isreflexive, symmetric and transitive. Two elements that are related by an equivalence relation are called equivalent

Example

Suppose that R is the relation on the set of strings of English letters such that a R b if and only if l(a) = l(b), where l(x) is the length of the string x. Is R an equivalence relation?

Solution :

Since l(a) = l(b) it follows that aRa whenever a is string, so that R is reflexive

Page 38: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Equivalence Relations

Suppose that a R b, so that l(a)=l(b). Then b R a, since l(b) = l(a). Hence, R is symmetric

Suppose that a R b and b R c. Then l(a)=l(b) and l(b)=l(c). Hence l(a)=l(c), so that aRc

Consequently R is an equivalence relation

Page 39: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Equivalence RelationsExample

Let R be the relation on the set of real number such thst aRbif and only if a – b is an integer. Is R an equivalence relation?Solution :

Since a – a = 0 is an integer for all real numbers a, aRa for all real numbers a. Hence, R is reflexive

Suppose that a R b. Then a – b is an integer, so that b – a is also an integer. Hence, b R a. It follows that R is symmetric

If a R b and b R c, then a – b and b – c are integers. Therefore, a-c = (a-b)+(b-c) is also integer. Hence a R c. Thus R transitive. So, R is an equivalence relation

Page 40: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Equivalence Relations

Let A be the set of all students in IT Telkom. Consider the relation R on A that consists of all pairs (x,y) where x and y graduated from the same high school. Given a student x, we can form the set the set of all students equivalent to x with respect to R. This set contains of all students who graduated from the same high school as x did. This subset of A is called an equivalence class of the relation

Page 41: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Let R be an equivalence relation on a set A. The set of all elements that are related to an element a of A is called the equivalence class of a. The equivalence class of a with respect to R is denoted by [a]R

[a]R = {s | (a,s) ∈ R}

When only one relation is under consideration, we will delete the subscript R and write [a] for this equivalence class

If b∈[a]R, then b is called a representative of theis equivalence class

Equivalence Classes

Page 42: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Partial OrderingsA relation on a set S is called a partial ordering or partial order if it is reflexive, antisymmetric, and transitive

A set S together with partial ordering R is called a partially ordered set (poset) and is denoted by (S,R)

Example

Show that the “greater than or equal” relation (≥) is aprtial ordering on the set of integers.

Solution:We know that ( ){ }babaR ≥= ,

aa ≥For every integers a,

it means, for every integers a, (a,a) ∈ R. thus R reflexive

Page 43: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Partial OrderingsFor arbitrary integer a, b, if a ≥ b and b ≥ a, then a = b. It means if (a,b) ∈ R and (b,a) ∈ R, then a = b. Thus R is antisymmetric

For arbitrary integer a, b, c, if a ≥ b and b ≥ c, then a ≥ c. It means If (a,b) ∈ R and (b,c) ∈ R then (b,c) ∈ R. Thus R is transitive.

Hence, R is partial ordering, and (Z, ≥) is poset

Exercise :

Show that divisibility relation (denoted by “ | “) is partial ordering on the set of positive integers

Show that the inclusion relation ⊆ is a partial ordering on the power set of a set S

Page 44: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Partial Orderings

The element a and b of a poset (S,R) are called comparable if either a R b or b R a. When a and b are elements of S such that neither a R b nor b R a, a and b are called incomparable

Example

In the poset (Z+,|), are the integers 3 and 9 comparable? Are 5 and 7 are comparable?

The integers 3 and 9 are comparable, since 3 divides 9 (3|9)

The integers 5 and 7 are incomparable, because 5 does not divide 7 and 7 does not divide 5

Page 45: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Partial Orderings

The adjective “partial” is used to describe partial orderings since pairs of elements may be incomparable. When every two elements in the set are comparable, the relation is called a total ordering

If (S,R) is a poset and every two elements of S are comparable, S is called a totally ordered set, and R is called a total order

Page 46: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Partial Orderings

The poset (Z, ≥) is totally ordered set, since a ≥ b or a ≥ b whenever a nd b integers

The poset (Z+, |) is not totally ordered set since it contains elements that are incomparable

Page 47: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Hasse DiagramHasse Diagram : Diagram which contains sufficient information to find the partial ordering

1. Start with directed graph for this relation. All edges are pointed upward

Procedure to construct the Hasse Diagram

2. Because a partial ordering is reflexive, remove the loops

3. Remove all edges that that must be present because the transitivity

4. Remove all the arrows on the directed edges

Page 48: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Hasse Diagram

Draw Hasse diagram representing partial ordering on set {1, 2, 3, 4}( ){ }babaR ≤= ,

3

4

2

1

1. Start with directed graph for this relation. All edges are pointed upward

Example

Page 49: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Hasse Diagram

2. Because a partial ordering is reflexive, remove the loops

3

4

2

1

Page 50: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Hasse Diagram

3. Remove all edges that that must be present because the transitivity

3

4

2

1

Page 51: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Hasse Diagram

4. Remove all the arrows on the directed edges. The result is Hasse diagram

3

4

2

1

Page 52: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Hasse Diagram

Draw Hasse diagram representing partial ordering on set {1, 2, 3, 4, 6, 8, 12}

Example

( ){ }baba divides ,Directed Graph

6

12

3

1

2

4

8

Hasse Diagram

Page 53: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Functions

Page 54: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Definition

Let A and B be sets Binary relation f from A to B is a function if every element in A related to exactly one element in B If f is a function from A to B, we can denote

f : A → BIt means f assigns set A to B. A is called the domain of f and B is called codomain of f.Another term for function is mapping or transformation.

Page 55: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Definition

If f(a) = b, then b is called image of a and a is called pre-image of b. The set that contains all values of mapping f is called range of f.

a b

A B

f

Page 56: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleRelation f = {(1, u), (2, v), (3, w)}from A = {1, 2, 3} to B = {u, v, w} is function from A to B. f(1) = u, f(2) = v, and f(3) = w. Domain of f is A and codomain is B. Range of f is {u, v, w}

Page 57: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleRelation f = {(1, u), (2, u), (3, v)}from A = {1, 2, 3} to B = {u, v, w} is a function from A to B. Domain of fis A, codomain B, Range of f is {u, v}.

Page 58: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleRelation f = {(1, u), (2, v), (3, w)}from A = {1, 2, 3, 4} to B = {u, v, w} is not function, because not all elements of A mapped to B.

Page 59: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleSuppose f : Z → Z defined by f(x) = x 2. Domain and codomain of f is set of integer, and range of f is a set of positive integer and zero

Page 60: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Function One to One

• Function f is called one-to-one or injective, if set A do not have two elements with similar image in set B

a 1

A B

2

3

4

5

b

c

d

Page 61: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Example . Relation f = {(1, w), (2, u), (3, v)} from A = {1, 2, 3} to B = {u, v, w, x} is function one to one But relation f = {(1, u), (2, u), (3, v)}from A = {1, 2, 3} to B = {u, v, w} is not function one to one, because f(1) = f(2) = u.

Function One to One

Page 62: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Example . Suppose f : Z → Z. Determine whether the functions f(x) = x2+1 and f(x) = x – 1 one-to-one?

Solution:f(x) = x2 + 1 is not function one-to-one, f(2) = f(-2) = 5 while –2 ≠ 2.f(x) = x – 1 is not function one-to-one since for a ≠ b, a – 1 ≠ b – 1. Suppose that for x = 2, f(2) = 1 and for x = -2, f(-2) = -3.

Function One to One

Page 63: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

The function f from set A to set B is said to be onto or surjective, if every element of of set B is the image of one or more of the two elements of set A. In other words, all elements of set B are the range of f

a 1

A B

2

3b

c

d

Function Onto

Page 64: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Example .Relation f = {(1, u), (2, u), (3, v)}

from A = {1, 2, 3} to B = {u, v, w} is not function onto since w is not range of fRelation f = {(1, w), (2, u), (3, v)}

from A = {1, 2, 3} to B = {u, v, w} is function onto since all elements of B are range of f.

Function Onto

Page 65: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleSuppose f : Z → Z. Determine whether f(x) = x2

+ 1 and f(x) = x – 1 are function onto ?

Solution:f(x) = x2 + 1 is not function onto, since not all of integers are range of f. f(x) = x – 1 is funtion onto since for every integer y, there is a real number x, such that x = y + 1.

Function Onto

Page 66: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Function one to one but is not onto

Function onto but is not one to one

a1

AB

2

3b

c4

a1

AB

2

3

b

c

cd

Function Onto

Page 67: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

It is not function one to one neither onto

It is not function

a 1

A B

2

3b

c

cd 4

a 1

A B

2

3b

c

cd 4

Function Onto

Page 68: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Function One to One Correspondence

Function f is said to be one-to-one correspondence or bijection, if it is both one-to-one and onto

Page 69: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleFunction f = {(1, u), (2, w), (3, v)} from A = {1, 2, 3} to B = {u, v, w} is function one-to-one correspondence since fis one-to-one and onto

Function f(x) = x – 1 is function one-to-one correspondence since f is one-to-one and onto

Function One to One Correspondence

Page 70: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Invers Function

Let function f be one-to-one correspondence from the set A to the set B, we will always be able to find the inverse function of fInverse function is denoted by f –1. Suppose that a is an element of set Aand b is an element of set B, thenf -1 (b) = a if f(a) = b.

Page 71: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Invers Function

ExampleRelation f = {(1, u), (2, w), (3, v)}from A = {1, 2, 3} to B = {u, v, w} is function one-to-one correspondence.inverse function f isf -1 = {(u, 1), (w, 2), (v, 3)}Thus, f is invertible function

Page 72: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleWhat is the inverse of function f(x) = x – 1.

Solution:Function f(x) = x – 1 is one-to-one correspondence that we can find its inverse Suppose that f(x) = y, that y = x – 1, then x= y + 1. Thus, the inverse function isf -1 (x) = y +1.

Invers Function

Page 73: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExampleWhat is the inverse of function f(x) = x2+1

Solution:Like the previous example, f(x) = x2 + 1 is not one-to-one correspondence that the inverse does not exist. Thus, f(x) = x2 + 1 is not invertible.

Invers Function

Page 74: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Exercises

List the ordered pairs in the relation R from A = {0, 1, 2, 3, 4} to B = {0, 1, 2, 3} where (a,b) ∈ R if and only if:

a = ba > ba + b = 4a | b

Page 75: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExercisesRelations below defined on {1, 2, 3, 4}. Determine properties of relations below !

{(2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4)}{(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4){(2, 4), (4, 2)}{(1, 2), (2, 3), (3, 4)}(1, 1), (2, 2), (3, 3), (4, 4)

Page 76: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Exercises

Determine whether the relation R on the set of all people is reflexive, symmetric, antisymmetric, and/or transitive, where (a,b) ∈ R if and only if

a is taller than ba and b were born on the same daya has the same first name as b

Page 77: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

ExercisesLet R be relation on the set of all URLs (or Web addresses) such that x R y if and only if Web page at x is the same as the Web page at y. Show that R is an equivalence relationLet R be the relation R on the set of ordered pairs of positive integers such that ((a,b),(c,d)) ∈ R if and only if ad=bc. Show that R is an equivalence relation

Page 78: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

Exercises

Which of these are poset?(Z, =)(Z, ≠)(Z, ≥)(Z, | )

Draw the Hasse for divisibility on the set :{1, 2, 3, 4, 5, 6}{3, 5, 7, 11, 13, 16, 17}{2, 3, 5, 10, 15, 25}{1, 3, 9, 27, 81, 243}

Page 79: Relations & Functions - SI-35-02 · Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology Let A and B be sets. A binary relation from A to B is subset

Discrete Mathematics (MA 2333) – Faculty of Science Telkom Institute of Technology

References

Rosen, Kenneth H., Discrete Mathematics and Its Applications 5th Ed, McGraw-Hill, New York, 2003Munir, Rinaldi., Matematika Diskrit, Edisi Kedua, Penerbit InformatikaBandung, Bandung, 2003