The Power of Test-Time Training for Approximate Sampling

Noah Golowich
Microsoft Research NYC
nzg@cs.utexas.edu

,

Ankur Moitra
MIT
moitra@mit.edu

,

Dhruv Rohatgi
MIT
drohatgi@mit.edu


Abstract

Efficiently sampling from a complex probability distribution is a fundamental problem across machine learning and theoretical computer science. It has become increasingly pertinent in recent years with the rise of generative AI, as sophisticated sampling procedures from large language models (LLMs) have been proposed to solve challenging reasoning problems spanning domains such as mathematics and coding. The efficacy of such sampling algorithms is limited, however, by the relationship between the LLM and the particular sampling task at hand, which has motivated the framework of test-time training (TTT). TTT works by updating a model’s weights in response to partial generations and reward feedback received at inference time, thus adapting to the particular problem. In this work, we propose a formalization for TTT as the problem of producing a sample from a given probability measure \(\mu^\star\) belonging to a known class \(\mathcal{F}\) of distributions, given an oracle \(\hat{\mu}\) which yields approximate density estimates for \(\mu^\star\). As it turns out, this is closely related to the problem of reducing sampling to approximate counting studied in seminal works of Jerrum, Valiant & Vazirani (1986) and Jerrum & Sinclair (1989): namely, when \(\mathcal{F}\) is the class of all distributions, it coincides exactly with the aforementioned counting-to-sampling reduction.

In this paper, we first show a quadratic lower bound on the query complexity of sampling from \(\mu^\star\) given query access to \(\hat{\mu}\) (which holds for sufficiently large classes \(\mathcal{F}\)), thus showing that the random walk approach proposed by Jerrum & Sinclair (1989), and later refined by Hayes & Sinclair (2010), is optimal. This result answers an open question explicitly posed by Hayes & Sinclair. We then show that this lower bound can be circumvented if the size of \(\mathcal{F}\) is bounded appropriately. As we discuss, this latter result can be viewed as an abstraction of TTT, and thus represents a starting point for the development of a principled theoretical framework for TTT.

1 Introduction↩︎

Efficiently sampling from a given probability distribution is a central problem in a number of areas spanning machine learning, artificial intelligence, and theoretical computer science. Recently, generative AI has enabled sampling from natural yet highly complex distributions. As some examples, diffusion models [1][3] enable sampling from a distribution over images via an iterative denoising process; and autoregressive large language models (LLMs) [4][6] enable generating text by repeatedly sampling the next token conditioned on all previous tokens. Each of these architectures was designed to be used with a specific sampling procedure. However, recent efforts have focused on more complex sampling procedures — e.g., generating multiple strings of text in parallel, or going back and revising generated text — which can produce samples from the model which are superior according to some metric. For instance, one might desire text written in a certain style, or to sample from the distribution of solutions to a math problem conditioned on them being correct.

1.0.0.1 From inference to test-time training.

A number of heuristic approaches have been proposed for these problems: they typically make many queries to a base (or reference) model \(\pi_{\mathsf{ref}}\), as well as to an additional reward model \(\hat{V}\), which at a high level provides information about the quality of complete or partial generations. For instance, in settings such as math or coding where answers can be verified, \(\hat{V}\) may directly assign a reward to proposed solutions [7][9], or more generally \(\hat{V}\) itself may be a model which is trained to score partial generations (in this context, it is often referred to as a process reward model (PRM)) [10][15]. In this paper we focus on the case where \(\pi_{\mathsf{ref}}\) is a language model, though similar frameworks can apply for other settings such as diffusion models.

While such approaches have shown promising performance, their efficacy is limited by the quality of the reference model \(\pi_{\mathsf{ref}}\). If the distribution of generations from \(\pi_{\mathsf{ref}}\) is far from the desired target distribution, then the number of queries to \(\pi_{\mathsf{ref}}\) and \(\hat{V}\) needed to obtain satisfactory samples may be prohibitively large. For instance, \(\pi_{\mathsf{ref}}\) may have been trained to solve general math problems, but if the desired target distribution is over solutions to a particular combinatorics conjecture, then \(\pi_{\mathsf{ref}}\) may suggest many approaches which are unlikely to work in that area of combinatorics.

To help to mitigate this issue, a recent line of work has studied test-time training (TTT), which proposes to update the weights of the base model \(\pi_{\mathsf{ref}}\) at inference time, using partial generations produced by \(\pi_{\mathsf{ref}}\) as well as feedback from \(\hat{V}\) [16][19].1 The hope is that this feedback will push \(\pi_{\mathsf{ref}}\) to be “closer” to the particular target distribution. In many such cases, TTT achieves impressive performance, beating the performance of existing sampling approaches which held the weights of the reference model \(\pi_{\mathsf{ref}}\) fixed. For instance, reinforcement learning at test time [8] was used in AlphaProof [20], which was the first model to achieve silver-level performance at the IMO; [7] achieved state-of-the art performance using TTT for a number of open mathematics and engineering problems.

In the coming years it is likely that language models will be used to solve even more challenging problems by investing large amounts of compute, and test-time training is at the forefront of techniques which will drive success in this endeavor. That said, for the most part the literature lacks a principled theoretical framework for reasoning about how test-time training works and in what manner it can lead to improved or more efficient sampling. In this work, we aim to fill this gap.

1.1 A framework for TTT in the context of LLM inference↩︎

We develop a formalization for TTT by viewing the sampling problem discussed above as that of tilting the output distribution of the reference language model, a common setting in the literature [12], [21][23].2 In particular, we suppose we are given a reference model \(\pi_{\mathsf{ref}}\in \Delta(\Sigma^n)\), which is an autoregressive language model on sequences of length \(n\): this means that for any partial sequence \(x_{1:i} = (x_1, \ldots, x_i) \in \Sigma^i\) (for \(i \leq n\)), we can query \(\pi_{\mathsf{ref}}\) for the conditional distribution of the last token given the previous ones, i.e., \(\pi_{\mathsf{ref}}(x_i \mid x_{1:i-1})\).3 We are also given a value function \(V^\star : \Sigma^n \to \mathbb{R}\), which assigns a “quality score” to each full sequence: for instance, \(V^\star(x)\) might score the style of \(x\) or its mathematical correctness. Our goal is to sample from the tilted distribution \(\mu^\star \in \Delta(\Sigma^n)\) obtained by reweighting \(\pi_{\mathsf{ref}}\) according to the exponentiated value function, defined by \[\begin{align} \mu^\star(x) := \frac{1}{Z} \pi_{\mathsf{ref}}(x) \cdot \exp( V^\star(x)), \qquad Z = \mathbb{E}_{x \sim \pi_{\mathsf{ref}}}[\exp(V^\star(x))].\label{eq:mustar-tilted-piref} \end{align}\tag{1}\]

1.1.0.1 Sampling from \(\mu^\star\) via a PRM.

We extend the domain of \(V^\star\) to all partial sequences (namely, to \(\Sigma^{\leq n}\), which we let denote the set of sequences of elements in \(\Sigma\) of length at most \(n\)) by letting \(V^\star(x_{1:i})\) be the log-expectation of the score of a full sequence starting with \(x_{1:i}\): namely, for \(x_{1:i} \in \Sigma^i\), we define \[\begin{align} V^\star(x_{1:i}) = \log \mathbb{E}_{x_{i+1:n} \sim \pi_{\mathsf{ref}}(\cdot \mid x_{1:i})}[\exp(V^\star(x_{1:n}))]\nonumber. \end{align}\] Roughly speaking, \(V^\star(x_{1:i})\) should be interpreted as a measure of how likely we are to achieve a high overall value if we generate a full sequence under \(\pi_{\mathsf{ref}}\), starting from \(x_{1:i}\). While sampling from the tilted measure \(\mu^\star\) without any guidance is typically intractable, it becomes tractable (specifically, can be solved in linear time in \(n\)) if we are given exact query access to \(V^\star\) on all partial sequences [12], [25].

Of course, exactly querying \(V^\star\) on a partial sequence is itself typically an intractable problem. A more reasonable assumption is that we are given approximate query access to \(V^\star\) on all partial sequences. A great deal of effort has gone into finding such \(\hat{V}\); depending on the context, they may be referred to as KL-regularized value functions [12], [22] or process reward models (PRMs) [10][15]. In particular, recent theoretical literature [12], [15], [26] assumes that we can query a mapping \(\hat{V} : \Sigma^{\leq n} \to \mathbb{R}\), so that, for some error \(\rho > 0\), we have \(|\hat{V}(x_{1:i}) - V^\star(x_{1:i})| \leq \rho\) for all sequences \(x_{1:i} \in \Sigma^i\) (\(i \in [n]\)).45

The below question captures the problem of sampling from the tilted measure \(\mu^\star\), using query access to \(\pi_{\mathsf{ref}}\) and \(\hat{V}\), without doing any TTT:

Question 1 (Sampling without TTT). In the above setting, what is the minimum number of queries to \(\pi_{\mathsf{ref}}\) and \(\hat{V}\) which are needed to produce a single sample from \(\mu^\star\) (perhaps approximately so)?

1.1.0.2 Sampling with TTT.

How can we effectively model TTT approaches which update the weights of the model \(\pi_{\mathsf{ref}}\) at inference time? In general, such approaches should be seen as attempting to learn the distribution \(\mu^\star \propto \pi_{\mathsf{ref}}\cdot V^\star\) — not in its entirety, but at least well enough so as to generate a single sample from it. Any potential benefit of TTT must stem from the inductive bias of the model architecture, i.e. the fact that updating the weights of the model is more structured than directly updating the distribution, and therefore may enable more generalizable learning.

Inspired by statistical learning theory, we therefore formalize test-time training as making an additional assumption that \(\mu^\star\) lies in a restricted class of models — or equivalently (since \(\pi_{\mathsf{ref}}\) is fixed), that \(V^\star\) lies in some known class \(\mathcal{V}\) consisting of functions \(V : \Sigma^n \to \mathbb{R}\). Thus, the question of sampling from \(\mu^\star\) with TTT may be phrased as follows:

Question 2 (Sampling with TTT). Suppose we are given a class \(\mathcal{V}\) of mappings \(V : \Sigma^{\leq n} \to \mathbb{R}\), with the promise that \(V^\star \in \mathcal{V}\). Using knowledge of \(\mathcal{V}\), what is the minimum number of queries to \(\pi_{\mathsf{ref}}\) and \(\hat{V}\) which are needed to produce a single (approximate) sample from \(\mu^\star\)?

Comparing 1 and 2, the problem of determining when TTT is beneficial is as follows: How do structural conditions on the class \(\mathcal{V}\) affect the query complexity of sampling from \(\mu^\star\)? In particular, for what choices of \(\mathcal{V}\) is the query complexity of 2 smaller than that of 1? In this paper we show a positive answer to this second question when the cardinality of the class \(\mathcal{V}\) is not too large. There are a number of further structural conditions which may be placed on \(\mathcal{V}\), analogous to the vast literature in statistical learning theory which characterizes the sample complexity of learning infinite hypothesis classes satisfying various capacity constraints. We expect these will lead to a plethora of fruitful directions for follow-up work; see 1.4.

1.2 Interpretation in the context of counting-to-sampling reductions↩︎

Beyond the motivation from recent progress in generative AI, our setting can be cast in the framework of a rich body of historical work in theoretical computer science on sampling algorithms. To explain this connection, we consider a slight rephrasing of the setting of 1.1. Namely, for \(x_{1:i} \in \Sigma^i\), we define \[\begin{align} \hat{\mu}(x_{1:i}) := \frac{1}{Z} \cdot \pi_{\mathsf{ref}}(x_{1:i}) \cdot \exp (\hat{V}(x_{1:i})) \label{eq:define-hatmu}. \end{align}\tag{2}\] It is straightforward to see that the marginal of \(\mu^\star\) on the first \(i\) coordinates, denoted \(\mu^\star(x_{1:i})\), satisfies \(\mu^\star(x_{1:i}) = \frac{1}{Z} \cdot \pi_{\mathsf{ref}}(x_{1:i}) \cdot \exp(V^\star(x_{1:i}))\), meaning that \(\hat{\mu}(x_{1:i})\) should be interpreted as an approximation of \(\mu^\star(x_{1:i})\) induced by \(\hat{V}\). Moreover, given a class \(\mathcal{V}\) of mappings \(V : \Sigma^n \to \mathbb{R}\) as above, let \(\mathcal{F}= \mathcal{F}_{\mathcal{V}} \subset \Delta(\Sigma^n)\) denote the class of distributions \[\begin{align} \mathcal{F}_{\mathcal{V}}: =\{ \pi_{\mathsf{ref}}\cdot \exp(V) \cdot Z_V^{-1} \mid V \in \mathcal{V}\}, \qquad Z_V = \mathbb{E}_{x \sim \pi_{\mathsf{ref}}}[\exp(V(x))]\label{eq:mf-mv}. \end{align}\tag{3}\] We now observe that the sampling problem in either 1 or 2 with respect to the target value function \(V^\star\) and the oracles \(\pi_{\mathsf{ref}}, \hat{V}\) is precisely an instance of the problem of sampling from \(\mu^\star\) given the ability to query the oracle \(\hat{\mu}\) (and in the case of 2, the knowledge that \(\mu^\star \in \mathcal{F}_{\mathcal{V}}\)). This observation is immediate from the definitions of \(\hat{\mu}\) and \(\mathcal{F}_{\mathcal{V}}\), save for one subtlety: per 2 , computing \(\hat{\mu}(x_{1:i})\) requires knowledge of \(Z\) in addition to the ability to query \(\pi_{\mathsf{ref}}\) and \(\hat{V}\), so it is not immediately evident that the two query models are equivalent. However, a key observation is that knowledge of \(Z\) is not required if the sampling algorithm which uses query access to \(\hat{\mu}\) is invariant under any rescaling of \(\hat{\mu}\). This will be the case for our algorithms (3), which treat the setting of having query access to \(\hat{\mu}\);6 thus they indeed can be simulated using query access to \(\pi_{\mathsf{ref}}\) and \(\hat{V}\), even without knowledge of \(Z\).7 See 10 for a formal statement of this equivalence.

In what sense is \(\hat{\mu}\) a good approximation of \(\mu^\star\)? The assumption that \(\| \hat{V} - V^\star\|_\infty \leq \rho\) and that \(\hat{V}(x) = V^\star(x)\) for \(x \in \Sigma^n\) from 1.1 implies that \(\hat{\mu}\) is an \(R\)-multiplicative approximation of \(\mu^\star\) with \(R = \exp(\rho)\), i.e., \[\begin{align} \frac{1}{R} \leq \frac{\mu^\star(x_{1:i})}{\hat{\mu}(x_{1:i})} \leq R \quad \text{for all } x_{1:i} = (x_1, \ldots, x_i) \in \Sigma^{i},\;i \leq n, \qquad \mu^\star(x) = \hat{\mu}(x) \text{ for all } x \in \Sigma^n.\label{eq:r-mult-intro} \end{align}\tag{4}\] For simplicity, we assume that \(R\) is a constant in this exposition. Thus, 1 may be rephrased as follows: Assuming 4 , how many queries to the oracle \(\hat{\mu}(\cdot)\) are needed to output a sample from a distribution \(\hat{\nu}\) which is close to \(\mu^\star\)? This question has a deep history pertaining to the algorithmic equivalence of sampling and approximate counting, as developed in seminal works of Jerrum, Valiant, and Vazirani [27] and Jerrum and Sinclair [28].8 This equivalence has been instrumental in the design of efficient randomized algorithms for a wide range of problems arising in combinatorics and statistical physics, including estimating the permanent of a nonnegative matrix [29], sampling proper colorings of graphs [30], [31], simulating the Ising and Potts models [32], [33], counting matchings [34], and sampling bases of matroids [35]. In more detail, under the assumption 4 , the mapping \(\hat{\mu} : \Sigma^{\leq n} \to \mathbb{R}_{\geq 0}\) may be viewed as an \(R\)-approximate counting oracle for the distribution \(\mu^\star\).9 The seminal work of Jerrum & Sinclair [28], which was later refined by Hayes & Sinclair [36], showed that \(\tilde{O}(n^2)\) queries to the counting oracle \(\hat{\mu}\) suffice to generate a sample from a distribution which is \(o(1)\)-close to \(\mu^\star\). The approach of [28], [36] relies on the clever idea of backtracking: we can try to sample a sequence \(x_1, x_2, x_3, \ldots\), character-by-character, by “pretending” that \(\hat{\mu}(\cdot)\) denotes the actual marginal probabilities of \(\mu^\star\). If at some point, we “make a mistake”, as evidenced by the fact that we have generated some sequence \(x_{1:i}\) for which \(\hat{\mu}(x_{1:i})\) is particularly small, then we can remove the most recently generated character, to yield the sequence \(x_{1:i-1}\), and continue. Formally, this process may be viewed as a random walk on the complete \(|\Sigma|\)-ary tree of depth \(n\), where edge weights are given by \(\hat{\mu}(\cdot)\).

In more recent years, a number of papers [15], [26], [37] have recovered the guarantee of [28], [36] that \(\tilde{O}(n^2)\) queries to \(\hat{\mu}\) suffice to approximately sample from \(\nu^\star\), using instead approaches from the family of of Sequential Monte Carlo (SMC) (i.e., particle filtering) algorithms. These approaches have the benefit that they can be parallelized, i.e., the queries can be arranged so that only \(\tilde{O}(n)\) rounds are needed where each round performs \(\tilde{O}(n)\) queries in parallel. Nevertheless, the total work remained as \(\tilde{O}(n^2)\), thus motivating the following question, which was explicitly posed by Hayes & Sinclair in 2010 [36]:

Question 3 ([36]). Is it possible to approximately sample from \(\mu^\star\) using \(o(n^2)\) queries to \(\hat{\mu}(\cdot)\) under the assumption 4 ?

In this paper, our first main result resolves 3 in the negative, giving a near-quadratic lower bound on the number of queries. As discussed above, such a lower bound also serves to show limits to what is possible for 1. This serves as motivation for test-time training: We proceed to show that this lower bound can be circumvented if the target distribution \(\mu^\star\) is known to belong to a structured class \(\mathcal{F}\) of distributions of bounded size, thus giving a positive answer to 2.

1.3 Results↩︎

1 below gives a negative answer to 3, showing that that the \(O(n^2)\) query complexity of the Jerrum-Sinclair algorithm [28], [36] is essentially optimal:

Theorem 1 (Main lower bound; informal version of 4). There is no algorithm which receives access to an oracle \(\hat{\mu} : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\) satisfying 4 with \(R = O(1)\) with respect to some unknown distribution \(\mu^\star \in \Delta(\{0,1\}^n)\), makes \(o(n^2 / \log^2 n)\) queries to \(\hat{\mu}(\cdot)\), and outputs a sample from a distribution \(\hat{\nu}\) satisfying \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \leq 1/10\).

Moreover, the same result holds even if \(\mu^\star\) is promised to be in a known class of densities of size at most \(\exp(\tilde{O}(n^4))\).

It is straightforward to see that, even in the case \(R = 1\) so that \(\hat{\mu} = \mu^\star\), any sampling algorithm requires \(\Omega(n)\) queries to \(\hat{\mu}\): this is evident by considering the case where \(\mu^\star\) is an unknown singleton in \(\{0,1\}^n\). Of course, when \(R = 1\), a sample from \(\mu^\star\) may be generated with exactly \(n\) queries to \(\hat{\mu}\) (simply by querying \(\hat{\mu} = \mu^\star\) coordinate-by-coordinate). Thus, one way to interpret 1 is that the price of approximation error in \(\hat{\mu}\) (or \(\hat{V}\) in the context of LLM inference) is that an additional \(\tilde{\Omega}(n)\) work must be paid “per-coordinate”.

Summarizing, 1 gives a limitation on what is possible in the context of 1, i.e., sampling from \(\mu^\star \propto \pi_{\mathsf{ref}}\cdot V^\star\) without TTT. What can we do with TTT, as captured by 2? Here we assume \(V^\star \in \mathcal{V}\) for some class \(\mathcal{V}\), which is equivalent to the knowledge that \(\mu^\star \in \mathcal{F}\) for some known class \(\mathcal{F}\) (see 3 ).10 Of course, the assumption that \(\mu^\star \in \mathcal{F}\) is only useful if we control the complexity of \(\mathcal{F}\): below, we show that as long as \(|\mathcal{F}| \leq \exp(o(n^2))\), then we can sample from \(\mu^\star\) using sub-quadratically many queries to \(\hat{\mu}\):

Theorem 2 (Main upper bound; simplified version of 3). Fix \(n \in \mathbb{N}\), \(\delta \in (0,1)\), an alphabet \(\Sigma\), and a (known) class of probability distributions \(\mathcal{F}\) on \(\Sigma^n\). Also fix any \(\mu^\star \in \mathcal{F}\) (unknown to the algorithm) as well as any mapping \(\hat{\mu}\) satisfying 4 with respect to \(\mu^\star\), for some parameter \(R \geq 1\). Then there is an algorithm (3) which makes at most \(|\Sigma|n \cdot \sqrt{\log|\mathcal{F}|} \cdot \mathop{\mathrm{poly}}(R, \log \frac{1}{\delta}, \log\log |\mathcal{F}|)\) queries to \(\hat{\mu}(\cdot)\) and outputs a sample \(X \in \Sigma^n\) according to some distribution \(\hat{\nu}\), which satisfies \(D_{\mathsf{TV}}({\hat{\nu}}, {\mu^\star}) \leq \delta\).

We remark that there is a gap between 1 2 in terms of the quantitative dependence on \(\log |\mathcal{F}|\): for a class \(\mathcal{F}\) of size \(\exp(n^2)\), 2 gives a quadratic upper bound, whereas 1 requires a class \(\mathcal{F}\) of size \(\exp(n^4)\) in order to obtain a quadratic lower bound. We view closing this gap as an intruiging direction for future work. In 8, we establish a generalization of 1, showing that for any “size parameter” \(S \leq \exp(O(n^4))\), there is a class \(\mathcal{F}\) of size \(|\mathcal{F}| \leq S\) so that any sampling algorithm requires \(\tilde{\Omega}(\sqrt{\log S})\) queries to \(\hat{\mu}\). As discussed below, finding the “right” dependence of the query complexity on \(|\mathcal{F}|\) and \(n\) remains open.

1.3.0.1 Takeaways for test-time training.

2 implies that as long as the class \(\mathcal{F}\) is not too large, then knowledge of it may effectively be leveraged to sample more efficiently from \(\mu^\star\) than what would be possible without knowledge of \(\mathcal{F}\). This gives an answer to our discussion following 2, on understanding under what conditions TTT is beneficial. Furthermore, we remark that the algorithm establishing 2 repeatedly generates partial samples from a “reference” distribution over \(\Delta(\Sigma^n)\), and periodically updates the “reference” distribution in response to feedback from \(\hat{\mu}\). This process is analogous to how TTT approaches update the reference model’s weights at inference time; see 2.1 for further details.

1.4 Discussion & Future Work↩︎

We view our results as only the beginning for a richer theoretical development of TTT. We elaborate on some directions for follow-up work below.

1.4.0.1 Tight quantitative bounds.

As discussed above, there is a quantitative gap between 1 and 2 in terms of the dependence on \(|\mathcal{F}|\). In general, it would be interesting to determine the following:

Problem 4. Supposing \(R, |\Sigma|, \delta\) are constants, what is the optimal function \(f(n, |\mathcal{F}|)\) so that \(f(n, |\mathcal{F}|)\) queries to an oracle \(\hat{\mu}\) (satisfying 4 ) are sufficient to approximately sample from \(\mu^\star\), given that \(\mu^\star \in \mathcal{F}\)?

We have shown that \(f(n, |\mathcal{F}|) = \tilde{O}(n \sqrt{\log |\mathcal{F}|})\) suffices, and that \(f(n, |\mathcal{F}|) = \tilde{\Omega}(\sqrt{\log |\mathcal{F}|})\) is necessary.

1.4.0.2 Richer complexity measures for \(\mathcal{F}\).

Viewed from the lens of statistical learning theory, our results, which obtain bounds for test-time training based on the cardinality of the class of distributions \(\mathcal{F}\), are only scratching the surface. A number of papers have developed combinatorial, geometric, and information-theoretic measures which capture learnability in a range of settings, such as i.i.d. learning, online learning, and reinforcement learning [38][40]. Thus, a pertinent question is:

Problem 5. What more fine-grained complexity measures of the class \(\mathcal{F}\) can be used to obtain refined bounds for the query complexity of sampling from \(\mu^\star \in \mathcal{F}\)?

1.4.0.3 Weaker assumptions on \(\hat{\mu}\).

The recent work of [15] showed that the \(\tilde{O}(n^2)\) query complexity upper bounds for SMC-based sampling approaches extend to the setting where one relaxes the \(L_\infty\) type assumption of 4 which requires that \(\hat{\mu}\) and \(\mu^\star\) are close on all partial sequences. In particular, it suffices that \(\hat{\mu}\) is close to \(\mu^\star\) on average over partial sequences, in an appropriate sense. Can the upper bound of 2 be extended to such a setting?

1.4.0.4 Computational efficiency and empirical implications.

Finally, we remark that the test-time training algorithm developed for the proof of 2 (namely, 3 2) is query-efficient but computationally inefficient, since it requires explicit enumeration over the class \(\mathcal{F}\). It would be interesting to empirically investigate whether the algorithmic ideas (e.g. the pruning or importance-weighting steps in 2) can be translated into practical algorithms. Towards this end, an important stepping stone may be developing algorithms in our framework that are also oracle-efficient, i.e. computationally efficient assuming access to certain optimization oracles for \(\mathcal{F}\).

2 Technical Overview↩︎

In 2.1, we discuss the proof of 2, and in 2.2, we discuss the proof of 1.

2.1 Upper bound↩︎

Figure 1: Basic Sampling

We begin by giving a very simple algorithm which proves a quantitatively weaker version of 2; we will then discuss the full algorithm and its analysis in more detail.

2.1.0.1 Warmup: a simple sampling algorithm.

A natural idea to prove 2 is to use the mean of the densities in \(\mathcal{F}\) (which we denote by \(\bar\eta\) in the present discussion) as a “proxy” for the true density \(\mu^\star\). If it so happens that the density ratio \(\frac{\mu^\star(x)}{\bar\eta(x)}=\frac{\hat{\mu}(x)}{\bar\eta(x)}\)11 is bounded (say, by \(\mathop{\mathrm{poly}}(R)\)) for all \(x \in \Sigma^n\), then it is very straightforward to produce samples from \(\mu^\star\), using rejection sampling. Namely, we simply sample \(x\) from \(\bar \eta(x = \cdot)\) and accept \(x\) with probability \(\frac{\hat{\mu}(x)}{\bar\eta(x)}\).

What about the (typical) case where the density ratio is not bounded as above? In this case, a natural strategy is to sample a sequence \(x\) from \(\bar\eta\), character-by-character, for as many steps as possible until we come to some sequence \(x\) and potential next character \(y\) where \(\frac{\hat{\mu}(x\circ y)}{\bar \eta(x\circ y)}\) becomes too large, say \(\geq 2 R\): this procedure is formalized in 1. Suppose that we get to such an \(x \circ y\) (namely, Line [line:hit-xy-intro]). At this point, not all is lost: we can restrict the class \(\mathcal{F}\) to densities that “are consistent with” \(\hat{\mu}\) at the input \(x\), i.e., suppose we define \(\mathcal{F}' := \{ \mu \in \mathcal{F}\mid \mu(x\circ y) \geq \hat{\mu}(x\circ y) / R \}\). Certainly \(\mu^\star\in \mathcal{F}'\) by 1. Moreover, for any \(\mu \in \mathcal{F}'\), we have \[\begin{align} \frac{\mu(x\circ y)}{\bar \eta(x\circ y)} \geq \frac{\hat{\mu}(x\circ y)}{R \cdot \bar \eta(x\circ y)} \geq 2\nonumber, \end{align}\] where the final inequality follows by the assumption that \(\frac{\hat{\mu}(x\circ y)}{\bar \eta(x\circ y)} \geq 2R\). But by Markov’s inequality, the number of such densities \(\mu \in \mathcal{F}\) is bounded above by \(|\mathcal{F}|/2\). Thus, we have halved the number of densities under consideration! We can now repeat 1, except using the class \(\mathcal{F}'\) as input instead of \(\mathcal{F}\). After at most \(\log |\mathcal{F}|\) repetitions of this procedure, we will either have narrowed \(\mathcal{F}\) down to \(\mu^\star\) (in which case outputting a sample from \(\mu^\star\) is trivial), or else we will have converged on some class \(\mathcal{F}''\) which has the following property: for some small value of \(\epsilon> 0\), the probability that 1 given the class \(\mathcal{F}''\) as input returns some \(x\) of length less than \(n\), is at most \(\epsilon\). Note that, in order to check if the aforementioned probability is bounded above by \(\epsilon\), we need to run 1 for \(\tilde{O}(1/\epsilon)\) iterations given the class \(\mathcal{F}''\) as input.

Let \(\bar\eta''\) denote the mean of the densities in \(\mathcal{F}''\), and let \(\mathcal{T}\) denote the set of \(x \in \Sigma^{<n}\) of length less than \(n\) which 1 can possibly output when its input is \(\mathcal{F}''\). Formally, \(\mathcal{T}\) is the set of \(x \in \Sigma^{<n}\) so that \(\frac{\hat{\mu}(x \circ y)}{\bar \eta''(x \circ y)} \geq 2R\) for some \(y \in \Sigma\) but no nodes \(x' \prec x\) satisfy this property. The choice of \(\mathcal{F}''\) gives that \(\sum_{x \in \mathcal{T}} \bar \eta(x) \leq \epsilon\). Furthermore, since \(\frac{\hat{\mu}(x)}{\bar \eta(x)} \leq 2R\) for all \(x \in \mathcal{T}\), we have \[\begin{align} \sum_{x \in \mathcal{T}} \mu^\star(x) \leq \sum_{x \in \mathcal{T}} R \cdot \hat{\mu}(x) \leq 2R^2 \sum_{x \in \mathcal{T}} \bar \eta(x) \leq 2R^2 \cdot \epsilon\nonumber. \end{align}\] It then follows from a straightforward analysis of rejection sampling that by using rejection sampling on the output of 1 (conditioned on its output having length \(n\), i.e., not returning on Line [line:return-early-intro]), we obtain a sample from a distribution \(\hat{\nu}\) satisfying \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \leq 2R^2 \cdot \epsilon\). Furthermore, the number of queries to \(\hat{\nu}(\cdot)\), over all rounds, is bounded above by \(\tilde{O}( n\log |\mathcal{F}| \cdot \frac{1}{\epsilon})\): there are at most \(\log |\mathcal{F}|\) rounds on which we halve the size of \(\mathcal{F}\), and each round takes up to \(\tilde{O}(n/\epsilon)\) queries to run 1 \(\tilde{O}(1/\epsilon)\) times.12

This guarantee falls short of the one stated in 2 in two respects:

  1. First, in 2, we only need \(\mathop{\mathrm{poly}}\log(\frac{1}{\epsilon})\) iterations to achieve total variation distance at most \(\epsilon\), as opposed to the (exponentially worse) scaling of \(1/\epsilon\) for the above procedure.

  2. Second, the above guarantee scales linearly with \(\log |\mathcal{F}|\), as opposed to the scaling of \(\sqrt{\log |\mathcal{F}|}\) in 2.

2.1.0.2 Towards a more efficient sampling procedure.

To address both of the above shortcomings, the following high-level idea will be useful: if we reach some \(x\) with large ratio as in Line [line:hit-xy-intro] of 1, there is no need to “start over” again, sampling a new sequence from scratch. Instead, we can try to continue sampling starting from the sequence \(x\) at which we previously “got stuck”, but using the mean density of the new (smaller) class \(\mathcal{F}'\) to sample continuations. There are a number of possible complications with this procedure:

  1. First, since in general it will be the case that \(\bar \eta(x) \neq \mu^\star(x)\), there will be some bias in the probability of choosing \(x\) in the first place. While this bias can be corrected using rejection sampling, we need to take care to ensure that such a bias does not accumulate multiplicatively over multiple rounds of this procedure.

  2. A second and more subtle complication is that the basic sampling procedure in 1 might sometimes output long sequences \(x\) (e.g., of length \(|x| = n\)) for which \(\hat{\mu}(x)\) is incredibly small (e.g., suppose \(\hat{\mu}(x) < 2^{-n} \cdot \bar \eta(x)\)), so that the subsequent rejection sampling step will nearly always reject such sequences. If such \(x\) are output by 1 with reasonably high probability (e.g., some constant), then it is possible that between each pair of consecutive steps of the overall algorithm where we halve the size of the class of densities, we will need to “pay” \(O(n)\) oracle calls to \(\hat{\mu}(\cdot)\) in the process of sampling these long sequences \(x\) where \(\hat{\mu}(x)\) is small. Overall, this amounts to \(O(n \log |\mathcal{F}|)\) oracle calls, which falls short of the desired \(O(n \sqrt{\log |\mathcal{F}|})\) guarantee in 2. To get around this complication, a key idea will be to employ truncation: if we are in the process of sampling a sequence \(x \in \Sigma^{<n}\) and we detect that \(\hat{\mu}(x) < \bar \eta(x)\), then we can simply prematurely reject \(x\) with high probability, since it would be very unlikely for \(x\) to be ultimately accepted in the subsequent rejection sampling step.

Below, we describe in further detail how we overcome the above complications.

2.1.0.3 Algorithm overview.

We are now ready to present 3, which establishes 2. The outermost loop of 3 iterates over multiple steps \(k\): each step implements a rejection sampling step ([line:k-rejection-sampling]) on a uniformly random element of a set \(\mathcal{S}^{\mathsf{term}}\) constructed in the course of that step. The bulk of the work goes into producing this set \(\mathcal{S}^{\mathsf{term}}\), which we proceed to describe in detail.

In each step \(k\), the algorithm operates over multiple iterations \(j\), maintaining a subclass \(\mathcal{F}^j \subset \mathcal{F}\) at each iteration. The class \(\mathcal{F}^j\) contains densities \(\mu\) which are “consistent with” the algorithm’s previous queries to the oracle \(\hat{\mu}\). Additionally, at each iteration \(j\), the algorithm maintains a set \(\mathcal{S}^{j-1}\) consisting of sequences \(z \in \Sigma^{\leq n}\): these sequences correspond to “partial samples” which the algorithm is considering, roughly speaking, as “candidates” for inclusion in \(\mathcal{S}^{\mathsf{term}}\). Over the course of the algorithm, sequences \(z\) in \(\mathcal{S}^{j-1}\) will be extended by adding characters; these sequences may further be removed from \(\mathcal{S}^{j-1}\) (if, e.g., it turns out that many extensions \(z' \succ z\) have very small values of \(\hat{\mu}(z')\)), or duplicated (if, e.g., it turns out that many extensions \(z' \succ z\) have very large values of \(\hat{\mu}(z')\)).

