Vous êtes sur la page 1sur 78

Tournaments

• R is a tournament if
– R is irreflexive: (x, x) ∈ R.
– For all x = y, either (x, y) ∈ R (x beats y) or
(y, x) ∈ R (y beats x), but not both.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 342
Number of Tournaments
n
(
Lemma 55 There are 2 2 ) possible tournaments on n
players.a
n
• There are 2 games for a tournament on n players.
• Each tournament has 2 outcomes.
a The same as the number of reflexive symmetric relations (p. 339).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 343
Transitive Tournaments
• If a tournament is transitive, the players can be ranked.
– Suppose every player is beaten at least once.
– Start with any node a and follow the “is beaten by”
edges, we will eventually obtain a loop.
– Suppose node a is on the loop.
– This implies (a , a ) ∈ R by transitivity, a
contradiction because R is irreflexive.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 344
Transitive Tournaments (concluded)
• (continued)
– Hence some player x is unbeaten and x is a
“champion.”
– Remove x and repeat the above argument.
– Player x must beat the next player chosen because x
was unbeaten.
– Continue this process until there are no players left.
– The result is a sequence of players where earlier ones
beat the later ones.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 345
Antisymmetric Relations
• R is antisymmetric if

(x, y) ∈ R ∧ (y, x) ∈ R ⇒ x = y

for all x, y ∈ A.
– “⊆” is antisymmetric.
– “≤” is antisymmetric.
• Alternatively, R is antisymmetric if

x = y ⇒ (x, y) ∈ R ∨ (y, x) ∈ R (43)

for all x, y ∈ A.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 346
Antisymmetric Relations (continued)
• With DeMorgan’s law, Eq. (43) can be rewritten as

x = y ⇒ ¬[ (x, y) ∈ R ∧ (y, x) ∈ R ].

• “<” is antisymmetric because

x = y ⇒ ¬[ (x < y) ∧ (y < x) ].

– The original version would have asked us to prove

(x < y) ∧ (x > y) ⇒ x = y,

which is true, too.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 347
Antisymmetric Relations (concluded)
• Antisymmetry is clearly not the same as symmetry.
– “⊆” is antisymmetric (p. 346) but not symmetric.
• Antisymmetry is not synonymous with “not symmetric”
either.
– Take R as the relation that is the empty set.
– So (x, y) ∈ R for any x, y.
– Then R is antisymmetric.
– R is also symmetric.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 348
Number of Antisymmetric Relations
Lemma 56 If | A | = m, then there are
2
2m 3(m −m)/2

antisymmetric relations on A.
• The m decisions on (x, x) ∈ R are arbitrary.
m 
• For each of the other 2 = (m2 − m)/2 unordered pairs
{ x, y } (x = y), there are 3 choices by Eq. (43) on p. 346:
1. (x, y) ∈ R but (y, x) ∈ R.
2. (x, y) ∈ R but (y, x) ∈ R.
3. (x, y) ∈ R and (y, x) ∈ R.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 349
Inverse Relations
• Let R ⊆ A × B be a relation.
• The inverse of R, denoted R−1 , is this relation from B
to A:
R−1 = {(b, a) : (a, b) ∈ R}.
– The inverse of “≤” is “≥” (not “>”).
– The inverse of “<” is “>” (not “≥”).
• Note that inversehood and complement are distinct
concepts.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 350
A Property of R−1
Lemma 57 If R is reflexive on A, then R−1 is also
reflexive.
• Let a ∈ A.
• Then (a, a) ∈ R.
• Hence (a, a) ∈ R−1 .
• So R−1 is reflexive.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 351
Composite Relations
• Let R1 ⊆ A × B and R2 ⊆ B × C be two relations.
• The composite relation R1 ◦ R2 is a relation from A
to C defined by

{(x, z) : x ∈ A, z ∈ C, ∃y ∈ B [ (x, y) ∈ R1 ∧(y, z) ∈ R2 ]}.

• The associative law holds:

R1 ◦ (R2 ◦ R3 ) = (R1 ◦ R2 ) ◦ R3 .
n
  
n
• R = R ◦ R ◦ · · · ◦ R is called the power of R.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 352
Composition of Relations

