L07 – Prime number theorem, Fermat test, linear congruence equations, and system of linear congruences

Discrete Mathematics2026年3月25日发布 芮和
1.1K 130
8,942字
38–57 分钟

Summary of Lecture 6

L06 – EA, EEA, and Chebyshev’s Theorem

𝐄𝐄𝐀(a,b)\mathbf{EEA}(a, b): inputa,b(ab>0)a, b\,(a \ge b > 0); outputd=gcd(a,b)d = \gcd(a, b), integers s,ts, t such that d=as+btd = as + bt

  • r0=a;r1=b;(s0t0)=(10);(s1t1)=(01);r_0 = a; r_1 = b; \begin{pmatrix} s_0 \\ t_0 \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \end{pmatrix}; \begin{pmatrix} s_1 \\ t_1 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix};
  • r0=r1q1+r2(0<r2<r1);(s2t2)=(s0t0)q1(s1t1)r_0 = r_1q_1 + r_2\,(0 < r_2 < r_1); \begin{pmatrix} s_2 \\ t_2 \end{pmatrix} = \begin{pmatrix} s_0 \\ t_0 \end{pmatrix} – q_1 \begin{pmatrix} s_1 \\ t_1 \end{pmatrix}
  • \vdots
  • ri1=riqi+ri+1(0<ri+1<ri);(si+1ti+1)=(si1ti1)qi(siti)r_{i-1} = r_iq_i + r_{i+1}\,(0 < r_{i+1} < r_i); \begin{pmatrix} s_{i+1} \\ t_{i+1} \end{pmatrix} = \begin{pmatrix} s_{i-1} \\ t_{i-1} \end{pmatrix} – q_i \begin{pmatrix} s_i \\ t_i \end{pmatrix}
  • \vdots
  • rk2=rk1qk1+rk(0<rk<rk1);(sktk)=(sk2tk2)qk1(sk1tk1)r_{k-2} = r_{k-1}q_{k-1} + r_k\,(0 < r_k < r_{k-1}); \begin{pmatrix} s_k \\ t_k \end{pmatrix} = \begin{pmatrix} s_{k-2} \\ t_{k-2} \end{pmatrix} – q_{k-1} \begin{pmatrix} s_{k-1} \\ t_{k-1} \end{pmatrix}
  • rk1=rkqkr_{k-1} = r_kq_k
  • output rk,sk,tkr_k, s_k, t_k

O((a)(b))O(\ell(a)\ell(b)) bit operations

Notations:Ω,Θ,π(x)=px1,vp(n)\Omega, \Theta, \pi(x) = \sum_{p \le x} 1, v_p(n)
// pvp(n)|n,pvp(n)+1np^{v_p(n)} | n, p^{v_p(n)+1} \nmid n

THEOREM (Chebyshev, 1850)π(x)=Θ(xlnx)\pi(x) = \Theta\left(\frac{x}{\ln x}\right).

LEMMA: Suppose that m+m \in \mathbb{Z}^+. Then

(2mm)22m2m and (2m+1m)22m\binom{2m}{m} \ge \frac{2^{2m}}{2m} \text{ and } \binom{2m+1}{m} \le 2^{2m}

LEMMA: Suppose that pp is a prime and n+n \in \mathbb{Z}^+. Then

vp(n!)=k1n/pkv_p(n!) = \sum_{k \ge 1} \lfloor n/p^k \rfloor

THEOREM: Let n+n \in \mathbb{Z}^+ and n2n \ge 2. Then π(n)ln22nlnn\pi(n) \ge \frac{\ln 2}{2} \cdot \frac{n}{\ln n}.

COROLLARY:π(x)=Ω(xlnx)\pi(x) = \Omega\left(\frac{x}{\ln x}\right).
// π(x)ln24xlnx\pi(x) \ge \frac{\ln 2}{4} \cdot \frac{x}{\ln x}


Chebyshev’s Theorem

COROLLARY:π(x)=Ω(xlnx)\pi(x) = \Omega\left(\frac{x}{\ln x}\right).

  • For any real number x2x \ge 2, we have π(x)π(x)ln22xlnxln22x1lnxln24xlnx\pi(x) \ge \pi(\lfloor x \rfloor) \ge \frac{\ln 2}{2} \cdot \frac{\lfloor x \rfloor}{\ln \lfloor x \rfloor} \ge \frac{\ln 2}{2} \cdot \frac{x-1}{\ln x} \ge \frac{\ln 2}{4} \cdot \frac{x}{\ln x}

Chebyshev’s theta function:θ(x)=pxlnp\theta(x) = \sum_{p \le x} \ln p
// θ(5.2)=ln2+ln3+ln5=ln30\theta(5.2) = \ln 2 + \ln 3 + \ln 5 = \ln 30

