CS201: Data Structures and Discrete Mathematics I

Slides:



Advertisements
Similar presentations
Prof. Johnnie Baker Module Basic Structures: Sets
Advertisements

Sets Lecture 11: Oct 24 AB C. This Lecture We will first introduce some basic set theory before we do counting. Basic Definitions Operations on Sets Set.
Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Structures & Algorithms Basics of Set Theory EECE 320 — UBC.
Instructor: Hayk Melikya
(CSC 102) Discrete Structures Lecture 14.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Week 21 Basic Set Theory A set is a collection of elements. Use capital letters, A, B, C to denotes sets and small letters a 1, a 2, … to denote the elements.
Sets DISCRETE STRUCTURE ABDUL BASIT TAHIR, KAMRAN ALI, FAIZAN ILLAHI, NOMAN AHMAD, ARSALAN MUBASHIR.
Denoting the beginning
Analytical Methods in CS (CIS 505)
SET.   A set is a collection of elements.   Sets are usually denoted by capital letters A, B, Ω, etc.   Elements are usually denoted by lower case.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Sets 1.
Sets 1.
1 Set Theory. 2 Set Properties Commutative Laws: Associative Laws: Distributive Laws:
1 Set Theory. Notation S={a, b, c} refers to the set whose elements are a, b and c. a  S means “a is an element of set S”. d  S means “d is not an element.
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
Mathematics.
Operations on Sets – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Operations on Sets Reading: Kolman, Section 1.2.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
Chapter 3 – Set Theory  .
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Sets Defined A set is an object defined as a collection of other distinct objects, known as elements of the set The elements of a set can be anything:
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Chapter 7 Review Important Terms, Symbols, Concepts 7.1. Logic A proposition is a statement (not a question.
1 ENM 503 Block 1 Algebraic Systems Lesson 2 – The Algebra of Sets The Essence of Sets What are they?
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.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
Discrete Mathematics R. Johnsonbaugh
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.
Week 6 - Friday.  What did we talk about last time?  Solving recurrence relations.
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Basic Principles (continuation) 1. A Quantitative Measure of Information As we already have realized, when a statistical experiment has n eqiuprobable.
Chapter 2 With Question/Answer Animations. Section 2.1.
Introduction to Set theory. Ways of Describing Sets.
Discrete Mathematics Lecture # 10. Set Theory  A well defined collection of {distinct} objects is called a set.  The objects are called the elements.
Discrete Mathematics Set.
Basic probability Sep. 16, Introduction Our formal study of probability will base on Set theory Axiomatic approach (base for all our further studies.
1 Section 1.2 Sets A set is a collection of things. If S is a set and x is a member or element of S we write x  S. Othewise we write x  S. The set with.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Notions & Notations (2) - 1ICOM 4075 (Spring 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Spring.
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.
Basic Probability. Introduction Our formal study of probability will base on Set theory Axiomatic approach (base for all our further studies of probability)
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
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.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
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.
Dr. Ameria Eldosoky Discrete mathematics
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
The Language of Sets If S is a set, then
Discrete Mathematical The Set Theory
Set, Combinatorics, Probability & Number Theory
Sets Section 2.1.
CS 2210:0001 Discrete Structures Sets and Functions
What is Probability? Quantification of uncertainty.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Exercises Show that (P  Q)  (P)  (Q)
CS100: Discrete structures
Set Operations Section 2.2.
Discrete Mathematics CS 2610
Discrete Mathematics R. Johnsonbaugh
Presentation transcript:

CS201: Data Structures and Discrete Mathematics I Basic Set Theory 4/24/2017 CS 201

Sets A set is a collection of distinct objects. For example (let A denote a set): A = {apple, pear, grape} A = {1, 2, 3, 4, 5} A = {1, b, c, d, e, f} A = {(1, 2), (3, 4), (9, 10)} A = {<1, 2, 3>, <3, 4, 5>, <6, 7, 8>} A = a collection of anything that is meaningful. 4/24/2017 CS 201

Members and Equality of Sets The objects that make up a set are called members or elements of the set. Two sets are equal iff they have the same members. That is, a set is completely determined by its members. Order and repetition do not matter in a set. 4/24/2017 CS 201

Set notations The notation of {...} describes a set. Each member or element is separated by a comma. E.g., S = {apple, pear, grape} S is a set The members of S are: apple, pear, grape Order and repetition do not matter in a set. The following expressions are equivalent: {1, 3, 9} {9, 1, 3} {1, 1, 3, 3, 9} 4/24/2017 CS 201

The membership symbol  and the empty set  The fact that x is a member of a set S can be expressed as x  S Reads: x is in S, or x is a member of S, or X belongs to S An example, S = {1, 2, 3}, 1  S, 2  S, 3  S The negation of  is written as  (is not in). The empty set is a set without any element Denoted by {} or  For any object x, x   4/24/2017 CS 201

Defining a Set by membership properties Notation S = {x  T | P(x)} (or S = {x | x  T and P(x)}) The members of S are members of an already known set T that satisfy property P. An example: Let Z be the set of integers Let Z+ be the set of positive integers. Z+ = {x  Z | x > 0} 4/24/2017 CS 201

Sets of numbers Z = The set of all integers Z+ = The set of positive integers Z+ = {1, 2, 3…} = {x | x  Z and x > 0} = {x  Z | x > 0} Z- = The set of negative integers Z- = {…, -3, -2, -1} = {-1, -2, -3…} = {x  Z | x < 0} R = The set of all real numbers Q = the set of all rational numbers Q = {x  R | x = p/q and p, q  Z and q  0} We can use “;” to replace “and” 4/24/2017 CS 201

Subsets A is a subset () of B, or B is a superset of A iff every member of A is a member of B. A  B iff forall x if x  A, then x  B An example: (-2, 0, 6}  {-3, -2, -1, 0, 1, 3, 6} Negation: A is not a subset of B or B is not a superset of A iff there is a member of A that is not a member of B A  B iff there exist x, x  A, x  B 4/24/2017 CS 201

Obvious subsets S  S   S By contradiction: if   S then there exist x, x   and x  S. 4/24/2017 CS 201

Proper subsets A is a proper subset () of B, or B is a proper superset of A iff A is a subset of B and A is not equal to B. A  B iff A  B and A  B Examples: {1, 2, 3}  {1, 2, 3, 4, 5} Z+  Z  Q  R If S   then   S 4/24/2017 CS 201

Power sets The set of all subsets of a set is called the power set of the set The power set of S is denoted by P(S). Example: P() ={} P({1, 2}) = {, {1}, {2}, {1, 2}} P(S) = {, …, S} What is P({1, 2, 3})? How many elements does the power set of S have? Assume S has n elements. 4/24/2017 CS 201

 and  are different Examples: 1  {1} is true 1  {1} is false {1}  {1} is true Which of the following statement is true? S  P(S) S  P(S) 4/24/2017 CS 201

Mutual inclusion and set equality Sets A and B have the same members iff they mutually include A  B and B  A That is, A = B iff A  B and B  A Mutual inclusion is very useful for proving the equality of sets To prove an equality, we prove two subset relationships. 4/24/2017 CS 201

An example: equality of sets Recall that Z = the set of (all) integers Let A = {x  Z | x = 2m for m  Z } Let B = {x  Z | x = 2n-2 for n  Z } To show A  B, note that 2m = 2(m+1) – 2 = 2n-2 To show that B  A, note that 2n-2=2(n-1) = 2m That is, A = B. (A, B both denote the set of all even integers. 4/24/2017 CS 201

Universal sets Depending on the context of discussion Examples: Define a set of U such that all sets of interest are subsets of U. The set U is known as a universal set Examples: When dealing with integers, U may be Z. When dealing with plane geometry, U may be the set of points in the plane 4/24/2017 CS 201

Venn diagram Venn diagram is used to visualize relationships of some sets. Each subset (of U, the rectangle) is represented by a circle inside the rectangle. 4/24/2017 CS 201

Set operations Let A, B be subsets of some universal set U. The following set operations create new sets from A and B. Union: A  B = {x  U | x  A or x  B} Intersection: A  B = {x  U | x  A and x  B} Difference: A  B = A \ B= {x  U | x  A and x  B} Complement A = U  A = {x  U | x  A} 4/24/2017 CS 201

Set union An example {1, 2, 3}  {1, 2, 4, 5} = {1, 2, 3, 4, 5} The venn diagram 5 1 4 3 2 4/24/2017 CS 201

Set intersection An example {1, 2, 3}  {1, 2, 4, 5} = {1, 2} The venn diagram 5 1 4 3 2 4/24/2017 CS 201

Set difference An example {1, 2, 3} - {1, 2, 4, 5} = {3} The venn diagram 5 1 4 3 2 4/24/2017 CS 201

Set complement The venn diagram 4/24/2017 CS 201

Some questions Let A  B. What is A – B? What is B – A? If A, B  C, what can you say about A  B and C? If C  A, B, what can you say about C and A  B? 4/24/2017 CS 201

Basic set identities (equalities) 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  C) = (A  B)  (A  C) A  (B  C) = (A  B)  (A  C) 4/24/2017 CS 201

Basic set identities (cont …) Identity laws   A = A   = A A  U = U  A = A Double complement law (A’)’ = A Idempotent laws A  A = A A  A = A De Morgan’s laws (A  B)’ = A’  B’ (A  B)’ = A’  B’ 4/24/2017 CS 201

Basic set identities (cont …) Absorption laws A  (A  B) = A A  (A  B) = A Complement law (U)’ =  ’ = U Set difference law A – B = A  B’ Universal bound law A  U = U A   =  4/24/2017 CS 201

Proof methods There are many ways to prove set identities The methods include Applying existing identities Using mutual inclusion Prove (A  B)  C = A  (B  C) using mutual inclusion First show: (A  B)  C  A  (B  C) Let x  (A  B) and x  C (x  A and x  B) and x  C x  A and x  (B  C) x  A  (B  C) Then show that A  (B  C)  (A  B)  C 4/24/2017 CS 201

More proof examples Let B = {x | x is a multiple of 4} A = {x | x is a multiple of 8} Then we have A  B Proof: let x  A. We must show that x is a multiple of 4. We can write x = 8m for some integer m. We have x = 8m = 2*4m = 4 k, where k = 2m, so k is a integer. Thus, x is a multiple of 4, and therefore x  B 4/24/2017 CS 201

More proof examples Prove {x | x  Z and x  0 and x2 < 15} Let A = {x | x  Z and x  0 and x2 < 15} B = {x | x  Z and x  0 and 2x < 7} Let x  A. x can only be 0, 1, 2, 3 2x for 0, 1, 2, 3 are all less then 7. Thus, A  B. Likewise, we can also show that B  A 4/24/2017 CS 201

Algebraic proof examples Prove: [A  (B  C)]  ([A’  (B  C)]  (B  C)’) =  Proof: [A  (B  C)]  ([A’  (B  C)]  (B  C)’) = ([A  (B  C)]  [A’  (B  C)])  (BC)’ (associative) = ([(B  C) A]  [(B  C)  A’])  (BC)’ (commutative) = [(B  C) (A  A’)]  (B  C)’ (distributive) = [(B  C) ]  (B  C)’ (complement) = (B  C)  (B  C)’ (Identity) =  (identity) 4/24/2017 CS 201

Algebraic proof examples Prove: (A  B) – C = (A – C)  (B – C) Proof: (A  B) – C = (A  B)  C’ (difference) = C’  (A  B) (commutative) = (C’  A)  (C’  B) (distributive) = (A  C’)  (B  C’) (commutative) = (A – C)  (B – C) (difference) 4/24/2017 CS 201

Disproving an alleged Set property Is the following true? (A – B)  (B – C) = A – C Solution: Draw a Venn diagram and construct some sets to confirm the answer Counterexample: A = {1, 2, 4, 5}, B = {2, 3, 5, 6}, and C = {4, 5, 6, 7} A – B = {1, 4}, B – C = {2, 3}, A – C = {1, 2} (A – B)  (B – C) = {1, 2, 3, 4} 4/24/2017 CS 201

Pigeonhole principle If more than k pigeons fly into k pigeonholes, then at least one hole will have more than one pigeon. Pigeonhole principle: if more than k items are placed into k bins, then at least one bin contains more than one item. Simple, and obvious!! To apply it, may not be easy sometimes. Need to be clever in identifying pigeons and pigeonholes. 4/24/2017 CS 201

Example How many people must be in a room to guarantee that two people have last names that begin with the same initial? 27 since we have 26 letters How many times must a single die be rolled in order to guarantee getting the same value twice? 7 4/24/2017 CS 201

Another example Prove that if four numbers are chosen from the set {1, 2, 3, 4, 5, 6}, at least one pair must add up to 7. Proof: There are 3 pairs of numbers from the set that add up to 7, i.e., (1, 6), (2, 5), (3, 4) Apply pigeonhole principle: bins are the pairs, and the numbers are the items. 4/24/2017 CS 201

Infinite sets In a finite set, we can always designate one element as the first member, s1, another element as the second member, s2 and so on. If there are k elements in the set we can list them as s1, s2, …, sk A set that is not finite is called a infinite set. If a set is infinite, we may still be able to select a first element s1, a second element s2 and so on: s1, s2, … Such an infinite set is said to be denumerable. Both finite and denumerable sets are countable. Countable does not mean we can give a total number, but means that we can say, “here is the first one” and “here is the second one” and so on. 4/24/2017 CS 201

Countable sets: examples The set of positive integer numbers are countable. To prove it, we need to give a counting scheme, in this case, 1, 2, 3, 4, …. The set of positive rational numbers are countable 1/1 1/2 1/3 1/4 … 2/1 2/2 2/3 2/4… 3/1 3/2 3/3 3/4 … 4/24/2017 CS 201

Uncountable sets There are also some sets that are uncountable. The set is so large, and there is no way to count out the elements. One example: The set of real numbers between 0 and 1 is uncountable. A computer can only manage finite sets. 4/24/2017 CS 201

Summary Sets are extremely important for Computer Science. A set is simply an unordered list of objects. Set operations: union, intersection, difference. To prove set equalities Applying existing identities Using mutual inclusion Pigeonhole principle 4/24/2017 CS 201