Abstract 1 Introduction 2 Preliminaries 3 Properties of sorted Lyndon Grammars 4 Lexicographically sorting a Lyndon Grammar 5 BWT construction 6 Practical Lyndon grammar construction 7 Experiments 8 Conclusion and Further Work References

Fast and Memory-Efficient BWT Construction of Repetitive Texts Using Lyndon Grammars

Jannik Olbrich ORCID Ulm University, Germany
Abstract

The Burrows-Wheeler Transform (𝖡𝖶𝖳) serves as the basis for many important sequence indexes. On very large datasets (e.g. genomic databases), classical 𝖡𝖶𝖳 construction algorithms are often infeasible because they usually need to have the entire dataset in main memory. Fortunately, such large datasets are often highly repetitive. It can thus be beneficial to compute the 𝖡𝖶𝖳 from a compressed representation. We propose an algorithm for computing the 𝖡𝖶𝖳 via the Lyndon straight-line program, a grammar based on the standard factorization of Lyndon words. Our algorithm can also be used to compute the extended 𝖡𝖶𝖳 (𝖾𝖡𝖶𝖳) of a multiset of sequences. We empirically evaluate our implementation and find that we can compute the 𝖡𝖶𝖳 and 𝖾𝖡𝖶𝖳 of very large datasets faster and/or with less memory than competing methods.

Keywords and phrases:
Burrows-Wheeler Transform, Grammar compression
Copyright and License:
[Uncaptioned image] © Jannik Olbrich; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Online algorithms
; Theory of computation Shared memory algorithms ; Theory of computation Data compression ; Theory of computation Sorting and searching ; Mathematics of computing Combinatorics on words
Supplementary Material:
Software  (Source Code): https://gitlab.com/qwerzuiop/lyndongrammar [38]
  archived at Software Heritage Logo swh:1:dir:0274cae4abb893b49bc035ef3a57986a418afe40
Editors:
Anne Benoit, Haim Kaplan, Sebastian Wild, and Grzegorz Herman

1 Introduction

The Burrows-Wheeler Transform (𝖡𝖶𝖳) [13] is one of the most important data structures in sequence analysis and is applied in a wide range of fields from data compression to bioinformatics. It is obtained by assigning the ith symbol of the 𝖡𝖶𝖳 to the last character of the ith lexicographically smallest conjugate of the input text. The 𝖡𝖶𝖳 can be computed in linear time and space. The run-length compressed 𝖡𝖶𝖳 (𝖱𝖫𝖡𝖶𝖳) uses the fact that the number of equal-character runs in the 𝖡𝖶𝖳 is small compared to the text length when the text is repetitive [13]. Mantaci et al. [32] extended the notion of the 𝖡𝖶𝖳 to string collections: the extended 𝖡𝖶𝖳 (𝖾𝖡𝖶𝖳) of a string collection consists of the last characters of the strings in arranged in infinite periodic order (see Section 2 for definitions).

The 𝖡𝖶𝖳 serves as the basis of several self-indexes, i.e., data structures supporting access to the text as well as pattern matching queries. One of the most successful such indexes is the FM-index [20], which is used e.g. in the important bioinformatics programs BWA [30] and Bowtie [28]. However, the FM-index uses space proportional to the size of the dataset and is thus not applicable for huge datasets that vastly exceed the size of main memory. Such datasets often contain data from thousands or millions of individuals from the same species and are therefore extremely repetitive. The r-index [22] is based on the 𝖱𝖫𝖡𝖶𝖳 and is the first text index of size proportional to the number r of runs in the 𝖡𝖶𝖳. It can be constructed in space proportional to r from the 𝖱𝖫𝖡𝖶𝖳, which raises the problem of constructing the 𝖱𝖫𝖡𝖶𝖳 of huge datasets with small working memory. For this reason, various tools have emerged that exploit the repetitiveness of these datasets.

The Lyndon grammar of a text is a straight-line program (SLP), i.e., a context-free grammar in Chomsky normal form that generates a single text, where each symbol corresponds to a node in the Lyndon tree. It was introduced in [25] as the basis for a self-index. In this paper, we describe a method for efficiently computing several 𝖡𝖶𝖳 variants of a text or a text collection via the input’s Lyndon grammar and show that our method surpasses other tools with respect to time or memory used, especially when using multiple threads.

1.1 Related work

Boucher et al. [11] developed prefix-free parsing (PFP), a dictionary-compression technique that results in a dictionary and parse from which the (𝖱𝖫)𝖡𝖶𝖳 can be constructed in space proportional to their total size and in time linear to the size of the dataset. While the dictionary typically grows slowly as the size of the dataset increases, the parse grows linearly with the input size (with a small constant chosen at runtime). Consequently, for extremely large and repetitive datasets, “the parse is more burdensome than the size of the dictionary” [41]. In an effort to remedy this, Oliva et al. [41] developed recursive prefix-free parsing, which applies PFP to the parse. PFP has also been used to construct the 𝖾𝖡𝖶𝖳 [10]. The currently fastest implementation for computing the suffix array 𝖲𝖠 (and 𝖡𝖶𝖳) for general texts is libsais and is based on the linear-time suffix array induced sorting (SAIS) algorithm [37, 40]. ropebwt3 uses libsais to compute the 𝖡𝖶𝖳 of chunks of the input and successively merges these 𝖡𝖶𝖳s [29]. Díaz-Domínguez and Navarro used grammar compression to maintain the intermediate data in the SAIS algorithm with low main memory usage, resulting in a linear-time semi-external algorithm that computes a variant of the 𝖾𝖡𝖶𝖳 [14, 17]. Specifically for a collection of sequences where each is similar to a given reference (e.g. human chromosomes), Masillo introduced CMS-BWT, which computes the 𝖡𝖶𝖳 via matching statistics [35].

Lyndon words have previously been used in the construction of 𝖲𝖠 and play an important role in the original 𝖾𝖡𝖶𝖳. In [33, 34], a strategy for computing 𝖲𝖠 was presented where “local suffixes” (i.e., substrings ending at boundaries between Lyndon factors) can be processed separately in each Lyndon factor. Later, Baier effectively generalized the underlying idea by showing that sorting the suffixes by their longest Lyndon prefixes can be used for linear time 𝖲𝖠 construction [2]. The bijective 𝖡𝖶𝖳 (𝖡𝖡𝖶𝖳) is the 𝖾𝖡𝖶𝖳 of the text’s Lyndon factors [23, 27, 32]. Bonomo et al. showed that it is possible to compute the 𝖾𝖡𝖶𝖳 via the 𝖡𝖡𝖶𝖳 and gave an 𝒪(NlogN/loglogN) construction algorithm based on properties of Lyndon words [8, 9]. Later, Bannai et al. modified the SAIS algorithm to compute the 𝖡𝖡𝖶𝖳 in linear time [3]. Since publication, Baier’s algorithm was improved in terms of time and memory usage [6, 39] and further generalized such that it can be used to compute 𝖾𝖡𝖶𝖳 and 𝖡𝖡𝖶𝖳 in linear time [40]. The principles used this generalized algorithm lie at the base of our algorithm for computing the 𝖡𝖶𝖳, 𝖡𝖡𝖶𝖳 and 𝖾𝖡𝖶𝖳 variants from a Lyndon grammar.

1.2 Our contributions