$ % &
[ ]

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 353
Composite Functions and Relations
• A function is a special type of relation.
• For a composite function f1 ◦ f2 , f2 is applied first (p.
316).
• For a composite relation R1 ◦ R2 , however, R1 is applied
first followed by R2 (p. 352).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 354
Matrices and Zero-One Matrices
• The m × n matrix (aij )m×n denotes the entry in the
ith row and the jth column is aij .
• The transpose of A = (aij )m×n , written as Atr , is the
matrix (bij )n×m , where bij = aji .
• In is the n × n identity matrix.
• A zero-one matrix has entries of zeros and ones.
– Interpret “+” as “∨.”
– Interpret “×” as “∧.”

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 355
Matrix Precedence
• Let E = (eij ) and F = (fij ) be two m × n zero-one
matrices.
• We say E precedes (or is less than) F , written as

E ≤ F,

if eij ≤ fij for all 1 ≤ i ≤ m and 1 ≤ j ≤ n.


• For example,
⎡ ⎤ ⎡ ⎤
0 1 1 0 1 1
⎢ ⎥ ⎢ ⎥
⎢ 0 0 1 ⎥ ⎢ 1 1 ⎥
⎣ ⎦≤⎣ 0 ⎦.
0 0 0 0 0 0

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 356
The Zero-One Matrix Representation of Relations
• Let R be a relation from A = { a1 , a2 , . . . , am } to
B = { b1 , b2 , . . . , bn }.
• The relation matrix of R, M (R), is the m × n
zero-one matrix (rij )m×n , where

⎨ 1, if (a , b ) ∈ R
Δ i j
rij =
⎩ 0, if (ai , bj ) ∈ R

• It can be shown that

M (R1 ◦ R2 ) = M (R1 )M (R2 ). (44)

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 357
An Example
• Consider the binary relation < on { 1, 2, 3, 4 }.
• Here is the relation matrix:
⎡ ⎤
1 0 1 1 1
⎢ ⎥
2 ⎢⎢ 0 0 1 1 ⎥

M (<) = ⎢ ⎥.
3 ⎢⎣ 0 0 0 1 ⎥

4 0 0 0 0

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 358
An Example (continued)
• Now,
⎡ ⎤
0 0 1 1
⎢ ⎥
⎢ 0 0 0 1 ⎥
⎢ ⎥
M (<)M (<) = ⎢ ⎥.
⎢ 0 0 0 0 ⎥
⎣ ⎦
0 0 0 0

• The entry at (1, 4) is calculated as follows:

[ 0, 1, 1, 1 ] · [ 1, 1, 1, 0 ]
= (0 ∧ 1) ∨ (1 ∧ 1) ∨ (1 ∧ 1) ∨ (1 ∧ 0) = 1.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 359
An Example (concluded)
• By Eq. (44) on p. 357, the above denotes the relation
where x y if there exists a z with x < z and z < y.
• Sensibly, it says

1 3, 1 4, 2 4.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 360
Relation Matrices and Relations
• Let R be a relation on A with | A | = n and M = M (R).
• R is reflexive if and only if In ≤ M .
– This means that mii = 1 in M = (mij )1≤i,j≤n .
• R is symmetric if and only if M = M tr .
• R is transitive if and only if M 2 ≤ M .a
– Verify this inequality with the M (<)M (<) on p. 359.
• R is antisymmetric if and only if (M ∧ M tr ) ≤ In .b
– Verify this inequality with the M (<) on p. 358.
a Equivalently,R2 ⊆ R.
b Recall the definition (43) on p. 346.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 361
Directed Graphsa and Relations
• A directed graph (or digraph) G = (V, E) is made up
of the node set V and the edge set E ⊆ V × V .
• If (a, b) ∈ E, there is an edge from node a to node b.
– a is adjacent to b, whereas b is adjacent from a.
– (a, a) is a (self )-loop (at a).
• Clearly, a digraph (V, E) corresponds to a relation R on
V , and vice versa.
– (x, y) ∈ R if and only if (x, y) ∈ E.
a Euler (1736).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 362
A Digraph

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 363
Relation < on { 1, 2, 3, 4 } and Its Digraph
Representation

