university of hawaii ics141: discrete mathematics for computer science...
TRANSCRIPT
9-1 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii
ICS141: Discrete Mathematics for Computer Science I
Dept. Information & Computer Sci., University of Hawaii
Jan Stelovsky based on slides by Dr. Baek and Dr. Still
Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by McGraw-Hill
9-2 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii
Lecture 9
Chapter 2. Basic Structures 2.2 Set Operations
9-3 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii 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-4 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii DeMorgan’s Law for Sets
n Exactly analogous to (and provable from) DeMorgan’s Law for propositions.
BABA
BABA
∪=∩
∩=∪
9-5 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii 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-6 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii 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-7 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii Method 2: Set Builder Notation & Logical Equivalence
n Show BABA ∪=∩
def. of complement
def. of “does not belong”
def. of intersection
De Morgan’s law (logic)
def. of “does not belong”
def. of complement
def. of union
by set builder notation BABAxxBxAxxBxAxx
BxAxxBxAxx
BAxxBAxxBA
∪=
∪∈=
∈∨∈=
∉∨∉=
∈¬∨∈¬=
∈∧∈¬=
∩∈¬=
∩∉=∩
}|{}|{}|{
)}()(|{)}(|{
))}((|{)}(|{
9-8 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii 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-9 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii Membership Table Example
n Prove (A ∪ B) - B = A - B.
AA BB AA∪∪BB ((AA∪∪BB))−−BB AA−−BB 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0 0 0 0
9-10 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii Membership Table Exercise n Prove (A ∪ B) - C = (A - C) ∪ (B - C).
A B C AA∪∪BB ((AA∪∪BB))−−CC AA−−CC BB−−CC ((AA−−CC))∪∪((BB−−CC)) 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0
1 1 1 1 1 1 0 0
0 1 0 1 0 1 0 0
0 1 0 1 0 0 0 0
0 1 0 0 0 1 0 0
0 1 0 1 0 1 0 0
9-11 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii Method 4: Venn Diagram n Prove (A ∪ B) - C = (A - C) ∪ (B - C).
A
B C A ∪ B
A
B C (A ∪ B) – C
A
B C A – C
A
B C B – C
A
B C (A – C) ∪ (B – C)
9-12 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii 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-13 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii 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 More generally, union of the sets Ai for i ∈ I:
n For infinite number of sets:
Ii
iA∈
n
iiA
1=
∞
=1iiA
9-14 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii
+
∞
=
==
∪∪∪=
∪∪∪=
Z,...}3,2,1{}3,2,1{}2,1{}1{
3211
AAAAi
i
Generalized Union Examples n Let Ai = {i, i+1, i+2,…}. Then,
n Let Ai = {1, 2, 3,…,i } for i = 1, 2, 3,…. Then, ,...}3,2,1{
,...}2,1,{,...}4,3,2{,...}3,2,1{
3211
=
++∪∪∪=
∪∪∪∪==
nnn
AAAAA n
n
ii
9-15 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii Generalized Intersection n Binary intersection operator: A ∩ B n n-ary intersection:
A1 ∩ A2 ∩…∩ An ≡ ((…((A1 ∩ A2) ∩…) ∩ An) (grouping & order is irrelevant)
n “Big Arch” notation:
n Generally, intersection of sets Ai for i∈I:
n For infinite number of sets:
n
iiA
1=
Ii
iA∈
∞
=1iiA
9-16 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii
}1{}3,2,1{}2,1{}1{
3211
=
∩∩∩=
∩∩∩=∞
=
AAAAi
i
Generalized Intersection Examples n Let Ai = {i, i+1, i+2,…}. Then,
n Let Ai = {1, 2, 3,…,i } for i = 1, 2, 3,…. Then, ,...}2,1,{
,...}2,1,{,...}4,3,2{,...}3,2,1{
3211
++=
++∩∩∩=
∩∩∩∩==
nnnnnn
AAAAA n
n
ii
9-17 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii
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!
Bit String Representation of Sets
9-18 ICS 141: Discrete Mathematics I Fall 2011
University of Hawaii
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
Examples of Sets as Bit Strings