Random Wheeler Automata

Ruben Becker, Davide Cenzato, Sung-Hwan Kim, Bojana Kodric, Riccardo Maso, Nicola PrezzaCPM 2024

Abstract

Wheeler Automata (WA) generalize the Burrows-Wheeler Transform to regular languages, enabling efficient compressed indexing. Despite their theoretical importance, empirical research has been limited by the lack of large-scale, unbiased datasets. This paper presents a new framework for the uniform sampling of Deterministic Wheeler Automata (WDFAs) in linear time and constant space. By establishing a bijection between WDFAs and a pair of binary structures—an out-transition matrix and an in-degree vector—the authors enable the generation of massive synthetic datasets (up to 8 billion edges) with minimal memory overhead.

Introduction

Since their introduction in 2017, Wheeler Automata have revolutionized string processing by providing a structural framework for indexing regular languages. A finite automaton is "Wheeler" if its states can be ordered co-lexicographically based on the strings labeling the paths entering them. This ordering allows for efficient pattern matching similar to the BWT.

However, the field has faced a significant experimental hurdle: WDFAs are extremely rare within the space of all possible DFAs. Previous methods for generating test data were either biased or computationally prohibitive. The work by Becker et al. addresses this by providing the first algorithm to sample WDFAs uniformly at random.

Combinatorial Characterization

The core contribution of this research is a new combinatorial characterization of WDFAs. The authors prove that any WDFA can be uniquely represented by two binary structures:

  1. Out-transition Matrix ($O$): An $n \times \sigma$ matrix where $O[u, j] = 1$ if state $u$ has an outgoing edge labeled with the $j$-th character of the alphabet.
  2. In-degree Vector ($I$): A bit-vector encoding the number of incoming edges for each state.
An example of a Wheeler Deterministic Finite Automaton (WDFA) with five states.

This bijection transforms the complex problem of generating a graph with global ordering constraints into a simpler task of sampling a valid matrix and vector pair. Because WDFAs are input-consistent (all transitions entering a state have the same label), the encoding of the in-degree vector is significantly simplified.

The combinatorial representation of a WDFA: the out-transition matrix O (left) and the in-degree vector I (right).

Efficient Uniform Sampling

To ensure the algorithm is practical for massive datasets, the authors implemented a "sequential shuffler." This technique generates random permutations on-the-fly, allowing the automaton to be streamed directly to disk edge-by-edge. This approach maintains a constant memory footprint (approximately 4 MB) regardless of the size of the automaton being generated.

The algorithm also utilizes rejection sampling to ensure that every character in the alphabet is represented at least once. The authors demonstrate that for typical parameters, the expected number of attempts is negligible (less than 2), ensuring the linear-time complexity is maintained in practice.

Performance and Scalability

The implementation demonstrates exceptional performance, capable of streaming over 8 million transitions per second. In benchmarking tests, the authors successfully generated a WDFA with 8 billion edges in under 15 minutes using only 4 MB of RAM. This scalability allows researchers to test string processing algorithms on a scale previously impossible.

Furthermore, the paper provides the first exact counting formula for WDFAs with $n$ states and $m$ transitions. It also establishes information-theoretic bounds showing that WDFAs are significantly more compressible than general DFAs, requiring only $n\sigma + (n - \sigma)\log \sigma$ bits for encoding.

Conclusion

The introduction of a uniform sampler for Wheeler Automata fills a critical gap in string processing research. By providing a tool to generate large, unbiased datasets, this work enables robust empirical validation of indexing and pattern-matching algorithms. Future work may extend these techniques to Wheeler NFAs and explore phase transitions in the connectivity of random Wheeler graphs as edge density varies.

Summary updated

BibTeX
@inproceedings{becker2024random,
  author = {Ruben Becker and Davide Cenzato and Sung-Hwan Kim and Bojana Kodric and Riccardo Maso and Nicola Prezza},
  title = {{Random Wheeler Automata}},
  booktitle = {CPM},
  year = {2024},
  doi = {10.4230/lipics.cpm.2024.5},
}
Figure