Let N be the size of a text or text collection, nmax the maximum size of a string in the text collection, and g the size of the Lyndon SLP of the text or text collection. We give two online in-memory algorithms for constructing the Lyndon SLP with 𝒪(Ng) and 𝒪(Nlogg+glog2g) worst-case time complexity, both using 𝒪(g) words of memory. Notably, the text or text collection is streamed from right to left and does not have to reside in main memory. Additionally, we give an expected linear-time algorithm that uses 𝒪(g+nmax) words of memory. Furthermore, we give an 𝒪(g) algorithm for sorting the symbols of a Lyndon SLP lexicographically by their generated strings, and an 𝒪(N) algorithm for constructing the (run-length compressed) 𝖡𝖶𝖳, 𝖡𝖡𝖶𝖳, or 𝖾𝖡𝖶𝖳 from a Lyndon SLP. We implemented our algorithms and demonstrate empirically that we can construct the 𝖡𝖶𝖳, 𝖡𝖡𝖶𝖳 or 𝖾𝖡𝖶𝖳 of repetitive texts or text collections faster and/or with less space than competing methods.

2 Preliminaries

For i,j0 we denote the set {k0:ikj} by the interval notations [i..j]=[i..j+1)=(i1..j]=(i1..j+1). For an array 𝖠 we analogously denote the subarray from i to j by 𝖠[i..j]=𝖠[i..j+1)=𝖠(i1..j]=𝖠(i1..j+1)=𝖠[i]𝖠[i+1]𝖠[j]. We use zero-based indexing, i.e., the first entry of the array 𝖠 is 𝖠[0].

A string S of length n over an alphabet Σ is a sequence of n characters from Σ. We denote the length n of S by |S| and the ith symbol of S by S[i1], i.e., strings are zero-indexed. In this paper we assume any string S of length n to be over a totally ordered and linearly sortable alphabet (i.e., the characters in S can be sorted in 𝒪(n)). Analogous to arrays we denote the substring from i to j by S[i..j]=S[i..j+1)=S(i1..j]=S(i1..j+1)=S[i]S[i+1]S[j]. For j>i we let S[i..j] be the empty string ε. For two strings u and v and an integer k0 we let uv be the concatenation of u and v and denote the k-times concatenation of u by uk. A string S is primitive if it is non-periodic, i.e., S=wk implies w=S and k=1. The suffix i of a string S of length n is the substring S[i..n) and is denoted by sufi(S). Similarly, the substring S[0..i] is a prefix of S. A suffix (prefix) is proper if i>0 (i+1<n). For two possibly empty strings u and v, uv is a conjugate of vu.

We assume totally ordered alphabets. This induces a total order on strings. Specifically, we say a string S of length n is lexicographically smaller than another string T of length m if and only if there is some min{n,m} such that S[0..)=T[0..) and either n=<m or <min{n,m} and S[]<T[], and write S<𝑙𝑒𝑥T in this case. A non-empty string S is in its canonical form if and only if it is lexicographically minimal among its conjugates. If S is additionally strictly lexicographically smaller than all of its other conjugates, S is a Lyndon word. Equivalently, S is a Lyndon word if and only if S is lexicographically smaller than all its proper suffixes [18].

In the following, we use abbabcbcabb as our running example.

Theorem 1 (Chen-Fox-Lyndon theorem [15]).

Any non-empty string S has a unique Lyndon factorization, that is, there is a unique sequence of Lyndon words (Lyndon factors) v1𝑙𝑒𝑥𝑙𝑒𝑥vk with S=v1vk.

The Lyndon factorization of our running example is abbabcbc,abb.

Definition 2 (Standard Factorization [15]).

The standard factorization of a Lyndon word w of length |w|2 is the tuple (u,v) where w=uv and v is the longest proper suffix of w that is Lyndon. The standard factorization (u,v) of a Lyndon word w with |w|2 always exists and both u and v are Lyndon.

The standard factorization of the first Lyndon factor of our running example is (abb,abcbc) as abcbc is Lyndon and no longer proper suffix is Lyndon.

Lemma 3 ([40, Lemma 3.20]).

Any Lyndon word w with |w|2 is of the form w[0]wc1wck, where wc1𝑙𝑒𝑥wc2𝑙𝑒𝑥𝑙𝑒𝑥wck are the Lyndon factors of suf1(w).

Figure 1: Next smaller suffix array nss (top) and 𝖡𝖡𝖶𝖳 (bottom) of the running example S=abbabcbcabb. Each arrow points from i to nss[i]. Lyndon factors are coloured ().

Figure 1 illustrates the following definitions.

Definition 4 (next smaller suffix array, nss).

Let the next smaller suffix array nss of a string S be such that nss[i]=min{j(i..|S|]sufj(S)<𝑙𝑒𝑥sufi(S)}.

Definition 5 (Infinite Periodic Order).

We write S<ωT if and only if the infinite concatenation S=SS is lexicographically smaller than the infinite concatenation T=TT.

For instance, ab<𝑙𝑒𝑥aba<𝑙𝑒𝑥abb and abb>ωab>ωaba since abb>𝑙𝑒𝑥abab>𝑙𝑒𝑥abaab.

Definition 6 (Bijective Burrows-Wheeler Transform (𝖡𝖡𝖶𝖳)).

The bijective Burrows-Wheeler Transform (𝖡𝖡𝖶𝖳) of a string S is the string obtained by taking the last character of each conjugate of the Lyndon factors of S arranged in infinite periodic order.

Definition 7 (Extended Burrows-Wheeler Transform (𝖾𝖡𝖶𝖳)).

The extended Burrows-Wheeler Transform (𝖾𝖡𝖶𝖳) of a multiset of strings is the string obtained by taking the last character of each conjugate of the strings in arranged in infinite periodic order.

Note that, by definition, the 𝖡𝖡𝖶𝖳 of a string S is the 𝖾𝖡𝖶𝖳 of the Lyndon factors of S. Similarly, the 𝖾𝖡𝖶𝖳 of a multiset of strings is the 𝖡𝖡𝖶𝖳 of the concatenation of the canonical forms of the strings in arranged in lexicographically decreasing order [3] (the Lyndon factors of the resulting string are conjugates of the roots of the strings in ).111The 𝖾𝖡𝖶𝖳 was originally defined for sets of primitive strings [32]. This limitation is unnecessary [10, 40].

For a primitive string S, its 𝖡𝖶𝖳, the 𝖾𝖡𝖶𝖳 of {S}, and the 𝖡𝖡𝖶𝖳 of the smallest conjugate of S are identical. Consequently, the $-𝖡𝖶𝖳 of a string S (i.e., 𝖡𝖶𝖳(S$), where $ is smaller than all characters in S) commonly computed via the suffix array of S, is identical to 𝖡𝖶𝖳($S)=𝖡𝖡𝖶𝖳($S)=𝖾𝖡𝖶𝖳({$S}).

2.1 Lyndon Grammar

Definition 8 (Lyndon Tree/Forest [4, 25]).

The Lyndon tree of a Lyndon word w – denoted by 𝐿𝑇𝑟𝑒𝑒(w) – is the ordered full binary tree defined recursively as follows: If |w|=1, then 𝐿𝑇𝑟𝑒𝑒(w) consists of a single node labelled by w, and if |w|2 and w has the standard factorization (u,v), the root of 𝐿𝑇𝑟𝑒𝑒(w) is labelled by w, the left child of the root is 𝐿𝑇𝑟𝑒𝑒(u), and the right child of the root is 𝐿𝑇𝑟𝑒𝑒(v). For a non-Lyndon word, we let the Lyndon Forest be the sequence of Lyndon trees of the Lyndon factors.

The Lyndon Forest of the running example is shown in Figure 2. Note that the Lyndon Forest of a string S is closely related to the Lyndon array λ of S [25], where λ[i] is the length of the longest prefix of sufi(S) that is Lyndon (equivalently, λ[i]=nss[i]i [7], cf. Figure 1). A succinct representation of λ occupies 2|S| bits and can be computed in linear time directly from the text [7, 16, 31].

Figure 2: Lyndon Forest (left) and Lyndon SLP (right) for the running example S=abbabcbcabb. For clarity, instead of the node labels the corresponding grammar symbols are shown. Note the structural similarity between the Lyndon forest and the arrows indicating nss in Figure 1.
Definition 9 (Lyndon straight-line program [25]).

