Discrete Mathematics

Discrete and Combinatorial
Mathematics
R. P. Grimaldi,
5th edition, 2004
Chapter 3
Set Theory
1
Sets
Set = a collection of distinct unordered objects
How to designate a set

Listing


A = {1,3,5,7}
Description

B = {x | x = 2k + 1, 0 < k < 3}
Members of a set are called elements

Examples

1  {1,3,5,7}; 2  {1,3,5,7}
2
Universe and empty sets
Universe  is the set of all elements about which
we make assertions.
The empty set  or { } has no elements.
Also called null set or void set.
3
Finite and infinite sets
Finite sets

Examples


A = {1, 2, 3, 4}
B = {x | x is an integer, 1 < x < 4}
Infinite sets

Examples


Z = {integers} = {…, -3, -2, -1, 0, 1, 2, 3,…}
S={x| x is a real number and 1 < x < 4} = [0, 4]
4
Some important sets
 = {all integers}
= {0, 1, -1, 2, -2, …}
+ = {all positive integers}
= {1, 2, 3, …}
 = {all natural numbers or nonnegative integers}
= {0, 1, 2, …}
 = {all rational numbers}
= {a/b| a,b, b0}
 = {all real numbers}
 = {all complex numbers}
= { x+yi | x,y, i2 = -1}
5
Cardinality
Cardinality or size of a set A (in symbols |A|) is the
number of elements in A

Examples


If A = {1, 2, 3} then |A| = 3
If B = {x | x is a natural number and 1< x< 9} then |B| = 9
Infinite cardinality
Countable (e.g., natural numbers, integers, rational
numbers)
 Uncountable (e.g., real numbers)

6
Subsets
X is a subset of Y if every element of X is also
contained in Y (in symbols X  Y)
X is a proper subset of Y if X  Y but Y  X (Y  X)
Equality:
X = Y iff X  Y and Y  X
7
Theorem 3.1
Let A, B, C  . If A  B and B  C, then A  C.
Proof.
 A  B  x [xA  xB]
 B  C  x [xB  xC]
 x [xA  xC]  A  C (Law of Syllogism)
 A  B  y [yB and yA]
 B  C  yC and yA
 A  C. #
8
Theorem 3.2
For any universe , let A  . Then   A , and
if A  , then   A.
Proof.
Assume   A.
 x [x and xA]
 
   A (by Contradiction)
 A    y [yA]
   A. #
9
Power set
The power set of X is the set of all subsets of X, in
symbols P(X), i.e., P(X)= {A | A  X}

Example

if X = {1, 2, 3}, then P(X) = {, {1}, {2}, {3}, {1,2}, {1,3}, {2,3},
{1,2,3}}
If |X| = n, then (1) there are C(n,k) subsets of
size k for 0  k  n; and (2) |P(X)| = 2n.
10
Union and intersection
Given two sets X and Y
The union of X and Y is defined as the set
X ∪ Y = { x | x  X or x  Y}
The intersection of X and Y is defined as the set
X ∩ Y = { x | x  X and x  Y}
Two sets X and Y are disjoint if X ∩ Y = 
11
Difference and complement
The difference (差集) of two sets X and Y
X – Y = { x | x  X and x  Y}
The symmetric difference of two sets X and Y
X Δ Y = (X – Y) ∪ (Y – X)
The complement (補集) of a set A contained in a
universe  is the set Ac =  – A
12
Laws of set operations (1)
For any sets A, B and C taken from a universe .
1) Law of Double Complement (回歸律):
(Ac)c = A
2) De Morgan’s laws:
(A∪B)c = Ac∩Bc
(A∩B)c = Ac∪Bc
3) Commutative laws (交換律):
A∪B=B∪A
A∩B=B∩A
13
Laws of set operations (2)
4) Associative laws (結合律):
(A ∪ B) ∪ C = A ∪ (B ∪ C)
(A ∩ B) ∩ C = A ∩ (B ∩ C)
5) Distributive laws (分配律):
A ∩ (B∪C) = (A∩B) ∪ (A∩C)
A ∪ (B∩C) = (A∪B) ∩ (A∪C)
6) Idempotent laws (等冪律):
A∪A = A
A∩A = A
7) Identity laws (同一律):
A∩=A
A∪=A
14
Laws of set operations (3)
8) Inverse laws (互補律):
A ∪ Ac = 
A ∩ Ac = 
9) Domination laws (支配律):
A∪ = 
A∩ = 
10) Absorption laws (吸收律):
A∪ (A∩B) = A
A∩ (A∪B) = A
15
Proof of Associative laws
Associative laws:
x  (A ∪ B) ∪ C  x  (A∪B) or x  C
 (x  A or x  B) or x  C
 x  A or (x  B or x  C)
 x  A or x  (B ∪ C)
 x  A ∪ (B ∪ C)
同法可證 (A ∩ B) ∩ C = A ∩ (B ∩ C).
#
16
Proof of De Morgan’s laws
De Morgan’s laws:
x  (A ∪ B)c  x  (A∪B)
 x  A and x  B
 x  Ac and x  Bc
 x  Ac ∩ Bc
