Chapter 8 8.1 Relations and Their Properties 8.2 n-ary Relations and Their Applications 8.3 Representing Relations 8.4 Closures of Relations 8.5 Equivalence Relations 8.6 Partial Orderings 1 8.1 Relations and Their Properties Definition: A binary relation R from a set A to a set B is a subset R A B. .
Note: there are no constraints on relations as there are on functions. We have a common graphical representation of relations: Definition: A Directed graph or a Digraph D from A to B is a collection of vertices V A B and a collection of edges R A B . If there is an ordered pair e =
B = {1, 2, 3, 4} R is defined by the ordered pairs or edges {, ,
Example : How many binary relations are there on a set A? Example 4: Let A be the set {1, 2, 3, 4}. Which ordered pairs are in the relation R={(a ,b) | a divides b}? 4 Special Properties of Binary Relations Given: A Universe U A binary relation R on a subset A of U Definition: R is reflexive iff "x [ x U < x, x >R ] Note: if U = then the implication is true vacuously The void relation on a void Universe is reflexive! Note: If U is not void then all vertices in a reflexive relation must have loops!
5 Properties of Relations Example 7: Consider the following relations on {1, 2, 3, 4} : R1:{(1,1) ,(1, 2), (2, 1), (2, 2), (3, 4), (4, 1) ,(4, 4)}. R2:{(1,1) ,(1, 2), (2, 1)}. R3:{(1,1) ,(1, 2), (1, 4), (2, 1), (2, 2), (3, 3) ,(4, 1), (4, 4)}. R4:{(2, 1), (3, 1), (3, 2), (4, 1) ,(4, 2), (4, 3)}. R5:{(1,1) ,(1, 2), (1, 3), (1, 4), (2, 2), (2, 3) ,(2, 4), (3, 3), (3, 4), (4, 4)}. R6:{ (3, 4)}. Which of these relations are reflexive?
6 Properties of Relations Definition: R is symmetric iff "x"y [< x, y > R < y, x > R ] Note:If there is an arc
if
8 Properties of Relations Definition: R is transitive iff "x"y"z [ < x, y > R < y, z > R < x,z > R ] Note: if there is an arc from x to y and one from y to z then there must be one from x to z. This is the most difficult one to check. We will develop algorithms to check this later. Example 13: Which of the relations in Example 7 are transitive? R1:{(1,1) ,(1, 2), (2, 1), (2, 2), (3, 4), (4, 1) ,(4, 4)}. R2: {(1,1) ,(1, 2), (2, 1)}. R3:{(1,1) ,(1, 2), (1, 4), (2, 1), (2, 2), (3, 3) ,(4, 1), (4, 4)}.
R4:{(2, 1), (3, 1), (3, 2), (4, 1) ,(4, 2), (4, 3)}. R5:{(1,1) ,(1, 2), (1, 3), (1, 4), (2, 2), (2, 3) ,(2, 4), (3, 3), (3, 4), (4,4)}. R6:{ (3, 4)}. 9 Properties of Relations Example: A: not reflexive symmetric antisymmetric transitive
C: not reflexive not symmetric antisymmetric not transitive B: not not not not reflexive symmetric
antisymmetric transitive D: not reflexive not symmetric antisymmetric transitive 10 Combining Relations A very large set of potential questions Let R1 and R2 be binary relations on a set A: If R1 has property 1 and
R2 has property 2, does R1 * R2 have property 3 where * represents an arbitrary binary set operation? 11 Combining Relations Example: If R1 is symmetric , and R2 is antisymmetric, does it follow that, R1R2 is transitive?R2 is transitive? If so, prove it. Otherwise find a counterexample. Example : Let R1 and R2 be transitive on A. Does it follow that
R1 R2 is transitive? R2 is transitive? 12 Composition Definition: Suppose R1 is a relation from A to B R2 is a relation from B to C. Then the composition of R2 with R1, denoted R2 R1 is the relation from A to C: If
For
Composition Definition: Let R be a binary relation on A. Then Basis: R1 = R Induction: Rn + 1= Rn R Note: an ordered pair
16 Composition Theorem: R is transitive iff Rn R for all n > 0 . 17 8.2 n-ary Relations and Their Applications Definition 1: Let A1, A2, . . ., An be sets. An n-ary relation o n these sets is a subset of A1 A2 . . . An The sets A1, A2, . . ., An are called the domains of the rela tion, and n is called its degree. Example 4: Let R be the relation consisting of 5-ruples (A
, N, S, D, T) representing airplane flights, where A is the ai rline, N is the starting point, D is the destination, and T is the departure time, for instance, if Nadir Express Airlines has flight 963 from Newark to Bangor at 15:00, then (Nad ir, 963, Newark, Bangor, 15:00) belongs to R, the degree of this relation is 5, and its domains are the set of all airli nes, the set of flight numbers, the set of cities, the set of cities(again) , and the set of times. 18 Databases and Relations The time required to manipulate information in a dat abase depends on how this information is stored. The operations of adding and deleting records, upda
ting records, searching for records, and combining re cords from overlapping databases are performed mill ions of times each day in a large database. Because of the importance of these operations, vario us methods for representing databases have been de veloped. We will discuss one of these methods, called the rela tional data model, based on the concept of a relatio n. 19 Databases and Relations A database consists of records, which are n-tuples, made u p of fields. For instance, a database of student records may
be made up of fields containing the name, student number, major, and grade point average of the student. Thus , stude nt records are represented as 4-tuples of the form (STUDEN T NAME, ID NUMBER, MAJOR, GPA). A sample database of six such records is (Ackermann, 231455, Computer Science, 3.88) (Adams, 888323, physics, 3.45) (Chou, 102147, Computer Science, 3.49) (Goodfriend, 453876, Mathematics, 3.45) (Rao, 678543, Mathematics, 3.90) (Stevens, 786576, Psychology, 2.99) 20 Databases and Relations
Relations used to represent databases are also called tables. A domain of an n-ary relation is called a primary key when the value of the n-tuple from this domain deter mines the n-tuple. The current collection of n-tuples in a relation is calle d the extension of the relation. The more permanent part of a database , including t he name and attributes of the database, is called its i ntension. 21 Databases and Relations
22 Databases and Relations Example 5: which domains are primary keys for the n-ary relation displayed in Table1, assuming that no n-tuples will be added in the future? Combinations of domains can also uniquely identify n-tuples in an n-ary relation. When the values of a se t of domains determine an n-tuple in a relation, the C artesian product of these domains is called a compos ite key. Example 6: Is the Cartesian product of the domain of major fields of study and the domain of GPAs a com
posite key for the n-ary relation from Table1, assumin g that no n-tuples are ever added? 23 Operations on n-ary Relations Definition 2: Let R be an n-ary relation and C a condition th at elements in R may satisfy. Then the selection operator sC maps the n-ary relation R to the n-ary relation of all n-tupl es from R that satisfy the condition C. Example 7: To find the records of computer science majors i n the n-ary relation R shown in Table 1, we use the operato r sC1, C1 is the condition Major = Computer Science. To find the records of students who have a grade point aver age above 3.5 in this database, we use the operator sC2, wh
ere C2 is the condition GPA > 3.5. To find the records of computer science majors who have a GPA above 3.5, we use the operator sC3 , C3 is the condition (Major=Computer Science GPA > 3.5 ). 24 Operations on n-ary Relations Definition 3: The projection, Pi1, Pi2,. . . , Pim where i1 < i2 <. . .< im , maps the n-tuple (a1, a2,. . ., an) to the m-tuple (ai1 , ai2 , . . ., aim ) , m n. Example 8: what results then the projection P1,3 is applied to t he 4-tuples (2, 3, 0, 4), (Jane Doe, 234111001, Geography, 3.1 4), and (a1, a2, a3, a4)? Example 9: What relation results when the projection
P1,4 is applied to the relation in Table 1? 25 8.3 Representing Relations Connection Matrices Let R be a relation from A = {a1, a2, . . . , am} to B = {b1, b2, . . . , bn}. Definition: An m n connection matrix M for R is defined by Mij = 1 if
R is antisymetric if Mij = 0 or Mji = 0 for all i j. FIGURE 1 The Zero-One Matrix for a Reflexive FIGURE 2 The Zero-One Matrices for Symmetric and Antisymmetric Relations. 27 Combining Connection Matrices Example 3: Suppose that the relation R on a set is represent ed by the matrix 1 1 0 M R = 1 1 1
0 1 1 Is R reflexive, symmetric and/or antisymmetric? Definition: the join of two matrices M1, M2, denoted M1 M2 , is the component wise boolean or of the two matrices. Fact: If M1 is the connection matrix for R1 and M2 is the connection matrix for R2 then the join of M1 and M2 , M1 M2 is the connection matrix for R1RR2 . 28 Combining Connection Matrices Definition: the meet of two matrices M1, M2, denoted M1 M2 is the componentwise boolean and of the t
wo matrices. Fact: If M1 is the connection matrix for R1 and M2 is th e connection matrix for R2 then the meet of M1 and M 2, M1 M2 is the connection matrix for R1R2 . Example 4: Suppose that the relations R1 and R2 on a set A are represented by the matrices. M R1 1 = 1 0 0 0
1 1 0 0 and , M R 2 1 = 0 1
0 1 0 1 1 0 What are the matrices representing R1RR2 and R1R2 ? 29 The Composition Definition: Let M1 be the connection matrix for R1 M2 be the connection matrix for R2.
The boolean product of two connection matrices M1 and M2, denoted M1 M2 , is the connection matrix for the composition of R2 with R1 , R2 R1. (M1 M2 )ij = k=1n [(M1 )ik (M2 )kj ] Why? 30 The Composition In order for there to be an arc
number of columns of M1 must equal the number of rows of M2. If M1 is m n and M2 is n p then M1 M2 is m p. 31 The Composition Example : (M1 M2 )12 = [(M1 )11 (M2 )12 ][(M1 )12 (M2 )22 ] [(M1 )13 (M2 )32 ][(M1)14 (M2 )42 ] = [0 0] [1 1] [0 0] [0 1] = 1 32
The Composition Note: there is an arc in R1 from node 1 in A to node 2 in B there is an arc in R2 from node 2 in B to node 2 in C. Hence there is an arc in R2 R1 from node 1 in A to n ode 2 in C. 33 Representing Relations Using Digraphs Definition 1: A directed graph, or digraph, consists of a set V of vertices (or nodes ) together with a set E of ordered pairs of elements of V called edges (or arcs). The vertex a is called the initial vertex of the edge (a,
b), and the vertex b is called the terminal vertex of thi s edge. An edge of the form (a, a) is represented using an arc from the vertex a back to itself. Such an edge is called a loop. 34 Representing Relations Using Digraphs Example 7: The directed graph with vertices a, b, c, a nd d, and edges (a, b), (a, d), (b, b), (b, d), (c, a), (c, b), and (d, b) is displayed in Figure 3. FIGURE 3 The Directed
Graph. 35 Representing Relations Using Digraphs Example 8: The directed graph of the relation R={(1, 1), (1, 3), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (4, 1)} on the set {1, 2, 3, 4} is shown in figure 4. FIGURE 4 The Directed Graph of the Relations R. 36
Representing Relations Using Digraphs Example 9: What are the ordered pairs in the relation R represented by the directed graph shown in figure 5? FIGURE 5 The Directed Graph of the Relations R. 37 Representing Relations Using Digraphs Example 10: Determine whether the relations for the directed graphs shown in figure 6 are reflexive, symm etric, antisymmetric, and/or transitive. FIGURE 6 The Directed Graph of the Relations R and
S. 38 8.4 Closures of Relations Definition: The closure of a relation R with respect to property P is the relation obtained by adding the minim um number of ordered pairs to R to obtain property P. In terms of the digraph representation of R --To find the reflexive closure - add loops. --To find the symmetric closure - add arcs in the opposite direction. --To find the transitive closure - if there is a path from a to b, and a path from b to c, add an arc from a to c.
Note: Reflexive and symmetric closures are easy. Transitive closures can be very complicated. 39 Closures of Relations Definition: Let A be a set and let = {
Put 1s on the diagonal of the connection matrix of R. 40 Closures of Relations Example 1: What is the reflexive closure of the relatio n R={(a, b) | a< b} on the set of integers? Example 2: What is the symmetric closure of the rela tion R={(a, b) | a> b} on the set of positive integers? 41 Symmetric Closure Definition: Let R be a relation on A. Then R-1 or the inverse of R is the relation R-1 = {< y, x >|< x, y >
R} Note: to get R-1 reverse all the arcs in the digraph representation of R take the transpose MT of the connection matrix M of R. Note: This relation is sometimes denoted as RT or Rc and called the converse of R The composition of the relation with its inverse does not necessarily produce the diagonal relation (recall that the composition of a bijective function with its inverse is the identity). 42 Symmetric Closure Theorem: Let R be a relation on A. The symmetric
closure of R, denoted s(R ), is the relation R R-1 . Example 2: What is the symmetric closure of the relatio n R={(a, b) | a> b} on the set of positive integers? Example : 43 Symmetric Closure Examples: If A = Z, then r( ) = Z Z If A = Z+, then s( < ) = . What is the (infinite) connection matrix of s(<)? If A = Z, then s() = ?) = ?
44 Symmetric Closure Theorem: Let R1 and R2 be relations from A to B. -1 = Then 1 1 = ( R -1) -1 = R R R (R1RR2) -1 = R1-1 R R2-1 (R1 - R2) -1 = R1 -1 - R2 -1
(R1 R2)-1= R1 -1R2 -1 If A = B, then (R1R2) -1 = R2-1R1-1 (A x B) -1 = B x A If R1 R2 then R1-1 R2-1 45 Paths in Directed Graphs Definition 1: A path from a to b in the directed graph G is a sequence of edges (x0, x1), (x1, x2), (x2, x3), . . ., (x
n-1, xn) in G, where n is a nonnegative integer, and x0= a and x1=b . that is , a sequence of edges where the terminal vert ex of an edge is the same as the initial vertex in the n ext edge in the path. This path is denoted by x0, x1, x2, . . .,xn-1 ,xn and has le ngth n. We view the empty set of edges as a path from a to a . a path of length n 1 that begins and ends at the sa1 that begins and ends at the sa me vertex is called a circuit or cycle. 46 Symmetric ClosurePaths in Directed Graphs Examples 3:
Which of the following are paths in the directed grap h show below? What are the lengths of those that ar e paths? Which of the paths in this list are circuits? a,b,e,d; a,e,c,d,b; b,a,c,b,a,a,b; d,c; c,b,a; e,b,a,d,a,b,e; 47 Paths in Directed Graphs Theorem: Let R be a relation on A. There is a path of
A such that there is a path of l ength 1 from a to x and a pat h of length n from x to b. From the Induction Hypoth esis, R and since
Useful Results for Transitive Closure Theorem: Theorem: Corollary: Theorem: If A B and C B, then A C B. If R S and T U then R T S U.
If R S then Rn Sn If R is transitive then so is Rn Theorem: If Rk = Rj for some j > k, then Rj+m = Rn for some n j. We dont get any new relations beyond Rj. As soon as you get a power of R that is the same a s one you had before, STOP. 49 Transitive Closure Recall that the transitive closure of a relation R, t(R), is the smallest transitive relation containing R. Also recall: R is transitive iff Rn is contained in R for all n
. Hence, if there is a path from x to y then there must be an arc from x to y, or
R*=n=1 Rn Examples: Let A = Z and R = {}. R* = < . Let A = the set of people, R = {
3) is the smallest transitive relation which contains R. Proof: Part 2): Easy from the definition of R*. Part 1): Suppose
We must show S contains R* to show R* is the smallest such relation. R S so R2 S2 S since S is transitive Therefore Rn Sn S for all n. (why?) Hence S must contain R* since it must also contain the union of all the powers of R. 53 Transitive Closure Theorem: If |A| = n, then any path of length > n must c ontain a cycle. Proof: If we write down a list of more than n vertices r epresenting a path in R, some vertex must appear at le
ast twice in the list (by the Pigeon Hole Principle). Thus Rk for k > n doesnt contain any arcs that dont already appear in the first n powers of R. 54 Transitive Closure Lemma 1: Let A be a set with n elements, and let R b e a relation on A . If there is a path of length at least one in R from a to b, then there is such a path with le ngth not exceeding n. Moreover, when a b , if there is a path of length at least one in R from a to b, then t here is such a path with length not exceeding n-1.
55 Transitive Closure Corollary: We can find the connection matrix of t(R) by computing the join of the first n powers of the con nection matrix of R. Powerful Algorithm! Example: 56 Transitive Closure Theorem 3: Let MR be the zero-one matrix of the rela tion R on the relation R on a set with n elements. The
n the zero-one matrix of the transitive closure R* is M R* =M R M [ 2] R M [ 3] R M
[n] R Example: Find the zero-one matrix of the transitive cl osure of the relation R where 1 1 0 M R = 1 0 1 0 1 0 57 Transitive Closure Algorithm 1 : A Procedure for Computing the Transitive Closure procedure transitive closure (MR :zero-one nxn matrix)
A := MR B := A for i :=2 to n begin A := AMMR B := B A end {B is the zero-one matrix for R* } 58 8.5 Equivalence Relations Now we group properties of relations together to de fine new types of important relations. Definition: A relation R on a set A is an equivalence relation iff R is
reflexive symmetric transitive 59 Equivalence Relations It is easy to recognize equivalence relations using digraphs. The subset of all elements related to a particular element forms a universal relation (contains all possible arcs) on that subset. The (sub)digraph representing the subset is called a complete (sub)digraph. All arcs are present.
The number of such subsets is called the rank of the equivalence relation. 60 Equivalence Relations Example: A has 3 elements: 61 Equivalence Relations Each of the subsets is called an equivalence class. A bracket around an element means the equivalence
class in which the element lies. [x] = {y |
A: Si Si Sj = if i j R2 is transitive?Si = A FIGURE 1 A Partition of a Set. 63 Equivalence Relations Theorem: The equivalence classes of an equivalence relation R partition the set A into disjoint nonempty subsets whose union is the entire set. This partition is denoted A/R and called -- the quotient set, or
-- the partition of A induced by R, or, -- A modulo R. Example : A = [a] [b] = [a] [c] = {a} {b,c} rank = 2 64 Equivalence Relations Theorem: Let R be an equivalence relation on A. The n either [a] = [b] Or [a] [b] =
Theorem: If R1 and R2 are equivalence relations on A then R1 R2 is an equivalence relation on A . 65 Equivalence Relations Definition: Let R be a relation on A. Then the reflexiv e, symmetric, transitive closure of R, tsr(R), is an equi valence relation on A, called the equivalence relation induced by R. Example: tsr(R)
rank = 2 A = [a] [b] = {a} {b, c, d} ; A/R = {{a}, {b, c, d}} 66 Equivalence Relations Theorem: tsr(R) is an equivalence relation Proof: We have to be careful and show that tsr(R) is still sym metric and reflexive. Since we only add arcs vs. deleting arcs when compu ting closures it must be that tsr(R) is reflexive since all loops
of r(R) ensures there is an arc
8.6 Partial Orderings Definition: Let R be a relation on A. Then R is a partia l order iff R is reflexive antisymmetric transitive (A, R) is called a partially ordered set or a poset. 69
Partial Orderings Note: It is not required that two things be related un der a partial order. That's the partial part of it. If two objects are always related in a poset, it is calle d a total order or linear order or simple order. In this case (A, R) is called a chain. 70 Partial Orderings Examples: (Z ) is a poset. In this case either a b or b a s o
two things are always related. Hence, is a total ord er and (Z, ) is a chain. If S is a set then (P(S), ) is a poset. It may not be th e case that A B or B A. Hence, is not a total o rder. (Z+, 'divides') is a poset which is not a chain. 71 Partial Orderings Definition 2: The elements a and b of a poset (S, ) are called comparable if either a b or b a . When a and b are elements of S such that neither a b nor b a , a and b are called incomparable. Example 5: In the poset (Z+, |), are the integers 3 and
9 comparable? Are 5 and 7 are incomparable, becaus e 5 7 and 7 5 . 72 Partial Orderings Definition: Let R be a total order on A and suppose S A. An element s in S is a least element of S iff sRb for every b in S. Similarly for greatest element. Note: this implies that is not in R for any a unle ss a = s. (There is nothing smaller than s under the or der R).
73 Partial Orderings A Chain (A,R) is well-ordered iff every subset of A has a l east element. Examples: (Z, ) is a chain but not well-ordered. Z does not have least element. (N, ) is well-ordered. (N, ) is not well-ordered. Theorem 1: The Principle of Well-Ordered Induction Suppose that S is a well-ordered set. Then P(x) is true for all x S, if Inductive Step: For every y S , if P(x) is true for all
x S with x y , then P(y) is true. 74 Lexicographic Order Given two posets (A1, R1) and (A2, R2) we construct an indu ced partial order R on A1A2: < x1, y1> R
(Note that 4 is not related to 5). 75 Lexicographic Order This definition extends naturally to multiple Cartesian products of partially ordered sets: A1 A2 A3 . . . An. Example: Using the same definitions of Ai and Ri as above, < 2, 3, 4, 5> R < 2, 3, 8, 2> since x1 = x2, y1 = y2 and 4 divides 8. <2, 3, 4, 5> is not related to <3, 6, 8, 10> since 2 does not divide 3.
76 Lexicographic Order In Figure 1 the ordered pairs in Z+ Z+ that are less tha n (3, 4) are highlighted. FIGURE 1 The Ordered Pairs Less Than (3,4) in Lexicographic Order. 77
Strings We apply this ordering to strings of symbols where there is an underlying 'alphabetical' or partial order (which is a total order in this case). Example: Let A = { a, b, c} and suppose R is the natural alphabetic al order on A: a R b and b R c. Then Any shorter string is related to any longer string(comes befor e it in the ordering). If two strings have the same length then use the induced par tial order from the alphabetical order:
aabc R abac 78 Hasse or Poset Diagrams To construct a Hasse diagram: 1) Construct a digraph representation of the poset (A, R) so that all arcs point up (except the loops). 2) Eliminate all loops 3) Eliminate all arcs that are redundant because of transitivity 4) eliminate the arrows at the ends of arcs since everything points up.
79 Hasse Diagrams For instance, consider the directed graph for the par tial ordering {(a, b)| a b} on the set {1, 2, 3, 4}. Figu re 2(a). we do not have to show t hese loops because they must be present. Figure 2 (a). We do not have to show t hose edges that must be
present because of transi tivity. Figure 2(c). FIGURE 2 Constructing the Hasse Diagram for ({1,2,3,4},). 80 Hasse Diagrams Example 12: Draw the Hasse diagram representing th e partial ordering {(a, b)| a divides b} on {1, 2, 3, 4, 6, 8, 12}. FIGURE 3 Constructing the Hasse Diagram of ({1,2,3,4,6,8,1 2}, ).
81 Hasse Diagrams Example 13: Draw the Hasse diagram representing th e partial ordering {(A, B)| A B} on the power set S ={a ,b, c}. FIGURE 4 The Hasse Diagram of (P({a,b,c}), ). 82 Maximal and Minimal Elements Definition: Let (A, R) be a poset. Then a in A is a minimal element if there does not exist an element b
in A such that bRa. Similarly for a maximal element. Example: In the above Hasse diagram, is a minimal element and {a, b, c} is a maximal element. 83 Maximal and Minimal Elements Example 14: Which elements of the poset ({2, 4, 5, 10 , 12, 20, 25}, |) are maximal, and which are minimal? FIGURE 5 The Hasse Diagram of a Poset. 84
Least and Greatest Elements Definition: Let (A, R) be a poset. Then a in A is the lea st element if for every element b in A, aRb and b is th e greatest element if for every element a in A, aRb . Theorem: Least and greatest elements are unique. Proof: Assume they are not. . . Example: In the poset above {a, b, c} is the greatest element. is the least element. 85 Maximal and Minimal Elements Example 15: Determine whether the posets represented by
each of the Hasse diagrams in Figure 6 have a greatest elem ent and a least element. FIGURE 6 Hasse Diagrams of Four Posets. 86 Upper and Lower Bounds Definition: Let S be a subset of A in the poset (A, R). I f there exists an element a in A such that sRa for all s in S, then a is called an upper bound . Similarly for lower bounds. Note: to be an upper bound you must be related to e very element in the set. Similarly for lower bounds. Example:
In the poset in Example 13, {a, b, c}, is an upper boun d for all other subsets. is a lower bound for all oth er subsets. 87 Upper and Lower Bounds Example 18: Find the lower and upper bounds of the subsets {a, b, c} , {j, h}, and {a, c, d, f} in the poset wit h the Hasse diagram shown in Figure 7. FIGURE 7 The Hasse Diagram of a Poset. 88
Least Upper and Greatest Lower Bounds Definition: If a is an upper bound for S which is relate d to all other upper bounds then it is the least upper bound, denoted lub(S) . Similarly for the greatest low er bound, glb(S) . Example: Consider the element {a} in Example 13. Sin ce {a, b, c}, {a, b} {a, c} and {a} are upper bounds and {a} is related to all of them, {a} must be the lub. It is a lso the glb. 89 Least Upper and Greatest Lower Bounds
Example 19: Find the greatest lower bound and the l east upper bound of {b, d, g}, if they exist, in the pose t shown in Figure 7. FIGURE 7 The Hasse Diagram of a Poset. 90 Lattices Definition: A poset is a l attice if every pair of ele ments has a lub and a gl b. Examples: In the poset
(P(S), ), lub(A, B) = A B. What is the glb(A, B)? Consider the elements 1 and 3. Upper bounds of 1 are 1, 2, 4 a nd 5. Upper bounds of 3 are 3, 2, 4 a nd 5. 2, 4 and 5 are upper bounds fo r the pair 1 and 3. There is no lub since -- 2 is not related to 4 -- 4 is not related to 2
-- 2 and 4 are both related to 5. There is no glb either. The poset is not a lattice. 91 Lattices Example 30: Determine whether the posets represen ted by each of the Hasse diagrams in Figure 8 are latti ces. FIGURE 8 Hasse Diagrams of Three Posets. 92 Topological Sorting
We impose a total ordering R on a poset compatible wi th the partial order. Useful in PERT charts to determine an ordering of tasks . Useful in rendering in graphics to render objects from back to front to obscure hidden surfaces. A painter uses a topological sort when applying paint t o a canvas - he/she paints parts of the scene furthest from the view first. This definition extends naturally to multiple Cartesian p roducts of partially ordered sets: A1 A2 A3 . . . An. 93
Topological Sorting Example: Consider the rectangles T and the relation R = is more distant than. Then R is a partial order o n the set of rectangles. Two rectangles, Ti and Tj , are related, Ti R Tj, if Ti is more distant from the viewer than Tj . 94 Topological Sorting The Hasse diagram for R is Draw 1 (or 8) and delete 1
from the diagram to get Then 1R2, 1R4, 1R3, 4R9, 4R5, 3R2, 3R9, 3R6, 8R7. Now draw 4 (or 3 or 8) and delete from the diagram. Always choose a minimal element. Any one will do. ...and so forth. 95 Topological Sorting Algorithm 1 Topological Sorting procedure Topological Sorting ((S, ) : finite poset) k :=1 while S
begin ak := a minimal element of S { such an element exists by Lemma 1} S := S - {ak } k := k + 1 end {a1, a2, . . ., an is a compatible total ordering of S} 96 Topological Sorting Example 26: Find a compatible total ordering for the poset ({1, 2, 4, 5, 12, 20}, | ). FIGURE 9 A Topological Sort of ({1,2,4,5,12,20}, ). 97
Topological Sorting Example 27 : A developme nt project at a computer co mpany requires the comple tion of seven tasks. Some of these tasks can be started only after other task s are finished. A partial ordering on tasks i s set up by considering task X task Y if task Y cannot b e started until task X has be en completed.
The Hasse diagram for the s even tasks, with respect to t his partial ordering, is show n in Figure 10 . Find an order in which thes e tasks can be carried out to complete the project. FIGURE 10 The Hasse Diagram for Seven Tasks. 98
Topological Sorting FIGURE 11 A Topological Sort of the Tasks. 99
Title Goes Here - United States Department of Housing and ...
HUD-VASH Broadcast February 10, 2009 HUD Presentation Portability Two types of portability in HUD-VASH based on which VAMC that will provide case management. Referring VAMC or a VAMC in another part of the country.