1 2 3 4

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 364
Adjacency Matrices
• The relation matrix for a digraph is called an
adjacency matrix.a
– We shall assume the digraph has no parallel edges
between nodes.
• The number of 1s is the number of edges.
• The adjacency matrix for the digraph on p. 364
appeared on p. 358.
a It
has many names in different fields: transition matrix, connection
matrix, precedence matrix, preference matrix, and predecessor matrix.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 365
Operations on Adjacency Matrices
• M 2 (over normal + and ×) is the number of walks of
length 2 between any two nodes.
2
– Mi,j = Mi1 M1j + Mi2 M2j + · · · + Min Mnj .
• Take the adjacency matrix M (<) on p. 358 for the
digraph on p. 364.
• Then ⎡ ⎤
0 0 1 2
⎢ ⎥
⎢ 0 0 0 1 ⎥
⎢ ⎥
M (<)M (<) = ⎢ ⎥.
⎢ 0 0 0 0 ⎥
⎣ ⎦
0 0 0 0

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 366
Operations on Adjacency Matrices (continued)
• In general, M k (over normal + and ×) counts the
number of walks of length k between any two nodes.
• Again, take the adjacency matrix M (<) on p. 358 for
the digraph on p. 364.
• Then
⎡ ⎤
0 0 0 1
⎢ ⎥
⎢ 0 0 0 0 ⎥
⎢ ⎥
M (<)M (<)M (<) = ⎢ ⎥.
⎢ 0 0 0 0 ⎥
⎣ ⎦
0 0 0 0

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 367
Operations on Adjacency Matrices (concluded)
• Similarly, M k (over ∨ and ∧) represents if there exist
paths of length k between any two nodes.
• If there are paths from a node to the other, one must
have length ≤ n − 1, where n is the number of nodes.
• Therefore the matrix
Δ
Y = M 1 ∨ M 2 ∨ · · · ∨ M n−1

(over ∨ and ∧) tells if there are paths between any two


nodes.a
• The digraph is thus disconnected if and only if Y
contains zero off-diagonal entries.
a This is called the middle-first search (Moore & Mertens, 2011).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 368
Partial Order
• A relation R on A is called a partial order or partial
ordering relation if it is
1. Reflexive.
2. Antisymmetric.a
3. Transitive.
• “≤” is a partial order.
• “|” (divisibility) is a partial order on Z+ .
• ⊆ is a partial order on 2A .b
a If(x, y) ∈ R ∧ (y, x) ∈ R ⇒ x = y for all x, y ∈ A (p. 346).
b Recall that 2A denotes A’s power set (p. 230).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 369
Partially Ordered Sets (Posets)
• Let A be a set.
• R is a relation on A.
• (A, R) is a partially ordered set or poset if R is a
partial order.
– Often R is not mentioned explicitly.
• Z, Q, R are all posets with “≤”.
• (Z+ , | ) is a poset.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 370
Hassea Diagrams
• Let (A, R) be a poset.
• Draw an edge from x to y if (x, y) ∈ R and there is no
other z ∈ A such that (x, z) ∈ R and (z, y) ∈ R.
– So edge (x, y) cannot be inferred from other edges via
transitivity considerations.
• The resulting graph is called a Hasse diagram.
• Hasse diagrams are not unique.
a Helmut Hasse (1898–1979).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 371
A Poset
• ({ 1, 2, 3, 4, 5, 6, 7, 8 }, | ).
• A self-loop at each node (not shown).
• Delete self-loops and “unnecessary” transitive edges to
form the Hasse diagram.
– Edge (1, 6) is deleted because it can be inferred from
edges (1, 3) and (3, 6).
– Edge (2, 6), on the other hand, cannot be inferred
from other edges via transitivity.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 372
A Hasse Diagram
2 1 1

2
3 8

3 4

4 7
5 6 7 8

5 6

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 373
Posets Have No Loops
• If (A, R) is a poset, then there do not exist distinct
x1 , x2 , . . . , xn ∈ A, n ≥ 2, such that

(x1 , x2 ), (x2 , x3 ), . . . , (xn−1 , xn ), (xn , x1 ) ∈ R.

– Suppose (x1 , x2 ), (x2 , x3 ), . . . , (xn−1 , xn ), (xn , x1 ) ∈ R


instead.
– By transitivity, (x1 , xi ), (xi , x1 ) ∈ R for 2 ≤ i ≤ n.
– By antisymmetry (p. 346),

x1 = x2 = · · · = xn ,

