← All papers
First page of Approximate Counting for Symbolic Automata

Approximate Counting for Symbolic Automata

Kuldeep S. Meel, Umang Mathur, Alexis de Colnet

cs.FL Nov 27, 2026 · v1 cs.PL
The core probabilistic correctness argument (concentration, confidence amplification) of the symbolic-NFA FPRAS is formalized in Lean 4 with a public artifact.
Given a nondeterministic finite automaton $\mathcal{A}$ and a length $n$ in unary, the problem #NFA seeks to compute the number of words of length $n$ accepted by $\mathcal{A}$. A celebrated result of Arenas, Croquevielle, Jayaram, and Riveros established that #NFA admits a fully polynomial-time randomized approximation scheme (FPRAS). Subsequent works have brought the running time down to $O(n^2m^3\log(nm)ε^{-2}\log(1/δ))$ for an NFA with $m$ states over a binary alphabet, with relative error at most $ε$ and failure probability at most $δ$. These running-time bounds concern explicitly represented alphabets, whereas automata arising from programs, strings, and structured data are naturally symbolic, i.e., their transitions carry predicates, or guards, over a large concrete alphabet $\mathbb{D}$. In this work, we study #Symbolic-NFA, which asks to count the number of words of a given length accepted by a symbolic NFA. We present a randomized approximation algorithm for this #P-hard problem. We formulate the algorithm using an oracle interface that supports membership testing, approximate counting, and almost-uniform sampling for transition guards. With polynomial-time implementations of these guard operations, the algorithm yields an FPRAS. Our algorithm extends the recent dependent sampling approach of Meel and de Colnet to symbolic automata. Our FPRAS queries only the input guards, avoiding the potentially exponential blowup from constructing Boolean combinations. For an automaton with transition set $Δ$, the algorithm makes $O(n^2|Δ|\log(n|Δ|)ε^{-2}\log(1/δ))$ counting and sampling queries. For constant-size explicit alphabets, our algorithm recovers the above running-time bound for #NFA. We also formalize the core probabilistic analysis, including concentration and confidence amplification, in Lean 4.

Counting the words of a given length accepted by a symbolic NFA, whose transitions carry predicates over a large concrete alphabet, is #P-hard. Existing FPRAS bounds for #NFA assume explicitly represented alphabets.

The algorithm extends the dependent-sampling FPRAS of Meel and de Colnet to symbolic automata. It uses an oracle interface that offers membership testing, approximate counting, and almost-uniform sampling for transition guards, without forming Boolean combinations of guards. Overlapping guards are handled by a canonical-transition rule, and the analysis introduces drift weights to account for oracle error. The core probabilistic analysis is formalized in Lean 4, with AI assistance used for the formalization.

The algorithm makes O(n^2|Δ|log(n|Δ|)ε^{-2}log(1/δ)) counting and sampling queries, which gives an FPRAS when guard operations run in polynomial time. It recovers the best known #NFA bound for constant-size explicit alphabets. The Lean 4 formalization of the concentration and amplification argument is publicly available.