# Semi-Thue system

In theoretical computer science and mathematical logic a string rewriting system (SRS), historically called a semi-Thue system, is a rewriting system over strings from a (usually finite) alphabet. Given a binary relation ${\displaystyle R}$ between fixed strings over the alphabet, called rewrite rules, denoted by ${\displaystyle s\rightarrow t}$ , an SRS extends the rewriting relation to all strings in which the left- and right-hand side of the rules appear as substrings, that is ${\displaystyle usv\rightarrow utv}$ , where ${\displaystyle s}$ , ${\displaystyle t}$ , ${\displaystyle u}$ , and ${\displaystyle v}$ are strings.

The notion of a semi-Thue system essentially coincides with the presentation of a monoid. Thus they constitute a natural framework for solving the word problem for monoids and groups.

An SRS can be defined directly as an abstract rewriting system. It can also be seen as a restricted kind of a term rewriting system. As a formalism, string rewriting systems are Turing complete. The semi-Thue name comes from the Norwegian mathematician Axel Thue, who introduced systematic treatment of string rewriting systems in a 1914 paper.[1] Thue introduced this notion hoping to solve the word problem for finitely presented semigroups. Only in 1947 was the problem shown to be undecidable this result was obtained independently by Emil Post and A. A. Markov Jr.[2][3]

## Definition

A string rewriting system or semi-Thue system is a tuple ${\displaystyle (\Sigma ,R)}$ where

• Σ is an alphabet, usually assumed finite.[4] The elements of the set ${\displaystyle \Sigma ^{*}}$ (* is the Kleene star here) are finite (possibly empty) strings on Σ, sometimes called words in formal languages; we will simply call them strings here.
• R is a binary relation on strings from Σ, i.e., ${\displaystyle R\subseteq \Sigma ^{*}\times \Sigma ^{*}.}$ Each element ${\displaystyle (u,v)\in R}$ is called a (rewriting) rule and is usually written ${\displaystyle u\rightarrow v}$ .

If the relation R is symmetric, then the system is called a Thue system.

The rewriting rules in R can be naturally extended to other strings in ${\displaystyle \Sigma ^{*}}$ by allowing substrings to be rewritten according to R. More formally, the one-step rewriting relation relation ${\displaystyle {\xrightarrow[{R}]{}}}$ induced by R on ${\displaystyle \Sigma ^{*}}$ for any strings ${\displaystyle s,t\in \Sigma ^{*}}$ :

${\displaystyle s{\xrightarrow[{R}]{}}t}$ if and only if there exist ${\displaystyle x,y,u,v\in \Sigma ^{*}}$ such that ${\displaystyle s=xuy}$ , ${\displaystyle t=xvy}$ , and ${\displaystyle u\rightarrow v}$ .

Since ${\displaystyle {\xrightarrow[{R}]{}}}$ is a relation on ${\displaystyle \Sigma ^{*}}$ , the pair ${\displaystyle (\Sigma ^{*},{\xrightarrow[{R}]{}})}$ fits the definition of an abstract rewriting system. Obviously R is a subset of ${\displaystyle {\xrightarrow[{R}]{}}}$ . Some authors use a different notation for the arrow in ${\displaystyle {\xrightarrow[{R}]{}}}$ (e.g. ${\displaystyle {\xrightarrow[{R}]{}}}$ ) in order to distinguish it from R itself (${\displaystyle \rightarrow }$ ) because they later want to be able to drop the subscript and still avoid confusion between R and the one-step rewrite induced by R.

Clearly in a semi-Thue system we can form a (finite or infinite) sequence of strings produced by starting with an initial string ${\displaystyle s_{0}\in \Sigma ^{*}}$ and repeatedly rewriting it by making one substring-replacement at a time:

${\displaystyle s_{0}\ {\xrightarrow[{R}]{}}\ s_{1}\ {\xrightarrow[{R}]{}}\ s_{2}\ {\xrightarrow[{R}]{}}\ \ldots }$

