330 likes | 347 Views
Learn about relations, matrices of relations, and functions as a special type of relation. Explore properties of relations and graph interpretations.
E N D
Agenda • Lecture Content: • Relations (Relasi) • Matrices of Relations (Matriks Relasi) • Review Quiz • Exercise
Relations Relations generalize the notion of function. Function is a special type of Relation Relationships between elements of sets occur in many contexts. To express a relationship between elements of two sets: ordered pairs made up of two related elements binary relations. (Bogor, Jawa Barat), (Surabaya, Jawa Timur)
Relation: Definition Let A and B be sets. A binary relation from A to B is a subset of A B. Cartesian Product IF R : binary relation THEN a R b: (a, b) R a R b: (a, b) R Notation: domain: {a A | (a,b) R for some b B} range: {b B | (a,b) R for some a A}
Example A = {0, 1, 2} B = {a, b} Relation from a to b: {(0, a), (0, b), (1, a), (2, b)} 0 R a ? 0 R 2 ? 2 R a ?
Note: Function is a special type of Relation • Properties: • The domain of the function f is equal to A • For each a A, there is exactly one b B such that (a,b) f.
How to represent relation • R = {(0, a), (0, b), (1, a), (2, b)} • Table • A B • 0 a • 0 b • 1 a • 2 b
a b d c How to represent relation Digraphs = Directed Graphs (chapter 8) A = {a, b, c, d}, R = {(a, b), (a, d), (b, b), (b, d), (c, a), (c, b), (d, b)}.
How to represent relation 1 A 1 1 1 2 B 1 1 3 C 1 4 D
Relations on a Set A Relation on the set A is a relation from A to A a subset of A A A = {1, 2, 3, 4} Which pairs are belong to R = {(a, b) | a ≤ b} ? {(1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4), (2,2), (3,3),(4,4)}
Example Ordered pairs: (1, 1), (1, 2), (2, 1), (1, -1) and (2, 2) R1 = {(a, b) | a ≤ b} R2 = {(a, b) | a > b} R3 = {(a, b) | a = b} R4 = {(a, b) | a = b or a = -b} R5 = {(a, b) | a = b + 1} R6 = {(a, b) | a + b ≤ 3}
Properties of Relations • Reflexive • Symmetric • Antisymmetric • Transitive • Composite
Reflexive A relation R on a set A is called reflexive if (a, a) R for every element a A. R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} R2 = {(1, 1), (1, 2), (2, 1)} R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)} R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} R6 = {(3, 4)}
Which one is reflexive? R1 = {(a, b) | a ≤ b} R2 = {(a, b) | a > b} R3 = {(a, b) | a = b} R4 = {(a, b) | a = b or a = -b} R5 = {(a, b) | a = b + 1} R6 = {(a, b) | a + b ≤ 3}
Symmetric and Antisymmetric A relation R on a set A is called symmetric: if (a, b) R then (b, a) R. A relation R on a set A is called antisymmetric: if for all a, b R, IF (a, b) R AND a ≠ bTHEN (b, a) R . (IF (a, b) R AND (b, a) R THEN a = b ) R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} R2 = {(1, 1), (1, 2), (2, 1)} R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)} R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} R6 = {(3, 4)}
Which one is symmetric, antisymmetric? R1 = {(a, b) | a ≤ b} R2 = {(a, b) | a > b} R3 = {(a, b) | a = b} R4 = {(a, b) | a = b or a = -b} R5 = {(a, b) | a = b + 1} R6 = {(a, b) | a + b ≤ 3}
Transitive A relation R on a set A is called transitive if whenever (a, b) R and (b, c) R then (a, c) R, for all a, b, c A . R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} R2 = {(1, 1), (1, 2), (2, 1)} R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)} R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} R6 = {(3, 4)}
Which one is transitive? R1 = {(a, b) | a ≤ b} R2 = {(a, b) | a > b} R3 = {(a, b) | a = b} R4 = {(a, b) | a = b or a = -b} R5 = {(a, b) | a = b + 1} R6 = {(a, b) | a + b ≤ 3}
Composition Let R be a relation from a set A to a set B and S a relation from B to a set C. We denote the composition of R and S by S R. S R = {(a,c) | (a,b) R and (b,c) S for some b B} R is the relation from {1, 2, 3} to {1, 2, 3, 4} R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} S is the relation from {1, 2, 3, 4} to {0, 1, 2} S = {(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)} S R ? S R = {(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, 1)}
Digraph and Properties of Relations Reflexive: there is a loop at every vertex. Symmetric: whenever there is a directed edge from x to y, there is also a directed edge from y to x. Antisymmetric: whenever there is a directed edge from x to y, and x ≠ y, then there is no directed edge from y to x. Transitive: whenever there are directed edges from x to y and from y to z, then there is also a directed graph from x to z.
Partial Orders Partial Orders is a relation R that is reflexive, antisymmetric and transitive. Ex. R1 = {(a, b) | a ≤ b}
Equivalence Relations A relation on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive Ex. R = {(1,1), (1,3), (1,5), (2,2),(2,4),(3,1),(3,3), (3,5),(4,2),(4,4),(5,1),(5,3),(5,5)} R is an equivalence relation on {1,2,3,4,5}
Matrices of Relations Alternative methods for representing relations: Zero – One matrices
Zero-One Matrices A = {a1, a2, …, an} B = {b1, b2, …, bn} R is a relation from A to B. R can be represented by the matrix MR = [mij] where mij = 1, if (ai,bj)R, and mij = 0, if (ai,bj)R.
Example A = {1, 2, 3} B = {1, 2} R = {(a, b) | a > b} R = {(2, 1), (3, 1), (3, 2)}
Example A = {a1, a2, a3 , a4} B = {b1, b2, b3 , b4} R ?
Zero-One Matrices Find Zero-One Matrices for: Reflexive Relation ? Symmetric Relation ? Antisymmetric Relation ?
Zero-One Matrices Reflexive Relation ? Symmetric Relation ? Antisymmetric Relation ?
Combining Relations A = {1, 2, 3} B = {1, 2, 3, 4} R1 = {(1, 1), (2, 2), (3, 3)} R2 = {(1, 1), (1, 2), (1, 3), (1, 4)} R1 R2 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (3, 3)} R1 R2 = {(1, 1)}