Formally, a Markov algorithm consists of a set of symbols A = {0, 1, ...} which is its alphabet, a marker alphabet M = {α, β, ...}, and an ordered sequence P = P1, P2, of rewriting rules or productions, which are of two types:

Pi = x -> y (continue)

Pi = x -~ y (terminate)

These productions can both be considered as functions from {A ∪ M}* to {A ∪ M}*

A Markov algorithm is executed by applying the first rule that applies to the input data string, applying the leftmost pattern match.

For example, a Markov algorithm that inverts a string from the alphabet {0, 1}:

P1: 0 -> 1

P2: 1 -> 0

To suffix '101' to a string, we might use this Markov algorithm:

P1: α 0 -> 0 α

P2: α 1 -> 1 α

P3: α -~ 101;

P4: ε -> α

where ε denotes the empty string.

It can be shown that the formalism of Markov algorithms is a universal model of computation, i.e. that there exists a Markov algorithm that can simulate a universal Turing machine. It's actually another way to write semi-Thue grammars to recognize recursively enumerable sets, those at the highest level of the Chomsky hierarchy. As with Turing machines and the pure lambda calculus, Markov algorithms in their purest form are totally useless for practical programming, being primarily of interest for theoretical computer science. Even the most ordinary tasks such as basic arithmetic become non-trivial programming exercises that can quickly turn into elaborate brain twisters. Ripe territory for the creation of a Turing tarpit. ;)