Optimal Hitting Sets for Combinatorial Shapes

We consider the problem of constructing explicit Hitting sets for Combinatorial Shapes, a class of statistical tests first studied by Gopalan, Meka, Reingold, and Zuckerman (STOC 2011). These generalize many well-studied classes of tests, including symmetric functions and combinatorial rectangles. Generalizing results of Linial, Luby, Saks, and Zuckerman (Combinatorica 1997) and Rabani and Shpilka (SICOMP 2010), we construct hitting sets for Combinatorial Shapes of size polynomial in the alphabet, dimension, and the inverse of the error parameter. This is optimal up to polynomial factors. The best previous hitting sets came from the Pseudorandom Generator construction of Gopalan et al., and in particular had size that was quasipolynomial in the inverse of the error parameter. Our construction builds on natural variants of the constructions of Linial et al. and Rabani and Shpilka. In the process, we construct fractional perfect hash families and hitting sets for combinatorial rectangles with stronger guarantees. These might be of independent interest.


Introduction
Randomness is a tool of great importance in Computer Science and combinatorics. The probabilistic method is highly effective both in the design of simple and efficient algorithms and in demonstrating the existence of combinatorial objects with interesting properties. But the use of randomness also comes with some disadvantages. In the setting of algorithms, introducing randomness adds to the number of resource requirements of the algorithm, since truly random bits are hard to come by. For combinatorial constructions, 'explicit' versions of these objects often turn out to have more structure, which yields advantages beyond the mere fact of their existence (e.g., we know of explicit error-correcting codes that can be efficiently encoded and decoded, but we don't know if random codes can [5]). Thus, it makes sense to ask exactly how powerful probabilistic algorithms and arguments are. Can they be 'derandomized', i.e., replaced by determinstic algorithms/arguments of comparable efficiency? 1 There is a long line of research that has addressed this question in various forms [19,11,18,23,16].
An important line of research into this subject is the question of derandomizing randomized space-bounded algorithms. In 1979, Aleliunas et al. [1] demonstrated the power of these algorithms by showing that undirected s-t connectivity can be solved by randomized algorithms in just O(log n) space. In order to show that any randomized logspace computation could be derandomized within the same space requirements, researchers considered the problem of constructing an efficient ε-Pseudorandom Generator (ε-PRG) that would stretch a short random seed to a long pseudorandom string that would be indistinguishable (up to error ε) to any logspace algorithm. 2 In particular, an ε-PRG (for small constant ε > 0) with seedlength O(log n) would allow efficient deterministic simulations of logspace randomized algorithms since a deterministic algorithm could run over all possible random seeds.
A breakthrough work of Nisan [18] took a massive step towards this goal by giving an explicit ε-PRG for ε = 1/poly(n) that stretches O(log 2 n) truly random bits to an n-bit pseudorandom string for logspace computations. In the two decades since, however, Nisan's result has not been improved upon at this level of generality. However, many interesting subcases of this class of functions have been considered as avenues for progress [20,12,14,13,15].
The class of functions we consider are the very natural class of Combinatorial Shapes. A boolean function f is a combinatorial shape if it takes n inputs x 1 , . . . , x n ∈ [m] and computes a symmetric function of boolean bits y i that depend on the membership of the inputs x i in sets A i ⊆ [m] associated with f . (A function of boolean bits y 1 , . . . , y n is symmetric if its output depends only on their sum.) In particular, ANDs, ORs, Modular sums and Majorities of subsets of the input alphabet all belong to this class. Until recently, Nisan's result gave the best known seedlength for any explicit ε-PRG for this class, even when ε was a constant. In 2011, however, Gopalan et al. [9] gave an explicit ε-PRG for this class with seedlength O(log(mn) + log 2 (1/ε)). This seedlength is optimal as a function of m and n but suboptimal as a function of ε, and for the very interesting case of ε = 1/n O (1) , this result does not improve upon Nisan's work.
Is the setting of small error important ? We think the answer is yes, for many reasons. The first deals with the class of combinatorial shapes: many tests from this class accept a random input only with inverse polynomial probability (e.g., the alphabet is {0, 1} and the test accepts iff the Hamming weight of its n input bits is n/2); for such tests, the guarantee that a 1/n o(1) -PRG gives us is unsatisfactory. Secondly, while designing PRGs for some class of statistical tests with (say) constant error, it often is the case that one needs PRGs with much smaller error -e.g., one natural way of constructing almost-log n wise independent spaces uses PRGs that fool parity tests [17] to within inverse polynomial error. Thirdly, the reason to improve the dependence on the error is simply because we know that such PRGs exist. Indeed, a randomly chosen function that expands O(log n) bits to an n-bit string is, w.h.p., an ε-PRG for ε = 1/poly(n). Derandomizing this existence proof is a basic challenge in understanding how to eliminate randomness from existence proofs. The tools we gain in solving this problem might help us in solving others of a similar flavor.
Our result. While we are unable to obtain optimal PRGs for the class of combinatorial shapes, we make progress on a well-studied weakening of this problem: the construction of an ε-Hitting Set (ε-HS). An ε-HS for the class of combinatorial shapes has the property that any combinatorial shape that accepts at least an ε fraction of truly random strings accepts at least one of the strings in the hitting set. This is clearly a weaker guarantee than what an ε-PRG gives us. Nevertheless, in many cases, this problem turns out to be very interesting and non-trivial: in particular, an ε-HS for the class of space-bounded computations would solve the long-standing open question of whether RL = L. Our main result is an explicit ε-HS of size poly(mn/ε) for the class of combinatorial shapes, which is optimal, to within polynomial factors, for all errors. Theorem 1.1 (Main Result (informal)). For any m, n ∈ N, ε > 0, there is an explicit ε-HS for the class of combinatorial shapes of size poly(mn/ε).
Related work: There has been a substantial amount of research into both PRGs and hitting sets for many interesting subclasses of the class of combinatorial shapes, and also some generalizations. Naor and Naor [17] constructed PRGs for parity tests of bits (alphabet size 2); these results were extended by Lovett, Reingold, Trevisan, and Vadhan [13] and Meka and Zuckerman [15] to modular sums (with coefficients). Combinatorial rectangles, another subclass of combinatorial shapes, have also been the subject of much attention. A series of works [6,4,14] have constructed ε-PRGs for this class of functions: the best such PRG, due to Lu [14], has seedlength O(log n + log 3/2 (1/ε)). Linial, Luby, Saks, and Zuckerman [12] constructed optimal hitting sets for this class of tests. We build on many ideas from this work.
We also mention two more recent results that are very pertinent to our work. The first is to do with Linear Threshold functions which are weighted generalizations of threshold symmetric functions of input bits. For this class, Rabani and Shpilka [21] construct an explicit ε-HS of optimal size poly(n/ε). They use a bucketing and expander walk construction to build their hitting set. Our construction uses similar ideas.
The final result that we use is the PRG for combinatorial shapes by Gopalan et al. [9] that was mentioned in the introduction. This work directly motivates our results and moreover, we use their PRG as a black-box within our construction. , 1} such that f (x 1 , . . . , x n ) = h(1 A 1 (x 1 ), . . . , 1 An (x n )). 3 If h is the AND function, we call f an (m, n)-Combinatorial Rectangle. If h is an unweighted threshold function (i.e. h accepts iff

Notation and Preliminaries
, then f is said to be an (m, n)-Combinatorial Threshold. We denote by CShape(m, n), CRect(m, n), and CThr(m, n) the class of (m, n)-Combinatorial Shapes, Rectangles, and Thresholds respectively.
Notation. In many arguments, we will work with a fixed collection of accepting sets A 1 , . . . , A n ⊆ [m] that will be clear from the context. In such a scenario, for i ∈ [n], we let 3 1A is the indicator function of the set A.
An ε-hitting set (ε-HS) for F is a multiset H containing only elements from D s.t. for any f ∈ F, Remark 2.3. Whenever we say that there exist explicit families of combinatorial objects of some kind, we mean that the object can be constructed by a deterministic algorithm in time polynomial in the description of the object.
We will need the following previous results in our constructions.
We will also need a stronger version of Theorem 2.5 for special cases of combinatorial rectangles. Informally, the strengthening says that if the acceptance probability of a 'nice' rectangle is > p for some reasonably large p, then a close to p fraction of the strings in the hitting set are accepting. Formally, the following is proved later in the paper.
Theorem 2.6 (Stronger HS for CRect(m, n)). For all constants c ≥ 1, m = n c , and ρ ≤ c log n, there is an explicit set S n,c,ρ rect of size n Oc(1) s.t. for any R ∈ CRect(m, n) which satisfies the properties: 1. R is defined by A i , and the rejecting probabilities Recall that a distribution µ over [m] n is k-wise independent for k ∈ N if for any S ⊆ [n] s.t. |S| ≤ k, the marginal µ| S is uniform over [m] |S| . Also, G : {0, 1} s → [m] n is a k-wise independent probability space over [m] n if for uniformly randomly chosen z ∈ {0, 1} s , the distribution of G(z) is k-wise independent.
Fact 2.7 (Explicit k-wise independent spaces). For any k, m, n ∈ N, there is an explicit k-wise independent probability space G m,n k-wise : {0, 1} s → [m] n with s = O(k log(mn)).
We will also use the following result of Even et al. [6].
Theorem 2.8. Fix any m, n, k ∈ N. Then, if f ∈ CRect(m, n) and µ is any k-wise independent distribution over [m] n , then we have Expanders. Recall that a degree-D multigraph G = (V, E) on N vertices is an (N, D, λ)-expander if the second largest (in absolute value) eigenvalue of its normalized adjacency matrix is at most λ. We will use explicit expanders as a basic building block. We refer the reader to the excellent survey of Hoory, Linial, and Wigderson [10] for various related results. Expanders have found numerous applications in derandomization. A central theme in these applications is to analyze random walks on a sequence of expander graphs. Let G 1 , . . . , G ℓ be a sequence of (possibly different) graphs on the same vertex set V . Assume G i (i ∈ [ℓ]) is an (N, D i , λ i )-expander. Fix any u ∈ V and y 1 , . . . , y ℓ ∈ N s.t. y i ∈ [D i ] for each i ∈ [ℓ]. Note that (u, y 1 , . . . , y ℓ ) naturally defines a 'walk' (v 1 , . . . , v ℓ ) ∈ V ℓ as follows: v 1 is the y 1 th neighbour of u in G 1 and for each i > 1, v i is the y i th neighbour of v i−1 in G i . We denote by W(G 1 , . . . , G ℓ ) the set of all tuples (u, y 1 , . . . , y ℓ ) as defined above. Moreover, given w = (u, y 1 , . . . , y ℓ ) ∈ W(G 1 , . . . , G ℓ ), we define v i (w) to be the vertex v i defined above (we will simply use v i if the walk w is clear from the context).
We need a variant of a result due to Alon, Feige, Wigderson, and Zuckerman [2]. The lemma as it is stated below is slightly more general than the one given in [2] but it can be obtained by using essentially the same proof and setting the parameters appropriately. The proof is given in the appendix.
Lemma 2.10. Let G 1 , . . . , G ℓ be a sequence of graphs defined on the same vertex set V of size N .
Then, as long as for each Also, in our applications, we will sometimes use the following corollary.
Corollary 2.11. Let V be a set of N elements, and let 0 < p i < 1 for 1 ≤ i ≤ s be given. There exists an explicit set of walks W, each of length s, s.t. for any subsets V 1 , V 2 , . . . , V s of V , with |V i | ≥ p i N , there exists a walk w = w 1 w 2 . . . w s ∈ W such that w i ∈ V i for all i. Furthermore, there exist such W satisfying |W| ≤ poly N, s i=1 1 p i . This follows from Lemma 2.10 by picking λ i smaller than p i p i−1 /10 for each i. By Fact 2.9, known explicit constructions of expanders require choosing degrees d i = 1/λ O(1) i . The number of walks of length s is N · ℓ i=1 d i , which gives the bound on W above.
Hashing. Hashing plays a vital role in all our constructions. Thus, we need explicit hash families which have several "good" properties. First, we state a lemma obtained by slightly extending part of a lemma due to Rabani and Shpilka [21], which itself builds on the work of Schmidt and Siegel [22] and Fredman, Komlós, and Szemerédi [8]. It is somewhat folklore and the proof is omitted. The family of functions thus constructed are called "perfect hash families". We also need a fractional version of the above lemma, whose proof is similar to that of the perfect hashing lemma and is presented later in the paper.

Outline of the Construction
We will outline some simplifying assumptions, and an observation which "reduces" constructing hitting sets for Combinatorial shapes CShape(m, n) to those for Combinatorial Thresholds CThr(m, n). It turns out that these are somewhat simpler to construct, appealing to the recent results of Gopalan et al. [9].
We first make a standard simplifying observation that we can throughout assume that m, n, 1/ε can be n O (1) . Thus, we only need to construct hitting sets of size n O(1) in this case. From now on, we assume m, 1/ε = n O(1) . Lemma 3.1. Assume that for some c ≥ 1, and m ≤ n c , there is an explicit 1/n c -HS for CShape(m, n) of size n Oc (1) . Then, for any m, n, ∈ N and ε > 0, there is an explicit ε-HS for CShape(m, n) of size poly(mn/ε).
Proof. Fix c ≥ 1 so that the assumptions of the lemma hold. Note that when m > n c , we can increase the number of coordinates to n ′ = m. Now, an ε-HS for CShape(m, n ′ ) is also an ε-HS for CShape(m, n), because we can ignore the final n ′ − n coordinates and this will not affect the hitting set property. Similarly, when ε < 1/n c , we can again increase the number of coordinates to n ′ that satisfies ε ≥ 1/(n ′ ) c and the same argument follows. In each case, by assumption we have an ε-HS of size (n ′ ) Oc(1) = poly(mn/ε) and thus, the lemma follows.
Next, we prove a crucial lemma which shows how to obtain hitting sets for CShape(m, n) starting with hitting sets for CThr(m, n). This reduction crucially uses the fact that CShape does only 'symmetric' tests -it fails to hold, for instance, for natural "weighted" generalizations of CShape.
Proof. Suppose we can construct hitting sets for CThr(m, n) and parameter ε ′ of size F (m, n, 1/ε ′ ), for all ε ′ > 0. Now consider some f ∈ CShape(m, n), defined using sets A i and symmetric function h. Since h is symmetric, it depends only on the number of 1's in its input. In particular, there is Thus if we consider functions in CThr(m, n) defined by the same A i , and thresholds T + w and T − w respectively, we have that both have accepting probability at least ε/(n+1), and thus an ε/(n+1)-HS S for CThr(m, n) must have 'accepting' elements y, z ∈ [m] n for T − w and T + w respectively. The key idea is now the following. Suppose we started with the string y and moved to string z by flipping the coordinates one at a time -i.e., the sequence of strings would be: In this sequence the number of "accepted" indices (i.e., i for which 1 A i (x i ) = 1) changes by at most one in each 'step'. To start with, since y was accepting for T − w , the number of accepting indices was at most w, and in the end, the number is at least w (since z is accepting for T + w ), and hence one of the strings must have precisely w accepting indices, and this string would be accepting for f ! Thus, we can construct an ε-HS for CShape(m, n) as follows. Let S denote an explicit (ε/(n+1))-HS for CThr(m, n) of size F (m, n, 1/ε). For any y, z ∈ S, let I y,z be the set of n + 1 "interpolated" strings obtained above. Define S ′ = y,z∈S I y,z . As we have argued above, S ′ is an ε-HS for CShape(m, n). It is easy to check that S ′ has the size claimed.
Overview of the Constructions. In what follows, we focus on constructing hitting sets for CThr(m, n). We will describe the construction of two families of hitting sets: the first is for the "high weight" case -w(f ) := i w i > C log n for some large constant C, and the second for the case w(f ) < C log n. The final hitting set is a union of the ones for the two cases.
The high-weight case (Section 4.1) is conceptually simpler, and illustrates the important tools. A main tool in both cases is a "fractional" version of the perfect hashing lemma, which, though a consequence of folklore techniques, does not seem to be known in this generality (Lemma 2.13).
The proof of the low-weight case is technically more involved, so we first present the solution in the special case when all the sets A i are "small", i.e., we have p i ≤ 1/2 for all i (Section 4.2). This case illustrates the main techniques we use for the general low-weight case. The special case uses the perfect hashing lemma (which appears, for instance in derandomization of "color coding" -a trick introduced in [3], which our proof in fact bears a resemblance to).
The general case (Section 4.3), in which p i are arbitrary, is more technical: here we need to do a "two level" hashing. The top level is by dividing into buckets, and in each bucket we get the desired "advantage" using a generalization of hitting sets for combinatorial rectangles (which itself uses hashing: Theorem 2.6).
Finally we describe the main tools used in our construction. The stronger hitting set construction for special combinatorial rectangles is discussed in Section 5 and the fractional perfect hash family construction is discussed in Section 6. We end with some interesting open problems and a proof of the expander walk lemma follows in the appendix.

Hitting sets for Combinatorial Thresholds
As described above, we first consider the high-weight case (i.e., w(f ) ≥ C log n for some large absolute constant C). Next, we consider the low-weight case, with an additional restriction that each of the accepting probabilities p i ≤ 1/2. This serves as a good starting point to explain the general low-weight case, which we get to in Section 4.3. In each section, we outline our construction and then analyze it for a generic combinatorial threshold f : [m] n → {0, 1} (subject to weight constraints) defined using sets A 1 , . . . , A n ⊆ [m]. The theorem we finally prove in the section is as follows.
Theorem 4.1. For any constant c ≥ 1, the following holds. Suppose m, 1/ε ≤ n c . For the class of functions CThr(m, n), there exists an explicit ε-hitting set of size n Oc (1) .
The main theorem, which we state below, follows directly from the statements of Theorem 4.1 and Lemmas 3.1 and 3.2.

High weight case
In this section we will prove the following: (1) for the class of functions in CThr(m, n) of weight at least C log n.
As discussed earlier, we wish to construct hitting sets for combinatorial shapes f where the associated symmetric function is either T + θ or T − θ , for θ s.t. the probability of the event for independent, perfectly random x i is at least 1/n c . For convenience, define µ := p 1 + p 2 + · · · + p n , and W := w 1 + w 2 + . . . w n . We have W > C log n for a large constant C (it needs to be large compared to c, as seen below). First, we have the following by Chernoff bounds.
Outline. Let us concentrate on hitting sets for combinatorial shapes that use symmetric functions of the form T + θ (the case T − θ follows verbatim). The main idea is the following: we first divide the indices [n] into log n buckets using a hash function h (from a fractional perfect hash family, see Lemma 2.13). This is to ensure that the w i get distributed somewhat uniformly. Second, we aim to obtain an advantage of roughly 2 cW log n in each of the buckets (advantage is w.r.t. the mean in each bucket): i.e., for each i ∈ [log n], we choose the indices x j (j ∈ h −1 (i)) s.t. we get p j + 2 cW/ log n with reasonable probability. Third, we ensure that the above happens for all buckets simultaneously (with probability > 0) so that the advantages add up, giving a total advantage of 2 √ cW log n over the mean, which is what we intended to obtain. In the second step (i.e., in each bucket), we can prove that the desired advantage occurs with constant probability for uniformly randomly and independently chosen x j ∈ [m] and then derandomize this choice by the result of Gopalan et al. [9] (Theorem 2.4). Finally, in the third step, we cannot afford to use independent random bits in different buckets (this would result in a seed length of Θ(log 2 n)) -thus we need to use expander walks to save on randomness.
Construction and Analysis. Let us now describe the three steps in detail. We note that these steps parallel the results of Rabani and Shpilka [21].
The first step is straightforward: we pick a hash function from a perfect fractional hash family H n,log n frac . From Lemma 2.13, we obtain The rest of the construction is done starting with each h ∈ H n,log n frac . Thus for analysis, suppose that we are working with an h satisfying the inequality from the above claim. For the second step, we first prove that for independent random x i ∈ [m], we have a constant probability of getting an advantage of 2 cW log n over the mean in each bucket.
The proof is straightforward, but it is instructive to note that in general, a random variable (in this case, S) need not deviate "much more" (in this case, a c ′ factor more) than its standard deviation: we have to use the fact that S is the sum of independent r.v.s. This is done by an application of the Berry-Esséen theorem [7].
Proof. We recall the standard Berry-Esséen theorem [7]. Fact 4.7 (Berry-Esseen). Let Y 1 , . . . , Y n be independent random variables satisfying ∀i, EY i = 0, EY 2 i = σ 2 and ∀i, |Y i | ≤ βσ. Then the following error bound holds for any t ∈ R, We can now apply this to Y i := X i − p i (so as to make EY i = 0). Then , this means we have the condition |Y i | ≤ βσ for β ≤ e −c ′2 /20. Now for the Gaussian, a computation shows that we have P[N (0, σ 2 ) > c ′ σ] > e −c ′2 /10. Thus from our bound on β, we get P[ Y i > c ′ σ] > e −c ′2 /20, which we pick to be α. This proves the lemma.
Assume now that we choose x 1 , . . . , x n ∈ [m] independently and uniformly at random. For each bucket i ∈ [log n] defined by the hash function h, we let By Lemma 4.6, if C is a large enough constant so that W i ≥ C/100 ≥ 20e 400c , then for uniformly randomly chosen x 1 , . . . , x n ∈ [m] and each bucket i ∈ [log n], we have P X (i) ≥ µ i + 2 cW/ log n ≥ α, where α > 0 is some fixed constant depending on c. When this event occurs for every bucket, GM RZ . Note that since α is a constant depending on c, we have s = O c (log n). Moreover, since we know that the success probability with independent random x j (j ∈ h −1 (i)) for obtaining the desired advantage is at least α, we have for any i ∈ [log n] and y (i) randomly chosen from {0, 1} s , This only requires seedlength O c (log n) per bucket. Thus we are left with the third step: here for each bucket i ∈ [log n], we would like to have (independent) seeds which generate the corresponding x (i) (and each of these PRGs has a seed length of O c (log n)). Since we cannot afford O c (log 2 n) total seed length, we instead do the following: consider the PRG G defined above. As mentioned above, since α = Ω c (1), the seed length needed here is only O c (log n). Let S be the range of G (viewed as a multiset of strings: S ⊆ [m] n ). From the above, we have that for the ith bucket, the probability x ∼ S exceeds the threshold on indices in bucket i is at least α/2. Now there are log n buckets, and in each bucket, the probability of 'success' is at least α/2. We can thus appeal to the 'expander walk' lemma of Alon et al. [2] (see preliminaries, Lemma 2.10 and the corollary following it).
This means the following: we consider an explicitly constructed expander on a graph with vertices being the elements of S, and the degree being a constant depending on α). We then perform a random walk of length log n (the number of buckets). Let s 1 , s 2 , . . . , s log n be the strings (from S) we see in the walk. We form a new string in [m] n by picking values for indices in bucket i, from the string s i . By the Lemma 2.10, with non-zero probability, this will succeed for all 1 ≤ i ≤ log n, and this gives the desired advantage.
The seed length for generating the walk is O(log |S|) + O c (1) · log n = O c (log n). Combining (or in some sense, composing) this with the hashing earlier completes the construction.

