L15 – Recurrence Relations, Inclusion-Exclusion, and Pigeonhole Principle

Discrete Mathematics2026年4月23日发布 芮和
590 60
9,097字
39–58 分钟

Recurrence Relation

Fibonacci Sequence: fn=fn1+fn2f_n = f_{n-1} + f_{n-2}(n2)(n \geq 2); f0=1f_0 = 1, f1=1f_1 = 1

The Tower of Hanoi: Hn=2Hn1+1H_n = 2H_{n-1} + 1(n2)(n \geq 2); H1=1H_1 = 1, H2=3H_2 = 3

DEFINITION: A linear recurrence relation of degree kk with constant coefficients is a recurrence relation of the form an=c1an1+c2an2++ckank+F(n)a_n = c_1 a_{n-1} + c_2 a_{n-2} + \dots + c_k a_{n-k} + F(n), where nkn \geq k, {ci}i=1k\{c_i\}_{i=1}^k are constant real numbers, and ck0c_k \neq 0.

  • degree kk: every term depends on kk terms preceding it
  • constant coefficients: c1,,ckc_1, \dots, c_k are independent of nn
  • linear: the right-hand side is a linear combination of a1,a2,,an1a_1, a_2, \dots, a_{n-1}.
  • linear homogeneous recurrence relation (LHRR): F(n)=0F(n) = 0
    // fn=fn1+fn2f_n = f_{n-1} + f_{n-2}
  • linear nonhomogeneous recurrence relation (LNRR): F(n)0F(n) \neq 0
    // Hn=2Hn1+1H_n = 2H_{n-1} + 1
    • associated LHRR: an=i=1kciania_n = \sum_{i=1}^k c_i a_{n-i}

Solving Recurrence Relation with GFs

GF-based Method: F(n)=(flnl++f1n+f0)sn=f(n)snF(n) = \left(f_l n^l + \dots + f_1 n + f_0\right)s^n = f(n)s^n

EXAMPLE: Solve an=8an1+10n1a_n = 8a_{n-1} + 10^{n-1} with a0=1a_0 = 1 using generating function.

  • A(x)=n=0anxnA(x)= \sum_{n=0}^\infty a_n x^n
    =1+n=1(8an1+10n1)xn=1 + \sum_{n=1}^\infty (8a_{n-1} + 10^{n-1})x^n
    =1+8xA(x)+x110x= 1 + 8xA(x) + \frac{x}{1-10x}
  • A(x)=19x(18x)(110x)A(x) = \frac{1-9x}{(1-8x)(1-10x)}
    =α1,118x+α2,1110x= \frac{\alpha_{1,1}}{1-8x} + \frac{\alpha_{2,1}}{1-10x}, α1,1=α2,1=12\alpha_{1,1}=\alpha_{2,1}=\frac{1}{2}
  • A(x)=12(118x+1110x)A(x) = \frac{1}{2}\left(\frac{1}{1-8x} + \frac{1}{1-10x}\right)
    =n=012(8n+10n)xn= \sum_{n=0}^\infty \frac{1}{2}(8^n + 10^n)x^n
  • an=12(8n+10n)a_n = \frac{1}{2}(8^n + 10^n)(n0)(n \geq 0)

THEOREM: Let Q(x),P(x)[x]Q(x), P(x) \in \mathbb{R}[x] be polynomials with deg(Q)>deg(P)\deg(Q) > \deg(P). If Q(x)=(1r1x)m1(1rtx)mtQ(x) = (1 – r_1 x)^{m_1} \cdots (1 – r_t x)^{m_t} for distinct non-zero numbers r1,,rtr_1,\dots,r_t and integers m1,,mt1m_1,\dots,m_t\geq 1, then there exist unique coefficients {αj,u:j[t], u[mj]}\{\alpha_{j,u}:\,j\in[t],\ u\in[m_j]\} s.t.