A Lyndon straight-line program (SLP) is a context-free grammar 𝒢 over an alphabet Σ in Chomsky normal form, where [Xi] is a Lyndon word for each symbol Xi and each rule XiXaXb is such that the standard factorization of [Xi] is ([Xa],[Xb]), where [Xi] denotes the unique string generated by Xi. A symbol Xi is called terminal symbol if there is a rule of the form Xic (cΣ), and non-terminal symbol otherwise. When r1,,rk are the root symbols of 𝒢,222In slight deviation of the usual definition of SLPs, we allow multiple root/start symbols. The reason for this is that we want to represent arbitrary strings with the Lyndon SLP, not just Lyndon words. 𝒢 generates [𝒢]=[r1][rk], and [r1][rk] is the Lyndon factorization of [𝒢]. The size |𝒢| of 𝒢 is the number of production rules plus the number of start symbols. The derivation tree of the SLP 𝒢 is a labelled ordered tree where the root node has the children r1,,rk. We assume that distinct symbols generate distinct words.

A Lyndon SLP arises from renaming the nodes of a Lyndon Forest such that two nodes with isomorphic subtrees (i.e., representing the same string) are assigned the same symbol. The Lyndon Forest and Lyndon SLP of our running example can be seen in Figure 2.

Clearly, the size of a Lyndon SLP 𝒢 is bounded by 𝒪(|[𝒢]|). This bound is tight and there is no non-trivial bound in terms of e.g. the number of runs in the 𝖡𝖶𝖳, the size γ of the smallest string attractor [26] or the size of the smallest SLP: consider S=an1b for n>1. The smallest SLP generating S has size 𝒪(logn), its 𝖡𝖶𝖳 has two runs, and the smallest string attractor has size γ=|{0,n1}|=2, but every suffix of S is Lyndon and thus the Lyndon SLP generating S has Θ(n) symbols.

In the following, we assume the set of symbols V of an SLP 𝒢 to be numbered consecutively, i.e., V={X1,,X|V|}.

3 Properties of sorted Lyndon Grammars

Consider a Lyndon grammar 𝒢 where the symbols are sorted lexicographically, i.e., [Xi]<𝑙𝑒𝑥[Xj]i<j. In this section we examine such Lyndon SLPs and find properties that enable sorting any Lyndon SLP lexicographically in linear time (Section 4) and give rise to an online algorithm for constructing Lyndon SLPs (Section 6.3). Note that the grammar shown in Figure 2 is lexicographically sorted.

Definition 10 (Prefix- and Suffix-symbols).

Define 𝒫L(Xi) (𝒫R(Xi)) as the set of symbols occurring on the leftmost (rightmost) path of Xi’s derivation tree. More formally, if Xi is a terminal symbol define 𝒫L(Xi)=𝒫R(Xi)={Xi}, and if XiXaXb is a non-terminal symbol define 𝒫L(Xi)={Xi}𝒫L(Xa) and 𝒫R(Xi)={Xi}𝒫R(Xb). We correspondingly define 𝒫L1(Xi) (𝒫R1(Xi)) to be the set of symbols on whose leftmost (rightmost) path of the derivation tree Xi occurs, i.e. 𝒫L1(Xi)={XjXi𝒫L(Xj)} and 𝒫R1(Xi)={XjXi𝒫R(Xj)}.

For example, we have 𝒫L(X6)={X6,X5,X1}, 𝒫R(X6)={X6,X8,X9} and 𝒫L1(X1)={X1,X2,X3,X4,X5,X6} for the grammar shown in Figure 2.

Definition 11.

Define 𝒟(Xi) as the set of symbols occurring in Xi’s derivation tree. More formally, if Xi is a terminal symbol define 𝒟(Xi)={Xi}, and if XiXaXb is a non-terminal symbol define 𝒟(Xi)={Xi}𝒟(Xa)𝒟(Xb).

Let r(Xi) be the largest symbol whose derivation tree has Xi on the leftmost path, i.e., r(Xi)=max(𝒫L1(Xi)). Similarly, let l(Xi) be the smallest symbol whose derivation tree has Xi on the leftmost path, i.e. l(Xi)=min(𝒫L1(Xi)). For example, l(X1)=X1 and r(X1)=X6 in the grammar from Figure 2. In the remainder of this section, we show that all symbols Xj in the interval [l(Xi)..r(Xi)] generate strings with [Xi] as prefix and even satisfy Xj𝒫L(Xi). This then implies that these intervals form a tree-structure.

Lemma 12.

l(Xi)=Xi for all i.

Proof.

For Xj𝒫L1(Xi) we have [Xi]𝑙𝑒𝑥[Xj] as [Xi] is prefix of [Xj] by definition.

The following lemma follows from basic properties of Lyndon words and the definition of the Lyndon grammar/tree. Its proof is omitted due to space constraints.

Lemma 13.

For all Xj[l(Xi)..r(Xi)] it holds Xi𝒫L(Xj), i.e., Xi occurs on the leftmost path of Xj’s derivation tree. Equivalently, [l(Xi)..r(Xi)]=𝒫L1(Xi).

Corollary 14.

Any two intervals [l(Xi),r(Xi)] and [l(Xj),r(Xj)] either do not intersect or one is fully contained within the other.

Proof.

Let Xi and Xj be different such that l(Xi)<l(Xj)r(Xi) (Lemma 3 implies l(Xi)l(Xj)). This implies Xj𝒫L(Xi) by Lemma 13 and thus 𝒫L(Xj)𝒫L(Xi) and r(Xj)r(Xi).

Figure 3: First-symbol forest of the (lex. sorted) Lyndon SLP of the running example (cf. Figure 2).
Corollary 15.

The intervals [l(Xi),r(Xi)] induce a forest.

The following definition defines this forest. An example can be seen in Figure 3.

Definition 16.

We say an interval [l(Xj),r(Xj)] is embedded in an interval [l(Xi),r(Xi)] if it is a subinterval of [l(Xi),r(Xi)], i.e. l(Xi)<l(Xj)r(Xj)r(Xi). If [l(Xj),r(Xj)] is embedded in [l(Xi),r(Xi)] and there is no interval embedded in [l(Xi),r(Xi)] in which [l(Xj),r(Xj)] is embedded, [l(Xj),r(Xj)] is a child interval of [l(Xi),r(Xi)].

The first-symbol forest is a rooted forest, where each symbol Xi of the SLP corresponds to a node ui, and uj is a child of ui if and only if [l(Xj),r(Xj)] is a child interval of [l(Xi),r(Xi)]. Note that the parent of XiXaXb is Xa. Also, the terminal symbols correspond to the roots of the trees in the forest.

Lemma 17.

Let Xi be a symbol of a Lyndon SLP. We have 𝒫L(Xi)={X0,,Xk} where XjXj1Xcj for all j[1..k], X0 is a terminal symbol, Xk=Xi, and [Xc1][Xck] is the Lyndon factorization of suf1([Xi]).

Proof.

Follows immediately from Lemma 3.

4 Lexicographically sorting a Lyndon Grammar

Given a Lyndon SLP 𝒢 with roots r1,,rk, we want to rename the symbols such that [Xi]<𝑙𝑒𝑥[Xj] holds if and only if i<j. This is possible in 𝒪(|𝒢|) using a similar principle to what is used for computing the Lyndon grouping in [2, 40]: consider a symbol Xi. By Lemma 17 and simple properties of Lyndon words, the symbols in 𝒟(Xi)𝒫L(Xi) are lexicographically greater than Xi. Therefore, when considering the symbols in lexicographically decreasing order we can “induce” the position of a symbol XiXaXb upon encountering Xb: the symbols in 𝒫L1(Xi) must be the lexicographically largest symbols with Xa as prefix symbol that have not yet been induced.

