Sets, Relations, and Lattices 1 Zvi Kohavi and Niraj K. Jha Sets Set: collection of distinct objects Example: attendees in this class; prime numbers Objects: elements, or members, of the set Set with no elements: empty, or null, set Set of all even numbers between 1 and 10: {2,4,6,8,10} Infinite set of all positive, even numbers: {2,4,6, …} Readers of the Kohavi-Jha book living in Antarctica: most likely empty 2 Set Definitions Universe U: set of all possible outcomes Example: Rolling a die • U = {f1, f2, f3, f4, f5, f6} U has 26 = 64 subsets • Null, {f1}, …, {f6}, {f1,f2}, …, {f5,f6}, {f1,f2,f3}, …, U A=B: A and B are identical A B: A is a subset of B A B: A is a proper subset of B A+B: union of A and B AB: intersection of A and B A’: complement of A 3 Venn Diagrams A A B A A B (b) A + B. (a) AB. A (d) AB = B (c) A . B A . (e) A B. 4 Ordered Pair Ordered pair (a,b): specific order associated with a and b • a: first coordinate • b: second coordinate Example: mother and daughter; teacher and student Example: {(a,a), (a,b), (b,a), (b,c), (c,a)} a c b Generalization: Ordered n-tuple (a1, a2, …, an) 5 Binary Relation Binary relation R: set of ordered pairs (a,b) a R b: a is related to b by R Cartesian product AxB: set of ordered pairs (a,b) s.t. a is in A and b is in B Example: If A = {p,q} and B = {r,s,t}, then AxB = {(p,r), (p,s), (p,t), (q,r), (q,s), (q,t)} Relation from set A to A: relation in A – subset of AxA or A2 Relation R in set A is • Reflexive if it contains (a,a) for every a in A • Symmetric if existence of (a,b) in R implies the existence of (b,a) • Transitive if existence of (b,a) and (a,c) in R implies existence of (b,c) 6 Properties of Relations Relation R in set A is • Reflexive if it contains (a,a) for every a in A • Symmetric if existence of (a,b) in R implies the existence of (b,a) • Transitive if existence of (b,a) and (a,c) in R implies existence of (b,c) Example: Relation {(a,a), (b,b), (a,b)} – reflexive and transitive, but not symmetric Example: Relation {(a,b), (b,a)} – symmetric, but not transitive since it does not contain (a,a) Binary relation R in set S: equivalence relation if it is reflexive, symmetric and transitive Example: Relation = is an equivalence relation since it satisfies for all a, b, and c in R • Reflexive: a = a • Symmetric: If a = b, then b = a • Transitive: If a = b and b = c, then a = c 7 Equivalence Classes Equivalence relation: partitions elements of a set into disjoint subsets s.t. all members of a subset are equivalent and members of different subsets are not equivalent Disjoint subsets: equivalence classes Example: Relation of parallelism between lines in a plane a b e d c f R = {(a,a), (b,b), (c,c), (d,d), (e,e), (f,f), (a,b), (b,a), (a,c), (c,a), (b,c), (c,b), (d,e), (e,d)} Equivalence classes: {a,b,c}, {d,e}, {f} 8 Compatibility Relation Compatibility relation: relation that is reflexive and symmetric, but not transitive • Nontransitivity nondisjoint subsets • Subsets: compatibility classes Partition: Partition on set S: collection of disjoint subsets with set union S • Disjoint subsets: blocks of partition • Uniform partition: each block contains the same no. of elements Example: Equivalence relation for parallel lines induces partition {a,b,c; d,e; f} Function: set of ordered pairs in which no two pairs have same first coordinate Example: If A = {a,b,c} and B = {d,e} • {(a,d), (b,e), (c,d)} is a function from A to B • {(a,d), (b,e), (c,d), (c,e)} is not 9 Partially Ordered Sets Partial ordering: reflexive, antisymmetric and transitive binary relation Example: For S = {a,b,c}, partial ordering satisfies • Reflexive: a a • Symmetric: a b and b a imply a=b • Transitive: if a b and b c, then a c Partition 1 on S “smaller than or equal to” than 2 on S, denoted 1 2 • if each pair of elements in a common block of 1 is also in a common block of 2 • two partitions incomparable if neither is smaller than or equal to the other Example: Consider S and its three partitions: S = {a,b,c,d,e,f,g,h,i} 1 = {a,b; c,d; e,f; g,h,i} 2 = {a,f; b,c; d,e; g,h; i} 3 = {a,b,e,f; c,d; g,h,i} 1 3 , but 1 and 2 are incomparable, as are 2 and 3 10 Totally Ordered Sets Total ordering: if for every pair a,b in S, either a b or b a , then S is totally ordered by binaryrelation Example: Set of all prime numbers is totally ordered by Displaying the ordering relation with a Hasse diagram Example: Partial ordering displaying divisibility relation among all positive divisors of 45, such that the quotient is an integer 45 15 9 5 3 1 Hasse diagram 11 Least/Greatest Member of a Set Least member: if a b for every b in S, then a is called the least member of S • When least member exists, it is unique Example: When the set does not have a least member, define minimal member a b Maximal members c d e f Minimal members Greatest member: if b a for every b in S, then a is called the greatest member of S • When greatest member exists, it is unique • When greatest member does not exist, define maximal member 12 Lower/Upper Bound of a Subset of Set S Upper bound: Let S be partially ordered and P be a subset of S, then an element s in S is an upper bound of P if and only if, for every p in P, ps • s is not necessarily a member of P Least upper bound (lub): smallest of all upper bounds Lower bound: Element s in S is an lower bound of P if and only if, for every p in P, s p Greatest lower bound (glb): largest of all lower bounds Example: S = {1,3,5,9,15,45} and P = {3,5} • Upper bounds: 15, 45 • lub: 15 • glb = 1 13 Lattice Lattice: partially ordered set in which every pair of elements has a unique glb and a unique lub • Least element: denoted as 0 • Greatest element: denoted as 1 • For each element a of lattice: a 1 and 0 a Example: a b Maximal members 45 15 c 9 5 d 3 1 e Lattice f Minimal members Not a lattice 14 Lattice (Contd.) Example: Lattice of all subsets of set S = {a,b,c}, under the ordering relation of set inclusion, where {a,b,c} = 1 and = 0 {a,b,c} {a,b} {b} {b,c} {a} {a,c} {c} 15 Binary Operation Because of their uniqueness, lub and glb may be viewed as binary operations • Sum a+b = lub(a,b) • Product a.b = glb(a,b) lub and glb satisfy: • Idempotency: a.a = a+a = a • Commutativity: a.b = b.a and a+b = b+a • Absorption: a+a.b = a and a.(a+b) = a • Associativity: a.(b.c) = (a.b).c and a+(b+c) = (a+b)+c Following properties valid for every finite lattice: • a+0 = a • a.0 = 0 • a.1 = a • a+1 = 1 16 Partially Ordered Set Whose Elements are Partitions Example: Let 1 = {a,b; c,d,e; f,h; g,i} and 2 = {a,b,c; d,e; f,g; h,i} 1 2 = {a,b,c,d,e; f,g,h,i} 1. 2 = {a,b; c; d,e; f; g; h; i} (I ) = {a,b,c,d,e,f,g,h,i}: greatest partition with just one block (0) = {a;b;c;d;e;f;g;h;i}: least partition with single-element blocks 17 Distributive Law Not Necessarily Valid Lattice is distributive if and only if • a.(b+c) = a.b+a.c • a+(b.c) = (a+b)(a+c) Example: Consider 0 = {a;b;c} = (0) 1 = {a,b;c} 2 = {a;b,c} 3 = {a,c;b} 4 = {a,b,c} = (I ) (I) 4= 2 1 0= 3 (0) Product 1.( 2 3) 1, but 1. 2 1. 3 0, hence lattice not distributive 18 Complemented Lattice Lattice is said to be complemented, if for each element a, there exist a’ s.t. • a.a’ = 0 • a+a’ = 1 • a’ is the complement of a and vice versa Example: {a,b,c} {a,b} {b} {b,c} {a} {a,c} {c} Distributed and complemented lattice 19