Professional Documents
Culture Documents
Chapter4 Sets
Chapter4 Sets
Tannaz R.Damavandi
Cal Poly Pomona
Credit for some of the slides in this lecture goes to Dr.Fang Tang
Outline
• 4.1– Sets
• 4.2- Counting
• 4.3- Principle of Inclusion and Exclusion; Pigeonhole Principle
• 4.4- Permutation and Combinations
• 4.5 – Binomial Theorem
• 4.6 - Probability
2
Section 4.1 – Sets
Set Theory
• A set is a collection of elements or objects, and an element is a
member of a set.
– Traditionally, sets are described by capital letters, and elements by lower
case letters
• The symbol means belongs to:
– Used to represent the fact that an element belongs to a particular set.
– aA means that element a belongs to set A
– bA implies that b is not an element of A
• Braces {} are used to indicate a set
• Example: A = {2, 4, 6, 8, 10}
– 3A and 2A
4
Set Theory (Cont’d)
• Ordering is not imposed on the set elements.
• Each element of a set is listed only once; listing elements twice or
more is redundant.
• Two sets are equal if and only if they contain the same elements
A = B means (x)[(xA xB) Λ (xB xA)]
• Finite and infinite set: described by number of elements
Members of infinite sets cannot be listed but a pattern for
listing elements could be indicated
5
Various Ways To Describe A Set
Assume set S of all positive even integers:
1) List (or partially list) its elements:
S = {2, 4, 6, 8, …}
2) Use recursion to describe how to generate the set elements:
2 S, if n S, then (n+2) S
3) Describe a property P that characterizes the set elements
• in words: S = {x | x is a positive even integer}
• Use predicates: S = {x P(x)} means (x)[(xS P(x)) Λ (P(x) xS)] where P is the
unary predicate.
• Hence, every element of S has the property P and everything that has a property P is
an element of S.
6
Practice #1
• Describe each of the following sets by listing the elements:
a. {x | x is a month with exactly thirty days}
a. {April, June, September , November}
7
Practice #2
• Describe each of the following sets by giving a characterizing
property.
a. {1,4,9,16}
a. {x| x is one of the first four squares}
b. {2,3,5,7,11,13,17,…}
b. {x| x is a prime number}
8
Standard Sets
• Some notations used for convenience of defining sets
• N = set of all nonnegative integers
• remember that 0 N
• Z = set of all integers
• Q = set of all rational numbers
• R = set of all real numbers
• C = Set of all complex numbers
9
Examples
• What are the elements in the following sets?
• A = {x| (y)(y {0,1,2} and x = y2}
A={0,1,4}
• B = {x| x N and (y) (y N and x <= y)}
B=N
• C = {x| x N and (y) (y N x <= y)}
C={0}
• D = {x| (y)(z)(y{1,2} and z{2,3} and x=z–y)}
D= {0,1,2}
10
Open and Closed Interval
• {x R | -2 < x < 3}
– denotes the set containing all real numbers between -2 and 3. This
is an open interval, meaning that the endpoints -2 and 3 are not
included. By all real numbers, we mean everything; 1.05, -3/4, and
every other real number within that interval.
• {x R | -2 x 3}
– is a closed interval. It includes all the numbers in the open interval
described above, plus the endpoints.
11
Practice #3
Describe each following set.
• A = {x| x N and (y) (y {2,3,4,5} x ≥y)}
A={x|x N and x ≥5}
12
Relationships Between Sets: Subsets
For A={1,3,5,7} and B ={x| x is a positive odd number},
Every member of A is also a member of B. Therefore, A is said to be a
subset of B
• In formal logic: A B : (x) (x A → x B).
If A B and A B, then there is at least one element of B that is not an
element of A, then A is a proper subset of B denoted by A B.
• In formal logic:
A B : (x) (x A → x B) Λ (y)[yB Λ (yA)’]
Any set is a subset of itself, but not a proper subset. (X ⊆ X is true, and X X
is false for any set X.) The empty set { }, denoted by ∅, is also a subset of any
given set X. It is also always a proper subset of any set except itself.
13
Relationships Between Sets : Supersets
• A superset is the opposite of subset. If M is a subset of S, then S is a superset of
M, denoted S M. Likewise, if M is a proper subset of S, then S is a proper
superset of M, denoted S M.
• The cardinality of a set is simply the number of elements within the set; the
cardinality of S is denoted by |S|. Then by the above definition of subset, it is
clear that set M must have fewer members than S, which yields the following
symbolic representation:
• M S |M| < |S|
• M S |M| <= |S|
14
Example
Let
A = {1,7,9,15}
B = {7,9}
C = { 7,9,15,20}
AC 26 C
{12} B {12} B
{} B ∉A
16
Practice #4 Solution
A = {x| x N and x 5}
B = {10, 12, 16, 20}
C = {x | (y)(y N and x = 2y)}
Which of the following statements are true?
BC T BA T
AC F 26 C T
{12} B F {12} B T
{} B F ∉A T
17
Example
For the following sets, prove A B
A = { x | x R such that x2 – 4x + 3 = 0}
B = { x | x N and 1 x 4}
18
Set of Sets
• From every set, many subsets can be generated. A set whose
elements are all such subsets is called the power set.
• For a set S, (S) is termed as the power set.
• For a set S = {1, 2, 3} ;
(S) = { ,{1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}
• For a set with n elements, the power set has 2n elements.
Note : ()={}
19
Set Operations
• Binary and unary operators
– Binary acts on two elements.
– Unary acts on a single element.
20
Binary Operations
• Binary operation on a set S defined as follows:
– is a binary operation if for every ordered pair (x,y) of elements of S, x y exists,
and is unique, and is a member of S.
– The fact that x y exists and is unique is the same as saying that the binary
operation is well-defined.
– The fact that x y always belongs to S means that S is closed under the
operation
• The operator is just a placeholder for the real operator like +, -, *, etc.
21
Examples
• +, - and * are all binary operators on Z.
• Is division a binary operation on Z and why? No, because X/0
does not exist.
22
Examples
Define x◦y on N by :
1 if x ≥ 5
x◦y =
0 if x ≤ 5
Then by the first definition for ◦ , 5 ◦1 = 1, while by its second
definition 5 ◦1 = 0 . Thus, ◦ is not well defined on N because the
result of 5 ◦1 is not unique.
23
Unary Operation
• For # to be a unary operation on a set S, it must be true that for
any x S, x# is well-defined and S is closed under #; in other
words, for any x S, x# exists, it is unique and member of S.
• Let x^ = -x, so that x^ is the negative of x.
– Is ^ a unary operation on Z? Yes
– Is ^ a unary operation on N? No, because N is not closed under ^.
24
Practice #5
25
Operations On Sets
New sets can be formed in a variety of ways, and can be described
using:
• Set builder notation (union, intersection, complement, etc.)
• Venn diagrams.
A rectangle marked by U is used to represent the universal set.
Venn diagrams can be used to visualize the binary operations of union
and intersection.
26
Union and Intersection
27
Disjoint, Universal and Difference Sets
28
Example
29
Cartesian Product
• If A and B are subsets of S, then the Cartesian product or cross
product of A and B denoted symbolically by A B is defined by:
• A B = {(x,y) | x A and y B }
• For example, given 2 sets A and B, where A = {a, b, c} and B = {1, 2, 3},
the Cartesian product of A and B can be represented as:
• A B = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3), (c, 1), (c, 2), (c, 3)}
• Is A B = B A ?
30
Cartesian Product (Cont’d)
• Cross-product of a set with itself is represented as A A or A2
31
Practice #6
• Given A = {1,2} and B = {3,4} ; find
• AB;BA
• A2 and A3
A B = {(1,3),(1,4),(2,3),(2,4)}
B A = {(3,1),(3,2),(4,1),(4,2)}
A2 = {(1,1),(1,2),(2,1),(2,2)}
A3 = (1,1,1),(1,1,2),(1,2,1),(1,2,2),(2,1,1),(2,1,2),(2,2,1),(2,2,2)}
32
Basic Set Identities
33
More Set Identities
Union and Intersection with U
A∪U=U A∩U=A
Double Complement Law
(A) = A
Idempotent Laws
A∪A =A A∩A =A
Absorption properties
A ∪ (A ∩ B) = A A ∩ (A ∪ B) = A
Alternate Set Difference Representation
A - B = A ∩ B
Inclusion in Union
AA∪B BA∪B
Inclusion in Intersection
A∩BA A∩BB
Transitive Property of Subsets
if A B, and B C, then A C
34
Practice #7
• Use the set identities to 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) using ap
= ([(B ∩ C) ∪ A] ∩ [(B ∩ C) ∪ A]) ∩ (B ∩ C) using cp twice
= [(B ∩ C) ∪ (A ∩ A)] ∩ (B ∩ C) using dp
= [(B ∩ C) ∪ ] ∩ (B ∩ C) using comp
= (B ∩ C) ∩ (B ∩ C) using ip
= using comp
35
Section 4.2 – Counting
Counting
Combinatorics is a branch of mathematic that deals with counting. The idea
is to find out how many members are present in a finite set, that is, the
cardinality of the set.
Examples :
• How many rows are there in a truth table with n statement letters? 2n
• How many subsets are there in a set with n elements? 2n
Multiplication Principle
Multiplication principle: If there are n possible outcomes for a first event
and m possible outcomes for a second event, then there are n*m possible
outcomes for the sequence of the two events.
Solution:
We can construct four-digit numbers by performing a sequence of
subtasks: choose the first digit, then the second, the third, and finally
the fourth.
a) 10.10.10.10 =10000
b) 10.9.8.7 = 5040
40
Practice #8
If a man has 4 suits, 8 shirts and 5 ties, how many outfits can he
put together?
Sequence of tasks:
Choose a suit
Choose a shirt
Choose a tie
(4)(8)(5)= 160
41
Addition Principle
Addition Principle: If A and B are disjoint events with n and m
outcomes, respectively, then the total number of possible
outcomes for event “A or B” is n+m
• If A and B are disjoint sets, then |A ∪ B| = |A| + |B| using the
addition principle.
42
Example
A customer wants to purchase a vehicle from a dealer. The dealer
has 23 autos and 14 trucks in stock. How many selections does the
customer have?
The customer wants to choose a car or a truck. These are disjoint
events; therefore, by addition principle customer has 37 choices:
23+14=37
43
More On Addition Principle
• If A and B are disjoint sets, then |A ∪ B| = |A| + |B| (1)
• Solution2 :
numbers begin with 4 or 5 : 2*10*10*10 = 2000
45
Practice #9
Suppose the last four digit of a telephone number must include at least one
repeated digit. How many such numbers are there?
Hint: use subtraction
Although it is possible to do this problem by using the addition principle directly, it is difficult
because there are so many disjoint cases to consider depends on which two digits are alike.
Instead, we solve the problem by noting that numbers with repetitions and numbers with no
repetitions are disjoint sets whose union equals all four-digit numbers.
Total numbers = numbers with repetition + numbers w/o repetition
Total numbers = 10*10*10*10 =10000
Numbers with no repetition = 10*9*8*7 = 5040
Numbers with repetition = 10000 – 5040 = 4960
46
Practice #10
• How many three-digit integers (numbers between 100 and 999 inclusive) are
even?
47
Section 4.3 – Principle of Inclusion and Exclusion;
Pigeonhole Principle
Principle of Inclusion and Exclusion
If A and B are any subsets of a universal set S, then A – B, B – A, and A ∩ B are
mutually distinct.
• We can see that (A-B) ∪ (B-A) ∪ (A ∩ B) is exactly A ∪ B
• For three disjoint sets
|(A-B) ∪ (B-A) ∪ (A ∩ B)| = |A-B| + |B-A| + |A ∩ B|
• |A-B| = |A| - |A ∩ B|
• |B-A| = |B| - |A ∩ B|
• We finally get:
|A ∪ B| = |A| + |B| - |A ∩ B|
49
Inclusion and Exclusion
• |A ∪ B| = |A| + |B| - |A ∩ B|
• The above equation represents the principle of inclusion and
exclusion
• The name comes from the fact that to calculate the elements in
a union:
We include the individual elements of A and B
but exclude the elements common to A and B so that we don't count
them twice
50
Example
How many integers from 1 to 1000 are either multiples of 3 or multiples of 5 ?
• We assume that A = {set of all integers from 1-1000 that are multiples of 3}
• We assume that B = {set of all integers from 1-1000 that are multiples of 5}
• We have
A ∪ B = {set of all integers from 1 to 1000 that are multiples of either 3 or 5}
A ∩ B = {set of all integers that are both multiples of 3 and 5, which is 15}
• To use the inclusion/exclusion principle to obtain |A ∪ B| , we need
|A| ,|B| and |A ∩ B|
51
Example(Cont’d)
From 1 to 1000, every third integer is a multiple of 3,each of this multiple can be
represented as 3p, for any integer p from 1 through 333, Hence |A| = 333.
Similarly for multiples of 5, each multiple of 5 is of the form 5q for some integer q
from 1 through 200. Hence, we have |B| = 200
Hence, |A ∩ B| = 66
From the principle, we have the number of integer either multiples of 3 or
multiples of 5 from 1 to 1000 given by
54
Example
A group of students plans to order pizza. If 13 will eat sausage topping, 10 will eat
pepperoni, 12 will eat extra cheese, 4 will eat both sausage and pepperoni, 5 will
eat both pepperoni and extra cheese , 7 will eat both sausage and extra cheese,
and 3 will eat all three toppings, how many student are in the group?
b. Assume:
A = {All the students who know Java in class}
B = {All the students who know Python in the class}
C = {All the students who know C++ in class}
So, we need to find |A ∩ B ∩ C|
58
Practice#12- Solution (Cont’d)
Then |A|=30, |B|=18 , |C|=26 , |A ∩ B|=9 , |B ∩ C|=8, |A ∩ C|=16,
and | A ∪ B ∪ C | = 47
| A ∪ B ∪ C | = |A| + |B| + |C| - |A ∩ B| - |B ∩ C|- |A ∩ C|+ |A ∩ B ∩ C|
47 = 30 + 18 + 26 – 9 – 8 - 16 + |A ∩ B ∩ C|
47 = 41 + |A ∩ B ∩ C|
|A ∩ B ∩ C| = 6
59
General Principle of Inclusion/Exclusion
60
Pigeonhole Principle
If more than k items are placed into k bins, then at least one bin has more than one
item.
from Wikipedia
61
Examples
How many people must be in a room to guarantee that two people have the last
name begin with the same initial?
26 alphabets hence, have to have 27 people.
How many times must a single die be rolled in order to guarantee getting the same
value twice?
6 possible outcomes, hence 7 times.
How many cards must be drawn from a standard 52-card deck to guarantee 2 cards
of the same suit?
4 suits (hearts, clubs, spades, diamonds), Hence 4+1= 5 draw
62
Section 4.4 -Permutations and Combinations
Permutations
• In our example of counting all possibilities for the last four digits of a telephone
number with no repetition, we see that order matters. For example 1234 is not the
same as 4321 or 3214.
• An ordered arrangement of objects is called a permutation.
• Each of these numbers (1234, 4321 ,…) is a permutation of 4 distinct objects chosen
from a set of 10 distinct objects (10 digits).
– Hence, a permutation of n distinct elements is an ordering of these n elements.
• P(n , r) denotes the number of permutations of r distinct objects chosen from n distinct
objects.
• A formula for P(n,r) can be written using the factorial functions, for 0≤ r ≤ n
a) P(7,3)
b) P(9,6)
c) P(8,0)
d) P(5,5)
e) P(6,1)
65
Special cases of Permutation
66
Example
67
Example
68
Practice #14
Practice #15
In how many ways a librarian can arrange 4 books on Operating
systems, 7 on Programming, and 3 on Data structure on a shelf
given that all books on the same subject must be together?
P(n, r ) n!
C (n, r )
r! r ! n r !
71
Practice #16
P(n, r ) n!
C (n, r )
r! r ! n r !
72
Special cases of Combinations
73
Important Note
74
Examples
75
Examples
76
Examples
77
Practice #17
78
Eliminating Duplicates
• How many ways can a committee of 2 be formed from 4 men and 3
women and it must include at least 1 man
Incorrect answer : C(4,1)*C(6,1) , because group of m1 and m2 is the
same as m2 and m1
Correct answer:
C(7,2) – C(3,2) = C(4,1)*C(6,1) – C(4,2)
C(4,2) is the number of committees with 2 men on it. It has to be
subtracted since we are counting it twice in C(4,1)*C(6,1)
C(7,2) = all committees possible
C(3,2) = all committees with no men on it
79
Examples
80
General Formula
81
Permutations and Combinations with Repetitions
Our formulas for P(n, r) and C(n, r) assume that we select r objects out
of n objects using each object only once, therefore r ≤ n. Suppose,
however, that the n objects are available for reuse as many times as
desired. Hence r might be greater than n.
• Counting the number of permutations of r objects out of n distinct
objects with repetition: nr, for example the 4-digit telephone
example with repetition.
83
Combination with Repetition
• General principle of combination with repetition:
If we want to select r objects out of n distinct objects with repetition
allowed, there must be n-1 markers.
This gives r + (n-1) slots to fill.
And we want to know the number of ways to select r of r + (n-1).
Hence :
(r n 1)! (r n 1)!
C (r n 1, r )
r ! r n 1 r ! r ! n 1!
84
Practice #18
85
Counting Techniques
Count the number of… Technique to Try
Elements in overlapping sections of related sets Use principle of inclusion and exclusion
86