离散数学P4 Number Theory I

【P4】 -Mathematics for Computer Science_哔哩哔哩_bilibili

Lec 4 | MIT 6.042J Mathematics for Computer Science, Fall 2010

Number theory: Study of the integers

Def:m|a(m divides a)

  • m∣a 是一个谓词,结果是真(true)或假(false)

  • 通常要求 m≠0,因为除数不能为零

  • ∣|” 是“整除符号”,不能与绝对值符号混淆

“A除B”时,实际计算为 B ÷ A。例如:“6除2”即2 ÷ 6=1/3。除数在前,被除数在后(B ÷ A)

“A除以B”时,计算为 A ÷ B。例如:“6除以2”即6 ÷ 2=3。被除数在前,除数在后(A ÷ B)

所以m|a可以读作m除a,即a除以m, a/m

m|a

exists k, whihc make a=km

suppose a is equal to 0,这里是假设被除数 等于 0。 

any integer will define a, will define 0,

这句话的意思是,任何非零整数都能“整除”0。 根据整除的定义,如果 整除 0,那么存在一个整数 ,使得

because I can take k to be equal to 0, so this is equal to 0 times any integer m,

这里明确了 。 这意味着,对于任何一个非零整数 ,我们都可以找到一个整数 ,使得 成立。

so m defines  0 for all integers,

对于所有的非零整数 通常在讨论整除时,除数不为0),我们都可以说 整除 0。 换句话说,任何非零整数都能够整除 0。

so this is kind of the exception

这被称为一个“例外”或者“特殊情况”,因为通常我们讨论整除关系时,被除数 不会是 0,或者说 0 作为被除数时具有这种普遍性,即任何非零整数都能整除 0

 

Suppose we have a gallon jug , also have b gallon jug, a=3 b=5, and a<=b

00:11:15提出的theorem

Theorem: m|a and m|b then m|any result.

