<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Grammar-based_code</id>
	<title>Grammar-based code - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Grammar-based_code"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Grammar-based_code&amp;action=history"/>
	<updated>2026-05-04T22:23:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Grammar-based_code&amp;diff=2166275&amp;oldid=prev</id>
		<title>imported&gt;Ringo62: ce</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Grammar-based_code&amp;diff=2166275&amp;oldid=prev"/>
		<updated>2025-05-18T03:19:11Z</updated>

		<summary type="html">&lt;p&gt;ce&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Lossless data compression algorithm}}&lt;br /&gt;
[[File:IndpGrm.gif|thumb|600px|[[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.]]&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Grammar-based codes&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;grammar-based compression&amp;#039;&amp;#039;&amp;#039; are [[Data compression|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.&amp;lt;ref&amp;gt;{{Citation | last1 = Kieffer  | first1 =  J. C.  | last2 = Yang | first2 = E.-H. | title = Grammar-based codes: A new class of universal lossless source codes | journal = IEEE Trans. Inf. Theory | volume = 46 | pages = 737–754 | year = 2000 | doi = 10.1109/18.841160 | issue = 3 }}&amp;lt;/ref&amp;gt; To compress a data sequence &amp;lt;math&amp;gt;x = x_1 \cdots x_n&amp;lt;/math&amp;gt;, a grammar-based code transforms &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; into a context-free grammar &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
The problem of finding a smallest grammar for an input sequence ([[smallest grammar problem]]) is known to be NP-hard,&amp;lt;ref&amp;gt;{{Citation | last1 = Charikar  | first1 =  M.  | last2 = Lehman | first2 = E. | last3 = Liu | first3 = D. | last4 = Panigrahy | first4 = R. | last5 = Prabharakan | first5 = M. | last6 = Sahai | first6 = A. | last7 = Shelat | first7 = A. |  title = The Smallest Grammar Problem | journal = IEEE Trans. Inf. Theory | volume = 51 | pages = 2554–2576 | year = 2005 | issue = 7 | doi=10.1109/tit.2005.850116| s2cid = 6900082 }}&amp;lt;/ref&amp;gt; so many grammar-transform algorithms are proposed from theoretical and practical viewpoints.&lt;br /&gt;
Generally, the produced grammar &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is further compressed by statistical encoders like [[arithmetic coding]].&lt;br /&gt;
&lt;br /&gt;
== Examples and characteristics ==&lt;br /&gt;
The class of grammar-based codes is very broad. It includes [[block code]]s, the multilevel pattern matching (MPM) algorithm,&amp;lt;ref&amp;gt;{{Citation | last1 = Kieffer | first1 = J. C. | last2 = Yang | first2 = E.-H.  | last3 = Nelson | first3 = G. | last4 = Cosman | first4 = P. | title = Universal lossless compression via multilevel pattern matching | journal = IEEE Trans. Inf. Theory | volume = 46 | pages = 1227–1245 | year = 2000 | doi = 10.1109/18.850665 | issue = 4 | s2cid = 8191526 | url = https://escholarship.org/uc/item/39k54514 }}&amp;lt;/ref&amp;gt; variations of the incremental parsing [[LZ77 and LZ78|Lempel-Ziv code]],&amp;lt;ref&amp;gt;{{Citation | last1 = Ziv | first1 = J. | last2 = Lempel | first2 = A. | title = Compression of individual sequences via variable rate coding | journal = IEEE Trans. Inf. Theory | volume = 24 | pages = 530–536 | year = 1978 | doi = 10.1109/TIT.1978.1055934 | issue = 5 | hdl = 10338.dmlcz/142945 | hdl-access = free }}&amp;lt;/ref&amp;gt; and many other new universal lossless compression algorithms.&lt;br /&gt;
Grammar-based codes are universal in the sense that they can achieve asymptotically the [[entropy rate]] of any stationary, [[ergodic]] source with a finite alphabet.&lt;br /&gt;
&lt;br /&gt;
== Practical algorithms ==&lt;br /&gt;
The compression programs of the following are available from external links.&lt;br /&gt;
&lt;br /&gt;
* [[SEQUITUR algorithm|Sequitur]]&amp;lt;ref&amp;gt;{{Citation | last1 = Nevill-Manning  | first1 =  C. G.  | last2 = Witten | first2 = I. H. | title = Identifying Hierarchical Structure in Sequences: A linear-time algorithm | journal =  Journal of Artificial Intelligence Research | volume = 7 | pages = 67–82 | year = 1997 | doi = 10.1613/jair.374| issue = 4 | hdl=10289/1186| arxiv = cs/9709102 | s2cid = 2957960 }}&amp;lt;/ref&amp;gt; is a classical grammar compression algorithm that sequentially translates an input text into a CFG, and then the produced CFG is encoded by an arithmetic coder.&lt;br /&gt;
* [[Re-Pair]]&amp;lt;ref&amp;gt;{{Citation | last1 = Larsson  | first1 =  N. J.  | last2 = Moffat | first2 = A. | title = Offline Dictionary-Based Compression | journal =  Proceedings of the IEEE| volume = 88 | pages = 1722–1732| year = 2000 | issue = 11 | doi=10.1109/5.892708| url = http://www.davidsalomon.name/DC4advertis/BPE.pdf }}&amp;lt;/ref&amp;gt; is a greedy algorithm using the strategy of most-frequent-first substitution. The compressive performance is powerful, although the main memory space requirement is very large.&lt;br /&gt;
* [[GLZA]],&amp;lt;ref&amp;gt;{{Cite book| last1 = Conrad  | first1 =  Kennon J. | last2 = Wilson | first2 = Paul R. | title = 2016 Data Compression Conference (DCC) | chapter = Grammatical Ziv-Lempel Compression: Achieving PPM-Class Text Compression Ratios with LZ-Class Decompression Speed | pages = 586 | year = 2016 | doi=10.1109/DCC.2016.119| isbn = 978-1-5090-1853-6 | s2cid = 3116024 }}&amp;lt;/ref&amp;gt; which constructs a grammar that may be reducible, i.e., contain repeats, where the entropy-coding cost of &amp;quot;spelling out&amp;quot; the repeats is less than the cost creating and entropy-coding a rule to capture them. (In general, the compression-optimal SLG is not irreducible, and the Smallest Grammar Problem is different from the actual SLG compression problem.)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Dictionary coder]]&lt;br /&gt;
*[[Grammar induction]]&lt;br /&gt;
* [[Straight-line grammar]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{reflist|30em}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[https://encode.su/threads/2427-GLZA GLZA discussion and paper]&lt;br /&gt;
*[https://www.mit.edu/~6.454/www_fall_2002/emin/summary.pdf Description of grammar-based codes with example]&lt;br /&gt;
*[http://sequitur.info Sequitur codes] {{Webarchive|url=https://web.archive.org/web/20081013024323/http://www.sequitur.info/ |date=2008-10-13 }} &lt;br /&gt;
*[http://www.cbrc.jp/~rwan/en/restore.html Re-Pair codes]&lt;br /&gt;
*[http://www.dcc.uchile.cl/~gnavarro/software/index.html Re-Pair codes] a version of Gonzalo Navarro.&lt;br /&gt;
*[https://github.com/GrammarViz2/grammarviz2_src GrammarViz 2.0] - implementation of Sequitur, Re-Pair, and parallel Re-Pair in Java.&lt;br /&gt;
&lt;br /&gt;
{{Compression methods}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Data compression]]&lt;br /&gt;
[[Category:Coding theory]]&lt;br /&gt;
[[Category:Information theory]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Ringo62</name></author>
	</entry>
</feed>