Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.

Slides:



Advertisements
Similar presentations
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Advertisements

Discrete Structures & Algorithms Basics of Set Theory EECE 320 — UBC.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
2.1 Sets. DEFINITION 1 A set is an unordered collection of objects. DEFINITION 2 The objects in a set are called the elements, or members, of the set.
Sets DISCRETE STRUCTURE ABDUL BASIT TAHIR, KAMRAN ALI, FAIZAN ILLAHI, NOMAN AHMAD, ARSALAN MUBASHIR.
1 Section 1.7 Set Operations. 2 Union The union of 2 sets A and B is the set containing elements found either in A, or in B, or in both The denotation.
Analytical Methods in CS (CIS 505)
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Sets 1.
Sets 1.
Discrete Maths Objective to re-introduce basic set ideas, set operations, set identities , Semester 2, Set Basics 1.
Sets.
1 Sets CS 202, Spring 2007 Epp, chapter 5 Aaron Bloomfield.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Chapter 7 Logic, Sets, and Counting Section 2 Sets.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
CS201: Data Structures and Discrete Mathematics I
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
CompSci 102 Discrete Math for Computer Science
Section 2.1. Section Summary Definition of sets Describing Sets Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal.
ELEMENTARY SET THEORY.
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Definition of a Set DM is study of discrete structures. Fundamental discrete structure upon which most of other discrete structures are built is the sets.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 Basic Structure : Sets, Functions, Sequences, and Sums Sets Operations.
Chapter 2 With Question/Answer Animations. Section 2.1.
Rosen 1.6, 1.7. Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by.
Discrete Mathematics SETS. What is a set? ^A set is a unordered collection of “objects”  People in a class: {A yşe, B arış, C anan }  Cities in Turkey.
Discrete Mathematics Lecture # 10. Set Theory  A well defined collection of {distinct} objects is called a set.  The objects are called the elements.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Discrete Mathematics. Set Theory - Definitions and notation A set is an unordered collection of elements. Some examples: {1, 2, 3} is the set containing.
Discrete Mathematics Set.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Set Operations Section 2.2.
Discrete Mathematics CS 2610 August 31, Agenda Set Theory Set Builder Notation Universal Set Power Set and Cardinality Set Operations Set Identities.
Section 2.1. Sets A set is an unordered collection of objects. the students in this class the chairs in this room The objects in a set are called the.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
CPCS 222 Discrete Structures I
Section 6.1 Set and Set Operations. Set: A set is a collection of objects/elements. Ex. A = {w, a, r, d} Sets are often named with capital letters. Order.
Sets, Permutations, and Combinations. Lecture 4-1: Sets Sets: Powerful tool in computer science to solve real world problems. A set is a collection of.
Set. Outline Universal Set Venn Diagram Operations on Sets.
Sets CS 202, Spring 2007 Epp, chapter 5.
CSE15 Discrete Mathematics 02/13/17
Dr. Ameria Eldosoky Discrete mathematics
Applied Discrete Mathematics Week 1: Logic and Sets
Set Definition: A set is unordered collection of objects.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Discrete Structures – CNS 2300
Discrete Mathematical The Set Theory
CSNB 143 Discrete Mathematical Structures
Set, Combinatorics, Probability & Number Theory
Sets Section 2.1.
Chapter 1 Logic and Proofs Homework 2 Given the statement “A valid password is necessary for you to log on to the campus server.” Express the statement.
Exercises Show that (P  Q)  (P)  (Q)
CS100: Discrete structures
Set Operations Section 2.2.
        { } Sets and Venn Diagrams Prime Numbers Even Numbers
2.1 Sets Dr. Halimah Alshehri.
Sets. EXAMPLE 1 The set O of odd positive integers less than 10 can be expressed by O = { l, 3, 5, 7, 9}. * This way of describing a set is known as.
Discrete Mathematics CS 2610
The aim of education is to teach students how to think rather than what to think. Sets The set is the fundamental discrete structure on which all other.
2 Chapter Numeration Systems and Sets
Lecture 2.1: Sets and Set Operations*
ICS 253: Discrete Structures I
L5 Set Operations.
Chapter 7 Logic, Sets, and Counting
Lecture Sets 2.2 Set Operations.
Sets & Set Operations.
Presentation transcript:

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete Mathematics and It's Applications” Kenneth H. Rosen; 7th edition, 2012.

Chapter 2.1 Sets

2.1 Sets Definition : A set is an unordered collection of objects. Definition : The objects in a set are called the elements, or members, of the set. Capital letters (A, B, S…) used for sets Italic lower-case letters (a, x, y…) used to denote elements of sets There are several ways to describe a set. Listing all members of a set, when this is possible Some examples: {1, 2, 3} is the set containing “1” and “2” and “3.” {1, 1, 2, 3, 3} = {1, 2, 3} since repetition is irrelevant. {1, 2, 3} = {3, 2, 1} since sets are unordered. {1, 2, 3, …} is a way we denote an infinite set.  = { } is the empty set, or the set containing no elements. Note that   {}