a contradiction.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 374
Maximal and Minimal Elements of Posets
• Let (A, R) be a poset.
• x ∈ A is a maximal element of A if (x, a) ∈ R for all
a ∈ A and a = x.a
– The poset ({ 1, 2, 3, 4, 5, 6, 7, 8 }, | ) on p. 373 has 4
maximal elements: 5, 6, 7, 8 as none of them divides
a number in { 1, 2, 3, 4, 5, 6, 7, 8 }.
• y ∈ A is a minimal element of A if (b, y) ∈ R for all
b ∈ A and b = y.
– The poset (Z+ , ≤) has minimal element 1 but no
maximal elements.
a It does not imply (a, x) ∈ R.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 375
Maximal and Minimal Elements of Finite Posets
• Let (A, R) be a finite poset.
• For every y ∈ A, there exists a minimal element x ∈ A
such that (x, y) ∈ R.a
– If y is a minimal element, we are done as (y, y) ∈ R.
– Otherwise, suppose y is not a minimal element.
– Then by the definition of minimality, there must be
an x1 = y such that (x1 , y) ∈ R.
– If x1 is minimal, then we are done.
a It is possible that x = y.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 376
Maximal and Minimal Elements of Finite Posets
(continued)
• (continued)
– Otherwise, there is an x2 = x1 such that (x2 , x1 ) ∈ R.
– Furthermore, x2 ∈ { x1 , y } by p. 374.
– If x2 is minimal, then (x2 , y) ∈ R by transitivity and
we are done.
– Otherwise, we continue the procedure.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 377
Maximal and Minimal Elements of Finite Posets
(concluded)
• (continued)
– As A is finite, eventually we will reach an xn such
that we can no longer find an
x ∈ { xn , xn−1 , . . . , x1 , y } and (x, xn ) ∈ R.
– This xn is minimal.
– Furthermore, (xn , y) ∈ R by transitivity.
• Similarly, for every x ∈ A, there is a maximal element
y ∈ A such that (x, y) ∈ R.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 378
Existence of Maximal and Minimal Elements
• If A is a finite poset, then A has a maximal and a
minimal element.
– Pick any element and apply the procedures on pp.
376ff.
• Alternatively, the topological sorting algorithm (p. 386)
returns a maximal element as v1 and a minimal element
as vn .
• The poset ({ 1, 2, 3, 4, 5, 6, 7, 8 }, | ) on p. 373 have 4
maximal elements: 5, 6, 7, and 8.
• It has only 1 minimal element: 1.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 379
Existence of Maximal and Minimal Elements
(concluded)
• So a poset can have more than one maximal element
and/or more than one minimal element.
• If (A, R) is a finite poset, then A has a minimal element
x and a maximal element y such that (x, y) ∈ R.
– Start wth a maximal element y, which exists (p. 379).
– There exists a minimal element x ∈ A such that
(x, y) ∈ R (p. 376).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 380
Ranking of Finite Posetsa
• Elements of a finite poset (A, R) can be ranked.b
• We can output a ranking, starting with the “smallest”
element, as follows.
– Pick any minimal element x ∈ A, which exists (379).
– Remove x from A after outputting it and repeat.c
a Contributed by Mr. Asger K. Pedersen (T02202107), Mr. Johnny
Lee (B02902018), and Mr. Larry Hsiang-Yu Lan (B02902123) on April
24, 2014.
b Compare p. 344.
c After that you still have a poset (prove it!).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 381
Total Order
• Let (A, R) be a poset.
• A is totally ordered if for all x, y ∈ A,

either (x, y) ∈ R or (y, x) ∈ R.

– Recall the definition of tournaments (p. 342).


• This R is called a total order or a linear order.
– (Z, ≤), (Q, ≤), and (R, ≤) are total orders.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 382
Number of Totally Ordered Sets
Lemma 58 If | A | = m, then there are m! totally ordered
sets on A.
• Every linear order of the elements of A defines a distinct
total order.
• So there are m! relations on A that are total orders.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 383
Relation Matrices of Total Orders
• Let R be a total order on A with m = | A |.
• Its relation matrix M (R) has m(m + 1)/2 1s.
– Reorder the rows and columns by increasing ranks
(p. 381).
– Then

M (R)i,j = 1 if and only if i ≤ j.

– The matrix is now an upper triangular matrix.


– The total number of 1s is therefore
 
