Complexity Theory of Polynomial-Time Problems
Lecture 4: The polynomial method Part II: All-pairs shortest paths
Sebastian Krinninger
Polynomial-Time Problems Lecture 4: The polynomial method Part II: - - PowerPoint PPT Presentation
Complexity Theory of Polynomial-Time Problems Lecture 4: The polynomial method Part II: All-pairs shortest paths Sebastian Krinninger Overview on APSP Algorithms Floyd-Warshall algorithm: ( 3 ) Inserts one node at a time
Lecture 4: The polynomial method Part II: All-pairs shortest paths
Sebastian Krinninger
Inserts one node at a time ๐ iterations, each taking time ๐(๐2)
Running Time Author(s) Year(s) ๐3 Floyd, Warshall 1962 ๐3/ log1/3 ๐ Fredman 1975 ๐3/ log1/2 ๐ Dobosiewicz, Takaoka 1990, 1991 ๐3/ log5/7 ๐ Han 2004 ๐3/ log ๐ Takaoka, Zwick, Chan 2004, 2005 ๐3/ log5/4 ๐ Han 2006 ๐3/ log2 ๐ Chan, Han/Takaoka 2007, 2012 ๐3/2ฮฉ log ๐ 1/2 Williams 2014 Grows faster than any polylogarithmic factor
For every pair of nodes ๐ฃ, ๐ค, SP ๐ฃ, ๐ค = next node on shortest path from ๐ฃ to ๐ค
๐,๐ = 0 or 1 with probability 1 2
๐ต ๐ฆ1, โฆ , ๐ฆ๐ =
๐=1 ๐
1 โ
๐=1 ๐
๐
๐,๐ โ ๐ฆ๐ โ 1
๐ ๐,๐ ๐ต ๐ฆ1, โฆ , ๐ฆ๐ = ๐ฆ1 โง โฏ โง ๐ฆ๐ โฅ 1 โ 1 2๐
๐ต ๐ฆ1, โฆ , ๐ฆ๐ =
๐=1 ๐
1 โ
๐=1 ๐
๐
๐,๐ โ ๐ฆ๐ โ 1
Lemma: Pr
๐ ๐,๐ ๐ต ๐ฆ1, โฆ , ๐ฆ๐ = ๐ฆ1 โง โฏ โง ๐ฆ๐ โฅ 1 โ 1 2๐
Proof: ๐ฆ1 โง โฏ โง ๐ฆ๐ = 1: Each ๐ฆ๐ must be 1. Clearly, ๐ต ๐ฆ1, โฆ , ๐ฆ๐ = 1 ๐ฆ1 โง โฏ โง ๐ฆ๐ = 0: First, fix some ๐ ๐: subsets of ๐ฆ๐โs that are 0 ๐โฒ: subsets of ๐ฆ๐โs that are 0 and additionally ๐
๐,๐ = 1
Bad event: ๐-th component of outer AND is 1 โ |๐โฒ| is even Each subset of ๐ has same probability of being picked as ๐โฒ Pr |๐โฒ| is odd = Pr |๐โฒ| is even = 1 2 ๐ต ๐ฆ1, โฆ , ๐ฆ๐ = 1 only if bad event happens for each component of outer AND โ Error probability โค 1
2๐
Observation: For every set ๐, #odd subsets = #even subsets (by binary encoding of the 2|๐| subsets)
(๐ฆ๐ = ๐ฆ๐[1], โฆ , ๐ฆ๐[๐] ) (๐ง๐ = ๐ง๐[1], โฆ , ๐ง๐[๐] )
Shape of polynomial ๐:
Define
โInner productโ
Entry ๐, ๐ : Evaluation of ๐๐|๐ฆ๐ Entry ๐, ๐ : Evaluation of ๐๐|๐ง๐
๐
We give an algorithm for the following problem:
๐ท ๐, ๐ = min
๐โ{1,โฆ,๐}(๐ต ๐, ๐ + ๐ถ ๐, ๐ )
Matrix multiplication in min-plus semiring:
๐โ such that ๐ต ๐, ๐โ + ๐ถ ๐โ, ๐ = min
๐โ{1,โฆ,๐}(๐ต ๐, ๐ + ๐ถ ๐, ๐ ) is a witness for ๐, ๐
๐ฅ ๐, ๐ = ๐ต[๐, ๐] ๐ฅ ๐, ๐ = ๐ถ[๐, ๐] (no edge if weight is โ)
1โค๐โค๐(๐ต ๐, ๐ + ๐ถ ๐, ๐ )
+ is entry-wise minimum Identity matrix ๐ฝ: 0 at diagonal, โ otherwise
โ ๐(log ๐) min-plus products for distances, shortest paths through witnesses
1. Set ๐ = 2 log ๐/100 2. Divide problem into
๐ ๐ subproblems
3. Solve each subproblem in time ๐ ๐2poly log ๐ 4. Merge solutions in time ๐ ๐3/๐ Total time: ๐ ๐3 ๐ poly log ๐ = ๐3/2ฮฉ log ๐ 1/2 For every ๐ = 1, โฆ ,
๐ ๐:
(๐ ร ๐ matrix with ๐ ร ๐ matrix) Return: min ๐ท1, โฆ , ๐ท๐/๐ (entry-wise minimum) ๐ต ๐ถ
๐ต1 ๐ต๐/๐ ๐ถ1 ๐ถ๐/๐
๐
๐โ{1,โฆ,๐}
๐โ{1,โฆ,๐} (๐ต ๐, ๐ + ๐ถ ๐, ๐ ) in time ๐ ๐2
For every entry ๐, ๐ of ๐ต: ๐ตโ ๐, ๐ โถ= ๐ต ๐, ๐ โ ๐ + 1 + ๐ For every entry ๐, ๐ of ๐ถ ๐ถโ ๐, ๐ โถ= ๐ถ ๐, ๐ โ ๐ + 1 Fix some pair ๐, ๐ and define ๐โ as smallest ๐โฒ โ {1, โฆ , ๐} such that ๐ต ๐, ๐โฒ + ๐ถ ๐โฒ, ๐ = min
๐โ{1,โฆ,๐} ๐ต ๐, ๐ + ๐ถ ๐, ๐
โ Work with ๐ตโ and ๐ถโ instead of ๐ต and ๐ถ to ensure unique minima Running time: ๐(log ๐) additions per entry (add to itself for ๐(log ๐) times) โ ๐ ๐๐ log ๐
Let ๐ โ ๐โ. We show that ๐ตโ ๐, ๐ + ๐ถโ ๐, ๐ > ๐ตโ ๐, ๐โ + ๐ถโ ๐, ๐
(1) ๐ต ๐, ๐ + ๐ถ ๐, ๐ โ ๐ + 1 + ๐ > ๐ต ๐, ๐โ + ๐ถ ๐โ, ๐ โ ๐ + 1 + ๐โ Case 1: ๐ต ๐, ๐ + ๐ถ ๐, ๐ = ๐ต ๐, ๐โ + ๐ถ ๐, ๐ Then ๐โ < ๐ because ๐โ is smallest index assuming min value (1) follows immediately Case 2: ๐ต ๐, ๐ + ๐ถ ๐, ๐ > ๐ต ๐, ๐โ + ๐ถ ๐, ๐ โ ๐ต ๐, ๐ + ๐ถ ๐, ๐ โฅ ๐ต ๐, ๐โ + ๐ถ ๐, ๐ + 1 (integers!) โ ๐ต ๐, ๐ + ๐ถ ๐, ๐ โ ๐ + 1 + ๐ โฅ ๐ต ๐, ๐โ + ๐ถ ๐โ, ๐ โ ๐ + 1 + ๐ + ๐ + 1 > ๐ต ๐, ๐โ + ๐ถ ๐โ, ๐ โ ๐ + 1 + ๐โ
For every pair ๐, โ sort set ๐๐,โ โ {๐ตโฒ ๐, ๐, โ , ๐ถโฒ ๐, โ , ๐ โฃ ๐ = 1, โฆ , ๐} Breaking ties:
Properties: 1. Entries of ๐ตโฒโฒ and ๐ถโฒโฒ from {1, โฆ , 2๐} 2. Comparisons preserved:
๐ตโฒ ๐, ๐, โ โค ๐ถโฒ ๐, โ , ๐ iff ๐ตโฒโฒ ๐, ๐, โ โค ๐ถโฒโฒ ๐, โ , ๐
3. For every ๐, ๐ there is unique ๐โ such that for all โ: ๐ตโฒโฒ ๐, ๐โ, โ โค ๐ถโฒโฒ ๐โ, โ , ๐
Define matrices ๐ตโฒโฒ and ๐ถโฒโฒ:
= rank(๐ตโฒ ๐, ๐, โ ; ๐๐,โ)
๐, โ , ๐ = rank(๐ถโฒ ๐, โ , ๐ ; ๐๐,โ) (replace each value by rank in ๐๐,โ) โ Every entry needs 1 + log ๐ bits
(no weight dependence!)
Footnote on running time: ๐ตโฒ and ๐ถโฒ do not need to be computed explicitly. No subtractions necessary!
Design circuit ๐ท๐ ๐ตโฒโฒ ๐,โ , ๐ถโฒโฒ[โ, ๐] computing ๐-th bit of unique ๐โ for which ๐ตโฒโฒ ๐, ๐โ, โ โค ๐ถโฒโฒ ๐โ, โ , ๐ for all โ Input: Each bit of ๐-th row of ๐ตโฒโฒ and ๐-th colum of ๐ถโฒโฒ
Goal: For every ๐, ๐, compute ๐โ s.t. โโ: ๐ตโฒโฒ ๐, ๐โ, โ โค ๐ถโฒโฒ ๐โ, โ , ๐ ๐ท๐ ๐ตโฒโฒ ๐,โ , ๐ถโฒโฒ[โ, ๐] =
๐โ 1,โฆ,๐ , ๐th bit of ๐ is 1 โ=1 ๐
๐ตโฒโฒ ๐, ๐, โ โค ๐ถโฒโฒ ๐, โ , ๐
โค ๐ถโฒโฒ ๐โ, โ , ๐ Proof:
(uniqueness of minimum)
1 iff comparison true (to be specified)
๐โ 1,โฆ,๐ , ๐th bit of ๐ is 1 โ=1 ๐
Fixing ๐, ๐, and ๐, we want to replace the following circuit by a polynomial: Apply Razborov-Smolensky with ๐ = 3 + log ๐:
1 2๐ = 1 8๐
1 8๐ = 1 8
(union bound)
โ=1 ๐
๐ตโฒโฒ ๐, ๐, โ โค ๐ถโฒโฒ ๐, โ , ๐
๐ฆ=1 ๐
1 โ
โ=1 ๐
๐
๐ฆ,โ โ ๐๐น๐ ๐,โ ๐ตโฒโฒ ๐,โ , ๐ถโฒโฒ[โ, ๐] โ 1
=: ๐๐น๐ ๐,โ โ ,โ
๐๐น๐ ๐, ๐ =
๐=1 ๐ข
(1 โ ๐๐ โ ๐๐) โจ
๐=1 ๐ข
1 โ ๐๐ โง ๐๐ โง
๐=1 ๐โ1
1 โ ๐๐ โ ๐
๐
= 1 iff ๐ = ๐ = 1 iff
May be replaced by XOR: at most one of inner expressions is true
Apply Razborov/Smolensky with ๐ = 3 + 2 log ๐ + log(๐ข + 1): Additional trick: For every entry ๐ of ๐ตโฒโฒ and every entry ๐ of ๐ถโฒโฒ: Precompute XOR of ๐๐โs and XOR of ๐๐โs: additional time ๐ ๐๐2๐ข๐ โค ๐ ๐2 Introduce new variables for these combinations for later evaluation New form:
๐๐น๐ ๐, ๐ =
๐=1 ๐ข
(1 โ ๐๐ โ ๐๐) โ
๐=1 ๐ข
1 โ ๐๐ โง ๐๐ โง
๐=1 ๐โ1
1 โ ๐๐ โ ๐
๐
๐ข+1 ๐ โค๐ข
"2 โ gates" ๐๐น๐ โฒ ๐, ๐ =
๐ข+1 ๐
("2 โ gates")
at most one ๐๐, at most one ๐๐, at most one constant
Expansion (distributive law): โ polynomial over ๐บ2 with
Error probability: For each application of Raz/Smol: Error prob. โค
1 2๐
By union bound:
๐ข+1 2๐
๐2(๐ข+1) 2๐
โค
๐2 ๐ข+1 23+2 log ๐+log ๐ข+1 = 1 8
๐๐น๐ โฒ ๐, ๐ =
๐ข+1 ๐
("2 โ gates")
Apply distributive law: #monomials bounded by
๐ โค ๐ โ ๐ + 1 ๐
๐ = ๐ โ
๐ + 1 ๐
2+log ๐
Error probability: โค
1 8 + 1 8 = 1 4
๐๐ ๐ตโฒโฒ ๐,โ , ๐ถโฒโฒ[โ, ๐] =
๐=1,โฆ,๐ ๐th bit of ๐ is 1 ๐ฆ=1 ๐
1 โ
โ=1 ๐
๐
๐ฆ,โ โ (๐๐น๐ ๐,โ โฒ
๐ตโฒโฒ ๐,โ , ๐ถโฒโฒ[โ, ๐] โ 1)
XOR with ๐ โค ๐ข + 1 โ 3๐ monomials XOR with โค (๐ + 1)๐ monomials
๐ + 1 ๐
๐ = ๐ โ
๐ + 1 ๐
3+log ๐
= ๐ โ ๐ + 1 โ ๐ข + 1 โ 3๐ 3+log ๐ = ๐ โ ๐ + 1 โ ๐ข + 1 โ 33+2 log ๐+log ๐ข+1
3+log ๐
log ๐ โค log ๐ + 3 + log ๐ log ๐ + 1 + log ๐ข + 1 + 3 + 2 log ๐ + log ๐ข + 1 โ log 3 โค log ๐ + 3 + log ๐ log ๐ + 1 + log ๐ + 1 + 3 + 2 log ๐ + log ๐ + 1 โ 2 โค log ๐ + 3 log ๐ + log ๐ 2 log ๐ + 2 log ๐ + 3 log ๐ + 2 log ๐ + 2 log ๐ โ 2 = log ๐ + 4 log ๐ 4 log ๐ + 7 log ๐ โ 2 = log ๐ + 76 log2 ๐ โค 100 log2 ๐ = 100 log ๐ 100
2
โค 0.1 log ๐ ๐ โฅ ๐ข
๐ = 2 log ๐/100 ๐ = 3 + log ๐ ๐ = 3 + 2 log ๐ + log(๐ข + 1)
For every ๐ โ 1, โฆ , log ๐ : Generate probabilistic polynomial ๐๐ with the following properties
๐ is XOR of ๐ โค ๐0.1 monomials
๐ can partitioned into two subsets ๐ and ๐
๐โ{1,โฆ,๐}
(๐ตโฒโฒ ๐, ๐, โ โค ๐ถโฒโฒ ๐, โ , ๐ ) with probability โฅ
3 4
โ (Fast Evaluation Lemma): Can evaluate ๐๐ for all ๐2 pairs ๐, ๐ in time ๐(๐2poly log ๐ ) Result matrix ๐๐ with entries ๐๐ ๐, ๐
For all pairs ๐, ๐ and every ๐ โ 1, โฆ , log ๐ : ๐๐ ๐, ๐ = ๐ท๐ ๐ตโฒโฒ ๐,โ , ๐ถโฒโฒ โ, ๐ with probability โฅ
3 4
Repeat evaluation with ๐ = 18 log ๐ different random polynomials Define ๐
๐[๐, ๐] as majority output of all ๐ evaluations
Fix pair ๐, ๐ and ๐ โ 1, โฆ , log ๐
๐: Random variable counting how often ๐๐[๐, ๐] and ๐ท๐(๐, ๐ ) agree over all ๐ trials Pr ๐
๐ ๐, ๐ โ ๐ท๐(๐, ๐) โค Pr ๐ < ๐
2 ๐น ๐ โฅ 3 โ ๐ 4
โฆstill ๐(๐2poly log ๐ )
Bound error probability using tail bound:
Pr ๐๐ ๐, ๐ โ ๐ท(๐, ๐, ๐) โค Pr ๐ < ๐ 2 โค Pr ๐ < 4 6 E ๐ = Pr ๐ < 1 โ 1 3 E ๐ โค ๐
โ 2 3
2
E ๐ 2 = ๐ โ4E ๐ 18 โค ๐ โ3๐ 18 = ๐โ3 log ๐ โค 2โ4 log ๐ = ๐โ4
Majority needs to be correct for all ๐2 pairs ๐, ๐ and log ๐ bit positions ๐ in all
๐ ๐ instances of the algorithm:
Union bound: Pr โ๐, ๐, ๐: ๐๐ ๐, ๐ โ ๐ท๐ ๐, ๐ in some instance โค ๐3 log ๐ ๐ โ ๐โ4 โค 1 ๐
Chernoff: Pr ๐ < 1 โ ๐ ๐น[๐] โค ๐โ๐2๐น[๐]/2