Sets and set operations Lecture 5 ICOM 4075 Reviewing sets As defined in a previous lecture, a set is a collection of objects that constitute the elements of the set – We say that a set contains its elements, and that an element belongs to its set If S is a set and x an element in S, we write – xЄS Examples of sets 1. The set of integers: {…, -3, -2, -1, 0, 1, 2, 3, …} 2. The set of the vowels in the Latin alphabet: {a, e, i, o, u} 3. The set of all real solutions of the equation x⁴ + y⁴ = 1 4. The set of 6 foot tall people 5. The set with no elements: this is the so-called empty set, and is denoted by φ Describing sets a) By listing: this is, providing a list (sometimes partial list or mere pattern of formation) of the elements Example: Integers = {…, -3, -2 , -2, 0, 1, 2, 3,…} b) By property: this is, by providing a logical statement (property) that characterizes membership in the set. In this case, an element x is in the set if the statement is true for x and it is not if the statement Property = logical statement is false – Example: A = {x : x is an integer and x⁴ + 1 is even} 1ЄA, since 1⁴+1 = 2; 3ЄA since 3⁴+1=82; etc… Equality of sets Definition: Two sets are equal if they have the same elements. If S and R are sets and they are equal, then we write S = R Examples: –{1, 2, 3} = {3, 1, 2} –{a, b, a} = {a, b} –{a, c} ≠ {a} Implications of equality As illustrated in the previous examples, (as a consequence of the definition of equality between sets) we have that in sets: –Repeated elements do not count (repetitions are ignored) –There is no particular order of the elements in a set Finite and infinite sets A set is finite if it has a finite number of elements or if it is the empty set. Otherwise, the set is said to be infinite Examples: – The set of vowels in the Latin alphabet is finite since it has only 5 elements – The set of people 20 foot tall is finite since it is empty – The set of integers is infinite Subsets Definition: If A and B are sets and every element in A is also an element in B, we say that A is a subset of B. If A is a subset of B we write: A⊂B Remark: The empty set is a subset of any set The power set Definition: The power set of a set A is the set of all subsets of A (includes the empty set and the set itself). The power set of A is denoted by pow(A) Example: Let A = {1, 2, 3}. The subsets of A are: φ, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, and A itself. Thus, pow( A ) = {φ, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, A} Proof strategies with subsets and equalities Following are useful strategies for proving logical statements asserting that two sets are equal or that one set is a subset of another set: Statement to prove Strategy A is a subset of B For arbitrary x in A, show that x is also in B A is not a subset of B Find an element in A that is not an element in B A equals B Show that A is a subset of B and B is a subset of A A is not equal to B Find an element in A that is not in B or an element in B that is not in A Example 1 Prove that A is subset of B where A = {x : x = 1 / (3n + 6), for some natural n} B = {x : x = 1 / n, for some natural n} Proof: If x is an element in A, then there is a natural number q such that x = 1 / (3q + 6). A generic element in A So, x = 1 / 3(q + 2) or what is the same Just a bit of x = 1 / 3k, where k = q + 2 is a natural number. algebra Therefore, x = 1 / n with n = 3k, a natural number. Conclusion: x is in B. The generic element in A satisfies the condition of membership in B Example 2 Let A = {x : x = 3k + 4, k integer} and B = {x : x = 5k + 6, k integer}. Is A subset of B or B subset of A? Answer: Neither A is subset of B nor B is subset of A. Proof: 7 is in A, since 3∙1+4 = 7. But, 7 is not in B since 7 =5k+6 implies k = 1/5 which is not integer. So, A is not a subset of B. Reciprocally, 11 is in B since 5∙1+6 = 11. But, 11 is not in A since 11 = 3k+4 implies k = 7/3 which is not integer. So, B is not a subset of A. Example 3 Let A = {x : x is prime and 12 ≤ x ≤ 18} and B = {x : x = 4 ∙ k + 1 and k = 3 or k = 4} Prove that A = B. Proof: First prove that A is a subset of B: Note that A = {13, 17} since these are the primes that satisfy the property. But, 13 = 4 ∙ 3 + 1 and 17 = 4 ∙ 4 + 1. Therefore, 13 is in B and 17 is in B. Reciprocally, if k = 3, 4 ∙ k + 1 = 4 ∙ 3 + 1 = 13. Now, 13 is prime and 12 ≤ 13 ≤ 18. So, 13 is in A. Also, if k = 4, 4 ∙ k + 1 = 4 ∙ 4 + 1 = 17. But, 17 is prime and 12 ≤ 17 ≤ 18. So, 17 is in A Set operations The main set operations are Union of sets Intersection of sets Complement of a set The union of two sets Definition: given two sets A and B, their union is the set A U B defined as A U B = {x: x in A or x in B} Example 1: Let A = {a, b, c, d} and B = {a, e, f}. Then, A U B = {a, b, c, d, e, f} Example 2: Let A be the even numbers and B be the odd numbers. Then, A U B is the set of natural numbers Properties of union 1. A ∪φ = A 2. A ∪ B = B ∪ A 3. A ∪ (B ∪ C) = (A ∪ B) ∪ C 4. A ∪ A = A 5. A ⊆ B if andonlyif A ∪ B = B Proving some of these properties These properties (as any other property) are logical statements about sets and operations. This is, they are ultimately mathematical statements. We’ll prove a one of them. Let’s take for example, properties 5. Proof of property 3 Remark: Note that property is and if and only if statement, and therefore, there are two implications involved. These are: (a) If A ⊆ B then A ∪ B = B (b) If A ∪ B = B then A ⊆ B Proof of (a): The thesis is a equality of sets. We’ll prove it by proving that: A ∪ B ⊆ B, and B ⊆ A∪B Proof of (a) (continuation) If x ∈ A ∪ B, then x ∈ A or x ∈ B. Since by hypothesis A ⊆ B, we have that if x ∈ A, then x ∈ B. Therefore, if x ∈ A ∪ B, then x ∈ B. This is, A ∪ B ⊆ B. Reciprocally, if x ∈ B then x ∈ B or x ∈ A; therefore, B ⊆ A ∪ B. So, A ∪ B = B. Proof of (b) The implication is now : If A ∪ B = B then, A ⊆ B. We use the contrapositive : If A ⊄ B then A ∪ B ≠ B. Proof of the contrapositive : If A ⊄ B, then there is an element x∈ A such that x ∉ B. But then, x ∈ A ∪ B but x ∉ B. Therefore A ∪ B and B do not have the same elements. This is, A ∪ B ≠ B. Infinite unions Definition: Let A₁, A₂, A₃,… be an infinite collection of sets. Their union is define as the ∞ set: U A i = {x : x ∈ A i , for some i ≥ 1} i =1 Example: Let A i = {−2i, 2i}, i = 1,2,3,... Thus, A1 = {−2, 2}; A 2 = {−4, 4}; A 3 = {−6, 6}, etc... ∞ Now, U A i = {...,-10, - 8, - 6, - 4, - 2, 2, 4, 6, 8, 10, ...} i =1 Intersections Definition: The intersection of two sets A and B is defined to be the set A ∩ B = {x : x ∈ A and x ∈ B} Example: Let A = {n : n is integer and n = 3k + 7 for some integer k} and let B = {m : m is integer and m = 4k + 5 for some integer k} Then A ∩ B = {n : n = 3k + 7 = 4k + 5, for some integer k} Is there a solution? Yes! Pick k = 2. Then 3k + 7 = 13 = 4k + 5. Therefore, A ∩ B = {13}. Properties of the intersection of two sets 1. A ∩ φ = φ 2. A ∩ B = B ∩ A 3. (A ∩ B) ∩ C = A ∩ (B ∩ C) 4. A ∩ A = A 5. A ⊆ B if and only if A ∩ B = A Further examples 1. Let A = {x : x is integer and x = 20 for some integer k} k and let B the set of all integers. Then A ∩ B = {-20, - 10, - 5, - 4, - 2, 2, 4, 5, 10, 20} 2. Let A = {y : y = (x - 1) 2 + 2 for some real number x} and let B = {z : z = -2x + 3 for some real number x}. Then, A ∩ B = {3} since if y = z then (x - 1) 2 + 2 = −2x + 3 x 2 − 2x + 1 + 2 = -2x + 3 x 2 + 3 = 3. This is, x = 0. By replacing in both equations : y = z = 3. Infinite intersections Definition : The intersection of an infinite collection A1 , A 2 , A 3 ,... of sets is defined to be the set : ∞ IA i = {x : x is an element of A i for all i} i =1 Example : Let A i = {x : x is integer and - i ≤ x ≤ i} where i is a positive even number. Then, ∞ IA i=2 i = {−2, 0, 2} Complement of a set Definition: The complement of a set always refer to sets that are subsets of a particular set U, called universe, universal set or “universe of discourse”. Thus, if A ⊆ U, the complement of A, denoted A' , is defined to be the set A' = {x ∈ U : x ∉ A} Example Let A be the set of odd numbers. If U is chosen to be the set of naturals, then A’={ 0, 2, 4, 6, … }, this is, the set of all even numbers But if U is chosen to be the set of all real numbers, then A’={x: x real and x ≠ 2n+1 for any n natural} Operational properties: Combining union and intersection 1. A ∩ ( B ∪ C) = (A ∩ B) ∪ (A ∩ C) 2. A ∪ ( B ∩ C) = (A ∪ B) ∩ (A ∪ C) Illustration of 1. : Let A = {1, 2, 3}, B = {a, b, 2, 3} and C = {1, 2, b, c}. Then, A ∩ (B ∪ C) = {1, 2, 3}∩ ({a, b, 2, 3} ∪ {1, 2, b, c}) = {1, 2, 3} ∩ {a, b, c,1, 2, 3} = {1, 2, 3} (A ∩ B) ∪ (A ∩ C) = ({1, 2, 3}∩{a, b, 2, 3}) ∪ ({1, 2, 3}∩{1, 2, b, c}) = {2, 3}∪{1, 2} = {1, 2, 3} Properties of complement 1. (A' )' = A 2. φ ' = U and U' = φ 3. A ∩ A' = φ and A ∪ A' = U 4. A ⊆ B if and only if B' ⊆ A' 5. (A ∪ B)' = A' ∩ B' 6. (A ∩ B)' = A' ∪ B' De Morgan’s LAWS Illustration of De Morgan’s laws Let A = {a, o, 3, 7}, B = {a, e, i, o, 1, 3, 5, 7} with universe U = {a, e, i, o, u, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. Then, (A ∪ B)' = {a, e, i, o, 1, 3, 5, 7}' = {u, 0, 2, 4, 6, 8, 9} A' ∩ B' = {e, i, u, 0, 1, 2, 4, 5, 6, 8, 9} ∩ {u, 0, 2, 4, 6, 8, 9} = {u, 0, 2, 4, 6, 8, 9} Summary • • • • • • • Notion of set, set descriptions Set equality and its implications Finite sets and infinite sets Subsets, power set Proof strategies with subsets and set equalities Operations with sets: definitions and properties Properties of combined operations Exercises 1. Describe each of the following sets in terms of a property 1. A = {1, 5, 9, 13,…} 2. B = {…, -8, -5, -2, 1, 4, 7, … } 3. C = {1, 2, 5, 10, 17,…,82} 2. Write down the power set for each of the following sets 1. A = pow({a, b}) 2. A = {a, {a, b}, φ} 3. A = {φ, {φ}} Exercises (cont.) 3. Is it true that power(A∪ B) = power(A)∪ power(B) ? {x : x is integer and x < -i or x > i}, if i is even 4. Let Ai = {x : x is integer and - i < x < i}, if i is odd 1. Find the union of the collection{Ai : i natural} 2. Find the intersection of the collection{Ai : i natural} 3. Find the union of the collection{Ai : i = 1, 2, 3, 4, 5} 4. Find the intersection of the collection{Ai : i = 1,3,5,7}