组合数学 (Fall 2011) and 组合数学 (Fall 2011)/Sieve methods: Difference between pages

From TCS Wiki
(Difference between pages)
Jump to navigation Jump to search
imported>Etone
 
imported>Etone
 
Line 1: Line 1:
{{Infobox
|name        = Infobox
|bodystyle    =
|title        = <font size=3>组合数学  <br>
Combinatorics</font>
|titlestyle  =


|image        = [[File:LW-combinatorics.jpeg|border|100px]]
== Principle of Inclusion-Exclusion ==
|imagestyle  =  
Let <math>A</math> and <math>B</math> be two finite sets. The cardinality of their union is
|caption      =
:<math>|A\cup B|=|A|+|B|-{\color{Blue}|A\cap B|}</math>.
|captionstyle =
For three sets <math>A</math>, <math>B</math>, and <math>C</math>, the cardinality of the union of these three sets is computed as
|headerstyle  = background:#ccf;
:<math>|A\cup B\cup C|=|A|+|B|+|C|-{\color{Blue}|A\cap B|}-{\color{Blue}|A\cap C|}-{\color{Blue}|B\cap C|}+{\color{Red}|A\cap B\cap C|}</math>.
|labelstyle  = background:#ddf;
This is illustrated by the following figure.
|datastyle    =
::[[Image:Inclusion-exclusion.png|200px|border|center]]


|header1 =Instructor
Generally, the '''Principle of Inclusion-Exclusion''' states the rule for computing the union of <math>n</math> finite sets <math>A_1,A_2,\ldots,A_n</math>, such that
|label1  =  
{{Equation|
|data1  =  
<math>
|header2 =
\begin{align}
|label2  =  
\left|\bigcup_{i=1}^nA_i\right|
|data2  = 尹一通
&=
|header3 =  
\sum_{I\subseteq\{1,\ldots,n\}}(-1)^{|I|-1}\left|\bigcap_{i\in I}A_i\right|.
|label3  = Email
\end{align}
|data3  = yitong.yin@gmail.com  yinyt@nju.edu.cn 
</math>
|header4 =
}}
|label4= office
-----
|data4= 计算机系 804
 
|header5 = Class
In combinatorial enumeration, the Principle of Inclusion-Exclusion is usually applied in its complement form.
|label5  =  
 
|data5  =  
Let <math>A_1,A_2,\ldots,A_n\subseteq U</math> be subsets of some finite set <math>U</math>. Here <math>U</math> is some universe of combinatorial objects, whose cardinality is easy to calculate (e.g. all strings, tuples, permutations), and each <math>A_i</math> contains the objects with some specific property (e.g. a "pattern") which we want to avoid. The problem is to count the number of objects without any of the <math>n</math> properties. We write <math>\bar{A_i}=U-A_i</math>. The number of objects without any of the properties <math>A_1,A_2,\ldots,A_n</math> is
|header6 =
{{Equation|
|label6  = Class meetings
<math>
|data6  = Thursday, 10am-12pm <br> 仙逸B-104
\begin{align}
|header7 =
\left|\bar{A_1}\cap\bar{A_2}\cap\cdots\cap\bar{A_n}\right|=\left|U-\bigcup_{i=1}^nA_i\right|
|label7  = Place
&=
|data7  =  
|U|+\sum_{I\subseteq\{1,\ldots,n\}}(-1)^{|I|}\left|\bigcap_{i\in I}A_i\right|.
|header8 =
\end{align}
|label8  = Office hours
</math>
|data8  = Wednesday, 2-5pm <br>计算机系 804
}}
|header9 = Textbook
For an <math>I\subseteq\{1,2,\ldots,n\}</math>, we denote
|label9  =
:<math>A_I=\bigcap_{i\in I}A_i</math>
|data9  =  
with the convention that <math>A_\emptyset=U</math>. The above equation is stated as:
|header10 =
{{Theorem|Principle of Inclusion-Exclusion|
|label10  =  
:Let <math>A_1,A_2,\ldots,A_n</math> be a family of subsets of <math>U</math>. Then the number of elements of <math>U</math> which lie in none of the subsets <math>A_i</math> is
|data10  = ''van Lint and Wilson,'' <br> A course in Combinatorics, 2nd Ed, <br> Cambridge Univ Press, 2001.
::<math>\sum_{I\subseteq\{1,\ldots, n\}}(-1)^{|I|}|A_I|</math>.
}}
 
Let <math>S_k=\sum_{|I|=k}|A_I|\,</math>. Conventionally, <math>S_0=|A_\emptyset|=|U|</math>. The principle of inclusion-exclusion can be expressed as
{{Equation|<math>
S_0-S_1+S_2+\cdots+(-1)^nS_n.
</math>
}}
 
=== Surjections ===
In the twelvefold way, we discuss the counting problems incurred by the mappings <math>f:N\rightarrow M</math>. The basic case is that elements from both <math>N</math> and <math>M</math> are distinguishable. In this case, it is easy to count the number of arbitrary mappings (which is <math>m^n</math>) and the number of injective (one-to-one) mappings (which is <math>(m)_n</math>), but the number of surjective is difficult. Here we apply the principle of inclusion-exclusion to count the number of surjective (onto) mappings.
{{Theorem|Theorem|
:The number of surjective mappings from an <math>n</math>-set to an <math>m</math>-set is given by
::<math>\sum_{k=1}^m(-1)^{m-k}{m\choose k}k^n</math>.
}}
{{Proof|
Let <math>U=\{f:[n]\rightarrow[m]\}</math> be the set of mappings from <math>[n]</math> to <math>[m]</math>. Then <math>|U|=m^n</math>.
 
For <math>i\in[m]</math>, let <math>A_i</math> be the set of mappings <math>f:[n]\rightarrow[m]</math> that none of <math>j\in[n]</math> is mapped to <math>i</math>, i.e. <math>A_i=\{f:[n]\rightarrow[m]\setminus\{i\}\}</math>, thus <math>|A_i|=(m-1)^n</math>.
 
More generally, for <math>I\subseteq [m]</math>, <math>A_I=\bigcap_{i\in I}A_i</math> contains the mappings <math>f:[n]\rightarrow[m]\setminus I</math>. And <math>|A_I|=(m-|I|)^n\,</math>.
 
A mapping <math>f:[n]\rightarrow[m]</math> is surjective if <math>f</math> lies in none of <math>A_i</math>. By the principle of inclusion-exclusion, the number of surjective <math>f:[n]\rightarrow[m]</math> is
:<math>\sum_{I\subseteq[m]}(-1)^{|I|}\left|A_I\right|=\sum_{I\subseteq[m]}(-1)^{|I|}(m-|I|)^n=\sum_{j=0}^m(-1)^j{m\choose j}(m-j)^n</math>.
Let <math>k=m-j</math>. The theorem is proved.
}}
 
Recall that, in the twelvefold way, we establish a relation between surjections and partitions.
 
* Surjection to ordered partition:
:For a surjective <math>f:[n]\rightarrow[m]</math>, <math>(f^{-1}(0),f^{-1}(1),\ldots,f^{-1}(m-1))</math> is an '''ordered partition''' of <math>[n]</math>.
* Ordered partition to surjection:
:For an ordered <math>m</math>-partition <math>(B_0,B_1,\ldots, B_{m-1})</math> of <math>[n]</math>, we can define a function <math>f:[n]\rightarrow[m]</math> by letting <math>f(i)=j</math> if and only if <math>i\in B_j</math>. <math>f</math> is surjective since as a partition, none of <math>B_i</math> is empty.
 
Therefore, we have a one-to-one correspondence between surjective mappings from an <math>n</math>-set to an <math>m</math>-set and the ordered <math>m</math>-partitions of an <math>n</math>-set.
 
The Stirling number of the second kind <math>S(n,m)</math> is the number of <math>m</math>-partitions of an <math>n</math>-set. There are <math>m!</math> ways to order an <math>m</math>-partition, thus the number of surjective mappings <math>f:[n]\rightarrow[m]</math> is <math>m! S(n,m)</math>. Combining with what we have proved for surjections, we give the following result for the Stirling number of the second kind.
 
{{Theorem|Proposition|
:<math>S(n,m)=\frac{1}{m!}\sum_{k=1}^m(-1)^{m-k}{m\choose k}k^n</math>.
}}
 
=== Derangements ===
We now count the number of bijections from a set to itself with no fixed points. This is the '''derangement problem'''.
 
For a permutation <math>\pi</math> of <math>\{1,2,\ldots,n\}</math>, a '''fixed point''' is such an <math>i\in\{1,2,\ldots,n\}</math> that <math>\pi(i)=i</math>.
A [http://en.wikipedia.org/wiki/Derangement '''derangement'''] of <math>\{1,2,\ldots,n\}</math> is a permutation of <math>\{1,2,\ldots,n\}</math> that has no fixed points.
 
{{Theorem|Theorem|
:The number of derangements of <math>\{1,2,\ldots,n\}</math> given by
::<math>n!\sum_{k=0}^n\frac{(-1)^k}{k!}\approx \frac{n!}{\mathrm{e}}</math>.
}}
{{Proof|
Let <math>U</math> be the set of all permutations of <math>\{1,2,\ldots,n\}</math>. So <math>|U|=n!</math>.
 
Let <math>A_i</math> be the set of permutations with fixed point <math>i</math>; so <math>|A_i|=(n-1)!</math>. More generally, for any <math>I\subseteq \{1,2,\ldots,n\}</math>, <math>A_I=\bigcap_{i\in I}A_i</math>, and <math>|A_I|=(n-|I|)!</math>, since permutations in <math>A_I</math> fix every point in <math>I</math> and permute the remaining points arbitrarily. A permutation is a derangement if and only if it lies in none of the sets <math>A_i</math>. So the number of derangements is
:<math>\sum_{I\subseteq\{1,2,\ldots,n\}}(-1)^{|I|}(n-|I|)!=\sum_{k=0}^n(-1)^k{n\choose k}(n-k)!=n!\sum_{k=0}^n\frac{(-1)^k}{k!}.</math>
By Taylor's series,
:<math>\frac{1}{\mathrm{e}}=\sum_{k=0}^\infty\frac{(-1)^k}{k!}=\sum_{k=0}^n\frac{(-1)^k}{k!}\pm o\left(\frac{1}{n!}\right)</math>.
It is not hard to see that <math>n!\sum_{k=0}^n\frac{(-1)^k}{k!}</math> is the closest integer to <math>\frac{n!}{\mathrm{e}}</math>.
}}
 
Therefore, there are about <math>\frac{1}{\mathrm{e}}</math> fraction of all permutations with no fixed points.
 
=== Permutations with restricted positions ===
We introduce a general theory of counting permutations with restricted positions. In the derangement problem, we count the number of permutations that <math>\pi(i)\neq i</math>. We now generalize to the problem of counting permutations which avoid a set of arbitrarily specified positions.  


|belowstyle = background:#ddf;
It is traditionally described using terminology from the game of chess. Let <math>B\subseteq \{1,\ldots,n\}\times \{1,\ldots,n\}</math>, called a '''board'''.  As illustrated below, we can think of <math>B</math> as a chess board, with the positions in <math>B</math> marked by "<math>\times</math>".
|below =  
{{Chess diagram small
|
|
|=
8 |__|xx|xx|__|xx|__|__|xx|=
7 |xx|__|__|xx|__|__|xx|__|=
6 |xx|__|xx|xx|__|xx|xx|__|=
5 |__|xx|__|__|xx|__|xx|__|=
4 |xx|__|__|__|xx|xx|xx|__|=
3 |__|xx|__|xx|__|__|__|xx|=
2 |__|__|xx|__|xx|__|__|xx|=
1 |xx|__|__|xx|__|xx|__|__|=
a b c d e f g h
|
}}
}}
For a permutation <math>\pi</math> of <math>\{1,\ldots,n\}</math>, define the '''graph''' <math>G_\pi(V,E)</math> as
:<math>
\begin{align}
G_\pi &= \{(i,\pi(i))\mid i\in \{1,2,\ldots,n\}\}.
\end{align}
</math>
This can also be viewed as a set of marked positions on a chess board. Each row and each column has only one marked position, because <math>\pi</math> is a permutation. Thus, we can identify each <math>G_\pi</math> as a placement of <math>n</math> rooks (“城堡”,规则同中国象棋里的“车”) without attacking each other.


This is the page for the class ''Combinatorics'' for the Fall 2011 semester. Students who take this class should check this page periodically for content updates and new announcements.  
For example, the following is the <math>G_\pi</math> of such <math>\pi</math> that <math>\pi(i)=i</math>.
{{Chess diagram small
|
|
|=
8 |rl|__|__|__|__|__|__|__|=
7 |__|rl|__|__|__|__|__|__|=
6 |__|__|rl|__|__|__|__|__|=
5 |__|__|__|rl|__|__|__|__|=
4 |__|__|__|__|rl|__|__|__|=
3 |__|__|__|__|__|rl|__|__|=
2 |__|__|__|__|__|__|rl|__|=
1 |__|__|__|__|__|__|__|rl|=
a b c d e f g h
|
}}
Now define
:<math>\begin{align}
N_0 &= \left|\left\{\pi\mid B\cap G_\pi=\emptyset\right\}\right|\\
r_k &= \mbox{number of }k\mbox{-subsets of }B\mbox{ such that no two elements have a common coordinate}\\
&=\left|\left\{S\in{B\choose k} \,\bigg|\, \forall (i_1,j_1),(i_2,j_2)\in S, i_1\neq i_2, j_1\neq j_2 \right\}\right|
\end{align}
</math>
Interpreted in chess game,
* <math>B</math>: a set of marked positions in an <math>[n]\times [n]</math> chess board.
* <math>N_0</math>: the number of ways of placing <math>n</math> non-attacking rooks on the chess board such that none of these rooks lie in <math>B</math>.
* <math>r_k</math>: number of ways of placing <math>k</math> non-attacking rooks on <math>B</math>.


= Announcement =
Our goal is to count <math>N_0</math> in terms of <math>r_k</math>. This gives the number of permutations avoid all positions in a <math>B</math>.
* (10/28/2011) <font size=5 color=red>第三次作业的第二题做了点修改,请同学们注意。</font>
* (10/27/2011) <font size=3 color=red>第三次作业发布。两周后11月3日上课时交。</font>
* (09/29/2011) 第二次作业发布。两周后10月13日上课时交。
* (09/15/2011) 第一次作业发布,在Assignments部分。下周四上课时交。
* 由于有事需要外出,9月14日星期三下午的office hour改在9月13日下午。
* 第一、二次课的slides已发布,见lecture notes部分。


= Course info =
{{Theorem|Theorem|
* '''Instructor ''': 尹一通
:<math>N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!</math>.
:*email: yitong.yin@gmail.com, yinyt@nju.edu.cn,
}}
:*office: 804
{{Proof|
* '''Teaching fellow''': TBA
For each <math>i\in[n]</math>, let <math>A_i=\{\pi\mid (i,\pi(i))\in B\}</math> be the set of permutations <math>\pi</math> whose <math>i</math>-th position is in <math>B</math>.
:*email: TBA
* '''Class meeting''': Thursday 10am-12pm, 仙逸B-104.
* '''Office hour''': Wednesday 2-5pm, 计算机系 804.


<math>N_0</math> is the number of permutations avoid all positions in <math>B</math>. Thus, our goal is to count the number of permutations <math>\pi</math> in none of <math>A_i</math> for <math>i\in [n]</math>.


= Syllabus =
For each <math>I\subseteq [n]</math>, let <math>A_I=\bigcap_{i\in I}A_i</math>, which is the set of permutations <math>\pi</math> such that <math>(i,\pi(i))\in B</math> for all <math>i\in I</math>. Due to the principle of inclusion-exclusion,
:<math>N_0=\sum_{I\subseteq [n]} (-1)^{|I|}|A_I|=\sum_{k=0}^n(-1)^k\sum_{I\in{[n]\choose k}}|A_I|</math>.


=== 先修课程 Prerequisites ===
The next observation is that
* 离散数学(Discrete Mathematics)
:<math>\sum_{I\in{[n]\choose k}}|A_I|=r_k(n-k)!</math>,
* 线性代数(Linear Algebra)
because we can count both sides by first placing <math>k</math> non-attacking rooks on <math>B</math> and placing <math>n-k</math> additional non-attacking rooks on <math>[n]\times [n]</math> in <math>(n-k)!</math> ways.
* 概率论(Probability Theory)


=== Course materials ===
Therefore,
* [[组合数学 (Fall 2011)/Course materials|教材和参考书清单]]
:<math>N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!</math>.
}}


=== 成绩 Grades ===
====Derangement problem====
* 课程成绩:本课程将会有六次作业和一次期末考试。最终成绩将由平时作业成绩和期末考试成绩综合得出。
We use the above general method to solve the derange problem again.
* 迟交:如果有特殊的理由,无法按时完成作业,请提前联系授课老师,给出正当理由。否则迟交的作业将不被接受。


=== <font color=red> 学术诚信 Academic Integrity </font>===
Take <math>B=\{(1,1),(2,2),\ldots,(n,n)\}</math> as the chess board.  A derangement <math>\pi</math> is a placement of <math>n</math> non-attacking rooks such that none of them is in <math>B</math>.
学术诚信是所有从事学术活动的学生和学者最基本的职业道德底线,本课程将不遗余力的维护学术诚信规范,违反这一底线的行为将不会被容忍。
{{Chess diagram small
|
|
|=
8 |xx|__|__|__|__|__|__|__|=
7 |__|xx|__|__|__|__|__|__|=
6 |__|__|xx|__|__|__|__|__|=
5 |__|__|__|xx|__|__|__|__|=
4 |__|__|__|__|xx|__|__|__|=
3 |__|__|__|__|__|xx|__|__|=
2 |__|__|__|__|__|__|xx|__|=
1 |__|__|__|__|__|__|__|xx|=
a b c d e f g h
|
}}
Clearly, the number of ways of placing <math>k</math> non-attacking rooks on <math>B</math> is <math>r_k={n\choose k}</math>. We want to count <math>N_0</math>, which gives the number of ways of placing <math>n</math> non-attacking rooks such that none of these rooks lie in <math>B</math>.


作业完成的原则:署你名字的工作必须由你完成。允许讨论,但作业必须独立完成,并在作业中列出所有参与讨论的人。不允许其他任何形式的合作——尤其是与已经完成作业的同学“讨论”。
By the above theorem
:<math>
N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!=\sum_{k=0}^n(-1)^k{n\choose k}(n-k)!=\sum_{k=0}^n(-1)^k\frac{n!}{k!}=n!\sum_{k=0}^n(-1)^k\frac{1}{k!}\approx\frac{n!}{e}.
</math>


本课程将对剽窃行为采取零容忍的态度。在完成作业过程中,对他人工作(出版物、互联网资料、其他人的作业等)直接的文本抄袭和对关键思想、关键元素的抄袭,按照 [http://www.acm.org/publications/policies/plagiarism_policy ACM Policy on Plagiarism]的解释,都将视为剽窃。剽窃者成绩将被取消。如果发现互相抄袭行为,<font color=red> 抄袭和被抄袭双方的成绩都将被取消</font>。因此请主动防止自己的作业被他人抄袭。
====Problème des ménages====
Suppose that in a banquet, we want to seat <math>n</math> couples at a circular table, satisfying the following constraints:
* Men and women are in alternate places.
* No one sits next to his/her spouse.


学术诚信影响学生个人的品行,也关乎整个教育系统的正常运转。为了一点分数而做出学术不端的行为,不仅使自己沦为一个欺骗者,也使他人的诚实努力失去意义。让我们一起努力维护一个诚信的环境。
In how many ways can this be done?


= Assignments =
(For convenience, we assume that every seat at the table marked differently so that rotating the seats clockwise or anti-clockwise will end up with a '''different''' solution.)
* (2011/09/15) [[组合数学 (Fall 2011)/Problem set 1|Problem set 1]] due on Sept 22, in class.
* (2011/09/29) [[组合数学 (Fall 2011)/Problem set 2|Problem set 2]] due on Oct 13, in class.
* (2011/10/27) [[组合数学 (Fall 2011)/Problem set 3|Problem set 3]] due on Nov 3, in class.
* (2011/11/17) [[组合数学 (Fall 2011)/Problem set 4|Problem set 4]] due on Dec 1, in class.


= Lecture Notes =
First, let the <math>n</math> ladies find their seats. They may either sit at the odd numbered seats or even numbered seats, in either case, there are <math>n!</math> different orders. Thus, there are <math>2(n!)</math> ways to seat the <math>n</math> ladies.
# [[组合数学 (Fall 2011)/Basic enumeration|Basic enumeration]] | [ftp://tcs.nju.edu.cn/slides/comb2011/comb1.pdf slides1] | [ftp://tcs.nju.edu.cn/slides/comb2011/comb2-1.pdf slides2]
 
# [[组合数学 (Fall 2011)/Generating functions|Generating functions]] | [ftp://tcs.nju.edu.cn/slides/comb2011/comb2-2.pdf slides1] | [ftp://tcs.nju.edu.cn/slides/comb2011/comb3.pdf slides2]
After sitting the wives, we label the remaining <math>n</math> places clockwise as <math>0,1,\ldots, n-1</math>. And a seating of the <math>n</math> husbands is given by a permutation <math>\pi</math> of <math>[n]</math> defined as follows. Let <math>\pi(i)</math> be the seat of the husband of he lady sitting at the <math>i</math>-th place.
# [[组合数学 (Fall 2011)/Sieve methods|Sieve methods]] | [ftp://tcs.nju.edu.cn/slides/comb2011/comb4.pdf slides]
 
# [[组合数学 (Fall 2011)/Pólya's theory of counting|Pólya's theory of counting]]
It is easy to see that <math>\pi</math> satisfies that <math>\pi(i)\neq i</math> and <math>\pi(i)\not\equiv i+1\pmod n</math>, and every permutation <math>\pi</math> with these properties gives a feasible seating of the <math>n</math> husbands. Thus, we only need to count the number of permutations <math>\pi</math> such that <math>\pi(i)\not\equiv i, i+1\pmod n</math>.
# [[组合数学 (Fall 2011)/Counting and existence|Counting and existence]]  | [ftp://tcs.nju.edu.cn/slides/comb2011/comb6.pdf slides]
 
# [[组合数学 (Fall 2011)/Discrete probability|Discrete probability]]
Take <math>B=\{(0,0),(1,1),\ldots,(n-1,n-1), (0,1),(1,2),\ldots,(n-2,n-1),(n-1,0)\}</math> as the chess board.  A permutation <math>\pi</math> which defines a way of seating the husbands, is a placement of <math>n</math> non-attacking rooks such that none of them is in <math>B</math>.
# [[组合数学 (Fall 2011)/The probabilistic method|The probabilistic method]] |  [ftp://tcs.nju.edu.cn/slides/comb2011/comb8.pdf slides]
{{Chess diagram small
# [[组合数学 (Fall 2011)/Extremal graph theory| Extremal graph theory]] |  [ftp://tcs.nju.edu.cn/slides/comb2011/comb9.pdf slides]
|
# [[组合数学 (Fall 2011)/Extremal set theory|Extremal set theory]] | [ftp://tcs.nju.edu.cn/slides/comb2011/comb10.pdf slides]
|
# [[组合数学 (Fall 2011)/Ramsey theory|Ramsey theory]] | [ftp://tcs.nju.edu.cn/slides/comb2011/comb11.pdf slides]
|=
# [[组合数学 (Fall 2011)/Matching theory|Matching theory]]
8 |xx|xx|__|__|__|__|__|__|=
# [[组合数学 (Fall 2011)/Flow and matching | Flow and matching]]
7 |__|xx|xx|__|__|__|__|__|=
# [[组合数学 (Fall 2011)/Optimization|Optimization]]
6 |__|__|xx|xx|__|__|__|__|=
# [[组合数学 (Fall 2011)/Matroid|Matroid]]
5 |__|__|__|xx|xx|__|__|__|=
4 |__|__|__|__|xx|xx|__|__|=
3 |__|__|__|__|__|xx|xx|__|=
2 |__|__|__|__|__|__|xx|xx|=
1 |xx|__|__|__|__|__|__|xx|=
  a b c d e f g h
|
}}
We need to compute <math>r_k</math>, the number of ways of placing <math>k</math> non-attacking rooks on <math>B</math>. For our choice of <math>B</math>, <math>r_k</math> is the number of ways of choosing <math>k</math> points, no two consecutive, from a collection of <math>2n</math> points arranged in a circle.
 
We first see how to do this in a ''line''.
{{Theorem|Lemma|
:The number of ways of choosing <math>k</math> ''non-consecutive'' objects from a collection of <math>m</math> objects arranged in a ''line'', is <math>{m-k+1\choose k}</math>.
}}
{{Proof|
We draw a line of <math>m-k</math> black points, and then insert <math>k</math> red points into the <math>m-k+1</math> spaces between the black points (including the beginning and end).
::<math>
\begin{align}
&\sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \\
&\qquad\qquad\qquad\quad\Downarrow\\
&\sqcup \, \bullet \,\, {\color{Red}\bullet} \, \bullet \,\, {\color{Red}\bullet} \, \bullet \, \sqcup \, \bullet \,\, {\color{Red}\bullet}\, \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \,\, {\color{Red}\bullet}
\end{align}
</math>
This gives us a line of <math>m</math> points, and the red points specifies the chosen objects, which are non-consecutive. The mapping is 1-1 correspondence.
There are <math>{m-k+1\choose k}</math> ways of placing <math>k</math> red points into <math>m-k+1</math> spaces.
}}
 
The problem of choosing non-consecutive objects in a circle can be reduced to the case that the objects are in a line.
 
{{Theorem|Lemma|
:The number of ways of choosing <math>k</math> ''non-consecutive'' objects from a collection of <math>m</math> objects arranged in a ''circle'', is <math>\frac{m}{m-k}{m-k\choose k}</math>.
}}
{{Proof|
Let <math>f(m,k)</math> be the desired number; and let <math>g(m,k)</math> be the number of ways of choosing <math>k</math> non-consecutive points from <math>m</math> points arranged in a circle, next coloring the <math>k</math> points red, and then coloring one of the uncolored point blue.
 
Clearly, <math>g(m,k)=(m-k)f(m,k)</math>.
 
But we can also compute <math>g(m,k)</math> as follows:
* Choose one of the <math>m</math> points and color it blue. This gives us <math>m</math> ways.
* Cut the circle to make a line of <math>m-1</math> points by removing the blue point.
* Choose <math>k</math> non-consecutive points from the line of <math>m-1</math> points and color them red. This gives <math>{m-k\choose k}</math> ways due to the previous lemma.
 
Thus, <math>g(m,k)=m{m-k\choose k}</math>. Therefore we have the desired number <math>f(m,k)=\frac{m}{m-k}{m-k\choose k}</math>.
}}
 
By the above lemma, we have that <math>r_k=\frac{2n}{2n-k}{2n-k\choose k}</math>. Then apply the theorem of counting permutations with restricted positions,
:<math>
N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!=\sum_{k=0}^n(-1)^k\frac{2n}{2n-k}{2n-k\choose k}(n-k)!.
</math>
 
This gives the number of ways of seating the <math>n</math> husbands ''after the ladies are seated''. Recall that there are <math>2n!</math> ways of seating the <math>n</math> ladies. Thus, the total number of ways of seating <math>n</math> couples as required by problème des ménages is
:<math>
2n!\sum_{k=0}^n(-1)^k\frac{2n}{2n-k}{2n-k\choose k}(n-k)!.
</math>
 
=== The Euler totient function ===
Two integers <math>m, n</math> are said to be '''relatively prime''' if their greatest common diviser <math>\mathrm{gcd}(m,n)=1</math>. For a positive integer <math>n</math>, let <math>\phi(n)</math> be the number of positive integers from <math>\{1,2,\ldots,n\}</math> that are relative prime to <math>n</math>. This function, called the Euler <math>\phi</math> function or '''the Euler totient function''', is fundamental in number theory.
 
We now derive a formula for this function by using the principle of inclusion-exclusion.
{{Theorem|Theorem (The Euler totient function)|
Suppose <math>n</math> is divisible by precisely <math>r</math> different primes, denoted <math>p_1,\ldots,p_r</math>. Then
:<math>\phi(n)=n\prod_{i=1}^r\left(1-\frac{1}{p_i}\right)</math>.
}}
{{Proof|
Let <math>U=\{1,2,\ldots,n\}</math> be the universe. The number of positive integers from <math>U</math> which is divisible by some <math>p_{i_1},p_{i_2},\ldots,p_{i_s}\in\{p_1,\ldots,p_r\}</math>, is <math>\frac{n}{p_{i_1}p_{i_2}\cdots p_{i_s}}</math>.  
 
<math>\phi(n)</math> is the number of integers from <math>U</math> which is not divisible by any <math>p_1,\ldots,p_r</math>.
By principle of inclusion-exclusion,
:<math>
\begin{align}
\phi(n)
&=n+\sum_{k=1}^r(-1)^k\sum_{1\le i_1<i_2<\cdots <i_k\le n}\frac{n}{p_{i_1}p_{i_2}\cdots p_{i_k}}\\
&=n-\sum_{1\le i\le n}\frac{n}{p_i}+\sum_{1\le i<j\le n}\frac{n}{p_i p_j}-\sum_{1\le i<j<k\le n}\frac{n}{p_{i} p_{j} p_{k}}+\cdots + (-1)^r\frac{n}{p_{1}p_{2}\cdots p_{r}}\\
&=n\left(1-\sum_{1\le i\le n}\frac{1}{p_i}+\sum_{1\le i<j\le n}\frac{1}{p_i p_j}-\sum_{1\le i<j<k\le n}\frac{1}{p_{i} p_{j} p_{k}}+\cdots + (-1)^r\frac{1}{p_{1}p_{2}\cdots p_{r}}\right)\\
&=n\prod_{i=1}^n\left(1-\frac{1}{p_i}\right).
\end{align}
</math>
}}
 
== Möbius inversion ==
 
=== Posets ===
A '''partially ordered set''' or '''poset''' for short is a set <math>P</math> together with a binary relation denoted <math>\le_P</math> (or just <math>\le</math> if no confusion is caused), satisfying
* (''reflexivity'') For all <math>x\in P, x\le x</math>.
* (''antisymmetry'') If <math>x\le y</math> and <math>y\le x</math>, then <math>x=y</math>.
* (''transitivity'') If <math>x\le y</math> and <math>y\le z</math>, then <math>x\le z</math>.
 
We say two elements <math>x</math> and <math>y</math> are '''comparable''' if <math>x\le y</math> or <math>y\le x</math>; otherwise <math>x</math> and <math>y</math> are '''incomparable'''.
 
;Notation
* <math>x\ge y</math> means <math>y\le x</math>.
* <math>x<y</math> means <math>x\le y</math> and <math>x\neq y</math>.
* <math>x>y</math> means <math>y<x</math>.
 
=== The Möbius function===
Let <math>P</math> be a finite poset. Consider functions in form of <math>\alpha:P\times P\rightarrow\mathbb{R}</math> defined over domain <math>P\times P</math>. It is convenient to treat such functions as matrices whose rows and columns are indexed by <math>P</math>.
 
;Incidence algebra of poset
:Let
::<math>\mathbb{A}(P)=\{\alpha:P\times P\rightarrow\mathbb{R}\mid \alpha(x,y)=0\text{ for all }x\not\le_P y\}</math>
:be the class of <math>\alpha</math> such that <math>\alpha(x,y)</math> is non-zero only for <math>x\le_P y</math>.
 
:Treating <math>\alpha</math> as matrix, it is trivial to see that <math>\mathbb{A}(P)</math> is closed under addition and scalar multiplication, that is,
:* if <math>\alpha,\beta\in \mathbb{A}(P)</math> then <math>\alpha+\beta\in\mathbb{A}(P)</math>;
:* if <math>\alpha\in \mathbb{A}(P)</math> then <math>c\alpha\in\mathbb{A}(P)</math> for any <math>c\in\mathbb{R}</math>;
:where <math>\alpha,\beta</math> are treated as matrices.
 
:With this spirit, it is natural to define the matrix multiplication in <math>\mathbb{A}(P)</math>. For <math>\alpha,\beta\in \mathbb{A}(P)</math>,
::<math>(\alpha\beta)(x,y)=\sum_{z\in P}\alpha(x,z)\beta(z,y)=\sum_{x\le z\le y}\alpha(x,z)\beta(z,y)</math>.
:The second equation is due to that for <math>\alpha,\beta\in \mathbb{A}(P)</math>, for all <math>z</math> other than <math>x\le z\le y</math>, <math>\alpha(x,z)\beta(z,y)</math> is zero.
:By transitivity, it is also easy to observe that <math>\mathbb{A}(P)</math> is closed under matrix multiplication (the detailed proof is left as an exercise). Therefore, <math>\mathbb{A}(P)</math> is closed under addition, scalar multiplication and matrix multiplication, so we have an algebra <math>\mathbb{A}(P)</math>, called '''incidence algebra''', over functions on <math>P\times P</math>.
 
;Zeta function and Möbius function
:A special function in <math>\mathbb{A}(P)</math> is the so-called '''zeta function''' <math>\zeta</math>, defined as
::<math>\zeta(x,y)=\begin{cases}1&\text{if }x\le_P y,\\0 &\text{otherwise.}\end{cases}</math>
:As a matrix (or more accurately, as an element of the incidence algebra), <math>\zeta</math> is invertible and its inversion, denoted by <math>\mu</math>, is called the '''Möbius function'''. More precisely, <math>\mu</math> is also in the incidence algebra <math>\mathbb{A}(P)</math>, and <math>\mu\zeta=I</math> where <math>I</math> is the identity matrix (the identity of the incidence algebra <math>\mathbb{A}(P)</math>).
 
There is an equivalent explicit definition of Möbius function.
{{Theorem|Definition (Möbius function)|
:<math>\mu(x,y)=\begin{cases}
-\sum_{x\le z\le y}\mu(x,z)&\text{if }x<y,\\
1&\text{if }x=y,\\
0&\text{if }x\not\le y.
\end{cases}
</math>
}}
 
To see the equivalence between this definition and the inversion of zeta function, we may have the following proposition, which is proved by directly evaluating <math>\mu\zeta</math>.
{{Theorem|Proposition|
:For any <math>x,y\in P</math>,
::<math>\sum_{x\le z\le y}\mu(x,z)=\begin{cases}1 &\text{if }x=y,\\
0 &\text{otherwise.}\end{cases}</math>
}}
{{Proof|
It holds that
:<math>(\mu\zeta)(x,y)=\sum_{x\le z\le y}\mu(x,z)\zeta(z,y)=\sum_{x\le z\le y}\mu(x,z)</math>.
On the other hand, <math>\mu\zeta=I</math>, i.e.  
:<math>(\mu\zeta)(x,y)=\begin{cases}1 &\text{if }x=y,\\
0 &\text{otherwise.}\end{cases}</math>
The proposition follows.
}}
Note that <math>\mu(x,y)=\sum_{x\le z\le y}\mu(x,z)-\sum_{x\le z< y}\mu(x,z)</math>, which gives the above inductive definition of Möbius function.
 
=== Principle of Möbius inversion ===
{{Theorem|Möbius inversion formula|
:Let <math>P</math> be a finite poset and <math>\mu</math> its Möbius function. Let <math>f,g:P\rightarrow \mathbb{R}</math>. Then
::<math>\forall x\in P,\,\, g(x)=\sum_{y\le x} f(y)</math>,
:if and only if
::<math>\forall x\in P,\,\, f(x)=\sum_{y\le x}g(y)\mu(y,x)</math>.
}}
 
 
{{Theorem|Möbius inversion formula, dual form|
:Let <math>P</math> be a finite poset and <math>\mu</math> its Möbius function. Let <math>f,g:P\rightarrow \mathbb{R}</math>. Then
::<math>\forall x\in P, \,\, g(x)=\sum_{y{\color{red}\ge} x} f(y)</math>,
: if and only if
::<math>\forall x\in P, \,\, f(x)=\sum_{y{\color{red}\ge} x}g(y)\mu(y,x)</math>.
}}


= Concepts =
== Reference ==
* [http://en.wikipedia.org/wiki/Binomial_coefficient Binomial coefficient]
* ''Stanley,'' Enumerative Combinatorics, Volume 1, Chapter 2.
* [http://en.wikipedia.org/wiki/Composition_(number_theory) Composition of a number]
* ''van Lin and Wilson'', A course in combinatorics, Chapter 10, 15.
* [http://en.wikipedia.org/wiki/Combination#Number_of_combinations_with_repetition Combinations with repetition], [http://en.wikipedia.org/wiki/Multiset_coefficient#Multiset_coefficients <math>k</math>-multisets on a set]
* [http://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind Stirling number of the second kind]
* [http://en.wikipedia.org/wiki/Partition_(number_theory) Partition of a number]
* [http://en.wikipedia.org/wiki/Partition_(number_theory)#Ferrers_diagram Ferrers diagram] (and the MathWorld [http://mathworld.wolfram.com/FerrersDiagram.html link])
* [http://en.wikipedia.org/wiki/Twelvefold_way The twelvefold way]
* [http://en.wikipedia.org/wiki/Generating_function Generating function] and [http://en.wikipedia.org/wiki/Formal_power_series formal power series]
* [http://en.wikipedia.org/wiki/Fibonacci_number Fibonacci number]
* [http://en.wikipedia.org/wiki/Binomial_series Newton's formula]
* [http://en.wikipedia.org/wiki/Catalan_number Catalan number]
* [http://en.wikipedia.org/wiki/Inclusion-exclusion_principle The principle of inclusion-exclusion] (and more generally the [http://en.wikipedia.org/wiki/Sieve_theory sieve method])
* [http://en.wikipedia.org/wiki/M%C3%B6bius_inversion_formula Möbius inversion formula]
* [http://en.wikipedia.org/wiki/Derangement Derangement], and [http://en.wikipedia.org/wiki/M%C3%A9nage_problem Problème des ménages]
* [http://en.wikipedia.org/wiki/Burnside's_lemma Burnside's lemma]
* [http://en.wikipedia.org/wiki/P%C3%B3lya_enumeration_theorem Pólya enumeration theorem]
* [http://en.wikipedia.org/wiki/Double_counting_(proof_technique) Double counting] and the [http://en.wikipedia.org/wiki/Handshaking_lemma handshaking lemma]
* [http://en.wikipedia.org/wiki/Sperner's_lemma Sperner's lemma] and [http://en.wikipedia.org/wiki/Brouwer_fixed_point_theorem Brouwer fixed point theorem]
* [http://en.wikipedia.org/wiki/Cayley's_formula Cayley's formula]
* [http://en.wikipedia.org/wiki/Pigeonhole_principle Pigeonhole principle]
:* [http://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Szekeres_theorem Erdős–Szekeres theorem]
:* [http://en.wikipedia.org/wiki/Dirichlet's_approximation_theorem Dirichlet's approximation theorem]
* [http://en.wikipedia.org/wiki/Probabilistic_method The Probabilistic Method]
* [http://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93R%C3%A9nyi_model Erdős–Rényi model for random graphs]
* [http://en.wikipedia.org/wiki/Graph_property Graph property]
* Some graph parameters: [http://en.wikipedia.org/wiki/Girth_(graph_theory) girth <math>g(G)</math>], [http://mathworld.wolfram.com/ChromaticNumber.html chromatic number <math>\chi(G)</math>], [http://mathworld.wolfram.com/IndependenceNumber.html Independence number <math>\alpha(G)</math>], [http://mathworld.wolfram.com/CliqueNumber.html clique number <math>\omega(G)</math>]
* [http://en.wikipedia.org/wiki/Extremal_graph_theory Extremal graph theory]
* [http://en.wikipedia.org/wiki/Turan_theorem Turán's theorem], [http://en.wikipedia.org/wiki/Tur%C3%A1n_graph Turán graph]
* Two analytic inequalities:
:*[http://en.wikipedia.org/wiki/Cauchy%E2%80%93Schwarz_inequality Cauchy–Schwarz inequality]
:* the [http://en.wikipedia.org/wiki/Inequality_of_arithmetic_and_geometric_means inequality of arithmetic and geometric means]
* [http://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Stone_theorem Erdős–Stone theorem] (fundamental theorem of extremal graph theory)
* [http://en.wikipedia.org/wiki/Dirac's_theorem Dirac's theorem]
* [http://en.wikipedia.org/wiki/Hall's_theorem Hall's theorem ] (the marriage theorem)
* [http://en.wikipedia.org/wiki/Birkhoff-Von_Neumann_theorem Birkhoff-Von Neumann theorem]
* [http://en.wikipedia.org/wiki/K%C3%B6nig's_theorem_(graph_theory) König-Egerváry theorem]
* [http://en.wikipedia.org/wiki/Dilworth's_theorem Dilworth's theorem]
* [http://en.wikipedia.org/wiki/Sperner_family Sperner system]
* [http://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Ko%E2%80%93Rado_theorem Erdős–Ko–Rado theorem]
* [http://en.wikipedia.org/wiki/VC_dimension VC dimension]
* [http://en.wikipedia.org/wiki/Kruskal%E2%80%93Katona_theorem Kruskal–Katona theorem]
* [http://en.wikipedia.org/wiki/Ramsey_theory Ramsey theory]
:*[http://en.wikipedia.org/wiki/Ramsey's_theorem Ramsey's theorem]
:*[http://en.wikipedia.org/wiki/Happy_Ending_problem Happy Ending problem]
:*[http://en.wikipedia.org/wiki/Van_der_Waerden's_theorem Van der Waerden's theorem]
:*[http://en.wikipedia.org/wiki/Hales-Jewett_theorem Hales–Jewett theorem]
* [http://en.wikipedia.org/wiki/Lov%C3%A1sz_local_lemma Lovász local lemma]
* [http://en.wikipedia.org/wiki/Combinatorial_optimization Combinatorial optimization]
:* [http://en.wikipedia.org/wiki/Optimization_(mathematics) optimization]
:* [http://en.wikipedia.org/wiki/Convex_combination convex combination], [http://en.wikipedia.org/wiki/Convex_set convex set], [http://en.wikipedia.org/wiki/Convex_function convex function]
:* [http://en.wikipedia.org/wiki/Local_optimum local optimum] (see also [http://en.wikipedia.org/wiki/Maxima_and_minima maxima and minima])
* [http://en.wikipedia.org/wiki/Linear_programming Linear programming]
:* [http://en.wikipedia.org/wiki/Linear_inequality linear constraint]
:* [http://en.wikipedia.org/wiki/Hyperplane hyperplane], [http://en.wikipedia.org/wiki/Half_space halfspace], [http://en.wikipedia.org/wiki/Polyhedron polyhedron], [http://en.wikipedia.org/wiki/Convex_polytope convex polytope]
:* [http://en.wikipedia.org/wiki/Simplex_algorithm the Simplex algorithm]
*  The  [http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem Max-Flow Min-Cut Theorem]
:* [http://en.wikipedia.org/wiki/Maximum_flow_problem Maximum flow]
:* [http://en.wikipedia.org/wiki/Minimum_cut minimum cut]
* [http://en.wikipedia.org/wiki/Unimodular_matrix Unimodularity]
* [http://en.wikipedia.org/wiki/Dual_linear_program Duality]
:* [http://en.wikipedia.org/wiki/Linear_programming#Duality LP Duality]
* [http://en.wikipedia.org/wiki/Matroid Matroid]
:* [http://en.wikipedia.org/wiki/Weighted_matroid weighted matroid] and [http://en.wikipedia.org/wiki/Greedy_algorithm greedy algorithm]
:* [http://en.wikipedia.org/wiki/Matroid_intersection Matroid intersection]
* [http://en.wikipedia.org/wiki/Laplacian_matrix Laplacian]
* [http://en.wikipedia.org/wiki/Algebraic_connectivity <math>\lambda_2</math> of a graph] and [http://en.wikipedia.org/wiki/Expander_graph#Cheeger_Inequalities Cheeger Inequalities]
* [http://en.wikipedia.org/wiki/Expander_graph Expander graph]
* [http://en.wikipedia.org/wiki/Szemer%C3%A9di_regularity_lemma Szemerédi regularity lemma]

Revision as of 09:08, 21 September 2011

Principle of Inclusion-Exclusion

Let [math]\displaystyle{ A }[/math] and [math]\displaystyle{ B }[/math] be two finite sets. The cardinality of their union is

[math]\displaystyle{ |A\cup B|=|A|+|B|-{\color{Blue}|A\cap B|} }[/math].

For three sets [math]\displaystyle{ A }[/math], [math]\displaystyle{ B }[/math], and [math]\displaystyle{ C }[/math], the cardinality of the union of these three sets is computed as

[math]\displaystyle{ |A\cup B\cup C|=|A|+|B|+|C|-{\color{Blue}|A\cap B|}-{\color{Blue}|A\cap C|}-{\color{Blue}|B\cap C|}+{\color{Red}|A\cap B\cap C|} }[/math].

This is illustrated by the following figure.

Generally, the Principle of Inclusion-Exclusion states the rule for computing the union of [math]\displaystyle{ n }[/math] finite sets [math]\displaystyle{ A_1,A_2,\ldots,A_n }[/math], such that

[math]\displaystyle{ \begin{align} \left|\bigcup_{i=1}^nA_i\right| &= \sum_{I\subseteq\{1,\ldots,n\}}(-1)^{|I|-1}\left|\bigcap_{i\in I}A_i\right|. \end{align} }[/math]


In combinatorial enumeration, the Principle of Inclusion-Exclusion is usually applied in its complement form.

Let [math]\displaystyle{ A_1,A_2,\ldots,A_n\subseteq U }[/math] be subsets of some finite set [math]\displaystyle{ U }[/math]. Here [math]\displaystyle{ U }[/math] is some universe of combinatorial objects, whose cardinality is easy to calculate (e.g. all strings, tuples, permutations), and each [math]\displaystyle{ A_i }[/math] contains the objects with some specific property (e.g. a "pattern") which we want to avoid. The problem is to count the number of objects without any of the [math]\displaystyle{ n }[/math] properties. We write [math]\displaystyle{ \bar{A_i}=U-A_i }[/math]. The number of objects without any of the properties [math]\displaystyle{ A_1,A_2,\ldots,A_n }[/math] is

[math]\displaystyle{ \begin{align} \left|\bar{A_1}\cap\bar{A_2}\cap\cdots\cap\bar{A_n}\right|=\left|U-\bigcup_{i=1}^nA_i\right| &= |U|+\sum_{I\subseteq\{1,\ldots,n\}}(-1)^{|I|}\left|\bigcap_{i\in I}A_i\right|. \end{align} }[/math]

For an [math]\displaystyle{ I\subseteq\{1,2,\ldots,n\} }[/math], we denote

[math]\displaystyle{ A_I=\bigcap_{i\in I}A_i }[/math]

with the convention that [math]\displaystyle{ A_\emptyset=U }[/math]. The above equation is stated as:

Principle of Inclusion-Exclusion
Let [math]\displaystyle{ A_1,A_2,\ldots,A_n }[/math] be a family of subsets of [math]\displaystyle{ U }[/math]. Then the number of elements of [math]\displaystyle{ U }[/math] which lie in none of the subsets [math]\displaystyle{ A_i }[/math] is
[math]\displaystyle{ \sum_{I\subseteq\{1,\ldots, n\}}(-1)^{|I|}|A_I| }[/math].

Let [math]\displaystyle{ S_k=\sum_{|I|=k}|A_I|\, }[/math]. Conventionally, [math]\displaystyle{ S_0=|A_\emptyset|=|U| }[/math]. The principle of inclusion-exclusion can be expressed as

[math]\displaystyle{ S_0-S_1+S_2+\cdots+(-1)^nS_n. }[/math]

Surjections

In the twelvefold way, we discuss the counting problems incurred by the mappings [math]\displaystyle{ f:N\rightarrow M }[/math]. The basic case is that elements from both [math]\displaystyle{ N }[/math] and [math]\displaystyle{ M }[/math] are distinguishable. In this case, it is easy to count the number of arbitrary mappings (which is [math]\displaystyle{ m^n }[/math]) and the number of injective (one-to-one) mappings (which is [math]\displaystyle{ (m)_n }[/math]), but the number of surjective is difficult. Here we apply the principle of inclusion-exclusion to count the number of surjective (onto) mappings.

Theorem
The number of surjective mappings from an [math]\displaystyle{ n }[/math]-set to an [math]\displaystyle{ m }[/math]-set is given by
[math]\displaystyle{ \sum_{k=1}^m(-1)^{m-k}{m\choose k}k^n }[/math].
Proof.

Let [math]\displaystyle{ U=\{f:[n]\rightarrow[m]\} }[/math] be the set of mappings from [math]\displaystyle{ [n] }[/math] to [math]\displaystyle{ [m] }[/math]. Then [math]\displaystyle{ |U|=m^n }[/math].

For [math]\displaystyle{ i\in[m] }[/math], let [math]\displaystyle{ A_i }[/math] be the set of mappings [math]\displaystyle{ f:[n]\rightarrow[m] }[/math] that none of [math]\displaystyle{ j\in[n] }[/math] is mapped to [math]\displaystyle{ i }[/math], i.e. [math]\displaystyle{ A_i=\{f:[n]\rightarrow[m]\setminus\{i\}\} }[/math], thus [math]\displaystyle{ |A_i|=(m-1)^n }[/math].

More generally, for [math]\displaystyle{ I\subseteq [m] }[/math], [math]\displaystyle{ A_I=\bigcap_{i\in I}A_i }[/math] contains the mappings [math]\displaystyle{ f:[n]\rightarrow[m]\setminus I }[/math]. And [math]\displaystyle{ |A_I|=(m-|I|)^n\, }[/math].

A mapping [math]\displaystyle{ f:[n]\rightarrow[m] }[/math] is surjective if [math]\displaystyle{ f }[/math] lies in none of [math]\displaystyle{ A_i }[/math]. By the principle of inclusion-exclusion, the number of surjective [math]\displaystyle{ f:[n]\rightarrow[m] }[/math] is

[math]\displaystyle{ \sum_{I\subseteq[m]}(-1)^{|I|}\left|A_I\right|=\sum_{I\subseteq[m]}(-1)^{|I|}(m-|I|)^n=\sum_{j=0}^m(-1)^j{m\choose j}(m-j)^n }[/math].

Let [math]\displaystyle{ k=m-j }[/math]. The theorem is proved.

[math]\displaystyle{ \square }[/math]

Recall that, in the twelvefold way, we establish a relation between surjections and partitions.

  • Surjection to ordered partition:
For a surjective [math]\displaystyle{ f:[n]\rightarrow[m] }[/math], [math]\displaystyle{ (f^{-1}(0),f^{-1}(1),\ldots,f^{-1}(m-1)) }[/math] is an ordered partition of [math]\displaystyle{ [n] }[/math].
  • Ordered partition to surjection:
For an ordered [math]\displaystyle{ m }[/math]-partition [math]\displaystyle{ (B_0,B_1,\ldots, B_{m-1}) }[/math] of [math]\displaystyle{ [n] }[/math], we can define a function [math]\displaystyle{ f:[n]\rightarrow[m] }[/math] by letting [math]\displaystyle{ f(i)=j }[/math] if and only if [math]\displaystyle{ i\in B_j }[/math]. [math]\displaystyle{ f }[/math] is surjective since as a partition, none of [math]\displaystyle{ B_i }[/math] is empty.

Therefore, we have a one-to-one correspondence between surjective mappings from an [math]\displaystyle{ n }[/math]-set to an [math]\displaystyle{ m }[/math]-set and the ordered [math]\displaystyle{ m }[/math]-partitions of an [math]\displaystyle{ n }[/math]-set.

The Stirling number of the second kind [math]\displaystyle{ S(n,m) }[/math] is the number of [math]\displaystyle{ m }[/math]-partitions of an [math]\displaystyle{ n }[/math]-set. There are [math]\displaystyle{ m! }[/math] ways to order an [math]\displaystyle{ m }[/math]-partition, thus the number of surjective mappings [math]\displaystyle{ f:[n]\rightarrow[m] }[/math] is [math]\displaystyle{ m! S(n,m) }[/math]. Combining with what we have proved for surjections, we give the following result for the Stirling number of the second kind.

Proposition
[math]\displaystyle{ S(n,m)=\frac{1}{m!}\sum_{k=1}^m(-1)^{m-k}{m\choose k}k^n }[/math].

Derangements

We now count the number of bijections from a set to itself with no fixed points. This is the derangement problem.

For a permutation [math]\displaystyle{ \pi }[/math] of [math]\displaystyle{ \{1,2,\ldots,n\} }[/math], a fixed point is such an [math]\displaystyle{ i\in\{1,2,\ldots,n\} }[/math] that [math]\displaystyle{ \pi(i)=i }[/math]. A derangement of [math]\displaystyle{ \{1,2,\ldots,n\} }[/math] is a permutation of [math]\displaystyle{ \{1,2,\ldots,n\} }[/math] that has no fixed points.

Theorem
The number of derangements of [math]\displaystyle{ \{1,2,\ldots,n\} }[/math] given by
[math]\displaystyle{ n!\sum_{k=0}^n\frac{(-1)^k}{k!}\approx \frac{n!}{\mathrm{e}} }[/math].
Proof.

Let [math]\displaystyle{ U }[/math] be the set of all permutations of [math]\displaystyle{ \{1,2,\ldots,n\} }[/math]. So [math]\displaystyle{ |U|=n! }[/math].

Let [math]\displaystyle{ A_i }[/math] be the set of permutations with fixed point [math]\displaystyle{ i }[/math]; so [math]\displaystyle{ |A_i|=(n-1)! }[/math]. More generally, for any [math]\displaystyle{ I\subseteq \{1,2,\ldots,n\} }[/math], [math]\displaystyle{ A_I=\bigcap_{i\in I}A_i }[/math], and [math]\displaystyle{ |A_I|=(n-|I|)! }[/math], since permutations in [math]\displaystyle{ A_I }[/math] fix every point in [math]\displaystyle{ I }[/math] and permute the remaining points arbitrarily. A permutation is a derangement if and only if it lies in none of the sets [math]\displaystyle{ A_i }[/math]. So the number of derangements is

[math]\displaystyle{ \sum_{I\subseteq\{1,2,\ldots,n\}}(-1)^{|I|}(n-|I|)!=\sum_{k=0}^n(-1)^k{n\choose k}(n-k)!=n!\sum_{k=0}^n\frac{(-1)^k}{k!}. }[/math]

By Taylor's series,

[math]\displaystyle{ \frac{1}{\mathrm{e}}=\sum_{k=0}^\infty\frac{(-1)^k}{k!}=\sum_{k=0}^n\frac{(-1)^k}{k!}\pm o\left(\frac{1}{n!}\right) }[/math].

It is not hard to see that [math]\displaystyle{ n!\sum_{k=0}^n\frac{(-1)^k}{k!} }[/math] is the closest integer to [math]\displaystyle{ \frac{n!}{\mathrm{e}} }[/math].

[math]\displaystyle{ \square }[/math]

Therefore, there are about [math]\displaystyle{ \frac{1}{\mathrm{e}} }[/math] fraction of all permutations with no fixed points.

Permutations with restricted positions

We introduce a general theory of counting permutations with restricted positions. In the derangement problem, we count the number of permutations that [math]\displaystyle{ \pi(i)\neq i }[/math]. We now generalize to the problem of counting permutations which avoid a set of arbitrarily specified positions.

It is traditionally described using terminology from the game of chess. Let [math]\displaystyle{ B\subseteq \{1,\ldots,n\}\times \{1,\ldots,n\} }[/math], called a board. As illustrated below, we can think of [math]\displaystyle{ B }[/math] as a chess board, with the positions in [math]\displaystyle{ B }[/math] marked by "[math]\displaystyle{ \times }[/math]".

a b c d e f g h
8 a8 __ b8 cross c8 cross d8 __ e8 cross f8 __ g8 __ h8 cross 8
7 a7 cross b7 __ c7 __ d7 cross e7 __ f7 __ g7 cross h7 __ 7
6 a6 cross b6 __ c6 cross d6 cross e6 __ f6 cross g6 cross h6 __ 6
5 a5 __ b5 cross c5 __ d5 __ e5 cross f5 __ g5 cross h5 __ 5
4 a4 cross b4 __ c4 __ d4 __ e4 cross f4 cross g4 cross h4 __ 4
3 a3 __ b3 cross c3 __ d3 cross e3 __ f3 __ g3 __ h3 cross 3
2 a2 __ b2 __ c2 cross d2 __ e2 cross f2 __ g2 __ h2 cross 2
1 a1 cross b1 __ c1 __ d1 cross e1 __ f1 cross g1 __ h1 __ 1
a b c d e f g h

For a permutation [math]\displaystyle{ \pi }[/math] of [math]\displaystyle{ \{1,\ldots,n\} }[/math], define the graph [math]\displaystyle{ G_\pi(V,E) }[/math] as

[math]\displaystyle{ \begin{align} G_\pi &= \{(i,\pi(i))\mid i\in \{1,2,\ldots,n\}\}. \end{align} }[/math]

This can also be viewed as a set of marked positions on a chess board. Each row and each column has only one marked position, because [math]\displaystyle{ \pi }[/math] is a permutation. Thus, we can identify each [math]\displaystyle{ G_\pi }[/math] as a placement of [math]\displaystyle{ n }[/math] rooks (“城堡”,规则同中国象棋里的“车”) without attacking each other.

For example, the following is the [math]\displaystyle{ G_\pi }[/math] of such [math]\displaystyle{ \pi }[/math] that [math]\displaystyle{ \pi(i)=i }[/math].

a b c d e f g h
8 a8 white rook b8 __ c8 __ d8 __ e8 __ f8 __ g8 __ h8 __ 8
7 a7 __ b7 white rook c7 __ d7 __ e7 __ f7 __ g7 __ h7 __ 7
6 a6 __ b6 __ c6 white rook d6 __ e6 __ f6 __ g6 __ h6 __ 6
5 a5 __ b5 __ c5 __ d5 white rook e5 __ f5 __ g5 __ h5 __ 5
4 a4 __ b4 __ c4 __ d4 __ e4 white rook f4 __ g4 __ h4 __ 4
3 a3 __ b3 __ c3 __ d3 __ e3 __ f3 white rook g3 __ h3 __ 3
2 a2 __ b2 __ c2 __ d2 __ e2 __ f2 __ g2 white rook h2 __ 2
1 a1 __ b1 __ c1 __ d1 __ e1 __ f1 __ g1 __ h1 white rook 1
a b c d e f g h

Now define

[math]\displaystyle{ \begin{align} N_0 &= \left|\left\{\pi\mid B\cap G_\pi=\emptyset\right\}\right|\\ r_k &= \mbox{number of }k\mbox{-subsets of }B\mbox{ such that no two elements have a common coordinate}\\ &=\left|\left\{S\in{B\choose k} \,\bigg|\, \forall (i_1,j_1),(i_2,j_2)\in S, i_1\neq i_2, j_1\neq j_2 \right\}\right| \end{align} }[/math]

Interpreted in chess game,

  • [math]\displaystyle{ B }[/math]: a set of marked positions in an [math]\displaystyle{ [n]\times [n] }[/math] chess board.
  • [math]\displaystyle{ N_0 }[/math]: the number of ways of placing [math]\displaystyle{ n }[/math] non-attacking rooks on the chess board such that none of these rooks lie in [math]\displaystyle{ B }[/math].
  • [math]\displaystyle{ r_k }[/math]: number of ways of placing [math]\displaystyle{ k }[/math] non-attacking rooks on [math]\displaystyle{ B }[/math].

Our goal is to count [math]\displaystyle{ N_0 }[/math] in terms of [math]\displaystyle{ r_k }[/math]. This gives the number of permutations avoid all positions in a [math]\displaystyle{ B }[/math].

Theorem
[math]\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)! }[/math].
Proof.

For each [math]\displaystyle{ i\in[n] }[/math], let [math]\displaystyle{ A_i=\{\pi\mid (i,\pi(i))\in B\} }[/math] be the set of permutations [math]\displaystyle{ \pi }[/math] whose [math]\displaystyle{ i }[/math]-th position is in [math]\displaystyle{ B }[/math].

[math]\displaystyle{ N_0 }[/math] is the number of permutations avoid all positions in [math]\displaystyle{ B }[/math]. Thus, our goal is to count the number of permutations [math]\displaystyle{ \pi }[/math] in none of [math]\displaystyle{ A_i }[/math] for [math]\displaystyle{ i\in [n] }[/math].

For each [math]\displaystyle{ I\subseteq [n] }[/math], let [math]\displaystyle{ A_I=\bigcap_{i\in I}A_i }[/math], which is the set of permutations [math]\displaystyle{ \pi }[/math] such that [math]\displaystyle{ (i,\pi(i))\in B }[/math] for all [math]\displaystyle{ i\in I }[/math]. Due to the principle of inclusion-exclusion,

[math]\displaystyle{ N_0=\sum_{I\subseteq [n]} (-1)^{|I|}|A_I|=\sum_{k=0}^n(-1)^k\sum_{I\in{[n]\choose k}}|A_I| }[/math].

The next observation is that

[math]\displaystyle{ \sum_{I\in{[n]\choose k}}|A_I|=r_k(n-k)! }[/math],

because we can count both sides by first placing [math]\displaystyle{ k }[/math] non-attacking rooks on [math]\displaystyle{ B }[/math] and placing [math]\displaystyle{ n-k }[/math] additional non-attacking rooks on [math]\displaystyle{ [n]\times [n] }[/math] in [math]\displaystyle{ (n-k)! }[/math] ways.

Therefore,

[math]\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)! }[/math].
[math]\displaystyle{ \square }[/math]

Derangement problem

We use the above general method to solve the derange problem again.

Take [math]\displaystyle{ B=\{(1,1),(2,2),\ldots,(n,n)\} }[/math] as the chess board. A derangement [math]\displaystyle{ \pi }[/math] is a placement of [math]\displaystyle{ n }[/math] non-attacking rooks such that none of them is in [math]\displaystyle{ B }[/math].

a b c d e f g h
8 a8 cross b8 __ c8 __ d8 __ e8 __ f8 __ g8 __ h8 __ 8
7 a7 __ b7 cross c7 __ d7 __ e7 __ f7 __ g7 __ h7 __ 7
6 a6 __ b6 __ c6 cross d6 __ e6 __ f6 __ g6 __ h6 __ 6
5 a5 __ b5 __ c5 __ d5 cross e5 __ f5 __ g5 __ h5 __ 5
4 a4 __ b4 __ c4 __ d4 __ e4 cross f4 __ g4 __ h4 __ 4
3 a3 __ b3 __ c3 __ d3 __ e3 __ f3 cross g3 __ h3 __ 3
2 a2 __ b2 __ c2 __ d2 __ e2 __ f2 __ g2 cross h2 __ 2
1 a1 __ b1 __ c1 __ d1 __ e1 __ f1 __ g1 __ h1 cross 1
a b c d e f g h

Clearly, the number of ways of placing [math]\displaystyle{ k }[/math] non-attacking rooks on [math]\displaystyle{ B }[/math] is [math]\displaystyle{ r_k={n\choose k} }[/math]. We want to count [math]\displaystyle{ N_0 }[/math], which gives the number of ways of placing [math]\displaystyle{ n }[/math] non-attacking rooks such that none of these rooks lie in [math]\displaystyle{ B }[/math].

By the above theorem

[math]\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!=\sum_{k=0}^n(-1)^k{n\choose k}(n-k)!=\sum_{k=0}^n(-1)^k\frac{n!}{k!}=n!\sum_{k=0}^n(-1)^k\frac{1}{k!}\approx\frac{n!}{e}. }[/math]

Problème des ménages

Suppose that in a banquet, we want to seat [math]\displaystyle{ n }[/math] couples at a circular table, satisfying the following constraints:

  • Men and women are in alternate places.
  • No one sits next to his/her spouse.

In how many ways can this be done?

(For convenience, we assume that every seat at the table marked differently so that rotating the seats clockwise or anti-clockwise will end up with a different solution.)

First, let the [math]\displaystyle{ n }[/math] ladies find their seats. They may either sit at the odd numbered seats or even numbered seats, in either case, there are [math]\displaystyle{ n! }[/math] different orders. Thus, there are [math]\displaystyle{ 2(n!) }[/math] ways to seat the [math]\displaystyle{ n }[/math] ladies.

After sitting the wives, we label the remaining [math]\displaystyle{ n }[/math] places clockwise as [math]\displaystyle{ 0,1,\ldots, n-1 }[/math]. And a seating of the [math]\displaystyle{ n }[/math] husbands is given by a permutation [math]\displaystyle{ \pi }[/math] of [math]\displaystyle{ [n] }[/math] defined as follows. Let [math]\displaystyle{ \pi(i) }[/math] be the seat of the husband of he lady sitting at the [math]\displaystyle{ i }[/math]-th place.

It is easy to see that [math]\displaystyle{ \pi }[/math] satisfies that [math]\displaystyle{ \pi(i)\neq i }[/math] and [math]\displaystyle{ \pi(i)\not\equiv i+1\pmod n }[/math], and every permutation [math]\displaystyle{ \pi }[/math] with these properties gives a feasible seating of the [math]\displaystyle{ n }[/math] husbands. Thus, we only need to count the number of permutations [math]\displaystyle{ \pi }[/math] such that [math]\displaystyle{ \pi(i)\not\equiv i, i+1\pmod n }[/math].

Take [math]\displaystyle{ B=\{(0,0),(1,1),\ldots,(n-1,n-1), (0,1),(1,2),\ldots,(n-2,n-1),(n-1,0)\} }[/math] as the chess board. A permutation [math]\displaystyle{ \pi }[/math] which defines a way of seating the husbands, is a placement of [math]\displaystyle{ n }[/math] non-attacking rooks such that none of them is in [math]\displaystyle{ B }[/math].

a b c d e f g h
8 a8 cross b8 cross c8 __ d8 __ e8 __ f8 __ g8 __ h8 __ 8
7 a7 __ b7 cross c7 cross d7 __ e7 __ f7 __ g7 __ h7 __ 7
6 a6 __ b6 __ c6 cross d6 cross e6 __ f6 __ g6 __ h6 __ 6
5 a5 __ b5 __ c5 __ d5 cross e5 cross f5 __ g5 __ h5 __ 5
4 a4 __ b4 __ c4 __ d4 __ e4 cross f4 cross g4 __ h4 __ 4
3 a3 __ b3 __ c3 __ d3 __ e3 __ f3 cross g3 cross h3 __ 3
2 a2 __ b2 __ c2 __ d2 __ e2 __ f2 __ g2 cross h2 cross 2
1 a1 cross b1 __ c1 __ d1 __ e1 __ f1 __ g1 __ h1 cross 1
a b c d e f g h

We need to compute [math]\displaystyle{ r_k }[/math], the number of ways of placing [math]\displaystyle{ k }[/math] non-attacking rooks on [math]\displaystyle{ B }[/math]. For our choice of [math]\displaystyle{ B }[/math], [math]\displaystyle{ r_k }[/math] is the number of ways of choosing [math]\displaystyle{ k }[/math] points, no two consecutive, from a collection of [math]\displaystyle{ 2n }[/math] points arranged in a circle.

We first see how to do this in a line.

Lemma
The number of ways of choosing [math]\displaystyle{ k }[/math] non-consecutive objects from a collection of [math]\displaystyle{ m }[/math] objects arranged in a line, is [math]\displaystyle{ {m-k+1\choose k} }[/math].
Proof.

We draw a line of [math]\displaystyle{ m-k }[/math] black points, and then insert [math]\displaystyle{ k }[/math] red points into the [math]\displaystyle{ m-k+1 }[/math] spaces between the black points (including the beginning and end).

[math]\displaystyle{ \begin{align} &\sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \\ &\qquad\qquad\qquad\quad\Downarrow\\ &\sqcup \, \bullet \,\, {\color{Red}\bullet} \, \bullet \,\, {\color{Red}\bullet} \, \bullet \, \sqcup \, \bullet \,\, {\color{Red}\bullet}\, \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \,\, {\color{Red}\bullet} \end{align} }[/math]

This gives us a line of [math]\displaystyle{ m }[/math] points, and the red points specifies the chosen objects, which are non-consecutive. The mapping is 1-1 correspondence. There are [math]\displaystyle{ {m-k+1\choose k} }[/math] ways of placing [math]\displaystyle{ k }[/math] red points into [math]\displaystyle{ m-k+1 }[/math] spaces.

[math]\displaystyle{ \square }[/math]

The problem of choosing non-consecutive objects in a circle can be reduced to the case that the objects are in a line.

Lemma
The number of ways of choosing [math]\displaystyle{ k }[/math] non-consecutive objects from a collection of [math]\displaystyle{ m }[/math] objects arranged in a circle, is [math]\displaystyle{ \frac{m}{m-k}{m-k\choose k} }[/math].
Proof.

Let [math]\displaystyle{ f(m,k) }[/math] be the desired number; and let [math]\displaystyle{ g(m,k) }[/math] be the number of ways of choosing [math]\displaystyle{ k }[/math] non-consecutive points from [math]\displaystyle{ m }[/math] points arranged in a circle, next coloring the [math]\displaystyle{ k }[/math] points red, and then coloring one of the uncolored point blue.

Clearly, [math]\displaystyle{ g(m,k)=(m-k)f(m,k) }[/math].

But we can also compute [math]\displaystyle{ g(m,k) }[/math] as follows:

  • Choose one of the [math]\displaystyle{ m }[/math] points and color it blue. This gives us [math]\displaystyle{ m }[/math] ways.
  • Cut the circle to make a line of [math]\displaystyle{ m-1 }[/math] points by removing the blue point.
  • Choose [math]\displaystyle{ k }[/math] non-consecutive points from the line of [math]\displaystyle{ m-1 }[/math] points and color them red. This gives [math]\displaystyle{ {m-k\choose k} }[/math] ways due to the previous lemma.

Thus, [math]\displaystyle{ g(m,k)=m{m-k\choose k} }[/math]. Therefore we have the desired number [math]\displaystyle{ f(m,k)=\frac{m}{m-k}{m-k\choose k} }[/math].

[math]\displaystyle{ \square }[/math]

By the above lemma, we have that [math]\displaystyle{ r_k=\frac{2n}{2n-k}{2n-k\choose k} }[/math]. Then apply the theorem of counting permutations with restricted positions,

[math]\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!=\sum_{k=0}^n(-1)^k\frac{2n}{2n-k}{2n-k\choose k}(n-k)!. }[/math]

This gives the number of ways of seating the [math]\displaystyle{ n }[/math] husbands after the ladies are seated. Recall that there are [math]\displaystyle{ 2n! }[/math] ways of seating the [math]\displaystyle{ n }[/math] ladies. Thus, the total number of ways of seating [math]\displaystyle{ n }[/math] couples as required by problème des ménages is

[math]\displaystyle{ 2n!\sum_{k=0}^n(-1)^k\frac{2n}{2n-k}{2n-k\choose k}(n-k)!. }[/math]

The Euler totient function

Two integers [math]\displaystyle{ m, n }[/math] are said to be relatively prime if their greatest common diviser [math]\displaystyle{ \mathrm{gcd}(m,n)=1 }[/math]. For a positive integer [math]\displaystyle{ n }[/math], let [math]\displaystyle{ \phi(n) }[/math] be the number of positive integers from [math]\displaystyle{ \{1,2,\ldots,n\} }[/math] that are relative prime to [math]\displaystyle{ n }[/math]. This function, called the Euler [math]\displaystyle{ \phi }[/math] function or the Euler totient function, is fundamental in number theory.

We now derive a formula for this function by using the principle of inclusion-exclusion.

Theorem (The Euler totient function)

Suppose [math]\displaystyle{ n }[/math] is divisible by precisely [math]\displaystyle{ r }[/math] different primes, denoted [math]\displaystyle{ p_1,\ldots,p_r }[/math]. Then

[math]\displaystyle{ \phi(n)=n\prod_{i=1}^r\left(1-\frac{1}{p_i}\right) }[/math].
Proof.

Let [math]\displaystyle{ U=\{1,2,\ldots,n\} }[/math] be the universe. The number of positive integers from [math]\displaystyle{ U }[/math] which is divisible by some [math]\displaystyle{ p_{i_1},p_{i_2},\ldots,p_{i_s}\in\{p_1,\ldots,p_r\} }[/math], is [math]\displaystyle{ \frac{n}{p_{i_1}p_{i_2}\cdots p_{i_s}} }[/math].

[math]\displaystyle{ \phi(n) }[/math] is the number of integers from [math]\displaystyle{ U }[/math] which is not divisible by any [math]\displaystyle{ p_1,\ldots,p_r }[/math]. By principle of inclusion-exclusion,

[math]\displaystyle{ \begin{align} \phi(n) &=n+\sum_{k=1}^r(-1)^k\sum_{1\le i_1\lt i_2\lt \cdots \lt i_k\le n}\frac{n}{p_{i_1}p_{i_2}\cdots p_{i_k}}\\ &=n-\sum_{1\le i\le n}\frac{n}{p_i}+\sum_{1\le i\lt j\le n}\frac{n}{p_i p_j}-\sum_{1\le i\lt j\lt k\le n}\frac{n}{p_{i} p_{j} p_{k}}+\cdots + (-1)^r\frac{n}{p_{1}p_{2}\cdots p_{r}}\\ &=n\left(1-\sum_{1\le i\le n}\frac{1}{p_i}+\sum_{1\le i\lt j\le n}\frac{1}{p_i p_j}-\sum_{1\le i\lt j\lt k\le n}\frac{1}{p_{i} p_{j} p_{k}}+\cdots + (-1)^r\frac{1}{p_{1}p_{2}\cdots p_{r}}\right)\\ &=n\prod_{i=1}^n\left(1-\frac{1}{p_i}\right). \end{align} }[/math]
[math]\displaystyle{ \square }[/math]

Möbius inversion

Posets

A partially ordered set or poset for short is a set [math]\displaystyle{ P }[/math] together with a binary relation denoted [math]\displaystyle{ \le_P }[/math] (or just [math]\displaystyle{ \le }[/math] if no confusion is caused), satisfying

  • (reflexivity) For all [math]\displaystyle{ x\in P, x\le x }[/math].
  • (antisymmetry) If [math]\displaystyle{ x\le y }[/math] and [math]\displaystyle{ y\le x }[/math], then [math]\displaystyle{ x=y }[/math].
  • (transitivity) If [math]\displaystyle{ x\le y }[/math] and [math]\displaystyle{ y\le z }[/math], then [math]\displaystyle{ x\le z }[/math].

We say two elements [math]\displaystyle{ x }[/math] and [math]\displaystyle{ y }[/math] are comparable if [math]\displaystyle{ x\le y }[/math] or [math]\displaystyle{ y\le x }[/math]; otherwise [math]\displaystyle{ x }[/math] and [math]\displaystyle{ y }[/math] are incomparable.

Notation
  • [math]\displaystyle{ x\ge y }[/math] means [math]\displaystyle{ y\le x }[/math].
  • [math]\displaystyle{ x\lt y }[/math] means [math]\displaystyle{ x\le y }[/math] and [math]\displaystyle{ x\neq y }[/math].
  • [math]\displaystyle{ x\gt y }[/math] means [math]\displaystyle{ y\lt x }[/math].

The Möbius function

Let [math]\displaystyle{ P }[/math] be a finite poset. Consider functions in form of [math]\displaystyle{ \alpha:P\times P\rightarrow\mathbb{R} }[/math] defined over domain [math]\displaystyle{ P\times P }[/math]. It is convenient to treat such functions as matrices whose rows and columns are indexed by [math]\displaystyle{ P }[/math].

Incidence algebra of poset
Let
[math]\displaystyle{ \mathbb{A}(P)=\{\alpha:P\times P\rightarrow\mathbb{R}\mid \alpha(x,y)=0\text{ for all }x\not\le_P y\} }[/math]
be the class of [math]\displaystyle{ \alpha }[/math] such that [math]\displaystyle{ \alpha(x,y) }[/math] is non-zero only for [math]\displaystyle{ x\le_P y }[/math].
Treating [math]\displaystyle{ \alpha }[/math] as matrix, it is trivial to see that [math]\displaystyle{ \mathbb{A}(P) }[/math] is closed under addition and scalar multiplication, that is,
  • if [math]\displaystyle{ \alpha,\beta\in \mathbb{A}(P) }[/math] then [math]\displaystyle{ \alpha+\beta\in\mathbb{A}(P) }[/math];
  • if [math]\displaystyle{ \alpha\in \mathbb{A}(P) }[/math] then [math]\displaystyle{ c\alpha\in\mathbb{A}(P) }[/math] for any [math]\displaystyle{ c\in\mathbb{R} }[/math];
where [math]\displaystyle{ \alpha,\beta }[/math] are treated as matrices.
With this spirit, it is natural to define the matrix multiplication in [math]\displaystyle{ \mathbb{A}(P) }[/math]. For [math]\displaystyle{ \alpha,\beta\in \mathbb{A}(P) }[/math],
[math]\displaystyle{ (\alpha\beta)(x,y)=\sum_{z\in P}\alpha(x,z)\beta(z,y)=\sum_{x\le z\le y}\alpha(x,z)\beta(z,y) }[/math].
The second equation is due to that for [math]\displaystyle{ \alpha,\beta\in \mathbb{A}(P) }[/math], for all [math]\displaystyle{ z }[/math] other than [math]\displaystyle{ x\le z\le y }[/math], [math]\displaystyle{ \alpha(x,z)\beta(z,y) }[/math] is zero.
By transitivity, it is also easy to observe that [math]\displaystyle{ \mathbb{A}(P) }[/math] is closed under matrix multiplication (the detailed proof is left as an exercise). Therefore, [math]\displaystyle{ \mathbb{A}(P) }[/math] is closed under addition, scalar multiplication and matrix multiplication, so we have an algebra [math]\displaystyle{ \mathbb{A}(P) }[/math], called incidence algebra, over functions on [math]\displaystyle{ P\times P }[/math].
Zeta function and Möbius function
A special function in [math]\displaystyle{ \mathbb{A}(P) }[/math] is the so-called zeta function [math]\displaystyle{ \zeta }[/math], defined as
[math]\displaystyle{ \zeta(x,y)=\begin{cases}1&\text{if }x\le_P y,\\0 &\text{otherwise.}\end{cases} }[/math]
As a matrix (or more accurately, as an element of the incidence algebra), [math]\displaystyle{ \zeta }[/math] is invertible and its inversion, denoted by [math]\displaystyle{ \mu }[/math], is called the Möbius function. More precisely, [math]\displaystyle{ \mu }[/math] is also in the incidence algebra [math]\displaystyle{ \mathbb{A}(P) }[/math], and [math]\displaystyle{ \mu\zeta=I }[/math] where [math]\displaystyle{ I }[/math] is the identity matrix (the identity of the incidence algebra [math]\displaystyle{ \mathbb{A}(P) }[/math]).

There is an equivalent explicit definition of Möbius function.

Definition (Möbius function)
[math]\displaystyle{ \mu(x,y)=\begin{cases} -\sum_{x\le z\le y}\mu(x,z)&\text{if }x\lt y,\\ 1&\text{if }x=y,\\ 0&\text{if }x\not\le y. \end{cases} }[/math]

To see the equivalence between this definition and the inversion of zeta function, we may have the following proposition, which is proved by directly evaluating [math]\displaystyle{ \mu\zeta }[/math].

Proposition
For any [math]\displaystyle{ x,y\in P }[/math],
[math]\displaystyle{ \sum_{x\le z\le y}\mu(x,z)=\begin{cases}1 &\text{if }x=y,\\ 0 &\text{otherwise.}\end{cases} }[/math]
Proof.

It holds that

[math]\displaystyle{ (\mu\zeta)(x,y)=\sum_{x\le z\le y}\mu(x,z)\zeta(z,y)=\sum_{x\le z\le y}\mu(x,z) }[/math].

On the other hand, [math]\displaystyle{ \mu\zeta=I }[/math], i.e.

[math]\displaystyle{ (\mu\zeta)(x,y)=\begin{cases}1 &\text{if }x=y,\\ 0 &\text{otherwise.}\end{cases} }[/math]

The proposition follows.

[math]\displaystyle{ \square }[/math]

Note that [math]\displaystyle{ \mu(x,y)=\sum_{x\le z\le y}\mu(x,z)-\sum_{x\le z\lt y}\mu(x,z) }[/math], which gives the above inductive definition of Möbius function.

Principle of Möbius inversion

Möbius inversion formula
Let [math]\displaystyle{ P }[/math] be a finite poset and [math]\displaystyle{ \mu }[/math] its Möbius function. Let [math]\displaystyle{ f,g:P\rightarrow \mathbb{R} }[/math]. Then
[math]\displaystyle{ \forall x\in P,\,\, g(x)=\sum_{y\le x} f(y) }[/math],
if and only if
[math]\displaystyle{ \forall x\in P,\,\, f(x)=\sum_{y\le x}g(y)\mu(y,x) }[/math].


Möbius inversion formula, dual form
Let [math]\displaystyle{ P }[/math] be a finite poset and [math]\displaystyle{ \mu }[/math] its Möbius function. Let [math]\displaystyle{ f,g:P\rightarrow \mathbb{R} }[/math]. Then
[math]\displaystyle{ \forall x\in P, \,\, g(x)=\sum_{y{\color{red}\ge} x} f(y) }[/math],
if and only if
[math]\displaystyle{ \forall x\in P, \,\, f(x)=\sum_{y{\color{red}\ge} x}g(y)\mu(y,x) }[/math].

Reference

  • Stanley, Enumerative Combinatorics, Volume 1, Chapter 2.
  • van Lin and Wilson, A course in combinatorics, Chapter 10, 15.