THEOREM:θ(x)=Θ(π(x)lnx)\theta(x) = \Theta(\pi(x) \ln x).

  • θ(x)π(x)lnx\theta(x) \le \pi(x) \cdot \ln x
    // there are π(x)\pi(x) terms in θ(x)\theta(x), each of which is lnx\le \ln x
  • θ(x)x<pxlnp\theta(x) \ge \sum_{\sqrt{x} < p \le x} \ln p
    (π(x)x)lnx\ge (\pi(x) – \sqrt{x}) \ln \sqrt{x}
    // there are at least π(x)x\pi(x) – \sqrt{x} terms in the sum x<pxlnp\sum_{\sqrt{x} < p \le x} \ln p, each lnx\ge \ln \sqrt{x}
    =12(1xπ(x))π(x)lnx= \frac{1}{2} \left( 1 – \frac{\sqrt{x}}{\pi(x)} \right) \pi(x) \ln x
    • π(x)ln24xlnxxπ(x)4lnxxln20\pi(x) \ge \frac{\ln 2}{4} \cdot \frac{x}{\ln x} \Rightarrow \frac{\sqrt{x}}{\pi(x)} \le \frac{4 \ln x}{\sqrt{x} \ln 2} \to 0 (when xx \to \infty)
    • xπ(x)<12\frac{\sqrt{x}}{\pi(x)} < \frac{1}{2} when xx is big enough, say xx0x \ge x_0
    • θ(x)14π(x)lnx\theta(x) \ge \frac{1}{4} \pi(x) \ln x for xx0x \ge x_0

THEOREM: For any integer n1,θ(n)<(2ln2)nn \ge 1, \theta(n) < (2 \ln 2)n.

  • n=1:θ(1)=0<(2ln2)1n = 1: \theta(1) = 0 < (2 \ln 2) \cdot 1
  • n=2:θ(2)=ln2<(2ln2)2n = 2: \theta(2) = \ln 2 < (2 \ln 2) \cdot 2
  • n=3:θ(3)=ln2+ln3<(2ln2)3n = 3: \theta(3) = \ln 2 + \ln 3 < (2 \ln 2) \cdot 3 // ln6<ln26\ln 6 < \ln 2^6
  • n>3n > 3 and 2|n2|n: θ(n)=θ(n1)<(2ln2)(n1)<(2ln2)n\theta(n) = \theta(n-1) < (2 \ln 2)(n-1) < (2 \ln 2)n
  • n>3n > 3 and 2n2 \nmid n: there is an integer m2m \ge 2 such that n=2m+1n = 2m + 1
    • M=(2m+1m)=(2m+1)(m+2)m!<22mM = \binom{2m+1}{m} = \frac{(2m+1)\cdots(m+2)}{m!} < 2^{2m}
    • Any prime p,m+1<p2m+1p, m+1 < p \le 2m+1 must divide MM
    • θ(2m+1)θ(m+1)=m+1<p2m+1lnp\theta(2m+1) – \theta(m+1) = \sum_{m+1 < p \le 2m+1} \ln p
      lnM\le \ln M
      <(2ln2)m< (2 \ln 2)m
    • θ(n)=θ(2m+1)θ(m+1)+θ(m+1)\theta(n) = \theta(2m+1) – \theta(m+1) + \theta(m+1)
      <(2ln2)m+(2ln2)(m+1)< (2 \ln 2)m + (2 \ln 2)(m+1)
      =(2ln2)n= (2 \ln 2)n

THEOREM: For any real number x1,θ(x)<(2ln2)xx \ge 1, \theta(x) < (2 \ln 2)x.
θ(x)=θ(x)<(2ln2)x<(2ln2)x\theta(x) = \theta(\lfloor x \rfloor) < (2 \ln 2)\lfloor x \rfloor < (2 \ln 2)x


Prime Number Theorem

DEFINITION: For x+x \in \mathbb{R}^+, π(x)=px1\pi(x) = \sum_{p \le x} 1: #\# of primes x\le x

THEOREM (Hadamard;Poussin,1896)limxπ(x)xlnx=1\lim_{x \to \infty} \frac{\pi(x)}{\frac{x}{\ln x}} = 1

  • Conjectured by Legendre and Gauss (1777-1855) in 1791, proved independently by Hadamard (1865-1963) and de la Vallée Poussin (1866-1962) in 1896
  • Chebyshev: if the limit exists, then it is equal to 11
  • Rosser (1907-1989) and Schoenfeld (1920-2002) proved in 1962:
    • π(x)>xlnx(1+12lnx)\pi(x) > \frac{x}{\ln x} (1 + \frac{1}{2 \ln x}) when x59x \ge 59
    • π(x)<xlnx(1+32lnx)\pi(x) < \frac{x}{\ln x} (1 + \frac{3}{2 \ln x}) when x>1x > 1

