CS100: Discrete structures

Slides:



Advertisements
Similar presentations
Lecture 2 Introduction To Sets CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Advertisements

Prof. Johnnie Baker Module Basic Structures: Sets
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
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.
Analytical Methods in CS (CIS 505)
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.
Mathematics.
Discrete Maths Objective to re-introduce basic set ideas, set operations, set identities , Semester 2, Set Basics 1.
Sets.
Set Notation.
This section will discuss the symbolism and concepts of set theory
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)
Chapter 7 Logic, Sets, and Counting Section 2 Sets.
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.
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.
Lecture 2.1: Sets and Set Operations CS 250, Discrete Structures, Fall 2014 Nitesh Saxena Adopted from previous lectures by Cinda Heeren.
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.
ITD1111 Discrete Mathematics & Statistics STDTLP
Discrete Mathematics Set.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
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.
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.
CSE15 Discrete Mathematics 02/13/17
Dr. Ameria Eldosoky Discrete mathematics
Applied Discrete Mathematics Week 1: Logic and Sets
Sets Finite 7-1.
Set Definition: A set is unordered collection of objects.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Discrete Mathematical The Set Theory
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.
… and now for something completely different…
Exercises Show that (P  Q)  (P)  (Q)
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.
Lecture 2.1: Sets and Set Operations*
Chapter 7 Logic, Sets, and Counting
… and now for something completely different…
2.1 – Symbols and Terminology
Lecture Sets 2.2 Set Operations.
Sets & Set Operations.
Presentation transcript:

CS100: Discrete structures Computer Science Department Lecture 1: Set and Sets Operations

Lecture Contents Sets Definition. Some Important Sets. Notation used to describe membership in sets. How to describe a set? Sets. Venn diagrams. Subset. Finite and Infinite Sets. Cardinality. Sets Operations. Exercises. 12-Nov-18 Computer Science Department

Sets and sets operations 12-Nov-18 Computer Science Department

Sets Definition: Set is the fundamental discrete structure on which all other discrete structures are built. Sets are used to group objects together. Often, the objects in a set have similar properties. A set is an unordered collection of objects. The objects in a set are called the elements or members of the set 12-Nov-18 Computer Science Department

Some Important Sets: The set of natural numbers: The set of integers: Z = {. . . ,−2,−1, 0, 1, 2, . . .} The set of positive integers: Z+ = {1, 2, 3, . . .} The set of fractions: Q = {0,½, –½, –5, 78/13,…} Q ={p/q | pЄ Z , qЄZ, and q≠0 } The set of Real: R = {–3/2,0,e,π2,sqrt(5),…} 12-Nov-18 Computer Science Department

Notation used to describe membership in sets a set A is a collection of elements. If x is an element of A, we write xA; If not: xA. xA Say: “x is a member of A” or “x is in A”. Note: Lowercase letters are used for elements, capitals for sets. Two sets are equal if and only if they have the same elements A= B : x( x A  x B) also Two sets A and B are equal if A  B and B  A. So to show equality of sets A and B, show: A  B B  A 12-Nov-18 Computer Science Department

Notation used to describe membership in sets The sets {1,3,5} and {3,5,1} are equal , because they have the same elements. Is {1,3,3,3,5,5,5,5} = {1,3,5} ?! Yes , because they have the same elements. 12-Nov-18 Computer Science Department

How to describe a set? List all the members of a set, when this is possible. We use a notation where all members of the set are listed between braces. { } Example : {dog, cat, horse} The set O of odd positive integers less than 10 can be expressed by O={1,3,5,7,9} 12-Nov-18 Computer Science Department

How to describe a set? Sometimes the brace notation is used to describe a set without listing all its members. Some members of the set are listed, and then ellipses (...) are used when the general pattern of the elements is obvious. Example: The set A of positive integers less than 100 can be denoted by A={1, 2, 3, . . . , 99} 12-Nov-18 Computer Science Department

How to describe a set? Another way to describe a set is to use set builder notation. We characterize all those elements in the set by stating the property or properties they must have to be members. Example: the set O of all odd positive integers less than 10 can be written as: O = {x | x is an odd positive integer <10} or, specifying the universe as the set of positive integers, as O = {x  Z+ | x is odd and x<10}.  12-Nov-18 Computer Science Department

Sets: The Empty Set (Null Set) We use  to denote the empty set and can also be denoted { }, i.e. the set with no elements. Example: the set of all positive integers that are greater than their squares is the null set. Singleton set A set with one element is called a singleton set. 12-Nov-18 Computer Science Department

Sets: Computer Science Note that the concept of a data type, or type, in computer science is built upon the concept of a set. In particular, a data type is the name of a set, together with a set of operations that can be performed on objects from that set. Example: Boolean is the name of the set {0, 1} together with operators on one or more elements of this set, such as AND, OR, and NOT. 12-Nov-18 Computer Science Department

Venn diagrams: Sets can be represented graphically using Venn diagrams. In Venn diagrams the universal set U, which contains all the objects under consideration, is represented by a rectangle. Inside this rectangle, circles or other geometrical figures are used to represent sets. Sometimes points are used to represent the particular elements of the set. 12-Nov-18 Computer Science Department