2.1 Sets 2. Set Builder notation Characterize all those elements in the set by stating the property or properties they must have to be members. D = {x | x is prime and x > 2} E = {x | x is odd and x > 2} The vertical bar means “such that” N = {0, 1, 2, 3, …} is the set of natural numbers Z = {…, -2, -1, 0, 1, 2, …} is the set of integers Z+ = {1, 2, 3, …} is the set of positive integers Z- = {-1, -2, -3, …} is the set of negative integers Q = {p/q : p, q  Z, q ≠ 0} is the set of rational numbers Any number that can be expressed as a fraction of two integers (where the bottom one is not zero) R is the set of real numbers R+, the set of positive real numbers C, the set of complex numbers.

2.1 Sets x  S means “x is an element of set S.” x  S means “x is not an element of set S.” Example: 4  {1, 2, 3, 4} 7  {1, 2, 3, 4} Universal set “U” : the set of all of elements (or the “universe”) from which given any set is drawn. For the set {-2, 0.4, 2}, U would be the real numbers For the set {0, 1, 2}, U could be the N, Z, Q, R depending on the context For the set of the vowels of the alphabet, U would be all the letters of the alphabet

2.1 Sets Venn diagrams Sets can be represented graphically using Venn diagrams universal set U, which contains all the objects under consideration, is represented by a rectangle. Circles or other geometrical figures Inside this rectangle are used to represent sets. Points represent the particular elements of the set. S U

2.1 Sets Sets can contain other sets V = { {{1}, {{2}}}, {{{3}}}, { {1}, {{2}}, {{{3}}} } } V has only 3 elements! Note that 1 ≠ {1} ≠ {{1}} ≠ {{{1}}} They are all different  ≠ {  } The first is a set of zero elements The second is a set of 1 element Replace  by { }, and you get: { } ≠ {{ }} It’s easier to see that they are not equal that way

2.1 Sets Definition: Two sets are equal if and only if they have the same elements. Therefore, if A and B are sets, then A and B are equal if and only if ∀ x(x ∈ A ↔ x ∈ B). We write A = B if A and B are equal sets. The set A is a subset of B if and only if every element of A is also an element of B.We use the notation A ⊆ B to indicate that A is a subset of the set B. Examples: {1, 2, 3, 4, 5} = {5, 4, 3, 2, 1} but {1, 2, 3, 4, 5} ≠ {1, 2, 3, 4} If A = {2, 4, 6}, B = {1, 2, 3, 4, 5, 6, 7}, A is a subset of B This is specified by A  B meaning that  x (x  A  x  B)

2.1 Sets A  B means “A is a subset of B.” or, “B contains A.” or, “every element of A is also in B.” or, x ((x  A)  (x  B)). For any set S, S  S (S S  S) For any set S,   S (S   S) Every non-empty set S, it has at least two subsets: 1)   S 2) S  S A B Venn Diagram U

2.1 Sets A  B means “A is a subset of B.” A  B means “A is a superset of B.” A = B if and only if A and B have exactly the same elements. iff, A  B and B  A iff, A  B and A  B iff, x ((x  A)  (x  B)).

2.1 Sets Proper Subsets U A  B means “A is a proper subset of B.” A  B, and A  B. x ((x  A)  (x  B))  x ((x  B)  (x  A)) A B U

2.1 Sets The difference between “subset” and “proper subset” is like the difference between “less than or equal to” and “less than” for numbers. {1,2,3}  {1,2,3,4,5} {1,2,3}  {1,2,3,4,5} Examples: Let B = {0, 1, 2, 3, 4, 5} If A = {1, 2, 3}, A is not equal to B, and A is a subset of B A proper subset is written as A  B Sets may contain other sets as members: A = {0, {a}, {b}, {a, b}} and B = {x I x is a subset of the set {a, b}}. Note that A = B, {a}  A , but a  A

2.1 Sets Quick examples: Is   {1,2,3}? Yes! x (x  )  (x  {1,2,3}) holds, because (x  ) is false. Is   {1,2,3}? NO Yes Is   {,1,2,3}? Is   {,1,2,3}? Is {x}  {x}? No

2.1 Sets Cardinality of Set If S is finite, then the cardinality of S is the number of distinct elements in S. The cardinality of S is denoted by |S|. Examples: If S = {1, 2, 3, 4, 5}, Then |S| = 5 If S = {3,3,3,3,3}, Then |S| = 1 If S = , Then |S| = 0 If S = {, {a}, {b}, {a, b}}, Then |S| = 4 If S be the set of odd positive integers less than 10 Then |S| = 5. If S be the set of letters in the English alphabet Then |S| = 26

