Sets
Sets
2)
Basic Structures:
• Sets
• Functions
• Sequences and Sums
• Cardinality of Sets
Sets
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 elements, or members
of the set. A set is said to contain its elements.
● The notation a ∈ A denotes that a is an element of
the set A.
● If a is not a member of A, write a ∉ A
3
Describing a Set:
Roster Method
● S = {a,b,c,d}
● Order not important
S = {a,b,c,d} = {b,c,a,d}
● Each distinct object is either a member or not; listing
more than once does not change the set.
S = {a,b,c,d} = {a,b,c,b,c,d}
● Elipses (…) may be used to describe a set without listing
all of the members when the pattern is clear.
S = {a,b,c,d,…,z }
4
Roster Method Examples
● Set of all vowels in the English alphabet:
V = {a,e,i,o,u}
● Set of all odd positive integers less than 10:
O = {1,3,5,7,9}
● Set of all positive integers less than 100:
S = {1,2,3,…,99}
● Set of all integers less than 0:
S = {…, -3,-2,-1}
5
Some Important Sets
N = natural numbers = {0,1,2,3….}
Z = integers = {…,-3,-2,-1,0,1,2,3,…}
Z⁺ = positive integers = {1,2,3,…..}
R = set of real numbers
R+ = set of positive real numbers
C = set of complex numbers.
Q = set of rational numbers
6
Set-Builder Notation
● Specify the property or properties that all members must
satisfy:
S = {x | x is a positive integer less than 100}
O = {x | x is an odd positive integer less than 10}
O = {x ∈ Z⁺ | x is odd and x < 10}
● A predicate may be used:
S = {x | P(x)}
● Example: S = {x | Prime(x)}
● Positive rational numbers:
Q+ = {x ∈ R | x = p/q, for some positive integers p,q, where q≠0}
7
Interval Notation
[a,b] = {x | a ≤ x ≤ b}
[a,b) = {x | a ≤ x < b}
(a,b] = {x | a < x ≤ b}
(a,b) = {x | a < x < b}
8
Universal Set and Empty Set
● The universal set U is the set containing everything
currently under consideration.
● Contents depend on the context. Venn Diagram
U
● The empty set is the set with no V
aei
elements. ou
• Symbolized by ∅ or {}.
The barber cannot shave himself as he only shaves those who do not shave themselves.
As such, if he shaves himself he ceases to be the barber.
12
the logical flaw of the naive set theory
If the barber does not shave himself, he needs to be shaved by a barber; so, he must shave
himself —> paradox!
This paradox depicts the need to set better definitions, a set of axioms that clarify the
case. (Shows the lacking of naive set theory.)
13
Russell’s Paradox
the logical flaw of the naive set theory
15
Set Equality
Two sets are equal if and only if they have the same elements.
{1,3,5} = {3, 5, 1}
{1,5,5,5,3,3,1} = {1,3,5}
16
Subsets
The set A is a subset of B, iff every element of A is also an element of B.
17
Subset Relation
● Showing that A is a Subset of B (A ⊆ B):
● if x belongs to A, then x also belongs to B.
● Showing that A is not a Subset of B (A ⊈ B):
● find an element x ∈ A with x ∉ B.
● such an x is a counterexample to the claim that x ∈ A
implies x ∈ B.
18
Equality of Sets Revisited
● Recall that two sets A and B are equal, denoted by
A = B, iff
● This is equivalent to
A ⊆ B and B ⊆ A
19
Proper Subsets (A ⊂ B)
If A ⊆ B, but A ≠ B, then we say A is a proper subset of B, denoted by A ⊂ B.
U
B
A
20
Set Cardinality
• |A|: the cardinality of set A.
• The number of distinct elements in A
• If there are exactly n distinct elements in S, (|S|=n), where n is a
nonnegative integer, we say that S is finite. Otherwise it is infinite.
Examples:
1. |ø| = 0
2. Let S be the letters of the English alphabet. Then |S| = 26
3. |{1,2,3}| = 3
4. |{ø}| = 1
5. The set of integers is infinite.
21
Power Sets (P(A))
The set of all subsets of A is called Power Set of A
22
Tuples
● The ordered n-tuple (a1,a2,…..,an): 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.
● Two n-tuples are equal if and only if their
corresponding elements are equal.
● 2-tuples are called ordered pairs.
● The ordered pairs (a,b) and (c,d) are equal if and only
if a = c and b = d.
23
René Descartes
(1596-1650)
Cartesian Product
The Cartesian Product of two sets A and B, denoted by A × B is the set of
ordered pairs (a,b) where a ∈ A and b ∈ B .
Example:
A = {a,b} B = {1,2,3}
A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}
24
René Descartes
(1596-1650)
Cartesian Product
The Cartesian Product of two sets A and B, denoted by A × B is the set of
ordered pairs (a,b) where a ∈ A and b ∈ B .
Example:
A = {a,b} B = {1,2,3}
A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}
25
Cartesian Product
26
Cartesian Product
• The cartesian products of the sets A1,A2,……,An, denoted by
A1 × A2 × …… × An , is the set of ordered n-tuples
(a1,a2,……,an) where ai belongs to Ai for i = 1, … n.
27
Cartesian Product
• The cartesian products of the sets A1,A2,……,An, denoted by
A1 × A2 × …… × An , is the set of ordered n-tuples
(a1,a2,……,an) where ai belongs to Ai for i = 1, … n.
28
Cartesian Product
• The cartesian products of the sets A1,A2,……,An, denoted by
A1 × A2 × …… × An , is the set of ordered n-tuples
(a1,a2,……,an) where ai belongs to Ai for i = 1, … n.
29
Truth Sets of Quantifiers
● Truth set of P to be the set of elements in D for which
P(x) is true. The truth set of P(x) is denoted by
30
Set Operations
Section 2.2
Boolean Algebra
● The operators in set theory are analogous to the
corresponding operators in propositional calculus.
● They are both instances of Boolean algebra.
● As always there must be a universal set U.
● All sets are assumed to be subsets of U.
32
Union
● The union of the sets A and B, denoted by A ∪ B, is
the set:
33
Intersection
● The intersection of sets A and B, denoted by A ∩ B, is
35
Difference
• The difference of the sets A and B, denoted by A – B, is
the set containing the elements of A that are not in B.
• The difference of A and B is also called the
complement of B with respect to A.
A – B = {x | x ∈ A ∧ x ∉ B} = A ∩ B
U
A
B
36
The Cardinality of the Union of Two
Sets
• Inclusion-Exclusion U
|A ∪ B| = |A| + | B| − |A ∩ B| A B
• Example: Let A be the math majors in your class and B be the CS majors. To
count the number of students who are either math majors or CS majors, add
the number of math majors and the number of CS majors, and subtract the
number of joint CS/math majors.
37
Review Questions
Example: U = {0,1,2,3,4,5,6,7,8,9,10} A = {1,2,3,4,5}, B ={4,5,6,7,8}
1. A∪B
Solution: ?
2. A ∩ B
Solution: ?
3. Ā
Solution: ?
4.
Solution: ?
5. A – B
Solution: ?
6. B – A
Solution: ?
38
Review Questions
Example: U = {0,1,2,3,4,5,6,7,8,9,10} A = {1,2,3,4,5}, B ={4,5,6,7,8}
1. A∪B
Solution: {1,2,3,4,5,6,7,8}
2. A ∩ B
Solution: {4,5}
3. Ā
Solution: {0,6,7,8,9,10}
4.
Solution: {0,1,2,3,9,10}
5. A – B
Solution: {1,2,3}
6. B – A
Solution: {6,7,8}
39
Symmetric Difference
The symmetric difference of A and B, denoted by
is the set
Example:
U = {0,1,2,3,4,5,6,7,8,9,10}
U
A = {1,2,3,4,5} B ={4,5,6,7,8}
A B
What is :
● Solution: ?
40
Symmetric Difference
The symmetric difference of A and B, denoted by
is the set
Example:
U = {0,1,2,3,4,5,6,7,8,9,10}
U
A = {1,2,3,4,5} B ={4,5,6,7,8}
A B
What is :
● Solution: {1,2,3,6,7,8}
41
Set Identities
● Identity laws
● Domination laws
● Idempotent laws
● Complementation law
● Associative laws
● Distributive laws
● Absorption laws
● Complement laws
44
Proving Set Identities
● 3 Different ways to prove set identities:
1. Prove that each set (each side of the identity) is a subset of
the other.
2. Use set builder notation and propositional logic.
3. Membership Tables: Verify that elements in the same
combination of sets always either belong or do not
belong to the same side of the identity.
• Use 1 to indicate it is in the set and a 0 to indicate
that it is not.
45
Proof of Second De Morgan Law
Using Subset Relation
Example: Prove that
Solution: We prove this identity by showing that:
1) and
2)
48
Proof of Second De Morgan Law
Using Set-Builder Notation
49
Using Membership Table
Example: Construct a membership table to show that the distributive law
holds.
Solution:
A B C
1 1 1 1 1 1 1 1
1 1 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 0 0 0 1 1 1 1
0 1 1 1 1 1 1 1
0 1 0 0 0 1 0 0
0 0 1 0 0 0 1 0
0 0 0 0 0 0 0 0 50
Generalized Unions and Intersections
● Let A1, A2 ,…, An be an indexed collection of sets.
We define:
51