NOTATION:\mathbb{P} – the set of all primes; n={p:2n1p<2n}\mathbb{P}_n = \{p \in \mathbb{P} : 2^{n-1} \le p < 2^n\}.

THEOREM:|n|2nnln2(12+O(1n))|\mathbb{P}_n| \ge \frac{2^n}{n \ln 2} \left(\frac{1}{2} + O\left(\frac{1}{n}\right)\right) when nn \to \infty.

EXAMPLE: The number of nn-bit primes for n{10,,25}n \in \{10, …, 25\}.

nn|n||\mathbb{P}_n|2n1nln2\frac{2^{n-1}}{n} \ln 2nn|n||\mathbb{P}_n|2n1nln2\frac{2^{n-1}}{n} \ln 2
107573.8181074910505.4
11137134.3192039019904.9
12255246.2203863537819.4
13464454.6217358672036.9
14872844.222140336137525.0
1516121575.823268216263091.4
1630302954.624513708504258.5
1757095561.725985818968176.3

Prime Number Generation

Basic Idea: randomly choose nn-bit integers until a prime found.

  • The number of nn-bit integers is 2n12^{n-1}
  • |n|2nnln2(12+O(1n))|\mathbb{P}_n| \ge \frac{2^n}{n \ln 2} \left(\frac{1}{2} + O\left(\frac{1}{n}\right)\right) when nn \to \infty
  • The probability that a prime is chosen in every trial is equal to
    αn=1nln2(1+O(1n)),n\alpha_n = \frac{1}{n \ln 2} \left(1 + O\left(\frac{1}{n}\right)\right), n \to \infty
  • In αn1=nln21+O(1n)2nln2\alpha_n^{-1} = \frac{n \ln 2}{1 + O\left(\frac{1}{n}\right)} \le 2n \ln 2 trials, we get a prime.

Efficient Algorithms: An algorithm is considered as efficient if its (expected) running time is a polynomial in the bit length of its input.
//a.k.a. (expected) polynomial-time algorithm

Expected complexity: Choosing an nn-bit prime can be done efficiently.

  • The expected #\# of trials is 2nln2\le 2n \ln 2, a polynomial in nn (input length)
  • Determine if an nn-bit integer is prime can be done efficiently

THEOREM: An integer n1n \ge 1 is a prime iff an11(modn)a^{n-1} \equiv 1 \pmod{n} for a=1,2,,n1a = 1, 2, \dots, n-1.

  • \implies: by Fermat’s little theorem
  • \implies: if not, then n=kln = kl. We cannot have kn11(modn)k^{n-1} \equiv 1 \pmod{n}

Fermat test: 𝐅𝐞𝐫𝐦𝐚𝐭(n,t)\mathbf{Fermat}(n, t)

  • Input: an odd integer n3n \ge 3 and an integer t1t \ge 1
  • Output: prime/composite
    • for i=1i = 1 to tt do
      • choose a random integer a{2,,n2}a \in \{2, \dots, n-2\}
      • If (an1modn)1(a^{n-1}\bmod n) \neq 1
        • return “composite”
    • return “prime”
  • Analysis:
    • If nn is a prime, always output “prime”
    • If nn is a composite, may output “prime” or “composite”
      // may fail with large probability for certain numbers

Other test algorithms: Solovay-Strassen, Miller-Rabin, Agrawal-Kayal-Saxena (2002)


Linear Congruence Equations

DEFINITION: Let a,b,n+a, b \in \mathbb{Z}, n \in \mathbb{Z}^+. A linear congruence equation is a congruence of the form axb(modn)ax \equiv b \pmod n, where xx is unknown.

THEOREM: Let n+,an \in \mathbb{Z}^+, a \in \mathbb{Z} and d=gcd(a,n)d = \gcd(a, n). Then axb(modn)ax \equiv b \pmod n has a solution if and only if d|bd\mid b.

  • \implies: suppose that ax0b(modn)ax_0 \equiv b \pmod n for a specific x0x_0 \in \mathbb{Z}
    • z\exists z \in \mathbb{Z} such that ax0b=nzax_0 – b = nz
    • b=ax0nzb = ax_0 – nz
    • d|a,d|nd|bd\mid a, d\mid n \implies d\mid b
  • \impliedby: suppose that d|bd\mid b
    • d=gcd(a,n)d = \gcd(a, n)
      • s,t\exists s, t \in \mathbb{Z} such that as+nt=das + nt = d
      • b=dz=asz+ntzb = dz = asz + ntz
      • a(sz)b(modn)a(sz) \equiv b \pmod n
      • szsz is a solution

