This builds on the formulation of an algorithm given here. We will place restrictions on , , and so as to enforce effectiveness.
Let be a finite set of letters, and let be the set of all strings on . Let be a nonnegative integer: we will then have be the set of all where and .
So is the set of ordered pairs of strings in and integers from to . We will then have be the subset where , and be the subset where .
We will define in terms of two lists of strings and two lists of integers. The strings and integers are given by , , and respectively, for .
In words: takes a pair , and branches the computation according to whether occurs in . If it does, then it substitutes by in , and switches for . Otherwise, does nothing to the string; it simply substitutes for .