Algorithm 1 shows the procedure. Throughout, 𝖠[i] is either the ith symbol in the lexicographical order or , and for each inserted Xi, 𝖦[i] is the index in 𝖠 of the smallest child of Xi that has been inserted into 𝖠 (or r(Xi)+1 if no child has been inserted yet). In the first for-loop, all terminal symbols are inserted into 𝖠, and in the second for-loop, the remaining symbols are induced. Consequently, after the second for-loop, 𝖠 contains the lexicographic order of the symbols, and 𝖦 is (almost) it’s inverse, i.e. 𝖦[𝖠[i]]=i+1.

There are two operations in Algorithm 1 that are not immediately obvious, namely finding |𝒫L1(Xi)| and iterating over all Xj with XjXaX𝖠[i] for a given 𝖠[i]. For the first, note that the values |𝒫L1(Xi)| can be trivially computed in linear-time using the recurrence |𝒫L1(Xa)|=1+XiXaXb|𝒫L1(Xi)|. Secondly, iterating efficiently over all Xj with XjXaX𝖠[i] can be achieved using a linear-time preprocessing step where we collect for each symbol Xi the symbols which have Xi as second symbol on the right-hand side.

The following theorem follows. Its proof is omitted due to space constraints.

Theorem 18.

Algorithm 1 lexicographically sorts a Lyndon SLP in linear time.

Algorithm 1 Lexicographically sorting a Lyndon SLP.

5 BWT construction

In this section, we describe an algorithm that derives the 𝖡𝖡𝖶𝖳 from the Lyndon SLP. Specifically, combining the second phase of GSACA [2, 40] with run-length encoding on the lexicographically sorted Lyndon SLP results in a very efficient algorithm on real data.

The following lemmas and corollary establish a relationship between the lexicographical order of suffixes and the lexicographical order of certain symbols of the Lyndon grammar.

Lemma 19 ([40, Lemma 3.3]).

Let i be the longest prefix of sufi(S) that is Lyndon. Then, i<𝑙𝑒𝑥j implies sufi(S)<𝑙𝑒𝑥sufj(S).

Lemma 20.

Consider an occurrence of XiXaXb at position j in the text S (this implies S[j..j+|[Xi]|]=[Xi]). Then, [Xb] is the longest prefix of sufj+|[Xa]|(S) that is Lyndon.

Proof.

Follows immediately from the relationship between Lyndon forest and Lyndon grammar [25] and [21, Lemma 15].

Corollary 21.

Consider occurrences of XiXaXb at position j and of XiXaXb at position j. It holds sufj+|[Xa]|(S)<𝑙𝑒𝑥sufj+|[Xa]|(S) if [Xb]<𝑙𝑒𝑥[Xb].

To see why Corollary 21 is useful, consider a symbol XiXaXb. Each occurrence of Xi in the derivation tree corresponds to a suffix of the text with prefix [Xb], and each such suffix introduces an occurrence of the last character of [Xa] to the 𝖡𝖶𝖳 in the 𝖲𝖠-interval of [Xb]. In our running example (cf. Figure 2), each occurrence of X8X7X9 introduces a b in the 𝖲𝖠-interval of [X9]=c.

Algorithm 2 Computing 𝖲𝖠 from the lexicographically sorted Lyndon grammar [40, Algorithms 2 and 3].

In [40], an array 𝖲𝖠333𝖲𝖠 is essentially the analogue to 𝖲𝖠 for conjugates of Lyndon factors and the infinite periodic order. A precise definition is omitted because only the relationship between SA and 𝖡𝖡𝖶𝖳 is relevant for this paper. is computed such that 𝖡𝖡𝖶𝖳[i]=S[𝖲𝖠[i]] holds for all i. This array arises from sorting the conjugates of the Lyndon factors of S and replacing each start position of a Lyndon word with the end position of the Lyndon word in S. It was shown that Algorithm 2 correctly computes the array 𝖲𝖠 in linear time [40].444In [40], Lyndon factors (roots of the Lyndon forest) come after every non-root representing the same Lyndon word. To reflect this, we use 𝖫[2(i1)+1] if an occurrence of Xi is a root and 𝖫[2(i1)] otherwise. Basically, Lemma 19 implies that the positions in 𝖲𝖠 are grouped by the longest Lyndon prefixes of the corresponding suffixes. The longest Lyndon prefix of sufi(S) is S[i..nss[i]). Because sufnss[i](S)<𝑙𝑒𝑥sufi(S) by definition, we can proceed by induction from lexicographically small to large.555There is a slight detail omitted here for clarity and brevity. Namely, that for the 𝖡𝖡𝖶𝖳 we are concerned with the next smaller conjugate of the respective Lyndon factor instead of the next smaller suffix [40]. Consider for instance the suffixes starting with c at indices 5 and 7 in our running example (cf. Figure 2). By Lemma 19, they are in the same “Lyndon group” [2] in the sorted list of suffixes because c is their longest Lyndon prefix. We have nss[5]=5+|c|=6 and nss[7]=7+|c|=8. When processing these Lyndon groups in lexicographically increasing order, the relative order of suffixes 6 and 8 is known at the point in time when the Lyndon group c is considered (because they are lexicographically smaller), and can therefore determine the lexicographical order of the suffixes 5 and 7.

We are now going to transform Algorithm 2 such that it outputs the 𝖡𝖡𝖶𝖳 instead of 𝖲𝖠 and works without nss and the text indices. First, consider a text index i[0..N) and let ui be the highest node in the Lyndon forest at position i. (Equivalently, ui corresponds to the longest Lyndon word starting at i.) Now consider the parent vi of ui. By its definition, it is clear that ui is the right child of vi. Let wi be the left child of vi. We can observe that, starting from wi, the nodes on the rightmost path (excluding wi) correspond exactly to the set {j[0..i)nss[j]=i}. For instance, in our running example there is a node labelled with [X8]=bc at position 6 (cf. Figures 1 and 2). This node is the right child of a node labelled with [X6], which has a node labelled with [X5] as left child. There are two nodes on the rightmost path from this latter node, namely one at position 4 labelled with [X8]=bc and one at position 5 labelled with [X9]=c. We consequently have nss[4]=nss[5]=6.

Second, for 𝖲𝖠[k]=i we have 𝖡𝖡𝖶𝖳[k]=S[i1] and it follows that 𝖡𝖡𝖶𝖳[k] is the last character of the string corresponding to vi’s left child wi. Because of these two observations, we can replace the insertion of i in Algorithm 2 with the insertion of wi. Consequently, we can reformulate Algorithm 2 to Algorithm 3.

Theorem 22.

Algorithm 3 correctly computes 𝖡𝖡𝖶𝖳 from the sorted Lyndon SLP in 𝒪(N) time.

Proof.

The linear worst-case time complexity trivially follows from the fact that each iteration of the inner loop appends at least one character to 𝖡𝖡𝖶𝖳. A proof of correctness is omitted due to space constraints.

Note that runs in a list in 𝖫 compound: If there is a run of symbol Xi, there is also a run of at least the same length of X in Xr for each non-terminal Xs𝒫R(Xi) with XsXXr. Thus, Algorithm 3 often requires much fewer than N iterations.

Algorithm 3 Deriving the 𝖡𝖡𝖶𝖳 from the lexicographically sorted Lyndon grammar.

5.1 Computing 𝗕𝗪𝗧 and 𝗲𝗕𝗪𝗧

When the text S is a Lyndon word, the 𝖡𝖡𝖶𝖳 of S is equal to the original 𝖡𝖶𝖳 of S [3]. Since the 𝖡𝖶𝖳 is independent of the rotation of the input and $S is a Lyndon word, we have 𝖡𝖡𝖶𝖳($S)=𝖡𝖶𝖳(S$). The latter is the $-𝖡𝖶𝖳 commonly computed via the suffix array. Therefore, we can simply compute the $-𝖡𝖶𝖳 by prepending a sentinel character to the text. Note that this is trivial and can be done after building the Lyndon grammar of S.

