Download presentation
Presentation is loading. Please wait.
Published byDale Baldwin Modified over 9 years ago
1
CSNB143 – Discrete Structure Topic 7 – Relations Part II
2
Topic 7 – Relations Learning Outcomes Student should be able to know how relation is being built Students should be able to apply relation and combine the knowledge with other topics in this subject.
3
Topic 7 – Relations Path in Relation
4
Topic 7 – Relations Path in Relation A relation R n on A : x R n y means there is a path of length n from x to y in R Example:
5
Topic 7 – Relations 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. Example: Find R for R = { (a,a), (a,b), (b,c), (c,e), (c,d), (d,e)}
6
Topic 7 – Relations Properties of relations - Reflexive Let say A = {1, 2, 3} Reflexive: All elements have relation to itselves. Set: {(1, 1), (2, 2), (3, 3,)} Matrix: Values on its diagonal are all 1. Diagraph: There must have cycle length 1 on each vertex.
7
Topic 7 – Relations Properties of relations - Irreflexive Let say A = {1, 2, 3} Set: U – R Matrix: All values on its diagonal is 0.. Diagraph: Diagraph: There is no cycle length 1 on each vertex
8
Topic 7 – Relations Properties of relations - 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. Diagraph: Two-way relation. Cycle length 1 is allowed.
9
Topic 7 – Relations Properties of relations - Asymmetric 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 be 0. Diagraph: No two-way and no cycle length 1 for all vertex.
10
Topic 7 – Relations Properties of relations – Antisymmetric 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. Diagraph: No two-way. Cycle length 1 is allowed
11
Topic 7 – Relations Exercise:
12
Topic 7 – Relations Exercise
13
Topic 7 – Relations Transitive Relation Definition: In mathematics, a relation R on a set X is transitive if whenever an element a is related to an element b, and b is in turn related to an element c, then a is also related to c. For example, "is greater than," "is at least as great as," and "is equal to“ are transitive relations: whenever A > B and B > C, then also A > C whenever A ≥ B and B ≥ C, then also A ≥ C whenever A = B and B = C, then also A = C On the other hand, "is the mother of" is not a transitive relation, because if Alice is the mother of Brenda, and Brenda is the mother of Claire, then Alice is not the mother of Claire. What is more, it is not transitive: Alice can never be the mother of Claire.
14
Topic 7 – Relations Transitive Closure Let R be a relation on set A and R is not transitive. So we want to make it becomes transitive. Let R be a relation on set A. Then R is a transitive closure for R.
15
Topic 7 – Relations Transitive Closure (R ) Ways to find the transitive closure for R 1.Matrix Product Matrix product require us to times M R few times until the final outcome is the same with the previous outcome.
16
Topic 7 – Relations Transitive Closure 2. Warshall Algorithm This algorithm only can be done to a square matrix n x n. The process must be done n times. Steps involved are: – Bring down all entries value 1 from W k-1 to W k. – List all location p 1, p 2, … in column k for W k-1 in which the entries is 1, and all location q 1, q 2, … in row k for W k-1, in which the entries is 1. – Put all 1 in all location p i, q j for W k (if the entries is 0).
17
Topic 7 – Relations Implementing Warshall Algorithm Find the transitive closure for M R
18
Topic 7 – Relations Find the transitive closure for M R Step 2 Step 3
19
Topic 7 – Relations Find the transitive closure for M R Step 4 Step 3
20
Topic 7 – Relations Independent Reading
21
Topic 7 – Relations Equivalence Relations A relation on set A is called equivalence relation if it is reflexive, symmetric and transitive. 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: 1. Complementary relation Complementary relation for R is written as R(complement). This is explained by a R b if and only if a R b 2. Inverse Inverse relation is written as R -1. This is explained by b R -1 a if and only if a R b
22
Topic 7 – Relations Composition Let say there are 3 sets 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. Example: 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)}
23
Topic 7 – Relations Closure If R is a relation on set A, R might show 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 R 1, in the relation that contains R and the new elements together so that R 1 will meets the criteria. In this case, we call R 1 as a closure of R. Example: Let A ={a, b, c} and R = {(a, a), (a, b), (b, c), (a, c)}. Then The reflexive closure for R is R 1 = {(a, a), (a, b), (b, c), (a, c), (b, b), (c, c)}. And, symmetric closure for R is R 1 = {(a, a), (a, b), (b, a), (b, c), (c, b), (a, c), (c, a)}
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.