Summary of Lecture 6 𝐄 𝐄 𝐀 ( a , b ) \mathbf{EEA}(a, b) : input a , b ( a ≥ b > 0 ) a, b\,(a \ge b > 0) ; output d = gcd ( a , b ) d = \gcd(a, b) , integers s , t s, t such that d = a s + b t d = as + bt
r 0 = a ; r 1 = b ; ( s 0 t 0 ) = ( 1 0 ) ; ( s 1 t 1 ) = ( 0 1 ) ; 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}; r 0 = r 1 q 1 + r 2 ( 0 < r 2 < r 1 ) ; ( s 2 t 2 ) = ( s 0 t 0 ) − q 1 ( s 1 t 1 ) 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 r i − 1 = r i q i + r i + 1 ( 0 < r i + 1 < r i ) ; ( s i + 1 t i + 1 ) = ( s i − 1 t i − 1 ) − q i ( s i t i ) 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 r k − 2 = r k − 1 q k − 1 + r k ( 0 < r k < r k − 1 ) ; ( s k t k ) = ( s k − 2 t k − 2 ) − q k − 1 ( s k − 1 t k − 1 ) 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} r k − 1 = r k q k r_{k-1} = r_kq_k output r k , s k , t k r_k, s_k, t_k O ( ℓ ( a ) ℓ ( b ) ) O(\ell(a)\ell(b)) bit operations
Notations: Ω , Θ , π ( x ) = ∑ p ≤ x 1 , v p ( n ) \Omega, \Theta, \pi(x) = \sum_{p \le x} 1, v_p(n) // p v p ( n ) | n , p v p ( n ) + 1 ∤ n p^{v_p(n)} | n, p^{v_p(n)+1} \nmid n
THEOREM (Chebyshev, 1850) π ( x ) = Θ ( x ln x ) \pi(x) = \Theta\left(\frac{x}{\ln x}\right) .
LEMMA: Suppose that m ∈ ℤ + m \in \mathbb{Z}^+ . Then
( 2 m m ) ≥ 2 2 m 2 m and ( 2 m + 1 m ) ≤ 2 2 m \binom{2m}{m} \ge \frac{2^{2m}}{2m} \text{ and } \binom{2m+1}{m} \le 2^{2m} LEMMA: Suppose that p p is a prime and n ∈ ℤ + n \in \mathbb{Z}^+ . Then
v p ( n ! ) = ∑ k ≥ 1 ⌊ n / p k ⌋ v_p(n!) = \sum_{k \ge 1} \lfloor n/p^k \rfloor THEOREM: Let n ∈ ℤ + n \in \mathbb{Z}^+ and n ≥ 2 n \ge 2 . Then π ( n ) ≥ ln 2 2 ⋅ n ln n \pi(n) \ge \frac{\ln 2}{2} \cdot \frac{n}{\ln n} .
COROLLARY: π ( x ) = Ω ( x ln x ) \pi(x) = \Omega\left(\frac{x}{\ln x}\right) . // π ( x ) ≥ ln 2 4 ⋅ x ln x \pi(x) \ge \frac{\ln 2}{4} \cdot \frac{x}{\ln x}
Chebyshev’s Theorem COROLLARY: π ( x ) = Ω ( x ln x ) \pi(x) = \Omega\left(\frac{x}{\ln x}\right) .
For any real number x ≥ 2 x \ge 2 , we have π ( x ) ≥ π ( ⌊ x ⌋ ) ≥ ln 2 2 ⋅ ⌊ x ⌋ ln ⌊ x ⌋ ≥ ln 2 2 ⋅ x − 1 ln x ≥ ln 2 4 ⋅ x ln x \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 ) = ∑ p ≤ x ln p \theta(x) = \sum_{p \le x} \ln p // θ ( 5.2 ) = ln 2 + ln 3 + ln 5 = ln 30 \theta(5.2) = \ln 2 + \ln 3 + \ln 5 = \ln 30
THEOREM: θ ( x ) = Θ ( π ( x ) ln x ) \theta(x) = \Theta(\pi(x) \ln x) .
θ ( x ) ≤ π ( x ) ⋅ ln x \theta(x) \le \pi(x) \cdot \ln x // there are π ( x ) \pi(x) terms in θ ( x ) \theta(x) , each of which is ≤ ln x \le \ln x θ ( x ) ≥ ∑ x < p ≤ x ln p \theta(x) \ge \sum_{\sqrt{x} < p \le x} \ln p ≥ ( π ( x ) − x ) ln x \ge (\pi(x) – \sqrt{x}) \ln \sqrt{x} // there are at least π ( x ) − x \pi(x) – \sqrt{x} terms in the sum ∑ x < p ≤ x ln p \sum_{\sqrt{x} < p \le x} \ln p , each ≥ ln x \ge \ln \sqrt{x} = 1 2 ( 1 − x π ( x ) ) π ( x ) ln x = \frac{1}{2} \left( 1 – \frac{\sqrt{x}}{\pi(x)} \right) \pi(x) \ln x π ( x ) ≥ ln 2 4 ⋅ x ln x ⇒ x π ( x ) ≤ 4 ln x x ln 2 → 0 \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 x → ∞ x \to \infty )x π ( x ) < 1 2 \frac{\sqrt{x}}{\pi(x)} < \frac{1}{2} when x x is big enough, say x ≥ x 0 x \ge x_0 θ ( x ) ≥ 1 4 π ( x ) ln x \theta(x) \ge \frac{1}{4} \pi(x) \ln x for x ≥ x 0 x \ge x_0 THEOREM: For any integer n ≥ 1 , θ ( n ) < ( 2 ln 2 ) n n \ge 1, \theta(n) < (2 \ln 2)n .
n = 1 : θ ( 1 ) = 0 < ( 2 ln 2 ) ⋅ 1 n = 1: \theta(1) = 0 < (2 \ln 2) \cdot 1 n = 2 : θ ( 2 ) = ln 2 < ( 2 ln 2 ) ⋅ 2 n = 2: \theta(2) = \ln 2 < (2 \ln 2) \cdot 2 n = 3 : θ ( 3 ) = ln 2 + ln 3 < ( 2 ln 2 ) ⋅ 3 n = 3: \theta(3) = \ln 2 + \ln 3 < (2 \ln 2) \cdot 3 // ln 6 < ln 2 6 \ln 6 < \ln 2^6 n > 3 n > 3 and 2 | n 2|n : θ ( n ) = θ ( n − 1 ) < ( 2 ln 2 ) ( n − 1 ) < ( 2 ln 2 ) n \theta(n) = \theta(n-1) < (2 \ln 2)(n-1) < (2 \ln 2)n n > 3 n > 3 and 2 ∤ n 2 \nmid n : there is an integer m ≥ 2 m \ge 2 such that n = 2 m + 1 n = 2m + 1 M = ( 2 m + 1 m ) = ( 2 m + 1 ) ⋯ ( m + 2 ) m ! < 2 2 m M = \binom{2m+1}{m} = \frac{(2m+1)\cdots(m+2)}{m!} < 2^{2m} Any prime p , m + 1 < p ≤ 2 m + 1 p, m+1 < p \le 2m+1 must divide M M θ ( 2 m + 1 ) − θ ( m + 1 ) = ∑ m + 1 < p ≤ 2 m + 1 ln p \theta(2m+1) – \theta(m+1) = \sum_{m+1 < p \le 2m+1} \ln p ≤ ln M \le \ln M < ( 2 ln 2 ) m < (2 \ln 2)m θ ( n ) = θ ( 2 m + 1 ) − θ ( m + 1 ) + θ ( m + 1 ) \theta(n) = \theta(2m+1) – \theta(m+1) + \theta(m+1) < ( 2 ln 2 ) m + ( 2 ln 2 ) ( m + 1 ) < (2 \ln 2)m + (2 \ln 2)(m+1) = ( 2 ln 2 ) n = (2 \ln 2)n THEOREM: For any real number x ≥ 1 , θ ( x ) < ( 2 ln 2 ) x x \ge 1, \theta(x) < (2 \ln 2)x .θ ( x ) = θ ( ⌊ x ⌋ ) < ( 2 ln 2 ) ⌊ x ⌋ < ( 2 ln 2 ) 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 ) = ∑ p ≤ x 1 \pi(x) = \sum_{p \le x} 1 : # \# of primes ≤ x \le x
THEOREM (Hadamard;Poussin,1896) lim x → ∞ π ( x ) x ln x = 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 1 1 Rosser (1907-1989) and Schoenfeld (1920-2002) proved in 1962:π ( x ) > x ln x ( 1 + 1 2 ln x ) \pi(x) > \frac{x}{\ln x} (1 + \frac{1}{2 \ln x}) when x ≥ 59 x \ge 59 π ( x ) < x ln x ( 1 + 3 2 ln x ) \pi(x) < \frac{x}{\ln x} (1 + \frac{3}{2 \ln x}) when x > 1 x > 1 NOTATION: ℙ \mathbb{P} – the set of all primes; ℙ n = { p ∈ ℙ : 2 n − 1 ≤ p < 2 n } \mathbb{P}_n = \{p \in \mathbb{P} : 2^{n-1} \le p < 2^n\} .
THEOREM: | ℙ n | ≥ 2 n n ln 2 ( 1 2 + O ( 1 n ) ) |\mathbb{P}_n| \ge \frac{2^n}{n \ln 2} \left(\frac{1}{2} + O\left(\frac{1}{n}\right)\right) when n → ∞ n \to \infty .
EXAMPLE: The number of n n -bit primes for n ∈ { 10 , … , 25 } n \in \{10, …, 25\} .
n n | ℙ n | |\mathbb{P}_n| 2 n − 1 n ln 2 \frac{2^{n-1}}{n} \ln 2 n n | ℙ n | |\mathbb{P}_n| 2 n − 1 n ln 2 \frac{2^{n-1}}{n} \ln 2 10 75 73.8 18 10749 10505.4 11 137 134.3 19 20390 19904.9 12 255 246.2 20 38635 37819.4 13 464 454.6 21 73586 72036.9 14 872 844.2 22 140336 137525.0 15 1612 1575.8 23 268216 263091.4 16 3030 2954.6 24 513708 504258.5 17 5709 5561.7 25 985818 968176.3
Prime Number Generation Basic Idea: randomly choose n n -bit integers until a prime found.
The number of n n -bit integers is 2 n − 1 2^{n-1} | ℙ n | ≥ 2 n n ln 2 ( 1 2 + O ( 1 n ) ) |\mathbb{P}_n| \ge \frac{2^n}{n \ln 2} \left(\frac{1}{2} + O\left(\frac{1}{n}\right)\right) when n → ∞ n \to \infty The probability that a prime is chosen in every trial is equal toα n = 1 n ln 2 ( 1 + O ( 1 n ) ) , n → ∞ \alpha_n = \frac{1}{n \ln 2} \left(1 + O\left(\frac{1}{n}\right)\right), n \to \infty In α n − 1 = n ln 2 1 + O ( 1 n ) ≤ 2 n ln 2 \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 n n -bit prime can be done efficiently.
The expected # \# of trials is ≤ 2 n ln 2 \le 2n \ln 2 , a polynomial in n n (input length) Determine if an n n -bit integer is prime can be done efficiently THEOREM: An integer n ≥ 1 n \ge 1 is a prime iff a n − 1 ≡ 1 ( mod n ) a^{n-1} \equiv 1 \pmod{n} for a = 1 , 2 , … , n − 1 a = 1, 2, \dots, n-1 .
⟹ \implies : by Fermat’s little theorem⟹ \implies : if not, then n = k l n = kl . We cannot have k n − 1 ≡ 1 ( mod n ) k^{n-1} \equiv 1 \pmod{n} Fermat test: 𝐅 𝐞 𝐫 𝐦 𝐚 𝐭 ( n , t ) \mathbf{Fermat}(n, t)
Input: an odd integer n ≥ 3 n \ge 3 and an integer t ≥ 1 t \ge 1 Output: prime/compositefor i = 1 i = 1 to t t dochoose a random integer a ∈ { 2 , … , n − 2 } a \in \{2, \dots, n-2\} If ( a n − 1 mod n ) ≠ 1 (a^{n-1}\bmod n) \neq 1 return “prime” Analysis: If n n is a prime, always output “prime” If n n 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 a x ≡ b ( mod n ) ax \equiv b \pmod n , where x x is unknown.
THEOREM: Let n ∈ ℤ + , a ∈ ℤ n \in \mathbb{Z}^+, a \in \mathbb{Z} and d = gcd ( a , n ) d = \gcd(a, n) . Then a x ≡ b ( mod n ) ax \equiv b \pmod n has a solution if and only if d | b d\mid b .
⟹ \implies : suppose that a x 0 ≡ b ( mod n ) ax_0 \equiv b \pmod n for a specific x 0 ∈ ℤ x_0 \in \mathbb{Z} ∃ z ∈ ℤ \exists z \in \mathbb{Z} such that a x 0 − b = n z ax_0 – b = nz b = a x 0 − n z b = ax_0 – nz d | a , d | n ⟹ d | b d\mid a, d\mid n \implies d\mid b ⟸ \impliedby : suppose that d | b d\mid b d = gcd ( a , n ) d = \gcd(a, n) ∃ s , t ∈ ℤ \exists s, t \in \mathbb{Z} such that a s + n t = d as + nt = d b = d z = a s z + n t z b = dz = asz + ntz a ( s z ) ≡ b ( mod n ) a(sz) \equiv b \pmod n s z sz is a solutionTHEOREM: Let n ∈ ℤ + , a ∈ ℤ , gcd ( a , n ) = d , t = ( a d ) − 1 ( mod n d ) 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 | b d\mid b , then a x ≡ b ( mod n ) ax \equiv b \pmod n iff x ≡ b d t ( mod n d ) x \equiv \frac{b}{d}t \pmod{\frac{n}{d}} .
d = gcd ( a , n ) , d | b d = \gcd(a, n), d\mid b a x ≡ b ( mod n ) ⟺ n | ( a x − b ) ax \equiv b \pmod n \iff n \mid (ax – b) n | ( a x − b ) ⟺ n d | ( a d x − b d ) n \mid (ax – b) \iff \frac{n}{d}\mid \left(\frac{a}{d}x – \frac{b}{d}\right) n d | ( a d x − b d ) ⟺ a d x ≡ b d ( mod n d ) \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}} a d x ≡ b d ( mod n d ) ⟹ t a d x ≡ t b d ( mod n d ) \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}} ⟹ x ≡ t b d ( mod n d ) \implies x \equiv t\frac{b}{d} \pmod{\frac{n}{d}} x ≡ t b d ( mod n d ) ⟹ t a d x ≡ t b d ( mod n d ) 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}} ⟹ a d x ≡ b d ( mod n d ) \implies \frac{a}{d}x \equiv \frac{b}{d} \pmod{\frac{n}{d}} t = ( a d ) − 1 ( mod n d ) t = \left(\frac{a}{d}\right)^{-1} \pmod{\frac{n}{d}} t a d ≡ 1 ( mod n d ) t\frac{a}{d} \equiv 1 \pmod{\frac{n}{d}} 1 ≡ t a d ( mod n d ) 1 \equiv t\frac{a}{d} \pmod{\frac{n}{d}} x ≡ t a d x ( mod n d ) 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?
x ≡ 2 ( mod 3 ) x \equiv 2 \pmod{3} ;x ≡ 3 ( mod 5 ) x \equiv 3 \pmod{5} ;x ≡ 2 ( mod 7 ) x \equiv 2 \pmod{7} DEFINITION: A system of linear congruences is a set of linear congruence equations of the form
{ a 1 x ≡ b 1 ( mod n 1 ) a 2 x ≡ b 2 ( mod n 2 ) ⋮ a k x ≡ b k ( mod n k ) . \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}. x ∈ ℤ x \in \mathbb{Z} is a solution if it satisfies all k k equations.
同余方程的条件判断挺关键的
质数定理这块公式看得眼花
同余方程这块我上课也没太听懂。
费马测试这块还是有点懵
同感,我也卡在这里
同余方程组这块例子挺生动的。
线性同余这块可以再展开讲讲吗?
同余方程组的解是不是唯一的?
素数定理这结论挺直观的
同余方程组这块例子挺生动的。
例子确实很清晰
费马测试部分没太看懂。
这课信息量有点炸裂,EEA推导那步卡了我十分钟😂