1 / 62

8.3 Representing Relations

8.3 Representing Relations. Directed Graphs Vertex Arc (directed edge) Initial vertex Terminal vertex. Example. Draw the “divides” relation on the set {2,3,4,5,6,7,8,9} as a directed graph. The zero-one Matrix Representation M R.

Download Presentation

8.3 Representing Relations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 8.3 Representing Relations • Directed Graphs • Vertex • Arc (directed edge) • Initial vertex • Terminal vertex

  2. Example • Draw the “divides” relation on the set {2,3,4,5,6,7,8,9} as a directed graph

  3. The zero-one Matrix Representation MR • MR is just a zero-one version of the “chart” representation of R.

  4. Reflexivity Directed graph picture Zero-one matrix picture

  5. Symmetry Directed graph picture Zero-one matrix picture

  6. Antisymmetry Directed graph picture Zero-one matrix picture

  7. Transitivity Directed graph picture Zero-one matrix picture

  8. Theorem For relations R1 and R2 on set A,

  9. Example: Let and be binary relations. Find and . Use them to find Verify by calculating without matrices.

  10. Corollary For a relation R on set A, for any positive integer n.

  11. Example: Let and . Calculate and to determine if the relations and are transitive.

  12. 8.4 Closures of Relations • Reflexive closure • Symmetric closure

  13. Example: Let R be the relation on the set containing the pairs What is the reflexive closure of R? What is the symmetric closure of R?

  14. Paths in Directed Graphs • A path in a directed graph is a sequence of vertices for which any two consecutive vertices ai and ai+1 in the sequence are joined by an arc from ai to ai+1. • Theorem: Let R be a relation on set A, and n a positive integer. Then there is a path of length n from a to b in R if and only if (a,b) is in Rn.

  15. Example:

  16. The “Connectivity Relation” R* • Let R be a relation on set A. We define

  17. Example: Let be the relation on the set of all people in the world that contains if has met . What is , where is a positive integer greater than one? What is ?

  18. The Transitive Closure • For a relation R on a set A, we define the transitive closure of R to be the smallest transitive relation containing R. • Theorem:

  19. Finding transitive closure the “hard” way:

  20. Computing R* • If A is a set with n elements, and R is a relation on A, then any time there is a path of length one or more from a to b in R then there is a path of length n or less. • So actually and • Interestingly, this is not the best way of computing R*

  21. Computing transitive closure the better way:

  22. Warshall’s Algorithm procedure Warshall(MR: n by n zero-one matrix) W := MR for k:=1 to n for i:=1 to n for j:=1 to n wij := wij (wik  wkj) { W now contains MR* }

  23. Illustration of Warshall’s Algorithm

  24. 8.5 Equivalence Relations • Definition: A relation R on set A is an equivalence relation if …

  25. Examples • aRb if and only if a and b have the same first name (on the set of students in this class) • aRb if and only if a ≡ b (mod 5) (on the set of integers)

  26. Equivalence Classes • If R is a relation on set A, and a is an element of A, then…

  27. Examples (continued) • [Michael] • [4]5

  28. Theorem For an equivalence relation R on set A and elements a and b of A, the following are all logically equivalent: • a R b • [a]R = [b]R • [a]R [b]R  

  29. Partitions • For a set S, a partition of S is a collection  = {A1, A2, …, Am} of nonempty subsets of S which satisfies the following properties: • Every element of A is in one of the sets Ai. • For all i, j  {1, 2, …, m}, if i  j then Ai Aj =  • Terminology: We say that the collection partitions S.

  30. Theorem • Let R be an equivalence relation on set S. Then the equivalence classes of R partition S. Conversely, for any partition  of S there is an equivalence relation R whose equivalence classes are the sets in .

  31. …,-10, , ,-7, , ,-4, , ,-1, , ,2, , ,5, , ,8, , , … …, ,-9, , ,-6, , ,-3, , ,0, , ,3, , ,6, , ,9, , … …, , ,-8, , ,-5, , ,-2, , ,1, , ,4, , ,7, , ,10, … Visual …, ,-9, , ,-6, , ,-3, , ,0, , ,3, , ,6, , ,9, , … …, , ,-8, , ,-5, , ,-2, , ,1, , ,4, , ,7, , ,10, … …,-10, , ,-7, , ,-4, , ,-1, , ,2, , ,5, , ,8, , , … [2]={… ,-10, -7, -4, -1, 2, 5, 8, …} [0]={… ,-9, -6, -3, 0, 3, 6, 9, …} [1]={… ,-8, -5, -2, 1, 4, 7, 10, …}

  32. Visual [2]={… ,-10, -7, -4, -1, 2, 5, 8, …} [0]={… ,-9, -6, -3, 0, 3, 6, 9, …} [1]={… ,-8, -5, -2, 1, 4, 7, 10, …} …,-10, , ,-7, , ,-4, , ,-1, , ,2, , ,5, , ,8, , , … …, ,-9, , ,-6, , ,-3, , ,0, , ,3, , ,6, , ,9, , … …, , ,-8, , ,-5, , ,-2, , ,1, , ,4, , ,7, , ,10, …

  33. Example: Turning a partition into an equivalence relation

  34. Zero-One Matrix Representation of an Equivalence Relation Examples

  35. Digraph Representation of an Equivalence Relation Examples

  36. Equivalence as “sameness” • Almost every equivalence relation definition comes down to identifying some notion of “sameness” • Same remainder when divided by n • Same name • Same set of a partition

  37. Number of Partitions of a Set with n Elements • n = 1 • n = 2 • n = 3 • n = 4

  38. Recurrence Relation for the Number of Partitions of a Set with n Elements

  39. 8.6 Partial Orderings Let A be a set, and R a relation on A. We say that R is a partial ordering if and only if… In this case we say that the pair (A, R) is a partially ordered set (poset).

  40. Examples: • The real numbers R under the  relation • The real numbers R under the  relation • The positive integers under the “divides” relation • Any set of sets under the  (subset) relation • The cartesian product ZZunder the “(,)” relation R. (i.e. (x,y) R (z,w) if and only if x  z and y  w.)

  41. Convention • The symbol is the default symbol used to represent a partial ordering. • Example: “Let A be a set, and let be a partial ordering on A.”

  42. Comparable and Incomparable Elements • Two elements aand bof a partially ordered set are said to be incomparable if and only if the statements ab and ba are both false. Otherwise the elements are comparable. • Examples: • Subsets • Cartesian products • Divides relation

  43. Examples:

  44. Total Orderings • Let A be a set, and let be a partial ordering on A. We say that is a total ordering provided…In this case we say that the pair (A, ) is a totally ordered set. (linearly ordered set, chain) • Examples: 1) Real numbers under  2) Any set of strings under the “dictionary”, or lexicographic, ordering

  45. A partial order on “induced” by partial orders on and on • Lexicographic ordering • Example:

  46. Well-Ordered Sets • A set S is well-ordered by the partial ordering if and only if every nonempty subset of S has a least element (minimum element). • Examples: • Non-Examples: , ,

  47. Hasse Diagrams • Begin with the digraph representation of the partial ordering • Omit the reflexive loops • Omit all edges which would be implied by transitivity • Orient all vertices and arcs so that the direction of each arc is up. • Remove the direction arrow from each arc

  48. Hasse Diagram Example I • Pairs in {1,2,3}{1,2,3} under lexicographic order

  49. Hasse Diagram Example I • Pairs in {1,2,3}{1,2,3} under lexicographic order

  50. Hasse Diagram Example I • Pairs in {1,2,3}{1,2,3} under lexicographic order

More Related