In theoretical computer science
Theoretical computer science is a division or subset of general computer science and mathematics which focuses on more abstract or mathematical aspects of computing....
, a Markov algorithm
is a string rewriting system that uses grammar
A formal grammar is a set of formation rules for strings in a formal language. The rules describe how to form strings from the language's alphabet that are valid according to the language's syntax...
-like rules to operate on strings
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....
of symbols. Markov algorithms have been shown to be Turing-complete, which means that they are suitable as a general model of computation
Computation is defined as any type of calculation. Also defined as use of computer technology in Information processing.Computation is a process following a well-defined model understood and expressed in an algorithm, protocol, network topology, etc...
and can represent any mathematical expression from its simple notation. Markov algorithms are named after the mathematician Andrey Markov Jr
Andrey Andreyevich Markov Jr. was a Soviet mathematician, the son of the great Russian mathematician Andrey Andreyevich Markov Sr, and one of the key founders of the Russian school of constructive mathematics and logic...
Refal "is a functional programming language oriented toward symbol manipulation", including "string processing, translation, [and] artificial intelligence". It is one of the oldest members of this family, first conceived in 1966 as a theoretical tool with the first implementation appearing in 1968...
is a programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
based on Markov algorithms.
is a sequence of pair of strings, usually presented in the form of pattern
. Some rules may be terminating.
Given an input
- Check the Rules in order from top to bottom to see whether any of the patterns can be found in the input string.
- If none is found, the algorithm stops.
- If one (or more) is found, use the first of them to replace the leftmost matching text in the input string with its replacement.
- If the applied rule was a terminating one, the algorithm stops.
- Return to step 1 and carry on.
- "A" -> "apple"
- "B" -> "bag"
- "S" -> "shop"
- "T" -> "the"
- "the shop" -> "my brother"
- "a never used" -> ."terminating rule"
If the algorithm is applied to the above example, the Symbol string will change in the following manner.
- "I bought a B of apples from T S."
- "I bought a bag of apples from T S."
- "I bought a bag of apples from T shop."
- "I bought a bag of apples from the shop."
- "I bought a bag of apples from my brother."
The algorithm will then terminate.
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.
If the algorithm is applied to the above example, it will terminate after the following steps.