Initially, \(\mathcal{F}^1\) is set to be the set of densities consistent with \(\hat{\mu}\) at all single-character sequences, i.e., “\(y\)” for \(y \in \Sigma\) (Line [line:f1-define]). At each iteration \(j\), the algorithm chooses an element \(z_j\) of \(\mathcal{S}^{j-1}\) which is incomplete (i.e., has length less than \(n\); Line [line:choose-zj]). Next, it calls the sub-procedure 2 with the node \(z_j\) and the density class \(\mathcal{F}^j\) as input. 2 returns a set \(\mathcal{T}_j \subset \Sigma^{\leq n}\) and a subset \(\mathcal{G}_j \subset \mathcal{F}^j\); we add all of \(\mathcal{T}_j\) to \(\mathcal{S}_j\) (and remove \(z_j\) from \(\mathcal{S}_j\)) and restrict \(\mathcal{F}^j\) to only contain densities in \(\mathcal{G}_j\), and then repeat the procedure.

2 performs the work of extending the sequence \(z_j\) (and possibly pruning or duplicating it). Below, we denote the class passed to 2 as input by \(\mathcal{G}\), and the node passed to it as input by \(w\); thus, we will have \(\mathcal{G}= \mathcal{F}^j\) and \(w = z_j\) in the context of the above discussion.

2 executes the following procedure over multiple trials \(i\) (the number of trials, denoted by \(M\) in 2, will be taken to be \(\mathop{\mathrm{poly}}(R)\)). In each trial \(i\), 2 defines a density \(\bar\eta_{i,0}\) to be the mean of the densities in \(\mathcal{G}\) (Line [line:initialize-ts-rs]) and lets \(w_{i,0}\) take the value of the input sequence \(z_j\) from above. It then repeatedly samples a character \(y \in \Sigma\) to append to the input sequence, according to the density \(\bar \eta_{i,0}\) (Lines [line:extend-1] and [line:extend-2]); the sequence which is being extended in this manner is denoed by \(w_{i,t}\) in 2 (initially, \(t = 1\)). This procedure is repeated until one of the following 3 events occur:

  • The first event (Line [line:if-big]) is that for some character \(y \in \Sigma\), the mass of \(\hat{\mu}(w_{i,t }\circ y)\), normalized by \(\hat{\mu}(w_{i,t-1})\), is much larger than \(\bar\eta_{i,t-1}(w_{i,t} \mid w_{i,t-1})\) (i.e., by a factor of at least \(M\)). This case is analogous to the “ratio becomes too large” case in Line [line:hit-xy-intro] of 1. In this case, the current sequence \(w_{i,t}\) is added to the multiset \(\mathcal{T}\) which will be output by 2 with an appropriate probability. Furthermore, the class \(\mathcal{G}^{\mathsf{ret}}\), which will be returned by 2 (along with \(\mathcal{T}\)), is restricted to contain only densities \(\eta\) satisfying \(\hat{\mu}(w_{i,t} \circ y)/\eta(w_{i,t} \circ y) \leq R\), thus eliminating densities inconsistent with \(\hat{\mu}\) at \(w_{i,t} \circ y\). As we will show, this step ensures that the returned class \(\mathcal{G}^{\mathsf{ret}}\) contains at most half the number of densities as the input class \(\mathcal{G}\). The trial \(i\) then terminates.

  • The second event (Line [line:else-lengthn]) is that \(w_{i,t}\) reaches full length \(|w_{i,t}| = n\), i.e., we have sampled a complete sequence. In this case, \(w_{i,t}\) is added to \(\mathcal{T}\) with appropriate probability (Lines [line:xi-else][line:add-to-T-end]), and the trial \(i\) terminates.

  • The third event (Line [line:if-small]) is that the mass of \(\hat{\mu}(w_{i,t})\), normalized by \(\hat{\mu}(w_{i,t-1})\) is much smaller than \(\bar \eta_{i,t-1}(w_{i,t} \mid w_{i,t-1})\) (i.e., by a factor of at least \(M\)). In this case, with an appropriate probability, the trial \(i\) simply ends (Line [line:break-m-trial-end]). Otherwise, we increment \(t\) and continue on sampling from \(w_{i,t}\).

    We refer to this as the truncation step, addressing complication (C2) above: rather than continuing to extend a sequence whose density under \(\hat{\mu}\) is very small (and which would therefore be nearly always rejected in a final rejection sampling step), the algorithm truncates the trial early with high probability.

2.1.0.4 Unbiasedness: addressing complication (C1).

The acceptance probabilities in 2 are calibrated to ensure the following key unbiasedness property: for any node \(w'\) in a certain “final” set of nodes descending from the input node \(w\), the expected number of occurrences of \(w'\) in the output multiset \(\mathcal{T}\) is exactly \(\hat{\mu}(w')/\hat{\mu}(w)\) (see 6). This unbiasedness property addresses complication (C1): even though the proposal distribution \(\bar\eta\) may differ substantially from \(\mu^\star\), the importance-weighting corrections prevent any accumulation of bias.

In order to show that the algorithm samples from the right distribution \(\mu^\star\), by the final rejection sampling step on Line [line:k-rejection-sampling] of 3, the key point is to control the extent to which \(|\mathcal{S}^{\mathsf{term}}|\) can exceed \(2RN \asymp \sqrt{\log |\mathcal{F}|} \cdot \mathop{\mathrm{poly}}(R)\). To do this, we reason as follows: a consequence of unbiasedness as discussed above (namely, 6) is that \(M_j := \sum_{x \in \mathcal{S}^j} \mu^\star(x)/\hat{\mu}(x)\) is a martingale over the iteration index \(j\) (11). Since \(\mu^\star(x) = \hat{\mu}(x)\) for complete sequences \(x \in \Sigma^n\), at termination (\(j = J\)) this martingale equals \(|\mathcal{S}^{\mathsf{term}}|\). The desired control on the truncation in the final rejection sampling step then follows from a standard martingale concentration argument, together with the corresponding upper-tail overshoot bound (12). We remark that this martingale concentration is crucial for improving the naive upper bound which was linear in \(\log |\mathcal{F}|\) to one which grows with \(\sqrt{\log |\mathcal{F}|}\): the number of iterations \(J\) in 3 is upper bounded by \(\log_2 |\mathcal{F}|\) (8) since each iteration halves the size of \(\mathcal{F}\), and the error term in martingale concentration grows only as \(\sqrt{J} \asymp \sqrt{\log |\mathcal{F}|}\).

2.1.0.5 Bounding the query cost of 3.

A key step in bounding the query cost of 3 is 7, which bounds the expected number of oracle queries made by the invocation of 2 on iteration \(j\) in 3 by the quantity \[\begin{align} \mathbb{E}\left[\left( \sum_{w' \in \mathcal{T}_j} \frac{\mu^\star(w')}{\hat{\mu}(w')} \cdot |w'| \right) - \frac{\mu^\star(w)}{\hat{\mu}(w)} \cdot |w|\right] \label{eq:query-cost-key-step}. \end{align}\tag{5}\] Recall that \(\mathcal{T}_j\) denotes the output set of 2; further, the above expectation is taken over the execution of 2, for the fixed input node \(w = z_j\). A key step in deriving this bound is the use of the truncation step discussed above: roughly speaking, the truncation step ensures that we only query nodes \(w'\) which have a decent probability of ending up in the set \(\mathcal{T}_j\) (thus addressing complication (C2)).

Thus, using Azuma’s inequality, in order to obtain a high-probability bound on the overall number of oracle calls, it suffices to bound the sum of the quantity 5 over all iterations \(j\) of 3. This argument is carried out in 14: the key step is the observation that the quantity inside the expectation in 5 is the difference \(W_j - W_{j-1}\), where \(W_j := \sum_{x \in \mathcal{S}^j} \frac{\mu^\star(x)}{\hat{\mu}(x)} \cdot |x|\) is a “weighted” variant of the martingale \(M_j\), where each sequence in \(\mathcal{S}^j\) is weighted by its length. Namely, the positive term in 5 corresponds to the contribution of the new sequences in \(\mathcal{T}_j\), while the negative term corresponds to the effect of removing the node \(z_j\) from \(\mathcal{S}_j\). Finally, we note that our high-probability bound on \(|\mathcal{S}^{\mathsf{term}}|\) from 12 allows us to bound \(W_J\) by \(\sqrt{\log |\mathcal{F}|} \cdot n \cdot \mathop{\mathrm{poly}}(R, \log \frac{1}{\delta}, \log\log |\mathcal{F}|)\), and a further application of Azuma’s inequality then gives the desired bound on the sum of the quantities in 5 over all iterations \(j\).

2.2 Lower bound↩︎

To prove 1, we consider the case that \(\Sigma = \{0,1\}\). We will construct a family of distributions \(\mathcal{F}\) over \(\{0,1\}^n\), which has the following property: each \(\mu^\star\in \mathcal{F}\) is associated with some value \(v^{\mathsf{init}}\in \{0,1\}\), so that \(\mu^\star(x_1 = v^{\mathsf{init}}) \approx \frac{1+\gamma}{2+\gamma} > \frac{1}{2}\), for some constant \(\gamma \in (0,1)\). In other words, sampling from \(\mu^\star\) to accuracy \(\ll \gamma\) requires one to learn \(v^{\mathsf{init}}\): formally, for any distribution \(\hat{\nu}\) we have \(\mu^\star(x_1 = v^{\mathsf{init}}) \gtrsim \frac{1+\gamma}{2+\gamma} - D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}})\), so if \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \ll \gamma\), then the first bit of a sample from \(\hat{\nu}\) is equal to \(v^{\mathsf{init}}\) with probability at least \(\frac{1}{2} + \Omega(\gamma)\).

We will show that, for an appropriate choice of \(\mathcal{F}\), with high probability over a random draw of \(\mu^\star\sim \mathcal{F}\) and an appropriately chosen \(\hat{\mu}\) satisfying 1 with respect to \(\mu^\star\), any algorithm \(\mathsf{Alg}\) making \(o(n^2/\log^2 n)\) queries to \(\hat{\mu}(\cdot)\) cannot output \(v^{\mathsf{init}}\) with probability \(\frac{1}{2} + \Omega(1)\), which will yield the desired result as \(\gamma\) was chosen to be constant. Below we give an overview of the construction of \(\mathcal{F}\), and then describe why subquadratically many queries are insufficient to learn \(v^{\mathsf{init}}\) for a random draw of \(\mu^\star\sim \mathcal{F}\).

2.2.0.1 Construction of \(\mathcal{F}\): overview.

Each element of \(\mathcal{F}\) is parametrized by a tuple \(\tau = (v^{\mathsf{init}}, \phi, \psi)\), where \(v^{\mathsf{init}}\) is as described above, and \(\phi, \psi\) are parameters which will be described below. Associated to each tuple \(\tau\), we define a density \(\mu_\tau \in \Delta(\{0,1\}^n)\), as well as a mapping \(\hat{\mu}_\tau : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\). To construct \(\hat{\mu}_\tau\) and \(\mu_\tau\), we will interpret \(\{0,1\}^n\) as the complete binary tree, so that its edges are in one-to-one correspondence with \(\{0,1\}^{\leq n}\). We will define edge weights for each edge of this tree, formalized by mappings \(\hat{\omega}_{\tau} : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\). We then define \(\hat{\mu}_\tau(x)\) to be proportional to the product of the edge weights on the root-to-leaf path corresponding to \(x\). Formally, for \(x \in \{0,1\}^j\) for some \(j \in [n]\), we define \[\begin{align} \hat{\mu}_\tau( x) = \frac{1}{\hat{Z}_j}\prod_{i=1}^{j} \hat{\omega}_\tau(x_{1:i}), \qquad \hat{Z}_j = \sum_{x' \in \{0,1\}^j} \prod_{i=1}^j \hat{\omega}_\tau(x'_{1:i})\label{eq:hat-mu-Z-intro}. \end{align}\tag{6}\] Our choice of \(\hat{\omega}_\tau\) will ensure that the normalizing constants \(\hat{Z}_j\) do not depend on \(\tau\) (see 18). Finally, we take \(\mu_\tau(x) = \hat{\mu}_\tau(x)\) for \(x \in \{0,1\}^n\); the choice of \(\hat{Z}_n\) above ensures that \(\mu_\tau(x)\) is indeed a distribution on \(\{0,1\}^n\). For \(j \in [n]\) and \(x \in \{0,1\}^j\), with slight abuse of notation we let \(\mu_\tau(x)\) denote the marginal distribution of \(\mu_\tau\) on \(x\), i.e., \(\mu_\tau(x) = \sum_{x' \in \{0,1\}^{n-j}} \mu_\tau(x \circ x')\); then we have \(\mu_\tau(x) = \mu_\tau(x \circ 0) + \mu_\tau(x \circ 1)\) for all \(x \in \{0,1\}^{<n}\). Since the sum of the edge weights on the edges leaving different nodes may differ, it can be the case that \(\mu_\tau(x) \neq \hat{\mu}_\tau(x)\) and \(\hat{\mu}_\tau(x) \neq \hat{\mu}_\tau(x \circ 0) + \hat{\mu}_\tau(x \circ 1)\) for \(x \in \{0,1\}^{<n}\).

The edge weights \(\hat{\omega}_\tau\) at step \(1\) are given as follows: for all \(\tau\), \(\hat{\omega}_\tau(1) = \hat{\omega}_\tau(0) = 1 + \gamma\). Recall, however, our desideratum above that \(\mu_\tau(x_1 = v^{\mathsf{init}}) \geq \frac{1}{2} + \Omega(\gamma)\) for each \(\tau\). If the edge weights \(\hat{\omega}_\tau(x)\) are “evenly balanced” for \(x\) whose first bit is \(0\) and for \(x\) whose first bit is \(1\), then it will hold that \(\mu_\tau(x_1 = 0) \approx \mu_\tau(x_1 = 1)\), which violates this lower bound on \(\mu_\tau(x_1 = v^{\mathsf{init}})\). Thus, we need the edge weights \(\hat{\omega}_\tau(x)\) for \(x\) whose first bit is \(1-v^{\mathsf{init}}\) to be noticeably smaller than those for \(x\) whose first bit is \(v^{\mathsf{init}}\).

On the other hand, this “bias” in the edge weights needs to be undetectable to any algorithm \(\mathsf{Alg}\) which can query sub-quadratically many values of \(\hat{\omega}_\tau(\cdot)\). Indeed, for any \(x \in \{0,1\}^{j}\) (\(j \in [n]\)) \(\mathsf{Alg}\) can determine the value of \(\hat{\omega}_\tau(x)\) by querying \(\hat{\mu}_\tau(x)\) and \(\hat{\mu}_\tau(x_{1:j-1})\). How do we achieve this goal? At a high level, we will divide the set of coordinates \(\{ 2, 3, \ldots, n\}\) into groups of size \(k \approx 2 \log n\): in each group, we will choose a fraction \(\epsilon= \Theta(\log(n)/n)\) of the \(2^k\) values \(\{0,1\}^k\) corresponding to the coordinates in that group for which we make the edge weights \(\hat{\omega}_\tau(\cdot)\) smaller by roughly a \((1+\gamma)\)-factor in the case that \(x_1 = 1-v^{\mathsf{init}}\), as compared to the case that \(x_1 = v^{\mathsf{init}}\). The precise choice of these \(\epsilon\cdot 2^k\) values is determined by \(\tau\), and will be uniformly random for a uniform choice of \(\tau\). Since \(\epsilon= \Theta(\log(n)/n)\) and \(2^k \approx n^2\), it is straightforward to see that any \(\mathsf{Alg}\) making \(o(n^2 /\log^2 n)\) queries to \(\hat{\omega}_\tau(\cdot)\) cannot tell whether the edge weights are decreased in this manner (which translates into showing that \(\mathsf{Alg}\) cannot determine the value of \(v^{\mathsf{init}}\)). Moreover, since there are \(n/\log(n)\) groups and for each group a fraction of \(\epsilon\sim \log(n)/n\) values of \(x\) have their edge weight decreased, with high probability over a full sample \(x \sim \mu_\tau\) (\(x \in \{0,1\}^n\)) there will be some group whose edge weight is decreased.

The astute reader will notice a potential flaw in the above line of reasoning: while, as we noted above, one can simulate a single query to \(\hat{\omega}_\tau(\cdot)\) using two queries to \(\hat{\mu}_\tau(\cdot)\), in fact this is not necessarily the best that \(\mathsf{Alg}\) can possibly do. Indeed, querying \(\hat{\mu}_\tau(x)\) for \(x \in \{0,1\}^j\) divulges information about up to the \(j\) values \(\hat{\omega}_\tau(x_1), \hat{\omega}_\tau(x_{1:2}), \ldots, \hat{\omega}_\tau(x)\). To avoid the possibility that \(\mathsf{Alg}\) can “batch query” \(\hat{\omega}_\tau(\cdot)\) in this manner, we will make it so that the vast majority of \(x \in \{0,1\}^j\) in fact have \(0\) edge weight, i.e., \(\hat{\omega}_\tau(x) = 0\). Thus, to find \(x\) with nonzero edge weight, \(\mathsf{Alg}\) needs to “walk” on a path starting from the root of the tree, and thus it can only learn information about a single value of \(\hat{\omega}_\tau(\cdot)\) with each query to \(\hat{\mu}(\cdot)\). Below, we describe these ideas in more detail.

2.2.0.2 Construction of the edge weights \(\hat{\omega}_\tau\).

We break the coordinates \(\{2, 3, \ldots, n\}\) into \(r\) groups of size \(2k\) (for \(k \approx 2 \log n\)), indexed by a value \(a \in \{0,1, \ldots, r-1 \}\). For each \(a\), and \(x \in \{0,1\}^{2(a+1)k+1}\), we define \(\hat{\omega}_\tau(x_{1:2ak+2}), \hat{\omega}_\tau(x_{1:2ak+3}), \ldots, \hat{\omega}_\tau(x)\), in a way that depends on the tuple \(\tau = (v^{\mathsf{init}}, \phi, \psi)\), as follows. Let us write \[\begin{align} \mathsf{base}_a(x) = x_{1:2ak+1}, \quad \mathsf{query}_a(x) = x_{2ak+2:2ak+k+1}, \quad \mathsf{key}_a(x) = x_{2ak+k+2:2(a+1)k+1}, \nonumber \end{align}\] so that \(x = \mathsf{base}_a(x) \circ \mathsf{query}_a(x) \circ \mathsf{key}_a(x)\). Then:

  • We set \(\hat{\omega}_\tau(\mathsf{base}_a(x) \circ \mathsf{query}_a(x)_{1:i}) = 1\) for each \(i \in [k]\).

  • To define the remaining values of \(\hat{\omega}_\tau\), we need to specify the data contained in \(\phi, \psi\). First, \(\psi\) is a mapping \(\psi : \{0,1\}^{\leq n} \to (\{0,1\}^k)^{\{0,1\}^k}\) (in words, the range of \(\psi\) consists of vectors with entries in \(\{0,1\}^k\) and whose entries are also indexed by \(\{0,1\}^k\)). Moreover, \(\phi\) is a mapping which takes each \(y \in \{0,1\}^n\) to a partition \(\{0,1\}^k = A(y) \sqcup B(y) \sqcup C(y)\), with \(|A(y)| = 2^{k} - \epsilon\cdot 2^{k-1}, |B(y)| = \epsilon\cdot 2^{k-1}, |C(y)| = 2^{k-1}\). We denote the set of partitions by \(\mathcal{V}^{\mathsf{valid}}_{k,\epsilon}\). We will be interested in the value of \(\phi, \psi\) evaluated at \(\mathsf{base}_a(x)\) for \(x \in \{0,1\}^{2(a+1)k+1}\) as above.

  • For \(1 \leq b \leq k\), we set \(\hat{\omega}_\tau(\mathsf{base}_a(x) \circ \mathsf{query}_a(x) \circ \mathsf{key}_a(x)_{1:b}) = 0\) if the \(b\) bits \(\mathsf{key}_a(x)_{1:b}\) do not agree with the first \(b\) bits of \(\psi(\mathsf{base}_a(x))_{\mathsf{query}_a(x)}\); this requirement accomplishes the goal mentioned above of forcing the algorithm to “walk from the root downwards” to uncover new values of \(x'\) for which \(\hat{\omega}_\tau(x') \neq 0\). Indeed, it is very unlikely that the algorithm will correctly guess the value of \(\psi(\mathsf{base}_a(x))_{\mathsf{query}_a(x)} \in \{0,1\}^k\), without first querying (most of) the values of \(\hat{\mu}_\tau(\mathsf{base}_a(x) \circ \mathsf{query}_a(x) \circ \mathsf{key}_a(x)_{1:b})\) (for \(b \in [k]\)), as \(\psi\) is unknown (and will be chosen uniformly at random).

  • If further \(b < k\) and the \(b\) bits in the previous bullet point do agree, then we set \(\hat{\omega}_\tau(\mathsf{base}_a(x) \circ \mathsf{query}_a(x) \circ \mathsf{key}_a(x)_{1:b}) = 1\).

  • Finally, in the case that \(b = k\), we choose \(\hat{\omega}_\tau(x) \in \{1,1+\gamma\}\) as follows: first, if \(x_1 = v^{\mathsf{init}}\), then we set \[\begin{align} \hat{\omega}_\tau(x) = \begin{cases} 1+\gamma & \text{if \mathsf{query}_a(x) \in A(x) \cup B(x)} \\ 1 & \text{if \mathsf{query}_a(x) \in C(x)}. \end{cases}\label{eq:intro-vinit} \end{align}\tag{7}\] If \(x_1 = 1-v^{\mathsf{init}}\), then typically we will set \[\begin{align} \hat{\omega}_\tau(x) = \begin{cases}1+\gamma & \text{if \mathsf{query}_a(x) \in A(x)} \\ 1 & \text{if \mathsf{query}_a(x) \in B(x) \cup C(x)}. \end{cases}\label{eq:intro-not-vinit} \end{align}\tag{8}\] In other words, for those \(x\) with \(\mathsf{query}_a(x) \in B(x)\), the value of \(\hat{\omega}_\tau(x)\) is smaller by a factor of \(1+\gamma\) in the event that \(x_1 = 1-v^{\mathsf{init}}\) as compared to the event that \(x_1 = v^{\mathsf{init}}\). We write “typically” above due to the following exception: if there is some previous block \(a' < a\) for which \(\mathsf{query}_{a'}(x) \in B(\mathsf{base}_{a'}(x))\), then we set \(\hat{\omega}_\tau(x)\) as in 7 . This exception is needed to ensure that we do not “overshoot” and decrease the probability of \(x\) by more than a \(1+\gamma\) factor.

2.2.0.3 Establishing the lower bound.

To establish that the above construction proves 1, we first need to verify that the ratio \(\hat{\mu}_\tau(x) / \mu_\tau(x)\) is a constant for all \(x \in \{0,1\}^{\leq n}\). We will in fact be able to show that this ratio lies in \([(1+\gamma)^{-2}, (1+\gamma)^2]\) (see 17). Roughly speaking, this holds because the “exception” described following 8 ensures that we only modify the ratio by at most a factor of \(\approx 1+\gamma\) in the aggregate over all levels of the tree.

Next, we need to verify that \(\mu_\tau(x_1 = v^{\mathsf{init}}) \approx \frac{1+\gamma}{2+\gamma}\) (which ensures that accurately sampling from \(\mu_\tau\), namely to error \(\ll \gamma\), enables predicting the value of \(v^{\mathsf{init}}\) correctly with probability \(\frac{1}{2} + \Omega(\gamma)\), when \(\tau\) is drawn uniformly at random). This holds due to the following reasoning: for any fixed \(\tau\), for \(x \sim \mu_\tau\), conditioned on \(x_1 = 1-v^{\mathsf{init}}\), for each \(0 \leq a < r\), the probability that \(\mathsf{query}_a(x) \in B(\mathsf{base}_a(x))\) is roughly \(\epsilon= \Theta(\log(n) \cdot \log(1/\gamma)/n)\). Since there are \(r\) values of \(a\) and \(r = \Theta(n / \log(n))\), the probability that there is some \(a\) with \(\mathsf{query}_a(x) \in B(\mathsf{base}_a(x))\) is roughly \(1 - (1-\epsilon)^r \approx 1 - e^{-\epsilon r} \approx 1 - c\gamma\), for a small constant \(c\). This means that, for the vast majority of \(x\) with \(x_1 = 1-v^{\mathsf{init}}\), there will be some block \(a\) where the weight \(\hat{\omega}_\tau(x_{1:2(a+1)k+1})\) is decreased by a factor of \(1+\gamma\) (per 8 ). Since \(\hat{\mu}(x)\) is proportional to the product of \(\hat{\omega}_\tau(x_{1:i})\) for \(i = 1, 2, \ldots, n\), this leads to the desired claim.

The above reasoning is carried out formally in 16: formally, in 4 we define an alternative measure \(\mu_{\mathsf{ideal}}\) which has the property that \(\mu_{\mathsf{ideal}}(x_1 = v^{\mathsf{init}}) = \frac{1+\gamma}{2+\gamma}\). Then 16 shows that \(\mu_{\mathsf{ideal}}\) and \(\mu_\tau\) are \(e^{-\epsilon r}\)-close in total variation distance.

The final step in the proof, which is the most technical, is to show that no algorithm can output \(v^{\mathsf{init}}\) with probability \(\frac{1}{2} + \Omega(\gamma)\) after making only \(o(n^2 / \log^2 n)\) queries to \(\hat{\mu}_\tau(\cdot)\), over a uniformly random draw of \(\tau\). The main technical lemma to show this is given in 20, which is stated informally below:

Lemma 1 (Informal version of 20). Fix any sequence of past queries of \(\mathsf{Alg}\), denoted \(X_1, \ldots, X_{j-1} \in \{0,1\}^{\leq n}\), as well as some response values for these queries, \(\mu_1', \ldots, \mu_{j-1}' \geq 0\). For \(b \in \{0,1\}\), let \(\mathbb{P}_b\) denote the distribution of \(\tau\) (which is uniform) conditioned on \(v^{\mathsf{init}}= b\). Let \(\mathcal{E}\) denote the event that \(\hat{\mu}_\tau(X_\ell) = \hat{\mu}_\ell'\) for each \(\ell \in [j-1]\). Then, assuming \(\mathbb{P}_0(\mathcal{E}), \mathbb{P}_1(\mathcal{E}) > 0\), for any “current” query \(X_j\), we have \[\begin{align} D_{\mathsf{KL}}({\mathbb{P}_0(\hat{\mu}_\tau(X_j) = \cdot \mid \mathcal{E})}||{\mathbb{P}_1(\hat{\mu}_\tau(X_j) = \cdot \mid \mathcal{E})})\leq O(\epsilon^2)\nonumber. \end{align}\]

Roughly speaking, 1 gives that the conditional distributions of the output of the \(j\)th query to \(\hat{\mu}_\tau\), for an arbitrary sequence of previous queries to \(\hat{\mu}_\tau\) and their answers, is close in the cases where we condition \(v^{\mathsf{init}}\) to equal \(1\) or \(0\). While the full proof of the lemma involves several complexities due to the necessity of considering which part of each “block” \(X_j\) is querying, as well as conditioning on past queries, the main idea boils down to the fact that the distributions \(\mathbb{P}_0, \mathbb{P}_1\) differ only in their values of \(\hat{\omega}_\tau(x)\in \{1,1+\gamma\}\) for \(x\) in the case of 7 8 above. Namely, the probability that \(\hat{\omega}_\tau(x) = 1+\gamma\) is larger by roughly \(|B(x)|/2^k = \epsilon\) in the event that \(x_1 = v^{\mathsf{init}}\) (as compared to the event that \(x_1 = 1-v^{\mathsf{init}}\)). Here we use that the random choice of \(\tau\) induces a uniformly random value for the set \(B(x) \subset \{0,1\}^k\). Further, the probability that \(\hat{\omega}_\tau(x) = 1+\gamma\) is bounded in \([1/3, 2/3]\). Then the claim of 1 follows because the KL divergence between Bernoulli random variables whose means are separated by \(\gamma\) and bounded in \([1/3, 2/3]\) is \(O(\epsilon^2)\).

Having established 1, by applying the chain rule for KL divergence we obtain that, comparing the event when \(v^{\mathsf{init}}= 0\) and the event when \(v^{\mathsf{init}}= 1\), the distribution of the transcript of \(\mathsf{Alg}\)’s computation can differ in these two cases by at most \(O(\epsilon^2 \cdot n^2 / \log^2 n) \ll 1\) in KL divergence. This establishes the desired claim.

2.2.0.4 On the role of \(\psi\).

The above argument has neglected to mention one key aspect of the proof, which motivates the inclusion of \(\psi\) in the tuple \(\tau\) as well as the “key” blocks \(\mathsf{key}_a(x)\) defined above. In particular, 1 implicitly assumes that each query that \(\mathsf{Alg}\) makes reveals information about \(\hat{\omega}_\tau(x)\) for a single value of \(x \in \{0,1\}^{\leq n}\). However, since \(\hat{\mu}_\tau(x)\) is proportional to the product \(\prod_{j=1}^{|x|} \hat{\omega}_\tau(x_{1:j})\) (see 6 ), \(\mathsf{Alg}\) can in principle learn information about up to \(n\) values of \(\hat{\omega}_\tau(\cdot)\) with a single query to \(\hat{\mu}_\tau(\cdot)\). To overcome this obstacle, we introduce a modified algorithm \(\widetilde{\mathsf{Alg}}\), which simulates \(\mathsf{Alg}\) in the following manner: if, at any point, \(\mathsf{Alg}\) “skips ahead” in the sense that it queries \(\hat{\mu}_\tau(x)\) for some \(x\) for which it has never queried a “previous block” (i.e., there is some \(a < \lfloor (|x| - 1) / (2k) \rfloor\) for which \(\mathsf{Alg}\) has never queried \(\hat{\mu}_\tau(\cdot)\) at \(x_{1:2ak+1}, x_{1:2ak+2}, \ldots, x_{1:2ak+2k}\)), then \(\widetilde{\mathsf{Alg}}\) does not actually query \(\hat{\mu}_\tau(\cdot)\) at such \(x\) and proceeds as if the answer to the query is \(0\).

Roughly speaking, 1 above applies to \(\widetilde{\mathsf{Alg}}\) as stated, since the definition of \(\widetilde{\mathsf{Alg}}\) ensures that it can only “learn information about” a single block \(0 \leq a < r\) with each query. The main remaining step in the proof of 1 is to show that the execution of \(\widetilde{\mathsf{Alg}}\) is identical to that of \(\mathsf{Alg}\), with high probability. This task is accomplished in the proof of 6. The proof uses the fact that for a uniform choice of \(\tau\), if \(\mathsf{Alg}\) does not query the value of \(\hat{\mu}_\tau(\cdot)\) at any of \(x_{1:2ak+1}, x_{1:2ak+2}, \ldots, x_{1:2ak+2k}\) prior to querying \(x\), then \(\psi(\mathsf{base}_a(x))_{\mathsf{query}_a(x)} \neq \mathsf{key}_a(x)\) with high probability (namely, \(1-2^{-k}\)); this holds because conditioned on the history of execution, \(\psi(\mathsf{base}_a(x))_{\mathsf{query}_a(x)}\) is uniformly random in \(\{0,1\}^k\), even conditioned on \(\mathsf{key}_a(x)\).

2.2.0.5 Making the class \(\mathcal{F}\) small via \(q\)-wise independence.

In the above construction, if we naively choose \(\phi : \{0,1\}^{\leq n} \to \mathcal{V}^{\mathsf{valid}}_{k,\epsilon}\) and \(\psi : \{0,1\}^{\leq n} \to (\{0,1\}^k)^{\{0,1\}^k}\) to be uniformly random functions on their respective domains, then the number of possible values for the tuple \((v^{\mathsf{init}}, \phi, \psi)\) grows doubly exponentially with \(n\), which falls far short of the claim in 1 that the number of possibilities for \(\mu_\tau\) grows only as \(\exp(\tilde{O}(n^4))\). To correct for this, we in fact choose \(\phi\) and \(\psi\) to be drawn from \(q\)-wise independent families of functions, where \(q = O(n^2 / \log^2 n)\) is an upper bound on the number of queries allocated to \(\mathsf{Alg}\). By a standard upper bound on the size of \(q\)-wise independent families, this leads to the desired upper bound and, roughly speaking, lets us treat \(\phi, \psi\) in the proof above as if they are uniformly random functions (as the algorithm can only ever access their values on at most \(q\) different inputs).

3 Proof of the main upper bound↩︎

In this section, we prove our main upper bound, stated formally as 3 below. We begin by reviewing the setup and terminology. We fix an alphabet \(\Sigma\) and a positive integer \(n\) denoting the length of sequences we will sample from. We are given a class \(\mathcal{F}\subset \Delta(\Sigma^n)\) of probability measures (i.e., \(\mathcal{F}\) is known to the algorithm). Suppose some unknown measure \(\mu^\star\in \mathcal{F}\) is fixed. With a slight abuse of notation, we write, for any \(\mu \in \Delta(\Sigma^n)\) and \(x \in \Sigma^{i}\), \(i < n\), \(\mu(x) = \mu(\{ x \circ x' \mid x' \in \Sigma^{n-i} \})\); in words, we use \(\mu(\cdot)\) to denote both the probability measure on \(\Sigma^n\) as well as its marginals on \(\Sigma^{< n}\).

We aim to come up with an algorithm that has knowledge of \(\mathcal{F}\) (but not \(\mu^\star\)), and which can make queries to a mapping \(\hat{\mu}: \Sigma^{\leq n} \to \mathbb{R}_{\geq 0}\) which satisfies the following assumption:

Assumption 1 (\(\ell_\infty\)-closeness). We assume that \(\hat{\mu} : \Sigma^{\leq n} \to \mathbb{R}_{\geq 0}\) is a mapping so that, for some \(R > 0\), for all \(x \in \Sigma^{\leq n}\), \[\begin{align} \frac{1}{R} \leq \frac{\mu^\star(x)}{\hat{\mu}(x)} \leq R\label{eq:R-ratio-asm}. \end{align}\tag{9}\] Moreover, we assume that \(\mu^\star(x) = \hat{\mu}(x)\) for all \(x \in \Sigma^n\). We also adopt the convention that \(\mu(\emptyset) = 1\).13

Recall, as we discussed in 1.1, 2 asks whether test-time training can speed up LLM inference. In our present notation, this question becomes the following: does the knowledge that \(\mu^\star \in \mathcal{F}\) allow us to sample more efficiently from \(\mu^\star\)? Recall that \(\mathcal{F}\) corresponds to the class of value functions which the test-time training algorithm is optimizing over. 3 below gives an affirmative answer to this question when \(\mathcal{F}\) is not too large; in particular, as long as \(|\mathcal{F}| \leq \exp(o(n^2))\), then 3 gives that we can sample using \(o(n^2)\) queries to \(\hat{\mu}(\cdot)\), which beats the quadratic lower bound of 1 (i.e., 4).

Theorem 3 (Main upper bound). Fix \(n \in \mathbb{N}\), \(\delta \in (0,1)\), a finite alphabet \(\Sigma\), and a known class of probability distributions \(\mathcal{F}\subseteq \Delta(\Sigma^n)\). Let \(\mu^\star \in \mathcal{F}\) be an unknown distribution, and let \(\hat{\mu} : \Sigma^{\leq n} \to \mathbb{R}_{\geq 0}\) satisfy 1 with respect to \(\mu^\star\) for some parameter \(R \geq 1\). Then there is a randomized algorithm (3) which outputs a sample from a distribution \(\hat{\nu} \in \Delta(\Sigma^n)\) satisfying \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \leq \delta\) and which makes at most \[\begin{align} O\left(n \cdot |\Sigma| \cdot R^{12} \cdot \sqrt{\log |\mathcal{F}|} \cdot \log \frac{1}{\delta} \cdot \left( \log \frac{R \log |\mathcal{F}|}{\delta}\right) \right)\nonumber \end{align}\] queries to \(\hat{\mu}(\cdot)\).

Recall the structure of 3 (discussed in depth in 2.1): for each outer iteration \(k\), the algorithm maintains a set \(\mathcal{S}^j\) of partial sequences. At each step \(j\), the algorithm removes an (arbitrary) element \(z_j\) of \(\mathcal{S}^{j-1}\) and replaces it with set \(\mathcal{T}_j\) of extensions of \(z_j\), returned by 2. In 3.1, we prove a number of lemmas that allow us to analyze 2; then, in 3.2, we put these pieces together and prove 3.

3.1 Analysis for 2↩︎

Figure 2: Tree-structured Rejection Sampling

In our analysis, we often view \(\Sigma^{\leq n}\) as a complete \(\Sigma\)-ary tree, and accordingly refer to elements \(x \in \Sigma^{\leq n}\) as nodes. For \(x = (x_1, \ldots, x_i) = x_{1:i} \in \Sigma^{\leq n}\) and \(i < j\), we will write \(x_{1:j} \prec x_{1:i}\), and say that \(x_{1:j}\) is an ancestor of \(x_{1:i}\) (which is a descendent of \(x_{1:j}\)).

To analyze 2, we need some additional notation to keep track of the nodes \(w_{i,t}\) maintained in 2. Given a class of densities \(\mathcal{G}\), a node \(w \in \Sigma^{\leq n}\), \(M \geq 1\), and \(t \geq 0\), we define the set of \((\mathcal{G}, M,t)\)-intermediate nodes with respect to \(w\), denoted \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\), and the set of \((\mathcal{G},M,t)\)-final nodes with respect to \(w\), denoted \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\), as follows:

  • First, we define \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,0}(w) := \{ w \}\) and \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,0}(w) = \emptyset\).

  • We define \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w),\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) inductively in terms of \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G}, M,t-1}(w)\), as follows: first, for each \(w' \succeq w\), we define \[\begin{align} \mathcal{G}_{t-1}(w') = \bigcap_{0 \leq s \leq t-1}\left\{ \eta \in \mathcal{G}\mid \frac{1}{R} \leq \frac{\hat{\mu}(w'')}{\eta(w'')} \leq R \; \forall w'' \preceq w', \;w'' \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,s}(w) \right\}\label{eq:define-gt}. \end{align}\tag{10}\] In words, \(\mathcal{G}_{t-1}(w')\) is the set of densities which is consistent with the value of \(\hat{\mu}\) at all ancestors of \(w'\) which are in some \((\mathcal{G}, M,s)\) intermediate set for \(s \leq t-1\). We then set \[\begin{align} \bar \eta_{t-1,w'} := \frac{1}{|\mathcal{G}_{t-1}(w')|} \sum_{\eta \in \mathcal{G}_{t-1}(w')} \eta\nonumber \end{align}\] to be the mean of the densities in \(\mathcal{G}_{t-1,w'}\). To define \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) and \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) we consider the following properties of nodes \(w' \succ w\):

    1. \(w' \succ w''\) for some \(w'' \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w)\) so that \[\begin{align} \frac{\hat{\mu}(w')}{\hat{\mu}(w'') \cdot \bar \eta_{t-1,w''}(w' \mid w'')} < \frac{1}{M}\nonumber \end{align}\]

    2. \(w' \succ w''\) for some \(w'' \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w)\) so that either \(|w'| = n\) or for some \(y \in \Sigma\), \[\begin{align} \frac{\hat{\mu}(w'\circ y)}{\hat{\mu}(w'') \cdot \bar \eta_{t-1,w''}(w' \circ y \mid w'')} > M\nonumber. \end{align}\]

    We then define \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) to be the set of \(w'\) satisfying (P1) and that neither it nor any of its ancestors satisfy either (P1), (P2). We define \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) to be the union of \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w)\) and the set of \(w'\) satisfying (P2) and that none of its ancestors satisfy either (P1), (P2).

For \(w \in \Sigma^{\leq n}\) and a subset \(\mathcal{N}\subset \Sigma^{\leq n}\), we say that \(\mathcal{N}\) is a simple \(w\)-cut if for each leaf \(v \in \Sigma^n\), \(v \succ w\), there is a single node \(w' \in \mathcal{N}\) so that \(w \preceq w' \preceq v\) (i.e., a single node in \(\mathcal{N}\) lies on the path from \(w\) to \(v\)). The next lemma shows that, at every stage of the construction, the intermediate and final nodes still form such a simple cut.

Lemma 2. For each \(t \geq 0\), \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G}, M, t}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) is a simple \(w\)-cut.