The 𝖾𝖡𝖶𝖳 of a set 𝒮 of strings is the same as the 𝖡𝖡𝖶𝖳 of the string 𝒮c that arises from arranging the canonical forms of the strings in 𝒮 in lexicographically decreasing order [40]. In particular, the Lyndon factors of 𝒮c are exactly the canonical forms of the input strings (assuming that the input strings are primitive). Note that, in Algorithm 3, sorting the canonical forms of the input strings is done implicitly in the first for-loop.

Note that the Lyndon grammars of the input strings are independent of each other (as long as equal Lyndon words are assigned equal grammar symbols). Therefore, we can also construct their Lyndon grammars independently of each other while using the same dictionary. As a consequence, it is easy to use our algorithms for parallel construction of the Lyndon grammar of a collection of sequences. Although our algorithm for deriving the 𝖡𝖶𝖳 from the grammar is not parallelized, parallel construction of the Lyndon grammar leads to a substantial reduction in wall-clock-time because it is by far the most time-consuming part of the pipeline (see Section 7).

5.2 Other 𝗕𝗪𝗧 variants for string collections

Besides the original 𝖾𝖡𝖶𝖳, several other 𝖡𝖶𝖳 variants for string collections have been proposed (see [14] for an overview). Several of the variants are especially suited to be computed with our algorithm, because there the input sequences 𝒮={S1,,Sn} can be parsed independently (and in parallel) like for the 𝖾𝖡𝖶𝖳: The dollar-𝖾𝖡𝖶𝖳 𝖽𝗈𝗅𝖤𝖡𝖶𝖳(𝒮)=𝖾𝖡𝖶𝖳({S$S𝒮}), the multidollar 𝖡𝖶𝖳 𝗆𝖽𝗈𝗅𝖡𝖶𝖳(𝒮)=𝖡𝖶𝖳(S1$1Sn$n), and the concatenated 𝖡𝖶𝖳 𝖼𝗈𝗇𝖼𝖡𝖶𝖳(𝒮)=𝖡𝖶𝖳(S1$Sn$#), where #<$ and $1<<$n are smaller than all characters in 𝒮. This is done by constructing the Lyndon SLP of each Si (with a shared dictionary) and then applying post-processing steps such that the desired 𝖾𝖡𝖶𝖳 variant can be derived from the resulting SLP. This is possible because the $’s separate the input strings in the sense that no Lyndon word starting inside some Si can contain a $.

More specifically, for the 𝖽𝗈𝗅𝖤𝖡𝖶𝖳, no post-processing is required and we can just apply our 𝖾𝖡𝖶𝖳 construction algorithm, except that finding the canonical forms of the strings is trivial because 𝖾𝖡𝖶𝖳({S$S𝒮})=𝖾𝖡𝖶𝖳({$SS𝒮}) and $S is a Lyndon word. For the 𝗆𝖽𝗈𝗅𝖡𝖶𝖳 and 𝖼𝗈𝗇𝖼𝖡𝖶𝖳, we replace each Si in S1$1Sn$n and S1$$Sn$#, respectively, with the roots of the grammar generating Si and compute the grammar of a rotation of the resulting string using Algorithm 3: both $1S2$2Sn$nS1 and #S1$$Sn$ are Lyndon. Therefore, 𝖡𝖶𝖳(S1$1Sn$n)=𝖡𝖡𝖶𝖳($1S2$2Sn$nS1) and 𝖡𝖶𝖳(S1$$Sn$#)=𝖡𝖡𝖶𝖳(#S1$$Sn$) and we can apply our 𝖡𝖡𝖶𝖳 construction algorithm to these rotations.

Note that all other 𝖡𝖶𝖳 variants for string collections given in [14] can be simulated with the multidollar 𝖡𝖶𝖳 by using different relative orders of the separator symbols.

6 Practical Lyndon grammar construction

As shown in [1], the simple folklore algorithm for constructing the Lyndon array can be used to construct the Lyndon forest. With a fitting lookup data structure, we can trivially construct the Lyndon SLP instead. We essentially use Algorithm 4.

Algorithm 4 Prepending S[i] [1].

There are two steps that have to be explained: First, one must be able to compare [Xt] and [Xc] lexicographically, and secondly, one must be able to find Xc with XcXcXt (this is also called the naming function). For the former, we store for each symbol on the stack a fixed-length prefix of the generated string. In many cases, this is sufficient for determining the lexicographical order. Possibilities to handle the other cases are explained in Sections 6.1, 6.2 and 6.3. The following paragraphs will deal with the naming function.

For the naming function, we use a hash table to find the symbol names. This provides (expected) constant time lookup/insertion.666Note that this is also possible in 𝒪(loglogg) deterministic time with at most 2g+glogg+o(glogg)) bits of memory, where g is the number of symbols of the grammar [42]. In practice however, N hash table lookups are unnecessarily slow, especially because we assume the input to be repetitive. In particular, having fewer but longer keys is cache friendlier and thus faster on modern computer architectures.

Specifically, we decrease the number of hash table accesses by partitioning the nodes of the Lyndon forest into heavy and light nodes and querying a second hash table H for each heavy node. The naming function is then only used when such a query to H does not return an answer. Leaves of the Lyndon forest are considered heavy. An inner node v is considered heavy, if and only if its number of immediate heavy descendants (heavy descendants for which only light nodes occur on the path to v) exceeds a fixed constant n𝑡ℎ𝑟𝑒𝑠>1 (see Figure 4).777In our experiments, n𝑡ℎ𝑟𝑒𝑠=31.

Figure 4: Partial representation of a Lyndon Forest with n𝑡ℎ𝑟𝑒𝑠=2. Heavy nodes are coloured in () while light nodes are not.

For a heavy node v of the Lyndon forest we query H with the sequence of immediate heavy descendants v1,,vk of v. This means that we only store heavy nodes on the stack, for a light node we instead store all immediate heavy descendants.

Different occurrences of the same symbol represent the exact same Lyndon tree and therefore correspond to the exact same sequence of immediate heavy descendants. Consequently, if a subtree isomorphic to the subtree rooted at a heavy node has occurred previously, the query to H is sufficient to resolve it. Otherwise, we use the naming function to find the correct symbol and insert the sequence of immediate heavy descendants with it into H.

Note that each heavy node has at most 2n𝑡ℎ𝑟𝑒𝑠 immediate heavy descendants because it has exactly two children (or zero), each of which is either light (and thus has at most n𝑡ℎ𝑟𝑒𝑠 immediate heavy descendants) or heavy itself. This implies that the total memory usage increases by a factor of at most 𝒪(n𝑡ℎ𝑟𝑒𝑠).

6.1 Constant time suffix comparisons

Because the Lyndon forest (and thus the Lyndon SLP) is closely related to the Lyndon array, we can use the Lyndon array to decide whether [Xt]𝑙𝑒𝑥[Xc] holds in constant time. Specifically, when considering S[i] in Algorithm 3, we have [Xc]<𝑙𝑒𝑥[Xt] while λ[i]>|[Xc]|.

Unfortunately, as far as we know, all linear-time algorithms for constructing the Lyndon array directly from the text need random access to the text [1, 7, 19] and thus the text should reside in main memory.

For a 𝖡𝖶𝖳 of a real-world string collection 𝒮 however, this is typically not a problem because, as noted in Section 5.1, the SLPs of the strings in 𝒮 can be computed independently (with a shared dictionary). Consequently, it suffices to have only the string (and its (succinct) Lyndon array) in main memory whose Lyndon SLP is currently computed. This increases the RAM usage by nmax(log2|Σ|+2) bits, where nmax is the length of the longest string in 𝒮. For real biological data, nmax is generally small compared to the size of the entire input.

