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 1 , x 2 , . . . , x n ] : X a i 1 ,i 2 ,...,i n x i 1 1 x i 2 2 · · · x i n f ( x 1 , x 2 , . . . , x n ) = n i 1 ,i 2 ,...,i n ≥ 0 degree of f : maximum i 1 + i 2 + · · · + i n with a i 1 ,i 2 ,...,i n 6 = 0
Input : of degree d f, g ∈ F [ x 1 , x 2 , . . . , x n ] Output : f ≡ g ? equivalently: Input : of degree d f ∈ F [ x 1 , x 2 , . . . , x n ] Output : f ≡ 0? f is given as block-box: given any ~ x = ( x 1 , x 2 , . . . , x n ) returns f ( ~ x ) e.g. or as product from: Vandermonde determinant x n − 1 x 2 1 x 1 . . . 1 1 x n − 1 x 2 1 x 2 . . . Y f ( ~ x ) = det( M ) = ( x i − x j ) 2 2 M = . . . . ... . . . . . . . . j<i x 2 x n − 1 1 x n . . . n n
Input : of degree d f ∈ F [ x 1 , x 2 , . . . , x n ] Output : f ≡ 0? fix an arbitrary S ⊆ F pick random r 1 , r 2 , ... , r n ∈ S uniformly and independently at random; check whether f ( r 1 , r 2 , ... , r n ) = 0 ; f ( r 1 , r 2 , . . . , r n ) = 0 f ≡ 0
Input : a polynomial of degree d f ∈ F [ x ] Output : f ≡ 0? fix an arbitrary S ⊆ F pick a uniform random r ∈ S ; check whether f ( r ) = 0 ; f ≡ 0 f ( r ) = 0 Fundamental Theorem of Algebra: A degree d polynomial has at most d roots. Pr[ f ( r ) = 0] ≤ d f 6⌘ 0 | S |
Input : of degree d f ∈ F [ x 1 , x 2 , . . . , x n ] Output : f ≡ 0? fix an arbitrary S ⊆ F pick random r 1 , r 2 , ... , r n ∈ S uniformly and independently at random; check whether f ( r 1 , r 2 , ... , r n ) = 0 ; f ( r 1 , r 2 , . . . , r n ) = 0 f ≡ 0 Schwartz-Zippel Theorem Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] ≤ d f 6⌘ 0 | S |
Schwartz-Zippel Theorem Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] ≤ d f 6⌘ 0 | S | induction on n : basis: single-variate case, proved by n =1 the fundamental Theorem of algebra I.H.: Schwartz-Zippel Thm is true for all smaller n
Schwartz-Zippel Theorem Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] ≤ d f 6⌘ 0 | S | induction step: f k 6⌘ 0 n k : highest power of x n in f degree of f k ≤ d − k k X x i f ( x 1 , x 2 , . . . , x n ) = n f i ( x 1 , x 2 , . . . , x n − 1 ) i =0 n f k ( x 1 , x 2 , . . . , x n − 1 ) + ¯ = x k f ( x 1 , x 2 , . . . , x n ) k − 1 ¯ X x i where f ( x 1 , x 2 , . . . , x n ) = n f i ( x 1 , x 2 , . . . , x n − 1 ) i =0 highest power of x n in ¯ f < k
Schwartz-Zippel Theorem Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] ≤ d f 6⌘ 0 | S | n f k ( x 1 , x 2 , . . . , x n − 1 ) + ¯ = x k f ( x 1 , x 2 , . . . , x n ) f ( x 1 , x 2 , . . . , x n ) f k 6⌘ 0 n highest power of x n in ¯ f < k degree of f k ≤ d − k law of total probability: ≤ d − k I.H. Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] | S | = Pr[ f ( ~ r ) = 0 | f k ( r 1 , . . . , r n − 1 ) = 0] · Pr[ f k ( r 1 , . . . , r n − 1 ) = 0] + Pr[ f ( ~ r ) = 0 | f k ( r 1 , . . . , r n − 1 ) 6 = 0] · Pr[ f k ( r 1 , . . . , r n − 1 ) 6 = 0] ≤ k = Pr[ g r 1 ,...,r n − 1 ( r n ) = 0 | f k ( r 1 , . . . , r n − 1 ) 6 = 0] | S | where g x 1 ,...,x n − 1 ( x n ) = f ( x 1 , . . . , x n )
Schwartz-Zippel Theorem Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] ≤ d f 6⌘ 0 | S | Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] ≤ d − k + k = d | S | | S | | S |
Input : of degree d f ∈ F [ x 1 , x 2 , . . . , x n ] Output : f ≡ 0? fix an arbitrary S ⊆ F pick random r 1 , r 2 , ... , r n ∈ S uniformly and independently at random; check whether f ( r 1 , r 2 , ... , r n ) = 0 ; f ( r 1 , r 2 , . . . , r n ) = 0 f ≡ 0 Schwartz-Zippel Theorem Pr[ f ( r 1 , r 2 , . . . , r n ) = 0] ≤ d f 6⌘ 0 | S |
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); • ....
Bipartite Perfect Matching bipartite graph perfect matchings G ([ n ],[ n ], E ) determine whether a bipartite graph has PM: • Hall’s theorem: enumerates all subset of [ n ] • Hungarian method: O( n 3 ) • Hopcroft-Karp algorithm: O( m √ n ) • efficient parallel algorithms?
bipartite graph 1 1 x 11 x 12 x 13 2 2 A = x 21 x 22 0 x 32 x 33 0 3 3 G ([ n ],[ n ], E ) det( A ) = x 11 x 22 x 33 + x 13 x 21 x 32 − x 12 x 21 x 33 Edmond matrix: ( if ( i, j ) 2 E x i,j A ( i, j ) = 0 if ( i, j ) 62 E X Y X Y A ( i, π ( i )) = det( A ) = sgn( π ) sgn( π ) x i, π ( i ) π ∈ S n i ∈ [ n ] π ∈ S n i ∈ [ n ] if and only if ∃ a perfect matching 6⌘ 0
bipartite graph Edmond matrix: ( 1 1 if ( i, j ) 2 E x i,j A ( i, j ) = 0 if ( i, j ) 62 E 2 2 3 3 det( A ) 6⌘ 0 if and only if ∃ a perfect matching G ([ n ],[ n ], E ) 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)
Isomorphism of Rooted Trees root root ≌
Isomorphism of Rooted Trees T associate each tree T a polynomial: 3 T is of height k T 1 T 2 T 3 2 subtrees rooted by children 1 of the root of T : T 1 , T 2 , ..., T m 0 f T = ( x k − f T 1 )( x k − f T 2 ) · · · ( x k − f T m ) f T = ( x 3 − x 0 )( x 3 − ( x 2 − ( x 1 − x 0 ) 3 )( x 2 − x 0 ))( x 3 − ( x 2 − ( x 1 − x 0 ) 2 )) by induction and the uniqueness of polynomial factorization : f T ≡ f T 0 = T 0 T ∼
Fingerprinting X = Y ? FING( X ) = FING( Y ) ? • 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.
Checking Matrix Multiplication three n × n matrices A , B , C : ? = × A B C Freivald’s Algorithm pick a uniform random r ∈ {0,1} n ; check whether A ( Br ) = Cr ; matrix M : FING( M ) = Mr for uniform random r ∈ {0,1} n
Polynomial Identity Testing (PIT) Input : of degree d f ∈ F [ x 1 , x 2 , . . . , x n ] Output : f ≡ 0? fix an arbitrary S ⊆ F pick random r 1 , r 2 , ... , r n ∈ S uniformly and independently at random; check whether f ( r 1 , r 2 , ... , r n ) = 0 ; polynomial f : FING( f ) = f ( r 1 , r 2 , ... , r n ) for uniform&independent r 1 , ... , r n ∈ S
Communication Complexity a = b ? a b EQ : { 0 , 1 } n × { 0 , 1 } n → { 0 , 1 } � 1 a = b EQ( a, b ) = 0 a ̸ = b
Fingerprinting FING( a ) = FING( b )? pick a random FING() description of FING() a b FING( b ) • 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.
n − 1 n − 1 f ( r )= g ( r ) ? � X b i x i a i x i f = g = i =0 i =0 r , g ( r ) ∈ { 0 , 1 } n a b ∈ { 0 , 1 } n pick uniform random r ∈ [2 n ] f, g ∈ Z p [ x ] for prime p ∈ [2 k , 2 k +1 ] k = � log 2 (2 n ) � FING( b ) = Σ i b i r i for random r
uniform random a ≡ b (mod p )? prime p ∈ [ k ] p a ∈ [2 n ] b ∈ [2 n ] b mod p FING( x ) = x mod p for uniform random prime p ∈ [ k ] communication complexity: O(log k ) if a = b a ≡ b (mod p ) if a ≠ b : Pr[ a ≡ b (mod p )] ≤ ? for a z = | a - b | ≠ 0 : Pr[ z mod p =0] ≤ ?
uniform random prime p ∈ [ k ] for a z = | a - b | ≠ 0 : Pr[ z mod p =0] ≤ ? ∈ [2 n ] } # of prime divisors of z ≤ n each prime divisor ≥ 2 # of prime divisors of z ≤ n Pr[ z mod p = 0] = # of primes in [ k ] = π ( k ) π ( N ) : # of primes in [ N ] Prime Number Theorem (PNT) N as N ⟶ ∞ π ( n ) ∼ ln N
uniform random a ≡ b (mod p )? prime p ∈ [ k ] p a ∈ [2 n ] b ∈ [2 n ] b mod p for a z = | a - b | ≠ 0 : Pr[ z mod p =0] ≤ ? # of prime divisors of z ≤ n Pr[ z mod p = 0] = # of primes in [ k ] = π ( k ) ≤ n ln k = 2ln n choose k = n 2 k n
uniform random a ≡ b (mod p )? prime p ∈ [ n 2 ] p a ∈ [2 n ] b ∈ [2 n ] b mod p FING( b ) = b mod p for uniform random prime p ∈ [ n 2 ] communication complexity: O(log n ) if a = b a ≡ b (mod p ) if a ≠ b Pr[ a ≡ b (mod p )] ≤ (2 ln n ) / n
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
Pattern Matching x ( i ) = y ? y ∈ {0,1} m y 1 y 2 y : y m x 1 x n ∈ {0,1} n x : x i x i +1 x i+m -1 x ( i ) Ω x ( i ) denote x ( i ) = x i x i +1 ... x i + m -1 FING( a ) = a mod p pick a random FING() ; for i =1, 2, ..., n - m +1 ; if FING( x ( i )) = FING( y ) then return “match!”; return “not match!”;
Pattern Matching x ( i ) = y ? y ∈ {0,1} m y 1 y 2 y : y m x 1 x n ∈ {0,1} n x : x i x i +1 x i+m -1 x ( i ) Ω x ( i ) denote x ( i ) = x i x i +1 ... x i + m -1 FING( a ) = a mod p Karp-Rabin Algorithm: pick a uniform random prime p ∈ [ mn 2 ] ; for i =1, 2, ..., n - m +1 ; if x ( i ) ≡ y (mod p ) then return “match!”; return “not match!”;
Recommend
More recommend