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

Slides:



Advertisements
Similar presentations
More Set Definitions and Proofs 1.6, 1.7. Ordered n-tuple The ordered n-tuple (a1,a2,…an) is the ordered collection that has a1 as its first element,
Advertisements

Lecture 2 Introduction To Sets CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Discrete Mathematics I Lectures Chapter 6
Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Instructor: Hayk Melikya
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Section 1.6: Sets Sets are the most basic of discrete structures and also the most general. Several of the discrete structures we will study are built.
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.
Denoting the beginning
Analytical Methods in CS (CIS 505)
Sets Definition of a Set: NAME = {list of elements or description of elements} i.e. B = {1,2,3} or C = {x  Z + | -4 < x < 4} Axiom of Extension: A set.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Chapter 2 The Basic Concepts of Set Theory
Sets 1.
CSE115/ENGR160 Discrete Mathematics 02/10/11 Ming-Hsuan Yang UC Merced 1.
Sets 1.
Set Theory.
Discrete Maths Objective to re-introduce basic set ideas, set operations, set identities , Semester 2, Set Basics 1.
Sets.
This section will discuss the symbolism and concepts of set theory
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
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.
Mathematical Proofs. Chapter 1 Sets 1.1 Describing a Set 1.2 Subsets 1.3 Set Operations 1.4 Indexed Collections of Sets 1.5 Partitions of Sets.
CS201: Data Structures and Discrete Mathematics I
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
1. 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 of A” A = {a 1, a 2,
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.
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.
Basic Structures: Sets, Functions, Sequences, and Sums.
1 Chapter Two Basic Concepts of Set Theory –Symbols and Terminology –Venn Diagrams and Subsets.
Discrete Mathematics Lecture # 10. Set Theory  A well defined collection of {distinct} objects is called a set.  The objects are called the elements.
(CSC 102) Lecture 13 Discrete Structures. Previous Lectures Summary  Direct Proof  Indirect Proof  Proof by Contradiction  Proof by Contra positive.
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.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Chapter 7 Sets and Probability Section 7.1 Sets What is a Set? A set is a well-defined collection of objects in which it is possible to determine whether.
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
Set. Outline Universal Set Venn Diagram Operations on Sets.
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
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.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
CS100: Discrete structures
Set Theory A B C.
        { } 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.
Chapter 7 Logic, Sets, and Counting
Lecture Sets 2.2 Set Operations.
Presentation transcript:

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

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 0.5-1 page answers.

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

Chapter Summary Sets The Language of Sets Set Operations Set Identities

Sets Section 2.1

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

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

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}

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

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   {}

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

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

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}

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

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

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

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)]

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}}}

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

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

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

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) = {, {}, {{}}, {, {}}}

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)}

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)}

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}

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) }

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.

Exercises

Exercises

Exercises

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

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 0.5-1 page answers.

Set Operations Section 2.2

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

Set Operations Union Intersection Compliment Difference

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}

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} ∩  = 

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!

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}

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

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)

Set Identities

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

Proof using Set Builder Notation

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

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

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

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}

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

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

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

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

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 12 3456 78910 10 1010 1010 01 0101 0101 11 1110 0000

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. 10 1010 1010 The string representing the subset of all even integers in U, namely, {2, 4, 6, 8, 10}, is 01 0101 0101 The string representing the set of all integers in U that do not exceed 5, namely, {1, 2, 3, 4, 5}, is 11 1110 0000

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 10 1010 1010, what is the bit string for the complement of this set? The bit string for the complement of this set is 01 0101 0101, which corresponds to the set {2, 4, 6, 8, 10}

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 11 1110 0000 and 10 1010 1010, respectively. Find the union and intersection of these sets. The bit string for the union of these sets is 11 1110 0000  10 1010 1010 = 11 1110 1010, corresponds to the set {1, 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 {1, 3, 5}

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

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

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

Exercises

Exercises

Exercises

Exercises