Combinatorics - TCS @ NJUtcs.nju.edu.cn › slides › comb2015 › intro.pdf · A course in...

Preview:

Citation preview

Combinatorics�������

Course Info

• Instructor: ���

• yinyt@nju.edu.cn, yitong.yin@gmail.com

• Office hour: 804 , Tuesday, 2pm-4pm

• course homepage:

• http://tcs.nju.edu.cn/wiki/

Textbook

van Lint and Wilson, A course in Combinatorics, 2nd Edition.

Jukna, Extremal Combinatorics: with applications in computer science,2nd Edition.

Reference Books

Graham, Knuth, and Patashnik, Concrete Mathematics: A Foundation for Computer Science

Stanley, Enumerative Combinatorics, Volume 1

Alon and Spencer. The Probabilistic Method.

Reference Books

Cook, Cunningham, Pulleyblank, and Schrijver. Combinatorial Optimization.

Aigner and Ziegler. Proofs from THE BOOK.

Combinatorics

• Enumeration (counting):

• Existence:

• Extremal:

• Ramsey:

• Optimization:

• Construction (design):

How many solutions to these constraints?

Does a solution exist?

When a solution is sufficiently large, some structure must emerge.

How large/small a solution can be to preserve/avoid certain structure?

Find the optimal solution.

Construct a solution.

solution: combinatorial objectconstraint: combinatorial structure

combinatorial≈discrete finite

Tools (and prerequisites)

• Combinatorial (elementary) techniques;

• Algebra (linear & abstract);

• Probability theory;

• Analysis (calculus).

Enumeration(counting)

• to rank n people?

• to assign m zodiac signs to n people?

• to choose m people out of n people?

• to partition n people into m groups?

• to distribute m yuan to n people?

• to partition m yuan to n parts?

• ... ...

How many ways are there:

Gian-Carlo Rota (1932-1999)

The Twelvefold Way

Stanley, Enumerative Combinatorics, Volume 1

The twelvefold wayf : N �M |N | = n, |M | = m

elements of N

elements of M any f 1-1 on-to

distinct distinct

identical distinct

distinct identical

identical identical

balls per bin: unrestricted ≤ 1 ≥ 1

n distinct balls,m distinct bins

n identical balls,m distinct bins

n distinct balls,m identical bins

n identical balls,m identical bins

Knuth’s version (in TAOCP vol.4A)

n balls are put into m bins

Counting (labeled) trees

“How many different trees can be formed from n distinct vertices?”

Cayley’s formulafor the number of trees

Chapter 30

Arthur Cayley

One of the most beautiful formulas in enumerative combinatorics concernsthe number of labeled trees. Consider the set N = {1, 2, . . . , n}. Howmany different trees can we form on this vertex set? Let us denote thisnumber by Tn. Enumeration “by hand” yields T1 = 1, T2 = 1, T3 = 3,T4 = 16, with the trees shown in the following table:

4 3 4 3 43 43 4 3 4 3 4 3 4

3 4 3 4 3 43 43 4 3 4 3 4 3 4

1 1 1 2 1 21 22

1 2 1 2 1 21 21

3

2 2 1 2 1 2

1 2 1 2 1 21 21 2 1 2 1 2 1 2

1

3 33

Note that we consider labeled trees, that is, although there is only one treeof order 3 in the sense of graph isomorphism, there are 3 different labeledtrees obtained by marking the inner vertex 1, 2 or 3. For n = 5 there arethree non-isomorphic trees:

605 60

For the first tree there are clearly 5 different labelings, and for the secondand third there are 5!

2 = 60 labelings, so we obtain T5 = 125. This shouldbe enough to conjecture Tn = nn−2, and that is precisely Cayley’s result.

Theorem. There are nn−2 different labeled trees on n vertices.

This beautiful formula yields to equally beautiful proofs, drawing on avariety of combinatorial and algebraic techniques. We will outline threeof them before presenting the proof which is to date the most beautiful ofthem all.

Arthur Cayley(1821-1895)

There are nn�2 trees on n distinct vertices.

Cayley’s formula:

Algorithmic Enumeration

“The number of different spanning trees of G(V,E).”

input: undirected graph G(V, E)

t(G) :

for i =1,2,3,... nn-2

output the i-th tree;

enumeration algorithm:

counting algorithm:

Graph Laplacian1 2

34

Graph G(V,E)adjacency matrix A

