Upload
others
View
12
Download
1
Embed Size (px)
Citation preview
8-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
8-2 ICS 141: Discrete Mathematics I- Fall 2011
University of Hawaii
Lecture 8
Chapter 2. Basic Structures 2.1 Sets 2.2 Set Operations
8-3 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Sets so far… n Previously…
n Literal set {a,b,c} and set-builder notation {x |P(x)} n Basic properties: unordered, distinct elements n infinite sets N, Z, Z+, Q, R
n Today n ∈ relational operator, and the empty set ∅ n Venn diagrams n Set relations =, ⊆, ⊆, ⊂, ⊃, ⊄, etc. n Cardinality |S| of a set S n Power sets P(S) n Cartesian product S × T n Set operators: ∪, ∩, -
8-4 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Basic Set Relations: Member of n x∈S (“x is in S”) is the proposition that object x
is an ∈lement or member of set S.
n e.g. 3 ∈ N, a ∈ {x | x is a letter of the alphabet}
n Can define set equality in terms of ∈ relation: ∀S,T: S = T ↔ [∀x (x∈S ↔ x∈T)] “Two sets are equal iff they have all the same members.”
n x∉S ≡ ¬(x∈S) “x is not in S”
8-5 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii The Empty Set
n ∅ (“null”, “the empty set”) is the unique set that contains no elements whatsoever.
n ∅ = { } = {x | False}
n No matter the domain of discourse, we have the axiom ¬∃x: x∈∅.
n { } ≠ {∅} = { { } } n {∅} it isn’t empty because it has ∅ as a member!
8-7 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Subset and Superset n S⊆T (“S is a subset of T ”) means that every
element of S is also an element of T. n S⊆T ≡ ∀x (x∈S → x∈T) n ∅⊆S, S⊆S n S⊆T (“S is a superset of T ”) means T⊆S n Note (S = T) ≡ (S⊆T ∧ S⊆T)
≡ ∀x(x∈S → x∈T) ∧ ∀x(x∈T → x∈S)
≡ ∀x(x∈S ↔ x∈T) n S⊆T means ¬(S⊆T), i.e. ∃x(x∈S ∧ x∉T)
8-8 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Proper (Strict) Subsets & Supersets n S⊂T (“S is a proper subset of T ”) means that
S⊆T but T⊆S. Similar for S ⊃T. n Example:
{1, 2} ⊂ {1, 2, 3}
S T
Venn Diagram of S⊂T
8-9 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Sets Are Objects, Too! n The objects that are elements of a set may
themselves be sets. n Example:
Let S = {x | x ⊆ {1, 2, 3}} then S = { ∅, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3} }
n Note that 1 ≠ {1} ≠ {{1}} !!!!
8-10 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Cardinality and Finiteness n |S| (read “the cardinality of S”) is a measure
of how many different elements S has.
n E.g., |∅| = 0, | {1, 2, 3} | = 3, | {a, b} | = 2,
| { {1, 2, 3}, {4, 5} } | = ____
n If |S| ∈ N, then we say S is finite. Otherwise, we say S is infinite.
n What are some infinite sets we’ve seen?
N, Z, Q, R
8-11 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii The Power Set Operation n The power set P(S) of a set S is the set of all
subsets of S. P(S) = {x | x⊆S}. n Examples
n P({a, b}) = { ∅, {a}, {b}, {a, b} } n S = {0, 1, 2}
P(S) = {∅, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}} n P(∅) = {∅} n P({∅}) = {∅, {∅}}
n Note that for finite S, |P(S)| = 2|S|. n It turns out ∀S (|P(S)| > |S|), e.g. |P(N)| > |N|.
8-12 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Ordered n-tuples
n These are like sets, except that duplicates matter, and the order makes a difference.
n For n∈N, an ordered n-tuple or a sequence or list of length n is written (a1, a2, …, an). Its first element is a1, its second element is a2, etc.
n Note that (1, 2) ≠ (2, 1) ≠ (2, 1, 1).
n Empty sequence, singlets, pairs, triples, quadruples, quintuples, …, n-tuples.
Contrast with sets’ {}
8-13 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Cartesian Products of Sets n For sets A and B, their Cartesian product
denoted by A × B, is the set of all ordered pairs (a, b), where a∈A and b∈B. Hence, A × B = { (a, b) | a∈A ∧ b∈B }.
n E.g. {a, b} × {1, 2} = { (a, 1), (a, 2), (b, 1), (b, 2) }
n Note that for finite A, B, |A × B| = |A||B|. n Note that the Cartesian product is not
commutative: i.e., ¬∀A,B (A × B = B × A). n Extends to A1 × A2 × … × An
= {(a1, a2, …, an) | ai ∈ Ai for i = 1, 2,…, n}
8-14 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii The Union Operator
n For sets A and B, their union A∪B is the set containing all elements that are either in A, or (“∨”) in B (or, of course, in both).
n Formally, ∀A,B: A∪B = {x | x∈A ∨ x∈B}.
n Note that A∪B is a superset of both A and B (in fact, it is the smallest such superset):
∀A,B: (A∪B ⊆ A) ∧ (A∪B ⊆ B)
8-15 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii
n {a, b, c} ∪ {2, 3} = {a, b, c, 2, 3} n {2, 3, 5} ∪ {3, 5, 7} = {2, 3, 5, 3, 5, 7} = {2, 3, 5, 7}
Union Examples
8-16 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii The Intersection Operator
n For sets A and B, their intersection A∩B is the set containing all elements that are simultaneously in A and (“∧”) in B.
n Formally, ∀A,B: A∩B = {x | x∈A ∧ x∈B}.
n Note that A∩B is a subset of both A and B (in fact it is the largest such subset):
∀A,B: (A∩B ⊆ A) ∧ (A∩B ⊆ B)
8-17 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii
n {a, b, c} ∩ {2, 3} = ___
n {2, 4, 6} ∩ {3, 4, 5} = ____
Intersection Examples
Think “The intersection of University Ave. and Dole St. is just that part of the road surface that lies on both streets.”
∅
{4}
8-18 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Disjointedness
n Two sets A, B are called disjoint (i.e., unjoined) iff their intersection is empty. (A ∩ B = ∅)
n Example: the set of even integers is disjoint with the set of odd integers.
Help, I’ve been
disjointed!
8-19 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Inclusion-Exclusion Principle n How many elements are in A∪B? |A∪B| = |A| + |B| - |A∩B|
n Example: How many students in the class major in Computer Science or Mathematics? n Consider set E = C ∪ M,
C = {s | s is a Computer Science major} M = {s | s is a Mathematics major}
n Some students are joint majors! |E| = |C ∪ M| = |C| + |M| - |C ∩ M|
8-20 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Inclusion-Exclusion Principle n How many elements are in A∪B? |A∪B| = |A| + |B| - |A∩B|
n Example: How many students in the class major in Computer Science or Mathematics? n Consider set E = C ∪ M,
C = {s | s is a Computer Science major} M = {s | s is a Mathematics major}
n Some students are joint majors! |E| = |C ∪ M| = |C| + |M| - |C ∩ M|
8-21 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Set Difference
n For sets A and B, the difference of A and B, written A - B, is the set of all elements that are in A but not B.
n Formally:
A - B = {x | x∈A ∧ x∉B} = {x | ¬(x∈A → x∈B)}
n Also called: The complement of B with respect to A.
8-22 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Set Difference: Venn Diagram
n A − B is what’s left after B “takes a bite out of A”
Set A
Set A - B
Set B
Chomp!
8-23 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Set Difference Examples
n {1, 2, 3, 4, 5, 6} - {2, 3, 5, 7, 9, 11} =
___________
n Z - N = {… , −1, 0, 1, 2, … } - {0, 1, … } = {x | x is an integer but not a natural #} = {… , −3, −2, −1} = {x | x is a negative integer}
{1, 4, 6}
8-24 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii Set Complements n The universe of discourse (or the domain)
can itself be considered a set, call it U.
n When the context clearly defines U, we say that for any set A ⊆ U, the complement of A, written as , is the complement of A with respect to U, i.e., it is U - A.
n E.g., If U = N,
A
{3,5} = {0,1, 2, 4, 6, 7,...}
8-25 ICS 141: Discrete Mathematics I - Fall 2011
University of Hawaii More on Set Complements
n An equivalent definition, when U is obvious: }|{ AxxA ∉=
U
A
AA