<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Pseudovariety: String Rewriting Systems & the Knuth-Bendix Completion Algorithm]]></title><description><![CDATA[A short introduction to string rewriting, but just enough to get to the Knuth-Bendix algorithm.]]></description><link>https://pseudovariety.com/s/string-rewriting-systems-and-the</link><image><url>https://substackcdn.com/image/fetch/$s_!Lxrf!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ad4f314-8f59-468a-8bf4-e1a46d66a1f0_382x382.png</url><title>Pseudovariety: String Rewriting Systems &amp; the Knuth-Bendix Completion Algorithm</title><link>https://pseudovariety.com/s/string-rewriting-systems-and-the</link></image><generator>Substack</generator><lastBuildDate>Wed, 22 Apr 2026 09:08:49 GMT</lastBuildDate><atom:link href="https://pseudovariety.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Peter Alspaugh]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[pseudovariety@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[pseudovariety@substack.com]]></itunes:email><itunes:name><![CDATA[Peter Alspaugh]]></itunes:name></itunes:owner><itunes:author><![CDATA[Peter Alspaugh]]></itunes:author><googleplay:owner><![CDATA[pseudovariety@substack.com]]></googleplay:owner><googleplay:email><![CDATA[pseudovariety@substack.com]]></googleplay:email><googleplay:author><![CDATA[Peter Alspaugh]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[2. String Rewriting Systems]]></title><description><![CDATA[Definitions of string rewriting systems.]]></description><link>https://pseudovariety.com/p/2-string-rewriting-systems</link><guid isPermaLink="false">https://pseudovariety.com/p/2-string-rewriting-systems</guid><dc:creator><![CDATA[Peter Alspaugh]]></dc:creator><pubDate>Fri, 04 Jul 2025 23:50:11 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!kexk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A <em>string rewriting system</em>, also known as an abstract reduction system or abstract rewriting system,<em> </em>is a pair consisting of an alphabet A and a set of rewriting rules R, where R is a relation</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\mathcal{R}\\subseteq A^*\\times A^*.&quot;,&quot;id&quot;:&quot;QPHMOHIPCW&quot;}" data-component-name="LatexBlockToDOM"></div><p>Here, A* denotes the free monoid generated by A, or the set of all strings over A equipped with concatenation of strings as its multiplication. It is not hard to see that concatenation is associative and the identity element is the empty word consisting of no letters, often denoted as</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\varepsilon&quot;,&quot;id&quot;:&quot;IYQFYUSXLN&quot;}" data-component-name="LatexBlockToDOM"></div><p>or &#8220;&#8220; for Python purposes. Note that rewriting rules are ordered pairs, meaning any rewriting happens in a specific order. We always assume that a word may rewrite to itself with precisely 0 applications of any rewriting rule.</p><p>Any string rewriting system defines a monoid presentation (or semigroup presentation, but we will focus on monoids) via the congruence closure of its set of rewriting rules. This provides a way to think about equivalence of words under the congruence as rewriting. Here, if two strings in A* are equal, such as a=b, then for any x and y in A* we have that xay=xby (by definition of congruence). We can say that xay rewrites to xby, denoted xay &#8594; xby or vice versa.</p><p>Now, let&#8217;s say that we have a monoid presentation and we would like to determine if two words are equal under the given presentation (or <em>solve the word problem</em> for that monoid). We could give a computer our presentation and tell it to determine if those words are equal by rewriting one into the other with the relations in the presentation like so: xaybz &#8594; xbybz &#8594; xbyaz (letting us conclude that xaybz=xbyaz). However, we will inevitably run into problems. For one, equalities in the presentation to not prescribe a direction for us to rewrite. Also, there are infinitely many ways that the rewritings could happen, or none at all (yet infinitely many ways we must rule out). </p><p>We then must make some specifications for the rewriting rules defined by a presentation. The following definition will be our most important.</p><h4>Definition: A rewriting system (A,R) is <em>Noetherian</em> if there does not exist any infinite sequence of words in A* such that</h4><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;x_1\\rightarrow x_2\\rightarrow x_3\\rightarrow\\cdots\\text{   (for }x_i\\in A^*,\\text{ }i\\in\\mathbb{Z^+)}&quot;,&quot;id&quot;:&quot;ATFXXNBSIP&quot;}" data-component-name="LatexBlockToDOM"></div><h4>and</h4><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\forall i\\in\\mathbb{Z}^+,\\text{ }x_i\\neq x_{i+1}.&quot;,&quot;id&quot;:&quot;JUQHLBWRZQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>That is, every rewriting of a word must terminate at some point. Any finite rewriting system (meaning one with a finite alphabet and finite set of rewriting rules) is Noetherian if it contains no &#8220;loops&#8220;, where there exist words x and y such that x&#8594;y and y&#8594;x using the rewriting rules in the system.</p><h4>Definition: A word which does not contain as a subword the left hand side of any rewriting rule is called <em>irreducible</em>. That is, it cannot be written by the given rewriting system. If x and y are two words such that x&#8594;y and y is irreducible, then we say that y is a normal form for x.</h4><p>Using just this definition a congruence class may contain several normal forms, or none at all! Luckily, we have the following theorems.</p><h4>Theorem: Every word (and thus congruence class) has a normal form under a Noetherian rewriting system.</h4><p>Proof: Let x be a word in A* and consider a sequence of rewritings of x which results in a word y. Since x has no normal form, y cannot be irreducible. Then y may be further rewritten, and hence x may be rewritten ad infinitum, so there exists an infinite sequence of rewritings of x (where each resulting word is not equal to the last). This contradicts the assumption that the rewriting system is Noetherian. &#9633;</p><h4>Definition: A rewriting system is <em>confluent</em> if for any word x in A*, if x rewrites to two words y and z, then there exists some word w such that y and z both rewrite to w. A rewriting system is <em>locally confluent</em> if for any x in A*, if x rewrites to both y and z with just one application of any rewriting rule, then y and z both rewrite to some w in A*.</h4><p>In the below diagram, I depict confluence and local confluence. Arrows with stars represent rewritings that may use zero or multiple rules, whereas arrows with no stars use precisely one rewriting rule. This notation is typical, but I neglect it in this series.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kexk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kexk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 424w, https://substackcdn.com/image/fetch/$s_!kexk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 848w, https://substackcdn.com/image/fetch/$s_!kexk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 1272w, https://substackcdn.com/image/fetch/$s_!kexk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kexk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png" width="903" height="470" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:470,&quot;width&quot;:903,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:29273,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://pseudovariety.com/i/167555724?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kexk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 424w, https://substackcdn.com/image/fetch/$s_!kexk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 848w, https://substackcdn.com/image/fetch/$s_!kexk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 1272w, https://substackcdn.com/image/fetch/$s_!kexk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3649b40-99b2-48c5-9a9b-5ed93cfab040_903x470.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h4>Theorem: A Noetherian rewriting system is confluent iff it is locally confluent.</h4><p>I do not give the proof of the theorem, but it should be accessible to the reader and can be found in Book &amp; Otto (1993).</p>]]></content:encoded></item><item><title><![CDATA[1. Semigroup Presentations]]></title><description><![CDATA[Recall the definitions of congruences, congruence closures, and presentations.]]></description><link>https://pseudovariety.com/p/1-semigroup-presentations</link><guid isPermaLink="false">https://pseudovariety.com/p/1-semigroup-presentations</guid><dc:creator><![CDATA[Peter Alspaugh]]></dc:creator><pubDate>Fri, 04 Jul 2025 22:58:49 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Lxrf!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ad4f314-8f59-468a-8bf4-e1a46d66a1f0_382x382.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>First, let us recall some basic algebraic definitions. A <em>semigroup</em> is a set which is closed under an associative binary operation, a <em>monoid</em> is a semigroup which contains an identity element, and a <em>group</em> is a monoid in which every element has a two-sided inverse.</p><p>A <em>semigroup homomorphism </em>is a map f between semigroups S and T such that for all r and s in S, f(rs)=f(r)f(s). A <em>congruence</em> is an equivalence relation on S such that for any two equivalence classes [r] and [s], if q is in [r] and t is in [s], then qt is in [rs]. That is, it is an equivalence relation that is compatible with the multiplication on S, so multiplication of equivalence classes is well-defined. Fundamentally, a partition of S into preimages of each element under a homomorphism defines a congruence (this generalizes the link between normal subgroups and homomorphisms in Group Theory).</p><p>Let </p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\mathcal{R}\\subseteq S^2&quot;,&quot;id&quot;:&quot;SUBZZTLYDW&quot;}" data-component-name="LatexBlockToDOM"></div><p>be a relation. The equivalence closure of R is the smallest equivalence relation on S containing R and the <em>congruence closure</em> of R is the smallest congruence on S containing R.</p><p>A <em>presentation</em> for a semigroup (resp. monoid, group, etc.) is a pair consisting of a set of generators X and a relation on the free semigroup (resp. monoid, group, etc.) generated by X (which is written F with a subscript X). It is usually written</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\langle X\\text{ }|\\text{ }\\mathcal{R}\\rangle.&quot;,&quot;id&quot;:&quot;UTOPZZDSHL&quot;}" data-component-name="LatexBlockToDOM"></div><p>The relation provided defines which words over X are equal to each other in the semigroup. Relations are often written using equalities rather than ordered pairs. Every presentation defines a semigroup S such that</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;S\\cong F_X/\\overline{\\mathcal{R}}&quot;,&quot;id&quot;:&quot;SIINWCAYOJ&quot;}" data-component-name="LatexBlockToDOM"></div><p>where R with an overset bar is the congruence closure of R.</p><p>Let us consider an example. We define a monoid with the following presentation (since it is a monoid, we take the free monoid generated by X rather than the free semigroup, so there is no need to specify the existence of the identity or include relations for it):</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\langle a \\text{ }|\\text{ } a^5=1 \\rangle.&quot;,&quot;id&quot;:&quot;GIKXYKEDDC&quot;}" data-component-name="LatexBlockToDOM"></div><p>This presentation defines the cyclic group of integers modulo 5.</p><p>Providing a presentation is a common way to define a semigroup, and perhaps the only way for a large or even infinite one. However, presentations can be impractical to work with computationally. Consider the following presentation for the <em>monoid</em> M:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\langle a,b \\text{ }|\\text{ } (ab)^2a^2=aba,\\text{ }b^2(ab)^2=a^2,\\text{ }b^2a=a,\\text{ }b^2ab=1,\\text{ }a^2=a \\rangle&quot;,&quot;id&quot;:&quot;WZKBEIMEUJ&quot;}" data-component-name="LatexBlockToDOM"></div><p>Could you tell that this actually defines the trivial group? if so, it probably took you a second. If you need proof, observe that </p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;b^2a=a\\text{ and }b^2ab=1\\text{ }\\Rightarrow\\text{ }ab=1\\Rightarrow b=a^{-1}.&quot;,&quot;id&quot;:&quot;EUCIQQVDTZ&quot;}" data-component-name="LatexBlockToDOM"></div><p>This means that a is contained in a subgroup of M with identity 1. Then, since a is idempotent, it must be the identity of M. Then b is also the identity, so the group is trivial.</p><p>Luckily, there are methods to make these computations easier. The focus of this series will be the Knuth-Bendix algorithm, which can extend a set of relations such that they can be used to rewrite any word into a unique <em>normal form </em>that represents the congruence class of that word defined by the presentation. However, this algorithm is not guaranteed to terminate, as when it does, it in effect solves the <em>word problem, </em>the undecidable problem of determining if two given words are equal under the presentation, for the semigroup it defines. In the subsequent posts in this series, I cover the basics of string rewriting systems before moving on to the Knuth-Bendix algorithm, for which I also provide a Python implementation.</p>]]></content:encoded></item></channel></rss>