1An automaton, like TM^, which reads characters in sequence
3. A MARKOV ALGORITHM SIMULATOR
As is known Markov Algorithms, although equivalent to Turing Machines are much faster and sophisticated devices. This has as a result that the internal function of a Turing Machine is much simpler than that of a Markov Algorithm. Thus a computer program simulating a Markov Algorithm has to be more complicated than a program which simulates a Turing Machine.
As in the case of the Turing Machine simulator, a Markov 4 Algorithm one will be able to behave as its abstract Markov
Algorithm counterpart whenever space and time problems do not present an obstacle to the computer.
The Markov Algorithm simulator, described in the following pages will later be used to simulate a Turing Machine, by a
suitable transformation of a Turing Machine program to an equi- i valent Markov Algorithm one.
The program is designed so that any (theoretically) number
of alphabets may be used and any number of generic variables 'i may correspond to each alphabet. It will also be capable of
accepting productions with LHS’s and for RUS’s containing symbols belonging to input alphabets (even if generics are used) including cases where the priority of substitution is important.
3.1 Input to the Program
Every input to the Markov Algorithm simulator will be of the following form.
n £hs^ ■> rhs^, ; or £hs^ ->* rhs^, if the algorithm is Ahs, - rhs^. ; unlabelled ilhs n rhs , i ; n n "input string" options. 3.2 Data Structure
A very useful property of the C language is the use of structures which help greatly to the program’s readability. Thus we use the following array structures.
First there will be a nuiriber of input lines equal to the number of alphabets used by the algorithm. Every one of
these lines will consist of the characters of one of the I alphabets followed by the generics corresponding to this
alphabet. Then the input lines with the rules of the
algorithm follow, and finally the input string followed by one I line of options.
Examples of input
^11^12“ *®1K^^^11^12* "^IX '
S :s V\ N s
i
A M i& - 0 r s t^ ç b p iC — ?£J/3 e--- -- T h e . Ze^gM c f . X U s:,- »!:///=/%^/-/z^s;-/ / h e /•‘ •’Sf- <zT)cc)'<xc f e y o p r h s ; fS -1 4 (^^■ayr,'iir>e^ / h e rte ^ ih Kv-we- A» b e
--- V) N CO---1vijo INDU4 |4> _oA lU «•-û i 0 j _ >«M.jr-.' 43. 9.N W |4k) 'a tf _ _ 1%. 0:1 M L O» ^ .--s F> U1 iÇr-' Itr- 0 3>f> Î3-1MS I j î h ; m Q ^ pü % 0 ^ A) ^ Fb ! S' o-iCj q\ cf S.4
a. LHS with two fields; the first, called Lsym, is of character type and contains the &hs’s of all rules sequentially, by separating every last character of a
Ehs of a rule from the first character of the fhs of 4 the next rule by a special symbol. In the second field
called Lgen, and being of integer type, there is an integer describing the character in the corresponding field of the same "line" of the structure; that is it
determines if it is an input symbol or a generic or a
I
marker. , A
b . RHS is a structure similar to LHS.
c. Another structure called Rules uses five fields of integer type. Thus Lpoint points to the cell of LHS containing the first symbol of the £hs of the corresponding rule. In the field called Lplatos there is an integer (for every rule) equal to the length of the £hs of the corresponding rule. The difference in length between £hs and rhs of a rule is stored in a field called diff. Finally an integer determining the next rule to be tested is stored in the field called Label.
d. The array structure Generic is more complicated since it has every line consisting of
(i) an array field, of character type called alphab, storing one of the input alphabets;
(ii) a single character field where the generics cor responding to alphab are stored;
(ill) a character field called used indicating each time the character into which the generic was translated;
(iv) the field mnenonic, which will be explained later.
e. The structure Register is a three-field structure, where, in every one of its first character-type field a char
acter of the string is stored, in every second field an . 4 integer determining the column of the character-array
field alphab of the structure Generic where this charac ter can be found. The third field, of integer type, is a pointer to the next element of the structure. Wlien the program starts, a number, of elements of the structure equal to the length of the input string is used. All the unused elements form a stack; a pointer called AVAIL points to the first (top of the stack) unused element. Thus whenever one or more new elements are needed from the stack, the one pointed to by AVAIL is always taken as first, and the second becomes that pointed to by AVAIL and so on. On the other hand every element used and not needed any more is placed on the top of the stack and is pointed to by AVAIL. The first of the used elements of Register is always occupied by the character "A" (that is the empty string).
A data structure diagram occupies the following page.
3.3 Procedures used
The procedures Initgen, Initrule, Introduce and Debbuging set
or 2. The symbol in LHS (field Lsymb) is a generic and the character in the string (Register) belongs to one of the alphabets (that is, it is not a marker), which is the range of the generic variable. In this case there are also two possibilities examined; that is whether the generic has been used before in this rule or it has not. This is specified by th e fields of generic mnemonic. 3, If none of cases 1 or 2 happen the rule is inapplicable. If a rule is applicable "search" returns "1", and "0" otherwise,