Representative sets for multisets Ariel Gabizon∗
Daniel Lokshtanov
Michal Pilipczuk
arXiv:1411.6756v3 [cs.DS] 27 Nov 2014
December 1, 2014
Abstract The notion of a q-representative set for a family of subsets has recently proven to be very useful in the design of parameterized and exact algorithms. We generalize this notion to families of multisets. We also give an efficient way to find a representative set for a family of multisets. As an application we give a deterministic algorithm for minimal weight r-SIMPLE k-PATH running in time O∗ (r O(k/r)) for 1 < r ≤ k. This extends a result of Abasi et. al [1] that gave a randomized algorithm of similar running time for the non-weighted case. We derive other algorithms for problems that can be viewed as augmenting a parameterized problem with a ‘relaxation’ parameter. A corollary of our construction is an improved explicit construction of lopsided universal sets (cf. [8]) for a certain range of parameters.
1
Introduction
Let P be a family of subsets of [n] of size p. A q-representative set for P is a subfamily Pˆ ⊆ P such that for every set Q ⊆ [n] of size q the following holds: If there exists a set P ∈ P that is disjoint from Q, there also exists a set P ′ ∈ Pˆ that is disjoint from Q. The Two-Families Theorem of Bollob´as [5] implies that there always exists a q-representative subfamily of size at most p+q . An interesting feature is that the size does not depend p on the universe [n] or the size of P. In particular, for any p, q with p + q = k, we always have a q-representative subfamily of size at most 2k . It turns out that efficiently finding a small q-representative subfamily is a central component in efficient algorithms for various problems. Roughly speaking, this is because it allows us to store only a small subset of the partial solutions constructed at an intermediate stage, before proceeding to attempt to augment them to a complete solution. A notable example is the recent work of Fomin, Lokshtanov and Saurabh [8] where an efficient method for finding representative sets is used to get faster deterministic algorithms for various problems such as LONG DIRECTED CYCLE, MINIMUM EQUIVALENT GRAPH, and k-PATH. Subsequently, their method was improved independently by Fomin et. al [7] and Shachnai and Zehavi [13].
1.1
Our contribution
Efficiently computing representative sets of multisets In this work we generalize the concept of a representative set to multisets. We also show how to efficiently compute representative sets for families of multisets As a corollary we obtain fast algorithms for versions of parameterized problems containing a second ‘relaxation parameter’. Parameterized problems with an auxillary relaxation parameter Let us illustrate what we mean by this relaxation parameter: In the well-known directed k-PATH problem, we are given a directed graph G and are asked to determine whether there exists a directed simple walk of length k in G. The current best-known algorithms for this problem on directed graphs are Williams [14] for unweighted case, and the works [7, 13] mentioned above for the weighted case, having running times O∗ (ck ) for c = 2 and c = 2.61804 respectively. (Bj¨ orklund et. al [4] obtain c = 1.66 when G is undirected.) Now suppose we added a parameter r that bounds the number of times a vertex is allowed to be visited in the walk. That is, we now want to determine if there exists a walk of length k where any vertex appears at most r times in the walk. Let us call such ∗ The research leading to these results has received funding from the European Community’s Seventh Framework Programme (FP7/2007-2013) under grant agreement number 257575 and 240258.
1
a walk an r-simple k-path. Note that in the original problem r = 1. On the other hand, note that when r = k this problem can be solved in polynomial time, e.g. by BFS. This setting was considered first by Abasi et. al [1] who showed that such a relaxation can indeed significantly improve the running time. Specifically, they obtain a randomized algorithm of running time O∗ (r2k/r ) for finding an r-simple k-path in G (assuming r > 1). As an application of our generalization, we obtain a deterministic algorithm with similar running time O∗ (rO(k/r) ) that can also find a minimal weight r-simple k-path in G. We obtain similar results for a version of the packing problem (see, e.g., Zehavi [15]) with a relaxation parameter - where instead of requiring for the packed sets to be disjoint we allow a given element to belong to at most r sets. Koutis [9] studied the problem of detecting whether a multivariate polynomial given as an arithmetic circuit contains a multilinear term, and showed that certain parameterized problems are reducible to this one. He gave a randomized algorithm running in time O∗ (2k ) for this problem.1 We study a similar problem of detecting an r-monomial - a monomial whose individual degree are all at most r, and show that this problem can be solved in deterministic time O∗ (rO(k/r ) when the circuit is non-canceling (See Theorem 5.4). Smaller lopsided universal sets Informally speaking, an n-p-q-lopsided universal set is a set of strings such that, when focusing on any k , p + q locations, we see all patterns of weight√p (see Definition 4.6). A probabilistic argument shows the existence of n-p-q-lopsided universal sets of size p · q · k · kp · log n (cf. Lemma 52 in [6]). Fomin, Lokshtanov and Saurabh [8] used the technique of [12] to construct an n-p-q-lopsided k universal set of size kp · 2O( log log(k) ) · log n. Consider the case p = o(q): For simplicity of discussion, let us focus on the kp ≤ (e · k/p)p term in the k probablistic construction and omit log n terms. In this case the 2O( log log(k) ) term of [8] is much larger than k p+2 (see Lemma 53 in [6]). We p . Bshouty [6] gives a better construction for such p achieving size roughly k O(p) give the first explicit construction of size (k/p) . Below, and throughout the paper, we use the notation Ok to hide k O(1) terms. Theorem 1.1. Fix integers p, q and n such that k = p + q ≤ n. An n-p-q-lopsided universal set of size Ok ((k/p)2·p · 2O(p) · log n) can be constructed in time Ok ((k/p)2·p · 2O(p) · n · log n).
2
Preliminaries
This section introduces known constructions of various combinatorial objects that will be needed in our construction. Notation: All functions will have domain [n] unless noted otherwise. Thus, the parameter n will be sometimes implicit in descriptions of families of functions. Alon, Yuster and Zwick [3] used a construction of Moni Naor (based on ideas from Naor et. al [12]) to hash a subset of size t into a world of size t2 using a very small set of functions Lemma 2.1. [[3] based on Naor] A t-perfect family of hash functions H , {f : [n] → [t2 ]} of size tO(1) · log n can be constructed in time O(tO(1) · n · log n) We introduce the notion of a hitting set for combinatorial rectangles. Definition 2.2. Let R ⊆ [m1 ]×[m2 ] . . .×[mt ] be a set of the form R1 ×. . .×Rt , where Ri ⊆ [mi ]. We say R is a combinatorial rectangle with sidewise density γ, if for every i ∈ [t], |Ri | ≥ γ·mi . A set H ⊆ [m1 ]×[m2 ] . . .×[mt ] is a hitting set for rectangles with sidewise density γ if for every set R ⊆ [m1 ] × [m2 ] . . . × [mt ] that is a combinatorial rectangle of sidewise density γ, R ∩ H 6= ∅. Linial et. al [10] gave the following construction of a hitting set for combinatorial rectangles. Theorem 2.3 ([10]). A hitting set for rectangles H ⊆ [m]t with sidewise density 1/3 of size |H| = (m · 2t )O(1) can be constructed in time (m · 2t )O(1) . We will need a hitting set for combinatorial rectangles in a universe where the coordinates are from domains of different sizes. We show that the theorem of [10] can be adapted to this setting. 1A
technicality is that his algorithm detects only multilinear terms with odd coefficients
2
Corollary 2.4. Suppose m1 , . . . , md ≤ m. A hitting set for rectangles H ⊆ [m1 ] × [m2 ] . . . × [mt ] with density 1/2 of size |H| = (m · 2t )O(1) can be constructed in time (m · 2t )O(1) . Proof. For the purpose of the proof it will be convenient to think of [a] as {0, . . . , a − 1} rather than {1, . . . , a}. Let m′ = m · 3 · t. Let H ′ ⊆ [m′ ]t be the hitting set for rectangles with density 1/3 of size nO(1) (m′ · 2t ) = nO(1) (m′ · 2t ) guaranteed in Theorem 2.3 Define H ⊆ [m1 ] × [m2 ] . . . × [mt ] as follows. For each element (a′1 , . . . , a′t ) ∈ H ′ add the element (a′1 mod m1 , . . . , a′t mod mt ) to H. Let us show that H is a hitting set for rectangles with density 1/2. Fix R = R1 × . . . × Rt ⊆ [m1 ] × [m2 ] . . . × [mt ] with |Ri | ≥ 1/2 · mi . Define R′ ⊆ [m′ ]t as follows. For a point (a′1 , . . . , a′t ) ∈ [m′ ]t , (a′1 , . . . , a′t ) ∈ R′ if and only if (a′1 mod m1 , . . . , a′t mod mt ) ∈Q R. t We have |R′ |/m′t ≥ |R|/ i=1 mi · (1 − 1/3t)t ≥ 1/2 · e−1/3 ≥ 1/3 . It follows there is a point (a′1 , . . . , a′t ) ∈ ′ ′ R ∩ H . Therefore the point (a′1 mod m1 , . . . , a′t mod mt ) is in R ∩ H. It follows that H is a hitting set as required. For integer t ≥ 1, we say a family of functions H = {f : [n] → [m]} is a t-perfect hash family, if for every C ⊆ [n] of size |C| = t, there is f ∈ H that is injective on T . We will use the following family of perfect hash functions of Naor, Schulman and Srinivasan [12]. Theorem 2.5 ([12]). For integer t, a t-perfect hash family H of functions f : [k 2 ] → [t] can be computed of 2 2 size et+O(log t) · log k can be constructed in time O(et+O(log t) · k · log k). We will be interested in constructing families of perfect hash functions that, in addition to being injective on a set C, have the property of sending another large set D to an output disjoint from the image of C. We call such a family of functions a separating family Definition 2.6 (Separating family). Fix integers t, k, s. For disjoint subsets C, D ⊆ [n] We say a function h : [n] → [s] separates C from D if • h is injective on C. • There are no collisions between C and D. That is, h(C) ∩ h(D) = ∅. A family of functions H , {h : [n] → [s]} is (t, k)-separating if for every disjoint subsets C, D ⊆ [n] with |C| = t and |D| ≤ k − t, there is a function h ∈ H that separates C from D. We say H is (t, k, s)-separating with probability γ if for any fixed C , D with sizes as above, a uniformly chosen h ∈ H separates C from D with probability at least γ. A central case of separating families will be when the range size is |C| + 1. In this case we use the term minimal -separating family. It will be convenient to assume in the definition that C is mapped to the first |C| elements in the range. Definition 2.7 (Minimal separating family). A family of functions H , {h : [n] → [t + 1]} is (t, k)-minimal separating if for every disjoint subsets C, D ⊆ [n] with |C| = t and |D| ≤ k − t there is a function h ∈ H such that separates C from D if • h(C) = [t]. • h(D) = t + 1.
3
Multiset separators and representative sets
The purpose of this section is to formally define and construct representative sets for multisets. The primary tool for this is what we call a multiset separator (Definition 3.1). Informally, a multiset separator is a not too large set of ‘witnesses’ for the fact that two multisets of bounded size do not jointly contain too many repetitions per element.
3
Notation for multisets Fix integers r, k ≤ n. We use the notation [r]0 , {0, . . . , r}. An r-set is a multiset A where each element of [n] appears at most r times. It will be convenient to think of A as a vector in [r]n0 where Ai denotes the number Pnof times i appears in A. We denote by |A| the number of elements in A counting repetitions. That is, |A| = i=1 Ai . We refer to |A| as the size of A. An (r, k)-set is an r-set A ∈ [r]n0 , where the number of elements with repetitions is at most k. That is, |A| ≤ k. Fix r-sets A, B ∈ [r]n0 . we say that A ≤ B when Ai ≤ Bi for all i ∈ [n]. Another convenient notation will be to denote by A ∈ [r]n0 the ‘complement’ r-set. That is, Ai = r − Ai for all i ∈ [n]. Suppose now that A and B are (r, k)-sets. We say that A and B are (r, k)-compatible if A + B is also an (r, k)-set, and |A + B| = k. That is, the total number of elements with repetitions in A and B together is k and any specific element i ∈ [n] appears in A and B together at most r times. With the notation above at hand, we can define the central object needed for our algorithms. Definition 3.1 (Multiset separator). Let F be a family of r-sets. We say that F is an (r, k)-separator if for any (r, k)-sets A, B ∈ [r]n0 that are (r, k)-compatible, there exists F ∈ F such that A ≤ F ≤ B. The following theorem shows how an (r, k)-separator can be constructed from a minimal separating family. Theorem 3.2. Fix integers 1 < r ≤ k, and let t , ⌊2k/r⌋. Suppose a (t, k)-minimal separating family H can be constructed in time O(|H| · n). Then an (r, k)-separator F of size |H| · (r + 1)t can be constructed in time O(|H| · n) Proof. For simplicity in the proof we assume r is even - otherwise we simply need to replace appearances of r/2 with ⌊r/2⌋. For each h : [n] → [t + 1] in H, for each w = (w1 , . . . , wt ) ∈ [r]t0 , construct the following r-set F h,w ∈ [r]n0 . Think of h as dividing [n] into t + 1 buckets. For 1 ≤ i ≤ t, we give all indices in the i’th bucket weight wi . Formally, for all j ∈ h−1 (i), we let fjh,w = wi . All indices in the (t + 1)’th bucket get weight r/2. Formally, for all j ∈ h−1 (t + 1), we let fjh,w = r/2. F will consist of all the r-sets F h,w . We have |F | = |H| · (r + 1)t . The efficiency of F ’s construction follows from the efficiency of H. Let us prove that F is indeed an (r, k)separator. Fix (r, k)-compatible (r, k)-sets A, B ∈ [r]n0 . Denote by C ⊆ [n] the sets of elements in A and B that appear more than r/2 times in one of the sets. That is, C = {i ∈ [n]|Ai > r/2 or Bi > r/2}. Denote by D the set of all other elements in A or B. That is, D = {i ∈ [n]|0 < Ai ≤ r/2 or 0 < Bi ≤ r/2}. Note that, as A and B are (r, k)-sets, |C| ≤ ⌊2k/r⌋ = t. As A and B are (r, k)-compatible, k/r ≤ |C ∪ D| ≤ k. Assume for simplicity that |C| = t.2 Now, fix h ∈ H that separates C from D. For 1 ≤ j ≤ t, let ij be the unique element of C mapped to j. Choose wj ∈ [r]0 such that Aij ≤ wj ≤ r − Bij . Such wj exists as A and B are (r, k)-compatible. Let w = (w1 , . . . , wt ). We claim that A ≤ F h,w ≤ B. For i ∈ C, the choice of w guarantees Ai ≤ Fih,w ≤ B i . For i ∈ D, we have F h,w = r/2; and from the definition of D we have for such i, Ai ≤ r/2 ≤ B i . For i ∈ / C ∪ D, we have that Ai = 0 and B i = r, so surely Ai ≤ Fih,w ≤ B i . Using the construction of a minimal separating family to be presented in Theorem 4.1, we get Corollary 3.3. Fix integers 1 < r ≤ k. An (r, k)-separator F of size Ok (r6k/r · 2O(k/r) · log n) can be constructed in time Ok (r6k/r · 2O(k/r) · n · log n)
Proof. Let H be the (t, k)-minimal separating family of size Ok ((k/t)2t · 2O(t) · log n) that can be constructed in time Ok ((k/t)2t · 2O(t) · n · log n) from Theorem 4.1. Using Theorem 4.1 we have |F | = |H| · (r + 1)t = Ok (r6k/r · 2O(k/r) · log n). Before proceeding we discuss the issue of weighted sets. From now on, we always assume the elements {1, . . . , n} are assigned integer weights. We define the weight of a multiset as the sum of the weights of its elements counting repetitions. Formally, for A ∈ [r]n0 , wt(A) =
n X i=1
Ai · wt(i).
2 Otherwise move elements from D to C so that |C| = t. The property we will need is that A , B ≤ r/2 for i ∈ D, and i i |D| ≤ k − t. These properties are not affected by moving elements from D to C.
4
We are ready to define the notion of a representative set for a family of multisets. Definition 3.4 (Representative sets for multisets). Let P be a weighted family of (r, k)-sets. We say a subset Pˆ ⊆ P represents P if for every (r, k)-set Q the following holds. If there is P ∈ P of weight w that is (r, k)-compatible with Q, then there is P ′ ∈ Pˆ of weight w′ ≤ w that is (r, k)-compatible with Q. The following definition and lemma show that an (r, k)-separator is sufficient for constructing representative sets. Definition 3.5. Let P be a weighted family of r-sets. Let F be a family of (r, k)-sets. The weighted family TrimF (P) ⊆ P is defined as follows. • For each F ∈ F , and for each 1 ≤ i ≤ k, check if there exists P ∈ P with |P | = i and P ≤ F . If so, insert into TrimF (P) some P ∈ P that is of minimal weight among those with |P | = i and P ≤ F . Lemma 3.6. Let F be an (r, k)-separator. Let P be a weighted family of (r, k)-sets. Then TrimF (P) represents P. Proof. Fix an (r, k)-set Q and suppose there is an (r, k)-set P ∈ P that is (r, k)-compatible with P . In particular, we have |P | = k − |Q|. Fix F ∈ F with P ≤ F ≤ Q. As P ≤ F , when computing TrimF (P) we must have inserted it an (r, k)-set P ′ ∈ P of size k−|Q| and weight w′ ≤ w such that P ′ ≤ F . Therefore P ′ ≤ Q, which implies that P ′ + Q is an (r, k)-set. As |P ′ + Q| = k, we have that P ′ and Q are (r, k)-compatible. Plugging in our construction of an (r, k)-separator into Lemma 3.6, we get the following. Corollary 3.7. Let P be a weighted family or (r, k)-sets. There exists a deterministic algorithm running in time Ok (|P| · r6k/r · 2O(k/r) · n · log n) returning a family Pˆ ⊆ P representing P of size Ok (r6k/r · 2O(k/r) · log n) . Proof. Let F be the (r, k)-separator of size Ok (r6k/r · 2O(k/r) · log n) from Corollary 3.3. F can be computed in time Ok (r6k/r · 2O(k/r) · n · log n). We compute TrimF (P) which represents P by Lemma 3.6. Computing TrimF (P) consists of going over all pairs of r-sets P ∈ P and F ∈ F and checking if P ≤ F . Thus, the computation takes time at most Ok (|P| · |F | · n · log r) = Ok (|P| · r6k/r · 2O(k/r) · n · log n).
3.1
The • operation.
Definition 3.8. We say that (r, k)-sets A and B are (r, k)-consistent, if |A + B| ≤ k, and Ai + Bi ≤ r for all i ∈ [n]. (This is a weaker definition than (r, k)-compatible which required |A + B| = k). Let A and B be families of (r, k)-sets. We denote by A • B the set A • B , {A + B|A ∈ A, B ∈ B| A and B are (r,k)−consistent}. In particular, for an element i ∈ [n], we denote A • {i} , {A + i|A ∈ A, |A| < k, Ai < r}. ˆ represents B, then Aˆ • B ˆ represents A • B. Claim 3.9. If Aˆ represents A and B Proof. Fix an (r, k)-set D such that there exists C ∈ A • B that is (r, k)-compatible with D. We have that C = A + B for some A ∈ A and B ∈ B that are (r, k)-consistent. In particular, A is (r, k)-compatible with B + D. Thus, there must be A′ ∈ Aˆ that is (r, k)-compatible with B + D. In other words, A′ + B + D is an ˆ (r, k)-set of size |A′ + B + D| = k. It follows that B is (r, k)-compatible with A′ + D. Thus, there is B ′ ∈ B that is (r, k)-compatible with A + D. Again, for this B ′ we have that A′ + B ′ + D is an (r, k)-set of size k. Therefore A′ + B ′ is an (r, k)-set of size at most k. In other words, A′ and B ′ are (r, k)-consistent, and therefore A′ + B ′ ∈ A′ • B ′ . As A′ + B ′ is (r, k)-compatible with D, we are done.
4
A construction of a separating family
The purpose of this section is to construct the separating family of functions in the following theorem. Theorem 4.1. Fix positive integers t ≤ k ≤ n. A (t, k)-minimal separating family of size Ok ((k/t)2t · 2O(t) · log n) can be constructed in time Ok ((k/t)2t · 2O(t) · n · log n) 5
We begin with some preliminary lemmas. One component in our construction is a family of ǫ-pairwise independent functions. Definition 4.2. A family of functions H , {f : [n] → [m]} is ǫ-pairwise independent if for all for all x, y ∈ [n] and a, b ∈ [m] |Prf ←H (f (x) = a ∧ f (y) = b) − 1/m2 | ≤ ǫ The constructions of [11] and [2] imply the following construction of an ǫ-pairwise independent family of functions (cf. Section 4 of [3]). Theorem 4.3. Fix any m ≤ n. A family of 1/m2 -pairwise independent functions H , {f : [n] → [m]} of size mO(1) · log n can be constructed in time O(mO(1) · n · log n). Lemma 4.4. For integers k ≤ n. A family Hk,4k , {f : [n] → [4 · k]} that is (1, k, 4 · k)-separating with probability 1/2 of size k O(1) · log n can be constructed in time k O(1) · n · log n. Proof. Let H : {f : [n] → [4k]} be the family of 1/(4k)2 -pairwise independent functions from Theorem 4.3. Fix the sets C = {a} and D = {b1 , . . . , bk−1 } we want to separate. For j ∈ [k − 1], let Xj be a random variable that is one if f (a) = f (bj ) and zero otherwise, where f ∈ H is chosen uniformly. From the 1/4k-pairwise Pk−1 independence of H, we have E(Xj ) = Pr(Xj = 1) ≤ 4k · (1/(4k)2 + 1/(4k)2 ) ≤ 1/(2k). Defining X = j=1 Xj we have E(X) < 1/2. Note that X is precisely the number of collisions between C and D. From Markov, Pr(X ≥ 1) ≤ 1/2. So with probability at least half over the choice of f , C and D are separated. The next claim follows from the well-known theorem that the geometric mean of non-negative numbers is always smaller than their arithmetic mean. Qt Claim 4.5. Let k1 , . . . , kt be positive real numbers such that k1 + . . . + kt ≤ k. Then i=1 ki ≤ (k/t)t . We are ready to proceed to the main construction.
4.1
The main construction - proof of Theorem 4.1
Proof. Fix disjoint subsets C, D ⊆ [n] with |C| = t and |D| ≤ k − t. Recall that we want to construct a family of functions H = {h : [n] → [t + 1]}, such that for any C and D as above, there exists h ∈ H that separates C from D. It will be convenient to present the family by constructing h adapatively given C and D. We will bound the number of choices we make when constructing h, and this will give a bound on the size of H. We assume without loss of generality that |D| = k − t. 1. Let H0 , {f : [n] → [k 2 ]} be the k-perfect hash family from Lemma 2.1. Choose f0 ∈ H0 that is injective on C ∪ D - k O(1) · log n choices. From now on, identify C and D with their images in [k 2 ] under f0 . 2. Let H1 , {f : [k 2 ] → [t]} be the t-perfect hash family from Theorem 2.5. Choose a function f1 ∈ H1 2 that is injective on C - et+O(log t) · log k choices. For i ∈ [t], we denote from now on by ci the (unique) element of C with f1 (ci ) = i.
3. Choose non-negative integers k1 , . . . , kt such that ki is the number ofkelements ta ∈ D with f1 (a) = i. Note that k1 + . . . + kt = k − t, so the number of choices is k−1 t−1 ≤ t ≤ (ek/t) . 4. For i ∈ [t], let Hki ,4ki , {f : [k 2 ] → [4 · ki ]} be the (1, ki , 4 · ki )-separating with probability 1/2 family O(1) · log k. of size mi = ki
Let R be the set of all vectors (h1 , . . . , ht ) where for all i ∈ [t], hi is an element of Hki ,4ki that separates ci from Di . Identify [mi ] with Hki ,4ki . Note that R is a combinatorial rectangle of sidewise density 1/2 in [m1 ] × . . . × [mt ]. Note that for all i ∈ [t], mi ≤ m for some m = k O(1) . Let H be the hitting set for combinatorial rectangles with sidewise density 1/2 from Corollary 2.4. Choose an element (h1 , . . . , ht ) ∈ Ht ∩ R - (k · 2t )O(1) choices.
For i ∈ [t], apply hi to partition Bi into buckets Bi,1 , . . . , Bi,4ki such that ci is mapped to a separate bucket from all elements of Di . 6
5. For each i ∈ [t], choose the j ∈ [4ki ] such that ci was mapped to bucket Bi,j . Map the elements of Bi,j Qt to i. Map the elements of Bi,j ′ for j ′ 6= j to t + 1; the number of choices is 4t · i=1 ki ≤ (4k/t)t , where the inequality uses Claim 4.5. To sum up, the number of different functions enumerated in all the above stages is at most k O(1) · log n · et+O(log
2
t)
· log k · (ek/t)t · (k · 2t )O(1) · (4k/t)t = (k/t)2t · 2O(t) · k O(1) · log n = Ok ((k/t)2t · 2O(t) · log n).
Similarly, going over the construction times of the different components used in the above stages, we get that the family can be constructed in time O(k O(1) · n · log n · et+O(log
2
t)
· k · log k · (ek/t)t · (k · 2t )O(1) · (4k/t)t )
= O((k/t)2t · 2O(t) · k O(1) · n · log n) = Ok ((k/t)2t · 2O(t) · n · log n)).
4.2
Lopsided universal sets
A corollary of the last section is a construction of smaller lopsided universal sets[8]. Bshouty [6] referred to this object as a cover free family. Definition 4.6. An n-p-q-lopsided universal set is a family of subsets F ⊆ [n] such that for every disjoint subsets A, B ⊆ [n] with |A| = p and |B| = q there exists F ∈ F with A ⊆ F and F ∩ B = ∅. Let k = p + q. An n-p-q-lopsided universal set is equivalent to a set of strings F ⊆ B n such that when restricting the strings in F to any k indices we see all strings of weight p. We restate and prove Theorem 1.1. Theorem 4.7. Fix integers p, q and n such that k = p + q ≤ n. An n-p-q-lopsided universal set of size Ok ((k/p)2·p · 2O(p) · log n) can be constructed in time Ok ((k/p)2·p · 2O(p) · n · log n). Proof. The theorem follows easily from our construction of a minimal separating family. Let H be the (p, k)minimal separating family of size Ok ((k/p)2p · 2O(p) · log n) from Theorem 4.1. For each h ∈ H, construct the set Fh = h−1 ({1, . . . , p}). Let F , {Fh |h ∈ H}. The definition of a minimal separating family implies F is an n-p-q-lopsided universal set.
5
Algorithmic applications
Throughout this section r denotes an integer always in the range 1 < r < k. The following simple observation will be used in all of our algorithmic applications. Claim 5.1. Let P be a family of (r, k)-sets containing a multiset P of size k and weight w. Then any Pˆ ⊆ P representing P contains a multiset P ′ of size k and weight w′ ≤ w. Proof. Take B = ∅. Then P and B are (r, k)-compatible. So there must be P ′ ∈ Pˆ that is (r, k)-compatible with B of weight at most w. As |P ′ + B| = k we have |P ′ | = k.
5.1
r-SIMPLE k-PATH
We introduce some notation for defining the r-SIMPLE k-PATH problem Let G be a directed graph on n vertices. A k-path in G is a simple walk P = v1 → v2 . . . → vk in G. An r-simple k-path is a walk P = v1 → v2 . . . → vk in G such that no vertex is repeated more than r times.
7
r-SIMPLE k-PATH
Input: Directed graph G = (V, E), weight function w : E → R. Parameter: k ∈ N. Problem: Determine if there exists an r-simple k-path in G and if so return one of minimal weight. Theorem 5.2. r-SIMPLE k-PATH can be solved in deterministic time Ok (r12k/r · 2O(k/r) · n3 · log n). Proof. For u ∈ [n] and i ∈ [k], let Pi,u denote the set of r-simple paths of length i in G ending in u. Note that an element P of such a set Pi,u can be viewed as an (r, k)-set when we ignore the order of vertices in the path. We can thus view the sets Pi,u as families of (r, k)-sets. We will compute by a dynamic programming algorithm, for each u ∈ [n] and i ∈ [k], a set Pˆi,u ⊆ Pi,u representing Pi,u of size at most Ok (r6k/r · 2O(k/r) · log n). Note that G contains an r-simple k-path if and only if one of the sets Pˆk,u is non-empty; thus, such an algorithm can be used to solve r-SIMPLE k-PATH. We proceed with the algorithm description. For i = 1, Pˆ1,u will simply contain the length one path u. Assume we have computed Pˆi,u for every u ∈ [n]. We describe the computation of Pˆi+1,v for a fixed v ∈ [n] together with its running time. S 1. We compute P ′ , (u,v)∈E Pˆi,u • v. We have |P ′ | ≤ n · Ok (r6k/r · 2O(k/r) · log n). We claim that P ′ S represents Pi+1,v : Note first that Pi+1,v = (u,v)∈E Pi,u • v. By Claim 3.9, for any u ∈ [n], Pˆi,u • v S S represents Pi,u • v. Therefore, P ′ = (u,v)∈E Pˆi,u • v represents (u,v)∈E Pi,u • v = Pi+1,v . P Computing P ′ requires time O( u∈[n] |Pˆi,u |) = Ok (n · r6k/r · 2O(k/r) · log n). 2. Now compute a set Pˆi+1,v of size |Pˆi+1,v | = Ok (r6k/r · 2O(k/r) · log n) representing P ′ using Corollary 3.7. This takes time O(|P ′ | · r6k/r · 2O(k/r) · n · log n) = O(n2 · r12k/r · 2O(k/r) · log n)
5.2
r − (p, q)-PACKING
We say P ⊆ [n] is a q-set if |P | = q. We say a set of q-sets A = {P1 , . . . , Pt } is an r-packing if any element j ∈ [n] appears in at most r of the q-sets in A. The r − (p, q)-PACKING problem asks whether a given family of q-sets contains an r-packing.3 r − (p, q)-PACKING
Input: Weighted family F of q-sets with |F | = nO(1) . Parameter: k = p · q ∈ N. Problem: Determine whether there exists a subset A ⊆ F with |A| = p that is an r-packing, and if so return such A of minimal weight. Theorem 5.3. Let k = p·q. r−(p, q)-PACKING can be solved in deterministic time Ok (r12k/r ·2O(k/r) ·nO(1) ). Proof. Fix a family F of q-sets. For i ∈ [p], denote by Pi the set of r-packings of size i in F . Note that an element A = {P1 , . . . , Pi } of Pi can be viewed as an (r, k)-set: We think of A as the multiset A = P1 ∪ . . . ∪ Pi . We know that this multiset has size at most p · q = k and any element j ∈ [n] appears in A at most r times. We will compute for each 1 ≤ i ≤ p, a set Pˆi ⊆ Pi representing Pi of size at most Ok (r6k/r · 2O(k/r) · log n). Note that F contains a subset A ⊆ F of size p that is an r-packing if and only if Pˆp is non-empty, thus such an algorithm will answer correctly. We proceed with the algorithm description. For i = 1, we have P1 = F . Assume we have computed Pˆi . We describe the computation of Pˆi+1 . 3 The assumption |F | = nO(1) below is only for convenience. Without it, the running time in Theorem 5.3 would have an extra |F |O(1) factor.
8
1. We compute P ′ , Pˆi • F . We have |P ′ | ≤ nO(1) · Ok (r6k/r · 2O(k/r) · log n). We claim that P ′ represents Pi+1 : Note first that Pi+1 = Pi • F . Thus, by claim 3.9 P ′ = Pˆi • F represents Pi • F = Pi+1 . Computing P ′ requires time Ok (|F | · |Pi,u | · nO(1) ) = Ok (r6k/r · 2O(k/r) · log n · nO(1) ).
2. Now compute a set Pˆi+1 of size |Pˆi+1 | = Ok (r6k/r · 2O(k/r) · log n) representing P ′ using Corollary 3.7. This takes time Ok (|P ′ | · r6k/r · 2O(k/r) · n · log n) = Ok (nO(1) · r12k/r · 2O(k/r) ).
5.3
(r, k)-MONOMIAL DETECTION
We say a monomial X1d1 · · · Xndn is an r-monomial if for all i ∈ [n], di ≤ r. We say the monomial is an (r, k)-monomial if the above holds and the total degree of the monomial is k. Let C be an arithmetic circuit computing a polynomial f (X1 , . . . , Xn ) ∈ Z[X1 , . . . , Xn ]. We say C is non-canceling if it contains only variables at its leafs (i.e., no constants), and only addition and multiplication gates (i.e., no substractions). For a non-canceling circuit C, we define |C| to be the number of multiplication and addition gates plus the number of leafs (each containing a variable). We assume the fan-in of a non-canceling circuit is two, i.e., each multiplication and addition gate has at most two wires coming in. (This will simply be convenient for bounding the run-time as a function of |C|). (r, k)-MONOMIAL DETECTION
Input: A non-cancelling circuit C computing a polynomial f (X1 , . . . , Xn ) ∈ Z[X1 , . . . , Xn ]. Parameter: k ∈ N. Problem: Determine if there exists an (r, k)-monomial in f with non-zero coefficient and if so, return such a monomial. Theorem 5.4. Given a non-canceling circuit C computing a polynomial f (X1 , . . . , Xn ) ∈ Z[X1 , . . . , Xn ], (r, k)-MONOMIAL DETECTION can be solved in deterministic time Ok (|C| · r12k/r · 2O(k/r) · n · log n).
Proof. For each gate s of C, let fs be the polynomial computed at s. Define Ps to be the set of r-monomials of total degree at most k that appear in fs with nonzero coefficient. We can view Ps as a family of (r, k)sets: An r-monomial M = X1d1 · · · Xndn of total degree at most k corresponds to the (r, k)-set where j ∈ [n] appears dj times. We present an algorithm that computes for every gate s of C a set Pˆs ⊆ Ps of size Ok (r6k/r · 2O(k/r) · log n) representing Ps . Let sout be the output gate of C. If f contains an r-monomial of total degree k then Pˆsout will contain such a monomial. We compute the sets Pˆs from bottom to top. Suppose we have computed Pˆ1 , Pˆs1 and P2 , Pˆs2 for the gates s1 and s2 having wires into s. • If s is an addition gate we define P ′ , Pˆ1 ∪ Pˆ2 . We claim that P ′ represents Ps : As C is non-canceling the monomials, appearing in fs with nonzero coefficient are simply the union of the monomials of s1 and s2 . In particular, Ps = Ps1 ∪ Ps2 . Therefore P ′ = Pˆs1 ∪ Pˆs2 represents Ps .
• If s is a multiplication gate define P ′ , Pˆs1 • Pˆs2 . As C is non-canceling, the monomials of fs are exactly the set of all products of a monomial of fs1 and a monomial of fs2 . Ps is exactly the set of these products that are also (r, k)-monomials. When viewed as a multiset, the product of the monomials M1 and M2 is the multiset M1 + M2 . Thus, Ps = Ps1 • Ps2 and therefore, using Claim 3.9, P ′ = Pˆs1 • Pˆs2 represents Ps . • Now compute a set Pˆs of size at most Ok (r6k/r · 2O(k/r) · log n) representing P ′ using Corollary 3.7. This takes time O(|P ′ | · r6k/r · 2O(k/r) · n · log n) = O(nO(1) · r12k/r · 2O(k/r) · n · log n)
Acknowledgements The first author thanks Fedor V. Fomin for hosting him at a visit in the University of Bergen where this research was initiated. 9
References [1] H. Abasi, N. H. Bshouty, A. Gabizon, and E. Haramaty. On r-simple k-path. In Mathematical Foundations of Computer Science 2014 - 39th International Symposium, MFCS 2014, Budapest, Hungary, August 2529, 2014. Proceedings, Part II, pages 1–12, 2014. [2] N. Alon, O. Goldreich, J. Hastad, and R. Peralta. Simple construction of almost k-wise independent random variables. Random Struct. Algorithms, 3(3):289–304, 1992. [3] N. Alon, R. Yuster, and U. Zwick. Color coding. In Encyclopedia of Algorithms. 2008. [4] A. Bj¨orklund, T. Husfeldt, P. Kaski, and M. Koivisto. Narrow sieves for parameterized paths and packings. CoRR, abs/1007.1161, 2010. [5] B. Bollob´ as. On generalized graphs. Acta Math. Acad Sci. Hungar, 16:447–452, 1965. [6] N. H. Bshouty. Testers and their applications. In ITCS, pages 327–352, 2014. [7] F. V. Fomin, D. Lokshtanov, F. Panolan, and S. Saurabh. Representative sets of product families. In Algorithms - ESA 2014 - 22th Annual European Symposium, Wroclaw, Poland, September 8-10, 2014. Proceedings, pages 443–454, 2014. [8] F. V. Fomin, D. Lokshtanov, and S. Saurabh. Efficient computation of representative sets with applications in parameterized and exact algorithms. In SODA, pages 142–151, 2014. [9] I. Koutis. Faster algebraic algorithms for path and packing problems. In Automata, Languages and Programming, 35th International Colloquium, ICALP 2008, pages 575–586, 2008. [10] N. Linial, M. Luby, M. E. Saks, and D. Zuckerman. Efficient construction of a small hitting set for combinatorial rectangles in high dimension. Combinatorica, 17(2):215–234, 1997. [11] J. Naor and M. Naor. Small-bias probability spaces: Efficient constructions and applications. SIAM J. Comput., 22(4):838–856, 1993. [12] Moni Naor, Leonard J. Schulman, and Aravind Srinivasan. Splitters and near-optimal derandomization. In FOCS, pages 182–191, 1995. [13] H. Shachnai and M. Zehavi. Representative families: A unified tradeoff-based approach. In Algorithms - ESA 2014 - 22th Annual European Symposium, Wroclaw, Poland, September 8-10, 2014. Proceedings, pages 786–797, 2014. [14] R. Williams. Finding paths of length k in o* (2k ) time. Inf. Process. Lett., 109(6):315–318, 2009. [15] M. Zehavi. Deterministic parameterized algorithms for matching and packing problems. abs/1311.0484, 2013.
10
CoRR,