6.2 Naïve suffix comparisons using the Lyndon grammar

In this section, we describe a simple method for comparing [Xt] and [Xc] lexicographically which requires constant extra memory and works well in practice. We assume that a,b<i holds for each rule XiXaXb. This is clearly the case for SLPs constructed with Algorithm 4 if we assign increasing indices to new symbols.

First note that, because we assign equal Lyndon words to equal symbols, [Xt]=[Xc] if and only if t=c. The key to our algorithm is that we find the longest common symbol X𝒫L(Xt)𝒫L(Xc). Additionally, we determine Xt𝒫L(Xt) and Xc𝒫L(Xc) with XtXXr and XcXXr. Note that, by definition, rr (otherwise, c=t, contradicting the choice of ) and therefore the lexicographical order of [Xr] and [Xr] is the same as the lexicographical order of [Xt] and [Xc]. Formally, [Xt]<𝑙𝑒𝑥[Xc][Xr]<𝑙𝑒𝑥[Xr]. If such a tuple (,t,c) does not exist, either [Xt] and [Xc] do not share a non-empty prefix (i.e., [Xt][0][Xc][0]), or one of Xt and Xc is a prefix of the other.

Note that the indices of the elements in 𝒫L(Xi) have the same relative order as the lengths of the generated strings in the sense that for all a,b𝒫L(Xi) we have a<b if and only if |[Xa]|<|[Xb]|. For this reason, we can proceed with a two-pointer search to find (and t and c). More specifically, assuming that the desired 𝒫L(Xt)𝒫L(Xc) exists, we have 𝒫L(Xa) if |[Xt]|<|[Xc]| for XcXaXb, and vice versa. A concrete implementation is omitted due to space constraints.

Because in each step, at least one of the symbol indices decreases, the time complexity for a comparison is at most linear in the size of the SLP. In fact, because in each step we go from a symbol to one of its children, the time complexity is actually bounded by the height of the SLP. This in turn implies a time complexity of 𝒪(Ng) when using Algorithm 4 with the described method for constructing the Lyndon SLP.

Note that this worst-case time complexity is tight, e.g. on the string akbak (k). However, the Lyndon forests of random strings have expected height proportional to the logarithm of the input size [36] and our approach works very well in practice (see Section 7).

6.3 Construction in 𝓞(𝑵𝐥𝐨𝐠𝒈+𝒈𝐥𝐨𝐠𝟐𝒈)

In this Section, we describe an algorithm that is able to compute the Lyndon grammar online in 𝒪(Nlogg+glog2g) deterministic time from right to left in a streaming fashion using 𝒪(g) words of extra memory.

Basically, this is done by maintaining the grammar’s set of symbols 𝒮 in an ordered sequence, lexicographically sorted by their respective generated strings. Using e.g. a B-Tree [5], one can then find the rank of any symbol in 𝒪(log|𝒮|) time. Thus, determining the lexicographical order of two symbols in 𝒮 can also be done in 𝒪(log|𝒮|) time. What remains to be shown is how the symbols can be maintained in this sorted arrangement.

As shown in Section 3, a lexicographically sorted Lyndon grammar has a forest-structure (cf. Figure 3). This first-symbol forest can be represented using a balanced parenthesis sequence (BPS) of length 2|𝒮| [24], which can be obtained using a depth-first traversal of the first-symbol forest (starting at the roots) by writing an opening parenthesis ‘(’ when visiting a node for the first time and a closing parenthesis ‘)’ when all subtrees of a node have been visited [24]. Each parenthesis pair corresponds to a symbol in the grammar, where the ith opening parenthesis corresponds to the ith smallest symbol (by lexicographical order). For a grammar with symbol set 𝒮, let this BPS be 𝒮. We represent 𝒮 as an ordered sequence 𝒯𝒮, which contains two markers (i and )i for each symbol Xi in 𝒮, such that the ranks of (i and )i are the indices of Xi’s opening and closing parenthesis in 𝒮, respectively. For instance, the sequence 𝒯𝒮 for the lexicographically sorted Lyndon grammar of our running example (see Figure 3) would be (1(2(3(4)4)3)2(5(6)6)5)1(7(8)8)7(9)9.

Now consider adding a new symbol XiXaXb, where Xa and Xb are in 𝒯 (i.e. Xi𝒮, Xa,Xb𝒮). By Lemma 15, the parent of Xi’s parenthesis pair in 𝒮{Xi} must be Xa’s parenthesis pair. Therefore, it suffices to determine Xi’s lexicographically smallest “sibling” XjXaXc (Xj𝒮) with [Xc]>𝑙𝑒𝑥[Xb]; Xi’s parenthesis pair must appear immediately in front of (j in 𝒯𝒮{Xi}. If there is no such sibling, Xi is (currently) the largest child of Xa and thus Xi’s parenthesis pair must be immediately in front of )a instead. Note that comparing [Xb] and [Xc] is possible in 𝒪(log|𝒮|) because both Xb and Xc are in 𝒯𝒮.

In order to be able to find the correct sibling of Xi as described, we additionally maintain for each Xa an ordered sequence 𝒯a containing the symbols 𝒮a={XkXaXbXk,Xb𝒮} in lexicographical order. Inserting XiXaXb into 𝒯a can then be accomplished with 𝒪(log|𝒮a|)𝒪(log|𝒮|) comparisons, each of which is possible in 𝒪(log|𝒮|) via 𝒯𝒮.

In total, we obtain a time complexity of 𝒪(|𝒮|log2|𝒮|) for maintaining the grammar’s symbols lexicographically sorted, and 𝒪(Nlog|𝒮|) for constructing the Lyndon forest.

7 Experiments

Figure 5: Wall clock time and maximum resident memory of 𝖡𝖶𝖳 construction algorithms on chromosome 19 sequences. The sequences were concatenated and all programs used only one thread.
Figure 6: Wall clock time and maximum resident memory of tools for constructing 𝖡𝖶𝖳 variants for string collection on chromosome 19 sequences. All programs used only one thread.
Figure 7: Wall clock time and maximum resident memory of tools for constructing 𝖡𝖶𝖳 variants on 1000 Chromosome 19 sequences (top) and 106 SARS-CoV-2 sequences (bottom) using multiple threads. Note that CMS-BWT does not support multithreading. For the SARS-CoV-2 data, PFP-eBWT required the ----reads flag.

The source code of our implementation is publicly available.888https://gitlab.com/qwerzuiop/lyndongrammar

We compare our 𝖡𝖶𝖳 algorithms for single texts with the programs Big-BWT 999https://gitlab.com/manzai/Big-BWT, last accessed: 22.04.2025, git hash 944cb27 [11] and r-pfbwt 101010https://github.com/marco-oliva/r-pfbwt, last accessed: 22.04.2025, git hash 1fea5c3 [41], as well as libsais.111111https://github.com/IlyaGrebnov/libsais, last accessed: 22.04.2025, git hash a138159 The latter uses a modified version of the Suffix-Array Induced Sorting (SAIS) algorithm [37] to compute the 𝖡𝖶𝖳 and, since it is based on the currently fastest 𝖲𝖠 construction implementation for general real-world data [40], can be viewed as a lower bound for algorithms using the suffix array to compute the 𝖡𝖶𝖳.

