# Regular Languages meet Prefix Sorting

**Authors:** Jarno Alanko, Giovanna D'Agostino, Alberto Policriti, Nicola Prezza

arXiv: 1902.01088 · 2020-12-17

## TL;DR

This paper introduces Wheeler languages, a subclass of regular languages characterized by prefix-sortable automata, and develops algorithms for their indexing, sorting, and minimization, extending string prefix sorting techniques to languages.

## Contribution

It characterizes Wheeler languages as regular languages with co-lexicographic ordering and provides algorithms for automaton conversion, sorting, and minimization specific to this class.

## Key findings

- Wheeler NFAs can be efficiently converted to Wheeler DFAs with at most 2n-1-|Σ| states.
- Algorithms for prefix-sorting Wheeler automata are quadratic, online, and linear-time, depending on the case.
- The smallest Wheeler DFA for a language can be computed in nearly optimal time.

## Abstract

Indexing strings via prefix (or suffix) sorting is, arguably, one of the most successful algorithmic techniques developed in the last decades. Can indexing be extended to languages? The main contribution of this paper is to initiate the study of the sub-class of regular languages accepted by an automaton whose states can be prefix-sorted. Starting from the recent notion of Wheeler graph [Gagie et al., TCS 2017]-which extends naturally the concept of prefix sorting to labeled graphs-we investigate the properties of Wheeler languages, that is, regular languages admitting an accepting Wheeler finite automaton. Interestingly, we characterize this family as the natural extension of regular languages endowed with the co-lexicographic ordering: when sorted, the strings belonging to a Wheeler language are partitioned into a finite number of co-lexicographic intervals, each formed by elements from a single Myhill-Nerode equivalence class. Moreover: (i) We show that every Wheeler NFA (WNFA) with $n$ states admits an equivalent Wheeler DFA (WDFA) with at most $2n-1-|\Sigma|$ states that can be computed in $O(n^3)$ time. This is in sharp contrast with general NFAs. (ii) We describe a quadratic algorithm to prefix-sort a proper superset of the WDFAs, a $O(n\log n)$-time online algorithm to sort acyclic WDFAs, and an optimal linear-time offline algorithm to sort general WDFAs. By contribution (i), our algorithms can also be used to index any WNFA at the moderate price of doubling the automaton's size. (iii) We provide a minimization theorem that characterizes the smallest WDFA recognizing the same language of any input WDFA. The corresponding constructive algorithm runs in optimal linear time in the acyclic case, and in $O(n\log n)$ time in the general case. (iv) We show how to compute the smallest WDFA equivalent to any acyclic DFA in nearly-optimal time.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1902.01088/full.md

## Figures

3 figures with captions in the complete paper: https://tomesphere.com/paper/1902.01088/full.md

## References

32 references — full list in the complete paper: https://tomesphere.com/paper/1902.01088/full.md

---
Source: https://tomesphere.com/paper/1902.01088