3-4. 排容原理
Principle of Inclusion and Exclusion (PIE)
U: universal set, a1, a2, ..., an: 性質, Ai = { x∈U | x 滿足 ai }, N(ai) = ∣Ai∣, N(ai¯) = ∣Ai¯∣
⇒N(ai¯aj¯) = ∣Ai¯∩Aj¯∣ = ∣U∣ - [N(ai) + N(aj)] + N(ai∩aj)
⇒N(ai¯aj¯ak¯) = ∣Ai¯∩Aj¯∩Ak¯∣ = ∣U∣ - [N(ai) + N(aj) + N(ak)] + [N(ai∩aj) + N(ai∩ak) + N(aj∩ak)] - N(aiajak)
⇒⋮
⇒N(a1¯a2¯ ... ak¯) = ∣U∣ - i=1∑nN(ai) + 1≤i<j≤n∑N(aiaj) - 1≤i<j<k≤n∑N(aiajak) + ... + (−1)nN(a1a2...an)
= S0 - S1 + S2 - S3 + ... + (−1)nSn, 其中 Sr 含 (rn) 項之和
排容原理即文氏圖,只看 U 與當下性質
Euler's Totient Function
n∈Z+, n = P1e1P2e2...Pkek 為 n 的質因數分解,則 ϕ(n) = n(1 - P11)(1 - P21)...(1 - Pk1)
proof: k = 3
U = { 1, 2, ..., n }, 令 ai 表 Pi 之倍數, i = 1, 2, 3, ϕ(n) = N(a1¯a2¯a3¯) = S0 - S1 + S2 - S3
= n - [P1n + P2n + P3n] + [P1P2n + P1P3n + P2P3n] - P1P2P3n
= n[1 - (P11 + P21 + P31) + (P1P21 + P1P31 + P2P31) - P1P2P31]
= P1P2P3n[P1P2P3 - (P1P2 + P1P3 + P2P3) + (P1 + P2 + P3) - 1]
= P1P2P3n(P1 - 1)(P2 - 1)(P3 - 1) = n(P1P1−1)(P2P2−1)(P3P3−1) = n(1 - P11)(1 - P21)(1 - P31)
Theorem of Onto Function Amount
A, B: sets, ∣A∣ = m, ∣B∣ = n, m≥n, 則 f: A→B onto 個數: onto(m, n) = i=0∑n(−1)i(in)(n - i)m
m 個相異球放入 n 個相異箱子,不允許空箱之方法數
proof:
U = { f | f: A→B } ⇒∣U∣ = nm, 令 ai 表示 U 中函數滿足值域不含 bi 之條件(第 i 個箱子為空), i = 1, ..., n
⇒onto(m, n) = N(a1¯a2¯ ... an¯) = S0 - S1 + S2 - S3 + ... + (−1)nSn
= (0n)nm - (1n)(n - 1)m + (2n)(n - 2)m - (3n)(n - 3)m + ... + (−1)n(nn)(n - n)m
= i=0∑n(−1)i(in)(n - i)m
(−1)n(nn)(n - n)m = 0
Stirling Number of The Second Kind
m, n∈Z, m>n>1
S(m, n) = n!onto(m,n) = n!i=0∑n(−1)i(in)(n−i)m
稱為第二種 Stirling 數(Stirling number of the second kind)
- 當 m < n 時,S(m, n) = 0
m 個相異球放入 n 個相同箱子,不允許空箱之方法數
→m 個相異球放入 n 個相同箱子,允許空箱之方法數?
S(m, n) + S(m, n - 1) + ... + S(m, 1)
- S(m, n): 0 個空箱
- S(m, n - 1): 1 個空箱
...
- S(m, 1): n - 1 個空箱
Theorem of S(m, n)
m, n∈N, m>n>2, S(m + 1, n) = S(m, n - 1) + nS(m, n)
proof:
S(m + 1, n): m + 1 相異物分成恰 n 箱,固定一物 A
- A 所在的箱子只有 A: S(m, n - 1)
- A 所在的箱子不只有 A: nS(m, n) → 先放除 A 之外的 m 個相異物入 n 箱,再從其中任一箱放入 A
Table of S(m, n)
m↓n→ |
1 |
2 |
3 |
4 |
5 |
6 |
1 |
1 |
|
|
|
|
|
2 |
1 |
1 |
|
|
|
|
3 |
1 |
3 |
1 |
|
|
|
4 |
1 |
7 |
6 |
1 |
|
|
5 |
1 |
15 |
25 |
10 |
1 |
|
6 |
1 |
31 |
90 |
65 |
15 |
1 |
Example:
onto(6, 3) + onto(6, 3) = ?
solution:
90(3!) + 65(4!)