m m(m + 1)
m+ = .
2 2

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 384
Topological Sort
• Given a partial order R represented as a Hasse diagram.
• The topological sorting algorithm produces a total order
T for which R ⊆ T .
– The total order needs only honor those (x, y) in R.
– The total order may not be unique.
– The partial order on p. 373 gives rise to one total
order
1, 2, 4, 3, 8, 7, 6, 5. (45)
– 1, 2, 4, 3, 8, 7, 5, 6 is another total order.
– Both honor the relations in the Hasse diagram.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 385
The Topological Sorting Algorithm
1: H1 is the input Hasse diagram; {| A | = n.}
2: for k = 1, 2, . . . , n do
3: Pick any vk ∈ Hk such that no edge in Hk starts from
vk ; {A maximal element, which exists (p. 379).}
4: if k = n then
5: return vn , vn−1 , . . . , v1 ; {(vi , vi−1 ) ∈ R,
i = 2, 3, . . . , n.}
6: end if
7: Remove vk and all edges that terminate at vk to yield
Hk+1 ; {Hk+1 remains a Hasse diagram (prove it!).}
8: end for

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 386
Least and Greatest Elements of Posets
• Let (A, R) be a poset.
• x ∈ A is a least element if (x, a) ∈ R for all a ∈ A.
• y ∈ A is a greatest element if (b, y) ∈ R for all b ∈ A.
• Least element and greatest element, if they exist, are
unique.
– For example, suppose x, y are both greatest elements.
– Then (x, y) ∈ R and (y, x) ∈ R, which imply x = y
by antisymmetry (p. 346).
• (A, R) is well-ordered if R is a total order and every
nonempty subset of A has a least element.a
a Recall the well-ordering principle (p. 203).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 387
Maximal vs. Greatest Elements of Posetsa
• A poset may have multiple maximal elements (p. 375).
• It is possible for a poset to have maximal elements but
no greatest elements (p. 375).
• The greatest element, if it exists, must be a maximal
element.
• In fact, the greatest element, if it exists, must be the
only maximal element (why?).
• So when a poset has more than 1 maximal element (such
as p. 375), it has no greatest element.
a Contributed by Ms. Li-Yin Wu (B91902051) on October 20, 2003.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 388
Latticesa
• Let (A, R) be a poset with B ⊆ A.
• x ∈ A is a lower bound of B if (x, b) ∈ R for all b ∈ B.
• y ∈ A is an upper bound of B if (a, y) ∈ R for all
a ∈ B.
• x ∈ A is a greatest lower bound (glb) of B if it is a
lower bound of B and (x , x ) ∈ R for all lower bounds
x of B.
• y  ∈ A is a least upper bound (lub) of B if it is an
upper bound of B and (y  , y  ) ∈ R for all upper bounds
y  of B.
a Friedrich Schröder (1841–1902).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 389
Lattices (concluded)
• (A, R) is called a lattice if for all x, y ∈ A, both
lub{ x, y } and glb{ x, y } exist in A.
– lub{ x, y } is called their join.
– glb{ x, y } is called their meet.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 390
Examples of Lattices
• (N, ≤).
– lub{ x, y } = max(x, y).
– glb{ x, y } = min(x, y).
• (2A , ⊆).a
– lub{ S, T } = S ∪ T .
– glb{ S, T } = S ∩ T .
a Recall that 2A denotes A’s power set: { B : B ⊆ A } (p. 230).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 391
Partitions
• Let ∅ = Ai ⊆ A for i ∈ I.
• {Ai }i∈I is a partition of A if

– A = i∈I Ai , and
– Ai ∩ Aj = ∅ for i = j.
• Ai ’s are called blocks.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 392
A3

A1

A2 A4

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 393
A Partition
• Let
Δ
Ai = { x ∈ Z : x ≡ i mod n }.

• Then
{ A0 , A1 , . . . , An−1 }
is a partition of Z.
– Every integer x is a member of the block Ar , where
r = x mod n.
– Two distinct blocks Ai and Aj , 0 ≤ i < j < n, are
disjoint.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 394
Number of Partitions
• The number of ways to partition a set of size n into k
blocks is S(n, k), a Stirling number.a
• The number of ways to partition a set of size n is Pn ,
the nth Bell number (p. 299).
a Recall
p. 275. See Eq. (40) on p. 293 and Eq. (41) on p. 295 for
easy-to-use recurrence relations.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 395
Equivalence Relations
• A relation R on A is called an equivalence relation if
it is
1. Reflexive.
2. Symmetric.
3. Transitive.
• “=” is an equivalence relation.
• “≡ modm” is an equivalence relation (p. 394).
• “<” is not an equivalence relation.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 396
Equivalence Classes
• Let R be an equivalence relation on A.
• For each x ∈ A, the equivalence class of x, denoted by
[ x ], is defined by

