Randomized Algorithms Polynomial Identity Testing (PIT) Input : - - PowerPoint PPT Presentation

randomized algorithms
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Randomized Algorithms

南京大学 尹一通

slide-2
SLIDE 2

Polynomial Identity Testing

(PIT)

Input:

  • f degree d

Output:

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] :

slide-3
SLIDE 3

Input:

  • f degree d

Output:

f ≡ g?

f, g ∈ F[x1, x2, . . . , xn]

Input:

  • f degree d

Output:

f ≡ 0?

f ∈ F[x1, x2, . . . , xn]

equivalently:

f is given as block-box: given any ~ x = (x1, x2, . . . , xn) returns f(~ x)

  • r as product from:

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)

e.g.

slide-4
SLIDE 4

Input:

  • f degree d

Output:

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 ;

fix an arbitrary S ⊆ F

f ≡ 0 f(r1, r2, . . . , rn) = 0

slide-5
SLIDE 5

A degree d polynomial has at most d roots.

Fundamental Theorem of Algebra:

pick a uniform random r ∈S; check whether f(r) = 0 ;

Input: a polynomial

  • f degree d

Output:

f ∈ F[x] f ≡ 0?

fix an arbitrary S ⊆ F

f ≡ 0 f(r) = 0 f 6⌘ 0 Pr[f(r) = 0] ≤ d |S|

slide-6
SLIDE 6

Input:

  • f degree d

Output:

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 ;

fix an arbitrary S ⊆ F

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 f ≡ 0 f(r1, r2, . . . , rn) = 0

slide-7
SLIDE 7

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0

induction on n : basis: n=1

single-variate case, proved by the fundamental Theorem of algebra

I.H.:

Schwartz-Zippel Thm is true for all smaller n

slide-8
SLIDE 8

f(x1, x2, . . . , xn) =

k

X

i=0

xi

nfi(x1, x2, . . . , xn−1)

k: highest power of xn in f

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

induction step:

slide-9
SLIDE 9

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]

I.H.

≤ 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]

slide-10
SLIDE 10

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|

slide-11
SLIDE 11

Input:

  • f degree d

Output:

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 ;

fix an arbitrary S ⊆ F

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 f ≡ 0 f(r1, r2, . . . , rn) = 0

slide-12
SLIDE 12

Applications of Schwartz-Zippel

  • test whether a graph has perfect matching;
  • test isomorphism of rooted trees;
  • distance property of Reed-Muller codes;
  • proof of hardness vs randomness tradeoff;
  • algebraic construction of probabilistically

checkable proofs (PCP);

  • ....
slide-13
SLIDE 13

Bipartite Perfect Matching

bipartite graph G([n],[n],E) perfect matchings

  • Hall’s theorem: enumerates all subset of [n]
  • Hungarian method: O(n3)
  • Hopcroft-Karp algorithm: O(m√n)
  • efficient parallel algorithms?

determine whether a bipartite graph has PM:

slide-14
SLIDE 14

bipartite graph G([n],[n],E)

A(i, j) = ( xi,j if (i, j) 2 E if (i, j) 62 E

Edmond matrix:

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

slide-15
SLIDE 15

bipartite graph G([n],[n],E)

A(i, j) = ( xi,j if (i, j) 2 E if (i, j) 62 E

Edmond matrix:

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:

  • use Schwartz-Zippel to check whether det(A)≢0
  • there are fast parallel algorithms for computing

determinants of numerical matrices (Chistov’s algorithm)

slide-16
SLIDE 16

Isomorphism of Rooted Trees

root root

slide-17
SLIDE 17

Isomorphism of Rooted Trees

T

T1 T2 T3

associate each tree T a polynomial:

fT = (xk − fT1)(xk − fT2) · · · (xk − fTm)

subtrees rooted by children

  • f the root of T: T1, T2, ..., Tm

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:

slide-18
SLIDE 18

Fingerprinting

  • FING( ) is a function: X=Y ⇒ FING(X ) = FING(Y )
  • if X ≠ Y , Pr[ FING( X ) = FING( Y ) ] is small.
  • Fingerprints are easy to compute and compare.

X = Y ? FING( X ) = FING( Y ) ?

slide-19
SLIDE 19

Checking Matrix Multiplication

A B C

×

=

?

three n×n matrices A, B, C:

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

matrix M:

slide-20
SLIDE 20

Input:

  • f degree d

Output:

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 ;

fix an arbitrary S ⊆ F

Polynomial Identity Testing (PIT)

FING(f) = f(r1, r2, ... , rn) for uniform&independent r1, ... , rn ∈S

polynomial f:

slide-21
SLIDE 21

Communication Complexity

EQ : {0, 1}n × {0, 1}n → {0, 1}

a b a = b?

EQ(a, b) =

  • 1

a = b a ̸= b

slide-22
SLIDE 22

Fingerprinting

a b

FING(a) = FING(b)? FING(b)

description

  • f FING()

pick a random

FING()

  • FING( ) is a function: a=b ⇒ FING(a) = FING(b)
  • if a ≠ b , Pr[ FING(a) = FING(b) ] is small.
  • Fingerprints are easy to compute and compare.
slide-23
SLIDE 23

a b ∈{0, 1}n ∈{0, 1}n

f =

n−1

  • i=0

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]

prime

f, g ∈ Zp[x]

for

FING(b) = Σi bi ri for random r

slide-24
SLIDE 24

a ∈[2n] b ∈[2n]

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

a ≡ b (mod p)

for a z = | a - b | ≠ 0 : Pr[z mod p =0] ≤ ?

b mod p

slide-25
SLIDE 25

for a z = | a - b | ≠ 0 : Pr[z mod p =0] ≤ ? ∈[2n]

Pr[z mod p = 0] # of primes in [k]

uniform random prime p ∈[k]

# of prime divisors of z ≤ n = π(k)

each prime divisor ≥ 2 # of prime divisors of z ≤ n

}

π(N) : # of primes in [N] = Prime Number Theorem (PNT)

π(n) ∼ N lnN

as N ⟶∞

slide-26
SLIDE 26

for a z = | a - b | ≠ 0 : Pr[z mod p =0] ≤ ?

Pr[z mod p = 0] # of primes in [k] # of prime divisors of z ≤ n = π(k) =

≤ n lnk k

choose k = n2

= 2lnn n

a ∈[2n] b ∈[2n]

p

a ≡ b (mod p)? uniform random prime p ∈[k]

b mod p

slide-27
SLIDE 27

a ∈[2n] b ∈[2n]

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

a ≡ b (mod p)

p b mod p

slide-28
SLIDE 28

Pattern Matching

  • Input: string x ∈ {0,1}n, pattern y ∈{0,1}m
  • check wether y is a substring of x
  • naive algorithm: O(mn) time
  • the Knuth-Morris-Prat algorithm: O(m+n) time
slide-29
SLIDE 29

Pattern Matching

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

slide-30
SLIDE 30

Pattern Matching

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

slide-31
SLIDE 31

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!”;

slide-32
SLIDE 32

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!”;