Thresholds with small weight and small sized sets
We now prove Theorem 4.1 for the case of thresholds f satisfying w(f ) = O(log n). Also we will make the simplifying assumption (which we will get rid of in the next sub-section) that the underlying subsets of f , A 1 , . . . , A n ⊆ [m] are of small size. We will prove this theorem in the rest of this sub-section. Note that since To begin, we note that hitting sets for the case when the symmetric function is T − θ is easily obtained. In particular, since T − 0 accepts iff X i = 0, it can also be interpreted as a combinatorial rectangle with accepting sets A 1 , . . . , A n . The probability of this event over uniformly chosen inputs is at least i (1 − p i ) ≥ e −2 i p i ≥ e −4 i p i (1−p i ) ≥ n −4c , where the first inequality uses the fact that (1 − x) ≥ e −2x for x ∈ [0, 1/2]. Thus the existence of a hitting set for such f follows from the result of Linial et al.. [12]. Further, by definition, a hitting set for T − 0 is also a hitting set for T − θ for θ > 0. We will therefore focus on hitting sets for thresholds of the form T + θ for some θ > 0. Let us now fix a function f (x) = T + θ ( i 1 A i (x i )) that accepts with good probability: Since w(f ) ≤ c log n and p i ≤ 2w i for each i ∈ [n], it follows that µ ≤ 2c log n. Thus by a Chernoff bound and the fact that ε = 1/n c , we have that θ ≤ c ′ log n for some c ′ = O c (1).
Outline. The idea is to use a hash function h from a perfect hash family (Lemma 2.12) mapping [n] → [θ]. The aim will now be to obtain a contribution of 1 to the sum i 1 A i (x i ) from each bucket 4 . In order to do this, we require i µ i be large, where µ i is the sum of p j for j in bucket B i = h −1 (i). By a reason similar to color coding (see [3]), it will turn out that this quantity is large when we bucket using a perfect hash family. We then prove that using a pairwise independent space in each bucket B i "nearly" gives probability µ i of succeeding. As before, since we cannot use independent hashes in each bucket, we take a hash function over [n], and do an expander walk. The final twist is that in the expander walk, we cannot use a constant degree expander: we will have to use a sequence of expanders on the same vertex set with appropriate degrees (some of which can be super-constant, but the product will be small). This will complete the proof. We note that the last trick was implicitly used in the work of [12].
Construction. Let us formally describe a hitting set for T + θ for a fixed θ. (The final set S n,c low,1 will be a union of these for θ ≤ c ′ log n along with the hitting set of [12] Step 2: We will plug in a pairwise independent space in each bucket. Let G m,n 2−wise : {0, 1} s → [m] n denote the generator of a pairwise independent space. Note that the seed-length for any bucket is s = O(log n) 5 .
Step 3: The seed for the first bucket is chosen uniformly at random and seeds for the subsequent buckets are chosen by a walk on expanders with varying degrees. For each i ∈ [θ] we choose every possible η ′ i such that 1/η ′ i is a power of 2 and i η ′ i ≥ 1/n Oc(1) , where the constant implicit in the O c (1) will become clear in the analysis of the construction below. There are at most poly(n) such choices for all η ′ i 's in total. We then take a (2 s , d i , λ i )-expander H i on vertices {0, 1} s with degree d i = poly(1/(η ′ i η ′ i−1 )) and λ i ≤ η ′ i η ′ i−1 /100 (by Fact 2.9, such explicit expanders exist). Now for any u ∈ {0, 1} s , {y i ∈ [d i ]} θ i=1 , let (u, y 1 , . . . , y θ ) ∈ W(H 1 , . . . , H θ ) be a θ-step walk. For all starting seeds z 0 ∈ {0, 1} s and all possible where the c ′ log n factor is due to the choice of θ, the n Oc(1) factor is due to the size of the perfect hash family, the number of choices of (η ′ 1 , . . . , η ′ θ ), and the choice of the first seed, and an additional n O(1) · i d i factor is the number of expander walks. Simplifying, |S n,c low,1 | = n Oc (1) (1) , where the last inequality is due to the choice of η ′ i 's.
Analysis. We follow the outline. First, by a union bound we know that P x∼[m] n [T + θ (x) = 1] ≤ |S|=θ i∈S p i and hence |S|=θ i∈S p i ≥ ε. Second, if we hash the indices [n] into θ buckets at random and consider one S with |S| = θ, the probability that the indices in S are 'uniformly spread' (one into each bucket) is 1/2 O(θ) . By Lemma 2.12, this property is also true if we pick h from the explicit perfect hash family H n,θ perf . Formally, given an h ∈ H n,θ perf , define α h = i∈[θ] j∈B i p j . Over a uniform choice of h from the family H n,θ perf , we can conclude that Thus there must exist an h that satisfies α h ≥ 1/n Oc (1) .
We fix such an h. For a bucket B i , define . Now for a moment, let us analyze the construction assuming independently seeded pairwise independent spaces in each bucket. Then the success probability, namely the probability that every bucket B i has a non-zero j∈B i 1 A j (x j ) is equal to i η i . The following claim gives a lower bound on this probability. Proof. For a bucket B i , define µ i = j∈B i p j . Further, call a bucket B i as being good if µ i ≤ 1/2, otherwise call the bucket bad. For the bad buckets, From the choice of h and the definition of α h we have 1 where we have used Equation (2) for the second inequality. Now let's analyze the η i 's. For a good bucket B i , by inclusion-exclusion, For a bad bucket, µ i > 1/2. But since all p i 's are ≤ 1/2, it isn't hard to see that there must exist a non empty subset B ′ i ⊂ B i satisfying 1/4 ≤ µ ′ i := j∈B ′ i p j ≤ 1/2. We now can use Equation (4) on the good bucket B ′ i to get the bound on the bad bucket B i as follows: So finally, where we have used (4) and (5) for the first inequality and (3) for the second inequality.
If now the seeds for G m,n 2−wise in each bucket are chosen according to the expander walk "corresponding" to the probability vector (η 1 , . . . , η θ ), then by Lemma 2.10 the success probability becomes at least (1/2 O(θ) ) i η i ≥ 1/n Oc(1) , using Claim 4.9 for the final inequality.
But we are not done yet. We cannot guess the correct probability vector exactly. Instead, we get a closest guess (η ′ 1 , . . . , η ′ θ ) such that for all i ∈ [θ], 1/η ′ i is a power of 2 and η ′ i ≥ η i /2. Again, by Lemma 2.10 the success probability becomes at least ( (1) , using Claim 4.9 for the final inequality. Note that this also tells us that it is sufficient to guess η ′ i such that i (1/η ′ i ) ≤ n Oc(1) .

The general low-weight case
The general case (where p i are arbitrary) is more technical: here we need to do a "two level" hashing. The top level is by dividing into buckets, and in each bucket we get the desired "advantage" using a generalization of hitting sets for combinatorial rectangles (which itself uses hashing) from [12]. The theorem we prove for this case can be stated as follows. Construction. We describe S n,c low by demonstrating how to sample a random element x of this set. The number of possible random choices bounds |S n,c low |. We define the sampling process in terms of certain constants c i (i ∈ [5]) that depend on c in a way that will become clear later in the proof. Assuming this, it will be clear that |S n,c low | = n Oc(1) .
Step 1: Choose at random t ∈ {0, . . . , 15c log n}. If t = 0, then we simply output a random element x of S m,n,1/n c 1 LLSZ for some constant c 1 . The number of choices for t is O c (log n) and if t = 0, the number of choices for x is n Oc (1) . The number of choices for non-zero t are bounded subsequently.
Step 2: Choose h ∈ H n,t perf uniformly at random. The number of choices for h is n Oc(1) · 2 O(t) = n Oc(1) .
Step 3: Choose at random non-negative integers ρ 1 , . . . , ρ t and a 1 , . . . , a t s.t. i ρ i ≤ c 2 log n and i a i ≤ c 3 log n. For any constants c 2 and c 3 , the number of choices for ρ 1 , . . . , ρ t and a 1 , . . . , a t is n Oc(1) .
Step 4: Choose a set V s.t. |V | = n Oc(1) = N and identify V with S n,c 4 ,ρ i rect for some constant c 4 ≥ 1 and each i ∈ [t] in some arbitrary way (we assume w.l.o.g. that the sets S n,c 4 ,ρ i rect (i ∈ [t]) all have the same size). Fix a sequence of expander graphs (G 1 , . . . , G t ) with vertex set V where G i is an (N, D i , λ i )-expander with λ i ≤ 1/(10 · 2 a i · 2 a i+1 ) and D i = 2 O(a i +a i+1 ) (this is possible by Fact 2.9). Choose w ∈ W(G 1 , . . . , G t ) uniformly at random.
The total number of choices in this step is bounded by |W(G 1 , . . Thus, the number of random choices (and hence |S n,c low |) is at most n Oc(1) .
Analysis. We will now prove Theorem 4.10. The analysis once again follows the outline of Section 4.2. For brevity, we will denote S n,c low by S. Fix any A 1 , . . . , A n ⊆ [m] and a threshold test f ∈ CThr(m, n) such that f (x) := T + θ ( i∈[n] 1 A i (x i )) for some θ ∈ N (we can analyze combinatorial thresholds f that use thresholds of the form T − θ in a symmetric way). We assume that f has low-weight and good acceptance probability on uniformly random input: that is, w(f ) ≤ c log n and P x∈[m] n [f (x) = 1] ≥ 1/n c . For each i ∈ [n], let p i denote |A i |/m and q i denote 1 − p i . We call A i small if p i ≤ 1/2 and large otherwise. Let S = {i | A i small} and L = [n] \ S. Note that for any x. We would like to show that P x∈S [f (x) = 1] > 0. Instead we show the following stronger statement: To do this, we first need the following simple claim.
We lower bound each term separately by 1/n O(c) .
To bound the first term, note that P x∈[m] n Z(x) = 0 = i∈L (1 − q i ) = exp{−O( i∈L q i )} where the last inequality follows from the fact that q i < 1/2 for each i ∈ L and (1 − x) ≥ e −2x for x ∈ [0, 1/2]. Now, since each q i < 1/2, we have w i ≤ 2q i for each i ∈ L and hence, i∈L q i = O(w(f )) = O(c log n). The lower bound on the first term follows.
To bound the second term, we note that This proves the claim.
To show that P x∈S Z(x) = 0 ∧ Y (x) ≥ θ − |L| > 0, we define a sequence of "good" events whose conjunction occurs with positive probability and which together imply that Z(x) = 0 and ) accepts a uniformly random x with probability at least 1/n c , we have by Chernoff bounds, we must have we see that θ − |L| ≤ 12c log n and hence, there is some choice of t in Step 1 so that E 1 occurs. We condition on this choice of t. Note that by Claim 4.11, we have P x∈[m] n Z(x) = 0 ∧ Y (x) ≥ t ≥ 1/n c 1 . If t = 0, then the condition that Y (x) ≥ t is trivial and hence the above event reduces to Z(x) = 0, which is just a combinatorial rectangle and hence, there is an x ∈ S m,n,1/n c 1 LLSZ with f (x) = 1 and we are done. Therefore, for the rest of the proof we assume that t ≥ 1.
Event E 2 : Given h ∈ H n,t perf , define α h to be the quantity i∈ (by union bound) Event E 2 is simply that α h ≥ 1/n c ′ 1 . By averaging, there is such a choice of h. Fix such a choice. Event E 3 : We say that this event occurs if for each i ∈ [t], we have ρ i = ⌈ j∈h −1 (i)∩S p j + k∈h −1 (i)∩S q k ⌉ + 1. To see that this event can occur, we only need to verify that for this choice of ρ i , we have i ρ i ≤ c 2 log n for a suitable constant c 2 depending on c. But this straightaway follows from the fact that j∈S p j + k∈L q k ≤ 2w(f ) ≤ 2c log n. Fix this choice of ρ i (i ∈ [t]).
To show that there is an x ∈ S s.t. Z(x) = 0 and Y (x) ≥ t, our aim is to show that there is an To show that this occurs, we first need the following claim. Proof of Claim 4.12. We assume that p j > 0 for every j ∈ h −1 (i) ∩ S (the other j do not contribute anything to the right hand side of the inequality above). The claim follows from the fact that the event However, by our choice of ρ i , we know that ρ i ≥ j∈h −1 (i)∩S p j + k∈h −1 (i)∩S q k + 1, which is at least the sum of the rejecting probabilities of each combinatorial rectangle R j above. Moreover, ρ i ≤ s∈[t] ρ t ≤ c 2 log n. Below, we choose c 4 ≥ c 2 and so we have ρ i ≤ c 4 log n.
The above claim immediately shows that if we plug in independent x (i) chosen at random from S n,c 4 ,ρ i rect in the indices in h −1 (i), then the probability that we pick an x such that Z(x) = 0 and Y (x) ≥ t is at least However, the x (i) we actually choose are not independent but picked according to a random walk w ∈ W(G 1 , . . . , G t ). But by Lemma 2.10, we see that for this event to occur with positive probability, it suffices to have To satisfy this, it suffices to have 1/2 a i ≤ p ′ i ≤ 1/2 a i −1 for each i. This is exactly the definition of the event E 4 . Event E 4 : For each i ∈ [t], we have 1/2 a i ≤ p ′ i ≤ 1/2 a i −1 . For this to occur with positive probability, we only need to check that i∈[t] ⌈log(1/p ′ i )⌉ ≤ c 3 log n for large enough constant c 3 . But from (7), we have

Stronger Hitting sets for Combinatorial Rectangles
As mentioned in the introduction, [12] give ε-hitting set constructions for combinatorial rectangles, even for ε = 1/poly(n). However in our applications, we require something slightly stronger -in particular, we need a set S s.t. P x∼S (x in the rectangle) ≥ ε (roughly speaking). We however need to fool only special kinds of rectangles, given by the two conditions in the following theorem. there is an explicit set S n,c,ρ rect of size n Oc(1) that satisfies P x∼S n,c,ρ rect [R(x) = 1] ≥ p/2 Oc(ρ) . To outline the construction, we keep in mind a rectangle R (though we will not use it, of course) defined by sets A i , and write p i = |A i |/m, q i = 1 − p i . W.l.o.g., we assume that ρ ≥ 10. The outline of the construction is as follows: 1. We guess an integer r ≤ ρ/10 (supposed to be an estimate for i q i /10).
2. Then we use a fractional hash family H n,r f rac to map the indices into r buckets. This ensures that each bucket has roughly a constant weight.
3. In each bucket, we show that taking O(1)-wise independent spaces (Fact 2.7) ensures a success probability (i.e. the probability of being inside R) depending on the weight of the bucket.
4. We then combine the distributions for different buckets using expander walks (this step has to be done with more care now, since the probabilities are different across buckets).
Steps (1) and (2) are simple: we try all choices of r, and the 'right' one for the hashing in step (2) to work is r = i q i /10; the probability that we make this correct guess is at least 1/ρ ≫ 1/2 ρ . In this case, by the fractional hashing lemma, we obtain a hash family H n,r f rac , which has the property that for an h drawn from it, we have Step (3) is crucial, and we prove the following: There is an absolute constant a ∈ N s.t. the following holds. Let A 1 , . . . , A k be the accepting sets of a combinatorial rectangle R in CRect(m, k), and let q 1 , . . . , q k be rejecting probabilities as defined earlier, with i q i ≤ C, for some constant C ≥ 1. Suppose i (1 − q i ) = π, for some π > 0. Let S be the support of an aC-wise independent distribution on [m] n (in the sense of Fact 2.7). Then Proof. We observe that if i q i ≤ C, then at most 2C of the q i are ≥ 1/2. Let B (for 'big') denote the set of such indices. Now consider S, an aC-wise independent distribution over [m] n . Let us restrict to the vectors in the distribution for which the coordinates corresponding to B are in the rectangle R. Because the family is aC-wise independent, the number of such vectors is precisely a factor i∈B (1 − q i ) of the support of S. Now, even after fixing the values at the locations indexed by B, the chosen vectors still form a (a − 2)C-wise independent distribution. Thus by Theorem 2.8, we have that the distribution δ-approximates, i.e., maintains the probability of any event (in particular the event that we are in the rectangle R) to an additive error of δ = 2 −Ω((a−2)C) < (1/2)e −2 i q i < (1/2) i ∈B (1 − q i ) for large enough a (In the last step, we used the fact that if x < 1/2, then (1 − x) > e −2x ). Thus if we restrict to coordinates outside B, we have that the probability that these indices are 'accepting' for R is at least (1/2) i ∈B p i (because we have a very good additive approximation).
Combining the two, we get that the overall accepting probability is π 2 , finishing the proof of the claim.
Let us now see how the claim fits into the argument. Let B 1 , . . . , B r be the sets of indices of the buckets obtained in Step (2). Claim 5.2 now implies that if we pick an aC-wise independent family on all the n positions (call this S), the probability that we obtain a rectangle on B i is at least (1/2) j∈B i (1 − q j ). For convenience, let us write P i = (1/2) j∈B i (1 − q j ). We wish to use an expander walk argument as before -however this time the probabilities P i of success are different across the buckets.
The idea is to estimate P i for each i, up to a sufficiently small error. Let us define L = ⌈c log n⌉ (where p is as in the statement of Theorem 2.6). Note that L ≥ log(1/p), since p ≥ 1/n c . Now, we estimate log(1/P i ) by the smallest integer multiple of L ′ := ⌊L/r⌋ ≥ 10 which is larger than it: call it α i · L ′ . Since i log(1/P i ) is at most L, we have i α i L ′ ≤ 2L, or i α i ≤ 3r. Since the sum is over r indices, there are at most 2 O(r) choices for the α i we need to consider. Each choice of the α i 's gives an estimate for P i (which is also a lower bound on P i ). More formally, set ρ i = e −α i L ′ , so we have P i ≥ ρ i for all i.
Finally, let us construct graphs G i (for 1 ≤ i ≤ r) with the vertex set being S (the aC-wise independent family), and G i having a degree depending on ρ i (we do this for each choice of the ρ i 's). By the expander walk lemma 2.10, we obtain an overall probability of success of at least i P i /2 O(r) for the "right" choice of the ρ i 's. Since our choice is right with probability at least 2 −O(r) , we obtain a success probability in Steps (3) and (4) . In combination with the success probability of 1/2 Oc(ρ) above for Steps (1) and (2), this gives us the claimed overall success probability.
Finally, we note that the total seed length we have used in the process is O c (log n+ i log(1/ρ i )), which can be upper bounded by O c (log n + L) = O c (log n).

Constructing a Fractional Perfect Hash family
The first step in all of our constructions has been hashing into a smaller number of buckets. To this effect, we need an explicit construction of hash families which have several "good" properties. In particular, we will prove the following lemma in this section.
Proof. For S ⊆ [n], we define z(S) to be j∈S z j . By assumption, we have z([n]) ≥ 10t. Without loss of generality, we assume that z([n]) = 10t (otherwise, we work withz = (10t/z([n]))z which satisfies this property; since we prove the lemma forz, it is true for z as well). We thus need to construct H n,t f rac such that for some constant c f rac > 0.
We describe the formal construction by describing how to sample a random element h of H n,t f rac . To sample a random h ∈ H n,t f rac , we do the following: Step 1 (Top-level hashing): We choose a pairwise independent hash function h 1 : [n] → [10t] by choosing a random seed to generator G t,n 2−wise . By Fact 2.7, this requires O(log n + log t) = O(log n) bits.
Step 2 (Guessing bucket sizes): We choose at random a subset I ′ ⊆ [10t] of size exactly t and y 1 , . . . , y 10t ∈ N so that i y i ≤ 30t. It can be checked that the number of possibilities for I ′ and y 1 , . . . , y 10t is only 2 O(t) .
Step 4 (Folding): This step is completely deterministic given the random choices made in the previous steps. We fix an arbitrary map f : otherwise.
It is easy to check that |H n,t f rac |, which is the number of possibilities for the random choices made in the above steps, is bounded by 2 O(t) n O(1) , exactly as required.
We now show that a random h ∈ H n,t f rac has the properties stated in the lemma. Assume h is sampled as above. We analyze the construction step-by-step. First, we recall the following easy consequence of the Paley-Zygmund inequality: Fact 6.2. For any non-negative random variable Z we have Consider h 1 sampled in the first step. Define, for each i ∈ [30t], the random variables Let E 1 denote the event that Y ≤ 20t. By Markov's inequality, this happens with probability at least 1/2. We condition on any choice of h 1 so that E 1 occurs. Note that in this case, we have X ≤ 10t + Y ≤ 30t. We now analyze the second step. We say that event E 2 holds if (a) I ′ contains only mediumsized buckets, and (b) for each i ∈ [t], y i = ⌈Y i ⌉. Since the number of random choices in Step 2 is only 2 O(t) and there are more than t many medium-sized buckets, it is clear that P [ We now condition on random choices in Step 2 so that both E 1 and E 2 occur.
For the third step, given i ∈ I ′ , we say that hash function h 2,i is collision-free if for each The following simple claim shows that this condition is implied by the condition that for each k, Y i,k := j 1 =j 2 ∈S i,k z j 1 z j 2 ≤ 2.
For the sake of analysis, assume first that the hash functions h 2,i (i ∈ [10t]) are chosen to be pairwise independent and independent of each other. Now fix any i ∈ [10t] and k ∈ [y i ]. Then, since h 2,i is chosen to be pairwise-independent, we have In particular, by Markov's inequality, P [Y i,k ≥ 2] ≤ 1/2y i . Thus, by a union bound over k, we see that the probability that a uniformly random pairwise independent hash function h 2,i is collisionfree is at least 1/2. Now, let us consider the hash functions h 2,i as defined in the above construction. Let E 3 denote the event that for each i ∈ I ′ , h 2,i is collision-free. Hence, by Lemma 2.10, we see that Thus, we have established that P [E 1 ∧ E 2 ∧ E 3 ] ≥ 1/2 O(t) . We now see that when these events occur, then the sampled h satisfies the properties we need. Fix such an h and consider i ∈ [t].
Since f is a bijection on I ′ × {0}, we see that there must be an i ′ ∈ I ′ s.t. f (i ′ ) = i. Since i ′ ∈ I ′ and the event E 2 occurs, it follows that i ′ is a medium-sized bucket. Thus, z(h −1 (i)) ≥ z(h −1 1 (i ′ )) ≥ 0.1. Secondly, since E 3 occurs, we have where the final inequality follows because E 3 holds. This shows that for each i, we have z(h −1 (i)) ∈ [0.1, 100] and hence h satisfies the required properties. This concludes the proof of the lemma.

Open Problems.
We have used a two-level hashing procedure to construct hitting sets for combinatorial thresholds of low weight. It would be nice to obtain a simpler construction avoiding the use of an 'inner' hitting set construction.
It would also be nice to extend our methods to weighted variants of combinatorial shapes: functions which accept an input x iff i α i 1 A i (x i ) = S where α i ∈ R ≥0 . The difficulty here is that having hitting sets for this sum being ≥ S and ≤ S do not imply a hitting set for '= S'. The simplest open case here is m = 2 and all A i being {1}. 6 However, it would also be interesting to prove formally that such weighted versions can capture much stronger computational classes.
A 1 A 2 . . . A ℓ 1 N , where 1 N denotes the vector (1/N, . . . , 1/N ), and A i is the normalized adjacency matrix of the graph G i . Now, we are interested in the probability that a walk satisfies the property that its ith vertex is in set V i for each i. For ℓ = 1, for example, this is precisely the L 1 weight of the set V 1 , in the vector A 1 1 N . More generally, suppose we define the operator I S to be one which takes a vector and returns the "restriction" to S (and puts zero everywhere else), we can write the probability as I V 1 A 1 1 N 1 . In general, it is easy to see that we can write the probability that the ith vertex in the walk is in V i for all 1 ≤ i ≤ t is precisely I Vt A t I V t−1 A t−1 . . . I V 1 A 1 1 . We will call the vector of interest u (t) , for convenience, and bound u (t) 1 inductively.
Intuitively, the idea will be to show that u (t) should be a vector with a 'reasonable mass', and is distributed 'roughly uniformly' on the set V t . Formally, we will show the following inductive statement. Define u (0) = 1 N .
Lemma A.2. For all 1 ≤ t ≤ ℓ, we have the following two conditions Note that the second equation informally says that the mass of u (t) is distributed roughly equally on a set of size p t N . The proof is by induction, but we will need a bit of simple notation before we start. Let us define u and u ⊥ to be the components of a vector u which are parallel and perpendicular (respectively) to the vector 1 N . Thus we have u = u + u ⊥ for all u. The following lemma is easy to see. Proof. The "furthermore" part is by the definition of x , and the first part follows directly from it.
We can now prove Lemma A.2. We will use the fact that A i 1 N = 1 N for each i, and that A i u 2 ≤ λ u 2 for u orthogonal to 1 N .
Proof of Lemma A.2. For t = 1, we have u (1) = I V 1 A 1 1 N = I V 1 1 N , and thus we have u (1) 1 = p 1 , and we have u (1) 2 = p 1 √ p 1 N , and thus the claims are true for t = 1. Now suppose t ≥ 2, and that they are true for t − 1.
For the first part, we observe that The first term is equal to I Vt u (t−1) 1 = p t u (t−1) 1 , because I Vt preserves p t N indices, and each has a contribution of u (t−1) 1 /N , by Claim A.3. The second term can be upper bounded as where we used the inductive hypothesis in the last step. From the condition λ t ≤ p t p t−1 /8, we have that the term above is bounded above by p t u (t−1) 1 /4. Combining this with Eq.(11), the first inequality follows. The second inequality is proved similarly. Note that for this part we can even assume the first inequality for t, i.e., u (t) 1 ≥ (3/4)p t u (t−1) 1 . We will call this (*).
The first term is the ℓ 2 norm of a vector with support V t , and each entry u (t−1) 1 /N , from Claim A.3 we have that the first term is equal to ptN , with the inequality following from (*).
The second term can be bounded by Here we first used the inductive hypothesis, and then used (*), along with our choice of λ t . Plugging these into Eq. (12), we obtain the second inequality. This completes the inductive proof of the two inequalities.