PIE
- PIE(Priciple of Inclusion-Exclusion)
- AI=⋂i∈IAi
- ∣⋃i=1nAi∣=∑I⊆{1,⋯,n},∣I∣≥1(−1)∣I∣−1∣AI∣
- ∣⋂i=1nAi∣=∑I⊆{1,⋯,n}(−1)∣I∣∣AI∣
- Sieve methods: 计算恰好具备某种性质的 ⇒ 计算不具有一系列坏性质的
- Define ∣U∣
- Define 'bad' properties Ai
- Use PIE count the number
Surjections
- Count Surjections f:N→M
- U={f:[n]→[m]},∣U∣=mn
- Ai={f:[n]→[m]\{i}},∣Ai∣=(m−1)n
- AI={f:[n]→[m]\I},∣AI∣=(m−∣I∣)n
- ∣⋂i=1nAi∣=∑I⊆{1,⋯,n}(−1)∣I∣∣AI∣=∑j=0m(−1)j(jm)(m−j)n=m!{mn}
Derangements
- fixed point i: i∈{1,2,⋯,n},π(i)=i
- derangement of {1,2,⋯,n} is π that has no fixed points
- U=Sn,∣U∣=n!
- Ai={π∣π(i)=i}, ∣Ai∣=(n−1)!
- ∣AI∣=(n−∣I∣)!
- ∑I⊆[n](−1)∣I∣∣AI∣=n!∑k=0nk!(−1)k≈en!
Permutations with restricted positions
- B⊆[n]×[n]
- Gπ(V,E)={(i,π(i))∣i∈[n]}
- N0=∣{π∣B∩Gπ=∅} (Non-attacking rooks)
- rk:∣{S∈(kB)∣∀(i1,j1),(i2,j2)∈S,i1=i2,j1=j2}
- N0=∑k=0n(−1)krk(n−k)!
Derangement problem
B={(i,i)∣i∈[n]}
Probleme des menages
- n couples at a circular table, M&F in alternate and no one sits next to his/her spouse
- Lady: 2(n!)
- Men: B={(0,0),(1,1),⋯,(n−1,n−1),(0,1),(1,2),⋯,(n−2,n−1),(n−1,0)}
- rk: choosingn k points, no two consecutive, from a collection of 2n points arranged in a circle
- line: (km−k+1)
- circle: m−1m(km−k)
- N0=∑k=0n(−1)k2n−k2n(k2n−k)(n−k)!
Euler totient function
- ϕ(n)=n∏i=1r(1−pi1)
- ∑d∣nϕ(d)=n
Inversion
- Poset P: partially ordered set
- Set P with ≤P satisfying reflexivity, antisymmetry and transitivity
- comparable: x≤y or y≤x
- incidence algebra: algebra I(P)
- I(P)={α:P×P→R∣α(x,y)=0,∀x≤Py} (α can be seen as matrix)
- if α,β∈I(P) then α+β∈I(P)
- if α∈I(P) then cα∈I(P)
- (αβ)(x,y)=∑z∈Pα(x,z)β(z,y)=∑x≤z≤yα(x,z)β(z,y)
- zeta function ζ(x,y)=[x≤Py]∈I(P)
- Möbius function: μζ=I
- I(x,y)=[x=y]
- ∑x≤z≤yμ(x,z)=[x=y]
μ(x,y)=⎩⎨⎧−∑x≤z<yμ(x,z)10x<yx=yx≤y
- P×Q: ∀(x,y),(x′,y′)∈P×Q,(x,y)≤(x′,y′) iff x≤x′,y≤y′
- product rule: μP×Q((x,y),(x′,y′))=μP(x,x′)μQ(y,y′)
- (fζ)(x)=∑y∈Pf(y)ζ(y,x)=∑y≤xf(y)
- (gμ)(x)=∑y∈Pg(y)μ(y,x)=∑y≤xg(y)μ(y,x)
- f,g:P→R
- Mobius inversion formula
- ∀x∈P,g(x)=∑y≤xf(y)⟺∀x∈P,f(x)=∑y≤xg(y)μ(y,x)
- fζ=g⟺f=gμ
- dual form: ζf⟺f=μg
剩余系
P=[n],≤P if i=j+1
μ(i,j)=⎩⎨⎧1−10i=ji+1=jo.w.
Boolean algebra
P=2U,≤P is ⊆
μ(S,T)={(−1)∣T∣−∣S∣0S⊆To.w.
- g(J)=∣⋂i∈JAi∣=∑i⊇Jf(I)
- belongs to exactly the sets Ai,i∈J: f(J)=∣(⋂i∈JAi)\(⋃i∈JAi)∣=∑I⊇Jg(I)μ(J,I)=∑I⊇J(−1)∣I∣−∣J∣∣⋂i∈IAi∣
- PIE:
- f(∅)=∣U\⋃iAi∣=∑I⊆[n](−1)∣I∣∣⋂i∈IAi∣
- ∑T⊆I⊆S(−1)∣S∣−∣I∣=0 if S=T else 1, A1=A2=⋯=An={1}
- Bipartite Perfect Matching
- Ai,j=1 if (i,j)∈E
- perm(A) = ∑π∈Sn∏i∈[n]Ai,π(i) (#P-hard)
- det(A) = ∑π∈Sn(−1)r(π)∏i∈[n]Ai,π(i) (poly-time)
- Ryser's formula: ∑π∈Sn∏i∈[n]Ai,π(i)=∑I⊆[n](−1)n−∣I∣∏i∈[n]∑j∈IAi,j
- O(n!)→O(n2n)
Number Theory
P={a>0∣a∣n},≤p is ∣
μ(a,b)=⎩⎨⎧(−1)r0ab is the product of r distinct primeso.w.
- number-theoretical Mobius function: μ(dn)=μ(n,d)
- ∑d∣nμ(d)=[n=1]
- ϕζ=id
- ϕ=idμ=∑d∣nμ(d)dn
- g(n)=∑d∣nf(d)
- f(n)=∑d∣ng(d)μ(dn)