Encontrar testigos en la suma de enteros minkowski

16

Sean AA y BB subconjuntos de { 0 , ... , n }{0,,n} . Estamos interesados ​​en encontrar la suma de Minkowski A + B = { a + b | a A , b B }  A+B={a+b | aA,bB} .

χ X : { 0 , , 2 n } { 0 , 1 }χX:{0,,2n}{0,1} es una función característica de XX si χ X ( x ) = { 1  si  x X 0 de lo  contrario

χX(x)={1 if xX0 otherwise

Sea ff la convolución discreta de χ AχA y χ BχB , luego x A + BxA+B si y solo si f ( x ) > 0f(x)>0 . Por lo tanto, A + BA+B se puede calcular en tiempo O ( n log n )O(nlogn) por convolución discreta a través de FFT.

A veces es importante averiguar el par real a AaA y b BbB que suma a xx . a AaA se llama testigo de xx , si existe b BbB tal que a + b = xa+b=x . Una función w : A + B Aw:A+BA se llama función testigo si w ( x )w(x) es testigo de xx .

¿Es posible calcular una función testigo en el tiempo O ( n log n ) ?O(nlogn)

Chao Xu
fuente
3
O ( n p o l y l o g n ) no es especialmente difícil. O(npolylogn)
Sariel Har-Peled
2
Puedes usar la búsqueda binaria. por ejemplo, dividir A en dos conjuntos de tamaños aproximadamente iguales A L , A R y calcular A L + B y A R + B ; compruebe en cuál de esos x está; y recurse. Esto te dará algo como O ( n lg 2 n ) . AAL,ARAL+BAR+BxO(nlg2n)
DW
@DW Esto sólo se puede encontrar un testigo para un solo x , pero queremos un testigo para cada elemento de A + B . (mi redacción parece no estar clara, así que acabo de actualizar la pregunta)xA+B
Chao Xu
Pero, ¿está interesado en la solución O (n polylog n)?
Sariel Har-Peled
@ SarielHar-Peled sí, también estoy interesado en el algoritmo determinista O ( n p o l y l o g n ) . O(npolylogn)
Chao Xu

Respuestas:

11

Aquí estoy explicando cómo obtener el tiempo de ejecución aleatorio O ( n p o l y l o g n ) . Necesitamos una secuencia de observaciones:O(npolylogn)

  1. Un testigo de un valor v es un par de números ( a , b ) A × B tal que a + b = v . Deje que P A ( x ) = i A x i y P B ( x ) se definan de manera análoga. Observe que el coeficiente de x v en P A ( x ) P B ( xv(a,b)A×Ba+b=vPA(x)=iAxiPB(x)xv) es el número de testigos que hay para el valor v .PA(x)PB(x)v

  2. Assume vv has a single witness (a,b)A×B(a,b)A×B, and consider the the polynomial QA(x)=iAixiQA(x)=iAixi. Clearly, the coefficient of xvxv in QA(x)PB(x)QA(x)PB(x) is aa, and as such we now know the pair (a,va)(a,va) and we are done.

  3. Entonces, hemos terminado con el caso de que hay un solo testigo. Así que considere el caso de que v tiene k testigos ( a 1 , b 1 ) , ... , ( a k , b k ) . Sea i ( k ) = lg vk(a1,b1),,(ak,bk)k. Observe que2i(k)-1i(k)=lgkk2 i ( k ) . Luego, dejemos queRj=(Aj,Bj), paraj=1,...,m, param=O(logn)sean muestras aleatorias, de modo que cada elemento deAse elija en Aicon probabilidadp=1/2 i ( k ) . La probabilidad de quev2i(k)1k2i(k)Rj=(Aj,Bj)j=1,,mm=O(logn)AAip=1/2i(k)v has a single witness in RjRj is α=(k1)p2(1p2)k1α=(k1)p2(1p2)k1, since the witness are disjoint pairs of numbers (since the sum of each pair is vv). It is easy to verify that αα is a constant in (0,1)(0,1) independent of the value of kk. As such, it must be, with high probability, that vv has a single witness in one of the samples R1,,RmR1,,Rm. As such, by computing the two polynomials associated with with such sample, as described above, in O(nlogn)O(nlogn) time (per sample), using FFT, we can decide this in constant time.

  4. We are almost done. Compute the above random samples for resolutions i=1,,lgni=1,,lgn. For each such resolution compute the random samples and associated polynomials. Also, compute the associated polynomial for AA and BB. This preprocessing naively takes O(nlog3n)O(nlog3n), but I suspect that being slightly more careful a lognlogn factor should be removable.

  5. The algorithm: For every value vv, compute how many witness, say k, it has in constant time, by consulting the polynomial QA(x)PB(x)QA(x)PB(x). Next, go to the relevant data-structure for i(k)i(k). Then, it finds the random sample that has it as a single witness, and it extract the pair that is this witness in constant time.

  6. Strangely enough, the preprocessing time is O(nlog3n)O(nlog3n), but the expected time to find the witness themselves take only O(n)O(n) time, since one can stop the search as soon as one find a witness. This suggests that this algorithm should be improveable. In particular, for i(k)lgni(k)lgn, the polynomials generated are very sparse, and one should be able to do much faster FFT.

Sariel Har-Peled
fuente
12

Ok, I've been holding off since really Sariel should get credit for an answer, but I'm tired of waiting, so here is my cut at a near-linear randomized algorithm.

  • By choosing samples of n(1ϵ)in(1ϵ)i points, i=0,1,i=0,1,, you can get a logarithmic number of subproblems such that each sum from the original problem has constant probability of being represented uniquely in one of the subproblems (the one where the sampling cuts down the expected number of representations to near 1).
  • By repeating the sampling process a logarithmic number of times you can get all sums to have unique representations with high probability.
  • If you have a partition of AA and BB into two subsets, then by multiplying the numbers by four, adding 2 to the numbers in one of the subsets in AA, and adding 1 to the numbers in one of the subsets in BB, you can read off from the mod-4 values of the achievable sums which of the two subsets their summands come from.
  • By repeating the partition process a logarithmic number of times, using each bit position of the binary representations of the values or indices in the subproblems to select the partitions in each step, you can uniquely identify the summands of every uniquely-represented sum.

This blows up the running time by three logarithmic factors; probably that can be reduced.

David Eppstein
fuente
3
Ha ha ;). I was in the middle of writing it, and then went to lunch...
Sariel Har-Peled
5

This answer gives a determinstic O(n polylogn)O(n polylogn) algorithm.

It appears that Sariel and David's algorithm can be derandomized through an approach similar to this paper. [2] While going through the process I found there is a more general problem that implies this result.

The kk-reconstruction problem

There are hidden sets S1,,Sn{1,,m}S1,,Sn{1,,m}, we have two oracles SizeSize and SumSum that take a query set QQ.

  1. Size(Q)Size(Q) returns (|S1Q|,|S2Q|,,|SnQ|)(|S1Q|,|S2Q|,,|SnQ|), the size of each intersection.
  2. Sum(Q)Sum(Q) returns (sS1Qs,sS2Qs,,sSnQs)(sS1Qs,sS2Qs,,sSnQs), the sum of elements in each intersection.

The kk-reconstruction problem asks one to find nn subsets S1,,Sn such that SiSi and |Si|=min(k,|Si|) for all i.

Let f be the running time of calling the oracles, and assume f=Ω(m+n), then one can find the sets in deterministic O(fklogn polylog(m)) time. [1]

Now we can reduce the finding witness problem to 1-reconstruction problem. Here S1,,S2n{1,,2n} where Si={a|a+b=i,aA,bB}.

Define the polynomials χQ(x)=iQxi, IQ(x)=iQixi

The coefficient for xi in χQχB(x) is |SiQ| and in IQχB(x) is sSiQs. Hence the oracles take O(nlogn) time per call.

This gives us an O(n polylog(n)) time deterministic algorithm.

[1] Yonatan Aumann, Moshe Lewenstein, Noa Lewenstein, Dekel Tsur: Finding witnesses by peeling. ACM Transactions on Algorithms 7(2): 24 (2011)

[2] Noga Alon, Moni Naor: Derandomization, witnesses for Boolean matrix multiplication and construction of perfect hash functions. Algorithmica 16(4-5) (1996)

Chao Xu
fuente