Straight-line grammar (with start symbol ß) for the second sentence of the
United States Declaration of Independence. Each blue character denotes a
nonterminal symbol; they were obtained from a
gzip-compression of the sentence.
Grammar-based codes or grammar-based compression are compression algorithms based on the idea of constructing a context-free grammar (CFG) for the string to be compressed. Examples include universal lossless data compression algorithms. To compress a data sequence G.
The problem of finding a smallest grammar for an input sequence (smallest grammar problem) is known to be NP-hard, so many grammar-transform algorithms are proposed from theoretical and practical viewpoints.
Generally, the produced grammar
↑ Kieffer, J. C.; Yang, E.-H. (2000), "Grammar-based codes: A new class of universal lossless source codes", IEEE Trans. Inf. Theory, 46 (3): 737–754, Bibcode:2000ITIT...46..737K, doi:10.1109/18.841160
↑ Ziv, J.; Lempel, A. (1978), "Compression of individual sequences via variable rate coding", IEEE Trans. Inf. Theory, 24 (5): 530–536, Bibcode:1978ITIT...24..530Z, doi:10.1109/TIT.1978.1055934, hdl:10338.dmlcz/142945
↑ Conrad, Kennon J.; Wilson, Paul R. (2016). "Grammatical Ziv-Lempel Compression: Achieving PPM-Class Text Compression Ratios with LZ-Class Decompression Speed". 2016 Data Compression Conference (DCC). p. 586. doi:10.1109/DCC.2016.119. ISBN 978-1-5090-1853-6. S2CID 3116024.