P(x)Q(x)=j=1tu=1mjαj,u(1rjx)u.\frac{P(x)}{Q(x)} = \sum_{j=1}^t \sum_{u=1}^{m_j} \frac{\alpha_{j,u}}{(1 – r_j x)^u}.

EXAMPLE: Solve an=4an14an2+n2a_n = 4a_{n-1} – 4a_{n-2} + n^2 with a0=2a_0 = 2, a1=5a_1 = 5.

  • A(x)=n=0anxnA(x)= \sum_{n=0}^\infty a_n x^n
    =2+5x+n=2(4an14an2+n2)xn= 2 + 5x + \sum_{n=2}^\infty (4a_{n-1} – 4a_{n-2} + n^2)x^n
    =2+5x+4x(A(x)2)4x2A(x)+n=2n2xn= 2 + 5x + 4x(A(x) – 2) – 4x^2 A(x) + \sum_{n=2}^\infty n^2 x^n
  • y=n=2n2xn=x2+x(1x)3xy=\sum_{n=2}^\infty n^2 x^n = \frac{x^2+x}{(1-x)^3} – x
    // z=n=0xnz=\sum_{n=0}^{\infty}x^n; y=x(xz)xy=x(xz’)’-x
  • A(x)=114x+4x2(24x+x2+x(1x)3)A(x) = \frac{1}{1-4x+4x^2}\left(2 – 4x + \frac{x^2+x}{(1-x)^3}\right)
    =212x+𝒙2+𝒙(12𝒙)2(1𝒙)3= \frac{2}{1-2x} + \boldsymbol{\frac{x^2+x}{(1-2x)^2(1-x)^3}}
  • 𝒙2+𝒙(12𝒙)2(1𝒙)3=𝒂12𝒙+𝒃(12𝒙)2+𝒄1𝒙+𝒅(1𝒙)2+𝒆(1𝒙)3\boldsymbol{\frac{x^2+x}{(1-2x)^2(1-x)^3} = \frac{a}{1-2x} + \frac{b}{(1-2x)^2} + \frac{c}{1-x} + \frac{d}{(1-x)^2} + \frac{e}{(1-x)^3}}
    // compare the numerators of both sides
    • a=26a=-26, b=6b=6, c=13c=13, d=5d=5, d=5d=5
  • A(x)=212x+2612𝒙+6(12𝒙)2+131𝒙+5(1𝒙)2+2(1𝒙)3A(x) = \frac{2}{1-2x} + \boldsymbol{\frac{-26}{1-2x} + \frac{6}{(1-2x)^2} + \frac{13}{1-x} + \frac{5}{(1-x)^2} + \frac{2}{(1-x)^3}}
  • an=n2+8n+20+(6n18)2na_n = n^2 + 8n + 20 + (6n – 18)2^n
    // (1+x)u=n=0(un)xn(1+x)^u=\sum_{n=0}^{\infty}\binom{u}{n}x^n

Principle of Inclusion-Exclusion

Two Sets

THEOREM: Let SS be a finite set. Let A1,A2A_1, A_2 be subsets of SS. Then

  • |𝑺𝑨1|=|𝑺||𝑨1|\boldsymbol{|S – A_1| = |S| – |A_1|}
    |𝑨1𝑨2|=|𝑨1||𝑨1𝑨2|\boldsymbol{|A_1 – A_2| = |A_1| – |A_1 \cap A_2|}
    • S=A1(SA1)S = A_1 \cup (S – A_1), A1(SA1)=A_1 \cap (S – A_1) = \emptyset;
      • {A1,SA1}\{A_1, S – A_1\} is a partition of SS
        • |S|=|A1|+|SA1||S| = |A_1| + |S – A_1|
          • |SA1|=|S||A1||S – A_1| = |S| – |A_1|
      • A1A2=A1A1A2A_1 – A_2 = A_1 – A_1 \cap A_2
        • |A1A2|=|A1||A1A2||A_1 – A_2| = |A_1| – |A_1 \cap A_2|
  • |𝑨1𝑨2|=|𝑨1|+|𝑨2||𝑨1𝑨2|\boldsymbol{|A_1 \cup A_2| = |A_1| + |A_2| – |A_1 \cap A_2|}
    • A1A2=(A1A2)A2A_1 \cup A_2 = (A_1 – A_2) \cup A_2, (A1A2)A2=(A_1 – A_2) \cap A_2 = \emptyset;
      • {A1A2,A2}\{A_1 – A_2, A_2\} is a partition of A1A2A_1 \cup A_2
        • |A1A2|=|A1A2|+|A2|=|A1||A1A2|+|A2||A_1 \cup A_2| = |A_1 – A_2| + |A_2| = |A_1| – |A_1 \cap A_2| + |A_2|
  • |𝑨1𝑨2|=|𝑨1|+|𝑨2||𝑨1𝑨2|\boldsymbol{|A_1 \cap A_2| = |A_1| + |A_2| – |A_1 \cup A_2|}