Proof. We argue by induction on \(t\). For \(t=0\) we have \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,0}(w)=\{w\}\) and \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,0}(w)=\emptyset\), so the claim is immediate.

Now fix \(t \geq 1\) and assume that \[\begin{align} \mathcal{C}_{t-1} := \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w)\nonumber \end{align}\] is a simple \(w\)-cut. Let \(v \in \Sigma^n\) be any leaf with \(v \succeq w\). Since \(\mathcal{C}_{t-1}\) is a simple \(w\)-cut, there is a unique node \(u \in \mathcal{C}_{t-1}\) on the path from \(w\) to \(v\).

If \(u \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w)\), then \(u\) is also in \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\). Moreover, no node of \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) or of \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w) \setminus \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w)\) can lie below \(u\), because every node added at time \(t\) must be a descendant of some element of \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w)\), whereas \(u\) is already the unique cut node on the path from \(w\) to \(v\). Thus \(u\) is the unique node of \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) on this path.

It remains to consider the case \(u \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w)\). Along the path from \(u\) to \(v\), the leaf \(v\) itself satisfies (P2) relative to \(u\), simply because \(|v|=n\). Hence there is at least one descendant of \(u\) on the path to \(v\) satisfying either (P1) or (P2) relative to \(u\). Let \(z\) be the first such descendant. By definition, \(z\) belongs to \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) if it satisfies (P1) but not (P2), and to \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) if it satisfies (P2).

By the choice of \(z\), no proper ancestor of \(z\) which is a descendant of \(u\) satisfies either (P1) or (P2). Also, no proper descendant of \(z\) can belong to \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) or to \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w) \setminus \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w)\), because membership in those sets requires that neither the node itself nor any of its ancestors satisfy (P1) or (P2). Finally, there is no element of \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w)\) below \(u\) on the path to \(v\), since \(u\) was the unique element of \(\mathcal{C}_{t-1}\) on that path. Therefore \(z\) is the unique node of \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) lying on the path from \(w\) to \(v\).

Since this holds for every leaf \(v \succeq w\), the set \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\) is a simple \(w\)-cut. ◻

The next lemma shows that the number of steps after which we can define subsequent nonempty intermediate node sets is at most \(n - |w|\).

Lemma 3. There is some \(t_0 \leq n-|w|\) so that for all \(t \geq t_0\), \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G}, M, t}(w) = \emptyset\), and therefore \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t_0}(w) = \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t_0+1}(w) = \cdots\).

Proof. We first claim that every node in \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) lies at depth at least \(|w|+t\). Indeed, for \(t=0\) this is immediate since \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,0}(w)=\{w\}\). For \(t \geq 1\), if \(u \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\), then by definition \(u\) satisfies (P1) relative to some node \(u' \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w)\), and hence \(u \succ u'\). By induction, \(|u'| \geq |w|+t-1\), so \(|u| \geq |u'|+1 \geq |w|+t\).

Next, no intermediate node can be a leaf. Indeed, if \(|u|=n\), then \(u\) satisfies (P2) by definition. But a node belongs to \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) only if neither it nor any of its ancestors satisfy (P1) or (P2). Therefore every \(u \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) must satisfy \(|u|<n\).

Combining the two observations, if \(t \geq n-|w|\) and \(u \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\), then \(|u| \geq |w|+t \geq n\), which forces \(|u|=n\), a contradiction. Hence \[\begin{align} \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)=\emptyset \qquad \forall t \geq n-|w|.\nonumber \end{align}\] Thus we may take \(t_0 := n-|w|\).

Finally, once \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) is empty, the inductive definition adds no further nodes to \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\), so the final sets remain constant for all subsequent times. ◻

The below lemma relates the values of \(w_{i,t}\) and \(\mathcal{G}_{i,t}\) that are computed in 2 to the sets \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\), \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\), and \(\mathcal{G}_t(w)\) defined above.

Lemma 4. Fix any \(i \in [M]\) denoting the outer iteration in 2. For any \(t \geq 1\), the final value of \(w_{i,t}\) computed in 2 is an element of \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\), and the candidate class \(\mathcal{G}_{i,t}\) defined in Line [line:proceed-next-t] is exactly \(\mathcal{G}_t(w_{i,t})\) as defined in 10 . Moreover, the set \(\mathcal{T}\) computed in 2 satisfies \(\mathcal{T}\subset \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\) almost surely.

Proof. We prove the first two claims by induction on \(t\), restricting attention to those values of \(t\) for which the \(i\)th outer-loop iteration actually reaches stage \(t\).

The base case \(t=0\) is immediate; now fix \(t \geq 1\) and assume the claim holds for \(t-1\). Suppose the \(i\)th outer-loop iteration reaches stage \(t\). Then stage \(t-1\) cannot have terminated in a final branch, so the only way to proceed is that Line [line:proceed-next-t] was executed at step \(t-1\). Consequently, \[\begin{align} w_{i,t-1} \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w) \qquad\text{and}\qquad \mathcal{G}_{i,t-1}=\mathcal{G}_{t-1}(w_{i,t-1}). \nonumber \end{align}\] In particular, the proposal distribution used at step \(t\) is exactly \(\bar \eta_{t-1,w_{i,t-1}}\).

At step \(t\), the while loop (Line [line:while-wit]) walks down the sampled path until the first descendant \(z \succ w_{i,t-1}\) for which either (P1) or (P2) relative to \(w_{i,t-1}\) is triggered. By the recursive definition of \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w)\) and \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\), this implies \[\begin{align} w_{i,t} \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w). \nonumber \end{align}\] If Line [line:proceed-next-t] is reached at stage \(t\), then \(w_{i,t}\) satisfies (P1) relative to \(w_{i,t-1}\), so the algorithm updates \[\begin{align} \mathcal{G}_{i,t} = \left\{ \eta \in \mathcal{G}_{i,t-1} \mid \frac{1}{R} \leq \frac{\hat{\mu}(w_{i,t})}{\eta(w_{i,t})} \leq R \right\}. \nonumber \end{align}\] Using the induction hypothesis \(\mathcal{G}_{i,t-1}=\mathcal{G}_{t-1}(w_{i,t-1})\), and using that exactly one element of each of \(\mathcal{G}_{1}(w_{i,t-1}), \mathcal{G}_2(w_{i,t-1}), \ldots, \mathcal{G}_{t-1}(w_{i,t-1})\) lies on the path from \(w\) to \(w_{i,t}\) (namely \(w_{i,1}, \ldots, w_{i,t-1}\)), it follows from the definition of \(\mathcal{G}_t(\cdot)\) (see 10 ) that \(\mathcal{G}_{i,t} = \mathcal{G}_t(w_{i,t})\). This completes the induction.

Finally, every element added to \(\mathcal{T}\) is added either on Line [line:add-to-T-mid] or on Line [line:add-to-T-end]. In the first case, the node \(w_{i,t}\) necessarily satisfies (P2) relative to the intermediate node \(w_{i,t-1}\) because some child \(w_{i,t}\circ y\) violates the upper threshold; in the second case, \(|w_{i,t}|=n\), so \(w_{i,t}\) again satisfies (P2). In both cases, the argument above shows that the added node lies in \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w) \subseteq \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\). ◻

Next, we show a key notion of “progress” made by 2. Whenever if returns a set \(\mathcal{T}\) with incomplete sequences (i.e., of length less than \(n\)), then its returned set of densities, \(\mathcal{G}^{\mathsf{ret}}\), must decrease in size relative to that of \(\mathcal{G}\).

Lemma 5. Fix any \(w \in \Sigma^{\leq n}\) and \(\mathcal{G}\subset \Delta(\Sigma^n)\). Let \(\mathcal{E}^{\mathsf{restrict}}\) denote the event that 2 returns a set \(\mathcal{T}\) for which \(\mathcal{T}\cap \Sigma^{<n} \neq \emptyset\). Then on the event \(\mathcal{E}^{\mathsf{restrict}}\), we have \(|\mathcal{G}^{\mathsf{ret}}| \leq \frac{R^2|\mathcal{G}|}{M}\).

Proof. On the event \(\mathcal{E}^{\mathsf{restrict}}\), there is at least one outer-loop iteration \(i \in [M]\) and one stage \(t \geq 1\) at which the algorithm executes Line [line:add-to-T-mid]. Fix any such pair \((i,t)\), and let \(z := w_{i,t} \in \Sigma^{<n}\) denote the node added to \(\mathcal{T}\) at that line. By the condition of the branch, there exists some \(y \in \Sigma\) such that \[\begin{align} \frac{\hat{\mu}(z \circ y)}{\hat{\mu}(w_{i,t-1}) \cdot \bar \eta_{i,t-1}(z \circ y \mid w_{i,t-1})} > M. \label{eq:gret-upper-trigger} \end{align}\tag{11}\] By definition of the class \(\mathcal{G}_{i,t-1}\) (Line [line:proceed-next-t] of 2), every \(\eta \in \mathcal{G}_{i,t-1}\) satisfies \(\frac{1}{R} \leq \frac{\hat{\mu}(w_{i,t-1})}{\eta(w_{i,t-1})} \leq R\). In particular, \(\hat{\mu}(w_{i,t-1}) \leq R \cdot \eta(w_{i,t-1})\) for every \(\eta \in \mathcal{G}_{i,t-1}\). Using that \(\bar \eta_{i,t-1} = \frac{1}{|\mathcal{G}_{i,t-1}|} \sum_{\eta \in \mathcal{G}_{i,t-1}} \eta\), we see that \(\hat{\mu}(w_{i,t-1}) \leq R \cdot \bar \eta_{i,t-1}(w_{i,t-1})\). Using this fact together with 11 , we see that \[\begin{align} \frac{\hat{\mu}(z \circ y)}{\bar \eta_{i,t-1}(z \circ y)} \geq \frac{\hat{\mu}(z \circ y)}{\bar \eta_{i,t-1}(z \circ y)} \cdot \frac{\bar \eta_{i,t-1}(w_{i,t-1})}{\hat{\mu}(w_{i,t-1})\cdot R} = \frac{\hat{\mu}(z \circ y)}{R \cdot \hat{\mu}(w_{i,t-1}) \cdot \bar \eta_{i,t-1}(z \circ y \mid w_{i,t-1})} > \frac{M}{R}\label{eq:hatmu-bareta-ratio}. \end{align}\tag{12}\] Since we have assumed that \(z\) is added to \(\mathcal{T}\) on Line [line:add-to-T-mid], then the value of \(\mathcal{G}^{\mathsf{ret}}\) eventually returned by 2 satisfies \[\begin{align} \mathcal{G}^{\mathsf{ret}}\subset \left\{ \eta \in \mathcal{G}_{i,t-1} \mid \frac{\hat{\mu}(z \circ y)}{\eta(z \circ y)} \leq R \right\}. \end{align}\] Combining this with 12 and using Markov’s inequality yields \(|\mathcal{G}^{\mathsf{ret}}| \leq |\mathcal{G}_{i,t-1}| \cdot \frac{R^2}{M} \leq |\mathcal{G}| \cdot \frac{R^2}{M}\). ◻

We let \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\) denote the set \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t_0}(w) = \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t_0+1}(w) = \cdots\). Fix any node \(w_t \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,r}(w)\). To simplify notation, we write \(\mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w) := \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w) \cup (\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w) \backslash \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w))\). Moreover, we define \[\begin{align} \mathcal{S}_{\mathcal{G},M,t}(w) := \{ w' \succeq w \mid \exists w_{t-1} \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w),\;w_t \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w) \text{ so that } w_{t-1} \prec w' \prec w \}\nonumber \end{align}\] to denote the set of nodes sandwiched between some node in \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w)\) (exclusive) and some node in \(\mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\) (exclusive). For each node \(w' \in \mathcal{S}_{\mathcal{G},M,t}(w)\) for some \(t \geq 1\), we let \(\mathfrak{p}(w')\) denote the unique ancestor of \(w'\) in \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t-1}(w)\) (its existence follows from definition and its uniqueness follows from 2). (Note that \(\mathfrak{p}(w')\) also depends on \(w, \mathcal{G}, M\), though we omit this dependence for clarity.)

Next, fix one outer-loop iteration \(i\) of 2. For \(t \geq 0\) and \(w_t \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\), let \(A_{i,t}(w_t)\) be the event that at the end of step \(t\) in iteration \(i\), the algorithm sets \(w_{i,t} = w_t\) and does not break at step \(t\) (i.e., \(\xi = 1\) in Line [line:proceed-next-t]). On \(A_{i,t}(w_t)\), the candidate class used by the algorithm (denoted by \(\mathcal{G}_{i,t}\) in 2) is exactly \(\mathcal{G}_{i,t} = \mathcal{G}_t(w_t)\), by 4. Hence, on the event \(A_{i,t}(w_t)\), the proposal distribution \(\bar \eta_{i,t}\) used in 2 is exactly \(\bar \eta_{t,w_t}\). Moreover, for \(w_t \in \mathcal{S}_{\mathcal{G},M,t}(w) \cup \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\), we let \(\bar A_{i,t}(w_t)\) be the event that the algorithm sets \(w_{i,t} = w_t\) at some point in its execution; in particular, for \(w \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\), \(\bar A_{i,t}(w_t) \supseteq A_{i,t}(w_t)\), but \(\bar A_{i,t}(w_t)\) also includes the event that the algorithm does break at step \(t\). The following lemma gives an expression for the probability of \(\bar A_{i,t}(w')\) (denoted using \(\mathbb{P}(\cdot)\)), over the randomness of 2.

Lemma 6. For any \(t \geq 1\) and \(w' \in \mathcal{S}_{\mathcal{G},M,t}(w)\), we have: \[\begin{align} \mathbb{P}(\bar A_{i,t}(w') ) = \bar \eta_{t-1, \mathfrak{p}(w')}(w' \mid \mathfrak{p}(w'))\cdot \frac{\hat{\mu}(\mathfrak{p}(w'))}{\hat{\mu}(w)}.\label{eq:ait-probs} \end{align}\tag{13}\] Moreover, for any \(w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\), the expected number of occurrences of \(w'\) in the set \(\mathcal{T}\) constructed in 2 is given as follows: \[\begin{align} \mathbb{E}\left[ \mathsf{occ}(w', \mathcal{T}) \right] = \frac{\hat{\mu}(w')}{\hat{\mu}(w)}\label{eq:exp-occurrences}. \end{align}\tag{14}\]

Proof. We first prove 13 . Fix \(t \geq 1\) and \(w' \in \mathcal{S}_{\mathcal{G},M,t}(w)\). For each \(0 \leq r < t\), let \(w_r\) denote the unique node on the path from \(w\) to \(w'\) that belongs to the simple cut \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,r}(w) \cup \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,r}(w).\nonumber\) By 4, we must have \(w_r \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,r}(w)\) for every \(0 \leq r < t\). In particular, \(w_0=w\), and for each \(1 \leq r \leq t\), the node \(w_r\) satisfies (P1) relative to \(w_{r-1}\).

For each \(1 \leq r \leq t\), conditioned on \(A_{i,r-1}(w_{r-1})\), the probability that the algorithm next reaches \(w_r\) and survives the Bernoulli test in the (P1) branch (on Line [line:proceed-next-t]) is \[\begin{align} \bar \eta_{r-1,w_{r-1}}(w_r \mid w_{r-1}) \cdot \frac{\hat{\mu}(w_r)}{\hat{\mu}(w_{r-1}) \cdot \bar \eta_{r-1,w_{r-1}}(w_r \mid w_{r-1})} = \frac{\hat{\mu}(w_r)}{\hat{\mu}(w_{r-1})}.\nonumber \end{align}\] Therefore \[\begin{align} \mathbb{P}(A_{i,t-1}(w_{t-1})) = \prod_{r=1}^{t-1} \frac{\hat{\mu}(w_r)}{\hat{\mu}(w_{r-1})} = \frac{\hat{\mu}(w_{t-1})}{\hat{\mu}(w)}.\nonumber \end{align}\] To establish 13 , we next note that \[\begin{align} \mathbb{P}(\bar A_{i,t}(w')) = \mathbb{P}(A_{i,t-1}(w_{t-1})) \cdot \bar \eta_{t-1,w_{t-1}}(w' \mid w_{t-1}) = \frac{\hat{\mu}(w_{t-1})}{\hat{\mu}(w)} \cdot \bar\eta_{t-1,w_{t-1}}(w' \mid w_{t-1})\label{eq:bar-ait-equality}, \end{align}\tag{15}\] which yields 13 by noting that \(w_{t-1} = \mathfrak{p}(w')\).

We proceed to prove 14 . Fix \(w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\), and let \(t \geq 1\) be the smallest index for which \(w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w)\). For each \(0 \leq r < t\), let \(w_r\) denote the unique node on the path from \(w\) to \(w'\) that belongs to the simple cut \(\mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,r}(w).\) It follows from the same argument used to derive 13 that \[\begin{align} \mathbb{P}(A_{i,t-1}(w_{t-1})) = \frac{\hat{\mu}(w_{t-1})}{\hat{\mu}(w)}. \label{eq:ts-rs-intermediate-chain} \end{align}\tag{16}\]

Now condition on \(A_{i,t-1}(w_{t-1})\). Since \(w'=w_t\) satisfies (P2) relative to \(w_{t-1}\), the algorithm reaches \(w'\) with probability \(\bar \eta_{t-1,w_{t-1}}(w' \mid w_{t-1})\), and then adds \(w'\) to \(\mathcal{T}\) (on either Line [line:add-to-T-mid] or Line [line:add-to-T-end]) with Bernoulli probability \[\begin{align} \frac{\hat{\mu}(w')}{\hat{\mu}(w_{t-1}) \cdot \bar \eta_{t-1,w_{t-1}}(w' \mid w_{t-1})} \cdot \frac{1}{M}. \nonumber \end{align}\] This Bernoulli parameter is indeed at most \(1\): the node \(w'\) was obtained by extending from \(w_{t-1}\) in the immediately preceding step of the while loop, and that extension could only occur while the while-condition in Line [line:while-wit] held. Thus, if \(B_i\) denotes the event that the \(i\)th outer-loop iteration contributes one copy of \(w'\) to \(\mathcal{T}\), then \[\begin{align} \mathbb{P}(B_i \mid A_{i,t-1}(w_{t-1})) = \bar \eta_{t-1,w_{t-1}}(w' \mid w_{t-1}) \cdot \frac{\hat{\mu}(w')}{\hat{\mu}(w_{t-1}) \cdot \bar \eta_{t-1,w_{t-1}}(w' \mid w_{t-1})} \cdot \frac{1}{M} = \frac{\hat{\mu}(w')}{M \cdot \hat{\mu}(w_{t-1})}.\nonumber \end{align}\] Combining this with 16 , we obtain \[\begin{align} \mathbb{P}(B_i) = \frac{\hat{\mu}(w_{t-1})}{\hat{\mu}(w)} \cdot \frac{\hat{\mu}(w')}{M \cdot \hat{\mu}(w_{t-1})} = \frac{\hat{\mu}(w')}{M \cdot \hat{\mu}(w)}.\nonumber \end{align}\]

Each outer-loop iteration contributes at most one copy of \(w'\) to \(\mathcal{T}\), and the \(M\) outer-loop iterations are identically distributed. Therefore \[\begin{align} \mathbb{E}[\mathsf{occ}(w',\mathcal{T})] = \sum_{i=1}^M \mathbb{P}(B_i) = M \cdot \frac{\hat{\mu}(w')}{M \cdot \hat{\mu}(w)} = \frac{\hat{\mu}(w')}{\hat{\mu}(w)},\nonumber \end{align}\] as claimed. ◻

The next lemma bounds the query complexity of a single call to 2 in terms of the weighted depths of the returned nodes.

Lemma 7. The expected number of oracle calls to \(\hat{\mu}\) made by 2 is bounded above by \[\begin{align} O \left( |\Sigma| \cdot R \cdot M^2 \right) \cdot \left( \mathbb{E}\left[\sum_{w' \in \mathcal{T}} \frac{\mu^\star(w')}{\hat{\mu}(w')} \cdot |w'| \right] - \frac{\mu^\star(w)}{\hat{\mu}(w)} \cdot |w|\right)\nonumber. \end{align}\] Moreover, the number of oracle calls is bounded almost surely by \(O(|\Sigma| M n)\).

Proof. For each \(i \in [M]\), let \(T_i \in \mathbb{N}\) denote the final value of \(t\) reached in the for loop in Line [line:for-t] of 2, in outer iteration \(i\). The expected number of oracle calls made by 2, which we denote by the random variable \(V\), may be bounded as follows: \[\begin{align} \mathbb{E}[V] \leq M |\Sigma| \cdot O \left( \sum_{t=1}^n \sum_{w' \in \mathcal{S}_{\mathcal{G},M,t}(w)} \mathbb{P}(\bar A_{i,t}(w'))+ \mathbb{E}[T_i+1]\right)\label{eq:ev-init-bnd}. \end{align}\tag{17}\] Indeed, for each outer loop iteration \(i \in [M]\), 2 queries \(\hat{\mu}\) at each of the nodes along the path \(w_{i,0} \to w_{i,1} \to \cdots \to w_{i,T_i}\), as well as at each of the children of each of these nodes (in order to check the condition in the while statement on [line:while-wit]). For each \(0 \leq t \leq T_i\), we have \(w_t \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\): the first term in 17 accounts for the queries made at the nodes in-between the \(w_{i,t}\), and the second term accounts for the queries made at the nodes \(w_{i,t}\).

