An Extension of Linear-size Suffix Tries for Parameterized Strings
Katsuhito Nakashima, Diptarama Hendrian, Ryo Yoshinaka, Ayumi, Shinohara

TL;DR
This paper introduces PLSTs, a new linear-size indexing structure for parameterized strings, enabling efficient pattern matching and improved space efficiency on repetitive data.
Contribution
It generalizes linear-size suffix tries to parameterized strings, providing a linear-time pattern matching algorithm and demonstrating space efficiency improvements.
Findings
PLSTs enable linear-time parameterized pattern matching.
PLSTs are more space-efficient than parameterized suffix trees on repetitive strings.
The structure combines features of suffix tries and suffix trees for parameterized strings.
Abstract
In this paper, we propose a new indexing structure for parameterized strings which we call PLSTs, by generalizing linear-size suffix tries for ordinary strings. Two parameterized strings are said to match if there is a bijection on the symbol set that makes the two coincide. PLSTs are applicable to the parameterized pattern matching problem, which is to decide whether the input parameterized text has a substring that matches the input parameterized pattern. The size of PLSTs is linear in the text size, with which our algorithm solves the parameterized pattern matching problem in linear time in the pattern size. PLSTs can be seen as a compacted version of parameterized suffix tries and a combination of linear-size suffix tries and parameterized suffix trees. We experimentally show that PLSTs are more space efficient than parameterized suffix trees for highly repetitive strings.
| random strings | ||||
| constant string | p-string | |||
| length | Type 1 | Type 2 | Type 1 | Type 2 |
| 10 | 16.98 | 6.04 | 16.93 | 5.23 |
| 20 | 35.66 | 12.78 | 35.72 | 12.27 |
| 40 | 74.58 | 27.25 | 74.53 | 26.22 |
| 80 | 153.61 | 56.82 | 153.48 | 56.04 |
| 160 | 312.37 | 115.55 | 312.45 | 115.24 |
| 320 | 631.40 | 234.55 | 631.27 | 235.32 |
| 640 | 1270.34 | 477.29 | 1270.47 | 475.34 |
| 1280 | 2549.35 | 956.18 | 2549.39 | 957.03 |
| 2560 | 5108.37 | 1923.62 | 5108.48 | 1922.97 |
| 5120 | 10227.48 | 3845.35 | 10227.29 | 3853.97 |
| 10240 | 20466.49 | 7710.50 | 20466.14 | 7704.25 |
| Thue-Morse strings | ||||
|---|---|---|---|---|
| constant string | p-string | |||
| length | Type 1 | Type 2,3 | Type 1 | Type 2,3 |
| 17 | 28 | 10 | 29 | 6 |
| 33 | 56 | 14 | 57 | 8 |
| 65 | 112 | 18 | 113 | 10 |
| 129 | 224 | 22 | 225 | 12 |
| 257 | 448 | 26 | 449 | 14 |
| 513 | 896 | 30 | 897 | 16 |
| 1025 | 1792 | 34 | 1793 | 18 |
| 2049 | 3584 | 38 | 3585 | 20 |
| 4097 | 7168 | 42 | 7169 | 22 |
| 8193 | 14336 | 46 | 14337 | 24 |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAlgorithms and Data Compression · Network Packet Processing and Optimization · Natural Language Processing Techniques
An Extension of Linear-size Suffix Tries for Parameterized Strings
Katsuhito Nakashima
Graduate School of Information Sciences, Tohoku University, Japan
Diptarama Hendrian
Graduate School of Information Sciences, Tohoku University, Japan
Ryo Yoshinaka
Graduate School of Information Sciences, Tohoku University, Japan
Ayumi Shinohara
Graduate School of Information Sciences, Tohoku University, Japan
Abstract
In this paper, we propose a new indexing structure for parameterized strings which we call PLSTs, by generalizing linear-size suffix tries for ordinary strings. Two parameterized strings are said to match if there is a bijection on the symbol set that makes the two coincide. PLSTs are applicable to the parameterized pattern matching problem, which is to decide whether the input parameterized text has a substring that matches the input parameterized pattern. The size of PLSTs is linear in the text size, with which our algorithm solves the parameterized pattern matching problem in linear time in the pattern size. PLSTs can be seen as a compacted version of parameterized suffix tries and a combination of linear-size suffix tries and parameterized suffix trees. We experimentally show that PLSTs are more space efficient than parameterized suffix trees for highly repetitive strings.
1 Introduction
The pattern matching problem is to check whether a pattern string occurs in a text string or not. To efficiently solve the pattern matching problem, a numerous number of text indexing structures have been proposed. Suffix trees are most widely used data structures and provide many applications including several variants of pattern matching problems [5, 11]. They can be seen as a compacted type of suffix tries, where two branching nodes that have no other branching nodes between them in a suffix trie are directly connected in the suffix tree. The new edges have a reference to an interval of the text so that the original path label of the suffix trie can be recovered. Recently, Crochemore et al. [6] proposed a new indexing structure, called a linear-size suffix trie (LST), which is another compacted variant of a suffix trie. An LST replaces paths consisting only of non-branching nodes by edges like a suffix tree, but the original path labels are recovered by referring to other edge labels in the LST itself unlike suffix trees. LSTs use less memory space than suffix trees for indexing the same highly repetitive strings [takagi2017linear]. LSTs may be used as an alternative of suffix trees for various applications, like computing the longest common substrings, not limited to the pattern matching problem.
On the other hand, different types of pattern matching have been proposed and intensively studied. The variant this paper is concerned with is the parameterized pattern matching problem, introduced by Baker [3]. Considering two disjoint sets of symbols and , we call a string over a parameterized string (p-string). In the parameterized pattern matching problem, given p-strings and , we must check whether substrings of that can be transformed into by applying a one-to-one function that renames symbols in . The parameterized pattern matching is motivated by applying to the software maintenance [1, 3], the plagiarism detection [9], the analysis of gene structure [14], and so on. Similarly to the basic string matching problem, several indexing structures that support the parameterized pattern matching have been proposed, such as parameterized suffix trees [3], structural suffix trees [14], parameterized suffix arrays [7, 12], and parameterized position heaps [8, 10].
In this paper, we propose a new indexing structure for p-strings, which we call PLST. A PLST is a tree structure that combines a linear-size suffix trie and a parameterized suffix tree for prev-encoded [3] suffixes of a p-string. We show that the size of a PLST is and give an algorithm for the parameterized pattern matching problem for given a pattern and a PLST, to find the occurrences of a pattern in the text, that runs in time, where is the length of the text and is the length of the pattern. Furthermore, we experimentally show that PLSTs are more space efficient than parameterized suffix trees for highly repetitive strings such as Fibonacci strings.
2 Preliminaries
2.1 Basic definitions and notation
We denote the set of all non-negative integers by . Let be an alphabet. For a string , , , and are called prefix, substring, and suffix of , respectively. The length of is denoted by and the -th symbol of is denoted by for . The substring of that begins at position and ends at position is denoted by for . For convenience, we abbreviate to and to for . The empty string is denoted by , that is . Moreover, let if . For a string and an extension , we write .
Throughout this paper, we fix two alphabets and . We call elements of constant symbols and those of parameter symbols. An element of is called a constant string and that of is called a parameterized string, or p-string for short. We assume that the size of and are constant.
Given two p-strings and of length , and are a parameterized match (p-match), denoted by , if there is a bijection on such that for any and for all [3]. We can determine whether or not by using an encoding called prev-encoding defined as follows.
Definition 1** (Prev-encoding [3]).**
For a p-string of length over , the prev-encoding for , denoted by , is defined to be a string over of length such that for each ,
[TABLE]
We call strings over pv-strings.
For any p-strings and , if and only if . For example, given and , and are p-matches by such that and , where .
We define parameterized pattern matching as follows.
Definition 2** (Parameterized pattern matching [3]).**
Given two p-strings, text and pattern , decide whether has a substring that p-matches .
For example, considering a text and a pattern over and , has two substrings and that p-match .
Throughout this paper, we assume that a text ends with a sentinel symbol \texttt{\}\in\SigmaT$.
2.2 Suffix tries, suffix trees, and linear-size suffix tries
This subsection briefly reviews tree structures for indexing all the substrings of a constant string .
The suffix trie is a tree with nodes corresponding to all the substrings of . Figure 1 (a) shows an example of a suffix trie. Throughout this paper, we identify a node with its corresponding string for explanatory convenience. Note that each node does not explicitly remember its corresponding string. For each nonempty substring of where , we have an edge from to labeled with . Then by reading the labels on the path from the root to a node , one can obtain the string the node corresponds. Then the path label from the node to a descendant is for . Since there are substrings of , the size of is .
The suffix tree is a tree obtained from by removing all non-branching internal nodes and replacing each path with no branching nodes by a single edge whose label refers to a corresponding interval of the text . That is, the label on the edge is a pair such that . Since there are at most branching nodes, the size of is .
An important auxiliary map on nodes is called suffix links, denoted by , which is defined by for each node with and .
The linear-size suffix trie (LST) [6] of a string is another compact variant of a suffix trie (see Figure 1 (b)). An LST suppresses (most) non-branching nodes and replaces paths with edges like a suffix tree, but the labels of those new edges do not refer to intervals of the input text. Each edge retains only the first symbol of the original path label . To recover the original label , we refer to another edge or a path in the LST itself following a suffix link, using the fact that . The reference will be recursive, but eventually one can regain the original path label by collecting those retained symbols. For this sake, keeps some non-branching internal nodes from and thus it may have more nodes than , but still the size is linear in . The nodes of consist of those of and non-branching node whose suffix links point at a branching node. We call the former Type 1 and the latter Type 2. Each edge has a 1-bit flag that tells whether . If it is the case, one knows the complete label . Otherwise, one needs to follow the suffix link to regain the other symbols. An LST uses suffix links to regain the original path label in the suffix trie. If we had only Type 1 nodes, for some edge , there may be a branching node between and , which makes it difficult to regain the original path label. Having Type 2 nodes, there is no branching node between and for every edge . Then it is enough to go straight down from to regain the original path label.
2.3 Parameterized suffix tries and parameterized suffix trees
For a p-string , a prev-encoded substring (pv-substring) of is the prev-encoding of a substring of . The set of pv-substrings of is denoted by .
A parameterized suffix trie of , denoted by , is the trie that represents all the pv-substrings of . The size of is .
For a pv-string , the -re-encoding for , denoted by , is defined to be the pv-string of length such that for each ,
[TABLE]
When , we omit . We then have for any p-string and .
Usually suffix links are defined on nodes of suffix trees, but it is convenient to have “implicit suffix links” on all nodes except the root of , i.e., all the nonempty substrings of , as well. For a nonempty pv-string , let denote the re-encoding of the string obtained by deleting the first symbol. This operation on strings will define real suffix links in indexing structures for parameterized strings based on parameterized suffix tries. Differently from constant strings, does not necessarily imply . What we actually have is .
A parameterized suffix tree (p-suffix tree) [3] of , denoted by , is a compacted variant of the parameterized suffix trie. Figure 2 shows an example of a p-suffix tree. Like the suffix tree for a constant string over , is obtained from by removing non-branching internal nodes and giving each edge as a label a reference to some interval of the prev-encoded text . The reference is represented by a triple of a text start position, end position, and suffix number, which refers to the pv-string .
3 PLSTs
We now introduce our indexing tree structures for p-strings, which we call PLSTs, based on LSTs and p-suffix trees reviewed in Sections 2.2 and 2.3. There are two difficulties in extending LSTs to deal with p-strings. Figure 3(a) shows the LST-like structure obtained from in the same way as is obtained from . We want to know for an edge by “reduction by suffix links”, but
it is not necessarily that , 2. 2.
there can be a branching node of such that is not branching.
An example edge exhibiting the first difficulty consists of and v=00\mathtt{b}3\texttt{\}{\mathsf{str}({u},{v}})=\texttt{b}3\texttt{$}{\mathsf{str}({\mathsf{sl}(u)},{\mathsf{sl}(v)}})=\texttt{b}0\texttt{$}\mathsf{sl}(u)=\langle u[2:]\rangle\mathsf{sl}(u)=u[2:]{\mathsf{str}({\mathsf{sl}(u)},{\mathsf{sl}(v)}})v{\mathsf{str}({u},{v}}){\mathsf{str}({\mathsf{sl}(u)},{\mathsf{sl}(v)}})00\mathtt{ab}\langle\mathsf{sl}(00\mathtt{ab})\rangle=0\mathtt{ab}T$ by keeping the necessary subsequence, where, as we will observe in experiments, the necessary subsequence is tend to be rather small. Our proposed structure PLST is shown in Figure 3(b). In what follows we explain PLSTs.
3.1 Definition and properties of PLSTs
Let be the set of nodes of . The set of nodes of the PLST for is a subset of , which is partitioned as . Nodes in are called Type for . The definition of Type 1 and Type 2 nodes follows the one for original LSTs [6].
A node is Type 1 if is a leaf or a branching node in . 2. 2.
A node is Type 2 if and .
Edges of are trivially determined: we have as an edge if and only if and there is no proper nonempty prefix of such that . We will show in Section 3.3 that . We say that is good if , and is bad otherwise. Note that any is good by the definition of , and that the root is bad.
To obtain for an edge , if , we simply read the edge label like an LST. Otherwise, if both and are good, we basically use the technique of “reduction by suffix links”. An important observation is that the equation , which was a key property to regain the original label in (non-parameterized) LSTs, does not necessarily hold for PLSTs. Figure 5 shows an example, where ; the third symbol in is re-encoded to [math] in , because the first symbol of , that is referenced by the symbol , is cut out in . Fortunately, the possible difference between and is limited.
Observation 1**.**
Any prev-encoded substring of text has at most one position such that . For such a position , we have and for any , . Thus, such a position is unique in for each edge in .
For each edge , we associate an integer named re-encoding sign, so that we can regain from as follows.
Definition 3** (Re-encoding sign).**
For each node , let be the parent of . We define re-encoding sign to by
[TABLE]
The re-encoding sign is well-defined by Observation 1. Figure 5 shows an example of re-encoding signs. The next lemma immediately follows from Observation 1 and Definition 3.
Lemma 1**.**
Let be an edge in such that both and are good. Then for any , . If , then and .
Lemma 1 tells how to recover from using the re-encoding sign at and the depth of . Note that the depth is the depth of in parameterized suffix tries, not the number of nodes from the root to in PLSTs.
If either or is bad in an edge with , we give up “reduction by suffix links” and simply label the edge with the reference to the corresponding substring of the original text , like p-suffix trees. However, differently from p-suffix trees, not every part of the original text is referenced by an edge in our case. We keep only the subsequence of obtained by removing parts that are not referred to. We label an edge connected to a bad node with an integer triple such that .
In summary, consists of three kinds of nodes: good Type 1, bad Type 1, and Type 2 (all good). If is a good node, has its depth, suffix link and re-encoding sign, i.e., the triple , where . Here we use the notation to emphasize that the suffix link is a pointer to the node corresponding to the string rather than the string itself. Therefore, it requires only constant size of memory space. If is bad, dose not have a suffix link, i.e., has the triple . Each edge has either a label character or triple; if both and are good or , the edge label is . Otherwise, the edge label is a triple such that . If some bad nodes appear in , we need the subsequence of to recover the labels of edges connecting the bad nodes. Otherwise, we do not need any text.
We remark that another idea to overcome the problem of the absence of in a PLST for a node might be to add to for all so that is closed under , where and . However, there exists a series of texts T_{n}=\mathtt{x}_{1}\mathtt{a}_{1}\dots\mathtt{x}_{n}\mathtt{a}_{n}\mathtt{x}_{1}\mathtt{a}_{1}\dots\mathtt{x}_{n}\mathtt{a}_{n}\mathtt{y}_{1}\mathtt{a}_{1}\dots\mathtt{y}_{n}\mathtt{a}_{n}\mathtt{z}\$$ where \mathtt{x}{i},\mathtt{y}{i},\mathtt{z}\in\Pi\mathtt{a}{i}\in\Sigmai\Omega(|T{n}|^{2})$. Thus, the size of the index structures cannot be kept in linear.
3.2 Parameterized pattern matching with PLSTs
This subsection presents our algorithm for solving the parameterized pattern matching problem as an application of PLSTs. The function P-Match of Algorithm 1 takes a prev-encoded string and a node in and checks whether there is such that . If it is the case, it returns the least extension of such that . In other words, is a prefix of , where should be itself if . Otherwise, it returns .
For an input pair , if , then P-Match returns , as it is required. Otherwise, it first tries to regain for the -child of , if has such a child. At first, suppose . We would like to know whether . If , it means that we have already confirmed that . Then we just go down to and recursively call . If and either or is bad, we refer to and check if as with matching in a p-suffix tree. If and both and are good, we cannot know from the edge itself what is except for its first symbol . To recover whole , we use the suffix link of . Since is good, is defined. If , we have by Lemma 1, and we simply call . Otherwise, we have if and only if and , where
[TABLE]
for . Thus, the recursive call of returns iff . If returns a node, then and thus we continue matching by calling .
The above discussion is valid when . If or , then is a prefix of iff is a prefix of . Otherwise, is a prefix of iff and is a prefix of . Thus the recursion is justified. If returns a node, is a prefix of and we call , which returns .
Proposition 1**.**
We can decide whether has a substring that p-matches using Algorithm 1.
The time complexity of Algorithm 1 is not linear as it is. Suppose that is called. It can be the case and either or where . In this case, the algorithm simply calls , where the first argument has not changed from the preceding call. Such recursion may be repeated, and amortized time complexity is not linear. The same difficulty and a solution have already been discussed by Crochemore et al. [6] for LSTs. Following them, we introduce fast links as follows, which allow us to skip recursions that always preserve the first argument.
Definition 4** (Fast link).**
For each edge such that and both , are good, the fast link for is defined to be where is the smallest integer satisfying either or , where for .
Algorithm 1 will run in linear time by replacing in Line 1 by . If , the node occurs between and . Then, will call . When , we change the -th symbol of , which must be a positive integer, to [math]. Therefore, the number of fast links we follow is bounded by . Figure 5 shows how to p-match and using fast links. We know that . After following the fast link (1), we check whether and rewrite the value of to [math]. After using (2), we check whether . In this way, we can know that matches .
Theorem 1**.**
Given and a pattern of length , we can decide whether has a substring that p-matches in time.
3.3 The size of PLSTs
We now show that the size of is linear with respect to the length of a text . First, we show a linear upper bound on the number of nodes of . The nodes of Type 1 appear in the p-suffix tree, so they are at most [3]. It is enough to show that the number of nodes of Type 2 is linearly bounded as well.
Lemma 2**.**
The number of Type 2 nodes in is smaller than .
Proof.
Let us consider an implicit suffix link chain in starting from with , i.e., . has such chains and every internal node of appears in at least one chain. If a chain has two distinct Type 2 nodes and with , since is Type 1 by definition, one can always find a Type 1 node between them.
Define a binary relation between and by
[TABLE]
and let . Since is a partial function from branching nodes to Type 2 nodes, we have . By the above argument on a chain, each chain has at most one Type 2 node such that . Since there are chains, we have . All in all, . ∎∎
The number of edges and their labels, as well as the number of suffix links, depth and re-encoding sign for nodes, is asymptotically bounded above by the number of nodes in . is a subsequence of , thus its length is . Therefore, the size of is .
Theorem 2**.**
Given a p-string of length , the size of is .
4 Experiments
We performed comparative experiments on the number of nodes of PLSTs and p-suffix trees for four sorts of text strings changing their length. Text strings we used are random strings over a constant alphabet with and those over a parameter alphabet with , and Fibonacci strings over with and those over with . PLSTs for constant strings are of course identical to LSTs. For random strings, we measured the average number of nodes for 100 strings of each length . For Fibonacci strings, we measured the number of nodes for each of the 11th through 22nd Fibonacci strings. The results of our experiments are shown in Table 1. Recall that p-suffix trees consist of Type 1 nodes, while PLSTs have Type 2 nodes in addition. For random strings, we can see that the number of Type 2 nodes is close to the text length. On the other hand, for Fibonacci strings, PLSTs have few Type 2 nodes. In these experiments, since no bad node appeared except the root, PLSTs did not need any text, that is, .
Because the size of each node is the same in a p-suffix tree and a PLST, the difference of the memory efficiency of the two data structures is just the difference of the memory size for and the Type 2 nodes (and if necessary). The experimental results suggest that PLSTs use less memory than p-suffix trees for indexing highly repetitive strings such as Fibonacci strings.
5 Conclusion and future work
In this paper, we presented an indexing structure called a PLST for the parameterized pattern matching problem. Given a p-string of length , the size of PLST for is . We presented an algorithm that solves the problem in time, where is the length of the pattern. We experimentally showed that PLST is space-saving from p-suffix tree for indexing highly repetitive strings such as Fibonacci strings.
For PLSTs to be useful for various applications, like computing the longest common substrings, an efficient algorithm for constructing PLSTs is required like LSTs [onlineLST]. Furthermore, the ideas developed in this paper may be useful to generalize L-CDAWGs [takagi2017linear] to a data structure for parameterized strings.
Appendix A Appendix
A.1 The implicit suffix link closure of branching nodes is too big
We show that the total number of nodes of the form for some cannot be linearly bounded by . Let us consider a text
[TABLE]
where and for each . Note that . Here
[TABLE]
is a Type 1 node, since . Then the set has elements. Therefore, we cannot keep our indexing structure in linear size. Figure 6 illustrates the case of , where twelve additional nodes are created.
A.2 Other experiments
We performed comparative experiments on the numbers of nodes of PLSTs and p-suffix trees for texts in addition to random and Fibonacci strings. The results of our experiments for Thue-Morse strings and Period-doubling strings are shown in Tables 2. For Thue-Morse strings and Period-doubling strings, our data structure only have a limited number of additional nodes. The Fibonacci strings, Thue-Morse strings and Period-doubling strings are defined as follows.
The -th Fibonacci string is defined by the following recurrence:
[TABLE]
The -th Thue-Morse string can be obtained by applying the following homomorphism to times:
[TABLE]
The -th Period-doubling string can be obtained by applying the following homomorphism to times:
[TABLE]
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Brenda S. Baker. A program for identifying duplicated code. Computing Science and Statistics , 24:49–57, 1992.
- 2[2] Brenda S. Baker. A theory of parameterized pattern matching: algorithms and applications. In Proc. 25th annual ACM symposium on Theory of computing , pages 71–80, 1993. doi:10.1145/167088.167115 . · doi ↗
- 3[3] Brenda S. Baker. Parameterized pattern matching: Algorithms and applications. Journal of Computer and System Sciences , 52(1):28–42, 1996. doi:10.1006/jcss.1996.0003 . · doi ↗
- 4[4] Brenda S. Baker. Parameterized duplication in strings: Algorithms and an application to software maintenance. SIAM Journal on Computing , 26(5):1343–1362, 1997.
- 5[5] M. Crochemore and W. Rytter. Jewels of Stringology: Text Algorithms . World Scientific, 2003.
- 6[6] Maxime Crochemore, Chiara Epifanio, Roberto Grossi, and Filippo Mignosi. Linear-size suffix tries. Theoretical Computer Science , 638:171–178, 2016.
- 7[7] Satoshi Deguchi, Fumihito Higashijima, Hideo Bannai, Shunsuke Inenaga, and Masayuki Takeda. Parameterized suffix arrays for binary strings. In Proceedings of the Prague Stringology Conference 2008 , pages 84–94, Czech Technical University in Prague, Czech Republic, 2008.
- 8[8] Diptarama, Takashi Katsura, Yuhei Otomo, Kazuyuki Narisawa, and Ayumi Shinohara. Position heaps for parameterized strings. In 28th Annual Symposium on Combinatorial Pattern Matching (CPM 2017) , pages 8:1–8:13, 2017.
