Gonzalo Navarro, Francisco Olivares, Cristian Urbina
{"title":"Generalized straight-line programs","authors":"Gonzalo Navarro, Francisco Olivares, Cristian Urbina","doi":"10.1007/s00236-025-00481-3","DOIUrl":null,"url":null,"abstract":"<div><p>It was recently proved that any straight-line program (SLP) generating a given string can be transformed in linear time into an equivalent balanced SLP of the same asymptotic size. We generalize this proof to a general class of grammars we call generalized SLPs (GSLPs), which allow rules of the form <span>\\(A \\rightarrow x\\)</span> where <i>x</i> is any Turing-complete representation (of size |<i>x</i>|) of a sequence of symbols (potentially much longer than |<i>x</i>|). We then specialize GSLPs to so-called Iterated SLPs (ISLPs), which allow rules of the form <span>\\(A \\rightarrow \\Pi _{i=k_1}^{k_2} B_1^{i^{c_1}}\\cdots B_t^{i^{c_t}}\\)</span> of size <span>\\(\\mathcal {O}(t)\\)</span>. We prove that ISLPs break, for some text families, the measure <span>\\(\\delta \\)</span> based on substring complexity, a lower bound for most measures and compressors exploiting repetitiveness. Further, ISLPs can extract any substring of length <span>\\(\\lambda \\)</span>, from the represented text <span>\\(T[1\\mathinner {.\\,.}n]\\)</span>, in time <span>\\(\\mathcal {O}(\\lambda + \\log ^2 n\\log \\log n)\\)</span>. This is the first compressed representation for repetitive texts breaking <span>\\(\\delta \\)</span> while, at the same time, supporting direct access to arbitrary text symbols in polylogarithmic time. We also show how to compute some substring queries, like range minima and next/previous smaller value, in time <span>\\(\\mathcal {O}(\\log ^2 n \\log \\log n)\\)</span>. Finally, we further specialize the grammars to run-length SLPs (RLSLPs), which restrict the rules allowed by ISLPs to the form <span>\\(A \\rightarrow B^t\\)</span>. Apart from inheriting all the previous results with the term <span>\\(\\log ^2 n \\log \\log n\\)</span> reduced to the near-optimal <span>\\(\\log n\\)</span>, we show that RLSLPs can exploit balancedness to efficiently compute a wide class of substring queries we call “composable”—i.e., <span>\\(f(X \\cdot Y)\\)</span> can be obtained from <i>f</i>(<i>X</i>) and <i>f</i>(<i>Y</i>). As an example, we show how to compute Karp-Rabin fingerprints of texts substrings in <span>\\(\\mathcal {O}(\\log n)\\)</span> time. While the results on RLSLPs were already known, ours are much simpler and require little precomputation time and extra data associated with the grammar.</p></div>","PeriodicalId":7189,"journal":{"name":"Acta Informatica","volume":"62 1","pages":""},"PeriodicalIF":0.4000,"publicationDate":"2025-02-13","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Acta Informatica","FirstCategoryId":"94","ListUrlMain":"https://link.springer.com/article/10.1007/s00236-025-00481-3","RegionNum":4,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q4","JCRName":"COMPUTER SCIENCE, INFORMATION SYSTEMS","Score":null,"Total":0}
引用次数: 0
Abstract
It was recently proved that any straight-line program (SLP) generating a given string can be transformed in linear time into an equivalent balanced SLP of the same asymptotic size. We generalize this proof to a general class of grammars we call generalized SLPs (GSLPs), which allow rules of the form \(A \rightarrow x\) where x is any Turing-complete representation (of size |x|) of a sequence of symbols (potentially much longer than |x|). We then specialize GSLPs to so-called Iterated SLPs (ISLPs), which allow rules of the form \(A \rightarrow \Pi _{i=k_1}^{k_2} B_1^{i^{c_1}}\cdots B_t^{i^{c_t}}\) of size \(\mathcal {O}(t)\). We prove that ISLPs break, for some text families, the measure \(\delta \) based on substring complexity, a lower bound for most measures and compressors exploiting repetitiveness. Further, ISLPs can extract any substring of length \(\lambda \), from the represented text \(T[1\mathinner {.\,.}n]\), in time \(\mathcal {O}(\lambda + \log ^2 n\log \log n)\). This is the first compressed representation for repetitive texts breaking \(\delta \) while, at the same time, supporting direct access to arbitrary text symbols in polylogarithmic time. We also show how to compute some substring queries, like range minima and next/previous smaller value, in time \(\mathcal {O}(\log ^2 n \log \log n)\). Finally, we further specialize the grammars to run-length SLPs (RLSLPs), which restrict the rules allowed by ISLPs to the form \(A \rightarrow B^t\). Apart from inheriting all the previous results with the term \(\log ^2 n \log \log n\) reduced to the near-optimal \(\log n\), we show that RLSLPs can exploit balancedness to efficiently compute a wide class of substring queries we call “composable”—i.e., \(f(X \cdot Y)\) can be obtained from f(X) and f(Y). As an example, we show how to compute Karp-Rabin fingerprints of texts substrings in \(\mathcal {O}(\log n)\) time. While the results on RLSLPs were already known, ours are much simpler and require little precomputation time and extra data associated with the grammar.
期刊介绍:
Acta Informatica provides international dissemination of articles on formal methods for the design and analysis of programs, computing systems and information structures, as well as related fields of Theoretical Computer Science such as Automata Theory, Logic in Computer Science, and Algorithmics.
Topics of interest include:
• semantics of programming languages
• models and modeling languages for concurrent, distributed, reactive and mobile systems
• models and modeling languages for timed, hybrid and probabilistic systems
• specification, program analysis and verification
• model checking and theorem proving
• modal, temporal, first- and higher-order logics, and their variants
• constraint logic, SAT/SMT-solving techniques
• theoretical aspects of databases, semi-structured data and finite model theory
• theoretical aspects of artificial intelligence, knowledge representation, description logic
• automata theory, formal languages, term and graph rewriting
• game-based models, synthesis
• type theory, typed calculi
• algebraic, coalgebraic and categorical methods
• formal aspects of performance, dependability and reliability analysis
• foundations of information and network security
• parallel, distributed and randomized algorithms
• design and analysis of algorithms
• foundations of network and communication protocols.