Three Sets

THEOREM: Let SS be a finite set. Let A1,A2,A3A_1, A_2, A_3 be subsets of SS. Then

|i=13Ai|=t=13(1)t11i1<<it3|Ai1Ait|\left|\bigcup_{i=1}^3 A_i\right| = \sum_{t=1}^3 (-1)^{t-1} \sum_{1 \leq i_1 < \dots < i_t \leq 3} |A_{i_1} \cap \dots \cap A_{i_t}|
  • |i=13Ai|=|(A1A2)A3|=|A1A2|+|A3||(A1A2)A3|\left|\bigcup_{i=1}^3 A_i\right| = |(A_1 \cup A_2) \cup A_3| = |A_1 \cup A_2| + |A_3| – |(A_1 \cup A_2) \cap A_3|
    • |A1A2|=|A1|+|A2||A1A2||A_1 \cup A_2| = |A_1| + |A_2| – |A_1 \cap A_2|
    • |(A1A2)A3|=|(A1A3)(A2A3)||(A_1 \cup A_2) \cap A_3| = |(A_1 \cap A_3) \cup (A_2 \cap A_3)|
      =|A1A3|+|A2A3||(A1A3)(A2A3)|= |A_1 \cap A_3| + |A_2 \cap A_3| – |(A_1 \cap A_3) \cap (A_2 \cap A_3)|
      =|A1A3|+|A2A3||A1A2A3|= |A_1 \cap A_3| + |A_2 \cap A_3| – |A_1 \cap A_2 \cap A_3|
      • |i=13Ai|=|A1|+|A2||A1A2|+|A3|(|A1A3|+|A2A3||A1A2A3|)\left|\bigcup_{i=1}^3 A_i\right| = |A_1| + |A_2| – |A_1 \cap A_2| + |A_3| – (|A_1 \cap A_3| + |A_2 \cap A_3| – |A_1 \cap A_2 \cap A_3|)
  • |i=13Ai|=t=13(1)t11i1<<it3|Ai1Ait|\left|\bigcap_{i=1}^3 A_i\right| = \sum_{t=1}^3 (-1)^{t-1} \sum_{1 \leq i_1 < \dots < i_t \leq 3} |A_{i_1} \cup \dots \cup A_{i_t}|

nn Sets

THEOREM: Let SS be a finite set. Let A1,A2,,AnSA_1, A_2, \dots, A_n \subseteq S. Then

  • |i=1nAi|=t=1n(1)t11i1<<itn|Ai1Ait|\left|\bigcup_{i=1}^n A_i\right| = \sum_{t=1}^n (-1)^{t-1} \sum_{1 \leq i_1 < \dots < i_t \leq n} |A_{i_1} \cap \dots \cap A_{i_t}|;
  • |i=1nAi|=t=1n(1)t11i1<<itn|Ai1Ait|\left|\bigcap_{i=1}^n A_i\right| = \sum_{t=1}^n (-1)^{t-1} \sum_{1 \leq i_1 < \dots < i_t \leq n} |A_{i_1} \cup \dots \cup A_{i_t}|.