For the 𝖡𝖶𝖳 of text collections, we compare with PFP-eBWT 121212https://github.com/davidecenzato/PFP-eBWT, last accessed: 22.04.2025, git hash 4ca75ce [10], r-pfbwt [41], ropebwt3 131313https://github.com/lh3/ropebwt3, last accessed: 22.04.2025, git hash 36a6411 [29], grlBWT 141414https://github.com/ddiazdom/grlBWT, last accessed: 22.04.2025, git hash f09e7fa [17] and CMS-BWT 151515https://github.com/fmasillo/cms-bwt, last accessed: 22.04.2025, git hash 1099d07. Note that the speed and memory usage of CMS-BWT has improved massively since its publication in [35]. [35] (for CMS-BWT we used the first sequence in the collection as reference). All tool except the last one support multi-threading. Note that not all of these tools compute the same 𝖡𝖶𝖳 variant [14]. Also note that all algorithms based on PFP as well as grlBWT are semi-external, i.e., write/read some temporary data to/from disk.

As test data, we use up to 1000 human Chromosome 19 haplotypes from [12] (61010bp) and 106 SARS-CoV-2 sequences (31010bp).161616Downloaded from https://www.covid19dataportal.org on 28.08.2024. All experiments were conducted on a Linux-6.8.0 machine with an Intel Xeon Gold 6338 CPU and 512 GB of RAM. All programs were compiled with GCC 13.3.0. Before each test, the test file was scanned once to ensure it is cached by the kernel. The results can be seen in Figures 5, 6 and 7. The subscripts for the PFP-based algorithms indicate the used modulus.

For our programs, computing the 𝖽𝗈𝗅𝖤𝖡𝖶𝖳 using the suffix comparison method from Section 6.2 is generally the fastest. Computing the original 𝖾𝖡𝖶𝖳 is slightly slower because we need to find the smallest rotation of each input string. In the single-threaded case, for both the 1000 Chromosome 19 haplotypes and 106 SARS-CoV-2 sequences, over 98% of the time was spent constructing the grammar (for our fastest algorithm). Using the linear-time algorithm for constructing the Lyndon array from [7] to ensure expected linear time complexity slows our programs down by up to 60%. As expected, the suffix comparison method from Section 6.3 is much slower than our other methods. The increase in memory consumption of our program in the multithreaded case is due to the use of thread-safe hash tables and multiple sequences and stacks residing in main memory.

For the Chromosome 19 collections and a single thread, CMS-BWT is the fastest program (at the cost of high memory usage), followed by r-pfbwt (for larger cases) and our algorithms. For more threads, our program is always the fastest. Regarding the memory consumption, grlBWT uses the least amount of main memory for single-threaded processing, followed by our programs. For the SARS-CoV-2 sequences, our program is the fastest, especially with multiple threads, and for more than one thread also the most memory efficient.

8 Conclusion and Further Work

We described an algorithm to compute the 𝖡𝖡𝖶𝖳 – and by extension the common $-𝖡𝖶𝖳 and various versions of the 𝖾𝖡𝖶𝖳 – from the lexicographically sorted Lyndon grammar of a text or text collection. Furthermore, we gave an algorithm that lexicographically sorts a Lyndon grammar and discussed approaches to efficiently compute the Lyndon grammar of a text or text collection. We implemented the described algorithms and found that they outperform other current state-of-the art programs in terms of time or memory consumed (often both).