(这里的 "any result" 指的是水壶中的水量 .

a=3,b=5, m=1

 

State Machine

States pairs(x,y)

x=# gallon in a jug

y=# gallon in b jug

start state:(0,0)

 

Transitions:

emptying

(x,y)->(0,y)

(x,y)->(x,0)

filling:

(x,y)->(a,y)

(x,y)>(x,b)

pouring:

pour form jug a to jug b

(x,y)->(0,x+y)  x+y<=b

(x,y)->(x-(b-y),b)->(x+y-b,b) x+y>=b

pour from jug b to jug a

(x,y)->(x+y,0) x+y<=a

(x,y)->(a,y-(a-x))->(a,x+y-a)  x+y>=a

Example a=3, b=5 
(0,0)->(3,0)->(0,3)->(3,3)->(1,5)->(1,0)->(0,1)->(3,1)->(0,4)

(0,0)->(0,5)->(3,2)->(0,2)->(2,0)->(2,5)->(3,4)

 

Theorem: m|a and m|b then m|any result

(这里的 "any result" 指的是水壶中的水量 .

00:21:06开始证明, 前面10分钟在讲状态机

Proof by induction: Assume m|a and m|b

Invariant: P(n)=If (x,y) is the state after n transitions, then m|x and m|y

Base Case: (0,0) m|0 -> P(0)

Inductive Step: Assume P(n)

Suppose that (x,y) state after n transitions

P(n)-> m|x and m|y

After another transition, each of the jugs are filled with

0, a, b, x, y, x+y, x+y-a, x+y-b gallons

m|0 , m|a, m|b, m|x, m|y =>m divides any of above.=> P(n+1)   

这里用到了整除的封闭性如果 m∣p 且 m∣q,则 m∣(p+q)m∣(p−q)

 

来这个证明是与倒水问题联系在一起的!这一下子就说通了,因为倒水问题恰好是一个非常适合用整除和裴蜀定理(Bézout's identity) 来分析的经典数学问题,而裴蜀定理的证明确实会涉及到归纳法或其等价形式。

倒水问题与

我们来回顾一下经典的倒水问题:你有两个没有刻度的水壶,容量分别为 升和 升,目标是得到恰好 升水。每次操作可以是:

  1. 灌满一个水壶。
  2. 倒空一个水壶。
  3. 从一个水壶向另一个水壶倒水,直到其中一个满或另一个空。

在这个问题中,每次操作,水壶中水的总量变化总是 的倍数或 的倍数。最终留在水壶中的水量,总可以表示成 的形式,其中 是整数(可以是正数、负数或零)。

例如,对于 3 升和 5 升的水壶,目标是得到 4 升水:

  • 灌满 5 升水壶 (得到 5 升,即 )
  • 将 5 升水壶的水倒入 3 升水壶 (5 升水壶剩余 2 升,即 )
  • 倒空 3 升水壶
  • 将 5 升水壶中剩余的 2 升水倒入 3 升水壶
  • 灌满 5 升水壶 (得到 5 升,3 升水壶中有 2 升)
  • 从 5 升水壶向 3 升水壶倒水(倒 1 升,使 3 升水壶满,5 升水壶剩余 4 升,即 升)。
    • 在这里,4 升可以看作是 的形式:

啊,原来这个证明是与倒水问题联系在一起的!这一下子就说通了,因为倒水问题恰好是一个非常适合用整除和裴蜀定理(Bézout's identity) 来分析的经典数学问题,而裴蜀定理的证明确实会涉及到归纳法或其等价形式。


为什么牵扯到

这个倒水问题与 最大公约数 (GCD) 密切相关。Greatest Common Divisor

关键性质: 在只有容量为 的水壶的情况下,你能够量出的任何水量 ,都必然是 的最大公约数 的倍数。换句话说,如果 的最大公约数是 ,那么你只能得到 的倍数的水量。

理由: 每一步操作,水壶中的水量都始终是 的整数线性组合(例如,灌满 5 升水壶是 ;将水倒掉 升是从 升中减去 ,等等)。因此,最终任何能测量出的水量,都形如


裴蜀定理 (Bézout's Identity)

这里就引入了非常重要的裴蜀定理

定理: 对于任意不全为零的整数 ,存在整数 ,使得 。 更一般地, 的所有可能值都是 的倍数。反之,所有 的倍数也都可以表示成 的形式。

因此,如果 ,那么 必然整除 。进而,由于 整除 的所有可能值,那么 也必然整除 的所有可能值。


归纳法与裴蜀定理的证明

您在 MIT 6.042 中可能看到的归纳法证明,很可能是针对裴蜀定理本身的证明,或者是在证明扩展欧几里得算法时使用的归纳法。

扩展欧几里得算法就是一种能够找到 的方法,使得 。这个算法通常用归纳法来证明其正确性。

在倒水问题中,目标水量 能否达到,取决于 是否是 的倍数。

  • 对于 3 升和 5 升的水壶:
  • 因为 ,这意味着你可以通过 3 升和 5 升水壶的组合得到任何 1 的倍数的水量。所以,得到 4 升水是可能的。

所以,当您说 "m|a and m|b then m|any result" 时,这里的 "any result" 指的就是 这种形式,而这个结论的根本支撑是裴蜀定理和整除的传递性,而裴蜀定理的证明往往会用到类似欧几里得算法的递推关系,这正是归纳法大显身手的地方。

 

🎯 定理要证:

如果 m∣am \mid am∣bm \mid b,那么在只允许用容量为 aabb 的两个水壶进行倒水操作的整个过程中,任意时刻两个壶中水量 x,yx, y 都满足:

m \mid x \text{ 且 } m \mid y
]

换句话说:

初始整除结构 + 合法操作 = 永远保持整除结构(整除关系作为不变量)


🧠 证明策略:数学归纳法(Induction)+ 不变量法(Invariant)


🔧 一、不变量(Invariant)设定

定义:

  • 状态 (x,y)(x, y) 表示当前两个水壶中的水量

  • 命题 P(n)P(n) 表示:nn 步之后的状态 (x,y)(x, y) 满足 m∣xm \mid xm∣ym \mid y

我们的目标是证明:

P(0)⇒P(1)⇒⋯⇒P(n) ∀n∈NP(0) \Rightarrow P(1) \Rightarrow \cdots \Rightarrow P(n)\ \forall n \in \mathbb{N}


🧱 二、基础情况(Base Case)

初始状态是空壶:

  • (x,y)=(0,0)(x, y) = (0, 0)

  • 显然 m∣0m \mid 0,所以 P(0)P(0) 成立


🔁 三、归纳步骤(Inductive Step)

假设 P(n)P(n) 成立,即:

在第 nn 步后,状态是 (x,y)(x, y),并且 m∣xm \mid xm∣ym \mid y

我们要证明下一步执行任意合法操作后,新状态 (x′,y′)(x', y') 仍满足 m∣x′m \mid x'm∣y′m \mid y'


⚙️ 四、所有合法操作对应的新状态

你列出的这些操作是典型的水壶倒水操作,包括:

操作 说明 对应表达式
倒空任意壶 x=0x = 0y=0y = 0 00
装满壶 x=ax = ay=by = b a,ba, b
相加 把一个壶的水倒进另一个壶直到满或清空 x+yx + y
减去壶容量 x+y−ax + y - a,表示合并后减去 a 容量 x+y−ax + y - a
其他中间状态 都是这几个的变形  

重点是:

你所有能达到的新水量,都是在 x,y,a,bx, y, a, b 的线性组合范围内


✅ 五、核心论点:整除的封闭性

归纳假设告诉我们:

  • m∣xm \mid xm∣ym \mid y

  • 前提又告诉我们 m∣am \mid am∣bm \mid b

  • 又知道 m∣0m \mid 0

而整除的定理告诉我们:

如果 m∣pm \mid pm∣qm \mid q,则 m∣(p+q)m \mid (p + q)m∣(p−q)m \mid (p - q)

所以无论你用 x,y,a,bx, y, a, b 做怎样的加减操作,只要是合法操作,就不会破坏“被 mm 整除”这个性质

因此:

下一状态中水壶水量仍然被 mm 整除,P(n+1)P(n+1) 成立


🧾 六、结论

归纳证明完成,得出结论:

在任意步操作之后,只要最初 m∣am \mid am∣bm \mid b,那么任意状态 (x,y)(x, y) 中都有 m∣xm \mid xm∣ym \mid y

00:32:38给出gcd的定义

Def: gcd(a,b)=the greatest common divisor of a and b

a=3, b=5, gcd(3,5)=1

00:34:24给出下面的定义

Def:a and b are relatively prime, if gcd(a,b)=1

 

for the jugs game

00:35:20给出下面的推论

Corollary: gcd(a,b) | any reuslt

 

00:36:43提出下面的定理

Theorem: (a<=b)Any linear combination L(L=sa+tb) of a nd b with 0=<L<=b can be reached.

4=-2*3+2*5 等式1

0= 5*3-3*5  等式2

等式1+等式2得到

4=3*3-1*5

Proof: Notice L=sa+tb=(s+mb)a+(t-ma)b

so eiist t',s' L=s'a+t'b with s'>0

Assume 0<L<b

Algorithm:

To obtain L gallon, repeat s' times

Fill a jug

Pour into b jug, when it becomes full, empty it out and continue pouring until a jug is empty

 

First loop:(0,0)->(3,0)->(0,3) 每次操作完, jug a是空的

Second loop:(0,3)-->(3,3)-->(1,5)-->(1,0)-->(0,1)  每次操作完, jug a是空的

Third loop:(0,1)-->(3,1)-->(0,4)

 

Filled the a jug s' times

Suppose b jug emptied u times

Let r be the remainder in b jug, 0=<r<=b

r=s'a-ub  L=s'a+t'b 这里要证明r=L

r=s'a+t'b-t'b-ub=L-(t'+u)b

if t'+u<>0, r<0 or r>b, contradiction here, so t'+u=0

so r=L

 

a=5 b=7 c=6

(0,0)->(5,0)->(0,5)->(5,5)->(3,7)->(3,0)->(0,3)  这里是2*5-7=3

(0,3)->(5,3)->(1,7)->(1,0)->(0,1)   这里是3*5-7*2=1

(0,1)->(5,1)->(0,6) 这里是4*5-7*2=6

 

01:00:10提到下面这个描述

There exists a unique q(quotient) and r(remainder) r=rem(b,a), such that b=qa+r with 0<=r<=a 这是一个描述,但是不打算证明

Lemma: gcd(a,b)=gcd(rem(b,a),a)

 

Euclid's Algorithm欧几里得算法

224=2*105+14

gcd(105,224)=gcd(rem(224,105),105)=gcd(14,105)

105=7*14+7

gcd(14,105)=gcd(rem(105,14),14)=gcd(7,14)

gcd(7,14)=gcd(rem(14,7),7)=gcd(0,7)=7

欧几里得算法(辗转相除法)

原理:

gcd⁡(a,b)=gcd⁡(b,a mod b)

不断用较小数除较大数,直到余数为 0。最后一个非零余数就是最大公约数。

 

Lemma: gcd(a,b)=gcd(rem(b,a),a)

01:07:40开始证明的

Proof: Suppose 【m|a and m|b】  =>  【m| b-qa=rem(b,a)  and m|a】 因为m|a m|b 所以m|rem(b,a) 因为rem(b,a)其实是a和b的线性组合,根据除法的封闭性可知,m|b-qa成立

If rem(b,a)<>0 then 【m| b-qa=rem(b,a) and m|a 】 => m|a and m|b

这一块听不懂,不知道在说什么,参考下面Gemini通过

整除的封闭性,如果m|a and m|b 那么m| (xa+yb)

 

  • 双向不等式法:用于证明两个具体的数值或代数表达式相等。它直接得出 的结论。
  • 夹逼定理:用于证明函数的极限相等。它通过另外两个函数的极限来推导出中间函数的极限。

所以,虽然两者都涉及到不等式,但它们的应用场景和目的完全不同

When a proof like is structured by showing two inequalities, it's a very common and robust technique. Here's why it's done that way:

Why Prove with Two Inequalities ( and )?

To prove that two quantities, let's call them and , are equal (), a common strategy is to demonstrate two separate inequalities:

  1. : This shows that is "no larger than" .
  2. : This shows that is "no smaller than" .

If is simultaneously less than or equal to , AND greater than or equal to , the only possible conclusion is that must be exactly equal to .

How it Applies to

Let's call:

The proof you likely saw in the MIT course (or a similar one) would break down as follows:

You're asking a great question that gets to the heart of how mathematical proofs often work, especially when showing two quantities are equal!

When a proof like is structured by showing two inequalities, it's a very common and robust technique. Here's why it's done that way:


Why Prove with Two Inequalities ( and )?

To prove that two quantities, let's call them and , are equal (), a common strategy is to demonstrate two separate inequalities:

  1. : This shows that is "no larger than" .
  2. : This shows that is "no smaller than" .

If is simultaneously less than or equal to , AND greater than or equal to , the only possible conclusion is that must be exactly equal to .


How it Applies to

Let's call:

The proof you likely saw in the MIT course (or a similar one) would break down as follows:


Step 1: Prove (i.e., ) 这个证明认为最大的gcd是右侧的

This part of the proof usually involves showing that any common divisor of a and b is also a common divisor of rem(b,a) and a.

Let d=gcd(a,b).
Since d divides a and d divides b, and we know r=b−q⋅a (where r=rem(b,a)), it follows that d must also divide r. (Because b is a multiple of d, and q⋅a is a multiple of d, so their difference r must also be a multiple of d).
So, d is a common divisor of r and a.
Since Y=gcd(r,a) is the greatest common divisor of r and a, and d is a common divisor of r and a, it must be that d≤Y.
Therefore, gcd(a,b)≤gcd(rem(b,a),a). 也就是X≤Y

Step 2: Prove (i.e., ) 这个证明认为最大的gcd是右侧的

This part of the proof involves showing that any common divisor of and is also a common divisor of and .

Let .

Since divides and divides , and we know , it follows that must also divide . (Because is a multiple of , and is a multiple of , so their sum must also be a multiple of ).

So, is a common divisor of and .

Since is the greatest common divisor of and , and is a common divisor of and , it must be that .

Therefore, . 也就是X

(Note: This is often stated as , which is the same as . Since , we get , or ).


Conclusion

By proving both and , you conclusively establish that the two quantities must be equal. This two-sided inequality approach is a powerful and common method for proving equality in mathematics, especially when dealing with concepts like greatest common divisors.

 

The proof structure using and implicitly handles the case where , but it's good to explicitly confirm it.


What Happens When ?

If , it means that is perfectly divisible by . In other words, is a divisor of .

In this scenario:

  • would be (since divides both and , and is the largest number that divides ).
  • The expression becomes .

Understanding

By definition, the greatest common divisor of and any non-zero integer is . This is because:

  • Any integer divides (since for any , where ).
  • The largest divisor of is .
  • So, the greatest common divisor of and is .

For the context of the Euclidean algorithm, we usually deal with positive integers for and , so .


Checking the Proof with

Let's re-examine our two inequalities when :

We want to prove .

1. Prove (i.e., )

  • As established, if , then .
  • Also, .
  • So, , which is true. This inequality holds.

2. Prove (i.e., )

  • Again, .
  • And .
  • So, , which is also true. This inequality holds.

Conclusion

The proof by showing and does indeed hold even when . The definition of is crucial here and seamlessly integrates into the logic.

In fact, the termination condition of the Euclidean algorithm itself relies on this: when you reach a remainder of 0, the GCD is the last non-zero remainder, which corresponds to the 'a' in .

 

Theorem: gcd(a,b) is a linear combination of a and b 也被称为Bézout's Identity (or Bézout's Lemma)

Proof by Induction:

Invariant:

P(n)=If Euclid's algorithm reaches gcd(x,y) after n steps, then both x and y are linear combinations of a and b. and we also know gcd(a,b)=gcd(x,y)

Base Case: 0 steps, we do nothing, x=a, y=b, P(0) is true

Inductive Step: Assume P(n) is true

Notice that exists q which make rem(y,x)=y-qx =>因为y是a和b的线性组合, x也是。->rem(y,x) is linear combinations of a and b

=>P(n+1) 得证?

gcd(0,y)=y

You've accurately captured the essence of an inductive proof for Bézout's Identity in the context of the Euclidean Algorithm, as it might be presented in a course like MIT's 6.042J! It's a clever way to frame it. Let's break down why this inductive approach works and clarify the parts that might be unclear.


Understanding the Inductive Proof for Bézout's Identity

The goal of Bézout's Identity is to show that for any two integers and , their greatest common divisor can be written as for some integers and .

gcd(a,b)=sa+tb

The inductive proof you've outlined uses an invariant (a property that stays true throughout the algorithm's execution) and focuses on the intermediate values generated by the Euclidean Algorithm.

The Invariant

Your statement for is a good start, but let's refine it for clarity and precision, especially in the context of the proof. A more precise would be:

: "If the Euclidean algorithm has taken steps to transform the pair into (where is the current dividend and is the current divisor), then both and are linear combinations of and , and ."

Let's use the standard notation for the algorithm steps:

Start with .

Step 1:

Step 2:

...

Step :

So, for your , and . (Or, if you prefer to keep as the divisor and as the dividend, let be the divisor at step , and be the dividend at step ).

Base Case:

  • steps: The algorithm hasn't started yet. The current pair is .
  • We need to show that and are linear combinations of and .
    • This is clearly true.
  • We also need to show . This is trivially true.

Therefore, is true.

Inductive Step: Assume is true, Prove is true

Assume that after steps, we have reached the pair (where is the divisor and is the dividend in the current step), and our inductive hypothesis states:

  1. for some integers .
  2. for some integers .
  3. .

Now we perform one more step of the Euclidean algorithm to get to . The next step involves dividing by : , where .

The new pair in the algorithm will be . (Or, if you follow structure, it's ). Let's stick with the general form . So the new pair is .

We need to prove for the pair :

  1. Is a linear combination of and ?

    • We know .
    • From our assumption , we know:
    • Substitute these into the expression for :
    • Since and are integers, is indeed a linear combination of and .
    • We also know is already a linear combination of and by the inductive hypothesis.
  2. Is ?

    • We know from our core Euclidean Algorithm property that , which means .
    • By our inductive hypothesis , we have .
    • Therefore, by transitivity, .

So, we've shown that if is true, then is true.

Conclusion

By the principle of mathematical induction, is true for all .

Now, let's consider the final step of the Euclidean Algorithm. The algorithm stops when we reach a remainder of 0. Let's say this happens at step , where . The last non-zero remainder, which is the , is (or in some notations).

So, the algorithm eventually yields a pair . According to (or depending on how you index your steps), the first element of this pair, , must be a linear combination of and . Thus, for some integers and .


Why this might have seemed confusing:

The confusion often arises because:

  • Defining precisely: Getting the exact formulation of and what represents at step can be tricky.
  • Connection to the final result: It's important to explicitly state how the truth of for all (specifically, for the final step of the algorithm) proves Bézout's Identity.

This inductive proof is a robust and elegant way to demonstrate Bézout's Identity, showing that the property of being a linear combination of and is maintained throughout the Euclidean Algorithm's execution, right up to the point where the GCD is isolated.

 

01:18:35给出这个定理,但是没写证明

Theorem: gcd(a,b) is the smallest positive linear combinations of a and b.

Theorem: is the smallest positive linear combination of and .

Proof Strategy: We will prove this in two parts:

  1. Show that is a positive linear combination of and . (This is what Bézout's Identity already tells us).
  2. Show that is smaller than or equal to any other positive linear combination of and .

Part 1: is a positive linear combination of and .

This part is covered by Bézout's Identity itself. As discussed, the Extended Euclidean Algorithm (or the inductive proof you mentioned) guarantees that for any non-zero integers and , there exist integers and such that:

Since is defined as a positive integer, it satisfies the "positive linear combination" requirement.


Part 2: is the smallest positive linear combination of and .

Let . Let be any positive linear combination of and . This means for some integers and , and .

We need to show that .

Since , by definition:

  • divides (i.e., for some integer ).
  • divides (i.e., for some integer ).

Now, substitute these into the expression for :

Since are all integers, is also an integer. Let . So, .

This means that divides .

Since is a positive integer () and divides , it must be that is a positive multiple of . If a positive integer is a multiple of another positive integer , then must be greater than or equal to . Therefore, .


Conclusion

From Part 1, we know that itself is a positive linear combination of and .

From Part 2, we showed that is less than or equal to any other positive linear combination of and .

Combining these two facts, must be the smallest positive linear combination of and .

This proof relies on the fundamental properties of divisibility and the prior knowledge that can indeed be expressed as a linear combination (Bézout's Identity).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2025-06-25 16:12  ChuckLu  阅读(23)  评论(0)    收藏  举报