Random Local Access for Sampling -SAT Solutions
Abstract
We present a sublinear time algorithm that gives random local access to the uniform distribution over satisfying assignments to an arbitrary -SAT formula , at exponential clause density. Our algorithm provides memory-less query access to variable assignments, such that the output variable assignments consistently emulate a single global satisfying assignment whose law is close to the uniform distribution over satisfying assignments to . Random local access and related models have been studied for a wide variety of natural Gibbs distributions and random graphical processes. Here, we establish feasibility of random local access models for one of the most canonical such sample spaces, the set of satisfying assignments to a -SAT formula.
Our algorithm proceeds by leveraging the local uniformity of the uniform distribution over satisfying assignments to . We randomly partition the variables into two subsets, so that each clause has sufficiently many variables from each set to preserve local uniformity. We then sample some variables by simulating a systematic scan Glauber dynamics backward in time, greedily constructing the necessary intermediate steps. We sample the other variables by first conducting a search for a polylogarithmic-sized local component, which we iteratively grow to identify a small subformula from which we can efficiently sample using the appropriate marginal distribution. This two-pronged approach enables us to sample individual variable assignments without constructing a full solution.
Keywords and phrases:
sublinear time algorithms, random generation, -SAT, local computationCopyright and License:
2012 ACM Subject Classification:
Theory of computation Streaming, sublinear and near linear time algorithmsAcknowledgements:
We would like to thank Kuikui Liu and Ronitt Rubinfeld for helpful discussions, suggestions, and feedback on a draft. We would like to thank the anonymous referees for identifying an issue with a previous version of this article.Funding:
NM was supported by the Hertz Graduate Fellowship and the NSF Graduate Research Fellowship Program #2141064. This material includes work supported by the NSF Grant DMS-1928930, while the authors were in residence at SLMath during the Spring 2025 semester.Event:
28th International Conference on Theory and Applications of Satisfiability Testing (SAT 2025)Editors:
Jeremias Berg and Jakob NordströmSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Efficiently sampling from an exponentially sized solution space is a fundamental problem in computation. The quintessential such problem is sampling a uniformly random satisfying assignment to a given -SAT formula, the setting of this work. Throughout, we let denote an -variable -formula, which is a -SAT formula in conjunctive normal form (which we also call a -CNF) such that each variable appears in at most clauses. We let denote the set of satisfying assignments to , and let denote the uniform distribution over . We consider the regime where is a (large) constant and take .
For , it has long been known (e.g., by the Lovász local lemma introduced in [8]) that any such -SAT formula has at least one satisfying assignment. Moreover, seminal work of Moser and Tardos [27] gave a simple algorithm that computes such a satisfying assignment in expected linear time. However, a similarly basic question in the sampling regime is far more poorly understood: when is it possible to efficiently sample an (approximately uniformly) random satisfying assignment to ?
The first breakthrough in this direction came from Moitra [25] who gave a deterministic, fixed-parameter tractable algorithm for approximately sampling from provided that for . This was followed up by work of Feng, Guo, Yin and Zhang [10], who used a Markov chain approach to give a polynomial time algorithm for sampling from provided that . Recent works [18, 31] have given state of the art results for sampling from -CNFs, when (in fact for large domain sizes, [31] gives essentially tight bounds on sampling from atomic constraint satisfaction problems). There has also been a tremendous amount of work sampling from random -CNFs, recently essentially resolved by work of [6], building on previous progress of [13, 7, 12, 19].
A natural question about such algorithms to sample from -CNFs is whether one can adapt them to more efficiently answer local questions about a random satisfying assignment in sublinear time. For variable , let denote the marginal distribution on induced by . When is large, one might wish to sample a small handful of variables from their marginal distributions in time, without computing an entire -sized satisfying assignment . Further, many traditional algorithms for counting the number of satisfying assignments to a given -SAT formula proceed by computing marginal probabilities of variable assignments, a task that can be completed given local access to a random assignment. Therefore, sublinear time algorithms for answering local questions can also yield speedups in more general counting algorithms.
Ideally, a random local access model should provide query access to variable assignments such that the output enjoys the following properties:
-
(a)
the model is consistent: queries for different variable assignments consistently emulate those of a single random satisfying assignment ;
-
(b)
the model is sublinear: sampling variable assignments takes time in expectation;
-
(c)
the model is memory-less: given the same initialization of randomness, answers to multiple, possibly independent queries for variable assignments are consistent with each other.
We give a more precise definition of random local access models in Section 2. Random local access models were formally introduced in work of Biswas, Rubinfeld, and Yodpinyanee [5], motivated by a long line of work over the past decades studying sublinear time algorithms for problems in theoretical computer science. The authors of [5] studied a different natural Gibbs distribution, the uniform distribution over proper -colorings of a given -vertex graph with maximum degree . By adapting previously studied classical and parallel sampling algorithms for -colorings, they were able to construct a local access algorithm to a random proper -coloring when The related problem of sampling partial information about huge random objects was pioneered much earlier in [15, 16]; further work in [28] considers the implementation of different random graph models. Random local access and related (e.g., parallel computation) models have also been recently studied for several other random graphical processes and Gibbs distributions (cf. [5, 4, 26, 23]).
The above model for local access to random samples extends a rich line of work studying local computation algorithms (LCAs), originally introduced in works of Rubinfield, Tamir, Vardi, and Xie [29] and Alon, Rubinfield, Vardi, and Xie [2]. Local computation algorithms are widely used in parallel and distributed computing, with notable practical success in areas such as graph sparsification [1], load balancing [24], and sublinear-time coloring [2]. A primary initial application of LCAs in [29] was locally constructing a satisfying assignment to a given -formula when . Similar to the desired properties of random local access, LCA implements query access to a large solution space in sublinear time using local probes. However, rather than sampling from a given distribution, LCA only provides local access to some consistent valid solution in the desired solution space that may otherwise be completely arbitrary in nature.
In this work, we present a polylogarithmic time algorithm that gives random local access to the uniform distribution over satisfying assignments of an arbitrary -SAT formula at exponential clause density (i.e., the number of occurrences of each variable is bounded by an exponential function of ). The following is an informal version of our main result; a more formal version can be found at Theorem 24.
Theorem 1 (Main theorem: informal).
There exists a random local access algorithm that satisfies the following conditions. For any -formula with maximum degree and any variable , we can use to sample a single assignment for , in expected polylogarithmic time (in ), such that the distribution of is the same as the marginal distribution of , where is a uniformly random satisfying assignment to .
Similar to [5], the proof of Theorem 1 adapts some of the algorithmic tools used to study parallel and distributed sampling. The proof also builds upon the work of Moitra [25] and Feng–Guo–Yin–Zhang [10] on sampling from bounded degree -CNFs in polynomial time. The authors of [25, 10] both critically took advantage of a global variable marking (see Definition 10) to better condition the marginal distributions of variables. Such an approach allows for a subset of the variable assignments to be sampled with ease; the resulting shattering of the solution space conditioned on such a partial assignment then allows one to efficiently complete the random satisfying assignment. These initial approaches have been extended and strengthened to nearly linear time algorithms that succeed for larger maximum variable degree in a flurry of recent work (c.f. [25, 10, 20, 17, 13, 7, 12, 31, 6]).
Recently, Feng, Guo, Wang, Wang, and Yin [9] used a recursive sampling scheme to simulate the systematic scan projected Glauber dynamics via a strategy termed coupling towards the past, which they used to derandomise several Markov chain Monte Carlo (MCMC) algorithms for sampling from CSPs. Additionally, recent work of He, Wang and Yin [18] used a recursive sampling scheme to sample -SAT solutions. Their work immediately gives a sublinear (in fact, expected constant time) algorithm for sampling the assignment of a single variable one time; however, this work does not immediately extend out of the box to a random local access model that enjoys the desired consistency and memory-less properties if multiple variables are sampled. Recursive sampling schemes have also been recently used to make progress on analyzing and designing fast sampling algorithms for a variety of Gibbs distributions (cf. [18, 7, 3]). As noted earlier, such schemes have been particularly useful for derandomising and constructing parallel and distributed versions of many popular MCMC algorithms for sampling solutions to CSPs [9, 11, 17, 18].
An immediate roadblock to adapting such global or parallel sampling strategies to random local access to -SAT solutions is that the vast majority of the aforementioned existing algorithms critically either use some global information – like a variable marking, particular ordering of variables, or other global state compression – as an input to make algorithmic decisions or postpone sampling of certain problematic variable assignments until a linear number of other choices are made. Both these issues necessitate a substantive departure from these approaches for any hope of local access adaptation. In this work, we overcome these obstacles by adapting the coupling towards the past strategy used in [9] to derandomise MCMC in conjunction with a local implementation of the variable marking strategy introduced in [25].
We use these algorithms to carefully select and sample a small number of auxiliary variable assignments on an as-needed basis, showing that bad cases can be reduced to small calculations after a sublinear number of steps. Our proof of Theorem 1 requires a novel adaptation of sampling techniques to avoid requiring global information or complete passes of the variable set; we show that we can perform analogous operations locally or leverage local uniformity properties to circumvent them altogether in the course of locally sampling a variable assignment. Importantly, we demonstrate how to execute local sampling in an oblivious, consistent fashion, so that the algorithm need not retain any memory and that variables need not be sampled in any particular order.
2 Preliminaries
Notation
Throughout, let be a -CNF on variable set with associated collection of clauses . In this work we do not let the same variable appear multiple times in any clause of , although our algorithm could be adapted to the more general scenario. We further assume that is a -formula; that is, each variable appears in at most clauses. For every clause , let denote the collection of variables in the clause . We further define , so in particular .
In the regime we work in, we assume is a large fixed constant and view We use to denote that there is some constant (not depending on ) such that . We also use the standard asymptotic notation (, , , , ), where when not specified, we assume these are in the limit. We use to denote the underlying distribution of a random variable .
We let denote the set of satisfying assignments to and let denote the uniform distribution over . We suppress the subscripts when the formula is clear from context. We introduce a few more concepts associated to a -SAT instance that will be used later.
Definition 2.
Given probability distributions over , the total variation distance is
If we have a random variable with , we may write instead of in a slight abuse of notation.
Definition 3 (Dependency hypergraph).
Given a -formula , let be the dependency hypergraph (with multiple edges allowed), where is the set of variables and is the collection of variable sets of clauses of .
Definition 4 (Partial assignment).
Given -formula , let
denote the space of partial assignments with the following symbology. Given a partial assignment on some , each variable is classified as follows:
-
means that is accessed by the algorithm and assigned with ;
-
means that is accessed by the algorithm but unassigned yet with any value.
We sometimes use to denote the empty assignment (i.e., is the empty set). We say that is feasible if it can be extended to a satisfying assignment to .
Definition 5 (Reduced formula on partial assignment).
Let be a -formula. Given a partial assignment on , let be the result of simplifying under . That is, define where
-
,
-
is obtained from by removing all clauses that have been satisfied under , and removing any appearance of variables that are assigned 0 or 1 by .
Let be the associated (not necessarily -uniform) hypergraph to . For variable , let denote the maximal connected component of to which belongs.
Definition 6 (Marginal distribution).
For an arbitrary set of variables , let be the marginal distribution on induced by , so that
When is a single vertex, we let . Furthermore, given some partial assignment for , if , we let be the marginal distribution on conditioned on the partial assignment . When , we simply use to denote .
2.1 The random local access model and local computation algorithms
One of the most widely studied models of local computation are local computation algorithms (LCAs) introduced in [2, 29]. Given a computation problem , an LCA (in an online fashion) provides the -th bit to some consistent solution in sublinear time. As originally defined, local computation algorithms need not be query-oblivious; in other words, the output solution can depend on the order of queried bits. However, several follow-up works have given query-oblivious analogues of LCAs for a variety of natural problems. Such models are the non-random-sampling version of the random local access models we study here.
In this work, we construct a query-oblivious LCA for an intermediate step in our construction of the random local access model (described in more detail in Section 2.2). We thus precisely define both LCAs and random local access models below.
Definition 7 (Local computation algorithm).
Given an object family with input and sample space (for some alphabet ), a -local computation algorithm (LCA) provides an oracle that implements query access to some arbitrary that satisfies the following conditions:
-
has query access to the input description and to a tape of public random bits .
-
gets a sequence of queries for any , and after each query , it produces an output such that the outputs are consistent with some .
-
The probability of success over all queries is at least (where ).
-
The expected running time of on any query is at most , which is sublinear in .
We further say that is query-oblivious if the outputs of do not depend on the order of the queries but depend only on and .
Motivated by the above, we give a formal definition of the random local access model introduced in [5].
Definition 8 (Random local access).
Given a random object family with input , sample space (with alphabet ) and distribution supported on , a -random local access implementation of a family of query functions provides an oracle with the following properties:
-
has query access to the input description and to a tape of public random bits
-
For a given input , upon being queried with , the oracle with probability uses at most resources (where is sublinear in ) to return the value for some specific .
-
The choice of only depends on and .
-
The distribution of over the randomness satisfies
where for constant .
In other words, if is a random local access oracle for a set of queries, then when provided the same input and the same random bits , it must provide outputs that are consistent with a single choice of regardless of the order and content of these queries.
2.2 Marking and a query-oblivious LCA
As noted in the introduction, the Lovász local lemma [30] guarantees the existence of a satisfying assignment to any -formula if Furthermore, the Moser-Tardos algorithm [27] gives a simple linear-time algorithm to construct such a satisfying assignment in the above -regime:
-
Sample uniformly at random;
-
While there exists a clause that is violated by the current assignment, resample variables in uniformly at random.
The Lovász local lemma can be made quantitative, showing that not only is there some satisfying assignment to if , but both that there are exponentially many such satisfying assignments and that the marginal distributions are approximately uniform with (see [25, 10]). Such local uniformity is critical to the success of algorithms that approximately sample from . In his breakthrough work, Moitra [25] noted that this local uniformity continues to hold for conditional distributions provided that each clause has a sufficiently large number of free variables under partial assignment . This motivates the idea of a marking, as introduced in [25], which is a careful selection (via the Lovász local lemma) of a linear sized subset of variables that has the following properties:
-
For every clause , . Having a large number of marked variables in each clause would hopefully result in a desired shattering condition; namely, we can sample a partial assignment on this marking that partitions the original formula into sufficiently small connected components.
-
For every clause , . This large non-intersection preserves the local uniformity of the marginal distributions of the as yet-unsampled variables in .
The general strategy of arguments following the marking approach is to show that it is “easy” to sample a partial assignment , and moreover, conditioned on any such assignment, the reduced formula is very likely to shatter into sufficiently small connected components such that the remaining variable assignments can be efficiently sampled from the conditional distribution by solving a smaller instance of the original problem. We now make this notion precise.
Definition 10 (-marking).
Given -formula and constant , we say that is an -marking if for every , and .
In this work, we locally, greedily construct an -marking using a local implementation of Moser-Tardos. We will further argue that because of the shattering property, we can locally compute the connected component of for some and a given vertex , without having to actually assign linearly many vertices.
Precisely, we construct a query-oblivious LCA, , where for a -formula and a given range of , can take in any variable and output either 0 or 1 indicating whether is in some -marking of . Moreover, takes sublinear time and when queried on all of , gives a consistent -marking of .
Theorem 11.
Let be a -formula. Suppose there exist constants that satisfy the following conditions:
| (1) | ||||
(Here is the binary entropy.)
Fix constant . Then there exists a time local computation algorithm which, given any variable , returns an assignment denoting whether is contained in an -marking of . Moreover, with probability at least , the responses for all yield a consistent -marking of .
The construction of and the verification that it is a query-oblivious LCA draws inspiration from the approach in [2] to obtain an oblivious LCA for hypergraph -coloring. From a high level, determines by randomly and greedily including variables in the marking and subsequently determining those that must/must not be in the marking, and finally (if needed) performing a rejection sampling on a smaller connected component that contains . The formulae in Theorem 11 are some technical conditions that guarantee this process to go through. We refer the readers to Appendix E of the full version (arxiv:2409.03951) for a proof of Theorem 11.
3 A random local access algorithm for -SAT solutions
In this section, we introduce the main algorithm (Algorithm 1) that locally accesses the assignment of a variable in a uniformly random satisfying assignment to .
Recall from Theorem 1 that given a -formula , variable , and any constant , we wish to come up with a random local access algorithm such that (1) the expected running time of is , and (2) the output of for every satisfies . As a high level description, given the above inputs, Algorithm 1 performs the following:
-
1.
Locally decides whether lies in an -marking of using (Theorem 11), such that the responses for all yield a consistent -marking .
-
2.
Suppose is a uniformly random satisfying assignment to . If is marked, then we sample by computing (adapted from [9, Algorithm 8]), which may make further recursive calls to sample other marked variables.
-
3.
If is not marked, then we perform a depth-first search starting from to compute restricted to . We start from ; for every we encounter that we have not yet sampled, we compute and update , to eventually obtain a (w.h.p. polylogarithmic in size) connected component that contains . This part is carried out by the algorithm .
After obtaining the connected component , we call (Theorem 13) to sample a uniformly random satisfying assignment to and extend . We then output .
Input: -CNF formula and variable
Output: random assignment
To illustrate the workflow of Algorithm 1, we present a toy example on a small -CNF formula, omitting some subroutine details for brevity.
Example 12.
Suppose , and . Consider the following -formula with variables and clauses , where
Suppose we wish to approximately sample using the local access algorithm . We run on each variable; suppose the resulting marking is , so that is not marked.
Since , we call to explore the connected component of containing . We initialize and partial assignment .
-
Process clause . Since , we call , which returns (say) . The clause becomes , which is unsatisfied with the current . We add adjacent clause (via and ) to .
-
Process clause . Since , we call , which returns (say) . The clause becomes , which is satisfied.
-
Process clause . We already have , so , and the clause is satisfied. Remove from .
Now the discovered component includes (1) clauses , (2) marked variable assignments , , (3) free variables: . We now run on the reduced subformula . The satisfying assignments are . We pick one uniformly at random, say . Then we return .
Algorithm 1 is our main routine; it has several subroutines , , , and that we now describe. Recall that has been discussed in Theorem 11. We now introduce the algorithm given by the work of He–Wang–Yin [18].
Theorem 13 ([18, Theorems 5.1 and 6.1]).
Suppose is a -CNF formula on variables with . Then there exists an algorithm that terminates in time in expectation, and outputs a uniformly random satisfying assignment to .
As seen in Theorem 13, for an -variable -CNF formula, the algorithm has running time . However, as we will only apply to connected components of size (that are shattered by the partial assignment on the marked variables), the execution of in Line 6 of Algorithm 1 will only take polylogarithmic time.
We will define subroutines and below and show that they satisfy the desired correctness and efficiency properties, beginning by verifying has the desired properties in Section 4.
Theorem 14.
Let be a -formula, , and be an -marking as in Definition 10. Fix positive constant . Suppose , , and . Then there exists a random local access algorithm such that for every , returns a random value in that satisfies the following:
-
1.
Let and be the joint distribution of the outputs . Then we have .
-
2.
For every , the expected cost of is .
We also require to be correct and have low expected cost.
Theorem 15.
Let be a -formula, , and be an -marking as in Definition 10. Suppose and . Then there exists a random local access algorithm such that for every , returns the connected component in that contains , where is the partial assignment given by . Moreover, for every , the expected cost of is .
From a high level, the algorithm explores the clauses and marked variables in the CNF formula that are reachable from , greedily sampling the marked variables and expanding through unsatisfied clauses. It iteratively builds a partial assignment that “shatters” the formula into disconnected components, isolating the one containing . We will verify Theorem 15 in Appendix D of the full version (arxiv:2409.03951).
4 Proof of Theorem 14
In this section we show Theorem 14. Throughout, let be a -formula, , and be an -marking with . We introduce a local access algorithm that satisfies the key property that the joint distribution of outputs consistently follows the marginal distribution . In particular, will simulate the output of a systematic scan Glauber dynamics on the marked variables.
Definition 16.
Let denote the marked variables (so ).
-
For every time , define .
-
For every time and , define
In the systematic scan Glauber dynamics, we always resample vertex at time (as opposed to randomly choosing a variable to resample at each step). For every and time , denotes the most recent time up to time at which got resampled. Observe that for all and , we have . Moreover, for all , we have .
Input: a -CNF formula , a set of marked variables , time , and an ordering
Output: a random assignment
We refer the readers to Appendix A of the full version (arxiv:2409.03951) for more introduction on the systematic scan Glauber dynamics and its comparison with the (original) projected Glauber dynamics Markov chain for sampling - solutions.
We have the following non-quantitative convergence for systematic scan Glauber dynamics.
Theorem 17 ([22]).
Let denote the Glauber dynamics or the systematic scan Glauber dynamics with stationary distribution . If is irreducible over , then for every , we have .
Let be a fixed set of marked variables for a given -CNF . Let be the marginal distribution of on . We will crucially use the following local uniformity of Algorithm 2 (the proof in the systematic scan setting follows essentially identically to [10, Lemma 5.3]):
Lemma 18.
Suppose is a -CNF with Let be either or for some (so correspondingly, is either or for some ). Then for any and , we have
Specifically, for any and , we have .
Definition 19.
Let be a distribution on . We say that is -marginally lower bounded if for all , and feasible partial assignment , we have
Let be a -marginally lower bounded distribution over . For every , we define the following distributions:
-
1.
Lower bound distribution over : we define , with
-
2.
Padding distribution over : for and feasible partial assignment , we define
Per Lemma 18, we have that is -lower bounded for
| (2) |
4.1 Systematic scan Glauber dynamics on marked variables
We adapt the approach of [9] to a local sampling algorithm by simulating the systematic scan projected Glauber dynamics on from time to , which is an aperiodic and irreducible Markov chain by results in [10, 9].
Let be the output of Algorithm 2, where we relabel by . We know from Theorem 17 that, as , we have where is the marginal distribution of on the marked variables. In particular, for every fixed and , there exists such that for all , the Markov chain satisfies .
We know from Lemma 18 that is -lower bounded, with the lower bound distribution defined by and . Thus, for every and , sampling can be decomposed into the following process:
-
1.
With probability , set to 0 or 1 uniformly at random;
-
2.
With probability , sample from the padding distribution .
Our goal is to obtain for , which by Theorem 17 will closely follow the marginal distribution for sufficiently large. It suffices to simulate the last update for . The key observation here is that updates of Glauber dynamics may depend only on a very small amount of extra information. When is close to , it is reasonably likely that we can determine without any other information. Thus, we can deduce by recursively revealing only the necessary randomness backwards in time. This method was termed coupling towards the past and studied for a variety of constraint satisfaction problems in [9].
We now give a general algorithm in Algorithm 5, whose output simulates the effects of Algorithm 2 at any particular time , by looking backwards in time at what happened over the course of running . The eventual algorithm we give in Theorem 14 will retrieve the most recent update of each variable , i.e., retrieve the coordinate .
Input: a -CNF formula , a set of marked variables , and a marked variable
Output: a random value in
The algorithm contains another subroutine that is defined in Algorithm 4. For every time , the output of follows the distribution (see Definition 19). In other words, preliminarily decides which of the above two regimes we fell into while resampling at time .
Throughout Algorithm 5, we maintain two global data structures.
-
We let record the previously revealed outcomes of Algorithm 5. That is, for every such that has already been executed, we set to be the outcome of .
-
We let record the previously revealed outcomes of Algorithm 4. That is, for every such that has already been executed and returned , we add to .
Since remain constant throughout Algorithms 5 and 4, and all recursive calls access and update the same and , we sometimes write and for short.
At the beginning of , we first check a few early stopping conditions:
-
(Lines 1–2) If variable remains its initial assignment at the end of time (i.e., is never resampled), we terminate and return .
-
(Lines 3–4) If , the number of stored outcomes of LB-Sample, already reaches , we terminate and return 1.
-
(Lines 5–6) If previous iterations have already computed and stored , we terminate and return .
If none of the above conditions occurs, we then resample, first by applying (Algorithm 4) in Lines 7–8. If (which occurs with probability ), we can update by choosing an assignment from uniformly at random without investigating the assignments of any other variables at earlier time steps (i.e., we fall into the zone of local uniformity).
If (which occurs with probability ), then we fall into a zone of indecision and must resample from the padding distribution . To resample its spin, we slowly proceed backwards in time, lazily computing previously resampled assignments, until we have determined enough information to compute the assignment of at the desired time step. Verifying accuracy is somewhat involved, given our lazy computation strategy and partitioning of into a locally uniform piece and an associated padding distribution. Thus, in Appendix A we show that Lines 9–19 correctly complete the desired task, proving the following bound on .
Proposition 20.
For any and sufficiently large, we have
We next require that Algorithm 5 has expected polylogarithmic cost. This is largely a consequence of the local uniformity of and our lazy recursive computation of variable assignments in Algorithm 5.
Lemma 21.
Suppose . For every , the expected cost of is .
Input: An integer and assignment ; an integer
Global variables: a set and -marking
Output: a random value in distributed as
Input: An integer and assignment ; an integer
Global variables: -CNF , -marking , , and
Output: a random value in
We prove Lemma 21 in Appendix B. These two results together allow us to prove Theorem 14.
Proof of Theorem 14.
The theorem directly follows from combining Proposition 20 and Lemma 21. By Proposition 20, we know that the joint distribution satisfies . By Lemma 21, we know that for every , the expected cost of is of order .
5 Proof of the main theorem
We are finally able to state and prove the formal version of Theorem 1. Before picking the relevant parameters, we first collect the list of conditions required to apply Theorems 13, 14, and 15.
Condition 22.
| (3) | ||||
Recall that we also need conditions Theorem 11 to apply Theorem 11. One can verify that for and sufficiently large, we can choose all the parameters appropriately so that Theorems 11 and 22 are satisfied.
Lemma 23.
We defer the proof of Lemma 23 to Appendix F of the full version (arxiv:2409.03951). We can now state and prove Theorem 24, the formal version of our main result.
Theorem 24.
Suppose is a -formula with and sufficiently large. Let be the uniform distribution over satisfying assignments to , with marginal distributions for . Then for all , there is a -random local access algorithm for sampling the variable assignment of as , such that
Here we remark that is any fixed constant, and the runtime of depends on it. As written, both the algorithmic runtime and correctness are random, since we give expected running time and bounds on the marginal distribution in total variation distance. However, our algorithm allows derandomising either correctness or running time at the expense of worse bounds on the other.
Proof.
Suppose is a -formula with and sufficiently large, and is any constant. Choose parameters
By Lemma 23, we know that with these parameters, conditions Theorems 11 and 22 are satisfied. Thus, by Theorem 11, there exists a time oblivious local computation algorithm that with probability at least gives a consistent -marking .
Suppose gives a consistent -marking . By Theorem 14, we know that there is a random local access algorithm with expected cost such that the distribution of satisfies .
Let . By the proof of Theorem 15, we know that for every unmarked variable , with probability , the number of clauses in is at most . We already proved in Theorem 15 that for every , the expected cost of is at most .
Furthermore, since the reduced formula has at least variables and at most variables in each clause, and every variable lies in at most clauses with , by Theorem 13, the expected cost of is asymptotically at most
Since both and succeed with probability 1, we get that , the joint distribution of outputs of Algorithm 1 for all , satisfies for all .
By construction, Algorithm 1 is memory-less as it samples all necessary variable assignments in order to compute the assignment of a queried variable . Furthermore, Algorithm 1 queried on different variables collectively returns an assignment that has . Since this holds for any constant, we obtain the desired result.
6 Concluding remarks
With more involved refinements and optimizations of the arguments in this work, the density constraint of Theorem 1 can be substantially improved (to something closer to ). We omit these additional calculations in favor of expositional clarity to highlight our main result: random local access models exist for arbitrary bounded degree -CNFs at exponential clause density. Furthermore, these arguments can also be adapted (in a similar fashion to [13, 19, 7]) to obtain a random local access model for random -CNFs in a comparable density regime.
Nonetheless, the limit of the approaches in this work would still fall well short of obtaining random local access for, e.g., approximately , the maximum density at which we currently know how to efficiently sample solutions to an arbitrary bounded degree -CNF in nearly-linear time [18, 31]. This is because of our reliance on a query-oblivious LCA to construct a local marking and our application of weaker sampling results to a correspondingly reduced CNF.
The approach we take in this work is only one of many possible schema to reduce from existing classical, parallel, and/or distributed algorithms to more local algorithms. Our approach involved using ideas and techniques from a variety of previous works (notably [25, 9, 10]), many of which were in the non-local setting, and adapting them in a novel way to obtain a sublinear sampler. Our approach bears some resemblance to work of [5] where authors adapted a parallel Glauber dynamics algorithm to obtain random local access to proper -colorings, and to work of [3] that used a recursive strategy to give perfect sampling algorithms from certain spin systems in amenable graphs. We expect that many other existing algorithms (including [18, 17, 19, 31]) can be adapted with some work to give random local access algorithms.
References
- [1] Kook Jin Ahn, Sudipto Guha, and Andrew McGregor. Graph sketches: sparsification, spanners, and subgraphs. In Proceedings of the 31st ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, PODS ’12, pages 5–14, New York, NY, USA, 2012. doi:10.1145/2213556.2213560.
- [2] Noga Alon, Ronitt Rubinfeld, Shai Vardi, and Ning Xie. Space-efficient local computation algorithms. In Proceedings of the twenty-third annual ACM-SIAM symposium on Discrete Algorithms, pages 1132–1139. SIAM, 2012. doi:10.1137/1.9781611973099.89.
- [3] Konrad Anand and Mark Jerrum. Perfect sampling in infinite spin systems via strong spatial mixing. SIAM Journal on Computing, 51(4):1280–1295, 2022. doi:10.1137/21M1437433.
- [4] Amartya Shankha Biswas, Edward Pyne, and Ronitt Rubinfeld. Local access to random walks. In 13th Innovations in Theoretical Computer Science Conference (ITCS 2022). Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2022. doi:10.4230/LIPIcs.ITCS.2022.24.
- [5] Amartya Shankha Biswas, Ronitt Rubinfeld, and Anak Yodpinyanee. Local access to huge random objects through partial sampling. 11th Innovations in Theoretical Computer Science (ITCS 2020), 2020. doi:10.4230/LIPIcs.ITCS.2020.27.
- [6] Zongchen Chen, Aditya Lonkar, Chunyang Wang, Kuan Yang, and Yitong Yin. Counting random -sat near the satisfiability threshold. arXiv preprint, 2024. doi:10.48550/arXiv.2411.02980.
- [7] Zongchen Chen, Nitya Mani, and Ankur Moitra. From algorithms to connectivity and back: finding a giant component in random k-SAT. In Proceedings of the 2023 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 3437–3470. SIAM, 2023.
- [8] Paul Erdos and László Lovász. Problems and results on 3-chromatic hypergraphs and some related questions. Infinite and finite sets, 10(2):609–627, 1975.
- [9] Weiming Feng, Heng Guo, Chunyang Wang, Jiaheng Wang, and Yitong Yin. Towards derandomising markov chain monte carlo. In 2023 IEEE 64th Annual Symposium on Foundations of Computer Science (FOCS), pages 1963–1990, 2023. doi:10.1109/FOCS57990.2023.00120.
- [10] Weiming Feng, Heng Guo, Yitong Yin, and Chihao Zhang. Fast sampling and counting -SAT solutions in the local lemma regime. J. ACM, 68(6):Art. 40, 42, 2021. doi:10.1145/3469832.
- [11] Weiming Feng and Yitong Yin. On local distributed sampling and counting. In Proceedings of the 2018 ACM Symposium on Principles of Distributed Computing, pages 189–198, 2018. doi:10.1145/3212734.3212757.
- [12] Andreas Galanis, Leslie Ann Goldberg, Heng Guo, and Andrés Herrera-Poyatos. Fast sampling of satisfying assignments from random -SAT. arXiv, 2022. arXiv:2206.15308.
- [13] Andreas Galanis, Leslie Ann Goldberg, Heng Guo, and Kuan Yang. Counting solutions to random CNF formulas. SIAM Journal on Computing, 50(6):1701–1738, 2021. doi:10.1137/20M1351527.
- [14] Mohsen Ghaffari and Jara Uitto. Sparsifying distributed algorithms with ramifications in massively parallel computation and centralized local computation. In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1636–1653. SIAM, 2019. doi:10.1137/1.9781611975482.99.
- [15] Oded Goldreich, Shafi Goldwasser, and Silvio Micali. How to construct random functions. J. ACM, 33(4):792–807, August 1986. doi:10.1145/6490.6503.
- [16] Oded Goldreich, Shafi Goldwasser, and Asaf Nussboim. On the implementation of huge random objects. SIAM Journal on Computing, 39(7):2761–2822, 2010. doi:10.1137/080722771.
- [17] Kun He, Xiaoming Sun, and Kewen Wu. Perfect sampling for (atomic) Lovász local lemma. arXiv, 2021. arXiv:2107.03932.
- [18] Kun He, Chunyang Wang, and Yitong Yin. Sampling Lovász local lemma for general constraint satisfaction solutions in near-linear time. In 2022 IEEE 63rd Annual Symposium on Foundations of Computer Science (FOCS), pages 147–158. IEEE, 2022. doi:10.1109/FOCS54457.2022.00021.
- [19] Kun He, Kewen Wu, and Kuan Yang. Improved bounds for sampling solutions of random CNF formulas. In Proceedings of the 2023 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 3330–3361. SIAM, 2023. doi:10.1137/1.9781611977554.CH128.
- [20] Vishesh Jain, Huy Tuan Pham, and Thuy-Duong Vuong. On the sampling Lovász local lemma for atomic constraint satisfaction problems. arXiv, 2021. arXiv:2102.08342.
- [21] Fabian Kuhn, Thomas Moscibroda, and Roger Wattenhofer. Local computation: Lower and upper bounds. Journal of the ACM (JACM), 63(2):1–44, 2016. doi:10.1145/2742012.
- [22] David A. Levin and Yuval Peres. Markov chains and mixing times. American Mathematical Society, Providence, RI, second edition, 2017. With contributions by Elizabeth L. Wilmer, With a chapter on “Coupling from the past” by James G. Propp and David B. Wilson. doi:10.1090/mbk/107.
- [23] Hongyang Liu and Yitong Yin. Simple parallel algorithms for single-site dynamics. In Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing, pages 1431–1444, 2022. doi:10.1145/3519935.3519999.
- [24] Yishay Mansour, Aviad Rubinstein, Shai Vardi, and Ning Xie. Converting online algorithms to local computation algorithms. In Automata, Languages, and Programming, pages 653–664, Berlin, Heidelberg, 2012. Springer Berlin Heidelberg. doi:10.1007/978-3-642-31594-7_55.
- [25] Ankur Moitra. Approximate counting, the Lovász local lemma, and inference in graphical models. J. ACM, 66(2):Art. 10, 25, 2019. doi:10.1145/3268930.
- [26] Peter Mörters, Christian Sohler, and Stefan Walzer. A sublinear local access implementation for the chinese restaurant process. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM 2022), 2022. doi:10.4230/LIPIcs.APPROX/RANDOM.2022.28.
- [27] Robin A. Moser and Gábor Tardos. A constructive proof of the general Lovász local lemma. J. ACM, 57(2):Art. 11, 15, 2010. doi:10.1145/1667053.1667060.
- [28] Moni Naor and Asaf Nussboim. Implementing huge sparse random graphs. In International Workshop on Approximation Algorithms for Combinatorial Optimization, pages 596–608, 2007. doi:10.1007/978-3-540-74208-1_43.
- [29] Ronitt Rubinfeld, Gil Tamir, Shai Vardi, and Ning Xie. Fast local computation algorithms. arXiv, 2011. arXiv:1104.1377.
- [30] Joel Spencer. Asymptotic lower bounds for ramsey functions. Discrete Mathematics, 20:69–76, 1977. doi:10.1016/0012-365X(77)90044-9.
- [31] Chunyang Wang and Yitong Yin. A sampling lovász local lemma for large domain sizes. In 2024 IEEE 65th Annual Symposium on Foundations of Computer Science (FOCS), pages 129–150. IEEE, 2024. doi:10.1109/FOCS61266.2024.00019.
Appendix A Correctness of Algorithm 5
In this section, we show Proposition 20 that with high probability, faithfully returns the final outcome of the systematic scan Glauber dynamics initialized at . We will later use Theorem 17 to show that therefore, when is set to be sufficiently large, the distribution of is close to the marginal distribution .
Proposition 25.
Fix and let . Suppose after the execution of (i.e., Line 4 of Algorithm 5 is never triggered). Then faithfully returns , where is the systematic scan Glauber dynamics started at .
Proof.
The statement clearly holds for and . Since , by Lines 1–2 of Algorithm 5, we have .
Inductively, for , assume the proposition for all . Let . Suppose after the execution of . Observe that, since for all , only makes further calls to with . Thus, by the inductive hypothesis, all further calls of have correctly returned the outcomes .
We wish to show that the resampled outcome follows the marginal distribution . Per Lines 5–6, we may assume that has never been called before, in which case we directly go to Line 7 of Algorithm 5. Lines 7–8 guarantee that with probability , we assign to be 0 or 1 uniformly at random. It remains to show that in Lines 9–19, we are able to resample from the padding distribution .
To show this, we first verify that the sets , and the partial assignment obtained in Line 19 satisfy the following four conditions:
-
(1)
;
-
(2)
;
-
(3)
for all such that and , is satisfied by ;
-
(4)
for all marked variables , we have ; for all variables , we either have , or have .
Here, property (1) holds because is added to in the initialization, and never removes variables. Property (2) holds because if variables in some clause are added to in Line 15, then all marked variables in are added to in Line 14. As the while loop terminates, the opposite condition of Line 10 holds, which is exactly property (3).
We now show property (4). For every , we know that is added to in Line 15 due to some clause ; if is marked, then by Line 14 and the inductive hypothesis, we know that we have assigned . For every , by Line 18, we have assigned . If , then we have .
Let denote the connected component in that contains . Let denote the distribution of a uniformly random satisfying assignment to . By property (3), we know that the connected component in that contains is supported on . By property (4), we know that is an extension of , which means that the connected component in that contains is also supported on . Moreover, property (4) implies that , which means that the two marginal distributions and are the same. Altogether, we get that
Recall that is the marginal distribution of on . Let denote the marginal distribution of on . Since and are both supported on subsets of , the above gives
Recall that we wish to sample from . Observe that for any partial assignment , is a deterministic function of (see Definition 19). Since , we have as well. Thus, it suffices to sample which was performed in Line 19. This shows that Lines 9–19 draws from the padding distribution , and finishes the proof.
We now show that the condition happens with high probability. To do this, we show that in a single instance of , the “chain” of further recursions is unlikely to be large. We build the following graph to track these recursions.
Definition 26.
For every and , let
i.e., is the pair comprising the variables of and the most recent times that any marked variable in was resampled up until time . Consider an associated graph defined by
such that in if and only if the following holds:
-
1.
,
-
2.
For , we have (recall that ).
We also recall the notion of a 2-tree in a graph or hypergraph.
Definition 27.
Let be a graph or hypergraph. We say that is a 2-tree if satisfies the following conditions:
-
1.
for all , ;
-
2.
the associated graph with vertex set and edge set is connected.
There are not many -trees containing a fixed vertex in a graph of bounded maximum degree. We recall one example upper bound below that will be sufficient for our purposes.
Observation 28 (see [10, Corollary 5.7]).
Let be a graph or hypergraph with maximum degree . Then for every , the number of 2-trees containing with is at most .
The following proposition shows that the size of is unlikely to be large when we terminate for any .
Proposition 29.
Fix . Suppose and . Upon the termination of , for every , the size of satisfies
Proof.
Fix and consider some instance of . For , we say that is triggered by if is called in Line 14 of with clause . Let . We begin by verifying a few basic properties that and enjoy.
Claim 30.
Upon the termination of , we have .
Proof.
Observe that for every , calls LB-Sample at most times (in Line 7 and Line 12 of Algorithm 5) before possibly going into another subroutine . Let denote the set of timestamps such that was called at least once. Then we have .
Observe that every with is triggered by some . Moreover, every triggers at most subroutines in Line 14. Thus, we get that , which gives .
Claim 31.
The maximum degree of is at most .
Proof.
Fix . There are at most clauses such that . For any such , we count the number of possible so that satisfies .
Suppose
Observe that and . If , then we have
which gives and . Thus, we have
Let . In particular, is an interval of size given by .
Observe that as increments from to , we have only if for some . Moreover, since and , we know that there are at most such numbers in , and these numbers have been completely determined by and (i.e., by and ). These numbers partition into at most intervals such that is the same for all on each interval. Thus, for every fixed and , the set has size at most .
Therefore, given any , we can pick a neighbor by first picking (which has choices) and then picking an element in (which has choices). So the number of possible in is at most .
Claim 32.
Let and . Then is a clique.
Proof.
Consider any two clauses such that . Suppose . Clearly . Moreover, since the timestamps over all marked variables lie in the range , we get that the maximum and minimum of differ by at most . Thus we have in .
Claim 33.
Let be as in Claim 32. For every , there exists a path in such that and .
Proof.
Let be any element in . We perform a double induction, the outside on and the inside on .
-
Base case: .
Suppose first that , so for some . Let . If , then and we are done. Inductively, suppose Claim 33 holds for all that triggers a recursive call earlier than in Algorithm 5. If , then by the while loop condition Line 10, there must exist some such that triggers a recursive call earlier than , and . By the inductive hypothesis, there exists a path in such that and . Since the maximum and minimum of differ by at most , we get that in . Therefore we can extend the path with . This finishes the inductive step.
-
Inductive step: .
Now suppose with . By the inductive hypothesis, we can assume Claim 33 for all . Let .
Suppose first that . Since , there must exist and such that triggers , with and . Let . Clearly . Since , we also know that the maximum and minimum of differ by at most . Thus we have in . By the inductive hypothesis for , there exists a path in such that and . Since in , we can extend the path by .
Inductively, suppose , and Claim 33 holds for all and for all that triggers a recursive call earlier than . Then there must exist some such that triggers a recursive call earlier than , and . By the inductive hypothesis, there exists a path such that and . Since the maximum and minimum of differ by at most , we get that in . Thus we can extend the path by . This finishes the inductive step.
Claim 34.
For all and , the function does not satisfy .
Proof.
This directly follows from Lines 12–14 of Algorithm 5. Since triggers a recursion in Line 14, by the condition in Line 12, for all marked variables , the function does not satisfy .
With these claims, we can now prove the proposition. Fix and . Assume , which by Claim 30 implies that . By Claim 33, we know that ; by Claim 31, has maximum degree . Thus, by a greedy selection, we can find a 2-tree containing some element in such that .
Fix any 2-tree such that . For every , if , then we know from Claim 34 that does not satisfy for all . Since the latter happens with probability at most , we have
Since is a 2-tree, we know that for every two , we have (as otherwise and would share a variable, and the union of these two sets would span an interval of size at most , meaning that in , which contradicts the fact that is an independent set in ). In particular, the sets
are disjoint. Thus, for every fixed 2-tree in , we have
Let denote the set of 2-trees of of size that intersects with . Since and has maximum degree at most , by Observation 28, we have
Thus, we have
where the last step used the assumption that and . This implies that
Setting , we get the following correctness statement on Algorithm 5.
Corollary 35.
For every , we have
In particular, for every , we have
Taking a union bound over all , we get that
Since we have picked in Algorithm 3 sufficiently large so that , we get that the joint output satisfies , proving Proposition 20.
Appendix B Efficiency of Algorithm 5
We now move on to show the efficiency of for all . Observe that for every , by Proposition 29, we have
| (4) |
Moreover, we terminate once we reach . We will use these information to give an upper bound on the expected cost of .
We start by upper bounding the size of the final sets and in Algorithm 5 in terms of .
Lemma 36.
The and in Line 19 of Algorithm 5 satisfy
Proof.
By Line 10 of Algorithm 5, we know that for all , there exists clause such that and . This shows that . Observe that contains at least clauses with disjoint variable sets. Since every marked variable in the clauses added to have gone through at least one round of LB-Sample (per Line 5 and Line 12), we get that .
To upper bound the expected cost of Line 19, we further need the result of He–Wang–Yin [18] on the existence of a “Bernoulli factory” algorithm such that for every locally uniform CNF and variable , the Bernoulli factory efficiently draws a -random variable according to the padding distribution of .
Proposition 37 ([18, Lemma 3.10 and Appendix A]).
Let be a -CNF, be a feasible partial assignment of , and be the reduced CNF (see Definition 5). Suppose we have
Then there exists an algorithm such that for every ,
-
with probability 1 returns ;
-
has expected cost .
We remark that in Algorithm 5, our partial assignment is always supported on the marked variables. Since every clause has at least unmarked variables that are not assigned by , we get that for every . Thus when applying Proposition 37, we will take .
We can now give an upper bound on the expected cost of Algorithm 5, proving Lemma 21.
Proof of Lemma 21.
Let be the set of all such that is executed at least once as subroutine of . Since we run at the beginning (Line 7) of each round , we know that .
Observe that for every , if has been computed once, then we will permanently assign , and later executions of will terminate at Line 4. Thus, it suffices to upper bound the cost of every first execution of before entering another . Multiplying this by would give an upper bound on the cost of .
Suppose we are at the first time of executing for some . We first estimate the cost of the while loop in Lines 10–18, which is a constant multiple of the number of executions of Line 14 and Line 18. Note that every time we execute Line 14 or Line 18, some is added to due to a clause chosen in Line 11, with . Moreover, each clause can be chosen in Line 11 at most once. Thus, the number of pairs that correspond to an execution of Line 14 or Line 18 is at most . Consequently, the cost of the while loop in Lines 10–18 is .
We now estimate the cost of Line 19. Observe that in Line 19, we can apply the Bernoulli factory in Proposition 37 to compute the padding distribution . Since the connected component in Line 19 has at most clauses, by Proposition 37, the expected cost of Line 19 is at most
Let . Combining the above and applying Equation 4, we get that the expected cost of is at most
where in the last step we used the information that
