Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)

Similar presentations


Presentation on theme: "CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)"— Presentation transcript:

1 CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Chapter 1 section 1.1 by Dr. Mosaad Hassan

2 First Midterm Exam 2nd Lecture, next week (same time as the lecture)
75 minute duration Will cover all lectures delivered before the exam date Will consist of MCQ’s, fill-in-the-blanks, questions with short answers, writing of proofs, and drawing of diagrams If you miss this exam for any reason, you will have to appear for a makeup exam on the Thursday of the last week of teaching. That exam will cover all lectures delivered in the semester. It will consist of writing of proofs, drawing of diagrams and answering questions having page answers.

3 Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Chapter 2 With Question/Answer Animations

4 Chapter Summary Sets The Language of Sets Set Operations
Set Identities

5 Sets Section 2.1

6 Section Summary Definition of sets Describing Sets
Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal Set Subsets and Set Equality Cardinality of Sets Tuples Cartesian Product

7 Introduction Sets are one of the basic building blocks for the types of objects considered in discrete mathematics Important for counting Programming languages have set operations

8 Sets A set is an unordered collection of objects Capital letters (A, B, C…) are used to denote sets The objects in a set are called the elements or members of that set. Lower-case letters (a, b, c…) are used to denote elements Membership of a Set x  A denotes that x is an element of the set A Example: lion {tiger, lion, cat} x  A denotes that x is not an element of the set A Example: 7  {1, 2, 3, 4}

9 Ways of Describing a Set
Roster method Using set builder notation Venn diagrams

10 Describing a Set: Roster Method
Listing all members of a set, when possible Examples {1, 2, 3} is the set containing “1”, “2” and “3” {1, 1, 2, 3, 3} not appropriate as repetition is not allowed. The correct form is {1, 2, 3} {1, 2, 3} = {3, 2, 1} = {2, 3, 1} since sets are unordered {1, 2, 3, …} is a way to denote an infinite set  or { } is the empty set, or the set containing no elements. Note that   {}

11 Describing a Set: Set Builder Notation
Characterize all elements in the set by stating the properties they must have to be members Examples E = {x | x is a student at Taibah University} O = {x | x is an odd positive integer less than 10} O = {x  Z+ | x is odd and x < 10} Q+ = {x  R | x = p/q, for some +ive integers p, q} D = {x | P(x)}, i.e. set of all x for which P(x) is true

12 Symbols for Sets of Numbers
N = {0, 1, 2, 3, …} - set of natural numbers Z = {…, -2, -1, 0, 1, 2, …} - set of integers Z+ = {1, 2, 3, …} - set of positive integers Z- = {-1, -2, -3, …} - set of negative integers R = set of real numbers R+ = set of positive real numbers C = set of complex numbers Q = {p/q | p  Z, q  Z, q ≠ 0} - set of rational numbers

13 Equal Sets Two sets are equal iff they have the same elements
If A and B are sets, then A and B are equal (A = B) iff x (x  A  x  B) Examples {1, 3, 5 } = {3, 5, 1} because they have the same elements {-3, -2, -1, 0, 1, 2, 3} = {x | x is an integer and |x| < 4} = {x | x  Z, |x| < 4} = {integers between -3 and 3 inclusive} {{1}} ≠ {1}

14 Describing a Set: Venn Diagrams
They are used to represent sets graphically They are often used to indicate the relationships among sets In Venn diagrams: Rectangles represent the universal set U, which contains all the objects under consideration Circles, inside a rectangle, represent sets Points represent the particular elements of the set

15 Venn Diagrams: Example
A Venn diagram that represents the set V V = {a, e, i, o, u}

16 Subset Set A is said to be a subset of set B iff 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. A  B iff x (x  A  x  B) is true Example A= {2, 4, 6}, B = {1, 2, 3, 4, 5, 6, 7} A  B, i.e., x (x  A  x  B) is true

17 Subsets Example: The set of all computer science students at Taibah University is a subset of the set of all students at Taibah University Remarks Every non-empty set has at least 2 subsets,  & itself Set A is a proper subset of B (A  B) if A  B but A ≠ B, i.e., A is a proper subset of B if x (x  A  x  B)  x (x  B  x  A) is true Set A = B iff A  B and B  A A  B means A is a superset of B, i.e., B is contained in A. It can be expressed as: x [(x  B)  (x  A)]

18 Sets within Sets Sets may contain other sets as members Examples A = {, {a}, {b}, {a, b}} and B = {x | x is a subset of the set {a, b}}. Notes: A = B. {a}  A , but a  A S = {{1}, {2}, {3}} T = {{1}, {{2}}, {{{3}}}} V = {{{1}, {{2}}}, {{{3}}}, {{1}, {{2}}, {{{3}}}}} Notes: V has only 3 elements. 1 ≠ {1} ≠ {{1}} ≠ {{{1}}}