2.1 Sets Power Sets The power set of S is the set of the subsets of S. (written as P(S)) Given S = {0, 1, 2} . All the possible subsets of S? P(S) = {, {0}, {l}, {2}, {0, 1}, {0, 2}, {l, 2}, {0, 1, 2}} Note that |S| = 3 and |P(S)| = 8 If S has n elements then the power set of S has 2n elements If S is a set, then the power set of S is 2S = { x : x  S }. If S = {a}, then P(S) =2S = {, {a}}. If S = {,{}}, then P(S) = 2S = {, {}, {{}}, {,{}}}. Fact: if S is finite, |P(S)| =|2S| = 2|S|. (if |S| = n, |2S| = 2n)

2.1 Sets Cartesian Product The Cartesian Product of two sets A and B is: A x B = { < a, b > : a  A  b  B} Example: Given A = { a, b } and B = { 0, 1 }, what is their Cartesian product? C = A x B = { (a,0), (a,1), (b,0), (b,1) } Example: What is the Cartesian product of: A = { I , 2} and B = {a, b, c} Solution: The Cartesian product A x B is: A  B = {(1 , a), (1, b), (1 , c) , (2 , a), (2 , b), (2 , c) }. Note that: A  B ≠ B  A Since, B  A = {(a, I), (a, 2), (b, I), (b, 2), (c , 1), (c , 2)} A1 x A2 x … x An = {<a1, a2,…, an>: a1  A1, a2  A2, …, an  An}

2.1 Sets Example: What is the Cartesian product A  B  C, where A = {0, l}, B = { I, 2}, and C = {0, 1 , 2}? Solution: A  B  C = {(0, 1 , 0) , (0 , I, I), (0 , 1, 2), (0 , 2 , 0), (0 , 2 , I), (0 , 2 , 2) , (1 , 1 , 0) , (1 , 1 , 1), (1 , 1 , 2), (1, 2 , 0), (1 , 2 , 1), (1 , 2 , 2)}.

2.1 Sets Exercises 1. List the members of these sets. a) {x I x is a real number such that x2 = I} b) {x I x is a positive integer less than 12} c) {x I x is the square of an integer and x < 100} d) {x I x is an integer such that x2 = 2} 2. Use set builder notation to give a description of each of these sets. a) {0, 3, 6, 9, I2} b) {-3, -2, -I,0, I , 2, 3} c) {m, n, o, p} 3. Determine whether each of these pairs of sets are equal. a) {I, 3, 3, 3, 5, 5, 5, 5, 5}, {5, 3, I} b) {{I}}, {I, {I}} c) , {} 4. Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6}, and D = {4, 6, 8}. Determine which of these sets are subsets of which other of these sets.

2.1 Sets Exercises

2.1 Sets Exercises

2.1 Sets Exercises

Chapter 2.2 Set Operations

2.2 Set Operations Definition: Union Two sets can be combined in many different ways: Definition: Union The union of the sets A and B, denoted by A U B, is the set that contains those elements that are either in A or in B, or in both. A  B = { x : x  A v x  B} Examples: {1, 2, 3} U {3, 4, 5} = {1, 2, 3, 4, 5} {a, b} U {3, 4} = {a, b, 3, 4} {1, 2} U  = {1, 2} A B

2.2 Set Operations Properties of the union operation A U  = A Identity law A U U = U Domination law A U A = A Idempotent law A U B = B U A Commutative law A U (B U C) = (A U B) U C Associative law

2.2 Set Operations Intersection 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 = { x : x  A  x  B} Examples: {1, 2, 3} ∩ {3, 4, 5} = {3} {a, b} ∩ {3, 4} =  {1, 2} ∩  =  A B

2.2 Set Operations Properties of the intersection operation A ∩ U = A Identity law A ∩  =  Domination law A ∩ A = A Idempotent law A ∩ B = B ∩ A Commutative law A ∩ (B ∩ C) = (A ∩ B) ∩ C Associative law

2.2 Set Operations Disjoint Formal definition for disjoint sets: two sets are disjoint if their intersection is empty set A  B =  Examples: {1, 2, 3} and {3, 4, 5} are not disjoint {a, b} and {3, 4} are disjoint {1, 2} and  are disjoint Their intersection is empty set  and  are disjoint!

2.2 Set Operations Complement Let U be the universal set. The complement of the set A, denoted by A , is the complement of A with respect to U. The complement of the set A is U - A. The complement of a set A is: A = { x : x  A} = Ac Note that:  = U and U =  Properties of complement sets (Ac)c = A Complementation law A U Ac = U Complement law A ∩ Ac =  Complement law Example: Let U is the set of all positive integers If A = {x| x > 10}, Then Ac = {l,2,3,4,5,6,7,8,9,l0}. A A

