#CFG and #DNNF admit FPRAS
Kuldeep S. Meel, Alexis de Colnet
TL;DR
This work resolves longstanding open questions by giving the first fully polynomial-time randomized approximation schemes (FPRAS) for counting words of length $n$ in a context-free language and for counting satisfying assignments of a DNNF circuit. The authors reduce both problems to multilinear, homogeneous $(+,\times)$ programs and design an estimator that tracks $p(q) \approx \frac{16n}{|\\mathit{supp}(q)|}$ along with carefully controlled dependent samples, using a median-of-means framework to achieve high-probability accuracy. The key innovations include allowing dependence among samples, leveraging derivation-tree structure via lcsn to bound joint probabilities, and applying depth-reduction to ensure polynomial-time performance. As a corollary, they obtain almost-uniform samplers for CFG and DNNF, enabling efficient random generation of objects in these classes. Overall, the results significantly advance approximate counting and sampling for fundamental models in formal languages and Boolean circuits, with broad implications for probabilistic reasoning and verification tasks.
Abstract
We provide the first fully polynomial-time randomized approximation scheme for the following two counting problems: 1. Given a Context Free Grammar $G$ over alphabet $Σ$, count the number of words of length exactly $n$ generated by $G$. 2. Given a circuit $\varphi$ in Decomposable Negation Normal Form (DNNF) over the set of Boolean variables $X$, compute the number of assignments to $X$ such that $\varphi$ evaluates to 1. Finding polynomial time algorithms for the aforementioned problems has been a longstanding open problem. Prior work could either only obtain a quasi-polynomial runtime (SODA 1995) or a polynomial-time randomized approximation scheme for restricted fragments, such as non-deterministic finite automata (JACM 2021) or non-deterministic tree automata (STOC 2021).