First, we note that, since \(M \geq 2\), we have \(\mathbb{P}(T_i \geq t+1 \mid T_i \geq t) \leq 1/M \leq 1/2\) for each \(t \geq 0\). Thus, \(\mathbb{E}[T_i] \leq 4\). We proceed to bound the first term in 17 .

Next, for any \(t \geq 1\), we compute \[\begin{align} & \sum_{w' \in \mathcal{S}_{\mathcal{G},M,t}(w)} \mathbb{P}(\bar A_{i,t}(w')) \nonumber\\ = & \sum_{w' \in \mathcal{S}_{\mathcal{G},M,t}(w)} \frac{\bar \eta_{t-1,\mathfrak{p}(w')}(w') \cdot \hat{\mu}(\mathfrak{p}(w'))}{\hat{\mu}(w)}\nonumber\\ \leq &\sum_{w' \in \mathcal{S}_{\mathcal{G},M,t}(w)} \frac{M \cdot \hat{\mu}(w')}{\hat{\mu}(w)}\nonumber\\ \leq & \sum_{w' \in \mathcal{S}_{\mathcal{G},M,t}(w)} \frac{MR \cdot \mu^\star(w')}{\hat{\mu}(w)}\nonumber\\ = & \sum_{w' \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)} \frac{MR \cdot \mu^\star(w')}{\hat{\mu}(w)} \cdot (|w' - \mathfrak{p}(w')| - 1)\label{eq:aitbar-bound}, \end{align}\tag{18}\] where:

  • The first equality uses 13 of 6.

  • The following inequality uses the fact that \(w'\) (not being in \(\mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\)) does not satisfy (P1), which gives \[\begin{align} \frac{\hat{\mu}(w')}{\hat{\mu}(\mathfrak{p}(w')) \cdot \bar \eta_{t-1,\mathfrak{p}(w')}(w' \mid \mathfrak{p}(w'))} \geq \frac{1}{M}.\label{eq:muhat-parent} \end{align}\tag{19}\]

  • The following inequality uses 1.

  • The final equality rearranges the summation, using that for each \(w' \in \mathcal{S}_{\mathcal{G},M,t}(w)\) we can write \[\begin{align} \mu^\star(w') = \sum_{\substack{x \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w) \\ w' \prec x}} \mu^\star(x)\nonumber \end{align}\] as \(\mu^\star\) is a distribution; further, each element \(w' \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\) is preceded by exactly \(|w' - \mathfrak{p}(w')| - 1\) elements of \(\mathcal{S}_{\mathcal{G},M,t}(w)\).

