<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2600%3A1700%3A4770%3AC21F%3AA980%3A6998%3A66FB%3A3448</id>
	<title>Vero - Wikipedia - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2600%3A1700%3A4770%3AC21F%3AA980%3A6998%3A66FB%3A3448"/>
	<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php/Special:Contributions/2600:1700:4770:C21F:A980:6998:66FB:3448"/>
	<updated>2026-08-15T00:10:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Markov_algorithm&amp;diff=139097</id>
		<title>Markov algorithm</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Markov_algorithm&amp;diff=139097"/>
		<updated>2025-09-06T20:35:03Z</updated>

		<summary type="html">&lt;p&gt;2600:1700:4770:C21F:A980:6998:66FB:3448: /* Symbol string */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Short description|Algorithm operating on grammar-like rules}}&lt;br /&gt;
{{No footnotes|date=May 2020}}&lt;br /&gt;
&lt;br /&gt;
In [[theoretical computer science]], a &#039;&#039;&#039;Markov algorithm&#039;&#039;&#039; is a [[string rewriting system]] that uses [[Formal grammar|grammar]]-like rules to operate on [[string (computer science)|strings]] of symbols. Markov algorithms have been shown to be [[Turing-complete]], which means that they are suitable as a general model of [[computation]] and can represent any [[mathematical expression]] from its simple notation. Markov algorithms are named after the Soviet mathematician [[Andrey Markov Jr.|Andrey Markov, Jr.]]&lt;br /&gt;
&lt;br /&gt;
[[Refal]] is a [[programming language]] based on Markov algorithms.&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
Normal algorithms are verbal, that is, intended to be applied to strings in different alphabets.&lt;br /&gt;
&lt;br /&gt;
The definition of any normal algorithm consists of two parts: an &#039;&#039;alphabet&#039;&#039;, which is a set of symbols, and a &#039;&#039;scheme&#039;&#039;. The algorithm is applied to strings of symbols of the alphabet. The scheme is a finite ordered set of &#039;&#039;substitution formulas&#039;&#039;. Each formula can be either &#039;&#039;simple&#039;&#039; or &#039;&#039;final&#039;&#039;. Simple substitution formulas are represented by strings of the form &amp;lt;math&amp;gt;L\to D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; are two arbitrary strings in the alphabet. Similarly, final substitution formulas are represented by strings of the form &amp;lt;math&amp;gt;L\to\cdot D&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a normal algorithm scheme in the five-letter alphabet &amp;lt;math&amp;gt;|*abc&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;math&amp;gt;\left\{\begin{matrix} |b&amp;amp;\to&amp;amp; ba|\\ ab&amp;amp;\to&amp;amp; ba\\ b&amp;amp;\to&amp;amp;\\ {*}|&amp;amp;\to&amp;amp; b*&amp;amp; \\ {*}&amp;amp;\to&amp;amp; c&amp;amp; \\&lt;br /&gt;
|c&amp;amp;\to&amp;amp; c\\ ac&amp;amp;\to&amp;amp; c|\\ c&amp;amp;\to\cdot\end{matrix}\right.&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The process of applying the normal algorithm to an arbitrary string &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; in the alphabet of this algorithm is a discrete sequence of elementary steps, consisting of the following. Let’s assume that &amp;lt;math&amp;gt;V&#039;&amp;lt;/math&amp;gt; is the word obtained in the previous step of the algorithm (or the original word &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, if the current step is the first). If of the substitution formulas there is no left-hand side which is included in the &amp;lt;math&amp;gt;V&#039;&amp;lt;/math&amp;gt;, then the algorithm terminates, and the result of its work is considered to be the string &amp;lt;math&amp;gt;V&#039;&amp;lt;/math&amp;gt;. Otherwise, the first of the substitution formulae whose left sides are included in &amp;lt;math&amp;gt;V&#039;&amp;lt;/math&amp;gt; is selected. If the substitution formula is of the form &amp;lt;math&amp;gt;L\to\cdot D&amp;lt;/math&amp;gt;, then out of all of possible representations of the string &amp;lt;math&amp;gt;V&#039;&amp;lt;/math&amp;gt; of the form &amp;lt;math&amp;gt;RLS&amp;lt;/math&amp;gt; (where &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; are arbitrary strings) the one with the shortest &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; is chosen. Then the algorithm terminates and the result of its work is considered to be &amp;lt;math&amp;gt;RDS&amp;lt;/math&amp;gt;. However, if this substitution formula is of the form &amp;lt;math&amp;gt;L\to D&amp;lt;/math&amp;gt;, then out of all of the possible representations of the string &amp;lt;math&amp;gt;V&#039;&amp;lt;/math&amp;gt; of the form of &amp;lt;math&amp;gt;RLS&amp;lt;/math&amp;gt; the one with the shortest &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; is chosen, after which the string &amp;lt;math&amp;gt;RDS&amp;lt;/math&amp;gt; is considered to be the result of the current step, subject to further processing in the next step.&lt;br /&gt;
&lt;br /&gt;
For example, the process of applying the algorithm described above to the word &amp;lt;math&amp;gt;|*||&amp;lt;/math&amp;gt; results in the sequence of words &amp;lt;math&amp;gt;|b*|&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;ba|*|&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;a|*|&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;a|b*&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;aba|*&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;baa|*&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;aa|*&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;aa|c&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;aac&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;ac|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c||&amp;lt;/math&amp;gt;, after which the algorithm stops with the result &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt;.    &lt;br /&gt;
&lt;br /&gt;
For other examples, see below.&lt;br /&gt;
&lt;br /&gt;
Any normal algorithm is equivalent to some [[Turing machine]], and vice versa{{snd}}any [[Turing machine]] is equivalent to some normal algorithm. A version of the [[Church–Turing thesis]] formulated in relation to the normal algorithm is called the &amp;quot;principle of normalization.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Normal algorithms have proved to be a convenient means for the construction of many sections of [[constructive mathematics]]. Moreover, inherent in the definition of a normal algorithm are a number of ideas used in programming languages aimed at handling symbolic information{{snd}}for example, in [[Refal]].&lt;br /&gt;
&lt;br /&gt;
==Algorithm==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Rules&#039;&#039; are a sequence of pairs of strings, usually presented in the form of &#039;&#039;pattern&#039;&#039; → &#039;&#039;replacement&#039;&#039;. Each rule may be either ordinary or terminating.&lt;br /&gt;
&lt;br /&gt;
Given an &#039;&#039;input&#039;&#039; string: &lt;br /&gt;
&lt;br /&gt;
#Check the Rules in order from top to bottom to see whether any of the &#039;&#039;patterns&#039;&#039; can be found in the &#039;&#039;input&#039;&#039; string.&lt;br /&gt;
#If none is found, the algorithm stops.&lt;br /&gt;
#If one (or more) is found, use &#039;&#039;&#039;the first&#039;&#039;&#039; of them to replace the leftmost occurrence of matched text in the &#039;&#039;input&#039;&#039; string with its &#039;&#039;replacement&#039;&#039;.&lt;br /&gt;
#If the rule just applied was a terminating one, the algorithm stops.&lt;br /&gt;
#Go to step 1.&lt;br /&gt;
&lt;br /&gt;
Note that after each rule application the search starts over from the first rule.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following example shows the basic operation of a Markov algorithm.&lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
#&amp;quot;A&amp;quot; -&amp;gt; &amp;quot;apple&amp;quot;&lt;br /&gt;
#&amp;quot;B&amp;quot; -&amp;gt; &amp;quot;bag&amp;quot;&lt;br /&gt;
#&amp;quot;S&amp;quot; -&amp;gt; &amp;quot;shop&amp;quot;&lt;br /&gt;
#&amp;quot;T&amp;quot; -&amp;gt; &amp;quot;the&amp;quot;&lt;br /&gt;
#&amp;quot;the shop&amp;quot; -&amp;gt; &amp;quot;my brother&amp;quot;&lt;br /&gt;
#&amp;quot;a never used&amp;quot; -&amp;gt; &#039;&#039;&#039;.&#039;&#039;&#039;&amp;quot;terminating rule&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Symbol string===&lt;br /&gt;
&amp;quot;I bought a B of As from T S.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Execution===&lt;br /&gt;
If the algorithm is applied to the above example, the Symbol string will change in the following manner.&lt;br /&gt;
&lt;br /&gt;
#&amp;quot;I bought a B of As from T S.&amp;quot;&lt;br /&gt;
#&amp;quot;I bought a B of apples from T S.&amp;quot;&lt;br /&gt;
#&amp;quot;I bought a bag of apples from T S.&amp;quot;&lt;br /&gt;
#&amp;quot;I bought a bag of apples from T shop.&amp;quot;&lt;br /&gt;
#&amp;quot;I bought a bag of apples from the shop.&amp;quot;&lt;br /&gt;
#&amp;quot;I bought a bag of apples from my brother.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The algorithm will then terminate.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
These rules give a more interesting example. They rewrite binary numbers to their unary counterparts. For example, 101 will be rewritten to a string of 5 consecutive bars.&lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
&lt;br /&gt;
#&amp;quot;|0&amp;quot; -&amp;gt; &amp;quot;0||&amp;quot;&lt;br /&gt;
#&amp;quot;1&amp;quot; -&amp;gt; &amp;quot;0|&amp;quot;&lt;br /&gt;
#&amp;quot;0&amp;quot; -&amp;gt; &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Symbol string===&lt;br /&gt;
&amp;quot;101&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Execution===&lt;br /&gt;
If the algorithm is applied to the above example, it will terminate after the following steps.&lt;br /&gt;
&lt;br /&gt;
#&amp;quot;101&amp;quot;&lt;br /&gt;
#&amp;quot;0|01&amp;quot;&lt;br /&gt;
#&amp;quot;00||1&amp;quot;&lt;br /&gt;
#&amp;quot;00||0|&amp;quot;&lt;br /&gt;
#&amp;quot;00|0|||&amp;quot;&lt;br /&gt;
#&amp;quot;000|||||&amp;quot;&lt;br /&gt;
#&amp;quot;00|||||&amp;quot;&lt;br /&gt;
#&amp;quot;0|||||&amp;quot;&lt;br /&gt;
#&amp;quot;|||||&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Formal grammar]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
* Caracciolo di Forino, A. &#039;&#039;String processing languages and generalized Markov algorithms.&#039;&#039; In Symbol manipulation languages and techniques, D. G. Bobrow (Ed.), North-Holland Publ. Co., Amsterdam, the Netherlands, 1968, pp.&amp;amp;nbsp;191–206.&lt;br /&gt;
* [[Andrey Markov Jr.|Andrey Andreevich Markov (1903–1979)]] 1960. &#039;&#039;The Theory of Algorithms.&#039;&#039; American Mathematical Society Translations, series 2, 15, 1–14. (Translation from the Russian, Trudy Instituta im. Steklova 38 (1951) 176-189&amp;lt;ref&amp;gt;{{Cite journal |last=Kushner |first=Boris A. |date=1999-05-28 |title=Markov&#039;s constructive analysis; a participant&#039;s view |url=https://core.ac.uk/works/41825477 |journal=Theoretical Computer Science |language=en |volume=219 |issue=1–2 |pages=268, 284 |doi=10.1016/S0304-3975(98)00291-6|doi-access=free }}&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* [https://yad-studio.github.io/ Yad Studio - Markov algorithms IDE and interpreter (Open Source)]&lt;br /&gt;
* [https://sourceforge.net/projects/markov  Markov algorithm interpreter]&lt;br /&gt;
* [https://web.archive.org/web/20060217113205/http://nic-nac-project.de/~jcm/index.php?nav=projects Markov algorithm interpreter]&lt;br /&gt;
* [https://rosettacode.org/wiki/Execute_a_Markov_algorithm Markov algorithm interpreters at Rosetta-Code]&lt;br /&gt;
* [https://store.steampowered.com/app/1720850/AB/ A=B, a game about writing substitution rules for a Markov algorithm]&lt;br /&gt;
&lt;br /&gt;
{{Strings}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Theory of computation]]&lt;br /&gt;
[[Category:Rewriting systems]]&lt;br /&gt;
[[Category:Models of computation]]&lt;/div&gt;</summary>
		<author><name>2600:1700:4770:C21F:A980:6998:66FB:3448</name></author>
	</entry>
</feed>