09 Sets21
09 Sets21
Computer Science I
9-1
Lecture 9
Chapter 2. Basic Structures
2.2 Set Operations
9-2
Set Identities
n Identity: A∪∅=A=A∩U
n Domination: A∪U=U, A∩∅=∅
n Idempotent: A∪A=A,A∩A=A
n Double complement: (A) = A
n Commutative: A ∪ B = B ∪ A, A ∩ B = B ∩ A
n Associative: A ∪ (B ∪ C) = (A ∪ B) ∪ C,
A ∩ (B ∩ C) = (A ∩ B) ∩ C
n Distributive: A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C),
A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
n Absorption: A ∪ (A ∩ B) = A, A ∩ (A ∪ B) = A
n Complement: A ∪ A = U, A ∩ A = ∅
9-3
DeMorgan’s Law for Sets
n Exactly analogous to (and provable from)
DeMorgan’s Law for propositions.
A∪ B = A ∩ B
A∩ B = A ∪ B
9-4
Proving Set Identities
n To prove statements about sets, of the form
E1 = E2 (where the Es are set expressions),
here are three useful techniques:
1. Prove E1 ⊆ E2 and E2 ⊆ E1 separately.
so x∈(A∩B)∪(A∩C).
n Case 2: x∈A and x∈C. Then x∈A∩C,
so x∈(A∩B)∪(A∩C).
n Therefore, x∈(A∩B)∪(A∩C).
9-6
Method 2: Set Builder Notation
& Logical Equivalence
n Show A ∩ B = A ∪ B
A ∩ B = {x | x ∉ ( A ∩ B)} def. of complement
= {x | ¬( x ∈ ( A ∩ B))} def. of “does not belong”
= {x | ¬( x ∈ A ∧ x ∈ B)} def. of intersection
= {x | ¬( x ∈ A) ∨ ¬( x ∈ B)} De Morgan’s law (logic)
= {x | x ∉ A ∨ x ∉ B} def. of “does not belong”
= {x | x ∈ A ∨ x ∈ B } def. of complement
= {x | x ∈ A ∪ B } def. of union
= A∪B by set builder notation
9-7
Method 3: Membership Tables
9-8
Membership Table Example
n Prove (A ∪ B) - B = A - B.
9-10
Method 4: Venn Diagram
n Prove (A ∪ B) - C = (A - C) ∪ (B - C).
A A
B C B C
A∪B (A ∪ B) – C
A A A
B C B C B C
A–C B–C (A – C) ∪ (B – C)
9-11
Generalized Unions &
Intersections
9-12
Generalized Union
n Binary union operator: A ∪ B
n n-ary union:
A1 ∪ A2 ∪…∪ An = ((…((A1 ∪ A2) ∪…) ∪ An)
(grouping & order is irrelevant)
n
“Big U” notation:
n
A
i =1
i
9-13
Generalized Union Examples
n Let Ai = {i, i+1, i+2,…}. Then,
n
A = A ∪A
i =1
i 1 2 ∪ A3 ∪ ∪ An
A = A ∪ A ∪ A ∪
i =1
i 1 2 3
∞
n For infinite number of sets: A
i =1
i
9-15
Generalized Intersection Examples
n Let Ai = {i, i+1, i+2,…}. Then,
n
A = A ∩A
i =1
i 1 2 ∩ A3 ∩ ∩ An
A = A ∩A
i =1
i 1 2 ∩ A3 ∩