The Generalized Smallest Grammar Problem

Payam Siyari, Matthias Gallé

Introduction

The intersection of data compression and linguistic structure has long been a subject of academic interest. While compression algorithms aim to represent data in the most compact form possible, linguistics seeks to uncover the underlying rules that govern language. This paper addresses the "Smallest Grammar Problem" (SGP) by introducing a generalized framework that moves beyond traditional "straight-line" programs to non-recursive grammars. This approach not only achieves state-of-the-art compression but also identifies syntactic structures that align closely with real-world language patterns.

The Smallest Grammar Problem and Its Limitations

The SGP asks for the smallest context-free grammar that generates exactly one specific sequence. Historically, solutions to this problem have relied on straight-line programs (SLPs)—lists of substitutions without branching or generalization capabilities. While effective for data compression, SLPs often fail at grammatical inference. Because they lack the ability to represent choices or variations (e.g., "The [car/bike] is fast"), the rules they generate rarely correspond to meaningful linguistic units like noun phrases. The authors aim to fix this by allowing grammars to be "non-recursive" rather than just "straight-line," introducing the ability to represent variations within the grammar itself.

Methodology: A Generalized Approach

The authors propose a framework based on the Minimum Description Length (MDL) principle, aiming to minimize the sum of the grammar's size and the cost of specifying the original sequence given that grammar. Key technical contributions include:

  1. Non-Recursive Context-Free Grammars: Unlike SLPs, these grammars allow "branching," where a non-terminal can lead to multiple different strings. This introduces ambiguity, which is resolved at a specific encoding cost to reconstruct the original sequence.
  2. Fixed-Length Motifs: To manage the search space, the algorithm focuses on motifs of the form $u.^k v$—sequences sharing a common prefix ($u$) and suffix ($v$) with a fixed-length middle section ($k$).
  3. Post-Processing Algorithm: The most successful implementation involves a post-processing step that takes a grammar compressed by standard SGP solvers (like Greedy, IRRMGP, or ZZ) and greedily merges rules into branching ones to optimize compression.

Experimental Setup

The proposed methods were evaluated across three distinct data types: genomic sequences (DNA Corpus), a classic compression benchmark (Canterbury Corpus), and annotated English text (Penn Treebank).

Characteristics of the DNA and Canterbury Corpus datasets used for evaluation.

The table above details the sequences used in the study, ranging from DNA fragments to source code and spreadsheets. These datasets provide a rigorous testing ground for both compression efficiency and the ability to capture diverse structural patterns across different domains.

Key Results and Discussion

The post-processing method consistently outperformed state-of-the-art SGP solvers across nearly all benchmarks. A notable result was observed with the kennedy.xls file, a binary spreadsheet, where the algorithm achieved a massive reduction in size (from approximately 166k symbols down to 98k) by capturing the repetitive structure of spreadsheet cells.

Beyond raw compression, the algorithm demonstrated significant linguistic accuracy. On the Penn Treebank, the branching rules discovered had a precision of 50-60% in identifying correct syntactic brackets. For comparison, standard SGP rules only achieved about 21% precision. This suggests that by allowing for ambiguity and context-based substitution, the algorithm effectively "learns" structural properties of English, aligning with the Distributional Hypothesis in linguistics.

Conclusion and Future Work

While the results are promising, several limitations remain. The algorithm currently exhibits high precision but low recall, meaning it identifies accurate structures but misses many others. Additionally, the current model is constrained to fixed-length motifs, as variable-length motifs introduced too much overhead in the current encoding scheme. Future research will focus on capturing more complex, variable-length patterns and exploring why specific file types, like spreadsheets, respond so exceptionally well to this generalized grammar approach.

Summary updated

BibTeX
@inproceedings{siyari2016generalized,
  author = {Payam Siyari and Matthias Gallé},
  title = {{The Generalized Smallest Grammar Problem}},
  booktitle = {ICGI},
  year = {2016},
}
Figure