Complexity Theory of Polynomial-Time Problems
Sebastian Krinninger
Complexity Theory of Polynomial-Time Problems Lecture 7: 3SUM II - - PowerPoint PPT Presentation
Complexity Theory of Polynomial-Time Problems Lecture 7: 3SUM II Sebastian Krinninger Reminder: 3SUM given sets , , of integers are there , , such that + + = 0 ?
Sebastian Krinninger
June 16, 2016 2/19
given sets ๐ต, ๐ถ, ๐ท of ๐ integers are there ๐ โ ๐ต, ๐ โ ๐ถ, ๐ โ ๐ท such that ๐ + ๐ + ๐ = 0? well-known: ๐(๐2) Conjecture: no ๐ ๐2โ๐ algorithm โ 3SUM-Hardness Alternative algorithm: ๐( ๐ต โ ๐ถ + |๐ท|) (store negated pairwise sums in hashmap)
June 16, 2016 3/19
Hash function โ: ๐ โ [๐]
Goal: Distribute uniformly, avoid collisions, etc.
June 16, 2016 4/19
Uniform difference: Pr โ ๐ฆ โ โ(๐ง) = ๐ = 1/๐ Balanced: ๐ฆ โ ๐ โถ โ ๐ฆ = ๐ โค 3๐/๐ Linear: โ ๐ฆ + โ ๐ง = โ ๐ฆ + ๐ง (mod ๐) (for any set ๐ = ๐ฆ1, โฆ , ๐ฆ๐ โ ๐ and any ๐ โ ๐ ) Desired properties for family of hash functions from ๐ โ ๐ (i.e., for every โ chosen from family) (for any ๐ฆ, ๐ง โ ๐ ) (for any ๐ฆ, ๐ง โ ๐ s.t. ๐ฆ โ ๐ง and ๐ โ ๐ )
June 16, 2016 5/19
June 16, 2016 6/19
Uniform difference: Pr โ ๐ฆ โ โ(๐ง) = ๐ = 1/๐ Almost balanced: Expected number of elements from S hashed to heavy values is ๐(๐), where value ๐ โ ๐ is heavy if ๐ฆ โ ๐ โถ โ ๐ฆ = ๐ > 3๐/๐ Almost linear: โ ๐ฆ + โ ๐ง โ โ ๐ฆ + ๐ง + ๐โ + 0,1 (mod ๐) (for any set ๐ = ๐ฆ1, โฆ , ๐ฆ๐ โ ๐ and any ๐ โ ๐ ) Desired properties for family of hash functions from ๐ โ ๐ (i.e., for every โ chosen from family) (for any ๐ฆ, ๐ง โ ๐ and some integer ๐โ depending only on โ) (for any ๐ฆ, ๐ง โ ๐ s.t. ๐ฆ โ ๐ง and ๐ โ ๐ )
June 16, 2016 7/19
Rest of this lecture: โ picked randomly from this family โ๐,๐,๐ = โ๐,๐: ๐ โ ๐ โฃ ๐ โ ๐ odd integer and ๐ โ ๐ โ๐,๐ ๐ฆ = ๐๐ฆ + ๐ mod ๐ div ๐ /๐ Thm: Family โ๐,๐,๐ is has the uniform difference property, is almost balanced and almost linear with ๐โ๐,๐ = (๐ โ 1 mod ๐ ) div ๐ /๐ . Set ๐ = ๐๐ for some ๐ โฅ ๐/2 and ๐, ๐, ๐ powers of 2 (Pairwise independence [Dietzfelbinger โ96] implies uniform difference (easy to check) and almost balanced [Baran et al. โ08]. Almost linear: easy to check.)
June 16, 2016 8/19
Lem: If 3SUM on universe of size ๐(๐3) solvable in exp. time ๐(๐2โ๐), then 3SUM on arbitrary universe solvable in expect. time ๐(๐2โ๐). Algorithm: Repeat until output:
โ ๐ ๐ โ ๐ต , ๐ถโฒ = {โ ๐ โฃ ๐ โ ๐ถ}, ๐ทโฒ = โ ๐ + ๐โ ๐ โ ๐ท
โ ๐ ๐ โ ๐ต , ๐ถโฒโฒ = {โ ๐ โฃ ๐ โ ๐ถ}, ๐ทโฒโฒ = โ ๐ + ๐โ + 1 ๐ โ ๐ท
๐ฆ, ๐ง, ๐จ
No false negatives: If ๐ฆ + ๐ง = ๐จ, then โ ๐ฆ + โ ๐ง โ โ ๐จ + ๐โ + 0,1
Follows from [Baran et al. โ08]
June 16, 2016 9/19
Number of iterations: Triple ๐ฆ, ๐ง, ๐จ gives false positive if ๐ฆ + ๐ง โ ๐จ and one of โ ๐ฆ + โ ๐ง = โ ๐จ + ๐โ or โ ๐ฆ + โ ๐ง = โ ๐จ + ๐โ + 1 Linearity: โ ๐ฆ + โ ๐ง = โ ๐ฆ + ๐ง + ๐โ or โ ๐ฆ + โ ๐ง = โ ๐ฆ + ๐ง + ๐โ + 1 Thus, probability that fixed ๐ฆ, ๐ง, ๐จ (with ๐ฆ + ๐ง โ ๐จ) gives false positive is: Pr โ ๐ฆ + ๐ง โ โ ๐จ โ {โ1,0,1} โค
3 6๐3 = 1 2๐3
(uniform difference) Overall probability of false positive: โค ๐3 โ
1 2๐3 = 1 2
In expectation: 2 iterations until no false positive (waiting time bound) (If no false positive, then algorithm certainly stops) We need to bound:
Then: number of calls to 3SUM algorithm: ๐(1)
June 16, 2016 10/19
Number of candidate witnesses: Fix 3SUM witness ๐ฆโฒ, ๐งโฒ, ๐จโฒ of instance (๐ตโฒ, ๐ถโฒ, ๐ทโฒ) Let ๐ฆโ โ โโ1 ๐ฆโฒ For every ๐ฆ โ ๐ฆโ: Pr โ ๐ฆ = โ ๐ฆโ =
1 6๐3
(uniform difference) ๐น โโ1 ๐ฆโฒ โค 1 +
๐ 4๐3 โค 2
Similarly: ๐น โโ1 ๐งโฒ โค 2, ๐น โโ1 ๐จโฒ โค 2 ๐น โโ1 ๐ฆโฒ โช โโ1 ๐งโฒ โช โโ1 ๐จโฒ โค ๐(1) (linearity of expectation) In expectation, algorithm manually checks constant number of candidate witnesses per iteration We need to bound:
Then: number of calls to 3SUM algorithm: ๐(1)
June 16, 2016 11/19
Given array ๐ต 1 โฆ ๐ of integers are there ๐, ๐ such that ๐ต ๐ + ๐ต ๐ = ๐ต[๐ + ๐]? trivial algorithm: ๐(๐2) Thm: There is no ๐(๐2โ๐) algorithm for Convolution 3SUM unless the 3SUM Conjecture fails.
๐ ๐ฆ ๐ง ๐ฆ + ๐ง ๐ ๐ + ๐ [Pฤtraศcu 2010]
Stepping stone towards hardness of other โstructuredโ problems
June 16, 2016 12/19
Given set ๐ โ [๐] of integers are there ๐ฆ, ๐ง, ๐จ โ ๐ such that ๐ฆ + ๐ง = ๐จ? Preprocessing: Check if there is a solution 2๐ฆ = ๐จ ๐ ๐ log ๐ Pick random hash function โ: ๐ โ ๐ (almost linear, etc.) 1 2 ๐ โฏ In expectation: ๐ ๐ elements in buckets with load > 3๐/๐ (almost bal.) For each such ๐ฆ: check for 3SUM triple involving ๐ฆ ๐ ๐๐ (in exp.) 1 3๐/๐ โฎ For this proof: assume โ is almost balanced and linear (magicallyโฆ)
June 16, 2016 13/19
1 ๐ข ๐ โฏ
๐ ๐ ๐
Number elements in each bucket from 0 to
3๐ ๐ โ 1
Iterate over all triples ๐, ๐, ๐ โ 3๐/๐ โฏ โฏ โฏ For every bucket ๐ข:
Set all other array entries to โ (sufficiently large number)
3๐ ๐ 3
instances of Convolution 3SUM
Assume ๐ฆ + ๐ง = ๐จ Then โ ๐ฆ + โ ๐ง = โ ๐จ (mod ๐) (linearity) Duplicate array for Convolution 3SUM instance If ๐ฆ = ๐ง, triple found in preprocessing If ๐ฆ, ๐ง, or ๐จ hashed to heavy bucket: triple found in second step Either โ ๐ฆ + โ ๐ง = โ ๐จ or โ ๐ฆ + โ ๐ง = โ ๐จ + ๐ Observation: ๐ต ๐ + ๐ต ๐ = ๐ต ๐ + ๐ only if ๐ = 8๐ข1 + 1 and ๐ = 8๐ข2 + 3 ๐ต 8โ ๐ฆ + 1 + ๐ต 8โ ๐ง + 3 = ๐ต 8โ ๐จ + 4 or ๐ต 8โ ๐ฆ + 1 + ๐ต 8โ ๐ง + 3 = ๐ต 8(โ ๐จ + ๐) + 4 Thus, no false negatives. Also no false positives: (๐ฆ + ๐ง = ๐จ mod 8 has unique solution over 1,3,4 and ๐ต ๐ โ ๐ต[๐])
Assumption: Convolution 3SUM in time ๐(๐2โ๐) Total expected running time: ๐ ๐ log ๐ + ๐๐ +
๐ ๐ 3
๐2โ๐ Set ๐ = ๐1โ๐/4 Total time: ๐ ๐2โ๐/4 Contradicts 3SUM Conjecture
Repeated queries (Static) data structure Goal: Lower bound on preprocessing and query time Queries not known in advance Offline Set Disjointness: ๐ queries known in advance (part of input)
Thm: Let ๐ ๐ be such that 3SUM requires expected time ฮฉ ๐2/๐(๐) . For any constant 0 โค ๐ฟ < 1, let ALG be an algorithm for offline Set Disjointness where ๐ = โฌ = ฮ(๐ log ๐), ๐ = ฮ ๐2โ2๐ฟ , each set in ๐ โช โฌ has at most ๐(๐1โ๐ฟ) elements from ๐, and ๐ = ฮ ๐1+๐ฟ log ๐ . Then ALG requires expected time ฮฉ ๐2/๐(๐) . Cor: Assuming the 3SUM conjecture, for any 0 < ๐ฟ < 1, any data structure for Set Disjointness has ๐ข๐ + ๐
1+๐ฟ 2โ๐ฟ๐ข๐ = ฮฉ ๐ 2 2โ๐ฟโ๐(1)
where ๐ is the sum of the set sizes, ๐ข๐ is the preprocessing time, and ๐ข๐ is the time per query. Example: Data structures with constant query time Make ๐ฟ tend to 1, need ๐ข๐ = ฮฉ ๐2โ๐(1) Evidence that trivial preprocessing algorithm is optimal (for constant query) (From Thm: ๐ = ฮ ๐2โ๐ฟ log ๐ )
In the following proof we use a balanced, linear hash function with uniform difference property. (magicallyโฆ) This can be modified for almost balanced, almost linear hash function with uniform difference property. Given set ๐ โ [๐] of integers are there ๐ฆ, ๐ง, ๐จ โ ๐ such that ๐ฆ โ ๐ง = ๐จ?
June 16, 2016 19/19
higher order bits lower order bits
June 16, 2016 20/19
Set ๐ = ๐๐ฟ, ๐ =
5๐ ๐ 2
Pick random hash functions โ: ๐ โ [๐] and ๐๐: ๐ โ [๐ ] for ๐ = 1 to 10 log ๐ Initialize buckets ๐ถ 1 , โฆ , ๐ถ[๐] s.t. ๐ถ ๐ = {๐ฆ โถ โ ๐ฆ = ๐} For all ๐ โ ๐ , ๐ โ ๐ , initialize buckets ๐ถ๐
โ ๐, ๐ and ๐ถ๐ โ[๐, ๐] s.t.
๐ถ๐
โ ๐, ๐ = ๐๐ ๐ฆ + ๐ โ
๐ mod ๐ โฃ ๐ฆ โ ๐ถ ๐ ๐ถ๐
โ ๐, ๐ = ๐๐ ๐ฆ โ ๐ (mod ๐ ) โฃ ๐ฆ โ ๐ถ ๐
Initialize ๐ set intersection problems with ๐ถ๐
โ ๐, ๐ โs and ๐ถ๐ โ[๐, ๐]โs
For every ๐จ โ ๐ and every ๐ = 1 to ๐ Check if ๐ถ๐
โ ๐, ๐๐ โ(๐จ) and ๐ถ๐ โ ๐ โ โ ๐จ
(mod ๐), ๐๐
โ(๐จ) intersect
If intersection for all ๐: Search for ๐ฆ โ ๐ถ ๐ and ๐ง โ ๐ถ[๐ โ โ ๐จ (mod ๐)] s.t. ๐ฆ โ ๐ง = ๐จ and output it if found If nothing found: output โno 3SUMโ
๐๐
โ ๐จ : higher order bits of ๐๐(๐จ)
๐๐
โ ๐จ : higher order bits of ๐๐(๐จ)
June 16, 2016 21/19
Algorithm verifies every triple before stopping Need to show: if ๐ฆ โ ๐ง = ๐จ, then algorithm finds it Claim 1: If ๐ฆ โ ๐ง = ๐จ, then ๐ถ ๐ โฉ (๐ถ ๐ + ๐จ) โ โ where ๐ = โ ๐ฆ , ๐ = ๐ โ โ ๐จ mod ๐ Linear hash function: โ ๐ฆ โ โ ๐ง = โ ๐ฆ โ ๐ง = โ ๐จ mod ๐ Thus: ๐ = โ ๐ฆ โ โ ๐จ = ๐ โ โ ๐จ mod ๐ ๐ง โ ๐ถ ๐ โ ๐ฆ = ๐ง + ๐จ โ ๐ถ ๐ + ๐จ
June 16, 2016 22/19
Claim 2: If ๐ถ ๐ โฉ ๐ถ ๐ + ๐จ โ โ , then ๐ถโ ๐, ๐๐
โ(๐จ) โฉ ๐ถโ ๐, ๐๐ โ ๐จ
โ โ โ๐. ๐ถ ๐ โฉ ๐ถ ๐ + ๐จ โ โ โ ๐๐ ๐ถ ๐ โฉ ๐๐ ๐ถ ๐ + ๐จ โ โ โ ๐๐ ๐ถ ๐ โฉ ๐๐ ๐ถ ๐ + ๐๐ ๐จ โ โ โ ๐๐ ๐ถ ๐ โฉ ๐๐ ๐ถ ๐ + ๐๐
โ ๐จ + ๐๐ โ ๐จ
โ โ โ ๐๐ ๐ถ ๐ โ ๐๐
โ ๐จ
โฉ ๐๐ ๐ถ ๐ + ๐๐
โ ๐จ
โ โ โ ๐ถโ ๐, ๐๐
โ(๐จ) โฉ ๐ถโ ๐, ๐๐ โ ๐จ
โ โ Claim 1: If ๐ฆ โ ๐ง = ๐จ, then ๐ถ ๐ โฉ (๐ถ ๐ + ๐จ) โ โ where ๐ = โ ๐ฆ , ๐ = ๐ โ โ ๐จ mod ๐ Conclusion: If ๐ฆ โ ๐ง = ๐จ, then ๐ถโ ๐, ๐๐
โ(๐จ) โฉ ๐ถโ ๐, ๐๐ โ ๐จ
โ โ โ๐.
June 16, 2016 23/19
Set intersection instance:
๐ = ๐ ๐1โ๐ฟ
Finding witnesses:
โ ๐, ๐๐ โ(๐จ) and ๐ถ๐ โ ๐, ๐๐ โ(๐จ) intersect, try to find ๐ฆ โ ๐ถ ๐ , ๐ง โ ๐ถ[๐]
s.t. ๐ฆ โ ๐ง = ๐จ
๐ ๐ per witness check
๐ ๐ + #false positives ๐ ๐ = ๐ ๐ ๐
June 16, 2016 24/19
For a fixed ๐จ and any pair ๐ฆ, ๐ง โ ๐ s.t. ๐ฆ โ ๐ง โ ๐จ: Pr ๐๐ ๐ฆ = ๐๐ ๐ง + ๐๐(๐จ) = Pr ๐๐ ๐ฆ โ ๐ง = ๐๐(๐จ) = 1 ๐ (linear and uniform difference) Remember: Every bucket has size โค
3๐ ๐
(balanced)
Pr ๐๐ ๐ถ[๐] = ๐๐ ๐ถ[๐] + ๐๐(๐จ) โค 3๐ ๐
2 1
๐ = 9 25
โค 1 ๐๐ In expectation: total number of false positives is a constant.