
Nested Regular Expressions can be Compiled to Small Deterministic Nested Word Automata Iovka Boneva, Joachim Niehren, Momar Sakho To cite this version: Iovka Boneva, Joachim Niehren, Momar Sakho. Nested Regular Expressions can be Compiled to Small Deterministic Nested Word Automata. CSR 2020 - 15th International Computer Science Symposium in Russia, Jun 2020, Ekaterinburg, Russia. hal-02532706v2 HAL Id: hal-02532706 https://hal.inria.fr/hal-02532706v2 Submitted on 19 Jul 2020 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Nested Regular Expressions can be Compiled to Small Deterministic Nested Word Automata Iovka Boneva1, Joachim Niehren2, and Momar Sakho1;2 1 Universit´ede Lille, 2 Inria Lille, France Abstract. We study the problem of whether regular expressions for nested words can be compiled to small deterministic nested word au- tomata (NWAs). In theory, we obtain a positive answer for small deter- ministic regular expressions for nested words. In practice of navigational path queries, nondeterministic NWAs are obtained for which NWA de- terminization explodes. We show that practical good solutions can be obtained by using stepwise hedge automata as intermediates. Keywords: Automata · Regular Expressions · Nested Words · XPath 1 Introduction Nested words are nested structures omnipresent in computer science. They were used in particular to represent data trees or Xml documents, or to analyze the call structure of recursive programs. The idea of nested words is to generalize words and unranked trees at the same time. Nested words can be obtained by enriching Dyck words with internal letters, besides opening and closing paren- theses. Nested words can also be defined recursively as the elements of the least set that contains internal letters from a given alphabet, triples consisting of an opening parenthesis, a nested word, and a closing parenthesis, and all sequences of nested words. Alternatively, nested words can be specified as finite sequences of internal letters, opening parentheses and closing parentheses. Only well-nested sequences are permitted in which every opening parenthesis is properly closed and every closing parenthesis is properly opened. Or else, nested words can be identified with sequences of unranked trees, which are often called hedges. From the viewpoint of formal language theory, the natural question is how to lift and relate the notions of finite automata and regular expressions for words and trees to the case of nested words. Automata for nested words (NWAs) are well studied [1,3,23] and also known as visibly pushdown automata. While having the same expressiveness as hedge automata [26,10], which generalize tree automata from ranked to unranked trees, they are often defined as pushdown automata with visible stacks, meaning that exactly one symbol is pushed when reading an opening parenthesis, and exactly one symbol is popped when reading a closing parenthesis, while the stack is not used otherwise. Their main advantage is a powerful notion of determinism, generalizing both over bottom-up and top- down determinism of tree automata for ranked trees [1]. In contrast to more general pushdown automata, NWAs permit determinization, basically since they are so closely related to tree automata. 2 I. Boneva, J. Niehren and M. Sakho Regular expressions for nested words were first introduced under the name of regular expression types by Hosoya et al. in the context of the Xml pro- gramming language XDuce [19]. We will call them nested regular expressions (NREs) instead. Independently, more complex notions of regular expressions were proposed [21,25] that can also deal to some extent with generalizations of nested words, in which dangling opening and closing parentheses are permitted. It was already claimed in [19], that NREs have the same expressiveness as hedge automata [26,10], which in turn have the same expressiveness as NWAs [1]. How- ever, the question under which conditions nested words can be compiled to small deterministic NWAs has not been studied. Whenever possible, one can decide language inclusion or equivalence in P. Otherwise, these problems may not be feasible since EXP-complete for general NWAs or NREs. Our concrete interest in the universality of deterministic NWAs is moti- vated by Xml stream processing: we want to compute the certain answers of a CoreXPath query on an Xml stream [24,15], i.e., those elements that are se- lected in all possible futures of the stream. Whether an answer is certain is computationally hard for tiny syntactic fragments of CoreXPath [4,15], but can be done in polynomial time for queries defined by deterministic NWAs [16]. A natural question is therefore, whether it is possible to compile CoreXPath queries as in the usual benchmark [14] to deterministic NWAs of reasonable size. Unfortunately, the existing compilers fail to do so [12], since they are based on NWA determinization for dealing with disjunction, negation, and recursive steps. Thereby they produce huge deterministic automata even for very simple CoreXPath queries from the benchmark, or do not terminate after some hours. In this paper, we consider NREs for defining queries on nested words, since there exist compilers that can map the CoreXPath queries from the usual bench- mark to NREs of reasonable size, under the condition that the path query contains only forwards steps. We then distinguish a subclass of \deterministic" NREs that can be complied in polynomial time to deterministic NWAs by gener- alizing on Glushkov's construction of deterministic finite-state automata (Dfas) from \deterministic" regular expressions [6,7]. However, the NREs obtained by compilation from CoreXPath queries are rarely deterministic, so neither are the NWAs obtained from them by direct compilation. Neither can we apply NWA determinization to them as argued above. We show that deterministic NWAs can be obtained nevertheless based on stepwise hedge automata (SHAs), that we in- troduce. SHAs combine stepwise tree automata [8] for unranked trees with finite state automata on words (Nfas). They can be determinized in a bottom-up and left-to-right manner, simply by combining the determinization procedures for tree automata and for Nfas. Furthermore, we can compile deterministic SHAs to deterministic NWAs in polynomial time. Conversely, NWAs can be compiled to SHAs in polynomial time too, but at the cost of introducing nondeterminism. By composing these compilers and determinization algorithms, NREs can be compiled to deterministic NWAs in the following two manners. The first method is to compile the NRE to an SHA, from there to an NWA, which is then determinized. The second way consists of compiling the NRE to an SHA, determinize it, and convert the result to a deterministic NWA. In an experimen- tal study, we consider a collection of NREs that we constructed automatically Small dNWAs for Nested Regular Expressions 3 from CoreXPath queries in the XMark benchmark [14]. It turns out a little sur- prisingly that both above algorithms yield a satisfactory solution: they produce small deterministic NWAs for all NREs in our collection. The sizes of the de- terministic may differ, sometimes in favor of the one or the other algorithm. We also discuss, why the NWA determinization behaves reasonably for the NWAs obtained from SHAs, while it behaved so badly for NWAs obtained directly from NREs. The reason seems to be that the former NWAs in contrast to the latter have the single entry property, which basically states that the NWA performs all its work in a bottom-up and left-to-right manner, and none when moving top-down. This conjecture is supported by practical evidence rather than some formal statement. Related Work. CoreXPath [17] is a fragment of nested regular path queries on data trees, in which recursion is restricted to basic steps up, down, left and right. Nested regular path queries were introduced in the seventies [13] under the name of the propositional dynamic logic (PDL). There they were applied to general labeled graphs, rather than being restricted to data trees. Since certain query answering for CoreXPath was considered as difficult, the currently existing approaches to CoreXPath evaluation on Xml streams [12,24] either approximate certain query answers based on nondeterministic machines or restrict the queries so that answers certainty can be decided without latency [22,4]. This also holds for recent streaming algorithms on words without nesting in the context of complex event processing [18]. 2 Nested Words Nested words are words with parentheses that are well-nested. They can be identified with hedges, that is sequences of internal symbols and unranked trees. Nested words are constructed with an opening and a closing parentheses, respectively h and i. An unranked alphabet Σ is a possibly infinite set of so called \internal" symbols, that does not contain the two parentheses. Nested words over Σ then have the following abstract syntax: h; h0 ::= " j a j hhi j h · h0 where a 2 Σ The empty word is denoted by " and assumed to satisfy "·h = h = h·". Nested words can be identified with hedges, hi c hi i.e., words of trees and internal symbols. Seen as a graph, the inner nodes are labeled by the tree constructor hi and a hi d hi the leafs by symbols in Σ or the tree constructor. For in- stance ha · hbi · "i · c · hd · h"ii corresponds to the hedge on b the right. A nested word of type tree has the form hhi.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages22 Page
-
File Size-