Truly Subcubic Algorithms for Language Edit Distance and RNA Folding via Fast Bounded-Difference Min-Plus Product Karl Bringmann , Fabrizio Grandoni, Barna Saha, Virginia Vassilevska Williams June 11, 2017
Bounded Differences (BD) Matrices Integer matrix π has BD if for all π, π : 2 2 3 2 π π, π β π[π, π + 1] β€ 1 1 1 2 3 and 2 1 2 3 π π, π β π[π + 1, π] β€ 1 1 0 1 2 More generally: πΏ -BD when differences are at most π
οΏ½ οΏ½ (min,+) Product For πΓπ -matrices π΅, πΆ , their (min,+) product π· = π΅ β πΆ is defined by π· π, π = min 7 π΅ π, π + πΆ[π, π] (min,+) product is equivalent to All Pairs Shortest Paths [Fischer,Meyerβ71] trivial algorithm: π(π ; ) best known algorithm: π ; /2 ?( @AB C ) [Williamsβ14] π· π, π = E π΅ π, π β πΆ[π, π] Standard matrix multiplication: 7 time π(π G ) where π β€ 2.373
οΏ½ (min,+) Product For πΓπ -matrices π΅, πΆ , their (min,+) product π· = π΅ β πΆ is defined by π· π, π = min 7 π΅ π, π + πΆ[π, π] (min,+) product is equivalent to All Pairs Shortest Paths [Fischer,Meyerβ71] trivial algorithm: π(π ; ) best known algorithm: π ; /2 ?( @AB C ) [Williamsβ14] Big Open Problem: Is (min,+) product in time π·(π πOπ» ) for some π» > π ? Study special cases!
οΏ½ (min,+) Product for Structured Matrices Matrices with small entries: [Alon,Galil,Margalitβ97] If π΅, πΆ have entries in βπ, β¦ , π βͺ β i(ππ G ) then π΅ β πΆ can be computed in time π Sketch: π΅ S π, π = π¦ U[V,W] π· π, π = min 7 π΅ π, π + πΆ[π, π] π·β² π, π = E π΅ S π, π β πΆ S [π, π] 7 π· π, π = degree of highest monomial in π· S [π, π]
(min,+) Product for Structured Matrices Matrices with small entries: [Alon,Galil,Margalitβ97] If π΅, πΆ have entries in βπ, β¦ , π βͺ β i(ππ G ) then π΅ β πΆ can be computed in time π Matrices with few distinct entries: [Yusterβ09] If each row of π΅ has a small number of distinct entries, then for arbitrary πΆ we can compute π΅ β πΆ in truly subcubic time Question: Is (min,+) product in time π·(π πOπ» ) for BD matrices? Why care about BD matrices?
1 st Application: Language Edit Distance (LED) for simplicity: |π»| = π(1) CFG Parsing: Given a context-free grammar π» and a string π‘ of length π , is π‘ in π(π») ? i(π G ) ... is in time π [L. Valiantβ75] Language Edit Distance: βerror-correcting CFG parsingβ Given a CFG π» and a string π‘ , compute minimum edit distance of π‘ to any string in π(π») insertions, deletions, substitutions ... is in time π(π ; ) [Aho,Petersonβ72] We show using Valiantβs approach: If (min,+) product on BD matrices is in time π(π n ) , ~8 page proof i(π n ) then LED is in time π intuitive reason for BD: LED( π‘ ) and LED( π‘π ) differ by β€ 1 for any symbol π
2 nd Application: RNA Folding RNA can be seen as a sequence of symbols from {A,C,G,U} Biologists want to predict the secondary structure of RNA: A can pair with U, and C can pair with G Given an RNA sequence, find the largest set of matching pairs, such that no two pairs intersect AUUGCAG not allowed but AUUGCAG is okay ... is in time π(π ; ) [Nussinov,Jacobsonβ80] Disclaimer: No author of ... can be cast as a LED problem (without substitutions) this paper is a biologist. If (min,+) product on BD matrices is in time π(π n ) , i(π n ) then RNA Folding is in time π
3 rd Application: Optimal Stack Generation for simplicity: |Ξ£| = π(1) Optimal Stack Generation: Given a string π‘ over alphabet Ξ£ , determine the shortest sequence of stack operations push(.), emit, pop s.t. performing these operations starting from an empty stack will emit π‘ and end with an empty stack a a π‘ = bab b b b b b b push(b) emit push(a) emit pop emit pop b a b ... is in time π(π ; ) (dynamic programming) [Tarjanβ05] If (min,+) product on O(1)-BD matrices is in time π(π n ) , We show: i(π n ) then Optimal Stack Generation is in time π intuitive reason for BD: OSG( π‘ ) and OSG( π‘π ) differ by β€ 3 for any π β Ξ£
Main Result ... so we have seen that (min,+) product of BD matrices is well motivated Main Result: We can compute the (min,+) product of BD matrices in randomized time π(π v.y; ) and deterministic time π(π v.yz ) here: π·(π π.π ) Generalization: For πΏ -BD matrix π΅ with π βͺ π ;OG β π t.uvu and arbitrary πΆ we can compute their (min,+) product in randomized truly subcubic time
Algorithm Sketch Input: BD matrices π΅, πΆ . Want: π· π, π = min 7 π΅ π, π + πΆ[π, π] 1) Compute approximation πΈ π, π = π· π, π Β± π π t.v time π(π v.u ) compute π· π, π exactly for all π, π that are multiples of π t.v set πΈ π, π to some π·[πβ, πβ] by rounding π, π If π΅, πΆ are BD, then their (π S , π S ) (min,+) product is also BD (π, π) π t.v
Algorithm Sketch Input: BD matrices π΅, πΆ . Want: π· π, π = min 7 π΅ π, π + πΆ[π, π] 1) Compute approximation πΈ π, π = π· π, π Β± π π t.v β€ π π t.v π΅ π, π + πΆ π, π = π· π, π implies π΅ π, π + πΆ π, π β πΈ π, π call these triples (π, π, π) relevant then π· π, π = 7:(V,7,W) β’β¬@β¬β’βΖβ π΅ π, π + πΆ[π, π] min
Algorithm Sketch (π, π, π) relevant: |π΅ π, π + πΆ π, π β πΈ π, π | β€ π π t.v Input: BD matrices π΅, πΆ . Want: π· π, π = min 7 π΅ π, π + πΆ[π, π] 1) Compute approximation πΈ π, π = π· π, π Β± π π t.v 2) Cover most relevant triples: fix π β , π β , and define matrices π΅ β , πΆ β π΅ β π, π β π΅ π, π + πΆ π, π β β πΈ π, π β β π΅ π β , π + πΆ π, π β β πΈ π β , π β πΆ β π, π β π΅ π β , π + πΆ π, π β πΈ π β , π (min,+) product π· β of π΅ β , πΆ β : = π· π, π β πΈ π, π β + πΈ π β , π β β πΈ π β , π π· β π, π = min 7 π΅ β π, π + πΆ β π, π can be cancelled afterwards
Algorithm Sketch (π, π, π) relevant: |π΅ π, π + πΆ π, π β πΈ π, π | β€ π π t.v Input: BD matrices π΅, πΆ . Want: π· π, π = min 7 π΅ π, π + πΆ[π, π] 1) Compute approximation πΈ π, π = π· π, π Β± π π t.v 2) Cover most relevant triples: fix π β , π β , and define matrices π΅ β , πΆ β π΅ β π, π β π΅ π, π + πΆ π, π β β πΈ π, π β β π΅ π β , π + πΆ π, π β β πΈ π β , π β πΆ β π, π β π΅ π β , π + πΆ π, π β πΈ π β , π if π, π, π β , π β , π, π β , π β , π, π are all relevant, then π΅ β π, π , πΆ β π, π = π π t.v set all π»(π t.v ) -entries of π΅ β , πΆ β to β then (min,+) product of π΅ β and πΆ β can be computed in time π i(π Gβ‘t.v ) (π, π, π) is βcoveredβ if π΅ β π, π and πΆ β π, π are π(π t.v ) , i.e., not set to β
Algorithm Sketch (π, π, π) relevant: |π΅ π, π + πΆ π, π β πΈ π, π | β€ π π t.v Input: BD matrices π΅, πΆ . Want: π· π, π = min 7 π΅ π, π + πΆ[π, π] (π, π, π) is βcoveredβ 1) Compute approximation πΈ π, π = π· π, π Β± π π t.v if π΅ β π, π and πΆ β π, π are π(π t.v ) 2) Cover most relevant triples: in some round Λ π, π β β initialize π· repeat for π(π t.; log π) rounds: i(π t.; ) iterations π pick π β , π β randomly π΅ β π, π β π΅ π, π + πΆ π, π β β πΈ π, π β β π΅ π β , π + πΆ π, π β β πΈ π β , π β πΆ β π, π β π΅ π β , π + πΆ π, π β πΈ π β , π set all π»(π t.v ) -entries of π΅ β , πΆ β to β time π π Gβ‘t.v = π(π v.u ) compute (min,+) product π· β = π΅ β β πΆ β Λ π, π , π· β π, π + πΈ π, π β β πΈ π β , π β + πΈ π β , π Λ π, π β min π· π· Lem: After π(π β° log π) rounds there are π(π ;Oβ°/; + π v.Ε ) total time = π π v.βΉ i π v.βΉ uncovered relevant triples w.h.p. π
Algorithm Sketch (π, π, π) relevant: |π΅ π, π + πΆ π, π β πΈ π, π | β€ π π t.v Input: BD matrices π΅, πΆ . Want: π· π, π = min 7 π΅ π, π + πΆ[π, π] (π, π, π) is βcoveredβ 1) Compute approximation πΈ π, π = π· π, π Β± π π t.v if π΅ β π, π and πΆ β π, π are π(π t.v ) 2) Cover most relevant triples in some round 3) Enumerate uncovered relevant triples: βfor each uncovered relevant (π, π, π) :β Λ π, π β min π· Λ π, π , π΅ π, π + πΆ[π, π] π· Λ is correct output now π·
Recommend
More recommend