EXAMPLE: (Euler’s phi function) ϕ(n)=n(11p1)(11pr)\phi(n) = n\left(1 – \frac{1}{p_1}\right) \cdots \left(1 – \frac{1}{p_r}\right) for n=p1e1prern = p_1^{e_1} \cdots p_r^{e_r}.

  • S={1,2,,n}S = \{1,2, \dots, n\};
    Ai={sS:pi|s}A_i = \{s \in S:\,p_i\mid s\}, i=1,2,,ri = 1,2, \dots, r
    • A=Si=1rAiA = S – \bigcup_{i=1}^r A_i
  • |i=1rAi|=t=1r(1)t11i1<<itn|Ai1Ait|\left|\bigcup_{i=1}^r A_i\right| = \sum_{t=1}^r (-1)^{t-1} \sum_{1 \leq i_1 < \dots < i_t \leq n} |A_{i_1} \cap \dots \cap A_{i_t}|
    • |Ai1Ait|=npi1pit|A_{i_1} \cap \dots \cap A_{i_t}| = \frac{n}{p_{i_1} \cdots p_{i_t}} for t=1,2,,rt = 1,2, \dots, r
  • |A|=|S||i=1nAi||A| = |S| – \left|\bigcup_{i=1}^n A_i\right|
    =n(np1++nprnp1p2npr1pr++(1)r1np1pr)= n – \left(\frac{n}{p_1} + \dots + \frac{n}{p_r} – \frac{n}{p_1p_2} – \dots – \frac{n}{p_{r-1}p_r} + \dots + (-1)^{r-1} \frac{n}{p_1 \cdots p_r}\right)
    =n(np1++npr)+(np1p2++npr1pr)+(1)rnp1pr= n – \left(\frac{n}{p_1} + \dots + \frac{n}{p_r}\right) + \left(\frac{n}{p_1p_2} + \dots + \frac{n}{p_{r-1}p_r}\right) – \dots + (-1)^r \frac{n}{p_1 \cdots p_r}
    =n(11p1)(11pr)= n\left(1 – \frac{1}{p_1}\right) \cdots \left(1 – \frac{1}{p_r}\right)

Pigeonhole Principle

EXAMPLE: Connect 15 workstations W1,,W15W_1, …, W_{15} to 10 servers S1,,S10S_1, …, S_{10} such that any 10\geq 10 workstations have access to all servers. How many cables are needed?

  • Solution 1: Connecting every workstation directly to every server. 150
  • Solution 2: SiS_i is connected to WiW_i for every i[10]i \in [10]; and each of W11,W12,W13,W14,W15W_{11}, W_{12}, W_{13}, W_{14}, W_{15} is connected to all servers.
    • This solution requires 60 lines.
    • Is this solution optimal?

Cover

DEFINITION: A cover of a finite set AA is a family {A1,A2,,An}\{A_1, A_2, …, A_n\} of subsets of AA such that i=1nAi=A\bigcup_{i=1}^n A_i = A.

LEMMA: Let {A1,A2,,An}\{A_1, A_2, …, A_n\} be a cover of a finite set AA. Then |A|i=1n|Ai||A| \leq \sum_{i=1}^n |A_i|.

  • n=1n = 1: |A|=|A1||A| = |A_1|
  • n=2n = 2: |A|=|A1A2|=|A1|+|A2||A1A2||A1|+|A2||A| = |A_1 \cup A_2| = |A_1| + |A_2| – |A_1 \cap A_2| \leq |A_1| + |A_2|
  • Suppose true when nkn \leq k (k2k \geq 2).
  • When n=k+1n = k + 1,
    |A|=|i=1kAiAk+1||A| = \left|\bigcup_{i=1}^k A_i \cup A_{k+1}\right|
    |i=1kAi|+|Ak+1|\leq \left|\bigcup_{i=1}^k A_i\right| + |A_{k+1}|
    i=1k|Ai|+|Ak+1|\leq \sum_{i=1}^k |A_i| + |A_{k+1}|
    =i=1k+1|Ai|= \sum_{i=1}^{k+1} |A_i|

