Randomized Algorithms
南京大学 尹一通
Randomized Algorithms Polynomial Identity Testing (PIT) Input : - - PowerPoint PPT Presentation
Randomized Algorithms Polynomial Identity Testing (PIT) Input : of degree d f, g F [ x 1 , x 2 , . . . , x n ] Output : f g ? F [ x 1 , x 2 , . . . , x n ] : ring of n -variate polynomials over field F f F [ x
南京大学 尹一通
f ≡ g?
f, g ∈ F[x1, x2, . . . , xn] F[x1, x2, . . . , xn] : ring of n-variate polynomials over field F f(x1, x2, . . . , xn) = X
i1,i2,...,in≥0
ai1,i2,...,inxi1
1 xi2 2 · · · xin n
degree of f : maximum i1 + i2 + · · · + in ai1,i2,...,in 6= 0 with f ∈ F[x1, x2, . . . , xn] :
f ≡ g?
f, g ∈ F[x1, x2, . . . , xn]
f ≡ 0?
f ∈ F[x1, x2, . . . , xn]
f is given as block-box: given any ~ x = (x1, x2, . . . , xn) returns f(~ x)
Vandermonde determinant
M = 1 x1 x2
1
. . . xn−1
1
1 x2 x2
2
. . . xn−1
2
. . . . . . . . . ... . . . 1 xn x2
n
. . . xn−1
n
f(~ x) = det(M) = Y
j<i
(xi − xj)
f ≡ 0?
f ∈ F[x1, x2, . . . , xn] pick random r1, r2, ... , rn ∈S
uniformly and independently at random;
check whether f(r1, r2, ... , rn) = 0 ;
f ≡ 0 f(r1, r2, . . . , rn) = 0
Fundamental Theorem of Algebra:
pick a uniform random r ∈S; check whether f(r) = 0 ;
f ∈ F[x] f ≡ 0?
f ≡ 0 f(r) = 0 f 6⌘ 0 Pr[f(r) = 0] ≤ d |S|
f ≡ 0?
f ∈ F[x1, x2, . . . , xn] pick random r1, r2, ... , rn ∈S
uniformly and independently at random;
check whether f(r1, r2, ... , rn) = 0 ;
Schwartz-Zippel Theorem
Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 f ≡ 0 f(r1, r2, . . . , rn) = 0
Schwartz-Zippel Theorem
Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0
single-variate case, proved by the fundamental Theorem of algebra
Schwartz-Zippel Thm is true for all smaller n
f(x1, x2, . . . , xn) =
k
X
i=0
xi
nfi(x1, x2, . . . , xn−1)
fk 6⌘ 0
degree of fk ≤ d − k
n = xk
nfk(x1, x2, . . . , xn−1) + ¯
f(x1, x2, . . . , xn) ¯ f(x1, x2, . . . , xn) =
k−1
X
i=0
xi
nfi(x1, x2, . . . , xn−1)
where highest power of xn in ¯ f < k
Schwartz-Zippel Theorem
Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0
highest power of xn in ¯ f < k fk 6⌘ 0
degree of fk ≤ d − k
= xk
nfk(x1, x2, . . . , xn−1) + ¯
f(x1, x2, . . . , xn)
Schwartz-Zippel Theorem
Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0
f(x1, x2, . . . , xn)
n law of total probability: Pr[f(r1, r2, . . . , rn) = 0]
= Pr[f(~ r) = 0 | fk(r1, . . . , rn−1) = 0] · Pr[fk(r1, . . . , rn−1) = 0] + Pr[f(~ r) = 0 | fk(r1, . . . , rn−1) 6= 0] · Pr[fk(r1, . . . , rn−1) 6= 0]
≤ d − k |S|
≤ k |S|
gx1,...,xn−1(xn) = f(x1, . . . , xn)
where
= Pr[gr1,...,rn−1(rn) = 0 | fk(r1, . . . , rn−1) 6= 0]
Schwartz-Zippel Theorem
Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 Pr[f(r1, r2, . . . , rn) = 0] ≤ d − k |S| + k |S| = d |S|
f ≡ 0?
f ∈ F[x1, x2, . . . , xn] pick random r1, r2, ... , rn ∈S
uniformly and independently at random;
check whether f(r1, r2, ... , rn) = 0 ;
Schwartz-Zippel Theorem
Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 f ≡ 0 f(r1, r2, . . . , rn) = 0
A(i, j) = ( xi,j if (i, j) 2 E if (i, j) 62 E
1 2 3 1 2 3 A = x11 x12 x13 x21 x22 x32 x33
det(A) = X
π∈Sn
sgn(π) Y
i∈[n]
A(i, π(i)) =
X
π∈Sn
sgn(π) Y
i∈[n]
xi,π(i)
6⌘ 0 if and only if ∃ a perfect matching det(A) =x11x22x33 + x13x21x32 − x12x21x33
A(i, j) = ( xi,j if (i, j) 2 E if (i, j) 62 E
1 2 3 1 2 3 if and only if ∃ a perfect matching det(A) 6⌘ 0 det(A) is an n-variate degree-n polynomial:
determinants of numerical matrices (Chistov’s algorithm)
≌
root root
T
T1 T2 T3
associate each tree T a polynomial:
fT = (xk − fT1)(xk − fT2) · · · (xk − fTm)
subtrees rooted by children
T is of height k
1 2 3
fT = (x3 − x0)(x3 − (x2 − (x1 − x0)3)(x2 − x0))(x3 − (x2 − (x1 − x0)2))
fT ≡ fT 0 T ∼ = T 0 by induction and the uniqueness of polynomial factorization:
Freivald’s Algorithm pick a uniform random r ∈{0,1}n; check whether A(Br) = Cr ; FING(M) = Mr for uniform random r ∈{0,1}n
f ≡ 0?
f ∈ F[x1, x2, . . . , xn] pick random r1, r2, ... , rn ∈S
uniformly and independently at random;
check whether f(r1, r2, ... , rn) = 0 ;
FING(f) = f(r1, r2, ... , rn) for uniform&independent r1, ... , rn ∈S
EQ : {0, 1}n × {0, 1}n → {0, 1}
EQ(a, b) =
a = b a ̸= b
FING(a) = FING(b)? FING(b)
description
pick a random
FING()
f =
n−1
aixi
pick uniform random r ∈[2n]
r, g(r) f(r)=g(r) ?
g =
n−1
X
i=0
bixi
k = log2(2n)
p ∈ [2k, 2k+1]
f, g ∈ Zp[x]
FING(b) = Σi bi ri for random r
p
a ≡ b (mod p)? uniform random prime p ∈[k] communication complexity: O(log k) FING(x) = x mod p for uniform random prime p ∈[k] if a ≠ b : Pr[a ≡ b (mod p)] ≤ ? if a = b
for a z = | a - b | ≠ 0 : Pr[z mod p =0] ≤ ?
b mod p
for a z = | a - b | ≠ 0 : Pr[z mod p =0] ≤ ? ∈[2n]
uniform random prime p ∈[k]
each prime divisor ≥ 2 # of prime divisors of z ≤ n
π(n) ∼ N lnN
as N ⟶∞
for a z = | a - b | ≠ 0 : Pr[z mod p =0] ≤ ?
≤ n lnk k
= 2lnn n
p
a ≡ b (mod p)? uniform random prime p ∈[k]
b mod p
a ≡ b (mod p)? uniform random prime p ∈[n2] communication complexity: O(log n) FING(b) = b mod p for uniform random prime p ∈[n2] if a ≠ b Pr[a ≡ b (mod p)] ≤ (2 ln n) / n if a = b
p b mod p
x : y : y1 y2 ym
xi+m-1
xi+1
x1
xi
xn ∈{0,1}m ∈{0,1}n
x(i) denote x(i) = xixi+1 ... xi+m-1 y x(i) x(i) = y ? pick a random FING(); for i=1, 2, ..., n-m+1; if FING(x(i)) = FING(y) then return “match!”; return “not match!”;
FING(a) = a mod p
x : y : y1 y2 ym
xi+m-1
xi+1
x1
xi
xn ∈{0,1}m ∈{0,1}n
x(i) denote x(i) = xixi+1 ... xi+m-1 y x(i) x(i) = y ? Karp-Rabin Algorithm: pick a uniform random prime p ∈[mn2]; for i=1, 2, ..., n-m+1; if x(i) ≡ y (mod p) then return “match!”; return “not match!”;
FING(a) = a mod p
x : y : y1 y2 ym
xi+m-1
xi+1
x1
xi
xn ∈{0,1}m ∈{0,1}n
x(i) for each i, if x(i) ≠ y Pr[ x(i) ≡ y (mod p) ] = m ln(mn2) /mn2 = o(1/n) Pr[ mistake ] = Pr[ ∃ i, x(i) ≠ y ∧ x(i) ≡ y (mod p) ] = o(1) union bound Karp-Rabin Algorithm: pick a uniform random prime p ∈[mn2]; for i=1, 2, ..., n-m+1; if x(i) ≡ y (mod p) then return “match!”; return “not match!”;
x : y : y1 y2 ym
xi+m-1
xi+1
x1
xi
xn ∈{0,1}m ∈{0,1}n
x(i) x(i+1) = xi+m + 2(x(i) - 2m-1xi)
FING(x(i+1)) = ( xi+m + 2(FING(x(i)) - 2m-1xi) ) mod p FING(a) = a mod p
“x(i) ≡ y (mod p)” can be tested in constant time Karp-Rabin Algorithm: pick a uniform random prime p ∈[mn2]; for i=1, 2, ..., n-m+1; if x(i) ≡ y (mod p) then return “match!”; return “not match!”;