150 likes | 407 Views
Discussion #27 Closures & Equivalence Relations. Topics. Reflexive closure Symmetric closure Transitive closure Equivalence relations Partitions. Closure. Closure means adding something until done. Normally adding as little as possible until some condition is satisfied
E N D
Topics • Reflexive closure • Symmetric closure • Transitive closure • Equivalence relations • Partitions
Closure Closure means adding something until done. • Normally adding as little as possible until some condition is satisfied • Least fixed point similarities
1 2 3 1 2 3 1 1 0 0 1 0 1 1 0 1 1 0 0 1 2 2 1 1 1 1 1 1 3 3 Reflexive Closure Reflexive closure of a relation: R(r) • smallest reflexive relation that contains R (i.e. fewest pairs added) • R(r) = R IA (R is a relation on a set A, and IA is the identity relation 1’s on the diagonal and 0’s elsewhere.) R(r) = R = x (xRx)
1 2 3 1 2 3 1 2 3 0 0 1 0 1 0 0 1 1 1 1 1 1 0 1 0 0 1 1 0 1 2 2 2 0 1 1 1 1 1 1 1 1 3 3 3 Symmetric Closure Symmetric closure of a relation: R(s) • smallest symmetric relation that contains R (i.e. fewest pairs added) • R(s) = R R~ (R~ is R inverse) R~ = R = R R~ = xy(xRy yRx)
Transitive Closure Transitive closure of a relation: R(t) = R+ • smallest transitive relation that contains R (i.e. fewest pairs added) • for each path of length i, there must be a direct path. (This follows from xy, yz xz; since, if we also have vx, we must have vz, a path of length 3.) • R(t) = R R2 R3 … R|A|. (No path can be longer than |A|, the number of elements in A.)
1 2 3 0 1 0 1 0 0 1 2 1 1 1 3 1 2 3 0 0 1 1 1 1 1 2 1 1 1 3 1 1 2 2 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 3 3 Transitive Closure – Example 1 1 All paths of length 1 R = 2 3 1 All paths of length 2 R2 = 2 3 1 All paths of length 3 R×R2 = R3 = 2 3 RR2R3 =
1 2 3 1 0 0 0 2 0 0 1 3 0 1 0 1 2 3 1 0 0 0 2 0 1 0 3 0 0 1 1 2 3 1 0 0 0 2 0 0 1 3 0 1 0 1 2 3 1 0 0 0 2 0 1 1 3 0 1 1 Transitive Closure – Example 2 1 R = All paths of length 1 2 3 1 R2 = All paths of length 2 2 3 1 R×R2 = R3 = All paths of length 3 2 3 1 RR2R3 = Paths of any length 2 3
1 2 3 1 2 3 1 0 0 0 1 1 0 0 2 0 1 1 2 0 1 0 3 0 1 1 3 0 0 1 1 2 3 1 1 0 0 2 0 1 1 3 0 1 1 Reflexive Transitive Closure • Reflexive transitive closure of a relation: R* • smallest reflexive and transitive relation that contains R • R* = IA R+ = R0 R+ = R0 R1 R2 …R|A| • Example: IA = R0 = R1 R2 R3 = 1 R0 R1 R2 R3 = 2 3
Equivalence Relations A relation R on a set A is an equivalence relation if R is reflexive, symmetric, and transitive. • Equivalence relations are about “equivalence” • Examples: • = for integers x = x reflexive x = y y = x symmetric x=y y=z x=z transitive • = for sets A = A reflexive A = B B = A symmetric A=B B=C A=C transitive • Let R be “has same major as” for college students xRx reflexive: same major as self xRy yRx symmetric: same major as each other xRy yRz xRz transitive: same as, same as same as
Partitions • A partition of a set S is • a set of subsets Si=1,2,…n of S • such that ni=1 Si = S, Sj Sk = for j k. • Each Si is called a block (also called an equivalence class) • Example: • Suppose we form teams (e.g. for a doubles tennis tournament) from the set: {Abe, Kay, Jim, Nan, Pat, Zed} then teams could be: { {Abe, Nan}, {Kay, Jim}, {Pat, Zed} } • Note: “on same team as” is reflexive, symmetric, transitive an equivalence relation. Equivalence relations and partitions are the same thing (two sides of the same coin).
Partitions (continued…) • Since individual elements can only appear in one block (Sj Sk = for j k), blocks can be represented by any element within the block. e.g. Nan’s Team Jimmer’s 2011 sweet-16 team • Formally, [x] = set of all elements related to x and y [x] iff xRy e.g. [Nan] represents {Abe, Nan}, Nan’s team [Abe] represents {Abe, Nan}, Abe’s team [Jimmer] represents the set of players who played on BYU’s 2011 sweet-16 team
Partitions & Equivalence Relations Example: • The mod function partitions the natural numbers into equivalence classes. • 0 mod 3 = 0 so 0 forms a class [0] • 1 mod 3 = 1 so 1 forms new class [1] • 2 mod 3 = 2 so 2 forms new class [2] • 3 mod 3 = 0 so 3 belongs to [0] • 4 mod 3 = 1 so 4 belongs to [1] • 5 mod 3 = 2 so 5 belongs to [2] • 6 mod 3 = 0 so 6 belongs to [0] • … • Thus, the mod function partitions the natural numbers into equivalence classes. • [0] = {0, 3, 6, …} • [1] = {1, 4, 7,…} • [2] = {2, 5, 8, …}
Partitions Equivalence Relations Theorem: If {S1, …, Sn} is a partition of S, then R:SS is an equivalence relation, where R is “in same block as.” Note: to prove that R is an equivalence relation, we must prove that R is reflexive, symmetric, and transitive. Proof: Reflexive: since every element is in the same block as itself. Symmetric: since if x is in the same block as y, y is in the same block as x. Transitive: since if x and y are in the same block and y and z are in the same block, x and z are in the same block.
Equivalence Relations Partitions Theorem: If R:SS is an equivalence relation and [x] = { y | xRy }, then { [x] | x S } is a partition P of S. Note: to prove that we have a partition, we must prove (1) that every element of S is in a block of P, and (2) that for every pair of distinct blocks Sj and Sk (jk) of P, Sj Sk = . Proof: (1) Since R is reflexive, xRx, every element of S is at least in its own block and thus in some block of P. (2) Suppose Sj Sk for distinct blocks Sj and Sk of P. Then, at least one element y is in both Sj and Sk. Let Sj = {y, x1, … xn} and Sk = {y, z1, … zm}, then yRxi, i=1, 2, …, n, and yRzp, p=1, 2, …, m. Since R is symmetric, xiRy, and since R is transitive xiRzp. But now, since the elements of Sj are R-related to the elements of Sk, x1, …, xn, y, z1, …, zm are together in a block of P and thus Si and Sk are not distinct blocks of P.