[ x ] = { y ∈ A : (y, x) ∈ R }.

– Anything that is related to x is in [ x ].

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 397
Equivalence Classes (concluded)
• Consider the equivalence relation ≡ modn on Z (same
remainder after division by n).
• Then [ i ] = { x ∈ Z : x ≡ i mod n }.
• {[ i ]}i=0,1,...,n−1 is a partition of Z (p. 394).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 398
Equivalence Classes as Partitions
• Let R be an equivalence relation on A and x, y ∈ A.
• x ∈ [ x ] (so [ x ] = ∅).
• (x, y) ∈ R if and only if [ x ] = [ y ].
– [ x ] = [ y ] ⇒ x ∈ [ y ] ⇒ (x, y) ∈ R.
– On the other hand, suppose (x, y) ∈ R.
∗ Pick any w ∈ [ x ].
∗ (w, y) ∈ R by symmetry and transitivity.
∗ Hence, w ∈ [ y ].
∗ We conclude [ x ] ⊆ [ y ].
∗ Similarly, [ y ] ⊆ [ x ].

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 399
The Proof (continued)
• [ x ] = [ y ] or [ x ] ∩ [ y ] = ∅.
– Suppose [ x ] = [ y ] but [ x ] ∩ [ y ] = ∅.
– Then there is a v ∈ A such that v ∈ [ x ] ∩ [ y ].
– But then (x, v) ∈ R and (v, y) ∈ R.
– Hence (x, y) ∈ R by transitivity.
– Therefore [ x ] = [ y ] by p. 399, a contradiction.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 400
The Proof (concluded)
• As x ∈ [ x ], we have

[ x ] = A.
x∈A

• Furthermore, distinct equivalence classes are disjoint.


Corollary 59 Equivalence classes partition A.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 401
Equivalence Relations and Partitions
Theorem 60 There is a one-to-one correspondence between
the set of equivalence relations on A and A’s set of
partitions.
• Let A be a set.
• Any equivalence relation R on A induces a natural
partition of A:
{ [ a ] : a ∈ A }.
– This partition, written as A/R, is called the
quotient.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 402
The Proof (concluded)
• Conversely, any partition of A gives rise to an
equivalence relation on A.
– Define R by (x, y) ∈ R if x and y are in the same
block (why?).
• It is not hard to see that our mapping is a one-to-one
correspondence.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 403
The Principle of Inclusion and Exclusion

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 404
If I am I because you are you,
and if you are you because I am I,
then I am not I,
and you are not you.
— Hassidic rabbi

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 405
The First Example
Count the number of 8-bit strings that start with 1 or end
with 00.
• The number of 8-bit strings that start with 1 is 27 = 128.
• The number of 8-bit strings that end with 00 is 26 = 64.
• The number of 8-bit strings that start with 1 and end
with 00 is 25 = 32.
• Finally, the desired number is

128 + 64 − 32 = 160.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 406
The Example on P. 29 Revisited
How many ways are there to arrange TALLAHASSEE with
no adjacent As?
• Rearrange the characters as AAAEEHLLSST.
• AAAEEHLLSST has 11 characters, among which there
are 3 As.
• There are
11!
= 831, 600
3! 2! 1! 2! 2! 1!
ways to arrange the 11 characters by Eq. (2) on p. 16.
• But some of them are invalid.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 407
The Example on P. 29 Revisited (continued)
• First, treat AA as a single, new character.
• The 10-character string (AA)AEEHLLSST can be
arranged in
10!
= 453, 600
1! 1! 2! 1! 2! 2! 1!
ways.
• But some arrangements of (AA)AEEHLLSST may
contain 3 consecutive As, which are counted twice.
– Such as (AA)AEEHLLSST and A(AA)EEHLLSST.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 408
The Example on P. 29 Revisited (concluded)
• To count them, as before, treat AAA as a single, new
character.
• The 9-character string (AAA)EEHLLSST can be
arranged in
9!
= 45, 360
1! 2! 1! 2! 2! 1!
ways.
• The desired number is hence

831, 600 − 453, 600 + 45, 360 = 423, 360,

matching the earlier result.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 409
The Setup
• Let S be a set with | S | = N .
• Let c1 , c2 , . . . , ct be conditions on the elements of S.
• N (a b c · · · ) denotes the number of elements of S that
satisfy
a∧ b ∧ c∧ ··· .