A zero-or-more-steps rewriting like this is captured by the reflexive transitive closure of ${\displaystyle {\xrightarrow[{R}]{}}}$ , denoted by ${\displaystyle {\xrightarrow[{R}]{*}}}$ (see abstract rewriting system#Basic notions). This is called the rewriting relation or reduction relation on ${\displaystyle \Sigma ^{*}}$ induced by R.

## Thue congruence

In general, the set ${\displaystyle \Sigma ^{*}}$ of strings on an alphabet forms a free monoid together with the binary operation of string concatenation (denoted as ${\displaystyle \cdot }$ and written multiplicatively by dropping the symbol). In a SRS, the reduction relation ${\displaystyle {\xrightarrow[{R}]{*}}}$ is compatible with the monoid operation, meaning that ${\displaystyle x{\xrightarrow[{R}]{*}}y}$ implies ${\displaystyle uxv{\xrightarrow[{R}]{*}}uyv}$ for all strings ${\displaystyle x,y,u,v\in \Sigma ^{*}}$ . Since ${\displaystyle {\xrightarrow[{R}]{*}}}$ is by definition a preorder, ${\displaystyle \left(\Sigma ^{*},\cdot ,{\xrightarrow[{R}]{*}}\right)}$ forms a monoidal preorder.

Similarly, the reflexive transitive symmetric closure of ${\displaystyle {\xrightarrow[{R}]{}}}$ , denoted ${\displaystyle {\overset {*}{\underset {R}{\leftrightarrow }}}}$ (see abstract rewriting system#Basic notions), is a congruence, meaning it is an equivalence relation (by definition) and it is also compatible with string concatenation. The relation ${\displaystyle {\overset {*}{\underset {R}{\leftrightarrow }}}}$ is called the Thue congruence generated by R. In a Thue system, i.e. if R is symmetric, the rewrite relation ${\displaystyle {\xrightarrow[{R}]{*}}}$ coincides with the Thue congruence ${\displaystyle {\overset {*}{\underset {R}{\leftrightarrow }}}}$ .

## Factor monoid and monoid presentations

Since ${\displaystyle {\overset {*}{\underset {R}{\leftrightarrow }}}}$ is a congruence, we can define the factor monoid ${\displaystyle {\mathcal {M}}_{R}=\Sigma ^{*}/{\overset {*}{\underset {R}{\leftrightarrow }}}}$ of the free monoid ${\displaystyle \Sigma ^{*}}$ by the Thue congruence in the usual manner. If a monoid ${\displaystyle {\mathcal {M}}}$ is isomorphic with ${\displaystyle {\mathcal {M}}_{R}}$ , then the semi-Thue system ${\displaystyle (\Sigma ,R)}$ is called a monoid presentation of ${\displaystyle {\mathcal {M}}}$ .

We immediately get some very useful connections with other areas of algebra. For example, the alphabet {a, b} with the rules { ab → ε, ba → ε }, where ε is the empty string, is a presentation of the free group on one generator. If instead the rules are just { ab → ε }, then we obtain a presentation of the bicyclic monoid.

The importance of semi-Thue systems as presentation of monoids is made stronger by the following:

Theorem: Every monoid has a presentation of the form ${\displaystyle (\Sigma ,R)}$ , thus it may be always be presented by a semi-Thue system, possibly over an infinite alphabet.[5]

In this context, the set ${\displaystyle \Sigma }$ is called the set of generators of ${\displaystyle {\mathcal {M}}}$ , and ${\displaystyle R}$ is called the set of defining relations ${\displaystyle {\mathcal {M}}}$ . We can immediately classify monoids based on their presentation. ${\displaystyle {\mathcal {M}}}$ is called

• finitely generated if ${\displaystyle \Sigma }$ is finite.
• finitely presented if both ${\displaystyle \Sigma }$ and ${\displaystyle R}$ are finite.

## The word problem for semi-Thue systems

The word problem for semi-Thue systems can be stated as follows: Given a semi-Thue system ${\displaystyle T:=(\Sigma ,R)}$ and two words (strings) ${\displaystyle u,v\in \Sigma ^{*}}$ , can ${\displaystyle u}$ be transformed into ${\displaystyle v}$ by applying rules from ${\displaystyle R}$ ? This problem is undecidable, i.e. there is no general algorithm for solving this problem. This even holds if we limit the input to finite systems.

Martin Davis offers the lay reader a two-page proof in his article "What is a Computation?" pp. 258–259 with commentary p. 257. Davis casts the proof in this manner: "Invent [a word problem] whose solution would lead to a solution to the halting problem."

## Connections with other notions

A semi-Thue system is also a term-rewriting systemone that has monadic words (functions) ending in the same variable as the left- and right-hand side terms,[6] e.g. a term rule ${\displaystyle f_{2}(f_{1}(x))\rightarrow g(x)}$ is equivalent to the string rule ${\displaystyle f_{1}f_{2}\rightarrow g}$ .

A semi-Thue system is also a special type of Post canonical system, but every Post canonical system can also be reduced to an SRS. Both formalisms are Turing complete, and thus equivalent to Noam Chomsky's unrestricted grammars, which are sometimes called semi-Thue grammars.[7] A formal grammar only differs from a semi-Thue system by the separation of the alphabet into terminals and non-terminals, and the fixation of a starting symbol amongst non-terminals. A minority of authors actually define a semi-Thue system as a triple ${\displaystyle (\Sigma ,A,R)}$ , where ${\displaystyle A\subseteq \Sigma ^{*}}$ is called the set of axioms. Under this "generative" definition of semi-Thue system, an unrestricted grammar is just a semi-Thue system with a single axiom in which one partitions the alphabet into terminals and non-terminals, and makes the axiom a nonterminal.[8] The simple artifice of partitioning the alphabet into terminals and non-terminals is a powerful one; it allows the definition of the Chomsky hierarchy based on what combination of terminals and non-terminals the rules contain. This was a crucial development in the theory of formal languages.

In quantum computing, the notion of a quantum Thue system can be developed.[9] Since quantum computation is intrinsically reversible, the rewriting rules over the alphabet ${\displaystyle \Sigma }$ are required to be bidirectional (i.e. the underlying system is a Thue system, not a semi-Thue system). On a subset of alphabet characters ${\displaystyle Q\subseteq \Sigma }$ one can attach a Hilbert space ${\displaystyle \mathbb {C} ^{d}}$ , and a rewriting rule taking a substring to another one can carry out a unitary operation on the tensor product of the Hilbert space attached to the strings; this implies that they preserve the number of characters from the set ${\displaystyle Q}$ . Similar to the classical case one can show that a quantum Thue system is a universal computational model for quantum computation, in the sense that the executed quantum operations correspond to uniform circuit classes (such as those in BQP when e.g. guaranteeing termination of the string rewriting rules within polynomially many steps in the input size), or equivalently a Quantum Turing machine.

## History and importance

Semi-Thue systems were developed as part of a program to add additional constructs to logic, so as to create systems such as propositional logic, that would allow general mathematical theorems to be expressed in a formal language, and then proven and verified in an automatic, mechanical fashion. The hope was that the act of theorem proving could then be reduced to a set of defined manipulations on a set of strings. It was subsequently realized that semi-Thue systems are isomorphic to unrestricted grammars, which in turn are known to be isomorphic to Turing machines. This method of research succeeded and now computers can be used to verify the proofs of mathematic and logical theorems.

At the suggestion of Alonzo Church, Emil Post in a paper published in 1947, first proved "a certain Problem of Thue" to be unsolvable, what Martin Davis states as "...the first unsolvability proof for a problem from classical mathematics -- in this case the word problem for semigroups."[10]

Davis also asserts that the proof was offered independently by A. A. Markov.[11]

## Notes

1. Book and Otto, p. 36
2. Abramsky et al. p. 416
3. Salomaa et al., p.444
4. In Book and Otto a semi-Thue system is defined over a finite alphabet through most of the book, except chapter 7 when monoid presentation are introduced, when this assumption is quietly dropped.
5. Book and Otto, Theorem 7.1.7, p. 149
6. Nachum Dershowitz and Jean-Pierre Jouannaud. Rewrite Systems (1990) p. 6
7. D.I.A. Cohen, Introduction to Computer Theory, 2nd ed., Wiley-India, 2007, ISBN 81-265-1334-9, p.572
8. Dan A. Simovici, Richard L. Tenney, Theory of formal languages with applications, World Scientific, 1999 ISBN 981-02-3729-4, chapter 4
9. J. Bausch, T. Cubitt, M. Ozols, The Complexity of Translationally-Invariant Spin Chains with Low Local Dimension, Ann. Henri Poincare 18(11), 2017 doi:10.1007/s00023-017-0609-7 pp. 3449-3513
10. Martin Davis (editor) (1965), The Undecidable: Basic Papers on Undecidable Propositions, Unsolvable Problems and Computable Functions, after page 292, Raven Press, New York
11. A. A. Markov (1947) Doklady Akademii Nauk SSSR (N.S.) 55: 583–586

## References

### Monographs

• Ronald V. Book and Friedrich Otto, String-rewriting Systems, Springer, 1993, ISBN 0-387-97965-4.
• Matthias Jantzen, Confluent string rewriting, Birkhäuser, 1988, ISBN 0-387-13715-7.

### Textbooks

• Martin Davis, Ron Sigal, Elaine J. Weyuker, Computability, complexity, and languages: fundamentals of theoretical computer science, 2nd ed., Academic Press, 1994, ISBN 0-12-206382-1, chapter 7
• Elaine Rich, Automata, computability and complexity: theory and applications, Prentice Hall, 2007, ISBN 0-13-228806-0, chapter 23.5.

### Surveys

• Samson Abramsky, Dov M. Gabbay, Thomas S. E. Maibaum (ed.), Handbook of Logic in Computer Science: Semantic modelling, Oxford University Press, 1995, ISBN 0-19-853780-8.
• Grzegorz Rozenberg, Arto Salomaa (ed.), Handbook of Formal Languages: Word, language, grammar, Springer, 1997, ISBN 3-540-60420-0.