Venn diagrams: Example: A Venn diagram that represents V = {a, e, i, o, u} the set of vowels in the English alphabet 12-Nov-18 Computer Science Department

Subset: The set A is said to be 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. We see that A  B if and only if the quantification x (x  A → x  B) is true. Examples: The set of all odd positive integers less than 10 is subset of the set of all positive integers . The set of rational numbers is subset of the set of real numbers . 12-Nov-18 Computer Science Department

x ((x  A)  (x  B))  x ((x  B)  (x  A)) Subsets: For every set S,   S S  S Proper subset: When a set A is a subset of a set B but A ≠ B, A  B, and A  B We write A  B and say that A is a proper subset of B For A  B to be true, it must be the case that x ((x  A)  (x  B))  x ((x  B)  (x  A)) 12-Nov-18 Computer Science Department

Subsets: Quick Examples: {1,2,3}  {1,2,3,4,5} {1,2,3}  {1,2,3,4,5} Is   {1,2,3}? Is   {1,2,3}? Is   {,1,2,3}? Is   {,1,2,3}? Yes! No! Yes! Yes! 12-Nov-18 Computer Science Department

Subsets: Quiz Time: Is {x}  {x,{x}}? Is {x}  {x,{x}}? Is {x}  {x}? Yes! Yes! Yes! No! 12-Nov-18 Computer Science Department

Finite and Infinite Sets: Let S be a set. If there are exactly n distinct elements in S where n is a nonnegative integer, we say that S is a finite set and that n is the cardinality of S. The cardinality of S is denoted by |S|. | A  B | = | A| + | B| - | A  B|   Infinite set A set is said to be infinite if it is not finite. For example, the set of positive integers is infinite. N.B. We only count unrepeated elements 12-Nov-18 Computer Science Department

Cardinality: Find S = {1,2,3}, S = {3,3,3,3,3}, S = , |S| is infinite 12-Nov-18 Computer Science Department

Sets: Ways to Define Sets: Explicitly: {John, Paul, George, Ringo} Implicitly: {1,2,3,…}, or {2,3,5,7,11,13,17,…} Set builder: { x : x is prime }, { x | x is odd }. In general { x : P(x) is true }, where P(x) is some description of the set. 12-Nov-18 Computer Science Department

The power of a set: Many problems involve testing all combinations of elements of a set to see if they satisfy some property. To consider all such combinations of elements of a set S, we build a new set that has as its members all the subsets of S. Given a set S, the power set of S is the set of all subsets of the set S. The power set of S is denoted by P(S). if a set has n elements , then the power has 2n elements. 12-Nov-18 Computer Science Department

The power of a set: Example: What is the power set of the set {0, 1, 2}? P({0,1,2}) is the set of all subsets of {0, 1, 2} P({0,1,2})= { , {0},{1},{2},{0,1},{0,2},{1,2},{0,1,2}} What is the power set of the empty set? What is the power set of the set {} ? P()= {} P({})= {,{}} N.B. the power set of any subset has at least two elements The null set and the set itself 12-Nov-18 Computer Science Department

P(S) = {, {}, {{}}, {,{}}}. The Power Set: Quick Quiz: Find the power set of the following: S = {a}, S = {a,b}, S = , S = {,{}}, P(S)= {, {a}}. P(S) = {, {a}, {b}, {a,b}}. P(S) = {}. P(S) = {, {}, {{}}, {,{}}}. 12-Nov-18 Computer Science Department

Cartesian Products: The order of elements in a collection is often important. Because sets are unordered, a different structure is needed to represent ordered collections. This is provided by ordered n-tuples. The ordered n-tuple (a1, a2, . . . , an) is the ordered collection that has a1 as its first element, a2 as its second element, . . . , and an as its nth element. 12-Nov-18 Computer Science Department

Cartesian Products: 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}. A1×A2×…×An={(a1, a2,…, an) | aiAi for i=1,2,…,n}. A×B not equal to B×A Example : A={1,2} , B={3,4} A×B={(1,3),(1,4),(2,3),(2,4)} B×A={(3,1),(3,2),(4,1),(4,2)} 12-Nov-18 Computer Science Department

Cartesian Products: Example: What is the Cartesian product A × B × C, where A = {0, 1}, B = {1, 2}, and C = {0, 1, 2}? AxBxC = {(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)} 12-Nov-18 Computer Science Department

Sets and sets operations 12-Nov-18 Computer Science Department

UNION: A  B = { x : x  A v x  B} The union of two sets A and B is: If A = {1, 2, 3}, and B = {2, 4}, then A  B = {1,2,3,4} A B 12-Nov-18 Computer Science Department

Intersection: A  B = { x : x  A  x  B} The intersection of two sets A and B is: A  B = { x : x  A  x  B} If A = {Charlie, Lucy, Linus}, and B = {Lucy, Desi}, then A  B = {Lucy} A B 12-Nov-18 Computer Science Department

Intersection: If A = {x : x is a US president}, and B = {x : x is deceased}, then A  B = {x : x is a deceased US president} A B 12-Nov-18 Computer Science Department