• So N (c1 c2 · · · ct ) denotes the number of elements of S


that satisfy none of the conditions ci .

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 410
The Principle of Inclusion and Exclusiona

N (c1 c2 · · · ct ) = N− N (ci )
1≤i≤t

+ N (ci cj )
1≤i<j≤t

− N (ci cj ck ) + · · ·
1≤i<j<k≤t

+(−1)t N (c1 c2 · · · ct )
t
 
k
= (−1) N (ci1 ci2 · · · cik ).
k=0 1≤i1 <i2 <···<ik ≤t

a Da Silva (1814–1878) in1854; James Joseph Sylvester (1814–1897)


in 1883.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 411
The Proof
• If x ∈ S satisfies none of the conditions ci , then x should
contribute one to N (c1 c2 · · · ct ).
– Indeed, it is counted once, in N .
• If x ∈ S satisfies 1 ≤ r ≤ t of the conditions ci , then x
should contribute zero to N (c1 c2 · · · ct ).
 r 
– It is counted once in N , r times in 1≤i≤t N (ci ), 2
 r 
times in 1≤i<j≤t N (ci cj ), . . ., and r times in
N (ci1 ci2 · · · cir ).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 412
The Proof (concluded)
• (continued)
– The total is
     
r r r
1−r+ − + · · · + (−1)r = (1 − 1)r = 0
2 3 r
by the binomial theorem (p. 55), as desired.
• We have exhausted all cases for x.a
a Contributed by Mr. Cheng-Chang Liu (B01902009) on April 18, 2013.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 413
Simplification of the Notation
• Define
Δ
S0 = N,
Δ
S1 = N (c1 ) + N (c2 ) + · · · + N (ct ),
Δ
S2 = N (c1 c2 ) + N (c1 c3 ) + · · · + N (ct−1 ct ),
..
.
Δ

Sk = N (ci1 ci2 · · · cik ). (46)
1≤i1 <i2 <···<ik ≤t
t
– Observe that Sk has k terms.
• The principle of inclusion and exclusion becomes

N (c1 c2 · · · ct ) = S0 − S1 + S2 − · · · + (−1)t St . (47)

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 414
A Corollary
• By DeMorgan’s law,

c1 ∨ c2 ∨ · · · ∨ ct = ¬(¬c1 ∧ ¬c2 ∧ · · · ∧ ¬ct ).

• Hence the number of elements in S that satisfy at least


one of the conditions ci equals

N (c1 ∨ c2 ∨ · · · ∨ ct ) = N − N (c1 c2 · · · ct ).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 415
A Corollary (concluded)
• By the inclusion-exclusion principle (47) on p. 414,

N (c1 ∨ c2 ∨ · · · ∨ ct ) = N (ci )
1≤i≤t

− N (ci cj )
1≤i<j≤t

+ N (ci cj ck )
1≤i<j<k≤t

− · · · + (−1)t−1 N (c1 c2 · · · ct )
= S1 − S2 + · · · + (−1)t−1 St .

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 416
A Further Simplification
• Often, N (ci1 ci2 · · · cik ) depends on k only and not on the
choice of i1 , i2 , . . . , ik .
• In this case, define
Δ
Nk = N (ci1 ci2 · · · cik ).

• Then  
t
Sk = Nk . (48)
k
• The above is much simpler than Eq. (46) on p. 414.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 417
Number of Onto Functions Revisited
• Let A = { a1 , a2 , . . . , am } and B = { b1 , b2 , . . . , bn }.
• Let ci be the condition that bi is not in the range of
f : A → B.
• N (c1 c2 · · · cn ) is the number of onto f : A → B.
• N (ci1 ci2 · · · cik ) is the number of

f : A → B − { bi1 , bi2 , . . . , bik }.

• Clearly
N (ci1 ci2 · · · cik ) = (n − k)m
for distinct i1 , i2 , . . . , ik .

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 418
Number of Onto Functions Revisited (concluded)
• By the principle of inclusion and exclusion,

N (c1 c2 · · · cn )
n 
k
= (−1) N (ci1 ci2 · · · cik )
k=0 1≤i1 <i2 <···<ik ≤n
n
  
n
= (−1)k (n − k)m by Eq. (48) on p. 417
k
k=0
= n! S(m, n), (49)

confirming again Eq. (32) on p. 267.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 419

Vous aimerez peut-être aussi