Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 Basic Structure : Sets, Functions, Sequences, and Sums Sets Operations
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 22 Union Let A and B be sets. The union of the sets A and B, denoted by A B, is the set that contains those elements that are either in A or in B, or in both. A B is shaded.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 33 Union An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongs to B. This tells us that A B = {x | x A x B} Example : The Union of the sets {1,3,5} and {1,2,3} is {1,2,3,5}
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 44 Intersection Let A and B be sets. The intersection of the sets A and B, denoted by A B, is the set containing those elements in both A and B. A B is shaded
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 55 Intersection An element x belongs to the intersection of the sets A and B if and only if x belongs to A and x belongs to B. This tells us that A B = {x | x A x B} Example : The Union of the sets {1,3,5} and {1,2,3} is {1,3}
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 66 Disjoint Two sets are called disjoint if their intersection is the empty set. Example A= { 1,3,5,7,9} B={2,4,6,8,10} A B= Cardinality of a union of two finite sets |A B| = |A| + |B| − |A B|. This called principle of inclusion -exclusion
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 77 Difference Let A and B be sets. The difference of A and B, denoted by A−B, is the set containing those elements that are in A but not in B. The difference of A and B is also called the complement of B with respect to A. A – B is shaded
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 88 Difference An element x belongs to the difference of A and B if and only if x A and x B. This tells us that A − B = {x | x A x B} Example : The difference of the sets {1,3,5} and {1,2,3} is A − B = {5} B − A = {2}
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 99 Complement Once the universal set U has been specified, the complement of a set can be defined. Let U be the universal set. The complement of the set A, denoted by Ā, is the complement of A with respect to U. In other words, the complement of the set A is U−A. Ā is shaded.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 10 Complement An element belongs to Ā if and only if x A. This tells us that Ā = {x | x A} Example : Let A be the set of positive integers grater than 10 Ā={1,2,3,4,5,6,7,8,9}
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 Exercise Let A = {1, 2, 3, 4, 5}, B = {0, 3, 6} and U={x| x Z + x<10}. Draw the Venn diagram for the following sets: Ā A B A B A − B B − A
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 12 Set Identities NameIdentity Identity laws A = AU=AAU=A Domination laws AU=UAU=UA = Idempotent laws AA=AAA=AAA=AAA=A Commutative laws AB=BAAB=BAAB=BAAB=BA A Absorption laws A (A B)=AA (A B)=A Complement laws A Ā = AĀ=UAĀ=U Complementation law (Ā) = A De Morgan’s laws A B= Ā BA B= Ā B
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 13 Set Identities 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)
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 14 Set Identities Methods to prove set identity We will prove several of these identities by different approaches to the solution of a problem. The rest will be left as exercise. One way to show that two sets are equal is to show that each is a subset of the other.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 15 Exercise Prove A B = Ā B We have to show that A B Ā B and Ā B A B Set identities can also be proved using set builder notation and logical equivalences. We can use Builder notation and logical equivalences to establish A B = Ā B
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 16 Set Identities Methods to prove set identity Set identities can also be proved using membership tables. We consider each combination of sets that an element can belong to, and verify that elements in the same combinations of sets belong to both the sets in the identity. To indicate that an element is in a set, a 1 is used; to indicate that an element is not in a set, a 0 is used. Note that: there is a similarity between membership tables and truth tables.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 17 Exercise Use member ship table to show that A (B C)= (A B) (A C) (A B) (A C) ACA CACA C ABA BABA B A(BC) A (B C) BCB CBCB C A B C
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 18 Exercise Prove A (B C) = (C B) A = A (B C) by first De Morgan law = A (B C) by the second De Morgan law = (B C) A by the commutative law of intersection = (C B) A by the commutative law of unions
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 19 Generalization Union and Intersection The Union of collection of sets is the set that contains those elements that are member of at least one set in the collection. A1 A2 … An = n Ai i =1 Let Ai= { i, i+1, i+2, ….} n Ai = { i, i+1, i+2, ….} = {1,2,3,…} i =1
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 20 Generalization Union and Intersection The intersection of collection of sets is the set that contains those elements that are member of all the sets in the collection. A1 A2 … An = n Ai i =1 Let Ai= { i, i+1, i+2, ….} n Ai = { i, i+1, i+2, ….} = {n,n+1,n+2,…} i =1
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 21 Generalization Union and Intersection Example : Suppose Ai={1,2,3,….,i} for i=1,2,3,… ф Ai = {1,2,3,…}=Z+ i =1 ф Ai = {1} i =1
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 22 Computer Representation of Sets One method is to store the elements of the set in an unordered fashion. However, if this were done, the operations of computing the union, intersection, or difference of two sets would be time-consuming, because each of these operations would require a large amount of searching for elements. We will present a method for storing elements using an arbitrary ordering of the elements of the universal set. This method of representing sets makes computing combinations of sets easy.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 23 Computer Representation of Sets Assume that the universal set U is finite (and of reasonable size so that the number of elements of U is not larger than the memory size of the computer being used). First, specify an arbitrary ordering of the elements of U, for instance a 1, a 2,..., a n. Represent a subset A of U with the bit string of length n, where the i th bit in this string is 1 if a i belongs to A and is 0 if a i does not belong to A.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 24 Computer Representation of Sets Example Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and the ordering of elements of U has the elements in increasing order; that is, ai = i. What bit strings represent the subset of all odd integers in U, the subset of all even integers in U, and the subset of integers not exceeding 5 in U? The set of all odd integers in U is {1, 3, 5, 7, 9}, The bit string is The set of all even integers in U is {2, 4, 6, 8, 10}, The bit string is The set of integers not exceeding 5 in U is {1, 2, 3, 4, 5}, The bit string is
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 25 Computer Representation of Sets Example (complement) The bit string for the set {1, 3, 5, 7, 9} is , with universal set {1, 2, 3, 4,5, 6, 7, 8, 9, 10} What is the bit string for the complement of this set? The bit string for the complement of this set is obtained by replacing 0s with 1s and vice versa. This yields the string , which corresponds to the set {2, 4, 6, 8, 10}.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 26 Computer Representation of Sets Example (union and intersection) The bit strings for the sets {1, 2, 3, 4, 5} is {1, 3, 5, 7, 9} is , Use bit strings to find the union and intersection of these sets. The bit string for the union of these sets is = Which corresponds to the set {1, 2, 3, 4, 5, 7, 9}. The bit string for the intersection of these sets is = Which corresponds to the set {1, 3, 5}.