Sets whose intersection Disjoint: If A = {x : x is a US president}, and B = {x : x is in this room}, then A  B = {x : x is a US president in this room} = Sets whose intersection is empty are called disjoint sets A B 12-Nov-18 Computer Science Department

Complement: The complement of a set A is: A = A’ = { x : x  A} If A = {x : x is bored}, then A = {x : x is not bored} =  A  B = B  A = U and U =  A U 12-Nov-18 Computer Science Department

Difference: The set difference, A - B, is: A - B = { x : x  A  x  B } A - B = A  B A U B 12-Nov-18 Computer Science Department

Symmetric Difference: The symmetric difference, A  B, is: A  B = { x : (x  A  x  B) v (x  B  x  A)} = (A - B)  (B - A) Like “exclusive or” A U B 12-Nov-18 Computer Science Department

Symmetric Difference: Example: Let A = {1,2,3,4,5,6,7} B = {3,4,p,q,r,s} Then we have A  B = {1,2,3,4,5,6,7,p,q,r,s} A  B = {3,4} We get A  B = {1,2,5,6,7,p,q,r,s} 12-Nov-18 Computer Science Department

TABLE 1: Set Identities Name Identity Identity laws A U  = A Domination laws A U U = U A   =  Idempotent laws A  A = A A  A = A Complementation laws (A) = A Commutative laws A  B = B  A A  B = B  A Associative laws A  (B  C) = (A  B)  C A  (B  C) = (A  B)  C Distributive laws A  (B U C) = (A  B)  (A  C) A  (B  C) = (A U B)  (A U C) De Morgan’s laws A U B = A  B A  B = A U B Absorption laws A  (A  B) = A A  (A  B) = A Complement laws A  A = U A  A =  12-Nov-18 Computer Science Department

Let’s proof one of the Identities Using a Membership Table A  (B  C) = (A  B)  (A  C) TABLE 2: A Membership Table for the Distributive Property (A  B)  (A  C) A  C A  B A  (B  C) B  C C B A 1 12-Nov-18 Computer Science Department

Exercise 1: List the members of these sets: a) {x | x is a real number such that x² = 1} {-1, 1} b) {x | x is a positive integer less than 12} {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} c) {x | x is the square of an integer and x < 100} {0, 1, 4, 9, 16, 25, 36, 49, 64, 81} d) {x | x is an integer such that x² = 2}  12-Nov-18 Computer Science Department

Exercise 2: Determine whether each of these pairs of sets are equal: Yes b) {{1}}, {1, {2}} No c) , {} 12-Nov-18 Computer Science Department

Exercise 3: Determine whether these statements are true or false. b) ∅∈{0} c) {0} ⊂∅ d) ∅⊂ {0} e) {0} ∈ {0} f) {0} ⊂ {0} g) {∅}⊆{∅} False False False True False False True 12-Nov-18 Computer Science Department

Exercise 4: Use a Venn diagram to illustrate the relationships 𝐀⊂𝑩 𝒂𝒏𝒅 𝑩⊂𝑪 . A B C U 12-Nov-18 Computer Science Department

Exercise 5: What is the cardinality of each of these sets? a) {a} 1 b) {{a}} c) {∅, {∅}} 2 d) {a, {a}, {a, {a}}} 3 12-Nov-18 Computer Science Department

Exercise 6: Let A = {1, 2, 3, 4, 5} and B = {0, 3, 6}. Find : a) A ∪ B {0, 1, 2, 3, 4, 5, 6} b) A ∩ B {3} c) A – B {1, 2, 4, 5} d) B – A {0, 6} 12-Nov-18 Computer Science Department

Exercise 7: For U = {1, 2,3, 4,5,6,7,8,9,10} let A = {1, 2,3,4,5} , B = {1,2, 4,8}, C = {1, 2,3,5,7}, and D = {2, 4,6,8} . Determine each of the following: a) (A∪B)∩C = b) A∪(B∩C)= c) C ∪ D = d) (A∪B)−C = e) A∪(B−C)= f) (B −C)−D = g) B−(C−D)= h) (A∪B)−(C ∩D)= i) A ⊕ B = {1,2,3,5} {1,2,3,4,5} {1, 2,3, 4, 5, 6, 7, 8} {4,8} {1,2,3,4,5,8} {} {2,4,8} {1,3,4,5,8} {3,5,8} 12-Nov-18 Computer Science Department

Exercise 8: Draw the VENN DIAGRAM of these sets and find (A∪B)−C and B′ A B C B 12-Nov-18 Computer Science Department

Exercise 9: Given the Universal set U={positive integers not larger than 12}, and the sets : A={positive integers not more than 6} B={3,4,6,7} , C={5,6,7,8,9,10} , Find : i) A U B = ii) | A−B |= iii) P(A‐B)=Power set of (A‐B)= {1,2,3,4,5,6,7} 3 {ф,{1},{2},{5},{1,2},{1,5},{2,5},{1,2,5}} 12-Nov-18 Computer Science Department

Refer to Chapter 2 for further reading 12-Nov-18 Computer Science Department