数论(仅裴蜀定理,扩欧等)

· · 个人记录

注:以下所有形如(a,b)都表示\gcd(a,b)。

裴蜀定理

求证:

\exists x,y\in Z,ax+by=1 \Leftrightarrow (a,b)=1

左式推右式:

反证法:假设(a,b)>1

\Rightarrow \frac{a}{(a,b)}x+\frac{b}{(a,b)}y=\frac{1}{(a,b)} \because \frac{a}{(a,b)} \in Z,\frac{b}{(a,b)} \in Z \therefore \frac{a}{(a,b)}x+\frac{b}{(a,b)}y \in Z \because \frac{1}{(a,b)} \notin Z \therefore (a,b)> 1\text{不成立} \because (a,b)>0 \therefore (a,b)=1

右式推左式

令集合A={z=ax+by,z>0} 据良序原理,正项数列必有最小正值,设为ax_0+by_0=m_0。

\forall m\in A, m=ax+by 设m_1=qm_0+r(0 \leq r <m) r=m_1-qm_0=a(x_1-qx_0)+b(y_2-qy_0) 令x_t=x1-qx_0,y_t=x_1-qy_0 \therefore r=ax_t+by_t \therefore r\in A
  1. r=0

综上,r=0

\forall m_p \in A,m_p=sm_0(s \in Z) \therefore m_0为A中m_p的因子 \because x=1,y=0 \Rightarrow m=a,即 a \in A \because x=0,y=1 \Rightarrow m=b,即b \in A \therefore m_0|a,m_0|b \therefore m_0=(a,b) \because (a,b)=1 \therefore m_0=1 即:ax_0+by_0=1

综上,证毕。

推广:\forall a,b,\exists x,y \Rightarrow ax +by=(a,b)

证明:

若

(c,d)=1,\Rightarrow cx+dy=1

易知

\frac{a}{(a,b)}x+\frac{b}{(a,b)}y=1

可令

c=\frac{a}{(a,b)},d=\frac{b}{(a,b)}

则将c,d带回原式,将(a,b)乘回去,得到原命题,证毕。

由此,可以推广裴蜀定理的n元形式,如下:

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

求证:(a,b)=(b,a\% b) 记

a=qb+r_1(r=a\% b) \Rightarrow \frac{a}{(a,b)} =q \times \frac{b}{(a,b)} +\frac{r}{(a,b)} \because \frac{a}{(a,b)} \in Z,q \times \frac{b}{(a,b)} \in Z \therefore \frac{r}{(a,b)}=\frac{a}{(a,b)}-q \times \frac{b}{(a,b)} \in Z

记c=(a,b),则有:

a=nc,b=mc \Rightarrow r=a-qb=(n-qm)c,b=mc \because ax+by=c \Rightarrow mx+ny=1 \Rightarrow (m,n)=1 \Rightarrow (n-qm+qm)y+mx=1 \Rightarrow (n-qm)y+(qy+x)m=1 \Rightarrow (n-qm,m)=1 \Rightarrow ((n-qm)c,mc)=c (r,b)=c

即:(a,b)=(b,a\%b),证毕。

递推式

\because (a,b)=(b,a\%b)=(b,a-a/b) \therefore ax+by=(a,b)