3 Set Operations
3 Set Operations
able to:
Understand the basic concepts on sets.
Perform operations on sets..
Agenda
Union
Intersection
Difference “-”
Complement “ ”
Symmetric Difference
Set theoretic operations allow us to build new
sets out of old sets. Given sets A and B, the
set theoretic operators are:
Union ()
Intersection ()
Difference (-)
Complement (“—”)
Symmetric Difference ()
giving us new sets AB, AB, A-B, AB,
andA
Venn diagrams are useful in representing sets
and set operations.
Various sets are represented by circles inside
a big rectangle representing the universe of
reference.
Union
Elements in at least one of the two sets:
AB = { x | x A x B }
U
AB
A B
Intersection
Elements in exactly one of the two sets:
AB = { x | x A x B }
U
A AB B
Disjoint Sets
If A and B have no common elements, they
are said to be disjoint, i.e. A B = .
U
A B
Disjoint Union
When A and B are disjoint, the disjoint union
operation is well defined. The circle above
the union symbol indicates disjointedness.
U
A B
A B
Disjoint Union
FACT: In a disjoint union of finite sets,
cardinality of the union is the sum of the
cardinalities.
I.e.
A B A B
Inclusion-Exclusion Principle
| A B | | A| | B | - | A B |
Inclusion-Exclusion Principle.
U
AB
A-(BC ) -ABC ( B- AC)
ABC
AC BC
-ABC -ABC
C-(AB)
| A B C | | A| | B | | C | - | A B | - | AC | - | B C | | A B C |
Example:
A 1,4,5,7
B 2,4,6,7 1 4 2
C 3,5,6,7
5 76
3
| A B C |
1 2 3 4 5 6 7
(1 4 5 7) (2 4 6 7) - 4 - 7 (3 5 6 7) - 4 - 6 - 7
| A | | B | | C | -( 4 5 6 7 7)
| A | | B | | C | -([ 4 7] [5 7] [6 7] - 7)
| A | | B | | C | -(| A B | | A C | | B C | - | A B C |)
| A| | B | | C | - | A B | - | AC | - | B C | | A B C |
Example:
How many numbers between 1 and 1000
(inclusive) are divisible by 3, 5, or 7.
L20 14
Answer:
Use the formula that the number of positive integers
up to N which are divisible by d is N/d.
With I-E-I principle get and the fact that for
relatively prime a, b both numbers divide x iff their
product ab divides x :
Total = 1000/3 + 1000/5 + 1000/7 - 1000/15
- 1000/21 - 1000/35 + 1000/105
L20 15
Set Difference.
Elements in first set but not second.
A-B = { x | x A x B }
U
A-B B
A
Theorem:
Let A and B be sets. Then
A-B and B-A are disjoints
A-B and A∩B are disjoints
B-A and A∩B are disjoints
A = (A-B)U(A∩B)
A UB = (A-B)U(A∩B) U(B-A)
A is a subset of B ↔ A-B=Ǿ
Symmetric Difference.
Elements in exactly one of the two sets:
AB = { x | x A x B }
AB U
A B
Theorem:
Let A and B be sets. Then
AǾ= A
A A =Ǿ
AB=BA
Complement.
Elements not in the set (unary operator):
A = { x | x U, x A }
A A
DeMorgan’s Laws.
DeMorgan’s Laws are among the most
important and useful results about sets.
These laws describe how union, intersection,
and complement are related.
Let A and B be sets. Then
A B A B
A B A B
DeMorgan’s Laws.
It’s often simpler to understand an identity
by drawing a Venn Diagram.
For example DeMorgan’s first law
A B A B
can be visualized as follows.
Visual DeMorgan
A: B:
L5 23
Visual DeMorgan
A: B:
AB :
L5 24
Visual DeMorgan
A: B:
AB :
A B :
L5 25
Visual DeMorgan
A: B:
L5 26
Visual DeMorgan
A: B:
A: B:
L5 27
Visual DeMorgan
A: B:
A: B:
A B :
L5 28
Visual DeMorgan
A B
=
A B
L5 29
Cartesian Product
The most famous example of 2-tuples are
points in the Cartesian plane R2.
Here ordered pairs (x,y) of elements of R
describe the coordinates of each point.
We can think of the first coordinate as the
value on the x-axis and the second coordinate
as the value on the y-axis.
DEF: The Cartesian product of two sets A and B
–denoted by A B– is the set of all ordered pairs
(a, b) where aA and bB .
Q: If A = {1,2}, B = {3,4}, C = {5,6,7}
what is A B ?
what is B A?
what is A C ?
what is C B ?
One can generalize the Cartesian product
to several sets simultaneously.
Q: If A = {1,2}, B = {3,4}, C = {5,6,7}
what is A B C ?
Answer:
If A = {1,2}, B = {3,4}, C = {5,6,7}
Answer:
0111 represents {beetle, cicada, dragonfly}
Conveniently, under this representation the
various set theoretic operations become the
logical bit-string operators that we saw before.
For example, the symmetric difference of {beetle}
with {ant, beetle, dragonfly} is represented by:
0100 1101 = 1001
= {ant, dragonfly}
Example:
let U = {1, 2, 3, . . ., 9}. A bit representation
for X is a binary number
x1 x2 x3 ... x9
with bit xi defined as
1 i X
x i if
0 i X
Answer:
Two students are taking neither class. There are 38 students in at least one of the classes.
There is a 24/40 = 0.6 = 60% probability that a randomly-chosen student in this group is taking
Chemistry but not English.
Example:
Suppose n(U) = 150, n(A) = 37, and n(B) = 84.
a) If n( A U B) = 100, find n( A n B) and draw a
Venn diagram illustrating the composition of U.
b) How many elements belong to A only?
Answer:
Example:
In a commercial survey involving 1000 persons
on brand preferences, 120 were found to
prefer brand x only, 200 persons prefer brand
y only, 150 persons prefer brand z only, 370
prefer either brand x or y but not z, 450
prefer brand y or z but not x, and 370 prefer
either brand z or x but not y, and none prefer
all the three brands at a time. How many
persons have no brand preference with any of
the three brands?
Example:
From a survey of 100 college students, a
marketing research company found that 75
students owned stereos, 45 owned cars, and 35
owned cars and stereos.
a) How many students owned either a car or a
stereo?
b) How many students did not own either a car
or a stereo?
Answer:
Example:
Suppose I discovered that my cat had a taste for the
adorable little geckoes that live in the bushes and vines in
my yard. In one month, suppose he deposited the following
on my carpet: six gray geckoes, twelve geckoes that had
dropped their tails in an effort to escape capture, and
fifteen geckoes that he'd chewed on a little. Only one of the
geckoes was gray, chewed on, and tailless; two were gray and
tailless but not chewed on; two were gray and chewed on but
not tailless. If there were a total of 24 geckoes left on my
carpet that month, and all of the geckoes were at least one
of "gray", "tailless", and "chewed on", how many were tailless
and chewed on but not gray?
Hint:
let "x“ stand for the number of tailless, chewed-on
geckoes.