19 The Empty Set  = { } ≠ {}   {1, 2, 3}? Yes   {1, 2, 3}? No
{ } has zero elements {} has one element   {1, 2, 3}? Yes   {1, 2, 3}? No   {, 1, 2, 3}? Yes   {, 1, 2, 3}? Yes {x}  {x}? No

20 Cardinality of a Set If S is finite, then the cardinality of S, |S|, is the number of distinct elements in S Examples S = {1, 2, 3, 4, 5}, |S| = 5 S = {3, 3, 3, 3, 3}, |S| = 1 S = , |S| = 0 S = {, {a}, {b}, {a, b}}, |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 A set is said to be infinite if it is not finite. The set of positive integers is infinite. It’s cardinality is infinite

21 Tuples The ordered n-tuple (a1,a2,…..,an) is the ordered collection that has a1 as its first element and a2 as its second element and so on until an as its last element 2-tuples are called ordered pairs Two n-tuples are equal iff their corresponding elements are equal The ordered pairs (a, b) and (c, d) are equal iff a = c and b = d

22 Power Set The power set of S, P(S), is the set of all subsets of S Let S = {0, 1, 2} then P(S) = {, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}} Note: |S| = 3 and |P(S)| = 8 If S has n elements then the power set of S has 2n elements S = {a}, P(S) = {, {a}} S = {, {}}, P(S) = {, {}, {{}}, {, {}}}

23 Cartesian Product Let A and B be sets , the Cartesian product of A and B, denoted by A  B, is the set of all ordered pairs (a, b), where a  A and b  B. A  B = { (a, b) | a  A  b  B} Example A = {1, 2} B = {a, b, c} A  B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}

24 A  B ≠ B  A A  B ≠ B  A, unless A = B Note: If A =  = B, then A  B =  Example A = {1, 2} B = {a, b, c} A  B = {(1, a), (1, b), (1, c) , (2, a), (2, b), (2, c)} B  A = {(a, 1), (a, 2), (b, 1), (b, 2), (c, 1), (c, 2)}

25 Relation A subset R of the Cartesian product A  B is called a relation from the set A to the set B The elements of R are ordered pairs, where the first element belongs to A and the second to B Example R = {(a, 0), (a 1), (a, 3), (b, 1), (b, 2), (c, 0) , (c, 3)} is a relation from the set {a, b, c} to the set {0, 1, 2, 3}

26 Cartesian Product of Many Sets
The Cartesian product of the sets A1, A2, ... , An is A1  A2 … An = {(a1, a2, ... , an) | ai  Ai for i = 1,2, ...,n} Example A = {0, 1} B = {1, 2} C = {0, 1 2} A  B  C = { (0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 2, 0), (0, 2, 1), (0, 2, 2), (1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2) }

27 Section 1.1: Exercises 1. List the members of these sets.
a) {x | x is a real number such that x2 = 1} b) {x | x is a positive integer less than 12} c) {x | x is the square of an integer and x < 100} d) {x | 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, 12} b) {-3, -2, -1,0, 1, 2, 3} c) {m, n, o, p} 3. Determine whether each of these pairs of sets are equal. a) {1, 3, 3, 3, 5, 5, 5, 5, 5}, {5, 3, 1} b) {{1}}, {1, {1}} 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.

28 Exercises

29 Exercises

30 Exercises

31 CS 103 Discrete Structures Lecture 11 Basic Structures: Sets (2)
Chapter 1 section 1.1 by Dr. Mosaad Hassan

32 First Midterm Exam Next lecture (same time as the lecture)
75 minute duration Will cover all lectures delivered before the exam date Will consist of MCQ’s, fill-in-the-blanks, questions with short answers, writing of proofs, and drawing of diagrams If you miss this exam for any reason, you will have to appear for a makeup exam on the Thursday of the last week of teaching. That exam will cover all lectures delivered in the semester. It will consist of writing of proofs, drawing of diagrams and answering questions having page answers.

33 Set Operations Section 2.2

34 Section Summary Set Operations More on Set Cardinality Set Identities
Union Intersection Complementation Difference More on Set Cardinality Set Identities Proving Identities Membership Tables

35 Set Operations Union Intersection Compliment Difference

36 Set Operations: Union Examples
The union of the sets A and B, A U B, is the set that contains those elements that are either in A or B, or both. A  B = {x : x  A  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}

37 Set Operations: Intersection
The intersection of the sets A and B, A  B, is the set containing those elements that are common between A and B. A  B = {x : x  A  x  B} Examples {1, 2, 3} ∩ {3, 4, 5} = {3} {a, b} ∩ {3, 4} =  {1, 2} ∩  = 

