1585 字
8 分鐘
03 Mathematical Induction

課程總覽

Euclidean Algorithm#

Basic Recurrence#

gcd(a,b)={bif r=0aotherwise   where a=bk+r,0r<b\text{gcd}(a,b) = \left\{\begin{aligned} & b & \text{if }r = 0 \\ & a & \text{otherwise} \end{aligned}\right.\ \ \ \text{where } a = b\cdot k + r, 0\le r < b

with an arbitary kk. 證明:gcd(a,b)=gcd(b,r){\text{gcd}(a,b) = \text{gcd}(b,r)}.

可以將問題拆解為「兩式互相小於等於對方」的兩個小命題,來簡化證明難度。

命題一,gcd(a,b)gcd(b,r){\text{gcd}(a,b) \le \text{gcd}(b,r)}.

  • Let dcommon divisor(a,b){d \in \text{common divisor}(a,b)}.
  •     a=k1db=k2d{\implies a = k_{1}d \land b = k_{2}d}, k1,k2Z{\exists k_{1}, k_{2} \in \mathbb{Z}}.
  • a=bk+r    r=(k1kk2)d{a = bk + r \implies r = (k_{1} - kk_{2})d}     dr{\implies d | r}.
  •     dcommon divisor(a,b)    dr{\implies \forall d' \in \text{common divisor(a,b)} \implies d' | r}.
    • Every common divisor of aa and bb is a divisor of rr, which surely contains gcd(a,b){\text{gcd}(a,b)}. (略命題二。)故得證 \blacksquare

Estimating Steps Needed in Euclidean Algorithm#

Let r0=a{r_{0} = a}, r1=b{r_{1} = b}; r0r1{r_{0} \ge r_{1}}.

\begin{array}. r_{0} = r_{1}k_{1} + r_{2} \\ r_{1} = r_{2}k_{2} + r_{3} \\ r_{2} = r_{3}k_{3} + r_{4} \\ \dots \\ r_{n - 1} = r_{n}k_{n} + 0 \end{array}

我們想知道這個遞迴式共花了多少步完成。或者說,我們想求 nn 的值。 在以上描述輾轉相除法的遞迴關係式中,我們可以觀察到 riri+1+ri+2{r_{i} \ge r_{i + 1} + r_{i + 2}},比如 r0r1+r2{r_{0} \ge r_{1} + r_{2}}等。這之中還輕易地得到 riri+1{r_{i} \ge r_{i + 1}},因此可以說:

rn2rn+2,r_{n} \ge 2\cdot r_{n + 2},

或者 rn+212rn{r_{n + 2} \le \frac{1}{2}r_{n}}。平均來說,也可說 rn+1121/2rnr_{n + 1} \le \frac{1}{2^{ 1/ 2}}r_{n}。試著將這個新的遞迴不等式串起來:

rn121/2rn1122/2rn212n/2r0,r_{n} \le \frac{1}{2^{1/2}} r_{n - 1} \le \frac{1}{2^{2 / 2}} r_{n - 2} \le \dots \le \frac{1}{2^{n / 2}}r_{0} ,

而我們可以單獨將頭尾抽出來看,得一指數遞減關係

rnr02n/2.r_{n} \le \frac{r_{0}}{2^{n/2}}.

設想一數 xx,使得

r02x/2<1\frac{r_{0}}{2^{x/2}} < 1

成立。那麼,考慮原本的遞減關係,當 nn 等於 xx 時,遞減關係必然成立:

rxr02x/2<1,r_{x} \le \frac{r_{0}}{2^{x/2}} < 1,

故若一數 xx 符合不等式 r02x/2<1{\frac{r_{0}}{2^{x/2}} < 1},則 xx 可作為 nn 之上界:

nx=2logr0+1. n \le x = 2\log r_{0} + 1.\ \blacksquare

可以說,找到的 xx 是一個保守解,這也是他作為「nn 的上界」的含意。

Mathematical Induction#

Well-ordering Axiom#

Let SS be a set with some positive integers. Then if

{1SnN, nS    n+1S ,\left\{\begin{aligned} & 1 \in S \\ & \forall n \in \mathbb{N},\ n \in S \implies n + 1 \in S \end{aligned}\right.\ ,

then SS is the set of all positive integers, namely N\mathbb{N}. 在這個公理之中便使用了數學歸納的概念。

Weak Mathematical Induction#

若要證明一個初階邏輯式P(n)P(n)對於所有nxn \ge x皆成立,則:

P(x)=truek>x, P(k)    P(k+1)P(x) = \text{true} \land \forall k > x,\ P(k) \implies P(k + 1)

Strong Mathematical Induction#

P(x)=truek>x, P(x)P(x+1)P(k)    P(k+1)P(x) = \text{true} \land \forall k > x,\ P(x) \land P(x + 1) \land \dots \land P(k) \implies P(k + 1)

Lame’s Theorem#

Generating function#

Infinite Sum vs. Closed Form#

  1. Infinite sum: 1+x+x2++xn+{1 + x + x^{2} + \dots + x^{n} + \dots}
  2. Closed form: 11x\frac{1}{1 - x}

例:自然數數列 1,2,3,4,5,1,2,3,4,5,\dots

列出生成函數 A(x)=1+2x+3x2+4x3+A(x)= 1 + 2x + 3x^{2} + 4x^{3} + \dots 法一,轉換為一連串的closed form:

=1+x+x2+x3+(11x)+x+x2+x3+(x1x)+x2+x3+(x21x)+. \begin{aligned} = 1 + x + x^{2} + x^{3} + \dots & \left( \frac{1}{1-x} \right)\\ + x + x^{2} + x^{3} + \dots & \left( \frac{x}{1 - x} \right)\\ +x^{2} + x^{3} + \dots & \left( \frac{x^{2}}{1 - x} \right) \\ +\dots.\ \square \end{aligned}

法二,兩邊微分:

(1+x+x2+x3+x4+)=1+2x+3x2+4x3+;\begin{aligned} & (1 + x + x^{2} + x^{3} + x^{4}+ \dots)' \\ = & 1 + 2x + 3x^{2} + 4x^{3}+ \dots; \end{aligned}

另一邊:

(11x)=1(1x)2. \left( \frac{1}{1 - x} \right)' = \frac{1}{(1 - x)^{2}}.\ \square

Solving Linear Recurrence by Generating Function#

數列 {an}\{ a_{n} \} 之生成函數乃其Formal power series:

i=0naixi=a0+a1x+a2x2++anxn+\sum ^{n}_{i=0} a_{i} x^{i} = a_{0} + a_{1}x + a_{2}x^{2} + \dots + a_{n}x^{n} + \dots

例:給予一數列之遞迴關係 an=8an1+10n,a0=6{a_{n} = 8 a_{n - 1} + 10^{n}, a_{0} = 6},求數列之一般式。

推導:

A(x)=a0+a1x+=a0+i=1(8ai1+10i)xi=a0+8i=1ai1xi+i=110ixi.\begin{aligned} A(x) & = a_{0} + a_{1}x + \dots \\ & = a_{0} + \sum ^{\infty}_{i = 1} (8a_{i - 1} + 10^{i}) x_{i} \\ & = a_{0} + 8\sum ^{\infty}_{i = 1} a_{i-1} x^{i} + \sum ^{\infty}_{i = 1} 10^{i}x^{i} .\\ \end{aligned}

前式的 ai1xia_{i-1}x^{i} 可以寫為 xai1xi1{x\cdot a_{i-1}x^{i-1}},可提出 xx;後式的 10ixi10^{i}x^{i} 則可寫為 (10x)i{(10x)^{i}},而變成無窮等比級數:

A(x)==6+8xA(x)+10x110x.\begin{aligned} A(x) & = \dots \\ & = 6 + 8xA(x) + \frac{10x}{1 - 10x}. \end{aligned}

等式兩邊消除了所有的無窮級數,而兩邊都有 A(x)A(x)。只消移項整理即可得 A(x)A(x)

(18x)A(x)=6+10x110x,A(x)=650x(18x)(110x)=(1)118x+5110x.\begin{aligned} & (1 - 8x) A(x) = 6 + \frac{10x}{1 -10x}, \\ & A(x) = \frac{6 - 50x}{(1 - 8x)(1 - 10x)} \underset{\text{(1)}}{=} \frac{1}{1-8x} + \frac{5}{1 - 10x}. \end{aligned}

接著,即可依照closed form來將其還原為一般項,

118x=1+8x+(8x)2+,\frac{1}{1 - 8x} = 1 + 8x + (8x)^{2} + \dots,5110x=5+510x+5(10x)2+\frac{5}{1 - 10x} = 5 + 5\cdot 10x + 5\cdot (10x)^{2} + \dots

而分別可以還原回一般式 8n{8^{n}}510n5\cdot 10^{n}。因此,便可以得一般項 an=8n+510n{a_{n} = 8^{n} +5\cdot 10^{n}}\blacksquare

重點

  1. 在推導時重複出現原式,可以移項整理,消去麻煩的式子
  2. xx的一次分式是很有價值的。有他就可以構成無窮等比(closed form)。因此遇到可以拆分的二次分式(形如1()()\frac{1}{()()})的話要多留意一下。

Manipulating Generating Function#

給兩個生成函式 A(x),B(x){A(x), B(x)} 分別對應到數列 a0,a1,a2,,ana_{0}, a_{1}, a_{2}, \dots, a_{n}b0,b1,b2,,bn{b_{0}, b_{1}, b_{2}, \dots, b_{n}}。 一、乘以 xx 會達成「位移」(shifting)的效果:

xA(x)0,a0,a1,,an1,xA(x) \leftrightarrow 0, a_{0}, a_{1}, \dots, a_{n-1}, \dots

二、生成函式的加法:

A(x)+B(x)a0+b0, a1+b1, a2+b2,A(x) + B(x) \leftrightarrow a_{0} + b_{0},\ a_{1} + b_{1},\ a_{2} + b_{2}, \dots

三、生成函數的乘法:

A(x)B(x)a0b0, a0b1+a1b0, a0b2+a1b1+a2b0,A(x)\cdot B(x) \leftrightarrow a_{0}b_{0},\ a_{0} b_{1} + a_{1}b_{0},\ a_{0}b_{2} + a_{1}b_{1} + a_{2}b_{0}, \dots

我們可以說,兩個生成函數相乘,即得他們對應數列(此處為 {an}{\{ a_{n} \}}{bn}{\{ b_{n} \}})的卷積(convolution)。 提示:A(x)B(x)=(a0+a1x+a2x2+)(b0+b1x+b2x2+){A(x)\cdot B(x) = (a_{0} + a_{1}x + a_{2}x^{2} + \dots)(b_{0} + b_{1}x + b_{2}x^{2} + \dots)}


例:計算費氏數列 fn=fn1+fn2;f0=0,f1=1{f_{n} = f_{n - 1} + f_{n - 2}; f_{0} = 0, f_{1} = 1}的一般項。

F(x)=i=0fixi=f0+f1x+i=2fixi=x+i=2(fi1+fi2)xi=x+i=2fi1xi+i=2fi2xi=x+xi=2fi1xi1+x2i=2fi2xi2\begin{aligned} F(x) & = \sum ^{\infty}_{i = 0} f_{i}x^{i} \\ & = f_{0} + f_{1} x + \sum ^{\infty}_{i = 2} f_{i} x^{i} \\ & = x + \sum ^{\infty}_{i = 2} (f_{i - 1} + f_{i - 2})x^{i} \\ & = x + \sum ^{\infty}_{i = 2}f_{i - 1} x^{i} + \sum ^{\infty}_{i = 2}f_{i - 2} x^{i} \\ & = x + x \sum ^{\infty} _{i=2}f_{i - 1}x^{i - 1} + x^{2} \sum ^{\infty}_{i = 2}f_{i - 2} x^{i - 2} \end{aligned}

此時,兩個無窮級數事實上都可以轉換為生成函數 F(x)F(x)

  • 前式:i=2fi1xi1=i=1fixi=F(x)f0=F(x){\sum ^{\infty}_{i = 2}f_{i - 1}x^{i - 1} = \sum ^{\infty}_{i = 1} f_{i}x^{i} = F(x) - f_{0} = F(x)}
  • 後式:i=2fi2xi2=i=0fixi=F(x){\sum ^{\infty}_{i = 2}f_{i - 2}x^{i - 2} = \sum ^{\infty}_{i = 0}f_{i}x^{i} = F(x)}
F(x)==x+xF(x)+x2F(x)\begin{aligned} F(x) & = \dots \\ & = x + xF(x) + x^{2} F(x) \end{aligned}

移項之後得 F(x)=x1xx2=xx2+x1{F(x) = \frac{x}{1 - x-x^{2}} = \frac{-x}{x^{2} + x - 1}},有兩個方法可解。

法一,用公式法分解二次式,然後再拆解分式:

F(x)=x(x1+52)(x152)=c1x+152+c2x+1+52. F(x) = \frac{-x}{\left( x - \frac{-1 + \sqrt{ 5 }}{2} \right)\left( x - \frac{-1 - \sqrt{ 5 }}{2} \right)} = \frac{c_{1}}{x + \frac{1 - \sqrt{ 5 }}{2}} + \frac{c_{2}}{x + \frac{1 + \sqrt{ 5 }}{2}}.\ \square

法二,將式子拆解為兩個乘法項,前後個別求一般式,然後解卷積:

F(x)=x(x1+52)(x152)=xx1+521x+1+52=21+5x121+5x11+21+5x.F(x) = \frac{-x}{\left( x - \frac{-1 + \sqrt{ 5 }}{2} \right)\left( x - \frac{-1 - \sqrt{ 5 }}{2} \right)} =\frac{-x}{x - \frac{-1 + \sqrt{ 5 }}{2}} \cdot \frac{1}{x + \frac{1 + \sqrt{ 5 }}{2}} = \frac{\frac{2}{-1 + \sqrt{ 5 }}x}{1 - \frac{2}{-1 + \sqrt{ 5 }}x}\cdot \frac{1}{1 + \frac{2}{1 + \sqrt{ 5 }}x}.

而這個方法比起法一來說更加麻煩。\square

03 Mathematical Induction
https://blade520.com/posts/discrete-mathematics/ch3-induction/
作者
Blade/磯江
發佈於
2025-04-07
許可協議
CC BY-NC-SA 4.0