THEOREM: (simple form) Let AA be a set with n+1\geq n + 1 elements. Let {A1,A2,,An}\{A_1, A_2, \dots, A_n\} be a cover of AA. Then k[n]\exists k \in [n], |Ak|2|A_k| \geq 2.

  • Suppose that |Ai|1|A_i| \leq 1 for every i[n]i \in [n]. Then n+1|A|i=1n|Ai|nn + 1 \leq |A| \leq \sum_{i=1}^n |A_i| \leq n.
    • If 𝒏+1\boldsymbol{\geq n + 1} objects are distributed into 𝒏\boldsymbol{n} boxes, then there is at least one box containing 2\boldsymbol{\geq 2} objects.

THEOREM: (general form) Let AA be a set with N\geq N elements. Let {A1,A2,,An}\{A_1, A_2, \dots, A_n\} be a cover of AA. Then k[n]\exists k \in [n], |Ak|Nn|A_k| \geq \left\lceil \frac{N}{n} \right\rceil.

  • If |Ai|<Nn|A_i| < \left\lceil \frac{N}{n} \right\rceil for all i[n]i \in [n], then N|A|i=1n|Ai|<nNn=NN \leq |A| \leq \sum_{i=1}^n |A_i| \boldsymbol{<} n \cdot \frac{N}{n} = N
    • If we distribute 𝑵\boldsymbol{\geq N} objects into 𝒏\boldsymbol{n} boxes, then there is at least one box that contains 𝑵𝒏\boldsymbol{\geq \left\lceil \frac{N}{n} \right\rceil} objects.

EXAMPLE: Connect 15 workstations W1,,W15W_1, \dots, W_{15} to 10 servers S1,,S10S_1, \dots, S_{10} such that any 10\geq 10 workstations have access to all servers. How many cables are needed?

  • Is Solution 2 optimal?
  • Consider an optimal scheme 𝚷\boldsymbol{\Pi}.
    • Let A={(Wi,Sj):i[15],j[10],Wi is not connected to Sj}A = \left\{\left(W_i, S_j\right):\,i \in [15], j \in [10], W_i\text{ is not connected to }S_j\right\} in Π\Pi
    • At={(Wi,Sj)A:j=t}A_t = \left\{\left(W_i, S_j\right) \in A:\,j = t\right\} for t=1,2,,10t = 1,2, \dots, 10
      • {A1,A2,,A10}\{A_1, A_2, \dots, A_{10}\} is a cover of AA
  • If there are <60\boldsymbol{< 60} lines in 𝚷\boldsymbol{\Pi}, then |A|>15060=90|A| > 150 – 60 = 90.
    • |A|91|A| \geq 91
    • k[10]\exists k \in [10] such that |Ak|9110=10|A_k| \geq \left\lceil \frac{91}{10} \right\rceil = 10
      • There are 10 workstations not connected to SkS_k
© 版权声明

相关文章

6 条评论

  • 星辰之歌
    星辰之歌 读者

    inclusion-exclusion套娃太烧脑了

    中国浙江
    回复
  • 泡泡桃
    泡泡桃 读者

    汉诺塔递推推得人麻了

    中国湖南
    回复
  • 无畏的船长
    无畏的船长 读者

    斐波那契数列这递推看着还挺顺眼

    中国上海
    回复
  • 糖心兔
    糖心兔 读者

    鸽巢原理倒是挺有意思的

    中国辽宁
    回复
    • 秘法使者
      秘法使者 读者

      我当时也觉得

      中国北京@ 糖心兔
      回复
  • 且末寻宝
    且末寻宝 游客

    这生成函数算得我头都大了,有没有更直观的方法啊?

    中国湖南
    回复