38 Disjoint Sets Two sets are called disjoint if their intersection is the 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  and  are disjoint!

39 Complement of A Set Let U be the universal set. The complement of the set A, Ā, is the complement of A with respect to U, i.e. U - A. Ā = {x : x  A } Examples Ū =  Let U is the set of the English alphabet letters A = {a, e, i, o, u} Ā = {b, c, d, j, g, h, j, k, l, p, q, r, s, t, v, w, x, y, z} Let U is the set of all positive integers A = {x | x > 10} Ā = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

40 Difference of Sets The difference of A and B, A - B, is the set containing those elements that are in A but not in B A - B = {x : x  A  x  B } The difference of A and B is also called the complement of B with respect to A Examples {1, 2, 3} - {3, 4, 5} = {1, 2} {a, b} - {3, 4} = {a, b} {1, 2} -  = {1, 2} S -  = S, where S is any set

41 Symmetric Difference The symmetric difference of sets A and B consists of those elements of the two sets that are not common among them A  B = {x : (x  A  x  B)  (x  B  x  A)} = (A - B)  (B - A) = (A  B) - (A  B)

42 Set Identities

43 How to Prove An Identity?
Prove each set is a subset of the other Use set builder notation and logical equivalences Use membership tables Example - Proving each is a subset of the other Prove that (A  B)c = Ac  Bc 1. Let x  (A  B)c x  (A  B) x  A or x  B x  Ac or x  Bc x  (Ac  Bc)  (A  B)c  Ac  Bc 2. Let x  Ac  Bc x  (A  B)c  Ac  Bc  (A  B)c From 1 and 2 we conclude that (A  B)c = Ac  Bc

44 Proof using Set Builder Notation

45 Proof using Membership Tables
(A  B)c Ac Bc Ac  Bc 1 Element is in the set Element is not in the set

46 Proof using Identities
Show that [A  (B  C)]c = (Cc  Bc )  Ac

47 Generalized Unions & Intersections
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

48 Generalized  & : Example
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}

49 Generalized Unions & 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. Generalized Intersection The intersection of a collection of sets is the set that contains those elements that are members of all the sets in the collection

50 Generalized  & : Example 1
Let Ai = {i, i+1, i+2, ... } then:

51 Generalized  & : Example 2
Ai = {1, 2, 3, ... , i}, i = 1,2, 3, ...

52 Computer Representation of Sets
If U is a finite set, then the number of elements in U cannot be larger than the memory size of the computer being used If the ordering of the elements of U is a1, a2, ... , an, and if A is a subset of U with the bit string of length n, then the string that represent A has its ith bit as 1 if ai  A and 0 if ai  A

53 Computer Representation: Example 1
The ordering of elements of U is in the increasing order, that is, ai = i What bit strings represent the subset of: All odd integers in U All even integers in U Integers not exceeding 5 in U

54 Computer Representation: Example 1
The bit string that represents the set of odd integers in U, namely, {1, 3, 5, 7, 9}, has bits in positions first, third, fifth, seventh, and ninth set to 1, and to zero elsewhere The string representing the subset of all even integers in U, namely, {2, 4, 6, 8, 10}, is The string representing the set of all integers in U that do not exceed 5, namely, {1, 2, 3, 4, 5}, is

55 Computer Representation: Example 2
U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} If the bit string for set {1, 3, 5, 7, 9} is , what is the bit string for the complement of this set? The bit string for the complement of this set is , which corresponds to the set {2, 4, 6, 8, 10}

56 Computer Representation: Example 3
U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} Bit strings for the sets {1, 2, 3, 4, 5} and {1, 3, 5, 7, 9} are and , respectively. Find the union and intersection of these sets. The bit string for the union of these sets is  = , corresponds to the set {1, 2, 3,4, 5, 7, 9} The bit string for the intersection of these sets is  = , corresponds to the set {1, 3, 5}

57 Section 1.8: Exercises 1. Let A be the set of students who live within one mile of school and let B be the set of students who walk to classes. Describe the students in each of these sets. a) A  B b) A  B c) A - B d) B - A 2. Suppose that A is the set of sophomores at your school and B is the set of students in discrete mathematics at your school. Express each of these sets in terms of A and B. a) the set of sophomores taking discrete mathematics in your school b) the set of sophomores at your school who are not taking discrete mathematics c) the set of students at your school who either are sophomores or are taking discrete mathematics d) the set of students at your school who either are not sophomores or are not taking discrete mathematics

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

59 Exercises 8. 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 9. 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 10. 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

60 Exercises

61 Exercises

62 Exercises

63 Exercises


Download ppt "CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)"

Similar presentations


Ads by Google