English

Counting and Sampling Traces in Regular Languages

Formal Languages and Automata Theory 2025-12-02 v1 Computational Complexity Logic in Computer Science Programming Languages

Abstract

In this work, we study the problems of counting and sampling Mazurkiewicz traces that a regular language touches. Fix an alphabet Σ\Sigma and an independence relation IΣ×Σ\mathbb{I} \subseteq \Sigma \times \Sigma. The input consists of a regular language LΣL \subseteq \Sigma^*, given by a finite automaton with mm states, and a natural number nn (in unary). For the counting problem, the goal is to compute the number of Mazurkiewicz traces (induced by I\mathbb{I}) that intersect the nthn^\text{th} slice Ln=LΣnL_n = L \cap \Sigma^n, i.e., traces that admit at least one linearization in LnL_n. For the sampling problem, the goal is to output a trace drawn from a distribution that is approximately uniform over all such traces. These tasks are motivated by bounded model checking with partial-order reduction, where an \emph{a priori} estimate of the reduced state space is valuable, and by testing methods for concurrent programs that use partial-order-aware random exploration. We first show that the counting problem is #P-hard even when LL is accepted by a deterministic automaton, in sharp contrast to counting words of a DFA, which is polynomial-time solvable. We then prove that the problem lies in #P for both NFAs and DFAs, irrespective of whether LL is trace-closed. Our main algorithmic contributions are a \emph{fully polynomial-time randomized approximation scheme} (FPRAS) that, with high probability, approximates the desired count within a prescribed accuracy, and a \emph{fully polynomial-time almost uniform sampler} (FPAUS) that generates traces whose distribution is provably close to uniform.

Keywords

Cite

@article{arxiv.2512.00314,
  title  = {Counting and Sampling Traces in Regular Languages},
  author = {Alexis de Colnet and Kuldeep S. Meel and Umang Mathur},
  journal= {arXiv preprint arXiv:2512.00314},
  year   = {2025}
}

Comments

To appear in POPL 2026. Author order is random

R2 v1 2026-07-01T08:00:31.834Z