2.2 Set Operations Difference 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 two sets A and B is: A - B = { x : x  A  x  B } A - B = A  B U

2.2 Set Operations Examples: {1, 2, 3} - {3, 4, 5} = {1, 2} {a, b} - {3, 4} = {a, b} {1, 2} -  = {1, 2} The difference of any set S with the empty set will be the set S S -  = S , where S is any set

2.2 Set Operations symmetric difference The symmetric difference of two sets A and B is: A  B = { x : (x  A  x  B) v (x  B  x  A)} = (A - B) U (B - A) = (A  B) – (A  B)

2.2 Set Operations Set identities

2.2 Set Operations Four methods: How to prove a set identity? For example Prove that : (A U B) = A  B Four methods: Use the basic set identities Use membership tables Prove each set is a subset of each other Use set builder notation and logical equivalences

1- By using the basic set identities (A U B) = A U B = A  B 2.2 Set Operations 1- By using the basic set identities (A U B) = A U B = A  B

2- Bu Using membership tables 2.2 Set Operations 2- Bu Using membership tables

2.2 Set Operations 3- By using each set is a subset of each other () (x  A U B)  (x  A U B)  (x  A and x  B)  (x  A  B) () (x  A  B)  (x  A and x  B)  (x  A U B)  (x  A U B)

2.2 Set Operations 4- By using set builder notation and logical equivalences (A U B) = {x : (x  A v x  B)} = {x : (x  A)  (x  B)} = {x : (x  A)  (x  B)} = A  B

2.2 Set Operations Generalized Unions and Intersections Let A, B, and C be sets then: A  B  C contains those elements that are in at least one of the sets A, B, and C A  B  C contains those elements that are in all of A, B, and C.

2.2 Set Operations Example: Let A = {0, 2, 4, 6, 8}, B = {0, 1,2,3, 4}, and C = {0, 3, 6, 9}, determine the following combinations: 1. A  B  C 2. A  B  C Solution: 1. A  B  C = {0, 1,2, 3,4, 6, 8, 9}. 2. A  B  C = {0}.

2.2 Set Operations Computer Representation of Sets Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. The bit string (of length |U| = 10) that represents the set A = {1, 3, 5, 6, 9} has a one in the first, third, fifth, sixth, and ninth position, and zero elsewhere. It is 1 0 1 0 1 1 0 0 1 0. What bit strings represent the subset of: All odd integers in U, A= {I, 3, 5, 7, 9}, and the bit string is 10 1010 1010. 2. Integers not exceeding 5 in U A= {l, 2, 3, 4, 5}, and the bit string is 11 1110 0000.

2.2 Set Operations Example: The bit strings for the sets {I, 2, 3, 4, 5} and {I, 3, 5, 7, 9} are 11 1110 0000 and 10 1010 1010, respectively. Use bit strings to find the union and intersection of these sets. Solution: The bit string for the union of these sets is: 11 1110 0000  10 1010 1010 = 11 1110 1010, Corresponds to the set {l, 2, 3,4, 5, 7, 9}. The bit string for the intersection of these sets is: 11 11100000  10 1010 1010 = 10 1010 0000, Corresponds to the set {I, 3, 5}.

2.2 Set Operations Exercises 1. Let A = { l , 2, 3,4, 5} and B = {0, 3, 6}. Find A  B b) A  B c) A – B d) B - A 2. Let A = {a, b, c, d, e} and B = {a, b, c, d, e, f, g, h}. Find A  B b) A  B c) A – B d) B – A 3. Find the sets A and B if A - B = {I, 5, 7, 8}, B - A = {2, l0}, and A  B = {3, 6,9} 4. Show that if A and B are sets, then a) A - B = A  Bc b) (A  B)  (A  Bc)= A 5. Find the symmetric difference of: a) { I , 3 , 5} and { I , 2, 3}. b) the set of computer science majors at a school and the set of mathematics majors at this school

2.2 Set Operations 6. Let A = {0, 2, 4, 6, 8, 10}, B = {0, 1 , 2, 3 ,4,5, 6}, and C = {4, 5 , 6, 7, 8 , 9, 10}. Find a) A  B  C b) A  B  C c) (A  B)  C d) (A  B)  C 7. What can you say about the sets A and B if we know that: a) A  B=A b) A  B=A c) A – B = A d) A  B= B  A e) A – B = B - A 8. Can you conclude that A = B if A, B, and C are sets such that: a) A  C = B  C b) A  C = B  C c) A  B = B  C and A  C = B  C

2.2 Set Operations