Skip to main content
QUICK REVIEW

[Paper Review] Practical and Effective Re-Pair Compression

Philip Bille, Inge Li Gørtz|arXiv (Cornell University)|Apr 27, 2017
Algorithms and Data CompressionComputer Science2 references6 citations
TL;DR

This paper presents a practical and space-efficient implementation of Re-Pair compression that reduces working space to (1.5+ε)n words—including the text—while maintaining linear time complexity. It further introduces a novel grammar encoding strategy that achieves near-optimal compressibility, using only 2.8% more bits than the information-theoretic minimum on average, outperforming 7-Zip in half the tested cases.

ABSTRACT

Re-Pair is an efficient grammar compressor that operates by recursively replacing high-frequency character pairs with new grammar symbols. The most space-efficient linear-time algorithm computing Re-Pair uses $(1+ε)n+\sqrt n$ words on top of the re-writable text (of length $n$ and stored in $n$ words), for any constant $ε>0$; in practice however, this solution uses complex sub-procedures preventing it from being practical. In this paper, we present an implementation of the above-mentioned result making use of more practical solutions; our tool further improves the working space to $(1.5+ε)n$ words (text included), for some small constant $ε$. As a second contribution, we focus on compact representations of the output grammar. The lower bound for storing a grammar with $d$ rules is $\log(d!)+2d\approx d\log d+0.557 d$ bits, and the most efficient encoding algorithm in the literature uses at most $d\log d + 2d$ bits and runs in $\mathcal O(d^{1.5})$ time. We describe a linear-time heuristic maximizing the compressibility of the output Re-Pair grammar. On real datasets, our grammar encoding uses---on average---only $2.8\%$ more bits than the information-theoretic minimum. In half of the tested cases, our compressor improves the output size of 7-Zip with maximum compression rate turned on.

Motivation & Objective

  • To design a practical Re-Pair compression algorithm that reduces working space below the state of the art without sacrificing linear time complexity.
  • To improve the compressibility of the output grammar by exploiting structural properties of Re-Pair’s substitution process.
  • To achieve a grammar representation that is close to the information-theoretic lower bound of d log d + 0.557d bits.
  • To evaluate the trade-offs between compression ratio, working space, and running time in real-world datasets.
  • To demonstrate that grammar compression can outperform general-purpose compressors like 7-Zip on repetitive, highly-structured data.

Proposed method

  • The algorithm uses a novel, practical integer clustering procedure to efficiently manage frequency counts during Re-Pair’s recursive pair replacement.
  • It maintains a dynamic structure to track high-frequency adjacent pairs, enabling linear-time processing via amortized cost control.
  • A new grammar encoding technique is introduced that leverages the number M of distinct pair frequencies at substitution time, reducing the representation to d(log d + log M + 1) + M log(d/M) + o(d log d) bits.
  • The encoding is computed in O(d) time by exploiting the order of rule creation and frequency distribution in the Re-Pair process.
  • The implementation uses a space-optimized data structure that reduces working space to (1.5+ε)n words, including the input text.
  • The method includes amortized structural rebuilding to maintain space bounds while ensuring linear-time performance.

Experimental results

Research questions

  • RQ1Can Re-Pair compression be made both practical and space-efficient, reducing working space to (1.5+ε)n words while preserving linear time complexity?
  • RQ2Can the compressibility of the Re-Pair grammar output be maximized by exploiting the frequency distribution of pairs during substitution?
  • RQ3How close can a grammar representation come to the information-theoretic lower bound of d log d + 0.557d bits in practice?
  • RQ4Does the proposed grammar encoding outperform general-purpose compressors like 7-Zip on repetitive datasets?
  • RQ5What is the relationship between the number M of distinct pair frequencies and the compressibility of the final grammar representation?

Key findings

  • The proposed Re-Pair implementation uses only (1.5+ε)n words of working space, reducing the state of the art by a factor of two.
  • The grammar encoding uses, on average, only 2.8% more bits than the information-theoretic minimum, with very low variance across datasets.
  • In half of the tested datasets, the compressor outperforms 7-Zip with maximum compression, especially on repetitive files like 'english', 'boost', and 'fib41'.
  • The number M of distinct pair frequencies at substitution time is typically one to three orders of magnitude smaller than d, validating the design of the new encoding.
  • The decompression speed is competitive—faster than bzip2 and comparable to NAV and 7-Zip—except on highly repetitive files where it is one order of magnitude slower.
  • The compression rate is most effective on less compressible files, where the grammar representation achieves better relative compression.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.