Summing 18 over \(t \geq 1\), we see that \[\begin{align} \sum_{t=1}^n \sum_{w' \in \mathcal{S}_{\mathcal{G},M,t}(w)} \mathbb{P}(\bar A_{i,t}(w')) \leq & \sum_{t=1}^n \sum_{w' \in \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)} \frac{MR \cdot \mu^\star(w')}{\hat{\mu}(w)} \cdot |w' - \mathfrak{p}(w')|\nonumber\\ = & \sum_{w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)} \frac{MR \cdot \mu^\star(w')}{\hat{\mu}(w)} \cdot |w' - w|\nonumber\\ =& \sum_{w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)} \frac{MR \cdot \mu^\star(w')}{\hat{\mu}(w)} \cdot (|w'| - |w|)\nonumber\\ =& \sum_{w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)} \frac{MR \cdot \mu^\star(w')}{\hat{\mu}(w)} \cdot |w'| - \frac{MR \cdot \mu^\star(w)}{\hat{\mu}(w)} \cdot |w|\nonumber\\ =& MR \cdot \left( \mathbb{E}\left[\sum_{w' \in \mathcal{T}} \frac{\mu^\star(w')}{\hat{\mu}(w')} \cdot |w'| \right] - \frac{\mu^\star(w)}{\hat{\mu}(w)} \cdot |w|\right)\label{eq:barait-final}, \end{align}\tag{20}\] where:

  • The first inequality uses 18 for each \(t\).

  • The following equality uses again the fact that \(\mu^\star\) is a distribution, writing, for each \(w' \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,t}(w) \subset \mathcal{N}^{\mathsf{append}}_{\mathcal{G},M,t}(w)\), \[\begin{align} \mu^\star(w') = \sum_{\substack{x \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w) \\ w' \prec x}} \mu^\star(x)\nonumber. \end{align}\] Moreover, for each \(w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\), if we choose \(t\) so that \(w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t}(w) \backslash \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M,t-1}(w)\), there is some \(w_s \in \mathcal{N}^{\mathsf{int}}_{\mathcal{G},M,s}(w)\) for each \(1 \leq s < t\) so that \(w_s \prec w'\), and summing \(|w_s - \mathfrak{p}(w_s)| = |w_s - w_{s-1}|\) over \(1 \leq s < t\) gives \(|w' - w|\).

  • The following equality uses the fact that \(|w' - w| = |w'| - |w|\) for \(w \succ w\).

  • The following equality uses that \(\mu^\star\) is a distribution and \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\) is a simple \(w\)-cut (2).

  • The final equality uses 14 of 6, which gives \(\mathbb{E}[\mathsf{occ}(w',\mathcal{T})] = \hat{\mu}(w')/\hat{\mu}(w)\) for each \(w' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{G},M}(w)\).

The claim of the lemma follows by combining 20 with 17 together with the fact that \(|w'| - |w| \geq 1\) for all \(w' \in \mathcal{T}\) and the fact that \(\mathbb{E}\left[ \sum_{w' \in \mathcal{T}} \frac{\mu^\star(w')}{\hat{\mu}(w')} \right] \geq 1/R\) (which follows from 14 of 6). ◻

Figure 3: Particle Filtering with Learning

3.2 Analysis of 3↩︎

We are now ready to analyze 3. We let \(J\) denote the total number of iterations executed by 3, i.e., the smallest index such that every element of \(\mathcal{S}^J\) has length \(n\). For convenience, for all \(j > J\) we set \(\mathcal{S}^j := \mathcal{S}^J\). Finally, for each \(j \geq 0\), let \(\mathscr{F}^j\) denote the sigma-algebra generated by all random variables in 3 up to the end of the \(j\)th iteration of the loop. Using the fact that the size of \(\mathcal{F}^j\) is decreased whenever 2 returns particles of length less than \(n\) (5), we first bound the number of iterations \(J\):

Lemma 8. With probability \(1\), we have \(J \leq 2 \bar R \cdot \log_2 |\mathcal{F}| + N\).

Proof. Consider any iteration \(j\) for which \(\mathcal{T}_j \cap \Sigma^{<n} \neq \emptyset\); 5 gives that for any such \(j\), we have \(|\mathcal{F}^{j+1}| \leq |\mathcal{F}^j| \cdot \frac{R^2}{\bar R} \leq |\mathcal{F}^j|/2\). Thus, the number of iterations \(j\) for which \(\mathcal{T}_j \cap \Sigma^{<n} \neq \emptyset\) is bounded above by \(\log_2 |\mathcal{F}|\). Since \(|\mathcal{T}_j| \leq \bar R\) almost surely for all \(j\) by the structure of 2, and all elements of \(\mathcal{S}^{j'} \backslash \mathcal{S}^0\) for any \(j' \in [J]\) are elements of some \(\mathcal{T}^j\) for some \(j < j'\), it follows that \(|\mathcal{S}^{j'}| \leq N + \bar R \cdot \log_2 |\mathcal{F}|\) for all \(j' \geq 1\).

Further, in any iteration \(j\) for which \(\mathcal{T}^j \cap \Sigma^{<n} = \emptyset\), we have \(|\mathcal{S}^{j} \cap \Sigma^{<n}| = |\mathcal{S}^{j-1} \cap \Sigma^{<n}| - 1\). It follows that \(J \leq \log_2 |\mathcal{F}| + \max_{j \geq 1} |\mathcal{S}^j| \leq 2 \bar R \cdot \log_2 |\mathcal{F}| + N\). ◻

Next, using 6, we give an expression for the expected number of times each ancestor of a given sequence \(x \in \Sigma^n\) will occur in one of the multisets \(\mathcal{S}^j\).

Lemma 9. For each \(x \in \Sigma^n\) and \(j \geq 0\), it holds that \(\left( \sum_{x' \in \mathcal{S}^j} \frac{\mathbb{1}\left\{{x' \preceq x}\right\}}{\hat{\mu}(x')} \right)_{j \geq 0}\) is a martingale with respect to \((\mathscr{F}^j)_{j \geq 0}\), and in particular \[\begin{align} \mathbb{E}\left[ \sum_{x' \in \mathcal{S}^j} \frac{\mathbb{1}\left\{{x' \preceq x}\right\}}{\hat{\mu}(x')} \right] = N\nonumber. \end{align}\]

Proof. For a fixed \(x \in \Sigma^n\), define \[\begin{align} \Phi_x(\mathcal{T}) := \sum_{x' \in \mathcal{T}} \frac{\mathbb{1}\left\{{x' \preceq x}\right\}}{\hat{\mu}(x')}\nonumber. \end{align}\] for any multiset \(\mathcal{T}\) of particles. We claim that \((\Phi_x(\mathcal{S}^j))_{j \geq 0}\) is a martingale with respect to \((\mathscr{F}^j)_{j \geq 0}\).

Fix any \(j \geq 1\). If \(j > J\), then \(\mathcal{S}^j = \mathcal{S}^{j-1}\) by definition, and there is nothing to prove. Suppose therefore that \(1 \leq j \leq J\). The update from \(\mathcal{S}^{j-1}\) to \(\mathcal{S}^j\) removes one copy of \(z_j\) from \(\mathcal{S}^{j-1}\) and then adds the multiset \(\mathcal{T}_j\) returned by 2. If \(z_j\not\preceq x\), then no element of \(\mathcal{T}_j\) can be an ancestor of \(x\), and so \(\Phi_x(\mathcal{S}^j) = \Phi_x(\mathcal{S}^{j-1})\). Otherwise, suppose that \(z_j \preceq x\). Conditioned on \(\mathscr{F}^{j-1}\), there is a unique ancestor of \(x\) that can belong to \(\mathcal{T}_j\), namely the unique ancestor of \(x\) in \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{F}^{j},\bar R}(z_j)\); denote this element by \(w_j\). Thus, we have \[\begin{align} \mathbb{E}\left[ \sum_{w \in \mathcal{T}_j} \frac{\mathbb{1}\left\{{w \preceq x}\right\}}{\hat{\mu}(w)} \mid \mathscr{F}^{j-1}\right] =& \mathbb{E}\left[ \frac{\mathsf{occ}(w_j, \mathcal{T}_j)}{\hat{\mu}(w_j)} \mid \mathscr{F}^{j-1}\right] \nonumber\\ =& \frac{\hat{\mu}(w_j)}{\hat{\mu}(z_j)} \cdot \frac{1}{\hat{\mu}(w_j)} = \frac{1}{\hat{\mu}(z_j)}\nonumber, \end{align}\] where the second equality uses 14 of 6.

Hence, on the (\(\mathscr{F}^{j-1}\)-measurable) event that \(z_j \preceq x\), we have \[\begin{align} \mathbb{E}\!\left[\Phi_x(\mathcal{S}^j)-\Phi_x(\mathcal{S}^{j-1}) \mid \mathscr{F}^{j-1} \right] = -\frac{1}{\hat{\mu}(z_j)} + \mathbb{E}\left[ \sum_{w \in \mathcal{T}_j} \frac{\mathbb{1}\left\{{w \preceq x}\right\}}{\hat{\mu}(w)} \mid \mathscr{F}^{j-1}\right] = 0.\nonumber \end{align}\]

Thus \((\Phi_x(\mathcal{S}^j))_{j \geq 0}\) is a martingale. At time \(0\), the multiset \(\mathcal{S}^0\) consists of \(N\) copies of the empty sequence, so by the convention \(\hat{\mu}(\emptyset) = 1\) we have \[\begin{align} \Phi_x(\mathcal{S}^0) = \frac{N}{\hat{\mu}(\emptyset)} = N.\nonumber \end{align}\] Combining this base case with the martingale property yields \(\mathbb{E}[\Phi_x(\mathcal{S}^j)] = N\) for every \(j \geq 0\), which is exactly the claimed identity. ◻

As a corollary of 9, we can show that each \(x \in \Sigma^n\) occurs in \(\mathcal{S}^{\mathsf{term}}\) a number of times that is proportional to its true density \(\mu^\star(x)\).

Lemma 10 (Unbiasedness). For each \(x \in \Sigma^n\), it holds that \(\mathbb{E}[\mathsf{occ}(x, \mathcal{S}^{\mathsf{term}})] = N \cdot \mu^\star(x)\), where the expectation is over the randomness in 3.

Proof. Fix \(x \in \Sigma^n\). Note that \(J\) is a stopping time for the filtration \((\mathscr{F}^j)_{j\geq 0}\). The optional stopping theorem gives \[\begin{align} \mathbb{E}\left[ \sum_{x' \in \mathcal{S}^J} \frac{\mathbb{1}\left\{{x' \preceq x}\right\}}{\hat{\mu}(x')} \right] = \mathbb{E}[\Phi_x(\mathcal{S}^J)] = \mathbb{E}[\Phi_x(\mathcal{S}^0)] = N\nonumber. \end{align}\] By definition of \(J\), every element of \(\mathcal{S}^J = \mathcal{S}^{\mathsf{term}}\) has length \(n\). Since \(x \in \Sigma^n\), the condition \(x' \preceq x\) for \(x' \in \mathcal{S}^J\) is equivalent to \(x' = x\). Together with the assumption that \(\mu^\star(x) = \hat{\mu}(x)\) for \(x \in \Sigma^n\), this gives \(\mathbb{E}\left[ \sum_{x' \in \mathcal{S}^J} \frac{\mathbb{1}\left\{{x' = x}\right\}}{\mu^\star(x')} \right] = N,\) which yields the desired statement after rearranging. ◻

For each \(j \geq 0\), we define \(M_j := \sum_{x \in \mathcal{S}^j} \frac{\mu^\star(x)}{\hat{\mu}(x)}\). The next lemma shows that this total reweighted mass is itself a martingale along the execution of the algorithm.

Lemma 11. \((M_j)_{j \geq 0}\) is a martingale with respect to the filtration \((\mathscr{F}^j)_{j \geq 0}\), i.e., for every \(j \geq 1\) we have \(\mathbb{E}[M_j \mid \mathscr{F}^{j-1}] = M_{j-1}\).

Proof. Fix any \(j \geq 1\). If \(j > J\), then \(M_j = M_{j-1}\) by definition, so the claim is immediate. For each \(1 \leq j \leq J\), we have \[\begin{align} M_j - M_{j-1} = \sum_{x' \in \mathcal{T}_j} \frac{\mu^\star(x')}{\hat{\mu}(x')} - \frac{\mu^\star(z_j)}{\hat{\mu}(z_j)}\nonumber. \end{align}\] It therefore suffices to show \[\begin{align} \mathbb{E}\left[ \sum_{x' \in \mathcal{T}_j} \frac{\mu^\star(x')}{\hat{\mu}(x')} \mid \mathscr{F}^{j-1} \right] = \frac{\mu^\star(z_j)}{\hat{\mu}(z_j)}.\label{eq:ij-mtgl} \end{align}\tag{21}\] Recall that \(\mathcal{T}_j \subset \mathcal{N}^{\mathsf{fin}}_{\mathcal{F}^j, \bar R}(z_j)\) by 4. Then we may compute \[\begin{align} \mathbb{E}\left[ \sum_{x' \in \mathcal{T}_j} \frac{\mu^\star(x')}{\hat{\mu}(x')} \mid \mathscr{F}^{j-1} \right] =& \sum_{x' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{F}^j, \bar R}(z_j)} \frac{\mu^\star(x')}{\hat{\mu}(x')} \cdot \mathbb{E}[\mathsf{occ}(x', \mathcal{T}_j) \mid \mathscr{F}^{j-1}] \nonumber\\ =& \sum_{x' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{F}^j, \bar R}(z_j)} \frac{\mu^\star(x')}{\hat{\mu}(x')} \cdot \frac{\hat{\mu}(x')}{\hat{\mu}(z_j)} \nonumber\\ =& \frac{1}{\hat{\mu}(z_j)} \sum_{x' \in \mathcal{N}^{\mathsf{fin}}_{\mathcal{F}^j, \bar R}(z_j)} \mu^\star(x') = \frac{\mu^\star(z_j)}{\hat{\mu}(z_j)}\label{eq:mij-mtgl}, \end{align}\tag{22}\] where the second equality uses 14 of 6 and the final equality uses the fact that \(\mathcal{N}^{\mathsf{fin}}_{\mathcal{F}^j, \bar R}(z_j)\) is a simple \(z_j\)-cut (2). ◻

Next, we use Azuma’s inequality to bound the martingale \(M_j\):

Lemma 12. Fix any \(\delta \in (0,1)\). Then the martingale \((M_j)_{j \geq 0}\) satisfies \[\begin{align} \mathbb{P}\left(\max_{1 \leq j \leq J} |M_j - M_0| \leq \frac{M_0}{2}\right) \geq 1-\frac{\delta}{2R}, \qquad \mathbb{E}\left[\left(\frac{M_J}{2RN}-1\right)_+\right] \leq \frac{\delta}{2R} \nonumber. \end{align}\]

Proof. Let \(T := 2 \bar R \cdot \log_2 |\mathcal{F}| + N\), so that 8 ensures that \(J \leq T\) with probability \(1\). For \(1 \leq j \leq J\), \(|\mathcal{T}_j| \leq \bar R\) almost surely and so \(0 \leq \sum_{x' \in \mathcal{T}_j} \frac{\mu^\star(x')}{\hat{\mu}(x')} \leq R \cdot \bar R\); thus \(|M_j - M_{j-1}| \leq R \bar R\) for all \(j\). Using the fact that a random variable \(M\) taking values in \([0,A]\) satisfies \(\log \mathbb{E}[\exp(\lambda \cdot (A - \mathbb{E}[A]))] \leq \lambda^2 A^2 / 8\), together with the fact that \(\mathbb{E}[M_j - M_{j-1} \mid \mathscr{F}^{j-1}] = 0\) (which was established in 11), we may conclude that for any \(\lambda \in \mathbb{R}\), \[\begin{align} \log \mathbb{E}\left[ \exp(\lambda \cdot (M_j - M_{j-1})) \mid \mathscr{F}^{j-1}\right] \leq \lambda^2 (R \bar R)^2\label{eq:mgf-bound-for-freedman}. \end{align}\tag{23}\] Since \(M_j=M_J\) for all \(j \geq J\), iterating the preceding conditional moment-generating function bound up to the deterministic time \(T\) gives, for every \(\lambda \geq 0\), \[\begin{align} \log \mathbb{E}\left[\exp(\lambda \cdot (M_J-M_0))\right] \leq T\lambda^2(R\bar R)^2.\nonumber \end{align}\] Therefore, for every \(s > 0\), \(\mathbb{P}(M_J-M_0 > s) \leq \exp\left(-\frac{s^2}{4T(R\bar R)^2}\right).\) Using \(M_0=N\) and \(R \geq 1\), it follows that \[\begin{align} \mathbb{E}\left[\left(\frac{M_J}{2RN}-1\right)_+\right] &= \frac{1}{2RN}\int_{(2R-1)N}^{\infty} \mathbb{P}(M_J-M_0 > s)\,ds \nonumber\\ &\leq \frac{1}{2RN}\int_N^{\infty} \exp\left(-\frac{s^2}{4T(R\bar R)^2}\right)\,ds \nonumber\\ &\leq \frac{T(R\bar R)^2}{RN^2}\exp\left(-\frac{N^2}{4T(R\bar R)^2}\right) \leq \frac{\delta}{2R},\nonumber \end{align}\] where the final inequality follows from the choice of \(N\) in 3, after increasing the absolute constant \(C_{\mathsf{N}}\) if necessary.

Moreover, using 23 , by 23 and a union bound over \(j \in [T]\) it follows that for any \(\lambda \in \mathbb{R}\), with probability at least \(1-\delta/(4R)\), for all \(1 \leq j \leq J\), we have \[\begin{align} \lambda \cdot (M_j - M_0) \leq j \cdot \lambda^2 (R \bar R)^2 + \log(4RT/\delta)\nonumber. \end{align}\] Rearranging and choosing \(\lambda =\pm\frac{\sqrt{\log (4RT/\delta)}}{\sqrt{T} \cdot R \bar R}\) gives that, with probability \(1-\delta/2R\), \[\begin{align} \max_{1 \leq j \leq J} |M_j - M_0| \leq & |\lambda |\cdot j (R \bar R)^2 + \frac{\log (4RT/\delta)}{|\lambda|} \leq O \left( R \bar R \cdot \sqrt{T \log (R\log_2(|\mathcal{F}|) N/\delta)} \right) \nonumber\\ \leq & O \left(R \bar R \sqrt{(\bar R \cdot \log_2 |\mathcal{F}| + N) \cdot \log (R\log_2(|\mathcal{F}|) N/\delta)} \right) \leq \frac{N}{2} = \frac{M_0}{2}\nonumber, \end{align}\] where the final inequality uses the choice of \(N\) in 3 for an appropriately large constant \(C_{\mathsf{N}}\). ◻

Next, we convert the preceding unbiasedness and concentration bounds for the martingale \(M_j\) into correctness of the output distribution.

Lemma 13. For any \(\delta \in (0,1/2)\), 3 with the parameter \(\delta\) outputs a sample from a distribution \(\mu_{\mathsf{alg}}\) satisfying \(D_{\mathsf{TV}}({\mu^\star}, {\mu_{\mathsf{alg}}}) \leq \delta\).

Proof. Fix one outer-loop iteration (i.e., over \(k \in [K]\)). Let \(X\) denote the random variable which is equal to the sample returned in that iteration if the final Bernoulli step succeeds, and is equal to \(\bot\) otherwise. By 10, we have, for any set \(\mathcal{A}\subseteq \Sigma^n\), \[\begin{align} \mathbb{P}(X\in \mathcal{A}) = \mathbb{E}\left[ \sum_{x \in \mathcal{A}} \frac{\mathsf{occ}(x, \mathcal{S}^{\mathsf{term}})}{|\mathcal{S}^{\mathsf{term}}|} \cdot \min \left\{ 1, \frac{|\mathcal{S}^{\mathsf{term}}|}{2RN} \right\} \right] \leq \frac{1}{2R} \cdot \mu^\star(\mathcal{A}).\label{eq:single-round-output-law} \end{align}\tag{24}\] For the lower bound, note that the pointwise inequality \[\begin{align} \sum_{x \in \mathcal{A}} \frac{\mathsf{occ}(x, \mathcal{S}^{\mathsf{term}})}{|\mathcal{S}^{\mathsf{term}}|} \cdot \min \left\{1, \frac{|\mathcal{S}^{\mathsf{term}}|}{2RN}\right\} \geq \frac{1}{2RN}\sum_{x \in \mathcal{A}}\mathsf{occ}(x,\mathcal{S}^{\mathsf{term}}) - \left(\frac{|\mathcal{S}^{\mathsf{term}}|}{2RN}-1\right)_+ \nonumber \end{align}\] holds for every realization of \(\mathcal{S}^{\mathsf{term}}\), where the left-hand side is interpreted as \(0\) if \(|\mathcal{S}^{\mathsf{term}}|=0\). Therefore, \[\begin{align} \mathbb{P}(X \in \mathcal{A}) &\geq \frac{1}{2RN}\mathbb{E}\left[\sum_{x \in \mathcal{A}} \mathsf{occ}(x,\mathcal{S}^{\mathsf{term}})\right] - \mathbb{E}\left[\left(\frac{|\mathcal{S}^{\mathsf{term}}|}{2RN}-1\right)_+\right] \nonumber\\ &\geq \frac{1}{2R} \cdot \mu^\star(\mathcal{A}) - \frac{\delta}{2R}.\label{eq:single-round-output-lb} \end{align}\tag{25}\] It follows that \(\frac{1}{2R} - \frac{\delta}{2R}\leq \mathbb{P}(X \neq \perp) \leq \frac{1}{2R}\), and so \[\begin{align} \mu^\star(\mathcal{A}) - \delta\leq \mathbb{P}(X \in \mathcal{A}\mid X \neq \perp) \leq \mu^\star(\mathcal{A}) \cdot \frac{1}{1-\delta} \leq \mu^\star(\mathcal{A}) \cdot (1 + \delta)\label{eq:mustar-close}. \end{align}\tag{26}\] Let \(\tilde{\mu}^{\mathsf{alg}}\in \Delta(\Sigma^n)\) be the distribution defined by \(\tilde{\mu}^{\mathsf{alg}}(x) := \mathbb{P}(X = x \mid X \neq \perp)\). Then 26 gives that \(D_{\mathsf{TV}}({\mu^\star}, {\tilde{\mu}^{\mathsf{alg}}}) \leq \delta\). By our choice of \(K = \lceil 4R \log_2(1/\delta) \rceil\) and the fact that each outer-loop iteration produces a symbol which is not \(\perp\) with probability at least \(\frac{1}{2R} - \frac{\delta}{2R} \geq \frac{1}{4R}\), with probability at least \(1-\delta\), some outer loop iteration will produce a symbol which is not \(\perp\), and which is therefore distributed according to \(\tilde{\mu}^{\mathsf{alg}}\). It follows that \(D_{\mathsf{TV}}({\mu^\star}, {\mu_{\mathsf{alg}}}) \leq 2\delta\); the claimed result follows by rescaling \(\delta\). ◻

The final lemma uses the oracle complexity bound of 7 to derive the overall oracle complexity guarantee for 3.

Lemma 14. The number of oracle calls to \(\hat{\mu}\) made by 3 is upper bounded by \[\begin{align} O\left(n \cdot |\Sigma| \cdot K \cdot R \bar R^2 \cdot \left\lceil \sqrt{\log |\mathcal{F}|} \cdot R^2 \bar R^2 \left( \log \frac{R \log |\mathcal{F}|}{\delta}\right) \right\rceil \right) = O\left(n \cdot |\Sigma| \cdot R^{12} \cdot \sqrt{\log |\mathcal{F}|} \cdot \log \frac{1}{\delta} \cdot \left(\log \frac{R \log |\mathcal{F}|}{\delta}\right) \right)\nonumber \end{align}\] with probability \(1-\delta\).

Proof. For each \(j \geq 1\), we let the random variable \(V_j\) denote the number of oracle calls to \(\hat{\mu}\) made by 2 in Line [line:rs-call] of 3 during step \(j\) of the algorithm. By 7, we have \[\begin{align} \mathbb{E}[V_j \mid \mathscr{F}^{j-1}] \leq O \left(|\Sigma| \cdot R \cdot \bar R^2 \right) \cdot \mathbb{E}\left[ \sum_{x \in \mathcal{T}_j} \frac{\mu^\star(x)}{\hat{\mu}(x)} \cdot |x| - \frac{\mu^\star(z_j)}{\hat{\mu}(z_j)} \cdot |z_j| \mid \mathscr{F}^{j-1} \right]\label{eq:vj-update}. \end{align}\tag{27}\] Next, we define a random variable \[\begin{align} W_j = \sum_{x \in \mathcal{S}_j}\frac{\mu^\star(x)}{\hat{\mu}(x)} \cdot |x|\nonumber. \end{align}\] Note that \[\begin{align} W_j = W_{j-1} - \frac{\mu^\star(z_j)}{\hat{\mu}(z_j)} \cdot |z_j| + \sum_{x \in \mathcal{T}_j} \frac{\mu^\star(x)}{\hat{\mu}(x)} \cdot |x| \label{eq:wj-update}, \end{align}\tag{28}\] so that 27 28 give \[\begin{align} \mathbb{E}[V_j \mid \mathscr{F}^{j-1}] \leq O \left(|\Sigma| \cdot R \cdot \bar R^2 \right) \cdot \mathbb{E}[W_j - W_{j-1} \mid \mathscr{F}^{j-1}].\label{eq:vj-wj} \end{align}\tag{29}\] It follows that \[\begin{align} \mathbb{E}\left[ \sum_{j=1}^J V_j \right] \leq O(|\Sigma| R \bar R^2) \cdot \mathbb{E}[W_J] = O(n \cdot |\Sigma| R \bar R^2) \cdot \mathbb{E}[M_J] = O(Nn \cdot |\Sigma| R \bar R^2)\nonumber. \end{align}\] Let \(T := 2 \bar R \cdot \log_2 |\mathcal{F}| + N\), so that \(J \leq T\) almost surely by 8. Fix one outer-loop iteration of 3. For each \(j \in [T]\), define \(\Gamma_j := V_j - \mathbb{E}[V_j \mid \mathscr{F}^{j-1}],\) where for \(j > J\) we interpret \(V_j := 0\). Then \((\sum_{s=1}^j \Gamma_s)_{j \in [T]}\) is a martingale. By the almost-sure bound in 7, \(|\Gamma_j| \leq O(|\Sigma| \bar R n)\) for every \(j\). Applying Azuma’s inequality, with probability at least \(1-\delta/(4K)\) we have \[\begin{align} \sum_{j=1}^J V_j \leq \sum_{j=1}^J \mathbb{E}[V_j \mid \mathscr{F}^{j-1}] + O\left(|\Sigma| \bar R n \sqrt{T \log \frac{K}{\delta}}\right).\label{eq:oracle-calls-v-azuma} \end{align}\tag{30}\] Next, define \[\begin{align} \Delta_j := (W_j - W_{j-1}) - \mathbb{E}[W_j - W_{j-1} \mid \mathscr{F}^{j-1}],\nonumber \end{align}\] where for \(j > J\) we interpret \(W_j := W_J\). Then \((\sum_{s=1}^j \Delta_s)_{j \in [T]}\) is a martingale. Since \(|\mathcal{T}_j| \leq \bar R\) almost surely and \(\mu^\star(x)/\hat{\mu}(x) \leq R\) for every \(x\), we have \[\begin{align} |W_j - W_{j-1}| \leq Rn(\bar R + 1) = O(R \bar R n)\nonumber \end{align}\] for every \(j\), and hence \(|\Delta_j| \leq O(R \bar R n)\). Applying Azuma’s inequality, with probability at least \(1-\delta/(4K)\) we therefore have \[\begin{align} \sum_{j=1}^J \mathbb{E}[W_j - W_{j-1} \mid \mathscr{F}^{j-1}] \leq W_J - W_0 + O\left(R \bar R n \sqrt{T \log \frac{K}{\delta}}\right).\label{eq:oracle-calls-w-azuma} \end{align}\tag{31}\] Since \(W_0 = 0\), 29 31 imply that, with probability at least \(1-\delta/(4K)\), \[\begin{align} \sum_{j=1}^J \mathbb{E}[V_j \mid \mathscr{F}^{j-1}] \leq O(|\Sigma| R \bar R^2) \cdot W_J + O\left(|\Sigma| R^2 \bar R^3 n \sqrt{T \log \frac{K}{\delta}}\right).\label{eq:oracle-calls-predictable} \end{align}\tag{32}\] Since \[\begin{align} N = C_{\mathsf{N}} \left\lceil \sqrt{\log |\mathcal{F}|} \cdot R^2 \bar R^2 \left( \log \frac{R \log |\mathcal{F}|}{\delta}\right) \right\rceil\nonumber \end{align}\] and by 12 we have, after increasing \(C_{\mathsf{N}}\) if needed, that \(M_J \leq 3N/2\) with probability at least \(1-\delta/(4K)\), it follows that with the same probability \(W_J \leq n M_J \leq 3nN/2.\) Combining this with 30 32 yields that, with probability at least \(1-3\delta/(4K)\), \[\begin{align} \sum_{j=1}^J V_j \leq O(|\Sigma| R \bar R^2) \cdot nN + O\left(|\Sigma| R^2 \bar R^3 n \sqrt{T \log \frac{K}{\delta}}\right) + O\left(|\Sigma| \bar R n \sqrt{T \log \frac{K}{\delta}}\right).\nonumber \end{align}\] Using \(T = O(\bar R \log |\mathcal{F}| + N)\) together with \(K = O(R \log(1/\delta))\), the choice of \(N\) ensures that the second and third terms are both absorbed into the main term for a sufficiently large absolute constant \(C_{\mathsf{N}}\). Therefore, one outer-loop iteration uses at most \[\begin{align} O\left(n \cdot |\Sigma| \cdot R \bar R^2 \cdot \left\lceil \sqrt{\log |\mathcal{F}|} \cdot R^2 \bar R^2 \left(\log \frac{R \log |\mathcal{F}|}{\delta}\right) \right\rceil \right)\nonumber \end{align}\] oracle calls with probability at least \(1-\delta/K\). Summing over the \(K\) outer-loop iterations and using a union bound proves that the total number of oracle calls made by 3 is at most \[\begin{align} O\left(n \cdot |\Sigma| \cdot K \cdot R \bar R^2 \cdot \left\lceil \sqrt{\log |\mathcal{F}|} \cdot R^2 \bar R^2 \left(\log \frac{R \log |\mathcal{F}|}{\delta}\right) \right\rceil \right)\nonumber, \end{align}\] with probability at least \(1-\delta\). Using \(\bar R = 2R^2\) and \(K = \lceil 4R\log_2(1/\delta) \rceil\) gives the second displayed bound in the lemma statement. ◻

Finally, we are ready to prove 3.

Proof of 3. Run 3 with failure tolerance \(\delta/2\). By 13, its output distribution \(\hat{\nu}'\) satisfies \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}'}) \leq \delta/2\). By 14, with probability at least \(1-\delta/2\), the number of oracle calls made by the algorithm is at most \[\begin{align} O\left(n \cdot |\Sigma| \cdot R^{12} \cdot \sqrt{\log |\mathcal{F}|} \cdot \log \frac{1}{\delta} \cdot \left(\log \frac{R \log |\mathcal{F}|}{\delta}\right) \right)\label{eq:final-oracle-ub}. \end{align}\tag{33}\] We can modify 3 so that, whenever its number of oracle calls reaches the threshold in 33 , it aborts and outputs an arbitrary symbol. This changes its output distribution by at most \(\delta/2\) in total variation distance, meaning that the resulting output distribution, which we denote by \(\hat{\nu}\), satisfies \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \leq \delta\). ◻

4 Lower bound↩︎

In this section, we prove our main lower bound, 4.

Theorem 4. There is a constant \(c > 0\) so that the following holds, for any sufficiently large \(n \in \mathbb{N}\) and \(\gamma \in (1/n,1)\). There is a class of distributions \(\mathcal{F}\subset \Delta(\{0,1\}^n)\) of size \(|\mathcal{F}| \leq \exp(O(n^4))\) so that no randomized algorithm \(\mathsf{Alg}\) enjoys the following guarantee: for any distribution \(\mu^\star \in \mathcal{F}\) and \(\hat{\mu} : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\) satisfying 1 with respect to \(\mu^\star\) for \(R = (1+\gamma)^2\), \(\mathsf{Alg}\) makes \(\frac{c \gamma^2 n^2}{ \log^2 (n) \cdot \log^2(2/\gamma)}\) queries to \(\hat{\mu}\) and outputs a (random) string \(X \in \{0,1\}^n\), according to some distribution \(\hat{\nu}\), satisfying \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \leq \frac{\gamma}{8}\).

The remainder of the section is organized as follows: in 4.1, we introduce some terminology and notation that will be used throughout the section. In 4.2, we describe the construction of the family \(\mathcal{F}\) of distributions. In 4.3, we analyze the construction and prove 4. Finally, in 4.4, we describe a couple of variants of 4 that give stronger or generalized lower bounds.

4.1 Terminology and setup↩︎

Fix a positive integer \(n\), and positive integers \(k,r\) so that \(n = 2kr + 1\). (Ultimately, we will extend the result to values of \(n\) which cannot be written in this form via a padding argument.) Fix some \(\epsilon\in (0, 1/2)\) (we will eventually choose \(\epsilon\sim \mathop{\mathrm{poly}}\log(n)/n\)). Write \(\mathcal{V}_k := \{0,1\}^{\{0,1\}^k}\) and \(\mathcal{U}_k = (\{0,1\}^k)^{\{0,1\}^k}\). We will interpret elements of \(\mathcal{V}_k, \mathcal{U}_k\) as vectors whose elements are indexed by \(\{0,1\}^k\); further, for \(v \in \mathcal{V}_k\), we will write \(\| v \|_1 = \sum_{x \in \{0,1\}^k} v_x\).

We will be concerned with tuples \((v, \tilde{v}) \in \mathcal{V}_k^2\) which are valid in the sense captured by the below definition:

Definition 6. We say that a tuple \((v, \tilde{v}) \in \mathcal{V}_k^2\) is \(\epsilon\)-valid if the following conditions hold:

  • \(v\) satisfies \(\| v \|_1= 2^{k-1}\).

  • \(\tilde{v}\) satisfies \(\| \tilde{v} \|_1 = 2^{k-1} - \epsilon\cdot 2^k\).

  • \(\tilde{v} \leq v\) entrywise (i.e., \(v_x = 0\) implies \(\tilde{v}_x = 0\) for \(x \in \{0,1\}^k\)).

We let the set of valid tuples be denoted by \(\mathcal{V}^{\mathsf{valid}}_{k,\epsilon}\).

Given a tuple \((v,\tilde{v}) \in \mathcal{V}^{\mathsf{valid}}_{k,\epsilon}\), it corresponds to a partition of \(\{0,1\}^k\) into three sets, namely \(A = \{ z \mid v_z =\tilde{v}_z = 1\}, B = \{ z \mid v_z = 1, \tilde{v}_z = 0\}, C = \{ z \mid v_z = 0\}\). The \(\epsilon\)-validity condition ensures that \(|A| = 2^{k-1} - \epsilon\cdot 2^k\), \(|B| = \epsilon\cdot 2^k\), and \(|C| = 2^{k-1}\). Such partitions are of the form of those discussed in 2.2.

Moreover, elements of \(\mathcal{U}_k\) are to be interpreted as elements of the “key” blocks discussed in 2.2. In particular, they will be used to ensure that any algorithm does not “skip ahead” and query \(\hat{\mu}(x)\) for certain \(x\) before querying \(\hat{\mu}(x')\) at various prefixes of \(x\).

Recall that a family \(\mathcal{H}\) of functions \(f : \mathcal{X}\to \mathcal{Y}\) (for finite sets \(\mathcal{X}, \mathcal{Y}\)) is defined to be \(q\)-wise independent if for any choice of distinct \(x_1, \ldots, x_q \in \mathcal{X}\), and a uniformly random draw of \(h \sim \mathrm{Unif}(\mathcal{H})\), the random variables \(h(x_1), \ldots, h(x_q)\) are independent and uniformly distributed in \(\mathcal{Y}\). We will be concerned with \(q\)-wise independent mappings from \(\{0,1\}^{\leq n}\) to valid tuples (and also to elements of \(\mathcal{U}_k\)), formalized below:

Definition 7. We consider the following families of functions:

  • Let \(\Phi_{n,k,q,\epsilon}\) be a \(q\)-wise independent family of functions \(\phi : \{0,1\}^{\leq n} \to \mathcal{V}^{\mathsf{valid}}_{k,\epsilon}\), of size \(\exp(O(q \cdot \max \{ n, 2^k\}))\).

  • Let \(\Psi_{n,k,q}\) be a \(q\)-wise independent family of functions \(\psi : \{0,1\}^{\leq n} \to \mathcal{U}_k\), of size \(\exp(O(q \cdot \max \{ n, k2^k\}))\).

  • We set \(\mathcal{H}_{n,k,q,\epsilon} := \{0,1\} \times \Phi_{n,k,q,\epsilon} \times \Psi_{n,k,q}\); we will denote elements of \(\mathcal{H}_{n,k,q,\epsilon}\) as tuples \((v^{\mathsf{init}}, \phi, \psi)\), where \(v^{\mathsf{init}}\in \{0,1\}\), \(\phi \in \Phi_{n,k,q,\epsilon}\), and \(\psi \in \Psi_{n,k,q}\).

For \(\phi \in \Phi_{n,k,q,\epsilon}\) and \(z \in \{0,1\}^k\), we will write \(\phi(x;z) := (\phi(x)_1)_z \in \{0,1\}\) and \(\tilde{\phi}(x;z) := (\phi(x)_2)_z \in \{0,1\}\) for \(x \in \{0,1\}^{\leq n}\). (Recall that \(\phi(x)\) is a tuple \((v,\tilde{v})\); thus \(\phi(x;z)\) uses the first coordinate \(v\) and \(\tilde{\phi}(x;z)\) uses the second coordinate \(\tilde{v}\).) For \(\psi \in \Psi_{n,k,q}\) and \(z\in \{0,1\}^k\), we will write \(\psi(x; z) = \psi(x)_z \in \{0,1\}^k\).

The below lemma, which follows from the construction of \(q\)-wise independent families via polynomials, is a standard fact.

Lemma 15 (Corollary 3.34 of [41]). There exist families \(\Phi_{n,k,q,\epsilon}, \Psi_{n,k,q}\) satisfying the conditions of 7.

Next, for \(\phi \in \Phi_{n,k,q,\epsilon}\), and \(0 \leq a \leq r-1\) and \(x \in \{0,1\}^{2ak+1}\), we define the following partitions depending on \(\phi(x)\), as alluded to above: \[\begin{align} A(x) &:= \{z \in \{0,1\}^k :\tilde{\phi}(x; z)=1\},\tag{34}\\ B(x) &:= \{z \in \{0,1\}^k : \phi(x;z) \text{ and } \tilde{\phi}(x;z)=0\},\tag{35}\\ C(x) &:= \{z \in \{0,1\}^k : \phi(x;z)=0\}.\tag{36} \end{align}\] By \(\epsilon\)-validity of \(\phi(x)\), these sets form a partition of \(\{0,1\}^k\), and moreover \[\begin{align} |A(x)| = 2^{k-1}-\epsilon 2^k,\qquad |B(x)| = \epsilon 2^k,\qquad |C(x)| = 2^{k-1}.\label{eq:ABC-sizes-initial-lemmas} \end{align}\tag{37}\]

Finally, we introduce the following notation which “breaks” strings \(x \in \{0,1\}^{\leq n}\) into chunks: for \(x \in \{0,1\}^i\), for \(1 \leq i \leq 2rk+1\), we define:

  • For \(0 \leq a \leq r-1\), \(\mathsf{query}_a(x) := x_{2 + 2ak : 1 + 2ak + k} \in \{0,1\}^{\leq k}\).

  • For \(0 \leq a \leq r-1\), \(\mathsf{key}_a(x) := x_{2ak + k + 2 : 2ak + 2k + 1} \in \{0,1\}^{\leq k}\).

  • For \(0 \leq a \leq r-1\), \(\mathsf{base}_a(x) := x_{1:2ak+1} \in \{0,1\}^{\leq 2ak+1}\). We will only consider \(\mathsf{base}_a(x)\) for \(a\) satisfying \(2ak+1\leq |x|\).

4.2 The lower bound construction↩︎

Fix integers \(k,n,r\) as above, a real number \(\gamma \in (0,1)\), and a tuple \(\tau := (v^{\mathsf{init}}, \phi, \psi) \in \mathcal{H}_{n,k,q,\epsilon}\). We will define a distribution \(\mu = \mu_{\tau} \in \Delta(\{0,1\}^n)\) as well as a mapping \(\hat{\mu} = \hat{\mu}_{\tau} : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\), which depend on \(\tau\). (To avoid clutter, we suppress the dependence on \(\tau\) in the below.) We will do so as follows: we will first define mappings \(\omega = \omega_{\tau}, \hat{\omega} = \hat{\omega}_{\tau}: \{0,1\}^{\leq n} \to \mathbb{R}_{ \geq 0}\). One should think of \(\omega, \hat{\omega}\) as specifying “edge weights” for the complete binary tree of depth \(n\), and then we will define \(\mu, \hat{\mu}\) so as to evaluate the (appropriately normalized) product of the edge weights on the path from each node to the root. Our mappings \(\omega,\hat{\omega}\), defined below, will have range equal to \(\{0,1, 1+\gamma \}\).

4.2.0.1 Defining \(\omega\).

First, for \(x \in \{0,1\}\), we set \(\omega(x) = 1 + \mathbb{1}\left\{{v^{\mathsf{init}}= x}\right\} \cdot \gamma\). Now consider \(x \in \{0,1\}^i\), for \(2 \leq i \leq 2rk+1\). We consider the following cases:

  • If \(i \pmod{2k} \in \{2, 3, \ldots, k+1 \}\), then we set \(\omega(x) = 1\).

  • If \(i \pmod{2k} =: p \in \{k+2,k+3, \ldots, 2k\}\), then, for \(a := \lfloor (i-2)/(2k) \rfloor\), we set \(\omega(x) = \mathbb{1}\left\{{\mathsf{key}_a(x) = \psi(\mathsf{base}_a(x); \mathsf{query}_a(x))_{1:|\mathsf{key}_a(x)|}}\right\}\).

  • If \(i =1 \pmod{2k}\), we set \[\begin{align} \omega(x) = \mathbb{1}\left\{{\mathsf{key}_a(x) = \psi(\mathsf{base}_a(x); \mathsf{query}_a(x))}\right\}\cdot (1 + \gamma \cdot \phi(\mathsf{base}_a(x);\mathsf{query}_a(x)),\label{eq:define-omega} \end{align}\tag{38}\] where \(a := \lfloor (i-2)/(2k) \rfloor\).

4.2.0.2 Defining \(\hat{\omega}\).

First, we set \(\hat{\omega}(1) = \hat{\omega}(0) =1+\gamma\). Now consider \(x \in \{0,1\}^i\), for \(2 \leq i \leq 2rk+1\). We consider the following cases:

  • If \(i \pmod{2k} \in \{2, 3, \ldots, k+1 \}\), then we set \(\hat{\omega}(x) = 1\).

  • If \(i \pmod{2k} =: p \in \{k+2,k+3, \ldots, 2k\}\), then, for \(a := \lfloor (i-2)/(2k) \rfloor\), we set \(\hat{\omega}(x) = \mathbb{1}\left\{{\mathsf{key}_a(x) = \psi(\mathsf{base}_a(x); \mathsf{query}_a(x))_{1:|\mathsf{key}_a(x)|}}\right\}\).

  • If \(i = 1\pmod{2k}\), write \(a = \lfloor (i-2)/(2k) \rfloor\), so that \(i=2(a+1)k+1\). If either \(v^{\mathsf{init}}= x_1\), or there is some \(0 \leq b < a\) such that \[\begin{align} \phi(\mathsf{base}_b(x);\mathsf{query}_b(x)) \neq \tilde{\phi}(\mathsf{base}_b(x);\mathsf{query}_b(x)),\label{eq:prior-b-exists} \end{align}\tag{39}\] then we set \[\begin{align} \hat{\omega}(x) = \mathbb{1}\left\{{\mathsf{key}_a(x) = \psi(\mathsf{base}_a(x); \mathsf{query}_a(x))}\right\} \cdot (1 + \gamma \cdot \phi(\mathsf{base}_a(x);\mathsf{query}_a(x))).\label{eq:define-hatomega-1} \end{align}\tag{40}\] Otherwise, we set \[\begin{align} \hat{\omega}(x) = \mathbb{1}\left\{{\mathsf{key}_a(x) = \psi(\mathsf{base}_a(x); \mathsf{query}_a(x))}\right\} \cdot (1 + \gamma \cdot \tilde{\phi}(\mathsf{base}_a(x);\mathsf{query}_a(x))).\label{eq:define-hatomega-2} \end{align}\tag{41}\]

4.2.0.3 Defining \(\hat{\mu}\) and \(\mu\).

For each \(i \in [n]\), define \[\begin{align} \hat{Z}_i = \sum_{x' \in \{0,1\}^{i}} \prod_{j=1}^{i} \hat{\omega}(x'_{1:j}).\label{eq:def-zhati} \end{align}\tag{42}\] For \(x \in \{0,1\}^{i}\), we set \[\begin{align} \hat{\mu}(x) = \hat{Z}_i^{-1} \cdot \prod_{j=1}^{i} \hat{\omega}(x_{1:j}).\label{eq:def-muhat-zhat} \end{align}\tag{43}\] For convenience, we write \(\hat{Z} := \hat{Z}_n\).

Next, we define \(\mu \in \Delta(\{0,1\}^n)\) by \(\mu(x) = \hat{\mu}(x)\) for \(x \in \{0,1\}^n\); by virtue of the division by \(\hat{Z}\) in the definition of \(\hat{\mu}\), we have that \(\mu\) is indeed a distribution.

For analysis purposes, we also define a distribution \(\mu_{\mathsf{ideal}}\in \Delta(\{0,1\}^n)\) as follows: for \(x \in \{0,1\}^n\), \[\begin{align} \mu_{\mathsf{ideal}}(x) = Z^{-1} \cdot \prod_{j=1}^n\omega(x_{1:j}), \qquad Z = \sum_{x \in \{0,1\}^n} \prod_{j=1}^n \omega(x_{1:j}) = (2+\gamma) \cdot \left( 2^k + \gamma \cdot 2^{k-1}\right)^r.\nonumber \end{align}\]

4.3 Proof of the lower bound↩︎

We first show that the distribution \(\mu\) is close to \(\mu_{\mathsf{ideal}}\) as long as \(\epsilon\cdot r\) is sufficiently large.

Lemma 16. It holds that \(D_{\mathsf{TV}}({\mu}, {\mu_{\mathsf{ideal}}}) \leq e^{-\epsilon r}\).

Proof. For a leaf \(x \in \{0,1\}^n\), define \[\begin{align} W(x) := \prod_{j=1}^n \omega(x_{1:j}), \qquad \hat{W}(x) := \prod_{j=1}^n \hat{\omega}(x_{1:j}).\nonumber \end{align}\] Then \(\mu(x) = \hat{\mu}(x) = \hat{W}(x)/\hat{Z}\) and \(\mu_{\mathsf{ideal}}(x) = W(x)/Z\) for \(x \in \{0,1\}^n\).

Let \(\mathcal{E} \subseteq \{0,1\}^n\) be the set of leaves \(x\) such that \(x_1=1-v^{\mathsf{init}}\) and \[\begin{align} \mathsf{query}_a(x) \notin B(\mathsf{base}_a(x)) \qquad \text{for every } 0 \leq a \leq r-1.\nonumber \end{align}\] We claim that for every leaf \(x \in \{0,1\}^n\), \[\begin{align} \hat{W}(x) = \bigl(1+\gamma \cdot \mathbb{1}\left\{{x \in \mathcal{E}}\right\}\bigr) \cdot W(x).\label{eq:What-over-W} \end{align}\tag{44}\] Indeed, if \(x_1=v^{\mathsf{init}}\), then \(x \not \in \mathcal{E}\) and the defining condition for \(\hat{\omega}\) always selects \(\phi\), so \(\hat{\omega}\) and \(\omega\) agree at every prefix of \(x\), including the root. Hence \(\hat{W}(x)=W(x)\). Now suppose that \(x_1=1-v^{\mathsf{init}}\). At the root we have \(\hat{\omega}(x_1)=1+\gamma\) whereas \(\omega(x_1)=1\). If \(x \in \mathcal{E}\), then for every index \(a < r\) we have \(\mathsf{query}_a(x) \in A(\mathsf{base}_a(x)) \cup C(\mathsf{base}_a(x))\), so \[\begin{align} \phi(\mathsf{base}_a(x);\mathsf{query}_a(x)) = \tilde{\phi}(\mathsf{base}_a(x);\mathsf{query}_a(x)).\nonumber \end{align}\] Thus, by the definitions in 40 41 38 , \(\hat{\omega}(x_{1:i}) = \omega(x_{1:i})\) for all \(i \geq 2\), and so \(\hat{W}(x) = (1+\gamma) \cdot W(x)\). Finally, if \(x \notin \mathcal{E}\), and let \(a_\star\) be the least index in \(\{0,\ldots,r-1\}\) such that \(\mathsf{query}_{a_\star}(x) \in B(\mathsf{base}_{a_\star}(x)).\) The definitions of \(\omega,\hat{\omega}\) give that \(\hat{\omega}(x_{1:i}) = \omega(x_{1:i})\) for all \(i \geq 2\) with \(i \neq 2(a_\star +1)k+1\), and for \(i = 2(a_\star+1)k+1\), we have \(\hat{\omega}(x_{1:i}) \cdot (1+\gamma) = \omega(x_{1:i})\). Then we again have \(\hat{W}(x) = W(x)\).

Let \(p := \mu_{\mathsf{ideal}}(\mathcal{E})\). Summing 44 over all leaves shows that \[\begin{align} \hat{Z} = \sum_{x \in \{0,1\}^n} \hat{W}(x) = \sum_{x \in \{0,1\}^n} W(x) + \gamma \sum_{x \in \mathcal{E}}W(x) = Z \cdot (1 + \gamma p).\label{eq:zhat-z-comparison} \end{align}\tag{45}\] Using that \(\mu(x) = \hat{\mu}(x)\) for \(x \in \{0,1\}^n\), it follows that \[\begin{align} \mu(x) = \frac{1+\gamma \cdot \mathbb{1}\left\{{x \in \mathcal{E}}\right\}}{1+\gamma p} \cdot \mu_{\mathsf{ideal}}(x).\label{eq:mu-vs-muideal-pointwise} \end{align}\tag{46}\] Therefore \[\begin{align} D_{\mathsf{TV}}({\mu}, {\mu_{\mathsf{ideal}}}) &= \frac{1}{2} \sum_{x \in \{0,1\}^n} \mu_{\mathsf{ideal}}(x) \cdot \left|\frac{1+\gamma \cdot \mathbb{1}\left\{{x \in \mathcal{E}}\right\}}{1+\gamma p} - 1\right|\nonumber\\ &= \frac{\gamma p(1-p)}{1+\gamma p} \leq p.\label{eq:tvd-by-p} \end{align}\tag{47}\]

It remains to bound \(p\). Under \(\mu_{\mathsf{ideal}}\), the probability of taking the root edge \(x_1 = 1-v^{\mathsf{init}}\) is \(1/(2+\gamma)\), because the two root subtrees have identical total \(W\)-mass below the root and the two root weights are \(1\) and \(1+\gamma\). Next, fix any \(0 \leq a \leq r-1\) and any \(y \in \{0,1\}^{2ak+1}\) with \(y_1 = 1-v^{\mathsf{init}}\) and so that for all \(b < a\), \(\phi(\mathsf{base}_b(y);\mathsf{query}_b(y)) = \tilde{\phi}(\mathsf{base}_b(y);\mathsf{query}_b(y))\). For each \(z \in \{0,1\}^k\), there is a unique “key” \(\kappa(z) \in \{0,1\}^k\) for which \(\mathsf{key}_a(y \circ z \circ \kappa(z)) = \psi(y;z)\). Moreover, we have \[\begin{align} \frac{W(y \circ z \circ \kappa(z))}{W(y)} = \prod_{j=2ak+2}^{2(a+1)k+1} \omega((y \circ z \circ \kappa(z))_{1:j}) = 1 + \gamma \cdot \phi(y;z).\nonumber \end{align}\] Therefore, under \(x \sim \mu_{\mathsf{ideal}}\), conditioned on \(x_{1:2ak+1} = y\), the conditional probability that \(\mathsf{query}_a(x) \notin B(y)\) is \[\begin{align} \frac{(1+\gamma)|A(y)| + |C(y)|}{(1+\gamma)(|A(y)|+|B(y)|) + |C(y)|} &= 1 - \frac{(1+\gamma)|B(y)|}{2^k + \gamma 2^{k-1}}\nonumber\\ &= 1 - \frac{1+\gamma}{1+\gamma/2} \cdot \epsilon\nonumber\\ &\leq 1-\epsilon,\label{eq:no-B-probability} \end{align}\tag{48}\] where we used 37 . Since the right-hand side of 48 is uniform over all such prefixes \(y\), we obtain \[\begin{align} p = \mu_{\mathsf{ideal}}(\mathcal{E}) \leq \frac{1}{2+\gamma} \cdot (1-\epsilon)^r \leq e^{-\epsilon r}.\nonumber \end{align}\] Combining this with 47 proves the lemma. ◻

For \(x \in \{0,1\}^{\leq n}\), recall that we let \(\mu(x)\) denote the marginal distribution of \(\mu\) on \(x\) (i.e., on its first \(|x|\) coordinates). The next lemma shows that, for an arbitrary choice of \(\tau \in \mathcal{H}_{n,k,q,\epsilon}\), the resulting values of \(\mu = \mu_\tau\) and \(\hat{\mu} = \hat{\mu}_\tau\) satisfy 1 with \(R = (1+\gamma)^2\).

Lemma 17. For all \(x \in \{0,1\}^{\leq n}\), either \(\mu(x) = \hat{\mu}(x) = 0\), or else it holds that \[\begin{align} \max\{ \mu(x)/\hat{\mu}(x), \hat{\mu}(x)/\mu(x) \} \leq (1 + \gamma)^2.\nonumber \end{align}\]

Proof. For \(x \in \{0,1\}^{\leq n}\), write \[\begin{align} P(x) := \prod_{j=1}^{|x|} \hat{\omega}(x_{1:j}),\qquad T(x) := \sum_{z \in \{0,1\}^{m-|x|}} \prod_{j=|x|+1}^{m} \hat{\omega}((x\circ z)_{1:j}).\nonumber \end{align}\] Then \[\begin{align} \hat{\mu}(x) = \frac{P(x)}{\hat{Z}_{|x|}},\qquad \mu(x) = \frac{P(x)\,T(x)}{\hat{Z}}, \qquad \frac{\mu(x)}{\hat{\mu}(x)} = \frac{T(x) \hat{Z}_{|x|}}{\hat{Z}}.\label{eq:muhat-mu-factorization} \end{align}\tag{49}\] In particular, \(\hat{\mu}(x)=0\) if and only if \(P(x)=0\). Moreover, for \(x \in \{0,1\}^{\leq n}\), whenever \(P(x)>0\) there is at least one leaf descendent of \(x\) with positive \(\hat{\omega}\)-mass, and therefore \(\mu(x)>0\) if and only if \(\hat{\mu}(x)>0\).

We next bound the possible values of \(T(x)\) at depths \(1 \pmod{2k}\). For \(0 \leq a \leq r\) and \(x \in \{0,1\}^{2ak+1}\), we say that \(x\) is switched if either \(x_1 = v^{\mathsf{init}}\), or there is some \(0 \leq b < a\) such that \(\mathsf{query}_b(x) \in B(\mathsf{base}_b(x)).\) Otherwise we say that \(x\) is unswitched.

Claim 5. For each \(0 \leq a \leq r\), there are positive real numbers \(F_a, G_a\) satisfying \[\begin{align} G_a \leq F_a \leq (1+\gamma) G_a,\nonumber \end{align}\] such that, for every prefix \(x \in \{0,1\}^{2ak+1}\) with \(P(x)>0\), we have \[\begin{align} T(x) = \begin{cases} F_a &: \text{if x is switched,}\\ G_a &: \text{if x is unswitched.} \end{cases}\nonumber \end{align}\]

Proof of 5. We argue by reverse induction on \(a\). For \(a=r\), every prefix \(x \in \{0,1\}^{2rk+1}=\{0,1\}^n\) is a leaf, so \(T(x)=1\). Thus we may set \(F_r = G_r = 1\).

Now fix \(0 \leq a < r\), and assume that the claim has already been established at step \(a+1\) for appropriate values of \(F_{a+1},G_{a+1}\). Let \(x \in \{0,1\}^{2ak+1}\) with \(P(x)>0\).

Suppose first that \(x\) is switched. For each \(z \in \{0,1\}^k\), let \(\kappa(z) \in \{0,1\}^k\) denote the unique string for which \(\mathsf{key}_a(x \circ z \circ \kappa(z)) = \psi(x;z).\) Then \(x \circ z \circ \kappa(z)\) is a prefix of length \(2(a+1)k+1\), and it is again active because \(x\) was already active. Moreover, note that \(\prod_{j=2ak+2}^{2(a+1)k+1} \hat{\omega}((x \circ z \circ \kappa(z))_{1:j}) = \hat{\omega}(x \circ z \circ \kappa(z)) = 1 + \gamma \cdot \phi(x;z)\), which is \(1+\gamma\) when \(z \in A(x)\cup B(x)\) and \(1\) when \(z \in C(x)\). Therefore \[\begin{align} T(x) = \bigl((1+\gamma)(|A(x)|+|B(x)|)+|C(x)|\bigr)F_{a+1} =: F_a.\nonumber \end{align}\]

Suppose instead that \(x\) is unswitched. For each \(z \in \{0,1\}^k\), let \(\kappa(z)\) be defined as above. Then \(x \circ z \circ \kappa(z)\) is unswitched when \(z \in A(x) \cup C(x)\), and switched when \(z \in B(x)\). Moreover, we have \(\prod_{j=2ak+2}^{2(a+1)k+1} \hat{\omega}((x \circ z \circ \kappa(z))_{1:j}) = \hat{\omega}(x \circ z \circ \kappa(z)) = 1 + \gamma \cdot \tilde{\phi}(x;z)\), which is \(1+\gamma\) when \(z \in A(x)\), and \(1\) when \(z \in B(x) \cup C(x)\). Therefore \[\begin{align} T(x) = \bigl((1+\gamma)|A(x)|+|C(x)|\bigr)G_{a+1} + |B(x)|F_{a+1} =: G_a.\nonumber \end{align}\] Using the induction hypothesis \(G_{a+1} \leq F_{a+1} \leq (1+\gamma)G_{a+1}\), we obtain \[\begin{align} G_a \leq \bigl((1+\gamma)(|A(x)|+|B(x)|)+|C(x)|\bigr)F_{a+1} = F_a\nonumber \end{align}\] and also \[\begin{align} F_a &= \bigl((1+\gamma)|A(x)|+|C(x)|\bigr)F_{a+1} + (1+\gamma)|B(x)|F_{a+1}\nonumber\\ &\leq (1+\gamma)\bigl((1+\gamma)|A(x)|+|C(x)|\bigr)G_{a+1} + (1+\gamma)|B(x)|F_{a+1}\nonumber\\ &\leq (1+\gamma)G_a.\nonumber \end{align}\] This completes the inductive step. ◻

For any \(i \leq n\), we have \(\hat{Z} = \sum_{x \in \{0,1\}^i} P(x) T(x)\), and \(\hat{Z}_i = \sum_{x \in \{0,1\}^i} P(x)\). Thus, for any \(0 \leq a \leq r-1\) and \(x \in \{0,1\}^{2ak + 1}\), we have \[\begin{align} \frac{1}{(1+\gamma) \cdot \hat{Z}_{2ak+1}} = \frac{G_a}{\sum_{x' \in \{0,1\}^{2ak+1}} P(x') \cdot (1+\gamma) G_a} \leq \frac{T(x)}{\hat{Z}} \leq \frac{(1+\gamma) \cdot G_a}{\sum_{x' \in \{0,1\}^{2ak+1}} P(x') \cdot G_a} = \frac{1+\gamma}{\hat{Z}_{2ak+1}}\nonumber, \end{align}\] and it follows from 49 that \(1/(1+\gamma) \leq \mu(x) / \hat{\mu}(x) \leq 1+\gamma\). In the above display, both inequalities use 5: the first inequality uses the claim to bound \(G_a \leq T(x)\) for all \(x \in \{0,1\}^{2ak+1}\) and \((1+\gamma) G_a \geq T(x')\) for all \(x' \in \{0,1\}^{2ak+1}\); the second inequality uses the claim to bound \(T(x) \leq (1+\gamma) \cdot G_a\) and \(T(x') \geq G_a\).

Having established the statement of 17 for \(x \in \{0,1\}^{\leq n}\) with \(|x| = 2ak+1\) for some \(0 \leq a \leq r\), we may now use this to extend the result for the remaining values of \(x \in \{0,1\}^{\leq n}\):

4.3.0.1 Case 1: \(|x| \pmod{2k} \in \{k+1, \ldots, 2k \}\).

For any \(0 \leq a \leq r-1\) and \(k+1 \leq a' \leq 2k\), we have \[\begin{align} \hat{Z}_{2ak + a'} = \sum_{x \in \{0,1\}^{2ak + a'}} P(x) \in [(1+\gamma)^{-1},1] \cdot \sum_{x \in \{0,1\}^{2ak + 2k +1}} P(x) = [(1+\gamma)^{-1} \cdot\hat{Z}_{2ak + 2k +1}, \hat{Z}_{2ak + 2k +1}]\nonumber, \end{align}\] since for each \(x \in \{0,1\}^{2ak + a'}\) with \(P(x) > 0\), there is a unique \(z \in \{0,1\}^{2k+1-a'}\) so that \(P(x \circ z) > 0\), and such \(z\) satisfies \(P(x \circ z) = P(x) \cdot \hat{\omega}(x \circ z)\). For such \(x,z\), we have \(T(x \circ z)\cdot \hat{\omega}(x \circ z) = T(x)\), which means that \[\begin{align} \frac{\mu(x)}{\hat{\mu}(x)} = \frac{T(x) \cdot \hat{Z}_{2ak+a'}}{\hat{Z}} = \frac{T(x \circ z) \cdot \hat{\omega}(x \circ z) \cdot \hat{Z}_{2ak+a'}}{\hat{Z}} \in [(1+\gamma)^{-1}, (1+\gamma)] \cdot \frac{\mu(x \circ z)}{\hat{\mu}(x \circ z)}. \end{align}\] Thus, by 5, \(\frac{\mu(x)}{\hat{\mu}(x)} \in [(1+\gamma)^{-2}, (1+\gamma)^2]\). As a consequence of this argument and of 5, we also see that for all \(x \in \{0,1\}^{2ak + k+1}\) (for any \(0 \leq a \leq r-1\)), we have \[\begin{align} T(x) \in [G_a/(1+\gamma), (1+\gamma)G_a].\label{eq:tx-kp1} \end{align}\tag{50}\]

4.3.0.2 Case 2: \(|x| \pmod{2k} \in \{2, \ldots, k \}\).

For any \(0 \leq a \leq r-1\) and \(1 \leq a' \leq k-1\), we have \[\begin{align} \hat{Z}_{2ak + 1 + a'} = \sum_{x \in \{0,1\}^{2ak + 1 + a'}} P(x) = 2^{a'-k} \cdot \hat{Z}_{2ak + k+1} \in 2^{a'-k} \cdot \hat{Z}_{2ak+2k+1} \cdot [(1+\gamma)^{-1},1]\nonumber, \end{align}\] since for any \(x \in \{0,1\}^{2ak + 1 + a'}\), we have \(P(x) = P(x_{1:2ak + k+1})\). Moreover, for such \(x\), \[\begin{align} T(x) = \sum_{x' \in \{0,1\}^{2ak+k+1} :\;x' \succ x} T(x') \in \left[ {2^{k-a'} \cdot G_a}/{(1+\gamma)}, 2^{k-a'} \cdot G_a \cdot (1+\gamma) \right],\nonumber \end{align}\] where the final step uses 50 . Thus \[\begin{align} \frac{\mu(x)}{\hat{\mu}(x)} = \frac{T(x) \cdot \hat{Z}_{2ak+1+a'}}{\hat{Z}} \in \frac{G_a \cdot \hat{Z}_{2ak+2k+1}}{\hat{Z}} \cdot [(1+\gamma)^{-2}, (1+\gamma)]\nonumber, \end{align}\] and it then follows from 5 that \(\frac{\mu(x)}{\hat{\mu}(x)} \in [(1+\gamma)^{-2}, (1+\gamma)^2]\). ◻

The next lemma shows that the normalizing constant \(\hat{Z}_i\) used to define \(\hat{\mu}\) in 42 43 does not depend on the choice of tuple \(\tau \in \mathcal{H}_{n,k,q,\epsilon}\).

Lemma 18. For each \(i \in [n]\), there is a value \(\hat{Z}_{\epsilon,i}\) so that, for any \(\tau \in \mathcal{H}_{n,k,q,\epsilon}\), the quantity \(\hat{Z}_i = \sum_{x' \in \{0,1\}^i} \prod_{j=1}^i \hat{\omega}_{\tau}(x_{1:j}')\) appearing in 42 is equal to \(\hat{Z}_{\epsilon,i}\). (In particular, it does not depend on \(\tau\).)

Proof. The proof is immediate by symmetry: consider any tuples \(\tau = (v^{\mathsf{init}}, \phi, \psi), \tau' = ((v^{\mathsf{init}})', \phi', \psi') \in \mathcal{H}_{n,k,q,\epsilon}\). Let the mappings \(\hat{\omega}\) corresponding to these two tuples be denoted \(\hat{\omega} = \hat{\omega}_{\tau}, \hat{\omega}'=\hat{\omega}_{\tau'} : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\). We claim that, for each \(i \leq n\), we can find a permutation \(\pi_i : \{0,1\}^{i} \to \{0,1\}^{i}\) so that \(\prod_{j=1}^i\hat{\omega}(x_{1:j}) = \prod_{j=1}^i \hat{\omega}'(\pi_i(x)_{1:j})\) for all \(x \in \{0,1\}^{i}\). To see this, we may construct the permutations \(\pi_i\) inductively, in blocks of size \(2k\). For the base case, \(\pi_1\) is the identity if \(v^{\mathsf{init}}= (v^{\mathsf{init}})'\), and swaps the bits otherwise. We will suppose (inductively) that we have constructed \(\pi_i\) for \(i \leq 2ak+1\) for some \(a \geq 0\), which satisfy the desired property above and also that \(x \in \{0,1\}^{2ak+1}\) satisfies 39 for \(\phi\) if and only if \(\pi_{2ak+1}(x)\) satisfies 39 for \(\phi'\).

We now construct \(\pi_i\) for the depths in the next block. Fix \(x \in \{0,1\}^{2ak+1}\) and write \(x' := \pi_{2ak+1}(x)\). Let the sets \(A(x), B(x), C(x)\) be defined as in 34 35 36 in terms of \(\phi\), and let \(A'(x'), B'(x'), C'(x')\) be defined similarly in terms of \(\phi'\). Since the sizes of these respective sets match up (per 37 ), we can find a permutation \(\sigma_x : \{0,1\}^k \to \{0,1\}^k\) so that \(\sigma_x(A(x)) = A'(x')\), \(\sigma_x(B(x)) = B'(x')\), and \(\sigma_x(C(x)) = C'(x')\).

We first define the permutations at depths lying in the query block. For \(1 \leq s \leq k\) and \(u \in \{0,1\}^s\), set \(\pi_{2ak+1+s}(x \circ u) := x' \circ u.\) Since all edge weights in the query block are equal to \(1\), this preserves the product of edge weights up to depth \(2ak+1+s\).

It remains to define the permutations inside the key block. Fix \(z \in \{0,1\}^k\) and \(1 \leq s \leq k\). Choose any bijection \(\lambda_{x,z,s}:\{0,1\}^s \to \{0,1\}^s\) satisfying \(\lambda_{x,z,s}\left(\psi(x;z)_{1:s}\right) = \psi'(x';\sigma_x(z))_{1:s}.\) Then for \(v \in \{0,1\}^s\), define \[\begin{align} \pi_{2ak+k+1+s}(x \circ z \circ v) := x' \circ \sigma_x(z) \circ \lambda_{x,z,s}(v).\label{eq:pi-key-block} \end{align}\tag{51}\] For each fixed \(s\), this defines a bijection on \(\{0,1\}^{2ak+k+1+s}\), since \(\pi_{2ak+1}\), \(\sigma_x\), and each \(\lambda_{x,z,s}\) are bijections. Moreover, 51 maps a prefix whose key block agrees with \(\psi(x;z)\) for its first \(s\) coordinates to a prefix whose key block agrees with \(\psi'(x';\sigma_x(z))\) for its first \(s\) coordinates, and maps every other key prefix to one which also fails the corresponding agreement condition. Thus the product of the key-indicator factors is preserved. If \(s<k\), this proves the desired product identity at depth \(2ak+k+1+s\). To deal with depth \(i = 2(a+1)k+1\), we simply note that the choice of \(\sigma_x\) maps \(A(x)\) to \(A'(x')\), \(B(x)\) to \(B'(x')\), and \(C(x)\) to \(C'(x')\), which completes the inductive construction of the permutations \(\pi_i\).

Now, existence of \(\pi_i\) as above implies that \[\begin{align} \sum_{x \in \{0,1\}^i} \prod_{j=1}^i \hat{\omega}(x_{1:j}) = \sum_{x \in \{0,1\}^i} \prod_{j=1}^i \hat{\omega}'(\pi_i(x)_{1:j}) = \sum_{x' \in \{0,1\}^i} \prod_{j=1}^i \hat{\omega}'(x'_{1:j}),\nonumber \end{align}\] as desired. ◻

19 is a technical ingredient needed in our proof; it shows that, when we draw a tuple \(\tau = (v^{\mathsf{init}}, \phi, \psi)\) uniformly at random from \(\mathcal{H}_{n,k,q,\epsilon}\), and condition on the values of the resulting mapping \(\hat{\mu}_\tau\) at a number of points \(x \in \{0,1\}^{\leq n}\), then conditionally \(\psi\) is independent of \((v^{\mathsf{init}}, \phi)\).

Lemma 19. Fix \(q \in \mathbb{N}\), and consider any collection \(x_1, \ldots, x_q \in \{0,1\}^{\leq n}\) and \(\mu_1, \ldots, \mu_q \geq 0\). Let \(\mathbb{P}\) denote the distribution of a uniformly random tuple \(\tau = (v^{\mathsf{init}}, \phi,\psi) \sim \mathcal{H}_{n,k,q,\epsilon}\) and the induced value of \(\hat{\mu} = \hat{\mu}_\tau\). Then for any \(v' \in \{0,1\}\), \(\phi' \in \Phi_{n,k,q,\epsilon}\), and \(\psi' \in \Psi_{n,k,q}\), we have \[\begin{align} \mathbb{P}(\psi = \psi' \mid (v^{\mathsf{init}}, \phi) = (v',\phi'), \;\;\hat{\mu}(x_j) = \mu_j\;\forall j \in [q]) = \mathbb{P}(\psi = \psi' \mid \hat{\mu}(x_j) = \mu_j\;\forall j \in [q]).\nonumber \end{align}\]

Proof. The definition of \(\hat{\omega} = \hat{\omega}_\tau\) and \(\hat{\mu} = \hat{\mu}_\tau\) above gives that there is a quantity \(\eta_{v^{\mathsf{init}},\phi}(x) > 0\) depending only on \((v^{\mathsf{init}},\phi)\) and an indicator \(\chi_\psi(x) \in \{0,1\}\) depending only on \(\psi\) such that \[\begin{align} \hat{\mu}_{\tau}(x) = \eta_{v^{\mathsf{init}},\phi}(x) \cdot \chi_\psi(x)\label{eq:muhat-factor-ci} \end{align}\tag{52}\] for all \(x \in \{0,1\}^{\leq n}\). Indeed, \(\eta_{v^{\mathsf{init}},\phi}(x)\) is the product of the positive factors of the form \(1+\gamma\) and \(1+\gamma \cdot \phi(\mathsf{base}_a(x); \mathsf{query}_a(x))\) or \(1+\gamma \cdot \tilde{\phi}(\mathsf{base}_a(x); \mathsf{query}_a(x))\), divided by \(\hat{Z}_{\epsilon,|x|}\), while \(\chi_\psi(x)=1\) if and only if every key block appearing along the path to \(x\) agrees with the corresponding value determined from \(\psi\).

Let \[\begin{align} \mathcal{E}:= & \{ (v^{\mathsf{init}}, \phi, \psi) \mid \hat{\mu}_{v^{\mathsf{init}},\phi,\psi}(x_j) = \mu_j\;\forall j \in [q]\}\nonumber\\ \mathcal{E}_\eta:=& \{(v^{\mathsf{init}},\phi,\psi) \mid \eta_{v^{\mathsf{init}}, \phi}(x_j) = \mu_j \;\forall js.t.\mu_j > 0 \}\nonumber\\ \mathcal{E}_\chi :=& \{(v^{\mathsf{init}}, \phi,\psi) \mid \chi_\psi(x_j) = 1 \;\forall js.t.\mu_j > 0, \;\chi_\psi(x_j) = 0 \;\forall js.t.\mu_j = 0\}\nonumber \end{align}\] Then since \(\eta_{v^{\mathsf{init}}, \phi}(x) > 0\) for all \(v^{\mathsf{init}},\phi, x\), it follows from 52 that \(\mathcal{E}= \mathcal{E}_\eta \cap \mathcal{E}_\chi\): for each \(j\) with \(\mu_j>0\) the equality \(\hat{\mu}(x_j)=\mu_j\) is equivalent to \(\eta_{v^{\mathsf{init}},\phi}(x_j)=\mu_j\) and \(\chi_\psi(x_j)=1\), while for each \(j\) with \(\mu_j=0\) it is equivalent to \(\chi_\psi(x_j)=0\). Moreover, note that the event \((v^{\mathsf{init}}, \phi, \psi) \in \mathcal{E}_\eta\) depends only on \((v^{\mathsf{init}}, \phi)\), while the event \((v^{\mathsf{init}}, \phi, \psi) \in \mathcal{E}_\chi\) depends only on \(\psi\). For any \((v', \phi')\) for which \(\mathbb{P}(\{ (v^{\mathsf{init}}, \phi) = (v', \phi') \} \cap \mathcal{E}) > 0\), we have \[\begin{align} \mathbb{P}(\psi = \psi' \mid \{(v^{\mathsf{init}}, \phi) = (v',\phi')\} \cap \mathcal{E}) &= \mathbb{P}(\psi = \psi' \mid \{(v^{\mathsf{init}}, \phi) = (v',\phi')\} \cap \mathcal{E}_\chi)\nonumber\\ &= \mathbb{P}(\psi = \psi' \mid \mathcal{E}_\chi) = \mathbb{P}(\psi = \psi' \mid \mathcal{E}_\chi \cap \mathcal{E}_\eta)\nonumber, \end{align}\] where the first equality uses that \((v^{\mathsf{init}}, \phi) = (v', \phi')\) implies that \(\mathcal{E}_\eta\) holds, while the second and third equalities use the independence of \((v^{\mathsf{init}}, \phi)\) and \(\psi\). Since \(\mathcal{E}=\mathcal{E}_\eta \cap \mathcal{E}_\chi\), this is the desired conditional independence statement. ◻

8 formalizes the notion of an “ideal” sequence of queries which can be made to \(\hat{\mu}\): namely such a sequence satisfies the property that the queries do not “skip ahead” in a certain sense. In particular, the sequence has the property that before making any query, all prefixes of that query of length \(1\pmod{2k}\) have been previously queried.

Definition 8. We say that a sequence \(X_1, \ldots, X_j \in \{0,1\}^{\leq n}\) is ideal if the following properties hold:

  • \(X_1, \ldots, X_j\) are all distinct.

  • For all \(j' \in [j]\), \(|X_{j'}| \pmod{2k} \in \{1, k+2, k+3, \ldots, 2k\}\).

  • For each \(j' \in [j]\) and \(0 \leq a < r\) for which \(|X_{j'}| > 2ak + 1\), there is some \(j'' < j'\) for which \(X_{j''} = \mathsf{base}_a(X_{j'}) = (X_{j'})_{1:2ak+1}\).

The main technical lemma in the proof of our lower bound is 20, which shows the following: under a uniformly random draw of \(\tau \sim \mathcal{H}_{n,k,q,\epsilon}\), for any fixed ideal sequence of queries (per 8), the distribution of the output of the final query in this sequence conditioned on the results of the previous queries in the sequence does not depend much on the value of \(v^{\mathsf{init}}\). Ultimately, we will combine 20 with the chain rule for KL divergence to show that the results of all queries in an ideal sequence do not depend much on the value of \(v^{\mathsf{init}}\), and this will ultimately allow us to show that no query-limited algorithm can guess the value of \(v^{\mathsf{init}}\).

To state the lemma, we introduce the following notation. Let \(\mathbb{P}\) denote the joint distribution over the random draw of \((v^{\mathsf{init}},\phi,\psi) \sim \mathcal{H}_{n,k,q,\epsilon}\) and the internal randomness of \(\mathsf{Alg}\), and \(\mathbb{E}\) denote the corresponding expectation. For each \(b \in \{0,1\}\), let \(\mathbb{P}_b(\cdot) := \mathbb{P}(\cdot \mid v^{\mathsf{init}}= b)\).

Lemma 20. Suppose that \(X_1, \ldots, X_j \in \{0,1\}^{\leq n}\) is an ideal sequence for some \(j \leq q\). For \(b \in \{0,1\}\), let \(\mathbb{P}_{b}\) denote the joint distribution of \((\hat{\mu}_\tau, \hat{\omega}_\tau, \tau)\) for \(\tau = (v^{\mathsf{init}}, \phi, \psi) \sim \mathcal{H}_{n,k,q,\epsilon}\), conditioned on \(v^{\mathsf{init}}= b\). Fix any values of \(\mu_1', \ldots, \mu'_{j-1} \geq 0\), and write \(\mathcal{E}\) to denote the event that \(\hat{\mu}(X_{j'}) = \mu'_{j'}\) for all \(j' \in [j-1]\). If \(\mathbb{P}_0(\mathcal{E}), \mathbb{P}_1(\mathcal{E}) > 0\), then we have \[\begin{align} D_{\mathsf{KL}}({\mathbb{P}_0(\hat{\mu}(X_{j}) = \cdot \mid \mathcal{E})}||{\mathbb{P}_1(\hat{\mu}(X_{j}) = \cdot \mid \mathcal{E})}) \leq O(\epsilon^2).\nonumber \end{align}\]

Proof. To simplify notation, we will typically write \(\hat{\mu} := \hat{\mu}_\tau, \hat{\omega}:= \hat{\omega}_\tau\). Further, we will make use of the sets \(A(x), B(x), C(x)\) indexed by \(x \in \{0,1\}^n\) (which are determined by the choice of \(\tau\)), defined in 34 35 36 , respectively. We consider the following two cases for \(X_j\):

4.3.0.3 Case 1 for \(X_j\).

Suppose \(X_j\) lies strictly inside a key block, so that \(|X_j| = 2ak + k + 1 + t\) for some \(0 \leq a < r\) and \(1 \leq t \leq k-1\). Since the sequence \(X_1, \ldots, X_j\) is ideal, there is some \(j' < j\) for which \(X_{j'} = (X_j)_{1:2ak+1}\). Note that \(\hat{\mu}(X_{j'}) = \mu_{j'}'\) under \(\mathcal{E}\), so that \[\begin{align} \hat{\mu}(X_j) = \frac{\mu_{j'}' \cdot \hat{Z}_{2ak+1}}{\hat{Z}_{|X_j|}} \cdot \mathbb{1}\left\{{\mathsf{key}_a(X_j) = \psi(\mathsf{base}_a(X_j); \mathsf{query}_a(X_j))_{1:t}}\right\},\nonumber \end{align}\] since every edge weight between depths \(2ak+2\) and \(2ak+k+1\) is equal to \(1\). In particular, \(\hat{\mu}(X_j)\) is \(\psi\)-measurable conditioned on \(\mathcal{E}\) (under both \(\mathbb{P}_0, \mathbb{P}_1\)). By 19, \(\psi\) and \((\phi, v^{\mathsf{init}})\) are conditionally independent conditioned on \(\mathcal{E}\) under both \(\mathbb{P}_0, \mathbb{P}_1\), so \[\begin{align} \mathbb{P}_0(\hat{\mu}(X_j) = \cdot \mid \mathcal{E}) = \mathbb{P}_1(\hat{\mu}(X_j) = \cdot \mid \mathcal{E}).\label{eq:case1-kl} \end{align}\tag{53}\]

4.3.0.4 Case 2 for \(X_j\).

Suppose \(|X_j| = 2(a+1)k+1\) for some \(0 \leq a < r\). Let \[\begin{align} I_j :=& \mathbb{1}\left\{{\mathsf{key}_a(X_j) = \psi(\mathsf{base}_a(X_j); \mathsf{query}_a(X_j))}\right\}\nonumber\\ R_j :=& \mathbb{1}\left\{{v^{\mathsf{init}}= (X_j)_1 \text{ or } \exists b<a:\;\phi(\mathsf{base}_b(X_j); \mathsf{query}_b(X_j)) \neq \tilde{\phi}(\mathsf{base}_b(X_j); \mathsf{query}_b(X_j))}\right\}\nonumber\\ S_j := & R_j \cdot \phi(\mathsf{base}_a(X_j); \mathsf{query}_a(X_j)) + (1-R_j) \cdot \tilde{\phi}(\mathsf{base}_a(X_j); \mathsf{query}_a(X_j)) \in \{0,1\}.\nonumber \end{align}\] Since the sequence \(X_1, \ldots, X_j\) is ideal, there is some \(j' < j\) so that \(X_{j'} = (X_j)_{1:2ak+1}\). We may then write \[\begin{align} \hat{\mu}(X_j) = \frac{\hat{\mu}(X_{j'}) \cdot \hat{Z}_{2ak+1}}{\hat{Z}_{|X_j|}} \cdot I_j \cdot \left(1 + \gamma \cdot S_j \right),\label{eq:hatmu-formula} \end{align}\tag{54}\] To characterize the distribution of \(\hat{\mu}(X_j)\) conditioned on \(\mathscr{F}_{j-1}\) under \(\mathbb{P}_0, \mathbb{P}_1\) we observe that \([j-1]\) may be partitioned into 3 subsets:

  • \(\mathcal{J}_1\) consists of \(\ell \in [j-1]\) for which \(\mu_\ell' = 0\).

  • \(\mathcal{J}_2\) consists of \(\ell \not \in \mathcal{J}_1\) for which \(\mathsf{base}_a(X_\ell) \neq \mathsf{base}_a(X_j)\).

  • \(\mathcal{J}_3\) consists of \(\ell \not \in \mathcal{J}_1 \cup \mathcal{J}_2\). We claim that all \(\ell \in \mathcal{J}_3\) satisfy \(\mathsf{query}_a(X_\ell) \neq \mathsf{query}_a(X_j)\). This claim holds since, in order to have \(\hat{\mu}(X_\ell) > 0\) (which must have positive probability) and \(\mathsf{base}_a(X_\ell) = \mathsf{base}_a(X_j)\) and \(\mathsf{query}_a(X_\ell) = \mathsf{query}_a(X_j)\), we must have \(X_j \prec X_\ell\), which is impossible since the sequence \(X_1, \ldots, X_j\) (as \(|X_j| \pmod{2k} = 1\)) is ideal.

Since sequence \(X_1, \ldots, X_j\) is ideal, under \(\mathcal{E}\), the values of \(\hat{\omega}(X_\ell)\) for each \(\ell \in \mathcal{J}_2 \cup \mathcal{J}_3\) are uniquely determined (under the distributions \(\mathbb{P}_0, \mathbb{P}_1\)); indeed, for such \(\ell\) we have \(\hat{\mu}(X_\ell) = \frac{1}{\hat{Z}_{|X_\ell|}} \cdot \prod_{b=0}^{\lfloor (|X_\ell| - 2)/(2k) \rfloor} \hat{\omega}(\mathsf{base}_b(X_\ell))\), and the values of \(\hat{\omega}(\mathsf{base}_b(X_\ell))\) for all but (potentially) the largest value of \(b\) in this product are determined by \(\mu'_1, \ldots, \mu'_{\ell-1}\)on the event \(\{ \hat{\mu}(X_{\ell'}) = \mu_{\ell'}' \;\forall \ell' < \ell \}\). Thus, we may make the following definitions:

  • Let \(\tilde{A}\) denote the set of values of \(\mathsf{query}_a(X_\ell)\), for \(\ell \in \mathcal{J}_3\), for which \(\hat{\omega}(X_\ell) = 1 + \gamma\).

  • Let \(\tilde{C}\) denote the set of values of \(\mathsf{query}_a(X_\ell)\), for \(\ell \in \mathcal{J}_3\), for which \(\hat{\omega}(X_\ell) = 1\).

All \(\ell \in \mathcal{J}_3\) satisfy \(\mathsf{query}_a(X_\ell) \in \tilde{A} \cup \tilde{C}\) since \(\hat{\omega}(\mathsf{base}_a(X_\ell)) \neq 0\) for \(\ell \in \mathcal{J}_3\). Let \(\mathcal{E}^{\mathsf{query}}\) denote the event that \(\hat{\omega}(x) = 1+\gamma\) for all \(x \in \tilde{A}\) and that \(\hat{\omega}(x) = 1\) for all \(x \in \tilde{C}\).

Finally, let \(\mathcal{D}\) denote the set of all values of \(\mathsf{base}_b(X_\ell)\) not equal to \(\mathsf{base}_a(X_j)\) for any \(0 \leq b< r\) and \(\ell \in \mathcal{J}_2 \cup \mathcal{J}_3\) with \(2bk+1 \leq |X_\ell|\). Since the sequence \(X_1, \ldots, X_j\) is ideal, each \(X_\ell\) can only contribute at most one new value to \(\mathcal{D}\), meaning that \(|\mathcal{D}| \leq q-1\). For each \(d \in \mathcal{D}\), let \((v^{(d)}, \tilde{v}^{(d)}) \in \mathcal{V}^{\mathsf{valid}}_{k,\epsilon}\) be an arbitrary \(\epsilon\)-valid tuple; via slight abuse of notation, we let \((v,\tilde{v})\) denote the collection of \((v^{(d)}, \tilde{v}^{(d)})\) for \(d \in \mathcal{D}\). Let \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}\) denote the event that \(\phi(d) = (v^{(d)}, \tilde{v}^{(d)})\) for each \(d \in \mathcal{D}\).

We proceed to analyze the distribution \(\mathbb{P}_{(X_j)_1}(\hat{\mu}(X_j) = \cdot \mid \mathcal{E})\). For any values of \(\psi' \in \Psi_{n,k,q}\) and \((v,\tilde{v}) \in (\mathcal{V}^{\mathsf{valid}}_{k,\epsilon})^{\mathcal{D}}\) as above which are consistent with \(\mathcal{E}\) in the sense that \(\mathbb{P}_{(X_j)_1}(\mathcal{E}\mid \{ \psi = \psi' \} \cap \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}) > 0\), we have \[\begin{align} & \mathbb{P}_{(X_j)_1} \left(S_j = 1 \mid \mathcal{E}\cap \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\cap \{\psi = \psi'\} \right) \nonumber\\ =& \mathbb{P}_{(X_j)_1} \left(S_j = 1 \mid \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\cap \{\psi = \psi'\} \right) \nonumber\\ =& \mathbb{P}_{(X_j)_1} \left(S_j = 1 \mid \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\right) \nonumber\\ =& \mathbb{P}_{(X_j)_1} \left( \mathsf{query}_a(X_j) \in A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j))\mid \mathcal{E}^{\mathsf{query}}\right) \nonumber\\ =& \mathbb{P}_{(X_j)_1} \left( \mathsf{query}_a(X_j) \in A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j)) \mid \tilde{A} \subset A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j)),\;\tilde{C} \subset C(\mathsf{base}_a(X_j)) \right)\nonumber\\ =& \frac{2^{k-1} - |\tilde{A}|}{2^k - |\tilde{A}| - |\tilde{C}|}\label{eq:xj-same}, \end{align}\tag{55}\] where the first equality uses that, for \(\psi', (v,\tilde{v})\) which are consistent with \(\mathcal{E}\), we have \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\cap \{\psi = \psi'\} \subseteq \mathcal{E}\); the second equality uses that \(S_j\) and \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\) depend only on \(\phi\), together with the fact that \(\phi, \psi\) are independent; and the third equality uses the fact that \(\phi\) is \(q\)-wise independent: \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}\) conditions on the values of \(\phi(d)\) for at most \(q-1\) values of \(d\), and \(S_j = 1\) if and only if \(\phi(\mathsf{base}_a(X_j); \mathsf{query}_a(X_j)) = 1\), i.e., if \(\mathsf{query}_a(X_j) \in A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j))\). The fourth equality simply rewrites the definition of \(\mathcal{E}^{\mathsf{query}}\), and the final equality follows from the following reasoning: on the event \(\tilde{A} \subset A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j)),\;\tilde{C} \subset C(\mathsf{base}_a(X_j))\), the set \(A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j)) \backslash \tilde{A}\) is a uniformly random set of size \(2^{k-1} - |\tilde{A}|\) in \(\{0,1\}^k \backslash (\tilde{A} \cup \tilde{C})\), which has size \(2^k - |\tilde{A}| - |\tilde{C}|\).

We next perform a similar computation for \(\mathbb{P}_{1-(X_j)_1}\). To do so, first note that, under \(\mathbb{P}_{1-(X_j)_1}\), conditioned on \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}\), the values of \(v,\tilde{v}\) uniquely determine the value of \(R_j\): indeed, conditioned on \(\mathcal{E}^{\mathsf{base}}_{b,\tilde{v}}\), \(R_j = 1\) if and only if some \(b < a\) satisfies \(v^{(\mathsf{base}_b(X_j))}_{\mathsf{query}_b(X_j)} \neq \tilde{v}^{(\mathsf{base}_b(X_j))}_{\mathsf{query}_b(X_j)}\). For any \((v,\tilde{v}) \in (\mathcal{V}^{\mathsf{valid}}_{k,\epsilon})^{\mathcal{D}}\) and \(\psi' \in \Psi_{n,k,q}\) which are consistent with \(\mathcal{E}\) under \(\mathbb{P}_{1-(X_j)_1}(\cdot)\), which further satisfy that \(R_j = 1\) under \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}\), we have \[\begin{align} & \mathbb{P}_{1-(X_j)_1} \left(S_j = 1 \mid\mathcal{E}\cap \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\cap \{\psi = \psi'\} \right)\nonumber\\ =& \mathbb{P}_{1-(X_j)_1} \left( \mathsf{query}_a(X_j) \in A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j)) \mid \tilde{A} \subset A(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j)),\;\tilde{C} \subset C(\mathsf{base}_a(X_j)) \right)\nonumber\\ =& \mathbb{P}_{(X_j)_1} \left( S_j = 1\mid \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}\right)\label{eq:xj-diff1}, \end{align}\tag{56}\] using the same reasoning as in 55 . In instead \((v,\tilde{v})\) is so that \(R_j = 0\) under \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}\), we have \[\begin{align} & \mathbb{P}_{1-(X_j)_1} \left(S_j = 1 \mid\mathcal{E}\cap \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\cap \{\psi = \psi'\} \right)\nonumber\\ =& \mathbb{P}_{1-(X_j)_1} \left( S_j = 1 \mid \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \mathcal{E}^{\mathsf{query}}\right)\nonumber\\ =& \mathbb{P}_{1-(X_j)_1} \left( S_j = 1 \mid \mathcal{E}^{\mathsf{base}}_{v,\tilde{v}} \cap \{\tilde{A} \subset A(\mathsf{base}_a(X_j))\} \cap \{\tilde{C} \subset C(\mathsf{base}_a(X_j))\cup B(\mathsf{base}_a(X_j))\} \right)\nonumber\\ =& \mathbb{P}_{1-(X_j)_1} \left( \mathsf{query}_a(X_j) \in A(\mathsf{base}_a(X_j)) \mid \tilde{A} \subset A(\mathsf{base}_a(X_j)) ,\;\tilde{C} \subset C(\mathsf{base}_a(X_j))\cup B(\mathsf{base}_a(X_j)) \right)\nonumber\\ =& \frac{2^{k-1} - \epsilon 2^k - |\tilde{A}|}{2^k - |\tilde{A}| - |\tilde{C}|}\label{eq:xj-diff2}, \end{align}\tag{57}\] where the first equality follows the steps as in 55 ; the second equality uses that under \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}\)) (so that \(R_j = 0\)), the event \(\mathcal{E}^{\mathsf{query}}\) is equivalent to the event that \(\tilde{A} \subset A(\mathsf{base}_a(X_j))\) and \(\tilde{C} \subset C(\mathsf{base}_a(X_j))\cup B(\mathsf{base}_a(X_j))\); and the third equality uses the \(q\)-independence of \(\phi\), together with the fact that \(\mathcal{E}^{\mathsf{base}}_{v,\tilde{v}}\) depends on the values of \(\phi(d)\) for at most \(q-1\) values of \(d\), all not equal to \(\mathsf{base}_a(X_j)\). The final equality uses the following reasoning: on the event \(\tilde{A} \subset A(\mathsf{base}_a(X_j))\), \(\tilde{C} \subset C(\mathsf{base}_a(X_j)) \cup B(\mathsf{base}_a(X_j))\), the set \(A(\mathsf{base}_a(X_j)) \backslash \tilde{A}\) is a uniformly random set of size \(2^{k-1} - \epsilon 2^k - |\tilde{A}|\) in \(\{0,1\}^k \backslash (\tilde{A} \cup \tilde{C})\), which has size \(2^k - |\tilde{A}| - |\tilde{C}|\).

Note that \(|\tilde{A}| \cup |\tilde{C}| \leq |\mathcal{J}_3| \leq j-1 \leq q-1\). Since we have assumed that \(q \leq 2^k/100\), the right-hand sides of 55 56 57 all lie in \([1/3, 2/3]\) and differ by at most \(10\epsilon\). Since 55 56 57 hold for every \(v,\tilde{v}\), it follows that \[\begin{align} \mathbb{P}_0(S_j = 1 \mid \mathcal{E}), \mathbb{P}_1(S_j = 1 \mid \mathcal{E}) \in [1/3,2/3], \qquad \left| \mathbb{P}_0(S_j = 1 \mid \mathcal{E}) - \mathbb{P}_1(S_j = 1 \mid \mathcal{E}) \right| \leq 10\epsilon\nonumber, \end{align}\] and so \[\begin{align} D_{\mathsf{KL}}({\mathbb{P}_0(S_j = \cdot \mid \mathcal{E})}||{\mathbb{P}_1(S_j = \cdot \mid \mathcal{E})}) \leq O(\epsilon^2).\nonumber \end{align}\] Next, 19 gives that, conditioned on \(\mathcal{E}\), \(I_j\) is independent of \(S_j\) under the measures \(\mathbb{P}_0, \mathbb{P}_1\); and further, the distribution of \(I_j\) conditioned on \(\mathcal{E}\) is identical under \(\mathbb{P}_0, \mathbb{P}_1\). Thus, combining the above display with 54 gives that \[\begin{align} D_{\mathsf{KL}}({\mathbb{P}_0(\hat{\mu}(X_j) = \cdot \mid \mathcal{E})}||{\mathbb{P}_1(\hat{\mu}(X_j) = \cdot \mid \mathcal{E})}) \leq O(\epsilon^2),\nonumber \end{align}\] as desired. ◻

Next, 21 uses 20 to show that no algorithm which can make \(q\) queries to \(\hat{\mu}_\tau\) (for a random choice of \(\tau\)) can predict the value of \(v^{\mathsf{init}}\), as long as \(q\) is not too large.

Lemma 21. Suppose \(q \leq 2^k/100\), and a tuple \(\tau = (v^{\mathsf{init}}, \phi, \psi) \in \mathcal{H}_{n,k,q,\epsilon}\) is drawn uniformly at random, and let \(\hat{\mu} = \hat{\mu}_{\tau}\) denote the corresponding oracle. Then any randomized algorithm which makes \(q\) adaptive queries to \(\hat{\mu}(\cdot)\) and outputs a bit \(\hat{B} \in \{0,1\}\) satisfies \[\begin{align} \mathbb{P}(\hat{B} = v^{\mathsf{init}}) \leq \frac{1}{2} + O(\epsilon\sqrt{q}) + q\cdot 2^{-k}\nonumber. \end{align}\]

Proof. Fix an algorithm \(\mathsf{Alg}\), and denote the (adaptive) queries the algorithm makes by \(X_1, \ldots, X_q \in \{0,1\}^{\leq n}\). We begin by setting up some notation.

4.3.0.5 Setup.

For any \(x \in \{0,1\}^{2ak + i}\) for some \(0 \leq a < r\) and \(1 \leq i \leq 2k\), if \(i \in \{2,3,\ldots,k+1\}\), then every edge weight on the path from \(x_{1:2ak+1}\) to \(x\) is equal to \(1\), so \(\hat{\mu}(x)\) is determined by \(\hat{\mu}(x_{1:2ak+1})\) together with the deterministic normalizing constant \(\hat{Z}_{2ak+i}\) from 42 18. Hence, it is without loss of generality to assume that for each query \(j \in [q]\), \(|X_j| \pmod{2k} \in \{1, k+2, k+3, \ldots, 2k\}\).

For each \(j \in [q]\), write \(\mathscr{F}_{j}\) for the sigma-algebra generated by the first \(j\) query-answer pairs \((X_1, \hat{\mu}(X_1)), \ldots, (X_{j}, \hat{\mu}(X_{j}))\), as well as the internal randomness of \(\mathsf{Alg}\); then for each \(j \in [q]\), \(X_j\) is \(\mathscr{F}_{j-1}\)-measurable. Moreover, at a cost of a factor of at most \(2\) in \(q\), we may assume the following: for each query \(X_j\) lying strictly inside a “key block”, i.e., with \(|X_j| = 2ak + k + 1 + t\) for some \(0 \leq a < r\) and \(1 \leq t \leq k-1\), there is some \(j' < j\) for which \(X_{j'} = (X_j)_{1:2ak+1}\). In words, prior to making such a query, the algorithm has already queried the most recent ancestor of \(X_j\) whose length is \(1 \pmod{2k}\).

Recall that \(\mathbb{P}\) denotes the joint distribution over the random draw of \((v^{\mathsf{init}},\phi,\psi) \sim \mathcal{H}_{n,k,q,\epsilon}\) and the internal randomness of \(\mathsf{Alg}\), and \(\mathbb{E}\) denotes the corresponding expectation. For each \(b \in \{0,1\}\), recall that \(\mathbb{P}_b(\cdot) := \mathbb{P}(\cdot \mid v^{\mathsf{init}}= b)\). We will show that the probability laws of \(\mathbb{P}_0(X_1, \ldots, X_q, \hat{\mu}(X_1), \ldots, \hat{\mu}(X_q) = \cdot)\) and \(\mathbb{P}_1(X_1, \ldots, X_q, \hat{\mu}(X_1), \ldots, \hat{\mu}(X_q) = \cdot)\) are close, from which the desired result will follow using Bayes rule.

4.3.0.6 Alternative algorithm: \(\widetilde{\mathsf{Alg}}\).

First, we consider the following further modification of \(\mathsf{Alg}\), which we denote by \(\widetilde{\mathsf{Alg}}\). \(\widetilde{\mathsf{Alg}}\) internally simulates \(\mathsf{Alg}\), in the following manner: it maintains a sequence \(Y_1, Y_2, \ldots, Y_t\) (intialized to be the empty sequence, so that \(t = 0\)), as follows. For each \(j \in [q]\), when \(\mathsf{Alg}\) is about to query \(\hat{\mu}(X_j)\), \(\widetilde{\mathsf{Alg}}\) checks if the sequence \(Y_1, \ldots, Y_t, X_j\) is ideal (in the sense of 8); we let this event be denoted by \(\mathcal{E}_j\). If \(\mathcal{E}_j\) holds, then \(\widetilde{\mathsf{Alg}}\) sets \(Y_{t+1} = X_j\), increments \(t\) by \(1\), and continues to execute \(\mathsf{Alg}\). Otherwise, \(\widetilde{\mathsf{Alg}}\) does not query \(\hat{\mu}(X_j)\) and simply proceeds as if the result of the query had returned \(\hat{\mu}(X_j) = 0\). We let \(\tilde{B}\) denote the output bit returned by \(\widetilde{\mathsf{Alg}}\). Moreover, for each \(j \in [q]\), we let \(\tilde{\mu}_j\) denote the value which \(\widetilde{\mathsf{Alg}}\) uses for \(\hat{\mu}(X_j)\) (i.e., \(\tilde{\mu}_j = \hat{\mu}(X_j)\) if \(Y_1, \ldots, Y_t, X_j\) is ideal, and otherwise \(\tilde{\mu}_j = 0\)). We may consider \(\mathsf{Alg},\widetilde{\mathsf{Alg}}\) as being defined on the same probability space, using the same internal randomness and the same sampled tuple \((v^{\mathsf{init}},\phi,\psi) \sim \mathcal{H}_{n,k,q,\epsilon}\). We denote the corresponding probability measure by \(\mathbb{P}\) (and use \(\mathbb{P}_0, \mathbb{P}_1\) to denote conditioning on \(v^{\mathsf{init}}= 0,1\), respectively).

Claim 6. It holds that \(\mathbb{P}(\hat{B} = \tilde{B}) \geq 1 - q 2^{-k}\).

The proof of 6 is deferred to below. Given 6, it suffices to upper bound \(\mathbb{P}(\tilde{B} = v^{\mathsf{init}})\).

4.3.0.7 Analyzing \(\widetilde{\mathsf{Alg}}\).

Let \(t_j\) be the value of \(t\) maintained by \(\widetilde{\mathsf{Alg}}\) at the beginning of step \(j\), so that prior to step \(j\), \(\widetilde{\mathsf{Alg}}\) has queried \(\hat{\mu}(\cdot)\) only at \(Y_1, \ldots, Y_{t_j}\). We denote the “simulated queries” of \(\mathsf{Alg}\) made by \(\widetilde{\mathsf{Alg}}\) by \(\tilde{X}_1, \ldots, \tilde{X}_q\). Further, we let \(\tilde{\mathscr{F}}_j\) denote the sigma-algebra generated by the internal randomness of \(\widetilde{\mathsf{Alg}}\) together with \((\tilde{X}_\ell, \tilde{\mu}_\ell)_{\ell \in [j]}\). If \(\mathcal{E}_j\) holds, then the sequence \(Y_1, \ldots, Y_{t_j}, Y_{t_j+1} = \tilde{X}_j\) is ideal, so we may apply 20 to this sequence to obtain that there is an absolute constant \(C\) such that \[\begin{align} D_{\mathrm{KL}}\!\left( \mathcal{\mathbb{P}}_1\left(\tilde{\mu}_j = \cdot \mid \tilde{\mathscr{F}}_{j-1}\right)\, \middle\|\, \mathcal{\mathbb{P}}_0\left(\tilde{\mu}_j = \cdot \mid \tilde{\mathscr{F}}_{j-1}\right) \right) \leq C\epsilon^2.\label{eq:case2-kl} \end{align}\tag{58}\] If \(\mathcal{E}_j\) does not hold, then \(\tilde{\mu}_j = 0\) and so \[\begin{align} D_{\mathrm{KL}}\!\left( \mathcal{\mathbb{P}}_1\left(\tilde{\mu}_j = \cdot \mid \tilde{\mathscr{F}}_{j-1}\right)\, \middle\|\, \mathcal{\mathbb{P}}_0\left(\tilde{\mu}_j = \cdot \mid \tilde{\mathscr{F}}_{j-1}\right) \right) = 0.\label{eq:case2b-kl} \end{align}\tag{59}\]

The chain rule for KL divergence yields \[\begin{align} & D_{\mathsf{KL}}({\mathbb{P}_1(\tilde{X}_{1:q},\tilde{\mu}_{1:q} = \cdot)}||{\mathbb{P}_0(\tilde{X}_{1:q}, \tilde{\mu}_{1:q} = \cdot)})\nonumber\\ =& \sum_{j=1}^q D_{\mathrm{KL}}\!\left( \mathcal{\mathbb{P}}_1\left(\tilde{\mu}_j = \cdot \mid \tilde{\mathscr{F}}_{j-1}\right)\, \middle\|\, \mathcal{\mathbb{P}}_0\left(\tilde{\mu}_j = \cdot \mid \tilde{\mathscr{F}}_{j-1}\right) \right) \leq C q \epsilon^2\nonumber, \end{align}\] where the final inequality uses 58 59 .

Pinsker’s inequality yields \[\begin{align} D_{\mathsf{TV}}({\mathbb{P}_1(\tilde{X}_{1:q},\tilde{\mu}_{1:q} = \cdot)}, {\mathbb{P}_0(\tilde{X}_{1:q}, \tilde{\mu}_{1:q} = \cdot)})\leq O(\epsilon\sqrt q).\nonumber \end{align}\] Consequently, we have \[\begin{align} & \mathbb{E}\left[ \left|\mathbb{P}(v^{\mathsf{init}}= 1 \mid \tilde{X}_{1:q}, \tilde{\mu}_{1:q})- \mathbb{P}(v^{\mathsf{init}}= 0 \mid \tilde{X}_{1:q}, \tilde{\mu}_{1:q})\right| \right]\nonumber\\ =& D_{\mathsf{TV}}({\mathbb{P}_1(\tilde{X}_{1:q},\tilde{\mu}_{1:q} = \cdot)}, {\mathbb{P}_0(\tilde{X}_{1:q}, \tilde{\mu}_{1:q} = \cdot)})\leq O(\epsilon\sqrt q)\nonumber, \end{align}\] and since \(v^{\mathsf{init}}\in \{0,1\}\), it follows that \[\begin{align} \mathbb{E}\left[ \left|\mathbb{P}(v^{\mathsf{init}}= 1 \mid \tilde{X}_{1:q}, \tilde{\mu}_{1:q}) - \frac{1}{2}\right| \right] \leq O(\epsilon\sqrt q),\nonumber \end{align}\] and thus, since \(\tilde{B}\) is a function of \(\tilde{X}_{1:q}, \tilde{\mu}_{1:q}\), and the internal randomness of \(\mathsf{Alg}\), \[\begin{align} \left|\mathbb{P}(v^{\mathsf{init}}= \tilde{B}) - \frac{1}{2} \right| \leq \mathbb{E}\left[ \left|\mathbb{P}(v^{\mathsf{init}}= \tilde{B} \mid \tilde{X}_{1:q}, \tilde{\mu}_{1:q}) - \frac{1}{2}\right| \right] \leq O(\epsilon\sqrt q).\nonumber \end{align}\] Combining the above with 6 yields the desired result. ◻

Finally, we prove 6.

Proof of 6. Recall that we couple \(\mathsf{Alg}\) and \(\widetilde{\mathsf{Alg}}\) using the same internal randomness and the same realization of \((v^{\mathsf{init}},\phi, \psi)\). The two algorithms can differ only if, at some query step \(j\), the event \(\mathcal{E}_j^c\) holds and yet the true oracle value satisfies \(\hat{\mu}(X_j)\neq 0\); indeed, in all other cases \(\widetilde{\mathsf{Alg}}\) feeds the same answer to the algorithm as \(\mathsf{Alg}\) does.

For each \(j \in [q]\), let \(a_j \geq 0\) be chosen as small as possible so that \(2k \cdot a_j +1 < |X_j|\) and \(\mathsf{base}_{a_j}(X_j)\) has not been previously queried. (If no such \(a_j\) exists, then we set \(a_j = \perp\).) Let \(J \in [q] \cup \{ \infty\}\) be a random variable denoting the first iteration for which \(a_J \neq \perp\) and \(\hat{\mu}(X_J) \neq 0\).

Fix \(j \in [q]\); in order for \(J = j\) to hold, it is necessary that (a) \(a_j \neq \perp\) and (b) \(\mathsf{key}_{a_j}(X_j) = \psi(\mathsf{base}_{a_j}(X_j); \mathsf{query}_{a_j}(X_j))\). Note that \(a_j\) is \(\mathscr{F}_{j-1}\)-measurable. We now make the following claim:

Claim 7. For each \(j \in [q]\), under the execution of \(\widetilde{\mathsf{Alg}}\), conditioned on \(a_j \neq \perp\) and \(\mathscr{F}_{j-1}\), the distribution of \(\psi(\mathsf{base}_{a_j}(X_j))\) is uniformly random on \(\{0,1\}^k\).

Proof of 7. First note that at each iteration \(\ell\) (in particular, those \(\ell < j\)), \(\hat{\mu}(X_\ell)\) only depends on \(\psi\) through (a) the history \(\mathscr{F}_{\ell-1}\) and (b) potentially \(\psi(\mathsf{base}_a(X_\ell))\) for a single value of \(a\) (namely, \(a = \lfloor (|X_\ell|-2)/k\rfloor\)). Indeed, if the values \(\mathsf{base}_b(X_\ell)\) for all \(b = 0, 1, \ldots, a-1\) had not been queried prior to step \(\ell\), then \(\widetilde{\mathsf{Alg}}\) would not have actually queried \(\hat{\mu}(X_\ell)\) and would have used the value \(0\) as the response. Thus, the history of interaction \(\mathscr{F}_{j-1}\) only depends on \(\psi\) through at most \(j-1\) values of \(\psi(x)\), \(x \in \{0,1\}^{\leq n}\).

Moreover, we claim that \(\mathsf{base}_a(X_j)\) is not one of these values: by our assumption on \(\mathsf{Alg}\) (and thus \(\widetilde{\mathsf{Alg}}\)), there is no \(\ell < j\) for which \(\mathsf{base}_a(X_\ell) = \mathsf{base}_a(X_j)\) and \(|X_\ell| = 2ak + t\) for \(t \in \{k+2, \ldots, 2k \}\) (as otherwise \(\mathsf{Alg}\) would have queried \(\hat{\mu}(\mathsf{base}_a(X_\ell))\) earlier). Further, if \(\mathsf{base}_a(X_\ell) = \mathsf{base}_a(X_j)\) and \(|X_\ell| \geq 2(a+1)k + 1\), then \(\widetilde{\mathsf{Alg}}\) would not have queried \(X_\ell\) (and would have instead proceeded by using \(0\) as the returned value of the oracle call).

Summarizing, since \(\psi\) is drawn from a \(q\)-wise independent family, conditioned on \(\mathscr{F}_{j-1}\), the value of \(\psi(\mathsf{base}_a(X_j))\) is uniformly random on its domain \((\{0,1\}^k)^{\{0,1\}^k}\). ◻

If \(a_j \neq \perp\) (so that \(\mathsf{base}_{a_j}(X_j)\) has not been previously queried), then we must in fact that \(|X_j| = 2(a_j+1)k + 1\) (by our assumption on \(\mathsf{Alg}\)). Hence, for any realization of the history for which \(a_j \neq \perp\), we have \[\begin{align} \mathbb{P}(J = j \mid \mathscr{F}_{j-1}) = \mathbb{P}(\mathsf{key}_{a_j}(X_j) = \psi(\mathsf{base}_{a_j}(X_j); \mathsf{query}_{a_j}(X_j)) \mid \mathscr{F}_{j-1}) = 2^{-k}\nonumber, \end{align}\] where the final equality uses the fact that \(\mathsf{key}_{a_j}(X_j)\), \(\mathsf{base}_{a_j}(X_j)\), and \(\mathsf{query}_{a_j}(X_j)\) are all \(\mathscr{F}_{j-1}\)-measurable, and \(\psi(\mathsf{base}_{a_j}(X_j); \mathsf{query}_{a_j}(X_j))\) is uniform on \(\{0,1\}^k\), conditioned on \(\mathscr{F}_{j-1}\), by 7. A union bound then yields \(\mathbb{P}\left( J \leq q \right) \leq q/2^k\); in other words, with probability at least \(1-q/2^k\), the execution traces of \(\mathsf{Alg}, \widetilde{\mathsf{Alg}}\) are identical, and thus the algorithms return the same bit as output. ◻

We are now ready to prove 4; it follows as a straightforward consequence of the previous lemmas, notably 21.

Proof of 4. Set \(q = \frac{c \gamma^2 n^2}{ \log^2 (n) \cdot \log^2(2/\gamma)}\), for a sufficiently small constant \(c > 0\) to be chosen later. Take \[\begin{align} k = \lceil 2 \log_2(n)\rceil, \qquad r =\left\lfloor \frac{n-1}{2k}\right\rfloor, \qquad \epsilon:= \frac{4 \log(48/\gamma) \cdot k}{n}, \qquad n' = 2rk+1.\label{eq:weak-params} \end{align}\tag{60}\]

Suppose to the contrary that such \(\mathsf{Alg}\) exists, and consider the execution of \(\mathsf{Alg}\) with respect to the distribution \(\mu^\star = \mu_{\tau}\) and mapping \(\hat{\mu}_{\tau}\), where \(\tau = (v^{\mathsf{init}}, \phi, \psi) \sim \mathcal{H}_{n',k,q}\) is drawn uniformly at random. First, 17 ensures that we indeed have that \(\frac{1}{(1+\gamma)^2} \leq \frac{\mu_{\tau}(x)}{\hat{\mu}_{\tau}(x)} \leq (1+\gamma)^2\) with probability \(1\) for all \(x \in \{0,1\}^{\leq n}\); further, by definition we have \(\mu_\tau(x) = \hat{\mu}(x)\) for \(x \in \{0,1\}^n\). Thus 1 is satisfied. For any instantiation of \(\tau\), let the distribution of the output \(X\) of \(\mathsf{Alg}\) be denoted \(\hat{\nu}_{\tau}\). The assumption that \(D_{\mathsf{TV}}({\mu_\tau}, {\hat{\nu}_\tau}) \leq \frac{\gamma}{8}\) and \(\gamma < 1\), as well as the fact that \(e^{-\epsilon r} \leq \gamma/48\) (from 60 ) yields \[\begin{align} & \mathbb{P}_{X \sim \hat{\nu}_\tau}(X_1 = v^{\mathsf{init}}_1) \geq \mathbb{P}_{X \sim \mu_\tau}(X_1 = v^{\mathsf{init}}_1) - \frac{\gamma}{8} \geq \mathbb{P}_{X \sim \mu_{\mathsf{ideal}}}(X_1 = v^{\mathsf{init}}_1) - \frac{\gamma}{8} - e^{-\epsilon r} \nonumber\\ & \geq \frac{1+\gamma}{2+\gamma} - \frac{\gamma}{8} - e^{-\epsilon r} \geq \frac{1}{2} + \frac{\gamma}{24} - e^{-\epsilon r} \geq \frac{1}{2} + \frac{\gamma}{48}\nonumber. \end{align}\] Above the second inequality uses 16, and the third inequality uses the definition of \(\mu_{\mathsf{ideal}}\). This contradicts 21 as long as \(q \leq \frac{c \gamma^2}{\epsilon^2}\) (which also yields \(q \cdot 2^{-k} < \gamma/100\)), for a sufficiently small constant \(c\).

Note that we have shown a lower bound for an instance \(\tau \in \mathcal{H}_{n',k,q}\), for which the corresponding measures are defined on \(\{0,1\}^{n'}\); but we can extend this to \(\{0,1\}^n\) by simply padding the last \(n-n'\) bits deterministically.

Finally, we remark that we can take the class \(\mathcal{F}\) to be equal to \(\mathcal{H}_{n',k,q}\). By 7 (which relies on 15), its cardinality satisfies \[\begin{align} \log |\mathcal{F}| = 2 + \log |\Phi_{n',k,q}| + \log |\Psi_{n',k,q}| \leq O(q k2^k) \leq O(n^4)\nonumber. \end{align}\] ◻

4.4 Additional lower bounds↩︎

Below we show a variant of 4 where we allow the cardinality of the class \(\mathcal{F}\) to be a free parameter: we derive a query lower bound of \(\tilde{\Omega}(\sqrt{\log |\mathcal{F}|})\). For simplicity, we take \(\gamma\) to be an absolute constant. Moreover, define the function \(f : \mathbb{N}\times \mathbb{N}\to \mathbb{R}\) by \[\begin{align} f(n, S) :=\max \left\{ \min\{ S, n \}, \min \left\{\frac{\sqrt{\log S}}{\log^2(2 + \log S)}, \frac{n^2}{\log^2 n} \right\} \right\}\nonumber. \end{align}\] It is easier to interpret \(f(n,S)\) when we condition on the size of \(S\), as follows — namely, note that \[\begin{align} f(n,S) \asymp\begin{cases} \min\{S, n\} &: S \leq \exp(n^2 \log^4 n) \\ \min \left\{\frac{\sqrt{\log S}}{\log^2(2 + \log S)}, \frac{n^2}{\log^2 n} \right\} &: \exp(n^2 \log^4 n) < S < \exp(n^4) . \end{cases}\nonumber \end{align}\]

Theorem 8 (Size-sensitive lower bound).

There is a constant \(c > 0\) so that the following holds for all sufficiently large \(n \in \mathbb{N}\) and all integers \(S\geq 2\). There exists a class of distributions \(\mathcal{F}\subseteq \Delta(\{0,1\}^n)\) with \(|\mathcal{F}| \leq S\) such that any randomized algorithm which enjoys the following guarantee must make at least \(c \cdot f(n,S)\) queries to \(\hat{\mu}\): for every \(\mu^\star \in \mathcal{F}\) and every mapping \(\hat{\mu} : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\) satisfying 1 with respect to \(\mu^\star\) for \(R = 9/4\), the algorithm outputs a distribution \(\hat{\nu}\) satisfying \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \leq \frac{1}{16}.\)

Proof. It is without loss of generality to assume that \(S \leq \exp(n^4)\) (as the function \(f(n,S)\) is constant as a function of \(S\) for \(S > \exp(n^4)\)).

4.4.0.1 Case 1: large \(S\).

We first show a lower bound of \(\Omega\left(\min \left\{\frac{\sqrt{\log S}}{\log^2(2 + \log S)}, \frac{n^2}{\log^2 n} \right\} \right)\) on the query complexity. Write \(n' = c'\log(S)^{1/4}\), for a sufficiently small constant \(c' > 0\) to be specified below. Then 4 with \(\gamma = 1/2\) gives that there is a class of distributions \(\mathcal{F}' \subset \Delta(\{0,1\}^{n'})\) of size at most \(\exp(O((n')^4))\) so that no randomized algorithm \(\mathsf{Alg}\) enjoys the following guarantee: for any \(\mu^\star \in \mathcal{F}'\) and \(\hat{\mu} : \{0,1\}^{\leq n'} \to \mathbb{R}_{\geq 0}\) satisfying 1 with \(R = 9/4\), \(\mathsf{Alg}\) makes \(\frac{c \cdot (n')^2}{\log^2(n')}\) queries to \(\hat{\mu}\) and outputs a random string \(X' \in \{0,1\}^{n'}\) according to some distribution \(\hat{\nu}\) which satisfies \(D_{\mathsf{TV}}({\mu^\star}, {\hat{\nu}}) \leq 1/16\), for some constant \(c > 0\). Note that we can view \(\mathcal{F}'\) as a subset of \(\Delta(\{0,1\}^n)\) by padding the last \(n-n'\) coordinates to be \(0\) with probability 1 (for all \(\mu \in \mathcal{F}'\)). Thus, noting that \((n')^2 = \Theta(\sqrt{\log S})\) and \(\log^2(n') \leq \log^2(2 + \log S)\), as well as \(|\mathcal{F}'| \leq S\) as long as the constant \(c'\) is sufficiently small, we obtain that any randomized algorithm satisfying the requirement of 8 must make \(\Omega\left(\min \left\{\frac{\sqrt{\log S}}{\log^2(2 + \log S)}, \frac{n^2}{\log^2 n} \right\} \right)\) queries to \(\hat{\mu}\).

4.4.0.2 Case 2: Small \(S\).

We next show a lower bound of \(\Omega (\min\{S, n\})\) on the query complexity. It suffices to assume \(S \leq n\). For \(1 \leq i \leq S\), let \(v_i \in \{0,1\}^S\) be defined by \(v_{i,j} = \mathbb{1}\left\{{j \leq i}\right\}\). We define a class \(\mathcal{F}_S \subset \Delta(\{0,1\}^S)\) consisting of the \(S-1\) measures \(\mu_1, \ldots, \mu_{S-1}\), where for each \(i \in [S-1]\), \[\begin{align} \mu_i := \frac{1}{2} \cdot \delta_{v_i} + \frac{1}{2} \cdot \delta_{v_S}.\nonumber \end{align}\] Next, for each \(i \in [S-1]\), define \(\hat{\mu}_i : \{0,1\}^{\leq S} \to \mathbb{R}_{\geq 0}\) by \[\begin{align} \hat{\mu}_i(x) = \begin{cases} \frac{1}{2} &: x \preceq v_iorx \preceq v_S \\ 0 &: otherwise. \end{cases}\nonumber \end{align}\] We claim that \(\hat{\mu}_i\) satisfies 1 with respect to \(\mu_i\), with \(R = 2 \leq 9/4\). Indeed, fix any \(x \in \{0,1\}^{\leq S}\). If \(x \npreceq v_i\) and \(x \npreceq v_S\), then \(\mu_i(x) = \hat{\mu}_i(x) = 0\). If \(x\) is a prefix of exactly one of \(v_i, v_S\), then \(\mu_i(x) = \hat{\mu}_i(x) = 1/2\). Finally, if \(x\) is a prefix of both \(v_i\) and \(v_S\), then necessarily \(x = 1^t\) for some \(t \leq i\), and thus \(\mu_i(x) = 1\) while \(\hat{\mu}_i(x) = 1/2\). Therefore, whenever \(\hat{\mu}_i(x) > 0\), we have \[\begin{align} 1 \leq \frac{\mu_i(x)}{\hat{\mu}_i(x)} \leq 2 \leq 9/4.\nonumber \end{align}\] Moreover, for every leaf \(x \in \{0,1\}^S\), the definition gives \(\hat{\mu}_i(x) = \mu_i(x)\), as required.

It remains to show that any randomized algorithm requires \(\Omega(S)\) queries. Fix any randomized algorithm making at most \(q\) queries, and draw \(I \sim \mathrm{Unif}([S-1])\). We will show that if \(q \leq cS\) for a sufficiently small constant \(c > 0\), then the algorithm cannot output a distribution within total variation distance \(1/16\) of \(\mu_I\).

Fix a realization \(\rho\) of the algorithm’s internal randomness, and consider the resulting deterministic algorithm. Let \(\hat{\mu}_\circ\) denote the reference oracle defined by \[\begin{align} \hat{\mu}_\circ(x) := \frac{1}{2} \cdot \mathbb{1}\left\{{x \preceq v_S}\right\}.\nonumber \end{align}\] Run the deterministic algorithm against \(\hat{\mu}_\circ\), and let \(x_1^{\rho}, \ldots, x_q^{\rho}\) denote the resulting query sequence, with output \(Y_{\rho} \in \{0,1\}^S\). Define \[\begin{align} T_{\rho} := \{ i \in [S-1] \mid \exists j \in [q]such thatx_j^{\rho} \preceq v_iandx_j^{\rho} \npreceq v_S\}.\nonumber \end{align}\] For any fixed query \(x\), there is at most one index \(i \in [S-1]\) such that \(x \preceq v_i\) and \(x \npreceq v_S\): indeed, once a prefix leaves the all-ones path leading to \(v_S\), it can lie on at most one of the paths to \(v_1, \ldots, v_{S-1}\). Consequently, \(|T_{\rho}| \leq q\).

Now fix any \(i \in [S-1] \setminus T_{\rho}\). By definition of \(T_{\rho}\), every query \(x_j^{\rho}\) receives the same answer from \(\hat{\mu}_i\) as from \(\hat{\mu}_\circ\): if \(x_j^{\rho} \preceq v_S\), then both oracles return \(1/2\), and otherwise \(x_j^{\rho} \npreceq v_i\), so both return \(0\). Thus, when run against \(\hat{\mu}_i\), the deterministic algorithm follows the exact same execution trace as it does against \(\hat{\mu}_\circ\), and hence outputs the same string \(Y_{\rho}\). Therefore, \[\begin{align} \mathbb{P}_{I \sim \mathrm{Unif}([S-1])}(Y_{\rho} = v_I) \leq \mathbb{P}(I \in T_{\rho}) + \mathbb{P}(Y_{\rho} = v_I,\;I \notin T_{\rho}) \leq \frac{|T_{\rho}|}{S-1} + \frac{1}{S-1} \leq \frac{q+1}{S-1}.\nonumber \end{align}\] Since this bound holds for every realization \(\rho\) of the algorithm’s internal randomness, averaging over \(\rho\) yields \[\begin{align} \mathbb{P}(X = v_I) \leq \frac{q+1}{S-1},\label{eq:small-s-success-bound} \end{align}\tag{61}\] where \(X\) denotes the output of the original randomized algorithm.

On the other hand, if the algorithm were to satisfy the guarantee of 8, then for every \(i \in [S-1]\) its output distribution \(\hat{\nu}_i\) under oracle \(\hat{\mu}_i\) would satisfy \(D_{\mathsf{TV}}({\hat{\nu}_i}, {\mu_i}) \leq 1/16\). Since \(\mu_i(v_i) = 1/2\), this implies \[\begin{align} \mathbb{P}(X = v_i \mid I = i) = \hat{\nu}_i(v_i) \geq \mu_i(v_i) - D_{\mathsf{TV}}({\hat{\nu}_i}, {\mu_i}) \geq \frac{1}{2} - \frac{1}{16} = \frac{7}{16}.\nonumber \end{align}\] Averaging over \(I \sim \mathrm{Unif}([S-1])\), we obtain \(\mathbb{P}(X = v_I) \geq 7/16\), which contradicts 61 as long as \(q \leq cS\) for a sufficiently small universal constant \(c > 0\).

Finally, we may view \(\mathcal{F}_S\) as a subset of \(\Delta(\{0,1\}^n)\) by padding the last \(n-S\) coordinates with zeros deterministically. Since \(|\mathcal{F}_S| = S-1 \leq S\), this establishes the desired \(\Omega(S) = \Omega(\min\{S,n\})\) lower bound in the small-\(S\) regime, and completes the proof. ◻

We next show a variant of the construction which yields a stronger lower bound, in the following sense: any algorithm which makes strictly subquadratically many queries to \(\hat{\mu}\) cannot sample from any distribution whose KL divergence from \(\mu\) is strictly sublinear (in \(n\)).

Fix positive integers \(n,k,q\) as above, as well as a positive integer \(s\). Recall the definition of the class \(\mathcal{H}_{n,k,q,\epsilon}\) in 7, as well as, for \(\tau = (v^{\mathsf{init}}, \phi, \psi) \in \mathcal{H}_{n,k,q,\epsilon}\), the distribution \(\mu_\tau \in \Delta(\{0,1\}^n)\) and mapping \(\hat{\mu}_\tau : \{0,1\}^{\leq n} \to \mathbb{R}_{\geq 0}\) defined in 43 .

Write \(\bar{n} := ns\). We will often interpret elements of \(\{0,1\}^{\bar{n}}\) by partitioning their coordinates into \(s\) blocks of size \(n\), as follows: for \(x \in \{0,1\}^{\bar{n}}\), we write \(x = (x^{(1)}, \ldots, x^{(s)})\), where each \(x^{(i)} \in \{0,1\}^n\) is the \(i\)th block of \(x\) consisting of the coordinates \((x_{(i-1)n+1}, \ldots, x_{in})\). Next, for \(\tau^{(1)}, \ldots, \tau^{(s)} \in \mathcal{H}_{n,k,q,\epsilon}\), we define a distribution \(\mu_{\tau^{(1:s)}} \in \Delta(\{0,1\}^{\bar{n}})\), and mapping \(\hat{\mu}_{\tau^{(1:s)}} : \{0,1\}^{\leq \bar{n}} \to \mathbb{R}_{\geq 0}\) as follows: for \(x = (x^{(1)}, \ldots, x^{(s)}) \in \{0,1\}^{\bar{n}}\) with each \(x^{(i)} \in \{0,1\}^n\), we set \[\begin{align} \mu_{\tau^{(1:s)}}(x) := \prod_{i=1}^s \mu_{\tau^{(i)}}(x^{(i)})\nonumber. \end{align}\] Further, for \(x = (x^{(1)}, \ldots, x^{(a)}) \in \{0,1\}^{\leq \bar{n}}\) with \(x^{(1)}, \ldots, x^{(a-1)} \in \{0,1\}^n\) and \(x^{(a)} \in \{0,1\}^{\leq n}\), we set \[\begin{align} \hat{\mu}_{\tau^{(1:s)}}(x) := \prod_{i=1}^{a} \hat{\mu}_{\tau^{(i)}}(x^{(i)}).\nonumber \end{align}\]

Lemma 22. For any \(\tau^{(1:s)} \in \mathcal{H}_{n,k,q,\epsilon}^s\) and \(x \in \{0,1\}^{\leq \bar{n}}\), we have \(\frac{1}{(1+\gamma)^{2}} \leq \frac{\mu_{\tau^{(1:s)}}(x)}{\hat{\mu}_{\tau^{(1:s)}}(x)} \leq (1+\gamma)^{2}\) for all \(x \in \{0,1\}^{\leq \bar{n}}\).

Proof. Let us write \(x = (x^{(1)}, \ldots, x^{(a)}) \in \{0,1\}^{\leq \bar{n}}\) with \(x^{(1)}, \ldots, x^{(a-1)} \in \{0,1\}^n\) and \(x^{(a)} \in \{0,1\}^{\leq n}\). By definition of \(\mu_{\tau^{(i)}}, \hat{\mu}_{\tau^{(i)}}\), for \(i < a\), since we have \(x^{(i)} \in \{0,1\}^n\), it holds that \(\mu_{\tau^{(i)}}(x^{(i)}) = \hat{\mu}_{\tau^{(i)}}(x^{(i)})\). Thus \[\begin{align} \frac{\mu_{\tau^{(1:s)}}(x)}{\hat{\mu}_{\tau^{(1:s)}}(x)} = \frac{\prod_{i=1}^a \mu_{\tau^{(i)}}(x^{(i)})}{\prod_{i=1}^a \hat{\mu}_{\tau^{(i)}}(x^{(i)})} = \frac{\mu_{\tau^{(a)}}(x^{(a)})}{\hat{\mu}_{\tau^{(a)}}(x^{(a)})} \in [(1+\gamma)^{-2}, (1+\gamma)^2],\nonumber \end{align}\] where the final inclusion uses 17. (Above, we interpret \(0/0 = 1\).) ◻

Theorem 9. There is a constant \(c > 0\) so that the following holds, for any sufficiently large \(\bar{n} \in \mathbb{N}\), parameter \(\gamma \in (1/\bar{n},1)\), and \(\mathsf{K}\geq \gamma^2\). There is no randomized algorithm \(\mathsf{Alg}\) which enjoys the following guarantee: for any distribution \(\mu^\star \in \Delta(\{0,1\}^{\bar{n}})\) and \(\hat{\mu} : \{0,1\}^{\leq \bar{n}} \to \mathbb{R}_{\geq 0}\) satisfying 1 with \(R = (1+\gamma)^2\), \(\mathsf{Alg}\) makes \(o\left( \frac{\bar{n}^2 \gamma^6}{\mathsf{K}^2 \log^2(\bar{n}) \cdot \log^2(2/\gamma)} \right)\) queries to \(\hat{\mu}\) and outputs a (random) vector \(X \in \{0,1\}^{\bar{n}}\), according to some distribution \(\hat{\nu}\), satisfying \(D_{\mathsf{KL}}({\mu^\star}||{\hat{\nu}}) \leq \mathsf{K}\).

Proof. If \(\frac{800 \mathsf{K}}{\gamma^2} > \frac{\bar{n}}{ 100 \log \bar{n}}\), then the claimed query bound \(c' \bar{n}^2\gamma^6 / (\mathsf{K}^2 \log^2 \bar{n} \cdot \log^2(2/\gamma))\) is \(O(1)\), so the result is trivial. Thus we may assume \(\frac{800 \mathsf{K}}{\gamma^2} \leq \frac{\bar{n}}{ 100 \log \bar{n}}\). Take \[\begin{align} s := \left\lceil \frac{800}{\gamma^2} \mathsf{K}\right\rceil, \qquad k := \lceil 10 \log_2 \bar{n} \rceil, \qquad r := \left\lfloor \frac{\lfloor \bar{n}/s \rfloor - 1}{2k} \right\rfloor,\nonumber\\ n := 1 + 2k \cdot r, \qquad \epsilon:= \frac{32 \log(96/\gamma) \cdot k}{n}, \qquad \bar{n}' :=ns \nonumber. \end{align}\] Since \(\frac{800 \mathsf{K}}{\gamma^2} \leq \frac{\bar{n}}{ 100 \log \bar{n}}\), we have \(s \leq \frac{\bar n}{50 \log \bar n}\) and hence \(r \geq 1\). Since \(\bar{n}' \leq \bar{n}\), it suffices to prove the lower bound with \(\bar{n}'\) in place of \(\bar{n}\) (we can simply pad the last \(\bar{n}-\bar{n}'\) coordinates deterministically).

Suppose to the contrary that such \(\mathsf{Alg}\) exists, and consider the execution of \(\mathsf{Alg}\) with respect to the distribution \(\mu^\star = \mu_{\tau^{(1:s)}}\) and mapping \(\hat{\mu}_{\tau^{(1:s)}}\), where \(\tau^{(1:s)} \sim \mathcal{H}_{n,k,q,\epsilon}^s\) is drawn uniformly at random. Note that \(\mu_{\tau^{(1:s)}} \in \Delta(\{0,1\}^{\bar{n}'})\), and that the domain of \(\hat{\mu}_{\tau^{(1:s)}}\) is \(\{0,1\}^{\leq \bar{n}'}\). First, 22 ensures that we indeed have that \(\frac{1}{(1+\gamma)^2} \leq \frac{\mu_{\tau^{(1:s)}}(x)}{\hat{\mu}_{\tau^{(1:s)}}(x)} \leq (1+\gamma)^2\) for all \(x \in \{0,1\}^{\leq \bar{n}'}\) with probability \(1\). Further, the definitions of \(\mu_{\tau^{(1:s)}}\) and \(\hat{\mu}_{\tau^{(1:s)}}\) ensure that \(\mu_{\tau^{(1:s)}}(x) = \hat{\mu}_{\tau^{(1:s)}}(x)\) for all \(x \in \{0,1\}^{\bar{n}}\). Hence 1 is satisfied.

For any instantiation of \(\tau^{(1:s)}\), let the distribution of the output \(X = (X^{(1)}, \ldots, X^{(s)}) \in \{0,1\}^{\bar{n}}\) of \(\mathsf{Alg}\) be denoted \(\hat{\nu}_{\tau^{(1:s)}}\), and the distribution of the first bits of each block, namely \((X^{(1)}_1, \ldots, X^{(s)}_1) \in \{0,1\}^s\), be denoted \(\hat{\beta}_{\tau^{(1:s)}}\).

For \(\tau = (v^{\mathsf{init}}, \phi, \psi) \in \mathcal{H}_{n,k,q,\epsilon}\), let \(\alpha_\tau \in \Delta(\{0,1\})\) be the distribution which puts mass \(\frac{1+\gamma}{2+\gamma}\) on \(v^{\mathsf{init}}\) and mass \(\frac{1}{2+\gamma}\) on \(1-v^{\mathsf{init}}\); in other words, \(\alpha_\tau\) is the distribution of \(X_1\), for \(X = (X_1, \ldots, X_n) \sim \mu_\tau\). Let \(\alpha_{\tau^{(1:s)}} := \alpha_{\tau^{(1)}} \times \cdots \times \alpha_{\tau^{(s)}} \in \Delta(\{0,1\}^s)\). Next, we may write \[\begin{align} \mathsf{K}\geq & \mathbb{E}_{\tau^{(1:s)} \sim \mathcal{H}_{n,k,q,\epsilon}^s} \left[ D_{\mathsf{KL}}({\mu_{\tau^{(1:s)}}}||{\hat{\nu}_{\tau^{(1:s)}}}) \right] \geq \mathbb{E}_{\tau^{(1:s)} \sim \mathcal{H}_{n,k,q,\epsilon}^s} \left[ D_{\mathsf{KL}}({\alpha_{\tau^{(1:s)}}}||{\hat{\beta}_{\tau^{(1:s)}}}) \right] \label{eq:exp-tau-alphabeta}, \end{align}\tag{62}\] where the first inequality uses the assumption on \(\mathsf{Alg}\) and the second inequality uses the data processing inequality. Next, for any \(\tau^{(1:s)} \in \mathcal{H}_{n,k,q,\epsilon}^s\), the chain rule for KL divergence gives \[\begin{align} D_{\mathsf{KL}}({\alpha_{\tau^{(1:s)}}}||{\hat{\beta}_{\tau^{(1:s)}}}) =& \sum_{i=1}^s \mathbb{E}_{(X^{(1)}, \ldots, X^{(i-1)}) \sim \alpha_{\tau^{(1:i-1)}}}\left[D_{\mathsf{KL}}({\alpha_{\tau^{(i)}}}||{\hat{\beta}_{\tau^{(1:s)}}(X^{(i)} = \cdot \mid X^{(1)}, \ldots, X^{(i-1)})})\right]\label{eq:alphabeta-chain}. \end{align}\tag{63}\] Combining 62 63 as well as convexity of KL divergence gives that there exists some \(i \in [s]\) such that \[\begin{align} & \mathbb{E}_{\tau^{(1:s)} \sim \mathcal{H}_{n,k,q,\epsilon}^s}\left[ D_{\mathsf{KL}}({\alpha_{\tau^{(i)}}}||{\hat{\beta}_{\tau^{(1:s)}}(X^{(i)} = \cdot)})\right]\nonumber\\ \leq & \mathbb{E}_{\tau^{(1:s)} \sim \mathcal{H}_{n,k,q,\epsilon}^{s}}\mathbb{E}_{(X^{(1)}, \ldots, X^{(i-1)}) \sim \alpha_{\tau^{(1:i-1)}}}\left[D_{\mathsf{KL}}({\alpha_{\tau^{(i)}}}||{\hat{\beta}_{\tau^{(1:s)}}(X^{(i)} = \cdot \mid X^{(1)}, \ldots, X^{(i-1)})})\right] \leq \frac{\mathsf{K}}{s}.\label{eq:algi-output} \end{align}\tag{64}\] This contradicts 21, however: consider the algorithm \(\mathsf{Alg}'\) which functions as follows, given access to \(\hat{\mu}_{\tau^{(i)}}\), for \(\tau^{(i)} \sim \mathcal{H}_{n,k,q,\epsilon}\). It draws \(\tau^{(j)} \sim \mathcal{H}_{n,k,q,\epsilon}\) uniformly for each \(j \in [s]\) with \(j \neq i\), and then simulates \(\mathsf{Alg}\), using \(\hat{\mu}_{\tau^{(i)}}\) together with \(\hat{\mu}_{\tau^{(j)}}\) (where \(\tau^{(j)}\) are known for \(j \neq i\)) to simulate access to the oracle \(\hat{\mu}_{\tau^{(1:s)}}\). The output of \(\mathsf{Alg}'\) is the first bit of the \(i\)th block of the output of \(\mathsf{Alg}\). By 64 , \(\mathsf{Alg}'\) outputs a distribution whose KL divergence from \(\alpha_{\tau^{(i)}}\) is at most \(\frac{\mathsf{K}}{s}\); in particular, by Pinsker’s inequality, the probability that the output bit of \(\mathsf{Alg}'\) is equal to \((v^{\mathsf{init}})^{(i)}\) is at least \[\begin{align} \mathbb{P}_{X \sim \mu_{\tau^{(i)}}}(X_1 = (v^{\mathsf{init}})^{(i)}) - \sqrt{\frac{\mathsf{K}}{2s}} \geq \frac{1+\gamma}{2+\gamma} - \sqrt{\frac{\mathsf{K}}{2s}} - e^{-\epsilon r} \geq \frac{1+\gamma}{2+\gamma} - 2 \cdot \frac{\gamma}{20} \geq \frac{1}{2} + \frac{\gamma}{15}.\nonumber \end{align}\] Above, the first inequality uses 16. The second inequality uses that \(\sqrt{\mathsf{K}/(2s)} \leq \gamma/20\) (from the definition of \(s\)) and that \(e^{-\epsilon r} \leq \gamma/96\) (from the definition of \(\epsilon\) and \(r\) and the fact that \(2kr \geq 1\)).

This contradicts 21 as long as the number of queries \(q\) made by \(\mathsf{Alg}\) satisfies \(q \leq c'\gamma^2/ \epsilon^2\), for a sufficiently small constant \(c' > 0\) (note that \(q \leq c'\gamma^2/\epsilon^2\) also ensures that \(q \cdot 2^{-k} \leq q/\bar{n}^{10} \leq \bar{n}^{-5} \leq \gamma/100\) for sufficiently small \(\bar{n}\)). In turn, the condition \(q \leq c'\gamma^2/\epsilon^2\) is satisfied as long as \(q\leq c \cdot \frac{\bar{n}^2 \gamma^6}{\mathsf{K}^2 \log^2(\bar{n}) \cdot \log^2(1/\gamma)}\) for a sufficiently small constant \(c\). ◻

Acknowledgments↩︎

AM is supported in part by a Microsoft Trustworthy AI Grant, NSF award CCF-2430381, ONR grant N00014-22-1-2339, and a David and Lucile Packard Fellowship. DR is supported by NSF awards CCF-2430381 and DMS-2022448, and ONR grant N00014-22-1-2339.

AI Disclosure↩︎

GPT-5.4 and GPT-5.2 were used to assist in the writing of this paper. Their principal use was in suggesting “first drafts” for several of the proofs of the lemmas. The final writing of the paper, including the proofs, was done primarily by the authors with some fragments suggested by GPT. Correctness of all proofs was verified by the authors.

5 Relationship between counting-to-sampling reduction and LLM inference↩︎

Proposition 10. Fix \(\Sigma, n, \delta, R\). Suppose that \(\mathsf{Alg}\) is a randomized algorithm which has query access to some \(\hat{\mu} : \Sigma^{\leq n} \to \mathbb{R}_{\geq 0}\) satisfying 4 with respect to some \(\mu^\star \in \Delta(\Sigma^n)\) and the ratio \(R\). Suppose that:

  • \(\mathsf{Alg}\) makes at most \(q\) queries to \(\hat{\mu}\), after which it outputs some \(X \in \Sigma^n\) distributed according to some distribution \(\hat{\nu}\) with \(D_{\mathsf{TV}}({\hat{\nu}}, {\mu^\star}) \leq \delta\).

  • The distribution of the output of \(\mathsf{Alg}\) is unchanged if every answer returned by the oracle \(\hat{\mu}\) is multiplied by the same positive constant.

Then there is a randomized algorithm \(\mathsf{Alg}'\), which is given query access to \(\pi_{\mathsf{ref}}\in \Delta(\Sigma^n)\) and \(\hat{V} : \Sigma^{\leq n} \to \mathbb{R}\) as in 1.1, satisfying \(\| \hat{V} - V^\star\|_\infty \leq \log R\) and \(V^\star(x) = \hat{V}(x)\) for \(x \in \Sigma^n\). The algorithm \(\mathsf{Alg}'\) makes at most \(q\) queries to \(\pi_{\mathsf{ref}}, \hat{V}\) and outputs some \(X \in \Sigma^n\) distributed according to some distribution \(\hat{\nu}\) with \(D_{\mathsf{TV}}({\hat{\nu}}, {\mu^\star}) \leq \delta\).

Proof. The algorithm \(\mathsf{Alg}'\) simply simulates \(\mathsf{Alg}\), answering queries to \(\hat{\mu}(x_{1:i})\) by returning \(\hat{\mu}(x_{1:i}) = \pi_{\mathsf{ref}}(x_{1:i}) \cdot \exp(\hat{V}(x_{1:i}))\). By scale-invariance of \(\mathsf{Alg}\), the distribution of the output of \(\mathsf{Alg}'\) is the same as if it had instead answered queries by returning \(\frac{1}{Z} \cdot \hat{\mu}(x_{1:i})\), which is an \(R\)-multiplicative approximation of \(\mu^\star\) by the assumption that \(\| \hat{V} - V^\star\|_\infty \leq \log R\). (Further, we have \(\frac{1}{Z} \hat{\mu}(x) = \mu^\star(x)\) for \(x \in \Sigma^n\).) Thus, the output distribution of \(\mathsf{Alg}'\) is \(\delta\)-close to \(\mu^\star\), as desired. ◻

6 Concentration inequalities↩︎

Lemma 23 (Freedman’s inequality). Suppose that \((X_i)_{i \in [n]}\) is a sequence of random variables adapted to a filtration \((\mathscr{F}_i)_{i \in [n]}\). Then for any \(\delta \in (0,1)\), with probability at least \(1-\delta\), \[\begin{align} \sum_{i=1}^n X_i \leq \sum_{i=1}^n \log \mathbb{E}[\exp( X_i)\mid \mathscr{F}_{i-1}] + \log(1/\delta)\nonumber. \end{align}\]

References↩︎

[1]
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv preprint arXiv:2006.11239, 2020.
[2]
Yang Song, Jascha Sohl-Dickstein, Diederik Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020.
[3]
Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. arXiv preprint arXiv:1503.03585, 2015.
[4]
Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
[5]
OpenAI. Gpt-4 technical report. arXiv preprint arXiv:2303.08774, 2023.
[6]
Gemini Team. Gemini: A family of highly capable multimodal models. arXiv preprint arXiv:2312.11805, 2023.
[7]
Mert Yuksekgönül, Daniel Koceja, Xinhao Li, Federico Bianchi, Jed McCaleb, Xiaolong Wang, Jan Kautz, Yejin Choi, James Zou, Yu Sun, and Carlos Guestrin. Learning to discover at test time. arXiv preprint arXiv:2601.16175, 2026.
[8]
Yuxin Zuo, Kaiyan Zhang, Li Sheng, Shang Qu, Ganqu Cui, Xuekai Zhu, Haozhan Li, Yuchen Zhang, Xinwei Long, Ermo Hua, Biqing Qi, Youbang Sun, Zhiyuan Ma, Lifan Yuan, Ning Ding, and Bowen Zhou. Ttrl: Test-time reinforcement learning. arXiv preprint arXiv:2504.16084, 2025.
[9]
Chengyi Yang, Zhishang Xiang, Yunbo Tang, Zongpei Teng, Chengsong Huang, Fei Long, Yuhan Liu, and Jinsong Su. Ttcs: Test-time curriculum synthesis for self-evolving. arXiv preprint arXiv:2601.22628, 2026.
[10]
Kaiwen Wang, Jin Peng Zhou, Jonathan Chang, Zhaolin Gao, Nathan Kallus, Kianté Brantley, and Wen Sun. Value-guided search for efficient chain-of-thought reasoning. arXiv preprint arXiv:2505.17373, 2025.
[11]
Isha Puri, Shivchander Sudalairaj, Guangxuan Xu, Kai Xu, and Akash Srivastava. A probabilistic inference approach to inference-time scaling of llms using particle-based monte carlo methods. arXiv preprint arXiv:2502.01618, 2025.
[12]
Dhruv Rohatgi, Abhishek Shetty, Donya Saless, Yuchen Li, Ankur Moitra, Andrej Risteski, and Dylan J Foster. Taming imperfect process verifiers: A sampling perspective on backtracking. arXiv preprint arXiv:2510.03149, 2025.
[13]
Hunter Lightman, Vineet Kosaraju, Yura Burda, Harri Edwards, Bowen Baker, Teddy Lee, Jan Leike, John Schulman, Ilya Sutskever, and Karl Cobbe. Let’s verify step by step. arXiv preprint arXiv:2305.20050, 2023.
[14]
Zhenru Zhang, Chujie Zheng, Yangzhen Wu, Beichen Zhang, Runji Lin, Bowen Yu, Dayiheng Liu, Jingren Zhou, and Junyang Lin. The lessons of developing process reward models in mathematical reasoning. arXiv preprint arXiv:2501.07301, 2025.
[15]
Noah Golowich, Fan Chen, Dhruv Rohatgi, Raghav Singhal, Carles Domingo-Enrich, Dylan J. Foster, and Akshay Krishnamurthy. Reject, resample, repeat: Understanding parallel reasoning in language model inference. arXiv preprint arXiv:2603.07887, 2026.
[16]
Moritz Hardt and Yu Sun. Test-time training on nearest neighbors for large language models. In The Twelfth International Conference on Learning Representations, 2024.
[17]
Yu Sun, Xinhao Li, Karan Dalal, Chloe Hsu, Sanmi Koyejo, Carlos Guestrin, Xiaolong Wang, Tatsunori Hashimoto, and Xinlei Chen. Learning to (learn at test time). arXiv preprint arXiv:2310.13807, 2023.
[18]
Yu Sun, Xiaolong Wang, Zhuang Liu, John Miller, Alexei A. Efros, and Moritz Hardt. Test-time training with self-supervision for generalization under distribution shifts. arXiv preprint arXiv:1909.13231, 2019.
[19]
Jinwu Hu, Zhitian Zhang, Guohao Chen, Xutao Wen, Chao Shuai, Wei Luo, Bin Xiao, Yuanqing Li, and Mingkui Tan. Test-time learning for large language models. arXiv preprint arXiv:2505.20633, 2025.
[20]
Trieu H. Trinh, Yuhuai Wu, Quoc V. Le, He He, et al. Olympiad-level formal mathematical reasoning with reinforcement learning. Nature, 627:1–7, 2025.
[21]
Jonathan Geuter, Youssef Mroueh, and David Alvarez-Melis. Guided speculative inference for efficient test-time alignment of LLMs. arXiv preprint arXiv:2506.04118, 2025.
[22]
Dylan J. Foster, Zakaria Mhammedi, and Dhruv Rohatgi. Is a good foundation necessary for efficient reinforcement learning? the computational role of the base model in exploration. arXiv preprint arXiv:2503.07453, 2025.
[23]
Wei Xiong, Hanze Dong, Chenlu Ye, Ziqi Wang, Han Zhong, Heng Ji, Nan Jiang, and Tong Zhang. Iterative preference learning from human feedback: Bridging theory and practice for RLHF under KL-constraint. arXiv preprint arXiv:2312.11456, 2024.
[24]
Raghav Singhal, Zachary Horvitz, Ryan Teehan, Mengye Ren, Zhou Yu, Kathleen McKeown, and Rajesh Ranganath. A general framework for inference-time scaling and steering of diffusion models. arXiv preprint arXiv:2501.06848, 2025.
[25]
Kevin Yang and Dan Klein. Fudge: Controlled text generation with future discriminators. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 3511–3535, 2021.
[26]
Youheng Zhu and Yiping Lu. On the power of (approximate) reward models for inference-time scaling. arXiv preprint arXiv:2602.01381, 2026.
[27]
Mark Jerrum, Leslie Valiant, and Umesh Vazirani. Random generation of combinatorial structures from a uniform distribution. Theoretical Computer Science, 1986.
[28]
Mark Jerrum and Alistair Sinclair. Approximate counting, uniform generation and rapidly mixing markov chains. Information and Computation, 82(1):93–133, 1989.
[29]
Mark Jerrum, Alistair Sinclair, and Eric Vigoda. A polynomial-time approximation algorithm for the permanent of a matrix with nonnegative entries. 2004.
[30]
Mark Jerrum. A very simple algorithm for estimating the number of k-colorings of a low-degree graph. 1995.
[31]
Eric Vigoda. Improved bounds for sampling colorings. 1999.
[32]
Mark Jerrum and Alistair Sinclair. Polynomial-time approximation algorithms for the ising model. 1993.
[33]
Zongchen Chen, Kuikui Liu, and Eric Vigoda. Spectral independence via stability and applications to holant-type problems. arXiv preprint arXiv:2106.03366, 2021.
[34]
Mark Jerrum and Alistair Sinclair. Approximating the permanent. Information and Computation, 1989.
[35]
Nima Anari, Kuikui Liu, Shayan Oveis Gharan, Cynthia Vinzant, and Thuy Duong Vuong. Log-concave polynomials iv: Exchange properties, tight mixing times, and faster sampling of spanning trees. arXiv preprint arXiv:2004.07220, 2020.
[36]
Thomas P. Hayes and Alistair Sinclair. Liftings of tree-structured markov chains. In Proceedings of the 13th International Conference on Approximation, and 14 the International Conference on Randomization, and Combinatorial Optimization: Algorithms and Techniques, APPROX/RANDOM’10, page 602–616, Berlin, Heidelberg, 2010. Springer-Verlag.
[37]
Nikolaus Schweizer. Non-asymptotic error bounds for sequential mcmc methods in multimodal settings. arXiv preprint arXiv:1205.6733, 2012.
[38]
Alexander Rakhlin and Karthik Sridharan. Statistical learning and sequential prediction, 2014. Lecture notes.
[39]
Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge University Press, 2014.
[40]
Dylan J. Foster and Alexander Rakhlin. Foundations of reinforcement learning and interactive decision making, 2023.
[41]
Salil Vadhan. Pseudorandomness. Foundations and Trends in Theoretical Computer Science, 2011.

  1. We remark that several of the initial works on TTT for LLMs (e.g., [16], [19]) do not make use of any external rewards (modeled here by \(\hat{V}\)) to update \(\pi_{\mathsf{ref}}\), and instead only rely on the prompt, and potentially partial generations under \(\pi_{\mathsf{ref}}\). However, the larger-scale developments, such as those achieving IMO-level performance for the first time [20] or advancing the state-of-the-art for open mathematics questions [7], do make use of external reward signals (typically by using reinforcement learning algorithms at test time [8]).↩︎

  2. While we focus on the setting of language models, similar logic applies to other settings, such as diffusion models (see [24]).↩︎

  3. In fact, we assume that \(\pi_{\mathsf{ref}}(x)\) can be determined using a single query; this is the case for typical autoregressive language models, which give the log-probabilities of all tokens in a sequence using a single forward pass.↩︎

  4. It is also assumed that \(\hat{V}\) and \(V^\star\) are equal on length-\(n\) sequences, which is without loss since query access to \(V^\star\) on full-length sequences is allowed.↩︎

  5. [12], [15] also study relaxations of this assumption where the error bound holds in a certain average-case sense, rather than uniformly over all sequences.↩︎

  6. To be more precise, our algorithms work in the setting where we are given a class \(\mathcal{V}\) of mappings \(V : \Sigma^n \to \mathbb{R}\) and an oracle \(\hat{V} : \Sigma^n \to \mathbb{R}\) so that \(|V(x_{1:i}) - \hat{V}(x_{1:i})| \leq \log R\) for all \(x_{1:i}\).↩︎

  7. Furthermore, in our lower bounds, the constant \(Z\) is known.↩︎

  8. Technically, this equivalence holds only for self-reducible problems, though a great number of concrete problems of interest satisfy this property.↩︎

  9. In general, the interpretation of \(\hat{\mu}\) as an approximate counting oracle for the “class of problems” captured by \(\mu^\star\) makes sense as long as the problem in question is self-reducible, which in turn is a ubiquitous assumption across a wide range of algorithmic problems.↩︎

  10. To be clear, when we say that \(\mathcal{F}\) is known, we mean that for any \(\mu \in \mathcal{F}\) and \(x_{1:i} \in \Sigma^i\), the algorithm can determine the value of \(\mu(x_{1:i})\) without paying for any queries to \(\hat{\mu}(\cdot)\).↩︎

  11. Recall that 1 gives that \(\hat{\mu}\) and \(\mu^\star\) are equal on length-\(n\) sequences.↩︎

  12. Technically, we need an additional \(\tilde{O}(Rn)\) queries to perform rejection sampling at the end, though after rescaling \(\epsilon\) down by a factor of \(R^2\) this term is dominated by the one we have written above.↩︎

  13. Note that \(\frac{0}{0}\) in the context of 9 is to be interpreted as \(1\).↩︎