relations
play

Relations Slides by Christopher M. Bourke Instructor: Berthe Y. - PowerPoint PPT Presentation

Relations CSE235 Relations Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 7.1, 7.37.5 of Rosen 1 / 1 cse235@cse.unl.edu


  1. Relations CSE235 Relations Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 7.1, 7.3–7.5 of Rosen 1 / 1 cse235@cse.unl.edu

  2. Introduction Relations Recall that a relation between elements of two sets is a subset CSE235 of their Cartesian product (of ordered pairs). Definition A binary relation from a set A to a set B is a subset R ⊆ A × B = { ( a, b ) | a ∈ A, b ∈ B } Note the difference between a relation and a function: in a relation, each a ∈ A can map to multiple elements in B . Thus, relations are generalizations of functions. If an ordered pair ( a, b ) ∈ R then we say that a is related to b . We may also use the notation aRb and a � Rb . 2 / 1

  3. Relations Relations CSE235 To represent a relation, you can enumerate every element in R . Example Let A = { a 1 , a 2 , a 3 , a 4 , a 5 } and B = { b 1 , b 2 , b 3 } let R be a relation from A to B as follows: = { ( a 1 , b 1 ) , ( a 1 , b 2 ) , ( a 1 , b 3 ) , ( a 2 , b 1 ) , R ( a 3 , b 1 ) , ( a 3 , b 2 ) , ( a 3 , b 3 ) , ( a 5 , b 1 ) } You can also represent this relation graphically. 3 / 1

  4. Relations Graphical View Relations CSE235 A B a 1 b 1 a 2 a 3 b 2 a 4 b 3 a 5 Figure: Graphical Representation of a Relation 4 / 1

  5. Relations On a Set Relations Definition CSE235 A relation on the set A is a relation from A to A . I.e. a subset of A × A . Example The following are binary relations on N : R 1 = { ( a, b ) | a ≤ b } R 2 = { ( a, b ) | a, b ∈ N , a b ∈ Z } R 3 = { ( a, b ) | a, b ∈ N , a − b = 2 } Exercise : Give some examples of ordered pairs ( a, b ) ∈ N 2 that are not in each of these relations. 5 / 1

  6. Reflexivity Definition Relations CSE235 There are several properties of relations that we will look at. If the ordered pairs ( a, a ) appear in a relation on a set A for every a ∈ A then it is called reflexive. Definition A relation R on a set A is called reflexive if � � ∀ a ∈ A ( a, a ) ∈ R 6 / 1

  7. Reflexivity Example Relations CSE235 Example Recall the following relations; which is reflexive? { ( a, b ) | a ≤ b } R 1 = { ( a, b ) | a, b ∈ N , a = b ∈ Z } R 2 R 3 = { ( a, b ) | a, b ∈ N , a − b = 2 } 7 / 1

  8. Reflexivity Example Relations CSE235 Example Recall the following relations; which is reflexive? { ( a, b ) | a ≤ b } R 1 = { ( a, b ) | a, b ∈ N , a = b ∈ Z } R 2 R 3 = { ( a, b ) | a, b ∈ N , a − b = 2 } R 1 is reflexive since for every a ∈ N , a ≤ a . 8 / 1

  9. Reflexivity Example Relations CSE235 Example Recall the following relations; which is reflexive? { ( a, b ) | a ≤ b } R 1 = { ( a, b ) | a, b ∈ N , a = b ∈ Z } R 2 R 3 = { ( a, b ) | a, b ∈ N , a − b = 2 } R 1 is reflexive since for every a ∈ N , a ≤ a . R 2 is also reflexive since a a = 1 is an integer. 9 / 1

  10. Reflexivity Example Relations CSE235 Example Recall the following relations; which is reflexive? { ( a, b ) | a ≤ b } R 1 = { ( a, b ) | a, b ∈ N , a = b ∈ Z } R 2 R 3 = { ( a, b ) | a, b ∈ N , a − b = 2 } R 1 is reflexive since for every a ∈ N , a ≤ a . R 2 is also reflexive since a a = 1 is an integer. R 3 is not reflexive since a − a = 0 for every a ∈ N . 10 / 1

  11. Symmetry I Definition Relations CSE235 Definition A relation R on a set A is called symmetric if ( b, a ) ∈ R ⇐ ⇒ ( a, b ) ∈ R for all a, b ∈ A . A relation R on a set A is called antisymmetric if �� � � ∀ a, b, ( a, b ) ∈ R ∧ ( b, a ) ∈ R → a = b for all a, b ∈ A . 11 / 1

  12. Symmetry II Definition Relations Some things to note: CSE235 A symmetric relationship is one in which if a is related to b then b must be related to a . An antisymmetric relationship is similar, but such relations hold only when a = b . An antisymmetric relationship is not a reflexive relationship. A relation can be both symmetric and antisymmetric or neither or have one property but not the other! A relation that is not symmetric is not necessarily asymmetric . 12 / 1

  13. Symmetric Relations Example Relations CSE235 Example Let R = { ( x, y ) ∈ R 2 | x 2 + y 2 = 1 } . Is R reflexive? Symmetric? Antisymmetric? 13 / 1

  14. Symmetric Relations Example Relations CSE235 Example Let R = { ( x, y ) ∈ R 2 | x 2 + y 2 = 1 } . Is R reflexive? Symmetric? Antisymmetric? It is clearly not reflexive since for example (2 , 2) �∈ R . 14 / 1

  15. Symmetric Relations Example Relations CSE235 Example Let R = { ( x, y ) ∈ R 2 | x 2 + y 2 = 1 } . Is R reflexive? Symmetric? Antisymmetric? It is clearly not reflexive since for example (2 , 2) �∈ R . It is symmetric since x 2 + y 2 = y 2 + x 2 (i.e. addition is commutative). 15 / 1

  16. Symmetric Relations Example Relations CSE235 Example Let R = { ( x, y ) ∈ R 2 | x 2 + y 2 = 1 } . Is R reflexive? Symmetric? Antisymmetric? It is clearly not reflexive since for example (2 , 2) �∈ R . It is symmetric since x 2 + y 2 = y 2 + x 2 (i.e. addition is commutative). √ √ It is not antisymmetric since ( 1 8 3 , 1 8 3 , 3 ) ∈ R and ( 3 ) ∈ R √ but 1 8 3 � = 3 16 / 1

  17. Transitivity Definition Relations CSE235 Definition 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 ∈ R . Equivalently, � � ∀ a, b, c ∈ A ( aRb ∧ bRc ) → aRc 17 / 1

  18. Transitivity Examples Relations CSE235 Example Is the relation R = { ( x, y ) ∈ R 2 | x ≤ y } transitive? Example Is the relation R = { ( a, b ) , ( b, a ) , ( a, a ) } transitive? 18 / 1

  19. Transitivity Examples Relations CSE235 Example Is the relation R = { ( x, y ) ∈ R 2 | x ≤ y } transitive? Yes it is transitive since ( x ≤ y ) ∧ ( y ≤ z ) ⇒ x ≤ z . Example Is the relation R = { ( a, b ) , ( b, a ) , ( a, a ) } transitive? 19 / 1

  20. Transitivity Examples Relations CSE235 Example Is the relation R = { ( x, y ) ∈ R 2 | x ≤ y } transitive? Yes it is transitive since ( x ≤ y ) ∧ ( y ≤ z ) ⇒ x ≤ z . Example Is the relation R = { ( a, b ) , ( b, a ) , ( a, a ) } transitive? No since bRa and aRb but b � Rb . 20 / 1

  21. Transitivity Examples Relations Example CSE235 Is the relation { ( a, b ) | a is an ancestor of b } transitive? Example Is the relation { ( x, y ) | x 2 ≥ y } transitive? 21 / 1

  22. Transitivity Examples Relations Example CSE235 Is the relation { ( a, b ) | a is an ancestor of b } transitive? Yes, if a is an ancestor of b and b is an ancestor of c then a is also an ancestor of b (who is the youngest here?). Example Is the relation { ( x, y ) | x 2 ≥ y } transitive? 22 / 1

  23. Transitivity Examples Relations Example CSE235 Is the relation { ( a, b ) | a is an ancestor of b } transitive? Yes, if a is an ancestor of b and b is an ancestor of c then a is also an ancestor of b (who is the youngest here?). Example Is the relation { ( x, y ) | x 2 ≥ y } transitive? No. For example, (2 , 4) ∈ R and (4 , 10) ∈ R (i.e. 2 2 ≥ 4 and 4 2 = 16 ≥ 10 ) but 2 2 < 10 thus (2 , 10) �∈ R . 23 / 1

  24. Other Properties Relations Definition CSE235 A relation is irreflexive if � � ∀ a ( a, a ) �∈ R A relation is asymmetric if � � ∀ a, b ( a, b ) ∈ R → ( b, a ) �∈ R Lemma A relation R on a set A is asymmetric if and only if R is irreflexive and R is antisymmetric. 24 / 1

  25. Combining Relations Relations CSE235 Relations are simply sets, that is subsets of ordered pairs of the Cartesian product of a set. It therefore makes sense to use the usual set operations, intersection ∩ , union ∪ and set difference A \ B to combine relations to create new relations. Sometimes combining relations endows them with the properties previously discussed. For example, two relations may not be transitive alone, but their union may be. 25 / 1

  26. Combining Relations Relations Example CSE235 Let { 1 , 2 , 3 , 4 } A = = { 1 , 2 , 3 } B R 1 = { (1 , 2) , (1 , 3) , (1 , 4) , (2 , 2) , (3 , 4) , (4 , 1) , (4 , 2) } = { (1 , 1) , (1 , 2) , (1 , 3) , (2 , 3) } R 2 Then 26 / 1

  27. Combining Relations Relations Example CSE235 Let { 1 , 2 , 3 , 4 } A = = { 1 , 2 , 3 } B R 1 = { (1 , 2) , (1 , 3) , (1 , 4) , (2 , 2) , (3 , 4) , (4 , 1) , (4 , 2) } = { (1 , 1) , (1 , 2) , (1 , 3) , (2 , 3) } R 2 Then R 1 ∪ R 2 = { (1 , 1) , (1 , 2) , (1 , 3) , (1 , 4) , (2 , 2) , (2 , 3) , (3 , 4) , (4 , 1) , (4 , 2) } 27 / 1

  28. Combining Relations Relations Example CSE235 Let { 1 , 2 , 3 , 4 } A = = { 1 , 2 , 3 } B R 1 = { (1 , 2) , (1 , 3) , (1 , 4) , (2 , 2) , (3 , 4) , (4 , 1) , (4 , 2) } = { (1 , 1) , (1 , 2) , (1 , 3) , (2 , 3) } R 2 Then R 1 ∪ R 2 = { (1 , 1) , (1 , 2) , (1 , 3) , (1 , 4) , (2 , 2) , (2 , 3) , (3 , 4) , (4 , 1) , (4 , 2) } R 1 ∩ R 2 = { (1 , 2) , (1 , 3) } 28 / 1

  29. Combining Relations Relations Example CSE235 Let { 1 , 2 , 3 , 4 } A = = { 1 , 2 , 3 } B R 1 = { (1 , 2) , (1 , 3) , (1 , 4) , (2 , 2) , (3 , 4) , (4 , 1) , (4 , 2) } = { (1 , 1) , (1 , 2) , (1 , 3) , (2 , 3) } R 2 Then R 1 ∪ R 2 = { (1 , 1) , (1 , 2) , (1 , 3) , (1 , 4) , (2 , 2) , (2 , 3) , (3 , 4) , (4 , 1) , (4 , 2) } R 1 ∩ R 2 = { (1 , 2) , (1 , 3) } R 1 \ R 2 = { (1 , 4) , (2 , 2) , (3 , 4) , (4 , 1) , (4 , 2) } 29 / 1

Recommend


More recommend