CSE115/ENGR160 Discrete Mathematics 02/14/12 Ming-Hsuan Yang UC Merced 1 2.2 Set operations • Union: the set that contains those elements that are either in A or in B, or in both A B {x | x A x B} • A={1,3,5}, B={1,2,3}, A⋃B={1,2,3,5} 2 Intersection • Intersection: the set containing the elements in both A and B A B {x | x A x B} • A={1,3,5}, B={1,2,3}, A⋂B={1,3} 3 Disjoint set • Two sets are disjoint if their intersection is ∅ • A={1,3}, B={2,4}, A and B are disjoint • Cardinality: | A B || A | | B | | A B | 4 Difference and complement • A-B: the set containing those elements in A but not in B A B {x | x A x B} • A={1,3,5},B={1,2,3}, A-B={5} 5 Complement • Once the universal set U is specified, the complement of a set can be defined • Complement of A: A {x | x A}, A U A • A-B is also called the complement of B with respect to A 6 Example • A is the set of positive integers > 10 and the universal set is the set of all positive integers, then A {x | x 10} {1,2,3,4,5,6,7,8,9,10} • A-B is also called the complement of B with respect to A 7 Set identities 8 Example • Prove A B A B • Will show that A B A B and A B A B • (→): Suppose that x A B , by definition of complement and use De Morgan’s law ( x A x B) (( x A)) (( x B)) ( x A) ( x B) • By definition of complement x A or x B • By definition of union x A B 9 Example • • • • • (←): Suppose that x A B By definition of union x A x B By definition of complement x A x B Thus ( x A) ( x B) By De Morgan’s law: ( x A) ( x B) ( x A x B) ( x ( A B)) • By definition of complement, x A B 10 Builder notation • Prove it with builder notation A B {x | x A B} (def of complement) {x | ( x ( A B))} (def of not belong t o) {x | ( x A x B)} (def of int ersecton) i {x | ( x A) ( x B )} (De Morgan's law) {x | x A x B} (def of not belong t o) {x | x A x B} (def of complement) {x | x A B} (def of union) A B 11 Example • Prove A ( B C ) ( A B) ( A C ) • (→): Suppose that x A ( B C ) then x A and x B C . By definition of union, it follows that x A , and x B or x C . Consequently, x A and x B or x A and x C • By definition of intersection, it follows x A B or x A C • By definition of union, x ( A B) ( A C ) 12 Example • (←): Suppose that x ( A B) ( A C ) • By definition of union, x A B or x A C • By definition of intersection, x A and x B , or x A and x C • From this, we see x A , and x B or x C • By definition of union, x A and x B C • By definition of intersection, x A ( B C ) 13 Membership table 14 Example • Show that A (B C) (C B) A A ( B C ) A B C (De Morgan's law) A ( B C ) (De Morgan's law) ( B C ) A (commutati ve law) (C B) A (commutati ve law) 15 Generalized union and intersection • A={0,2,4,6,8}, B={0,1,2,3,4}, C={0,3,6,9} • A⋃B⋃C={0,1,2,3,4,6,8,9} • A⋂B⋂C={0} 16 General case • • • • • n Union: A A A A Intersection A A A A Union: A A A A Intersection: A A A A Suppose Ai={1, 2, 3,…, i} for i=1,2,3,… 1 2 n 1 i i 1 n 2 n i 1 1 2 n 1 i 1 i 1 i i 1 2 i n i 1 i A { 1 , 2 , 3 , , i } { 1 , 2 , 3 , } Z i A {1,2,3,, i} {1} i 1 i i 1 17 Computer representation of sets • U={1,2,3,4,5,6,7,8,9,10} • A={1,3,5,7,9} (odd integer ≤10),B={1,2,3,4,5} (integer ≤5) • Represent A and B as 1010101010, and 1111100000 • Complement of A: 0101010101 • A⋂B: 1010101010˄1111100000=1010100000 which corresponds to {1,3,5} 18