Abstract
In this paper, a fully compressed pattern matching problem is studied. The compression is represented by straight-line programs (SLPs), i.e. a context-free grammars generating exactly one string; the term fully means that both the pattern and the text are given in the compressed form. A novel technique of dealing with SLPs is introduced and applied: the SLPs are recompressed, so that substrings of the pattern and text are encoded in both SLPs in the same way. To this end, the SLPs are locally decompressed and then recompressed in a uniform way. This technique yields an O((n+m) log M log(n+m) log log(n+m)) algorithm for compressed pattern matching, where n is the size of the compressed representation of the text, similarly m is size of the compressed representation of pattern, while M is the size of the decompressed pattern. Since M <= 2^m, this greatly improves the previously best O(m^2 n) algorithm. Since LZ compression standard reduces to SLP with log(N / n) overhead and in O(n log(N/n)) time, the presented algorithm can be straightforwardly applied also to the fully LZ-compressed pattern matching problem, yielding an O(S log S log log S \log M) running time algorithm, where S = n \log(N/n) + m \log(M/m).