VIEWS: 37 PAGES: 15 POSTED ON: 1/16/2011 Public Domain
Relations RELATIONS OBJECTIVES 1. Student should be able to know how relation is being builds. 2. Students should be able to apply relation and combine the knowledge with other topics in this subject. 3. Students should be able to use relation in daily lives. What, Which, Where, When 1. Basics of relation Domain and Range (Clear / Not Clear) 2. Relation Representation Set representation (Clear / Not Clear) Matrix representation (Clear / Not Clear) Diagraph representation (Clear / Not Clear) 3. Concept of degree, path and cycle (Clear / Not Clear) 4. Properties of relations and how to identify it Reflexive and Irreflexive (Clear / Not Clear) Symmetric, Asymmetric and Antisymmetric (Clear / Not Clear) 5. Equivalence relation (Clear / Not Clear) 6. Relations Manipulation Complement and Inverse (Clear / Not Clear) Intersection and union (Clear / Not Clear) 7. Transitive Closure Matrix product (Clear / Not Clear) Warshall Algorithm (Clear / Not Clear) Kolman, Busby and Ross page 110 – 167 Rosen 4th Ed page 374 – 414 Rosen 5th Ed page 471 – 515 Jonsonbaugh page 77 – 91 Mattson page 137 – 144 1 Relations RELATIONS Product Set - An order of a pair (a, b) in which a and b will appear in dedicated order; a appear first, followed by b. - If 2 set A and B are nonempty set, its product set for A x B or named Cartesian product is a set for ALL (a, b) pairs in which a A and b B. - Written as A x B = {(a, b) | a A and b B} Ex 1: Let A = {1, 2, 3} and B = {r, s} So, A x B = {(1, r), (1, s), (2, r), (2, s), (3, r), (3, s)} and B x A = {(r, 1), (r, 2), (r, 3), (s, 1), (s, 2), (s, 3)} Therefore, A x B B x A. Relation - A relation between 2 set where its value was determined by a condition. All elements in that relation must fulfill the condition. - Let A and B are nonempty set. A relation from A to B is a subset for A x B. - If R A x B and (a, b) R, we say that a relates to b through R and we write as a R b. Ex 2: Let A = {1, 2, 3} and B = {r, s}. So, R is a relation so that R = {(1, r), (2, s), (3, r)}. Ex 3: Let A = {1, 2, 3, 4, 5} R is a relation less than on set A. So R = {(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)} Sets arise from relations - When there is a relation from A to B, we can find domain and range for the relation. - Domain for R is elements in set A. That is, Dom(R) is a subset for A. - Range for R is elements in set B. That is, Range(R) is a subset for B. Ex 4: Consider Ex 3. Dom(R) is {1, 2, 3, 4}. Ran(R) is {2, 3, 4, 5} 2 Relations Relation Representation - A relation can be represent in three ways: a) Set Set representation is in Ex 3. b) Matrix Matrix representation is only for two finite sets. Ex 5: Relation for set A = {a1, a2, a3} and B = {b1, b2, b3, b4} is as below: MR = 1 0 0 1 0 1 1 0 1 0 1 0 So R = {(a1, b1), (a1, b4), (a2, b2), (a2, b3). (a3, b1), (a3, b3)} c) Diagraph Digraph representation needs both set to have the same elements. It is normally called relation on that set. Each element is called vertex and the path is called edge. Ex 6: A = {a, b, c, d} and R = {(a, a), (a, b), (b, a), (b, b) (b, c), (b, d), (c, d), (d, a)} So, the diagraph of R is shown below: b a c d 3 Relations Degree - This is an important concept in relation. - If R is a relation on set A and a A, then in-degree for a is the number of b A where (b, a) R. - Out-degree for a is the number of b A where (a, b) R. - For diagraph above, its degrees are: Vertex a b c d In-degree 3 2 1 2 Out-degree 2 4 1 1 - To read in-degree and out-degree from matrix. Ex 7: ` Let A = {a, b, c, d} and R is given below: MR = 1 0 0 0 0 1 0 0 1 1 1 0 0 1 0 1 Note: In-degree is in the column, while out-degree is in the row. The answer: Element a b c d In-degree 2 3 1 1 Out-degree 1 1 3 2 Exercise 1: Get the in degree and out degree for diagraph below. Then, write the relation into set and matrix. Read the in degree and out degree from matrix. 2 1 3 4 4 Relations Path in relations - Let say R is a relation on set A. a path with length n in R from a to b is a finite sequence starts at a and ends at b in which a R x1, x1 R x2, …., xn-1 R b and path length n will involve n + 1 elements. Ex 8: Consider this diagraph: 1 2 3 5 4 1: 1, 2, 5, 4, 3 is a path length 4 from vertex 1 to vertex 3. 2: 1, 2, 5, 1 is a path length 3 from vertex 1 to itself. 3: 2, 2 is a path length 1 from vertex 2 to itself. 4: 2, 5, 1, 2 is a path length 3 from vertex 2 to itself. - A path that start and ends at the same vertex is called a cycle. - 2, 3 and 4 are all cycles. 3 and 4 are cycle that starts and ends at the same vertex but different length. - Path length n can be found using set, matrix or diagraph representation. Ex 9: Let A = {a, b, c, d, e} R = {(a, a), (a, b), (b, c), (c, a), (c, d), (c, e), (d, e)} Find all paths with length 2. Ans: Set: R2 = {(a, b), (a, c), (b, d), (b, e), (c, a), (c, b), (c, e)} (manual checking) Matrix: MR = 1 1 0 0 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 We can use Boolean product of MR and MR to get MR2, where MR2 = MR ⊙ MR. 5 Relations Diagraph: Manual checking. - Reachability is a concept in which there is a relation between x and y in whatever length possible. - Written as x R y where x and y have relations. - Consider Ex 8. Identify all x R y. Exercise 2: 1. List all path length 2 from Exercise 1 using three ways of representation. 2. List all path length 1, 2 and 3 for Ex 7 and Ex 8. Properties of relations - Relation has few properties that have to be identified clearly, such as: a) Reflexive and Irreflexive - A relation R on set A is said to be reflexive if (a, a) R for ALL element, a A, that is, a R a for ALL a A. - A relation R on set A is said to be irreflexive if a R a for ALL a A. Ex 10: Let say for an equality relation on set A, that is R = {(a, a)| a A}. So, this relation is reflexive. b) Symmetric - A relation R on set A is said to be symmetric if there is a R b, then b R a. - Relation is said not symmetric if there are a and b A with a R b, but b R a. It is like a relation ‘sibling’ between a and b. c) Asymmetric - Relation R on set A is said to be asymmetric if there is a R b, then b R a. - Relation is said not asymmetric if there are a and b A, both a R b and b R a are exist. It is like a relation ‘mother of’ between a and b. d) Antisymmetric - A relation R on set A is said to be antisymmetric if there is a R b, and b R a, and then a = b. That is, if a b, then a R b or b R a. - Relation is not antisymmetric if a b, and there is both a R b and b R a. 6 Relations Identifying: Let say A = {1, 2, 3} a) Reflexive: All elements have relation to itselves. Set: {(1, 1), (2, 2), (3, 3,)} Matrix: Values on its diagonal are all 1. 1 x x x 1 x x x 1 Diagraph: There must have cycle length 1 on each vertex. 1 2 3 b) Irreflexive Set: U – R Matrix: All value on its diagonal is 0. 0 x x x 0 x x x 0 Diagraph: There is no cycle length 1on each vertex, c) Symmetric: If a = b, a R b, b R a (allowed), if a b, a R b, b R a Set: {(1, 1), (1, 2), (2, 1), (2, 3), (3, 2)} Matrix: Values symmetrical on the diagonal are either both 0 or 1. 1 1 0 1 0 1 0 1 0 Diagraph: Two-way relation. Cycle length 1 is allowed. 1 2 3 d) Asymmetric: If a b, a R b or b R a Set: {(1, 2), (1, 3), (2, 3)} Matrix: Values not symmetrical on the diagonal. Diagonal entries must all 0. 0 1 1 0 0 1 0 0 0 Diagraph: No two-way and no cycle length 1 for all vertex. 1 2 3 7 Relations e) Antisymmetric: If a R b, b R a, then a = b, if a b, a R b or b R a. Set: {(1, 1), (1, 2), (1, 3), (2, 3), (3, 3)} Matrix: Values not symmetrical on the diagonal. 1 1 1 0 0 1 0 0 1 Diagraph: No two-way. Cycle length 1 is allowed. 1 2 3 Ex 11: Let say R is a relation defined as below: R = {(x, y) A x A | x is a cousin to y} Identify this relation either it is symmetric, asymmetric and/or antisymmetric. Ans: Symmetric: If x is a cousin to y, then y is a cousin to x. This fulfill the a R b and b R a. Asymmetric: Not asymmetric. Antisymmetric: Not antisymmetric. Ex 12: Let say R is a relation defined as below: R = {(a, b) A x A | a < b} where this is a relation less than. Identify this relation either it is symmetric, asymmetric and/or antisymmetric. Ans: Symmetric: Not symmetric because a < b but b < a, that is a R b, but b R a Asymmetric: If a < b, then b < a, so R is asymmetric. Antisymmetric: If a b, then either a R b or b R a, so, R is antisymmetric. Ex 13: Identify either matrix below symmetric, asymmetric and/or antisymmetric. MR1 1 0 1 MR2 1 1 1 MR3 0 1 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 0 1 1 MR4 0 0 1 1 MR5 1 0 0 1 MR6 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 8 Relations Ex 14: Identify either diagraph below symmetric, asymmetric and/or antisymmetric. 1 2 1 2 3 4 5 4 3 5 - In all the properties, symmetric is the much important. - If a diagraph has a two-way relation (such as symmetric), it can be simplify by erasing the arrow. And the new diagraph is called graph. a c a c b b e d e d Diagraph for R Graph for R - Symmetric relation R on set A is said to be connected if there exist a path from any elements in A to any elements in A. A is said to be in one piece. - If there is no path, graph is said to be disconnected. A B 1 2 E C 4 5 D 3 Graph A Graph B 9 Relations Transitive Relation - We said that relation R on set A is transitive if there exist a R b and b R c, there must exist a R c. - Not transitive when there exist a R b, and b R c, but a R c. - If a, b and c is not exist, then R is transitive (cannot prove that it is not transitive). Ex 15: Consider Ex 12. Relation less than. Ans: This relation is transitive because if a < b, and b < c, then a < c. This meets the criteria of transitive. Identifying: Let say A = {1, 2, 3, 4} Set: Identify manually by observation. Ex: R = {(1, 2), (1, 3), (4, 1), (4, 2)} This is transitive because we cannot prove it as not transitive. Matrix: mij = 1 and mjk = 1, then mik = 1. In short, if MR2 = MR, then R is transitive. Diagraph: Observation. 1 2 3 4 Equivalence Relations - A relation on set A is called equivalence relation if it is reflexive, symmetric and transitive. Ex 16: Let say A = {1, 2, 3, 4} and let R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 3), (3, 3), (4, 4)} It is clear that R is an equivalence relation. Ex 17: Let set A is set integer, Z and R is defined as a R b if and only if a b. Is R an equivalence relation? Ans: We can see that a a, then R is reflexive. If a b, then it is not necessarily b a, then R is not symmetric. R is transitive because if a b, b c, then a c. But, because R is not fulfilling all the condition, therefore, R is not an equivalence relation. 10 Relations Relation Manipulation - We can manipulate relation with few operations to change, combine or update the previous relations. We can have new relations after manipulation. - Manipulations involved either one relation such as: a) Complementary relation Complementary relation for R written as R(complement). This is explained by a R b if and only if a R b b) Inverse Inverse relation is written as R-1. This is explained by b R-1 a if and only if a R b - Manipulations involving two relations R and S includes: a) Intersection, Intersection relation R S is a relation in which its elements fulfill this condition: a (R S) b if and only if a R b and a S b b) Union, Union relation R S is a relation in which its elements fulfill this condition: a (R S) b if and only if a R b or a S b Ex 18: Identify all manipulation by using all three ways of representation. Theorem involved: Theorem 1: Let say R and S are relations from A to B; a) If R S, then R-1 S-1 b) If R S, then S(complement) R(complement) Theorem 2: let R and S are relations on set A a) If R reflexive, then R-1 is also reflexive. b) If R and S reflexive, then R S and R S is also reflexive. c) R is reflexive if and only if R(complement) is irreflexive. 11 Relations Theorem 3: Let say R is a relation on set A. a) R is symmetric if and only if R = R-1 b) R is antisymmetric if and only if R R-1 c) R is asymmetric if and only if R R-1 = Theorem 4: Let R and S are relations on set A. a) If R symmetric, then a R-1 and R(complement) is also symmetric b) If R and S symmetric, then R S and R S is also symmetric. Theorem 5: Let R and S are relations on set A a) (R S)2 R2 S2 b) If R and S are transitive, then R S is also transitive. c) If R and S are equivalence relations, then R S is also equivalence relation. Composition - Let say there are 3 set A, B and C where R is a relation from A to B and S is a relation from B to C. - A new relation, named composition can be build, written as S R. - Relation S R is a relation from A to C, defined as: If (a A) and (c C), then a (S R) c if and only if (b B), and there exist a R b and b S c. Ex 19: Let A = {1, 2, 3, 4}. R = {(1, 2), (1, 1), (1, 3), (2, 4), (3, 2)} and S = {(1, 4), (1, 3), (2, 3), (3, 1), (4, 1)}. Find S R. Ans: In R we find that (1, 2) R and (2, 3) S, then we must have (1, 3) S R. using this method, we can find that S R = {(1, 3), (1, 4), (1, 1), (2, 1), (3, 3)} # Do Ex 19 again using matrix and diagraph. Theorem 6: Let R is a relation from A to B and S is a relation from B to C. Then, if A1 is any subset for A, we can find that (S R) (A1) = S(R(A1)) Theorem 7: Let A, B, C and D are sets, R is a relation from A to B, S is a relation from B to C and T is a relation from C to D. Then, T (S R) = (T S) R 12 Relations Theorem 8: Let A, B and C are sets, R is a relation from A to B and S is a relation from B to C. Then, (S R)-1 = R-1 S-1 - RSSR Ex 20: Let A = {a, b} and R and S are relations on set A. Given R = {(a, a), (b, a), (b, b)} and S = {(a, b), (b, a), (b, b)}. Find S R and R S. Closure - If R is a relation on set A, R might less few elements in which R is not fulfilling the important properties such as reflexive, symmetric and transitive. - We might want to and as minimum as possible, new elements in order to make R meets the criteria. - The smallest relation R1, in the relation that contains R and the new elements together so that R1 will meets the criteria. - In this case, we call R1 as a closure of R. Ex 21: Let A ={a, b, c} and R = {(a, a), (a, b), (b, c), (a, c)}. Then The reflexive closure for R is R1 = {(a, a), (a, b), (b, c), (a, c), (b, b), (c, c)}. And, symmetric closure for R is R1 = {(a, a), (a, b), (b, a), (b, c), (c, b), (a, c), (c, a)} - The most important is Transitive Closure. Transitive Closure - Let R is a relation on set A and R is not transitive. So we have to make it becomes transitive. - Theorem 1: Let R is a relation on set A. Then R is a transitive closure for R. - There are 2 ways to find R : a) Matrix Product Matrix product require us to times MR few times until the final outcome is the same with the previous outcome. - Theorem 2: Let A is a set with |A| = n, and let R is a relation on set A. Then R = R R2 ….. Rn. 13 Relations b) Warshall Algorithm Steps involved are: a) Bring down all entries value 1 from Wk-1 to Wk. b) List all location p1, p2, … in column k for Wk-1 in which the entries is 1, and all location q1, q2, … in row k for Wk-1, in which the entries is 1. c) Put all 1 in all location pi, qj for Wk (if the entries is 0). - This algorithm only can be done to a square matrix n x n. The process above must be done n times. Ex 22: Consider the relation below: MR = 0 1 0 0 = W0 p (column 1) q (row 1) 1 0 1 0 2 2 0 0 0 1 {(2, 2)} 0 0 1 0 W1 = 0 1 0 0 p (column 2) q (row 2) 1 1 1 0 1, 2 1, 2, 3 0 0 0 1 {(1, 1), (1, 2), (1, 3) 0 0 1 0 (2, 1), (2, 2), (2, 3)} W2 = 1 1 1 0 p (column 3) q (row 3) 1 1 1 0 1, 2, 4 4 0 0 0 1 {(1, 4), (2, 4), (4, 4)} 0 0 1 0 W3 = 1 1 1 1 p (column 4) q (row 4) 1 1 1 1 1, 2, 3, 4 3, 4 0 0 0 1 {(1, 3), (1, 4), (2, 3), (2, 4) 0 0 1 1 (3, 3), (3, 4), (4, 3), (4, 4)} W4 = 1 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 So, W4 is a transitive closure for R. 14 Relations Exercise 3: 1. Given A = {1, 2, 3, 4} and R and S are relation on set A. Given R = {(1, 1), (1, 3), (2, 1), (2, 4), (3, 3), (3, 2), (4, 1), (4, 4)}. Given S = {(1, 2), (1, 3), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (4, 1), (4, 3)}. Find: a) R S b) S R c) R R d) S S 2. Given A = {a, b, c} and R and S are relation on A. Given R = {(a, a), (b, a), (b, c), (c, b)} and S = {(a, b), (a, c), (b, b), (c, a). Find: a) R S b) S R c) R R d) S S 3. Find the transitive closure for each MR below using Warshall Algorithm, given A = {1, 2, 3, 4}. a) MR = 1 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 b) MR = 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 c) MR = 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 d) MR = 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 15