0% found this document useful (0 votes)
47 views18 pages

09 Sets21

lecture

Uploaded by

Lokesh Bohra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views18 pages

09 Sets21

lecture

Uploaded by

Lokesh Bohra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Discrete Mathematics for

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.

2. Use set builder notation &


logical equivalences.
3. Use a membership table.
4. Use a Venn diagram.
9-5
Method 1: Mutual Subsets
Example: Show A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).
n Part 1: Show A ∩ (B ∪ C) ⊆ (A ∩ B) ∪ (A ∩ C).

n Assume x∈A∩(B∪C), & show x∈(A∩B)∪(A∩C).

n We know that x∈A, and either x∈B or x∈C.

n Case 1: x∈A and x∈B. Then x∈A∩B,

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).

n Therefore, A∩(B∪C) ⊆ (A∩B)∪(A∩C).

n Part 2: Show (A∩B)∪(A∩C) ⊆ A∩(B∪C). (Try it!)

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

n Analog to truth tables in propositional logic.


n Columns for different set expressions.
n Rows for all combinations of memberships in
constituent sets.
n Use “1” to indicate membership in the
derived set, “0” for non-membership.
n Prove equivalence with identical columns.

9-8
Membership Table Example
n Prove (A ∪ B) - B = A - B.

A B A∪B (A∪B)−B A−B


1 1 1 0 0
1 0 1 1 1
0 1 1 0 0
0 0 0 0 0
9-9
Membership Table Exercise
n Prove (A ∪ B) - C = (A - C) ∪ (B - C).

A B C A∪B (A∪B)−C A−C B−C (A−C)∪(B−C)


11 1 1 0 0 0 0
11 0 1 1 1 1 1
10 1 1 0 0 0 0
10 0 1 1 1 0 1
01 1 1 0 0 0 0
01 0 1 1 0 1 1
00 1 0 0 0 0 0
00 0 0 0 0 0 0

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

n Since union & intersection are commutative


and associative, we can extend them from
operating on pairs of sets A and B to
operating on sequences of sets A1,…, An, or
even on sets of sets, X = {A | P(A)}.

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

n More generally, union of the sets Ai for i ∈ I:


A
i∈I
i

n For infinite number of sets: 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

= {1,2,3,...} ∪ {2,3,4,...} ∪  ∪ {n, n + 1, n + 2,...}


= {1,2,3,...}
n Let Ai = {1, 2, 3,…,i } for i = 1, 2, 3,…. Then,

 A = A ∪ A ∪ A ∪
i =1
i 1 2 3

= {1} ∪ {1,2} ∪ {1,2,3} ∪ 


= {1,2,3,...} = +
9-14
Generalized Intersection
n Binary intersection operator: A ∩ B
n n-ary intersection:
A1 ∩ A2 ∩…∩ An ≡ ((…((A1 ∩ A2) ∩…) ∩ An)
(grouping & order is irrelevant)
n

n “Big Arch” notation: A


i =1
i

n Generally, intersection of sets Ai for i∈I: A


i∈I
i


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

= {1,2,3,...} ∩ {2,3,4,...} ∩  ∩ {n, n + 1, n + 2,...}


= {n, n + 1, n + 2,...}
n Let Ai = {1, 2, 3,…,i } for i = 1, 2, 3,…. Then,

A = A ∩A
i =1
i 1 2 ∩ A3 ∩ 

= {1} ∩ {1,2} ∩ {1,2,3} ∩ 


= {1}
9-16
Bit String Representation of Sets
n A frequent theme of this course are methods of
representing one discrete structure using another
discrete structure of a different type.
n For an enumerable universal set U with ordering
x1, x2, x3,…, we can represent a finite set S ⊆ U
as the finite bit string B = b1b2…bn where
bi = 1 if xi ∈S and bi = 0 if xi ∉S.
n E.g. U = N, S = {2,3,5,7,11}, B = 0011 0101 0001.

n In this representation, the set operators


“∪”, “∩”, “ ” are implemented directly by bitwise
OR, AND, NOT!
9-17
Examples of Sets as Bit Strings
n Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and the
ordering of elements of U has the elements in
increasing order, then
S1 = {1, 2, 3, 4, 5} ⇒ B1 = 11 1110 0000
S2 = {1, 3, 5, 7, 9} ⇒ B2 = 10 1010 1010
n S1 ∪ S2 = {1, 2, 3, 4, 5, 7, 9}
⇒ bit string = 11 1110 1010 = B1 ∨ B2
n S1 ∩ S2 = {1, 3, 5}
⇒ bit string = 10 1010 0000 = B1 ∧ B2
n S1 = {6, 7, 8, 9, 10}
⇒ bit string = 00 0001 1111 = ¬B1
9-18

You might also like