THEOREM: Let n+,a,gcd(a,n)=d,t=(ad)1(modnd)n \in \mathbb{Z}^+, a \in \mathbb{Z}, \gcd(a, n) = d, t = \left(\frac{a}{d}\right)^{-1} \pmod{\frac{n}{d}}.
If d|bd\mid b, then axb(modn)ax \equiv b \pmod n iff xbdt(modnd)x \equiv \frac{b}{d}t \pmod{\frac{n}{d}}.

  • d=gcd(a,n),d|bd = \gcd(a, n), d\mid b
  • axb(modn)n|(axb)ax \equiv b \pmod n \iff n \mid (ax – b)
  • n|(axb)nd|(adxbd)n \mid (ax – b) \iff \frac{n}{d}\mid \left(\frac{a}{d}x – \frac{b}{d}\right)
  • nd|(adxbd)adxbd(modnd)\frac{n}{d} \mid \left(\frac{a}{d}x – \frac{b}{d}\right) \iff \frac{a}{d}x \equiv \frac{b}{d} \pmod{\frac{n}{d}}
  • adxbd(modnd)tadxtbd(modnd)\frac{a}{d}x \equiv \frac{b}{d} \pmod{\frac{n}{d}} \implies t\frac{a}{d}x \equiv t\frac{b}{d} \pmod{\frac{n}{d}}
    xtbd(modnd)\implies x \equiv t\frac{b}{d} \pmod{\frac{n}{d}}
  • xtbd(modnd)tadxtbd(modnd)x \equiv t\frac{b}{d} \pmod{\frac{n}{d}} \implies t\frac{a}{d}x \equiv t\frac{b}{d} \pmod{\frac{n}{d}}
    adxbd(modnd)\implies \frac{a}{d}x \equiv \frac{b}{d} \pmod{\frac{n}{d}}
  • t=(ad)1(modnd)t = \left(\frac{a}{d}\right)^{-1} \pmod{\frac{n}{d}}
  • tad1(modnd)t\frac{a}{d} \equiv 1 \pmod{\frac{n}{d}}
  • 1tad(modnd)1 \equiv t\frac{a}{d} \pmod{\frac{n}{d}}
  • xtadx(modnd)x \equiv t\frac{a}{d}x \pmod{\frac{n}{d}}

System of Linear Congruences

Sun-Tsu’s Question: There are certain things whose number is unknown. When divided by 3, the remainder is 2; when divided by 5, the remainder is 3; and when divided by 7, the remainder is 2. What will be the number of things?

  • x2(mod3)x \equiv 2 \pmod{3};
  • x3(mod5)x \equiv 3 \pmod{5};
  • x2(mod7)x \equiv 2 \pmod{7}

DEFINITION: A system of linear congruences is a set of linear congruence equations of the form

{a1xb1(modn1)a2xb2(modn2)akxbk(modnk).\begin{cases}a_1 x \equiv b_1 \pmod{n_1} \\a_2 x \equiv b_2 \pmod{n_2} \\\vdots \\a_k x \equiv b_k \pmod{n_k}\end{cases}.
  • xx \in \mathbb{Z} is a solution if it satisfies all kk equations.
© 版权声明

相关文章

13 条评论

  • 飞鸟与远行
    飞鸟与远行 读者

    同余方程的条件判断挺关键的

    马来西亚
    回复
  • 毁灭之歌
    毁灭之歌 读者

    质数定理这块公式看得眼花

    中国湖北
    回复
  • 水泥管道
    水泥管道 读者

    同余方程这块我上课也没太听懂。

    中国湖北
    回复
  • 碧海灵瞳
    碧海灵瞳 读者

    费马测试这块还是有点懵

    中国福建
    回复
    • 爱冒险的薯条
      爱冒险的薯条 读者

      同感,我也卡在这里

      日本@ 碧海灵瞳
      回复
  • 碧海歌者
    碧海歌者 读者

    同余方程组这块例子挺生动的。

    澳大利亚
    回复
  • 甜心奶球
    甜心奶球 读者

    线性同余这块可以再展开讲讲吗?

    日本
    回复
  • 水色天光
    水色天光 读者

    同余方程组的解是不是唯一的?

    中国湖北
    回复
  • 烤红薯香喷喷
    烤红薯香喷喷 读者

    素数定理这结论挺直观的

    美国
    回复
  • 檀木余温
    檀木余温 读者

    同余方程组这块例子挺生动的。

    中国广东
    回复
  • 磨坊姚
    磨坊姚 读者

    费马测试部分没太看懂。

    中国黑龙江
    回复
  • 长安旅人
    长安旅人 读者

    这课信息量有点炸裂,EEA推导那步卡了我十分钟😂

    中国
    回复