References

  • [1] Golnaz Badkobeh, Maxime Crochemore, Jonas Ellert, and Cyril Nicaud. Back-to-front online lyndon forest construction. In Hideo Bannai and Jan Holub, editors, 33rd Annual Symposium on Combinatorial Pattern Matching, volume 223 of LIPIcs. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2022. doi:10.4230/LIPICS.CPM.2022.13.
  • [2] Uwe Baier. Linear-time Suffix Sorting - A New Approach for Suffix Array Construction. In Roberto Grossi and Moshe Lewenstein, editors, 27th Annual Symposium on Combinatorial Pattern Matching, volume 54 of Leibniz International Proceedings in Informatics, Dagstuhl, Germany, 2016. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.CPM.2016.23.
  • [3] Hideo Bannai, Juha Kärkkäinen, Dominik Köppl, and Marcin Piątkowski. Constructing the Bijective and the Extended Burrows-Wheeler Transform in Linear Time. In Paweł Gawrychowski and Tatiana Starikovskaya, editors, 32nd Annual Symposium on Combinatorial Pattern Matching, volume 191 of Leibniz International Proceedings in Informatics. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.CPM.2021.7.
  • [4] Hélène Barcelo. On the action of the symmetric group on the free lie algebra and the partition lattice. Journal of Combinatorial Theory, Series A, 55(1):93–129, 1990. doi:10.1016/0097-3165(90)90050-7.
  • [5] Rudolf Bayer and Edward McCreight. Organization and maintenance of large ordered indices. In Proceedings of the 1970 ACM SIGFIDET (Now SIGMOD) Workshop on Data Description, Access and Control, pages 107–141, 1970. doi:10.1145/1734663.1734671.
  • [6] Nico Bertram, Jonas Ellert, and Johannes Fischer. Lyndon Words Accelerate Suffix Sorting. In Petra Mutzel, Rasmus Pagh, and Grzegorz Herman, editors, 29th Annual European Symposium on Algorithms, volume 204 of Leibniz International Proceedings in Informatics. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ESA.2021.15.
  • [7] Philip Bille, Jonas Ellert, Johannes Fischer, Inge Li Gørtz, Florian Kurpicz, J. Ian Munro, and Eva Rotenberg. Space Efficient Construction of Lyndon Arrays in Linear Time. In Artur Czumaj, Anuj Dawar, and Emanuela Merelli, editors, 47th International Colloquium on Automata, Languages, and Programming, volume 168 of Leibniz International Proceedings in Informatics. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.ICALP.2020.14.
  • [8] Silvia Bonomo, Sabrina Mantaci, Antonio Restivo, Giovanna Rosone, and Marinella Sciortino. Suffixes, Conjugates and Lyndon Words. In Marie-Pierre Béal and Olivier Carton, editors, Developments in Language Theory, pages 131–142, Berlin, Heidelberg, 2013. Springer Berlin Heidelberg. doi:10.1007/978-3-642-38771-5_13.
  • [9] Silvia Bonomo, Sabrina Mantaci, Antonio Restivo, Giovanna Rosone, and Marinella Sciortino. Sorting conjugates and suffixes of words in a multiset. International Journal of Foundations of Computer Science, 25(08):1161–1175, 2014. doi:10.1142/S0129054114400309.
  • [10] Christina Boucher, Davide Cenzato, Zsuzsanna Lipták, Massimiliano Rossi, and Marinella Sciortino. Computing the original eBWT faster, simpler, and with less memory. In International Symposium on String Processing and Information Retrieval, pages 129–142. Springer, 2021. doi:10.1007/978-3-030-86692-1_11.
  • [11] Christina Boucher, Travis Gagie, Alan Kuhnle, Ben Langmead, Giovanni Manzini, and Taher Mun. Prefix-free parsing for building big BWTs. Algorithms for Molecular Biology, 14:1–15, 2019. doi:10.1186/s13015-019-0148-5.
  • [12] Christina Boucher, Travis Gagie, I Tomohiro, Dominik Köppl, Ben Langmead, Giovanni Manzini, Gonzalo Navarro, Alejandro Pacheco, and Massimiliano Rossi. PHONI: Streamed matching statistics with multi-genome references. In 2021 Data Compression Conference, pages 193–202. IEEE, 2021. doi:10.1109/dcc50243.2021.00027.
  • [13] Michael Burrows and David Wheeler. A block-sorting lossless data compression algorithm. Digital SRC Research Report, 124, 1994.
  • [14] Davide Cenzato and Zsuzsanna Lipták. A survey of BWT variants for string collections. Bioinformatics, 40(7):btae333, 2024. doi:10.1093/bioinformatics/btae333.
  • [15] Kuo Tsai Chen, Ralph H. Fox, and Roger C. Lyndon. Free differential calculus, iv. the quotient groups of the lower central series. Annals of Mathematics, pages 81–95, 1958. doi:10.2307/1970044.
  • [16] Maxime Crochemore and Luís M.S. Russo. Cartesian and Lyndon trees. Theoretical Computer Science, 806, 2020. doi:10.1016/j.tcs.2018.08.011.
  • [17] Diego Díaz-Domínguez and Gonzalo Navarro. Efficient construction of the BWT for repetitive text using string compression. Information and Computation, 294:105088, 2023. doi:10.1016/j.ic.2023.105088.
  • [18] Jean-Pierre Duval. Factorizing words over an ordered alphabet. Journal of Algorithms, 4(4):363–381, 1983. doi:10.1016/0196-6774(83)90017-2.
  • [19] Jonas Ellert. Lyndon Arrays Simplified. In Shiri Chechik, Gonzalo Navarro, Eva Rotenberg, and Grzegorz Herman, editors, 30th Annual European Symposium on Algorithms, volume 244 of Leibniz International Proceedings in Informatics, pages 48:1–48:14, Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ESA.2022.48.
  • [20] Paolo Ferragina and Giovanni Manzini. Indexing compressed text. Journal of the ACM (JACM), 52(4):552–581, 2005. doi:10.1145/1082036.1082039.
  • [21] Frantisek Franek, ASM Sohidull Islam, M Sohel Rahman, and William F Smyth. Algorithms to Compute the Lyndon Array. In Jan Holub and Jan Žďárek, editors, Prague Stringology Conference, pages 172–184, 2016. URL: http://www.stringology.org/event/2016/p15.html.
  • [22] Travis Gagie, Gonzalo Navarro, and Nicola Prezza. Optimal-time text indexing in BWT-runs bounded space. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1459–1477. SIAM, 2018. doi:10.1137/1.9781611975031.96.
  • [23] Joseph Yossi Gil and David Allen Scott. A bijective string sorting transform, 2012. doi:10.48550/arXiv.1201.3077.
  • [24] Guy Jacobson. Space-efficient static trees and graphs. In 30th Annual Symposium on Foundations of Computer Science, pages 549–554, Los Alamitos, CA, USA, 1989. IEEE Computer Society. doi:10.1109/sfcs.1989.63533.
  • [25] Tsuruta Kazuya, Köppl Dominik, Nakashima Yuto, Inenaga Shunsuke, Bannai Hideo, Takeda Masayuki, Tsuruta Kazuya, Köppl Dominik, Nakashima Yuto, Inenaga Shunsuke, Bannai Hideo, and Takeda Masayuki. Grammar-compressed Self-index with Lyndon Words. Information Processing Society of Japan, 13:84–92, 2020. URL: https://ipsj.ixsq.nii.ac.jp/records/206700.
  • [26] Dominik Kempa and Nicola Prezza. At the roots of dictionary compression: string attractors. In Proceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing, Stoc 2018, pages 827–840, New York, NY, USA, 2018. Association for Computing Machinery. doi:10.1145/3188745.3188814.
  • [27] Manfred Kufleitner. On bijective variants of the burrows-wheeler transform. In Jan Holub and Jan Žďárek, editors, Prague Stringology Conference, pages 65–79, Czech Technical University in Prague, Czech Republic, 2009. URL: http://www.stringology.org/event/2009/p07.html.
  • [28] Ben Langmead and Steven L Salzberg. Fast gapped-read alignment with Bowtie 2. Nature methods, 9(4):357–359, 2012. doi:10.1038/nmeth.1923.
  • [29] Heng Li. BWT construction and search at the terabase scale. Bioinformatics, 40(12):btae717, 2024. doi:10.1093/bioinformatics/btae717.
  • [30] Heng Li and Richard Durbin. Fast and accurate short read alignment with Burrows–Wheeler transform. bioinformatics, 25(14):1754–1760, 2009. doi:10.1093/bioinformatics/btp324.
  • [31] Felipe A. Louza, Sabrina Mantaci, Giovanni Manzini, Marinella Sciortino, and Guilherme P. Telles. Inducing the Lyndon Array. In Nieves R. Brisaboa and Simon J. Puglisi, editors, String Processing and Information Retrieval, pages 138–151, Cham, 2019. Springer International Publishing. doi:10.1007/978-3-030-32686-9_10.
  • [32] Sabrina Mantaci, Antonio Restivo, G. Rosone, and Marinella Sciortino. An Extension of the Burrows Wheeler Transform and Applications to Sequence Comparison and Data Compression. In Alberto Apostolico, Maxime Crochemore, and Kunsoo Park, editors, 16th Annual Symposium on Combinatorial Pattern Matching, pages 178–189. Springer, 2005. doi:10.1007/11496656_16.
  • [33] Sabrina Mantaci, Antonio Restivo, Giovanna Rosone, and Marinella Sciortino. Sorting Suffixes of a Text via its Lyndon Factorization. In Jan Holub and Jan Zdárek, editors, Prague Stringology Conference, pages 119–127, 2013. URL: http://www.stringology.org/event/2013/p11.html.
  • [34] Sabrina Mantaci, Antonio Restivo, Giovanna Rosone, and Marinella Sciortino. Suffix array and Lyndon factorization of a text. Journal of Discrete Algorithms, 28:2–8, 2014. doi:10.1016/j.jda.2014.06.001.
  • [35] Francesco Masillo. Matching Statistics Speed up BWT Construction. In Inge Li Gørtz, Martin Farach-Colton, Simon J. Puglisi, and Grzegorz Herman, editors, 31st Annual European Symposium on Algorithms, volume 274 of Leibniz International Proceedings in Informatics, pages 83:1–83:15, Dagstuhl, Germany, 2023. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ESA.2023.83.
  • [36] Lucas Mercier and Philippe Chassaing. The height of the Lyndon tree. Discrete Mathematics & Theoretical Computer Science, DMTCS Proceedings vol. AS, 25th International Conference on Formal Power Series and Algebraic Combinatorics (FPSAC 2013), January 2013. doi:10.46298/dmtcs.2357.
  • [37] Ge Nong, Sen Zhang, and Wai Hong Chan. Linear Suffix Array Construction by Almost Pure Induced-Sorting. In 2009 Data Compression Conference, pages 193–202, 2009. doi:10.1109/dcc.2009.42.
  • [38] Jannik Olbrich. lg. Software, swhId: swh:1:dir:0274cae4abb893b49bc035ef3a57986a418afe40 (visited on 2025-09-04). URL: https://gitlab.com/qwerzuiop/lyndongrammar, doi:10.4230/artifacts.24673.
  • [39] Jannik Olbrich, Enno Ohlebusch, and Thomas Büchler. On the Optimisation of the GSACA Suffix Array Construction Algorithm. In Diego Arroyuelo and Barbara Poblete, editors, String Processing and Information Retrieval, pages 99–113, Cham, 2022. Springer International Publishing. doi:10.1007/978-3-031-20643-6_8.
  • [40] Jannik Olbrich, Enno Ohlebusch, and Thomas Büchler. Generic Non-recursive Suffix Array Construction. ACM Transactions on Algorithms, 20(2):18, 2024. doi:10.1145/3641854.
  • [41] Marco Oliva, Travis Gagie, and Christina Boucher. Recursive prefix-free parsing for building big BWTs. In 2023 data compression conference, pages 62–70. IEEE, 2023. doi:10.1109/DCC55655.2023.00014.
  • [42] Yoshimasa Takabatake, Tomohiro I, and Hiroshi Sakamoto. A Space-Optimal Grammar Compression. In Kirk Pruhs and Christian Sohler, editors, 25th Annual European Symposium on Algorithms, volume 87 of Leibniz International Proceedings in Informatics (LIPIcs), pages 67:1–67:15, Dagstuhl, Germany, 2017. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ESA.2017.67.