Sets Mukulika Ghosh Fall 2018 Based on slides by Dr. Hyunyoung Lee
Sets Sets A set is an unordered collection of objects, called elements, without duplication. We write a A to denote that a is an element in A. Sets are the most fundamental discrete structure on which all other discrete structures are built. Examples: A = {a, b, c} N = {0, 1, 2,..., 99}, all positive integers below 100 Mukulika Ghosh Parasol Lab - Texas A&M University 2/27
Common Sets Common Sets N = 0, 1, 2, 3,..., set of natural numbers. Z =..., 2, 1, 0, 1, 2,..., set of integers. R set of real numbers, C set of complex numbers. Mukulika Ghosh Parasol Lab - Texas A&M University 3/27
Empty Set Empty Set Empty set does not have any member and is denoted by. Example: Empty directory in file structure. Question: What does { } mean? Mukulika Ghosh Parasol Lab - Texas A&M University 4/27
Set Builder Notation Set Builder Notation The set builder notation describes all elements having certain properties (even they can formed from elements from other sets). Q = {p/q R p Z, q Z, and q 0} [a, b] = {x a <= x <= b, a < b and x, a, b R} [a, b) = {x a <= x < b, a < b and x, a, b R} (a, b] = {x a < x <= b, a < b and x, a, b R} (a, b) = {x a < x < b, a < b and x, a, b R} Mukulika Ghosh Parasol Lab - Texas A&M University 5/27
Equal Sets Equal Sets Two sets (A and B) are considered equal (A = B) if and only if they have the same elements ( x(x A x B). To prove A = B, it is sufficient to show both x(x A x B) and x(x B x A) hold. Mukulika Ghosh Parasol Lab - Texas A&M University 6/27
Subset Subset A set A is a subset of B, written A B, if every element of A is also an element of B ( x(x A x B)). Example: Z R A = {1, 2}, B = {0, 1, 1, 2}, A B Mukulika Ghosh Parasol Lab - Texas A&M University 7/27
Subset Prove that for every set S, we have S. Proof: We have to show that ( x(x x S)) is true. Since the empty set does not contain any elements, the premise is always false; hence, the implication x x S is always true. Therefore, ( x(x x S)) is true; hence, the claim follows. Mukulika Ghosh Parasol Lab - Texas A&M University 8/27
Exercise 1 Exercise 1 Answer the following: 1. Use set builder notation to define the set { 3, 2, 1, 0, 1, 2, 3}. 2. If A = {2, 4, 6}, B = {2, 6}, C = {4, 6} and D = {4, 6, 8}, then determine which of these sets are subsets of which other of these sets. 3. State true/false : { } { }. 4. State true/false : {{ }}. 5. State true/false : If A = B, then A B and B A. Mukulika Ghosh Parasol Lab - Texas A&M University 9/27
Cardinality of Sets Cardinality of Sets Let S be a set with a finite number of elements. We say that the set has cardinality n if and only if S contains n elements. We write S to denote the cardinality of the set. Example: A = {1, 2, 3}, then A = 3. What is the cardinality of ( )? Mukulika Ghosh Parasol Lab - Texas A&M University 10/27
Power Sets Power Sets Given a set S, the power set P (S) of S is the set of all subsets of S. Example: P ({1}) = {, {1}} P ({1, 2}) = {, {1}, {2}, {1, 2}} P ( ) = { } since every set contains the empty set as a subset, even the empty set. P ({ }) = {, { }}. Question: Determine P ({, { }}) Mukulika Ghosh Parasol Lab - Texas A&M University 11/27
Cartesian Product Cartesian Product Let A and B be sets. The cartesian product of A and B, denote A B, is the set of all pairs (a, b) with a A and b B. A B = {(a, b) a A b B} Example: Let A = {1, 2} and B = {a, b}, then A B = {(1, a), (1, b), (2, a), (2, b)}. Question: What is the catersian product of A = {1, 2} and empty set? Mukulika Ghosh Parasol Lab - Texas A&M University 12/27
Exercise 2 Exercise 2 Let A = {a, b, c} and B = {0, 1}. Answer the following: 1. What is cardinality of sets A and B? 2. Determine P (A) and P (B). 3. What is A B? Mukulika Ghosh Parasol Lab - Texas A&M University 13/27
Set Operations Set Operations Let A and B be two sets. The union of Aand B, denoted A B, is the set that contains those elements that are in A or in B, or in both. The intersection of Aand B, denoted A B, is the set that contains those elements that are in both A and B. The difference between A and B, denoted A B or A\B, is the set that contains those elements that are in A but not in B (A B = {x A x / B}). Mukulika Ghosh Parasol Lab - Texas A&M University 14/27
Set Operations Example: A = {1, 2, 3}, B = {2, 4, 6} A B = {1, 2, 3, 4, 6} A B = {2} A B = {1, 3} B A = {4, 6} Mukulika Ghosh Parasol Lab - Texas A&M University 15/27
Set Operations Exercise 3 Let A = {a, b, c, d, e} and B = {a, b, c, d, e, f, g, h}. Find: 1. A B 2. A B 3. A B 4. B A Mukulika Ghosh Parasol Lab - Texas A&M University 16/27
Universe and Complement Universe and Complement A set which has all the elements in the universe of discourse is called a universal set and is denoted by U. The complement of set A, denoted A c or Ā, is given by U A. Example: Let the universal set be set of all letters in English alphabets, and V be set of all vowels. The complement of V ( V ) is set of all consonants. Mukulika Ghosh Parasol Lab - Texas A&M University 17/27
Set Identities Set Identities Let U be universal set. Identity Laws: A U = A, A = A Domination Laws: A U = U, A = Idempotent Laws: A A = A, A A = A Commutative Laws: A B = B A, A B = B A Associative Laws: A (B C) = (A B) C, A (B C) = (A B) C Distributive Laws: A (B C) = (A B) (A C), A (B C) = (A B) (A C) Mukulika Ghosh Parasol Lab - Texas A&M University 18/27
De Morgan s Law De Morgan s Law A B = Ā B A B = {x x / A B} by definition of complement (1) = {x (x A B)} by definition of / (2) = {x (x A x B)} by definition of intersection (3) = {x (x A) (x B)} by De Morgan s law (4) = {x (x / A) (x / B)} by definition of / (5) = {x (x Ā) (x B)} by definition of complement (6) = {x x Ā x B} by definition of union (7) = Ā B by set builder notation (8) Mukulika Ghosh Parasol Lab - Texas A&M University 19/27
Exercise 4 Exercise 4 Simplify the equation using set identity laws if A, B and C are sets (A B) (B C). Mukulika Ghosh Parasol Lab - Texas A&M University 20/27
Generalized Unions and Intersections Generalized Unions and Intersections The union of a collection of sets is the set that contains those elements that are members of at least one set in the collection. nk=1 A k = A 1 A 2... A n The intersection of a collection of sets is the set that contains those elements that are members of all sets in the collection. nk=1 A k = A 1 A 2... A n Mukulika Ghosh Parasol Lab - Texas A&M University 21/27
Generalized Unions and Intersections Example: For i = 1, 2,..., let A i = {i, i + 1, i + 2,...} ni=1 A i = n i=1 {i, i + 1, i + 2,...} = {1, 2, 3,...} ni=1 A i = n i=1 {i, i + 1, i + 2,...} = {n, n + 1, n + 2,...} = A n Mukulika Ghosh Parasol Lab - Texas A&M University 22/27
Exercise 5 Exercise 5 Let A i = {..., 2, 1, 0, 1,..., i}. Find: 1. n i=1 A i 2. n i=1 A i Mukulika Ghosh Parasol Lab - Texas A&M University 23/27
Computer Representation of Sets Computer Representation of Sets Suppose that the universal set U is small. Order the elements of U, say a 1, a 2,..., a n. Represent a subset A of U by a bit string of length n. The k-th bit is equal to 1 if and only if a k is contained in A. Mukulika Ghosh Parasol Lab - Texas A&M University 24/27
Computer Representation of Sets Example: Let U = {1, 2, 3, 4, 5, 6} be the universal set. 1 6 Represent the subset A = {1, 2} by a bit string of length 6. 1 1 0 0 0 0 1 6 Mukulika Ghosh Parasol Lab - Texas A&M University 25/27
Computer Representation of Sets Operations Let A and B be sets represented by the bit strings a and b, respectively. Ā is represented by negating the bits of a. The A B is represented by (a k b k ) k=1..n The A B is represented by (a k b k ) k=1..n Mukulika Ghosh Parasol Lab - Texas A&M University 26/27
Computer Representation of Sets Usage The bit string representation of sets is particularly efficient if the size of the universal set can be represented with a few machine words. If many set operations beside union, intersection, and complement are needed, then this representation might not be such a good choice. Mukulika Ghosh Parasol Lab - Texas A&M University 27/27