Rewriting
In mathematics, linguistics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms.[src] Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or reduction systems).[8] In their most basic form, they consist of a set of objects, plus relations on how to transform those objects.[src] Rewriting can be non-deterministic.[src] One rule to rewrite a term could be applied in many different ways to that term, or more than one rule could be applicable.[src] Rewriting systems then do not provide an algorithm for changing one term to another, but a set of possible rule applications.[8] When combined with an appropriate algorithm, however, rewrite systems can be viewed as computer programs, and several theorem provers and declarative programming languages are based on term rewriting.[8]
In mathematics, linguistics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms.[src] Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or reduction systems).[8] In their most basic form, they consist of a set of objects, plus relations on how to transform those objects.[src] Rewriting can be non-deterministic.[src] One rule to rewrite a term could be applied in many different ways to that term, or more than one rule could be applicable.[src] Rewriting systems then do not provide an algorithm for changing one term to another, but a set of possible rule applications.[8] When combined with an appropriate algorithm, however, rewrite systems can be viewed as computer programs, and several theorem provers and declarative programming languages are based on term rewriting.[8] A string rewriting system (SRS), also known as semi-Thue system, exploits the free monoid structure of the strings (words) over an alphabet to extend a rewriting relation, R , to all strings in the alphabet that contain left- and respectively right-hand sides of some rules as substrings.[src] Formally a semi-Thue system is a tuple (\Sigma, R) where \Sigma is a (usually finite) alphabet, and R is a binary relation between some (fixed) strings in the alphabet, called the set of rewrite rules.[src] The one-step rewriting relation \underset{R}\rightarrow induced by R on \Sigma^* is defined as: if s, t \in \Sigma^* are any strings, then s \underset{R}\rightarrow t if there exist x, y, u, v \in \Sigma^* such that s = xuy , t = xvy , and u R v .[src] Since \underset{R}\rightarrow is a relation on \Sigma^* , the pair (\Sigma^*, \underset{R}\rightarrow) fits the definition of an abstract rewriting system.[src] Since the empty string is in \Sigma^* , R is a subset of \underset{R}\rightarrow .[src] If the relation R is symmetric, then the system is called a Thue system.[src] In a SRS, the reduction relation \overset{*}\underset{R}\rightarrow is compatible with the monoid operation, meaning that x \overset{*}\underset{R}\rightarrow y implies uxv \overset{*}\underset{R}\rightarrow uyv for all strings x, y, u, v \in \Sigma^* .[src] Similarly, the reflexive transitive symmetric closure of \underset{R}\rightarrow , denoted \overset{*}{\underset R \leftrightarrow} , is a congruence, meaning it is an equivalence relation (by definition) and it is also compatible with string concatenation.[src] The relation \overset{*}\underset{R} \leftrightarrow is called the Thue congruence generated by R .[src] In a Thue system, i.e.[src] if R is symmetric, the rewrite relation \overset{*}\underset{R}\rightarrow coincides with the Thue congruence \overset{*}{\underset R \leftrightarrow} .[src] The notion of a semi-Thue system essentially coincides with the presentation of a monoid.[src] Since \overset{*}{\underset R \leftrightarrow} is a congruence, we can define the factor monoid \mathcal{M}_R = \Sigma^*/\overset{*}{\underset R \leftrightarrow} of the free monoid \Sigma^* by the Thue congruence.[src] If a monoid \mathcal{M} is isomorphic with \mathcal{M}_R , then the semi-Thue system (\Sigma, R) is called a monoid presentation of \mathcal{M} .[src] We immediately get some very useful connections with other areas of algebra.[src] For example, the alphabet \{ a,b \} with the rules \{ ab \rightarrow \varepsilon, ba \rightarrow \varepsilon \} , where \varepsilon is the empty string, is a presentation of the free group on one generator.[src] If instead the rules are just \{ ab \rightarrow \varepsilon \} , then we obtain a presentation of the bicyclic monoid.[src] Thus semi-Thue systems constitute a natural framework for solving the word problem for monoids and groups.[9] In fact, every monoid has a presentation of the form (\Sigma, R) , i.e.[src] it may always be presented by a semi-Thue system, possibly over an infinite alphabet.[src] The word problem for a semi-Thue system is undecidable in general; this result is sometimes known as the Post–Markov theorem.[src] ===Formal definition === A rewrite rule is a pair of terms, commonly written as l \rightarrow r , to indicate that the left-hand side can be replaced by the right-hand side .[src] A term rewriting system is a set of such rules.[8] A rule l \rightarrow r can be applied to a term if the left term matches some subterm of , that is, if there is some substitution \sigma such that the subterm of s rooted at some position is the result of applying the substitution \sigma to the term .[src] The subterm matching the left hand side of the rule is called a redex or reducible expression.[src] The result term of this rule application is then the result of replacing the subterm at position in by the term r with the substitution \sigma applied, see picture 1.[src] In this case, s is said to be rewritten in one step, or rewritten directly, to t by the system R , formally denoted as s \rightarrow_R t , s \underset{R}\rightarrow t , or as s \overset{R}\rightarrow t by some authors.[src] If a term t_1 can be rewritten in several steps into a term t_n , that is, if t_1 \underset{R}\rightarrow t_2 \underset{R}\rightarrow \cdots \underset{R}\rightarrow t_n , the term t_1 is said to be rewritten to t_n , formally denoted as t_1 \overset{+}\underset{R}\rightarrow t_n .[src] In other words, the relation \overset{+}\underset{R}\rightarrow is the transitive closure of the relation \underset{R}\rightarrow ; often, also the notation \overset{*}\underset{R}\rightarrow is used to denote the reflexive-transitive closure of \underset{R}\rightarrow , that is, s \overset{*}\underset{R}\rightarrow t if s = t or A term rewriting given by a set R of rules can be viewed as an abstract rewriting system as defined above, with terms as its objects and \underset{R}\rightarrow as its rewrite relation.[8] For example, x*(y*z) \rightarrow (x*y)*z is a rewrite rule, commonly used to establish a normal form with respect to the associativity of * .[src] That rule can be applied at the numerator in the term \frac{a*((a+1)*(a+2))}{1*(2*3)} with the matching substitution \{ x \mapsto a, \; y \mapsto a+1, \; z \mapsto a+2 \} , see picture 2.[src] Applying that substitution to the rule's right-hand side yields the term (a*(a+1))*(a+2) , and replacing the numerator by that term yields \frac{(a*(a+1))*(a+2)}{1*(2*3)} , which is the result term of applying the rewrite rule.[src] Altogether, applying the rewrite rule has achieved what is called "applying the associativity law for * to \frac{a*((a+1)*(a+2))}{1*(2*3)} " in elementary algebra.[src] Alternately, the rule could have been applied to the denominator of the original term, yielding \frac{a*((a+1)*(a+2))}{(1*2)*3} .[src] ===Termination=== Termination issues of rewrite systems in general are handled in Abstract rewriting system#Termination and convergence.[11] For term rewriting systems in particular, the following additional subtleties are to be considered.[8] Termination even of a system consisting of one rule with a linear left-hand side is undecidable.[src] Termination is also undecidable for systems using only unary function symbols; however, it is decidable for finite ground systems.[11] The following term rewrite system is normalizing, but not terminating, and not confluent: \begin{align} f(x,x) & \rightarrow g(x) , \\ f(x,g(x)) & \rightarrow b , \\ h(c,x) & \rightarrow f(h(x,c),h(x,x)) .[src] \\ \end{align} The following two examples of terminating term rewrite systems are due to Toyama: f(0,1,x) \rightarrow f(x,x,x) and g(x,y) \rightarrow x, g(x,y) \rightarrow y.[11] Their union is a non-terminating system, since \begin{align} & f(g(0,1),g(0,1),g(0,1)) \\ \rightarrow & f(0,g(0,1),g(0,1)) \\ \rightarrow & f(0,1,g(0,1)) \\ \rightarrow & f(g(0,1),g(0,1),g(0,1)) \\ \rightarrow & \cdots \end{align} This result disproves a conjecture of Dershowitz, who claimed that the union of two terminating term rewrite systems R_1 and R_2 is again terminating if all left-hand sides of R_1 and right-hand sides of R_2 are linear, and there are no "overlaps" between left-hand sides of R_1 and right-hand sides of R_2 .[8] All these properties are satisfied by Toyama's examples.[src] See Rewrite order and Path ordering (term rewriting) for ordering relations used in termination proofs for term rewriting systems.[11] ==See also== Critical pair (logic) Compiler Knuth–Bendix completion algorithm L-systems specify rewriting that is done in parallel.[8] Referential transparency in computer science Regulated rewriting Interaction nets[src]
59 sentences · 59 cited inline · 11 references stored
References
- Sculthorpe, Neil. The Kansas University rewrite engine . · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Sculthorpe, Neil. The Kansas University rewrite engine ." Sculthorpe, Neil. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Sculthorpe, Neil. The Kansas University rewrite engine ." Sculthorpe, Neil. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA Sculthorpe, Neil. (2026). Sculthorpe, Neil. The Kansas University rewrite engine . Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- N. Dershowitz. Proc. RTA . Springer . 1985. · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "N. Dershowitz. Proc. RTA . Springer . 1985." N. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "N. Dershowitz. Proc. RTA . Springer . 1985." N. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA N. (2026). N. Dershowitz. Proc. RTA . Springer . 1985. Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Nipkow, Tobias. Automated Deduction - A Basis for Applic . · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Nipkow, Tobias. Automated Deduction - A Basis for Applic ." Nipkow, Tobias. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Nipkow, Tobias. Automated Deduction - A Basis for Applic ." Nipkow, Tobias. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA Nipkow, Tobias. (2026). Nipkow, Tobias. Automated Deduction - A Basis for Applic . Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Programming with Constraints: An Introduction . · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Programming with Constraints: An Introduction ." 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Programming with Constraints: An Introduction ." 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA encyclopegia.org. (2026). Programming with Constraints: An Introduction . Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Robert Freidin. Foundations of Generative Syntax . MIT Press . 1992. · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Robert Freidin. Foundations of Generative Syntax . MIT Press . 1992." Robert Freidin. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Robert Freidin. Foundations of Generative Syntax . MIT Press . 1992." Robert Freidin. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA Robert Freidin. (2026). Robert Freidin. Foundations of Generative Syntax . MIT Press . 1992. Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Signal Processing in the Pure Programming Language . · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Signal Processing in the Pure Programming Language ." 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Signal Processing in the Pure Programming Language ." 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA encyclopegia.org. (2026). Signal Processing in the Pure Programming Language . Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Pure – eine einfache funktionale Sprache . · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Pure – eine einfache funktionale Sprache ." 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Pure – eine einfache funktionale Sprache ." 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA encyclopegia.org. (2026). Pure – eine einfache funktionale Sprache . Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Klop, J. W. Term Rewriting Systems . Papers by Nachum Dershowitz and students . · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Klop, J. W. Term Rewriting Systems . Papers by Nachum Dershowitz and students ." Klop, J. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Klop, J. W. Term Rewriting Systems . Papers by Nachum Dershowitz and students ." Klop, J. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA Klop, J. (2026). Klop, J. W. Term Rewriting Systems . Papers by Nachum Dershowitz and students . Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Gerard Huet, D.S. Lankford. On the Uniform Halting Problem for Term Rewriting Systems . Mar 1978. · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Gerard Huet, D.S. Lankford. On the Uniform Halting Problem for Term Rewriting Systems . Mar 1978." Gerard Huet, D. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Gerard Huet, D.S. Lankford. On the Uniform Halting Problem for Term Rewriting Systems . Mar 1978." Gerard Huet, D. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA Gerard Huet, D. (2026). Gerard Huet, D.S. Lankford. On the Uniform Halting Problem for Term Rewriting Systems . Mar 1978. Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Bernhard Gramlich. Proc. International Conference on Logic Programming and Autom . · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Bernhard Gramlich. Proc. International Conference on Logic Programming and Autom ." Bernhard Gramlich. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Bernhard Gramlich. Proc. International Conference on Logic Programming and Autom ." Bernhard Gramlich. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA Bernhard Gramlich. (2026). Bernhard Gramlich. Proc. International Conference on Logic Programming and Autom . Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
- Yoshihito Toyama. Counterexamples to Termination for the Direct Sum of Term Rewriting Systems . 1987. · retrieved 2026-10-05 · rev 1378824686
Cite this reference
MLA "Yoshihito Toyama. Counterexamples to Termination for the Direct Sum of Term Rewriting Systems . 1987." Yoshihito Toyama. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686. Accessed 25 November 2026.
Chicago "Yoshihito Toyama. Counterexamples to Termination for the Direct Sum of Term Rewriting Systems . 1987." Yoshihito Toyama. 2026-10-05. https://en.wikipedia.org/w/index.php?oldid=1378824686.
APA Yoshihito Toyama. (2026). Yoshihito Toyama. Counterexamples to Termination for the Direct Sum of Term Rewriting Systems . 1987. Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378824686
Cite this article
MLA
"Rewriting." encyclopegia.org, 2026, https://encyclopegia.org/wiki/rewriting. Accessed 25 November 2026.
Chicago
"Rewriting." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/rewriting.
APA
encyclopegia.org. (2026). Rewriting. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/rewriting
Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON