A Universal Grammar-Based Code for Lossless Compression of Binary Trees

Jie Zhang, En-Hui Yang, John C. Kieffer

This 2013 paper by Jie Zhang, En-hui Yang, and John C. Kieffer presents a rigorous theoretical framework for the lossless compression of binary trees. By bridging the gap between formal grammar theory and information theory, the authors develop a "universal" code—one that achieves optimal compression across a wide variety of tree-generating processes without needing to know the specific underlying probability distribution in advance.

TL;DR

The authors propose a two-step, grammar-based algorithm that transforms a binary tree into a context-free grammar (CFG) and then encodes that grammar into a binary string. They prove that this method is "asymptotically optimal," meaning its efficiency approaches the theoretical limit (entropy) as trees grow larger, making it a universal solution for various probabilistic tree models.

What Problem Does This Paper Address?

In information theory, we have well-established "universal" codes for strings (like Lempel-Ziv/LZ77), but extending these concepts to structured data like trees is non-trivial. Most existing tree compression methods are either ad-hoc or designed for specific types of trees.

The challenge lies in the "structure" itself. How do you define a "source" that produces trees? How do you measure the redundancy of a code when the data isn't a simple sequence of symbols? The authors tackle these questions by defining a general framework for "structure sources" and seeking a code that can compress binary trees efficiently regardless of whether they were generated by a leaf-centric process, a depth-centric process, or other probabilistic models.

Methods

The proposed compression algorithm operates in two distinct stages:

  1. Tree-to-Grammar Transformation: The binary tree is converted into a deterministic context-free grammar (CFG). This is essentially equivalent to finding the minimal Directed Acyclic Graph (DAG) representation of the tree. If a subtree appears multiple times within the larger tree, the grammar represents it once and assigns it a variable. This step exploits the internal structural redundancy of the tree.
  2. Grammar Encoding: The resulting grammar is then converted into a binary codeword. This isn't just a simple bit-mapping; the authors use a sophisticated combinatorial approach. They partition the grammar's production rules into sequences and use enumerative encoding (assigning an index to a specific permutation in a sorted list of all possible permutations) to represent the grammar as compactly as possible.

The decoder simply reverses these steps: it reconstructs the grammar from the bits and then "expands" the grammar to recover the original binary tree.

Datasets

As a theoretical paper in information theory, this work does not use empirical datasets (like web crawls or genomic data). Instead, it uses probabilistic source models to evaluate performance:

  • The Gilbert Model: A classic random graph model adapted for trees.
  • Leaf-Centric Sources: Models where the probability of a tree depends on the number of leaves in its subtrees (e.g., the Bisection model).
  • Depth-Centric Sources: Models where the probability depends on the maximum path length (depth) of subtrees.

Key Insights and Ideas

  • The Minimal DAG Connection: The "aha moment" is realizing that a deterministic CFG that generates exactly one tree is functionally identical to a minimal DAG. Compression, therefore, becomes a task of identifying and "deduplicating" identical subtrees.
  • The Representation Ratio ($r(t)$): The authors define $r(t)$ as the ratio of the number of unique subtrees (grammar variables) to the total number of leaves. They show that compression performance is directly tied to this ratio; the more "repetitive" the tree's structure, the better the grammar-based code performs.
  • Universal Optimality: The paper proves that if a tree source satisfies two conditions—the Domination Property (probabilities are bounded by a specific class of functions) and the Representation Ratio Negligibility (RRN) Property—the grammar-based code will be asymptotically optimal.

Key Results

  • Theorem 1 (Performance Bound): The authors provide a concrete upper bound for the codeword length $L[\phi_e(t)]$, showing it is bounded by a function of the number of variables in the grammar and the empirical entropy of the production rules.
  • Universality Proofs: The paper successfully proves that the code is universal for broad subfamilies of both leaf-centric and depth-centric binary tree sources.
  • Redundancy Convergence: Mathematically, they demonstrate that the "average redundancy" (the extra bits used beyond the theoretical minimum) vanishes as the size of the tree approaches infinity.

Limitations and Future Work

  • The RRN Property: While the Domination Property is relatively easy to verify, the Representation Ratio Negligibility (RRN) property is more mathematically "troublesome" to prove for some complex sources.
  • Skewed Trees: The authors note that "one-dimensional" trees (highly skewed trees where subtrees rarely repeat) are a difficult case for this specific grammar-based approach, as there is little structural redundancy to exploit.
  • Extension to Branching Processes: The authors suggest that future work will investigate scenarios involving branching processes, which are common in biology and physics, to see if the RRN property holds there as well.

Summary updated

BibTeX
@article{zhang2014universal,
  author = {Jie Zhang and En-Hui Yang and John C. Kieffer},
  title = {{A Universal Grammar-Based Code for Lossless Compression of Binary Trees}},
  journal = {IEEE Trans. Information Theory},
  year = {2014},
  doi = {10.1109/tit.2013.2295392},
}
Figure