同法可證 (A ∩ B)c = Ac ∪ Bc.
#
17
Generalized De Morgan’s laws
Let I be an index set and Ai   for all iI. Then
a)  Ai   Ai
b)  Ai   Ai
iI
Proof of a).
x   Ai  x 
iI
iI
iI
iI
A
i
iI
  i  I [x  Ai]
  i  I [x  Aic]
 x   Ai .
#
iI
18
Venn diagrams
A Venn diagram provides a graphic view of
sets.
Set union, intersection, difference, symmetric
difference and complements can be
identified.
19
Counting vs. Venn diagrams
If A, B, C are finite sets, then |A  B  C| =
|A| + |B| + |C| - |A  B| - |A  C| - |B  C| + |A 
B  C|.
A
B
C
20
Introduction to probability
An experiment is a process that yields an
outcome
An event is an outcome or a set of outcomes
from an experiment
The sample space is the event of all possible
outcomes
21
Probability
Probability of an event is the number of outcomes
in the event divided by the number of outcomes
in the sample space.
If S is a finite sample space and E is an event (E
is a subset of S) then the probability of E is
P(E) = |E| / |S|
22
Discrete probability theory
When all outcomes are equally likely and there
are n possible outcomes, each one has a
probability 1/n.
BUT this is not always the case. When all
probabilities are not equal, then some
probability (possibly different numbers) must
be assigned to each outcome.
23
Probability function
A probability function P is a function from the set
of all outcomes (sample space S) to the interval
[0, 1], in symbols
P : S  [0, 1]
The probability of an event E  S is the sum of
the probabilities of every outcome in E
P ( x)
P(E) =

xE
24
Probability of an event
Given E  S, we have
0 < P(E) < P(S) = 1
If S = {x1, x2,…, xn} isn a sample space, then
P ( xi )

P(S) = i 1
=1
If Ec is the complement of E in S, then
P(E) + P(Ec) = 1
25
Events in a sample space
Given any two events E1 and E2 in a sample space S.
Then
P(E1  E2) = P(E1) + P(E2) – P(E1  E2)
We also have P() = 0
Events E1 and E2 are mutually exclusive if and
only if E1  E2 = . In this case
P(E1  E2) = P(E1) + P(E2)
26
Conditional probability
Conditional probability is the probability of an event
E, given that another event F has occurred.
In symbols P(E|F).
If P(F) > 0 then
P(E|F) = P(EF) / P(F)
Two events E and F are independent if
P(EF) = P(E)P(F)
27
Pattern recognition
Pattern recognition places items into classes,
based on various features of the items.
Given a set of features F we can calculate the
probability of a class C, given F: P(C|F)
Place the item into the most probable class, i.e.
the one C for which P(C|F) is the highest.
Example: Wine can be classified as Table wine (T), Premium (R) or
Swill (S). Let F  {acidity, body, color, price}
Suppose a wine has feature F, and P(T|F) = 0.5, P(R|F) = 0.2 and
P(S|F) = 0.3. Since P(T|F) is the highest number, this wine will
be classified as table wine.
28
Bayes’ Theorem
Given pairwise disjoint classes C1, C2,…, Cn
and a feature set F, then
P(Cj|F) = A / B, where
n
A = P(F|Cj)P(Cj) and B =  P(F|Ci)P(Ci)
i 1
C2
C1
C3
F
29
Proof of Bayes’ Theorem
P(C j | F ) 
 P(C j | F ) 
P(C j  F )
P( F )
, P( F | C j ) 
P( F  C j )
P(C j )
P( F | C j ) P(C j )
P( F )
F  ( F  C1 )  ( F  C2 )    ( F  Cn )
 P( F )  P( F  C1 )  P( F  C2 )    P( F  Cn )
n
n
 P( F )   P( F  Ci )   P( F | Ci )P(Ci ).
i 1
#
i 1
30
Detecting HIV Virus
Classes:
H: has the HIV virus
Hc: does not have HIV virus
Feature:
Pos: ELISA test positive
Given Information:
P(H)=0.15, P(Hc)=0.85, P(Pos|H)=0.95, P(Pos|Hc)=0.02
P( H | Pos) 
P( Pos | H ) P( H )
P( Pos | H ) P( H )  P( Pos | H c ) P( H c )
(0.95) P(0.15)

 0.893.
(0.95)(0.15)  (0.02)(0.85)
31
Brainstorm
小明昨晚從9點到11:30間持續讀完五個科目:國文、數學、
英文、化學、生物(順序未知)。其中沒有同時讀兩個
科目的情形。另外每一科所花的時間也不同:10分、20
分、30分、40分、50分(順序也未知)。已知
(1)小明10:05正在讀數學。
(2)第三順位只用10分鐘,第四順位則用50分鐘。
(3)讀完國文後,讀數學;讀完英文(20分鐘)後,
讀化學。
問題: 請推算出小明在不同時段分別讀那一科。
32