680 likes | 690 Views
This chapter focuses on the basics of relations, their representation, properties, manipulation, transitive closure, and how sets arise from relations.
E N D
CSNB 143 Discrete Mathematical Structures Chapter 8 - Relations
Sets OBJECTIVES • Student should be able to know how relation is being builds. • Students should be able to apply relation and combine the knowledge with other topics in this subject.
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)
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. • Ex 2: A marketing research firm classifies a person according to the following two criteria: • Gender: male (m); female (f) • Highest level of education completed: elementary school (e); high school (h); college (c); graduate school (g)
Sol: Let S = {m, f} and L = {e, h, c, g}. The product ser S x L contains all the categories into which the population classified. There are eight categories in this classification scheme.--> {(m, e), (m, h), (m, c), (m, g), (f, e), (f, h), (f, c), (f, g)}. Thus the classification (f, g) represents a female who completed graduate school.
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 3: • Let A = {1, 2, 3} and B = {r, s}. • Sol: R = {(1, r), (2, s), (3, r)} is a relation from A to B.
Ex 4: Let A = {1, 2, 3, 4, 5}. Define the following relation R (less than) on A. • Sol: R is a relation less than on set A. a R b if and only if a < b • So R = {(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)}
Ex 5: An airline services the five cities c1, c2, c3, c4 and c5. Table below gives the cost (in RM)of going from ci to ci.
We now define the following relation r on the set of cities A = c1, c2, c3, c4, c5 : ci R cj if and only if the cost of going from ci to ci is defined and less than or equal to RM180. Find R. • Sol: The relation R is the subset of A x A consisting of all cities (ci, ci), where the cost going from ci to ci is less than or equal to RM180. Hence: • R = {(c1, c2), (c1, c3), (c1, c4), (c2, c4), (c3, c1), (c3, c2), (c4, c3), (c4, c5), (c5, c2), (c5, c4)}
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, is the set of all first element in the pairs that make up R • Range for R is elements in set B. That is, Ran(R) is a subset for B, is the set of element in B that are second elements of pairs in R.
Ex 6: Consider Ex 4. Let A = {1, 2, 3, 4, 5}. Define the following relation R (less than) on A. • So R = {(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)} • Sol: Dom(R) is {1, 2, 3, 4}. Ran(R) is {2, 3, 4, 5}
Relation Representation • A relation can be represent in three ways: 1. Set Set representation is in Ex 4. 2. Matrix Matrix representation is only for two finite sets. • Ex 7: Let R be the relation defined in example 3. --> Let A = {1, 2, 3} and B = {r, s}. • Sol: R = {(1, r), (2, s), (3, r)} is a relation from A to B. Then the matrix of R is
MR = 1 0 0 1 1 0 • Ex 8: Consider the matrix • MR = 1 0 0 1 0 1 1 0 1 0 1 0 • Since M is 3 x 4, we let A = {a1, a2, a3} and B = {b1, b2, b3, b4}.
Sol: Relation for set is as below: • So R = {(a1, b1), (a1, b4), (a2, b2), (a2, b3). (a3, b1), (a3, b3)} 3. Diagraph (directed graph of R) • 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 9: Let A = {a, b, c, d} and • R = {(a, a), (a, b), (b, a), (b, b) (b, c), (b, d), (c, d), (d, a)} • Sol: The diagraph of R is shown below:
b a c d
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:
Note: In-degree of a vertex is the number of edges terminating at the vertex • Out-degree of a vertex is the number of edge leaving the vertex. • To read in-degree and out-degree from matrix. • Ex 10: 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.
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
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 12: 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.
In Example above 3 is cycle length 1, respectively. It is clear that paths of length 1 can be identified with the ordered pairs (x,y) that belong to R. • Paths in a relation R can be used to defined new relations that are quite useful. If n is a fixed positive integer, we defined relation Rnon A as follows: x Rn y means that there is a path of length n from x to y in R. • We may also defined a relation Ron A by letting x R y mean that there is some path in R from x to y. The length of the path is depend on x and y.
The relation Ris sometimes called the connectivity relation for R. • Note that Rn(x) consists of all vertices that can be reached from x by means of a path in R of length n. • The set R (x) consists of all vertices that can be reached from x by some path in R. • Path length n can be found using set, matrix or diagraph representation.
Ex 13: Let A = {a, b, c, d, e} and R = {(a, a), (a, b), (b, c), (c, d), (c, e), (d, e)} Find all paths with length 2. • Ans: Set: R2 = {(a, a), (a, b), (a, c), (b, d), (b, e), (c, e)} (manual checking)
Matric MR = 1 1 0 0 0 0 0 1 0 0 0 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.
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 12. Identify all x R y. • Answer: R = {(a,a), (a,b),( a,c), (a,d),(a,e),(b,c), (b,d),(b,e),(c,d),(c,e),(d,e)} • Exercise 2: • List all path length 2 from Exercise 1 using three ways of representation. • List all path length 1, 2 and 3 for Ex 10 and Ex 12.
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.
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. 2 3 1
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 3 2
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 3 2
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
Ex 14: Identify either diagraph below symmetric, asymmetric and/or antisymmetric. 1 1 2 2 3 3 5 5 4 4
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. c c a a b b e e d d
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) B A 2 1 C E 5 4 D 3
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. • Equivalence Relations • A relation on set A is called equivalence relation if it is reflexive, symmetric and transitive. 1 2 3 4
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.
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