A(i, j) =

(1 {i, j} 2 E

0 {i, j} 62 E

D(i, j) =

(deg(i) i = j

0 i 6= j

diagonal matrix DD =

2

6664

d1d2

. . .dn

3

777500

graph Laplacian L

L = D �A L =

2

664

3 �1 �1 �1�1 2 �1 0�1 �1 3 �1�1 0 �1 2

3

775

Li,i : submatrix of L by removing ith row and ith collumn

i

i

t(G) : number of spanning trees in G

Kirchhoff ’s Matrix-Tree Theorem:8i, t(G) = det(Li,i)

Gustav Kirchhoff (1824-1887)

Bipartite Perfect Matching

4 Perfect matchings in bipartite graphs. Consider a bipartite graph with bi-partition (N,N), where N = {1, . . . , n}, and edge set E ⊆ N × N . A perfectmatching is an edge subset M ⊆ E that includes every node as an endpointexactly once. See Fig. 3 for some interpretations.

Fig. 3. Row 1: A bipartitegraph and its three perfectmatchings. Row 2: In thegraph’s adjacency matrixA, every perfect matchingcorresponds to a permuta-tion π for which Ai,π(i) = 1for all i ∈ [n]. Row 3: Inthe directed n-node graphdefined by A, every perfectmatching corresponds toa directed cycle partition.Bottom row: an equiva-lent formulation in termsof non-attacking rooks ona chess board with forbid-den positions.

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1

23

1

23

1

23

1

23

VRVR

VR

VRVR

VR

VRVRVR

The Ryser formula for counting the perfect matchings in such a graph canbe given as

!

π∈Sn

n"

i=1

[iπ(i) ∈ E] =!

S⊆N

(−1)|N\S|n"

i=1

!

j∈S

[ij ∈ E] , (4)

where Sn denotes the set of permutations from N to N . The left hand sidesuccinctly describes the problem as iterating over all permutations and checkingif the corresponding edges (namely, 1π(1), 2π(2), . . ., nπ(n)) are all in E. Directevaluation would require n! iterations. The right hand side provides an equivalentexpression that can be evaluated in time O(2nn2), see Fig. 4.

Proof of (4). For fixed i ∈ N , the value#

j∈S [ij ∈ E] counts the number of i’sneighbours in S ⊆ N . Thus the expression

n"

i=1

!

j∈S

[ij ∈ E] (5)

is the number of ways every node i ∈ N can choose a neighbour from S. (Thisallows some nodes to select the same neighbour.) Consider such a choice as amapping g : N → N , not necessarily onto, with image R = g(N). The contribu-tion of g to (5) is 1 for every S ⊇ R, and its total contribution to the right hand

4 Perfect matchings in bipartite graphs. Consider a bipartite graph with bi-partition (N,N), where N = {1, . . . , n}, and edge set E ⊆ N × N . A perfectmatching is an edge subset M ⊆ E that includes every node as an endpointexactly once. See Fig. 3 for some interpretations.

Fig. 3. Row 1: A bipartitegraph and its three perfectmatchings. Row 2: In thegraph’s adjacency matrixA, every perfect matchingcorresponds to a permuta-tion π for which Ai,π(i) = 1for all i ∈ [n]. Row 3: Inthe directed n-node graphdefined by A, every perfectmatching corresponds toa directed cycle partition.Bottom row: an equiva-lent formulation in termsof non-attacking rooks ona chess board with forbid-den positions.

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1

23

1

23

1

23

1

23

VRVR

VR

VRVR

VR

VRVRVR

The Ryser formula for counting the perfect matchings in such a graph canbe given as

!

π∈Sn

n"

i=1

[iπ(i) ∈ E] =!

S⊆N

(−1)|N\S|n"

i=1

!

j∈S

[ij ∈ E] , (4)

where Sn denotes the set of permutations from N to N . The left hand sidesuccinctly describes the problem as iterating over all permutations and checkingif the corresponding edges (namely, 1π(1), 2π(2), . . ., nπ(n)) are all in E. Directevaluation would require n! iterations. The right hand side provides an equivalentexpression that can be evaluated in time O(2nn2), see Fig. 4.

Proof of (4). For fixed i ∈ N , the value#

j∈S [ij ∈ E] counts the number of i’sneighbours in S ⊆ N . Thus the expression

n"

i=1

!

j∈S

[ij ∈ E] (5)

is the number of ways every node i ∈ N can choose a neighbour from S. (Thisallows some nodes to select the same neighbour.) Consider such a choice as amapping g : N → N , not necessarily onto, with image R = g(N). The contribu-tion of g to (5) is 1 for every S ⊇ R, and its total contribution to the right hand

4 Perfect matchings in bipartite graphs. Consider a bipartite graph with bi-partition (N,N), where N = {1, . . . , n}, and edge set E ⊆ N × N . A perfectmatching is an edge subset M ⊆ E that includes every node as an endpointexactly once. See Fig. 3 for some interpretations.

Fig. 3. Row 1: A bipartitegraph and its three perfectmatchings. Row 2: In thegraph’s adjacency matrixA, every perfect matchingcorresponds to a permuta-tion π for which Ai,π(i) = 1for all i ∈ [n]. Row 3: Inthe directed n-node graphdefined by A, every perfectmatching corresponds toa directed cycle partition.Bottom row: an equiva-lent formulation in termsof non-attacking rooks ona chess board with forbid-den positions.

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1

23

1

23

1

23

1

23

VRVR

VR

VRVR

VR

VRVRVR

The Ryser formula for counting the perfect matchings in such a graph canbe given as

!

π∈Sn

n"

i=1

[iπ(i) ∈ E] =!

S⊆N

(−1)|N\S|n"

i=1

!

j∈S

[ij ∈ E] , (4)

where Sn denotes the set of permutations from N to N . The left hand sidesuccinctly describes the problem as iterating over all permutations and checkingif the corresponding edges (namely, 1π(1), 2π(2), . . ., nπ(n)) are all in E. Directevaluation would require n! iterations. The right hand side provides an equivalentexpression that can be evaluated in time O(2nn2), see Fig. 4.

Proof of (4). For fixed i ∈ N , the value#

j∈S [ij ∈ E] counts the number of i’sneighbours in S ⊆ N . Thus the expression

n"

i=1

!

j∈S

[ij ∈ E] (5)

is the number of ways every node i ∈ N can choose a neighbour from S. (Thisallows some nodes to select the same neighbour.) Consider such a choice as amapping g : N → N , not necessarily onto, with image R = g(N). The contribu-tion of g to (5) is 1 for every S ⊇ R, and its total contribution to the right hand

4 Perfect matchings in bipartite graphs. Consider a bipartite graph with bi-partition (N,N), where N = {1, . . . , n}, and edge set E ⊆ N × N . A perfectmatching is an edge subset M ⊆ E that includes every node as an endpointexactly once. See Fig. 3 for some interpretations.

Fig. 3. Row 1: A bipartitegraph and its three perfectmatchings. Row 2: In thegraph’s adjacency matrixA, every perfect matchingcorresponds to a permuta-tion π for which Ai,π(i) = 1for all i ∈ [n]. Row 3: Inthe directed n-node graphdefined by A, every perfectmatching corresponds toa directed cycle partition.Bottom row: an equiva-lent formulation in termsof non-attacking rooks ona chess board with forbid-den positions.

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1 1 1

1 1 0

0 1 1

1

23

1

23

1

23

1

23

VRVR

VR

VRVR

VR

VRVRVR

The Ryser formula for counting the perfect matchings in such a graph canbe given as

!

π∈Sn

n"

i=1

[iπ(i) ∈ E] =!

S⊆N

(−1)|N\S|n"

i=1

!

j∈S

[ij ∈ E] , (4)

where Sn denotes the set of permutations from N to N . The left hand sidesuccinctly describes the problem as iterating over all permutations and checkingif the corresponding edges (namely, 1π(1), 2π(2), . . ., nπ(n)) are all in E. Directevaluation would require n! iterations. The right hand side provides an equivalentexpression that can be evaluated in time O(2nn2), see Fig. 4.

Proof of (4). For fixed i ∈ N , the value#

j∈S [ij ∈ E] counts the number of i’sneighbours in S ⊆ N . Thus the expression

n"

i=1

!

j∈S

[ij ∈ E] (5)

is the number of ways every node i ∈ N can choose a neighbour from S. (Thisallows some nodes to select the same neighbour.) Consider such a choice as amapping g : N → N , not necessarily onto, with image R = g(N). The contribu-tion of g to (5) is 1 for every S ⊇ R, and its total contribution to the right hand

bipartite graph

G([n],[n],E)

perfect matchings

permutation � of [n] (i,�(i)) � Es.t.

Ai,j =

�1 (i, j) � E

0 (i, j) �� E

n � n matrix A :

=�

��Sn

i�[n]

Ai,�(i)

# of P.M. in G

Permanentn � n matrix A :

=�

��Sn

i�[n]

Ai,�(i)perm(A)

det(A) =�

��Sn

(�1)r(�)�

i�[n]

Ai,�(i)

determinant:

poly-time by Gaussian elimination

#P-hard to compute

Ryser’s formula

��Sn

i�[n]

Ai,�(i) =�

I�[n]

(�1)n�|I|�

i�[n]

j�I

Ai,j

O(n!) time O(n2n) time

I�S

(�1)|S|�|I| =

�1 S = �0 otherwise

PIE (Principle of Inclusion-Exclusion):

PIE(Principle of Inclusion-Exclusion)

|A �B| = |A| + |B|�|A ⇥B|

|A �B � C| = |A| + |B| + |C|�|A ⇥B|� |A ⇥ C|� |B ⇥ C|+|A �B � C|

Inversion

f : 2[n] � N

V: 2n-dimensional vector space of all mappings

� : V � Vlinear transformation

�S � [n],

�S � [n],

then its inverse:

�f(S) ��

T�ST�[n]

f(T )

��1f(S) =�

T�ST�[n]

(�1)|T\S|f(T )

Fibonacci number

Fn =

�⌅⇤

⌅⇥

Fn�1 + Fn�2 if n � 2,

1 if n = 10 if n = 0.

� =1 +

�5

2�̂ =

1�⇥

52

Fn =1⇥5

��n � �̂n

by generating functions ...

Quicksort

Qsort(A):

choose a pivot x = A[1];

•partition A into L with all L[i ] < x ,

R with all R[i ] > x ;Qsort(L) and Qsort(R);

input: an array A of n numbers

Complexity: number of comparisons

worst-case:

average-case: ?

Θ(n2)

Qsort(A):

choose a pivot x = A[1];

•partition A into L with all L[i ] < x ,

R with all R[i ] > x ;Qsort(L) and Qsort(R);

Tn :average # of comparisons

used by Qsort

=1

n

n�

k=1

(n � 1 + Tk�1 + Tn�k)Tn

pivot: the k-th smallest number in A|L| = k-1 |R| = n-k

n � 1

Recursion:

T0 = T1 = 0

= 2n ln n + O(n)

generating functions

Counting with SymmetryRotation :

Rotation & Reflection:

Symmetries

Pólya’s Theory of Counting

George Pólya(1887-1985)

a~v : # of config. (up to symmetry) with ni many color i

pattern inventory :

FG(y1, y2, . . . , ym) =X

~v=(n1,...,nm)n1+···+nm=n

a~v yn11 yn2

2 · · · ynmm

(multi-variate) generating function

FG(y1, y2, . . . , ym) = PG

mX

i=1

yi,mX

i=1

y2i , . . . ,mX

i=1

yni

!Pólya’s enumeration formula (1937):

⇡ =

`1z }| {(· · · )

`2z }| {(· · · ) · · ·

`kz }| {(· · · )| {z }

k cycles

M⇡(x1, x2, . . . , xn) =kY

i=1

x`i

PG(x1, x2, . . . , xn) =1

|G|X

⇡2G

M⇡(x1, x2, . . . , xn)cycle index:

FD20(r, q, l)

Existing

• a configuration satisfying this condition?

• a counterexample for this method?

• an efficient algorithm for this problem?

• a problem which is hard to solve in this computation model?

• ...

Does there exist:

Circuit Complexity

¬

x1 x2 x3

f : {0, 1}n � {0, 1}Boolean function

Boolean circuit

Claude Shannon(1916 - 2001)

Theorem (Shannon 1949)

There is a boolean functionf : {0, 1}n � {0, 1} whichcannot be computed by anycircuit with 2n

3n gates.

no constructive proof is known

Combinatorics

• Enumeration (counting):

• Existence:

• Extremal:

• Ramsey:

• Optimization:

• Construction (design):

How many solutions to these constraints?

Does a solution exist?

When a solution is sufficiently large, some structure must emerge.

How large/small a solution can be to preserve/avoid certain structure?

Find the optimal solution.

Construct a solution.

solution: combinatorial objectconstraint: combinatorial structure

combinatorial≈discrete finite

Recommended