Counter machine models

Counter machine models

This page supplements counter machine.

Although some authors use the name "register machine" synonymously with "counter machine", this article will give details and examples of only of the most primitive species -- the "counter machine" -- of the genus "register machine."

Within the species "counter machine" there are a number of varieties: the models of Hermes (1954), Kaphengst (1957), Ershov (1958), Peter (1958), Minsky (1961) and Minsky (1967), Melzak (1961), Lambek (1961), Shepherdson and Sturgis (1963), and Schönhage (1980). These models will be described in more detail in the following.


The models in more detail

1954: Hermes' model

Shepherdson and Sturgis observe that "the proof of this universality [of digital computers to Turing machines] ... seems to have been first written down by Hermes, who showed in [7--their reference number] how an idealized computer could be programmed to duplicate the behavior of any Turing machine" (Shepherdson and Sturgis, p. 219).

1957: Kaphengst's model

Shepherdson and Sturgis observe that:

"Kaphengst's approach is interesting in that it gives a direct proof of the universality of present-day digital computers, at least when idealized to the extent of admitting an infinity of storage registers each capable of storing arbitrarily long words" (Shepherdson and Sturgis, p. 219)

The only two arithmetic instructions are

  • (1) Successor operation
  • (2) Testing two numbers for equality

The rest of the operations are transfers from register-to-accumulator or accumulator-to-register or test-jumps.

Kaphengst's paper is written in German; Sheperdson and Sturgis' translation results in strange words such as "mill" and "orders".

The machine contains "a mill" (accumulator). Kaphengst designates his mill/accumulator with the "infinity" symbol but we will use "A" in the following description. It also contains an "order register" ("order" as in "instruction", not as "in sequence"). (This usage came from the report of Burks-Goldstine-von Neumann (1946) description of ' Electronc Computing Instrument'.) The order/instruction register is register "0". And, although not clear from Sheperdson and Sturgis' exposition the model contains an "extension register" designated by Kaphengst "infinity-prime"; we will use "E".

The instructions are stored in the registers:

" the machine, like an actual computer, is capable of doing arithmetic operations on its own program" (p. 244).

Thus this model is actually a random access machine. In the following, "[ r ]" indicates "contents of" register r, etc.

Action: Description
D1: C(r, A) [ r ] → A , [ r ] → r Copy contents of register r to accumulator A
D2: C(A, r) [ A ] → r, [ A ] → A Copy contents of accumulator A to regiser r
C1: O(A) 0 → A Zero (clear) accumulator A
A1: P(A) [ A ] + 1 → A Increment (add 1 to) contents of accumulator A
F1: J(A) [E1] IF [ A ] = 0 THEN jump to "Exit 1" Jump if contents of accumulator A = 0
G1: On(A) IF [ A ] = [ r ] THEN 0 → < A > ELSE 1 → A Clear contents of A if contents of A = contents of r, else "set" A=1
G2: O'(A) 1 → A "Set" contents of A = 1

Shepherdson and Sturgis remove the mill/accumulator A and reduce the Kaphengst instructions to register-to-register "copy", arithmetic operation "Increment", and "register-to-register compare". Observe that there is no decrement. This model, almost verbatim, is to be found in Minsky (1967); see more in the section below.

Action: Description:
a: P(A) [ A ] + 1 → A Increment (add 1 to) contents of accumulator A
d. C(m,n) [ rj ] → rk, [ rj ] → rj Copy contents of register rj to register rk
f: J(r) [E1] IF [ r ] = 0 THEN jump to "Exit 1" ELSE next instruction Jump if contents of register r = 0
c: E(rj, rk) IF [ rj ] = [ rk ] THEN 0 → E ELSE 1 → E Clear contents of register E if contents of rj = contents of rk, else "set" E=1

1958: Ershov's class of operator algorithms

Shepherdson and Sturgis (1963) observe that Ersov's model allows for storage of the program in the registers. They assert that Ersov's model is as follows:

Action: Description:
d. C(rj,rk) [ rj ] → rk, [ rj ] → rj Copy contents of register rj to register rk
d'. C' (rj,rk) rj ] +1 → rk, [ rj ] → rj Copy incremented contents of register rj to register rk
e. J[E1] Jump to "Exit 1" Unconditional jump to "Exit #1"
f*: J(rj, rk)[E1, E2] IF [ rj ] ≤ [ rk ] THEN jump to "Exit 1" ELSE jump to "Exit 2" Jump to exit E1 if contents of register rj is less than or equal to contents of rk, else jump to E=2

1958: Péter's "treatment"

Shepherdson and Sturgis (1963) observe that Péter's "treatment" (they are not too specific here) has an equivalence to the instructions shown in the following table. They comment specifically about these instructions, that:

"from the point of view of proving as quickly as possible the computability of all partial recursive functions Péter's is perhaps the best; for proving their computability by Turing machines a further analysis of the copying operation is necessary along the lines we have taken above." (Shepherdson and Sturgis (1963) p. 246)
Action: Description:
c: O(n) 0 → [ n ] Zero (clear) register n
d. C(m,n) [ m ] → n , [ m ] → [ m ] Copy contents of register m to register n
d'. C'(m,n) [ m ] + 1 → [ n ], [ m ] → [ m ] Copy incremented contents of register m to register n
e. J(m, n)[E1, E2] IF [m]=[n] jump to E1 ELSE jump to E2 Conditional jump to E1 if contents of m equals contents of n, else jump to E2.

1961: Minsky's model of a partial recursive function reduced to a "program" of only two instructions

In his inquiry into problems of Emil Post (the tag system) and Hilbert's 10th problem (Hilbert's problems, Diophantine equation) led Minsky to the following definition of:

"an interesting basis for recursive function theory involving programs of only the simplest arithmetic operations" (Minsky (1961) p. 437).

His "Theorem Ia" asserts that any partial recursive function is represented by "a program operating on two integers S1 and S2 using instructions Ij of the forms (cf Minsky (1961) p. 449):

Action: Description:
a. ADD ( r, Ij1 ) [ r ] + 1 → r; go to instruction Ij1. Increment (add 1 to) contents of register r and go to instruction Ij1.
b. SUB (r, Ij1, Ij2) If [ r ] ≤ 0 THEN go to instr. Ij2 ELSE [ r ] -1 → r and go to instr. Ij1 IF contents of register r equals zero THEN jump to instruction Ij2; ELSE decrement (subtract 1 from) contents of register r and jump to instr. Ij1.

The first theorem is the context of a second "Theorem IIa" that

"...represents any partial recursive function by a program operating on one integer S [contained in a single register r1] using instructions Ij of the forms":
Action: Description:
a. MULT (Kj, Ij1) [ r1 ]*Kj → r1; go to instruction Ij1. Multiply contents of register r1 by constant Kj
b. DIV (Kj, Ij1, Ij2) [ r1 ]/Kj = 0 then go to instruction Ij2 else go to Ij1. If division of contents of register 1 by constant Kj has no remainder then instr. Ij1 else instr. Ij2

In this second form the machine uses Gödel numbers to process "the integer S". He asserts that the first machine/model does not need to do this if it has 4 registers available to it.

1961: Melzak model: a single ternary instruction with addition and proper subtraction

"It is our object to describe a primitive device, to be called a Q-machine, which arrives at effective computability via arithmetic rather than via logic. Its three operations are keeping tally, comparing non-negative integers, and transferring" (Melzak (1961) p. 281)

If we use the context of his model, "keeping tally" means "adding by successive increments" (throwing a pebbles into) or "subtracting by successive decrements"; transferring means moving (not copying) the contents from hole A to hole B, and comparing numbers is self-evident. This appears to be a blend of the three base models.

Melzak's physical model is holes { X, Y, Z, etc. } in the ground together with an unlimited supply of pebbles in a special hole S (Sink or Supply or both? Melzak doesn't say).

"The Q-machine consists of an indefinitely large number of locations: S, A1, A2, ..., an indefinitely large supply of counters distributed among these locations, a program, and an operator whose sole purpose is to carry out the instructions. Initially all but a finite number from among the locations ... are empty and each of the remaining ones contains a finite number of counters" (p. 283, boldface added)

The phrases indefinitely large number of locations and finite number of counters here are important. This model is different than the Minsky model that allows for a finite number of locations with unbounded (effectively infinite) capacity for "markers".

The instruction is a single "ternary operation" he calls "XYZ":

"XYZ" denotes the operation of
(i) Count the number of pebbles in hole Y,
(ii) put them back into Y,
(iii) attempt to remove this same amount from hole X. IF this is not possible because it will empty hole X THEN do nothing and jump to instruction #I; ELSE,
(iv) remove the Y-amount from X and (iv) transfer them to, i.e. add them to, the quantity in hole Z.

Of all the possible operations, some are not allowed, as shown in the table below:

Allowed Instruction Hole "X" Hole "Y" Hole "Z" Meaning of Instruction
XXY ([ X ] - [ X ])=0 → X [ Y ] + [ X ] → Y [ Z ] → Z All of X's pebbles taken from X and added to Y
XXS ([ X ] - [ X ])=0 → X [ Y ] → Y [ Z ] → Z All of X's pebbles taken from X and put into sink/source S
XYY [ X ] - [ Y ] → X [ Y ] + [ Y ] → Y [ Z ] → Z Count of Y's pebbles taken from X and placed in Y, doubling count of Y
XYZ [ X ] - [ Y ] → X [ Y ] → Y [ Z ] + [ Y ] → Z Count of Y's pebbles taken from X and added to Z,
SYY [ X ] → X [ Y ] + [ Y ] → Y [ Z ] → Z Count of Y's pebbles taken from S and added to Y, doubling Y's count
SYZ [ X ] → X [ Y ] → Y [ Z ] + [ Y ] → [ Z ] Count of Y's pebbles taken from S and added to Z

Some observations about the Melzak model:

(a) If all the holes start with 0, then how do we increment? Apparently this is not possible; one hole must contain a single pebble.
(b) The conditional "jump" occurs on every instance of XYZ type because: if it cannot be performed because X does not have enough counters/pebbles then the jump occurs; otherwise if it can be performed it will be and the instructions continue to the next in sequence.
(c) Neither SXY nor XXY can cause a jump because both can always be performed.
(d) Melzak adds indirection to his model (see Random access machine) and gives two examples of its use. But he does not pursue this further. This is the first verified instance of "indirection" to appear in the literature.
(e) Both papers -- that of Z. Alexander Melzak (William Lowell Putnam Mathematical Competition, winner 1950) was received 15 May 1961 and Joachim Lambek received a month later on 15 June 1961 -- are contained in the same volume, one after the other.
(f) Is Melzak's assertion true? -- that this model is "so simple that its working could probably be understood by an average school-child after a few minutes's explanation" (p. 282)? The reader will have to decide.

1961: Lambek "abacus" model: atomizing Melzak's model to X+, X- with test

Original "abacus" model of Lambek (1962):

Lambek references Melzak's paper. He atomizes Melzak's single 3-parameter operation (really 4 if we count the instruction addresses) into a 2-parameter increment "X+" and 3-parameter decrement "X-". Interestingly, he also provides both an informal and formal definition of "a program". This form is virtually identical to the Minsky (1961) model, and has been adopted by Boolos-Burgess-Jeffrey (2002).

Action: Description:
a. X+ (r, Ia) [ r ] + 1 → r; go to instruction Ia. Increment (add 1 to) contents of register r
b. X- (r, Ia, Ib) If [ r ] ≤ 0, go to instr.Ib else [ r ]-1 → r and go to instr. Ia First test for zero, then decrement (subtract 1 from) contents of register r

Abacus model of Boolos-Burgess (1970, etc), Boolos-Burgess-Jeffrey (2002):

The various editions beginning with 1970 the authors use the Lambek (1961) model of an "inifinite abacus". This series of Wikipedia articles is using their symbolism, e.g. " [ r ] +1 → r" "the contents of register identified as number 'r', plus 1, replaces the contents of [is put into] register number 'r' ".

They use Lambek's name "abacus" but follow Melzak's pebble--in-holes model, modified by them to a 'stones-in-boxes' model. Like the original abacus model of Lambek, their model retains the Minsky (1961) use of non-sequential instructions -- unlike the "conventional" computer-like default sequential instruction execution, the next instruction Ia is contained within the instruction.

Observe, however, that B-B and B-B-J do not use a variable "X" in the mnemonics with a specifying parameter (as shown in the Lambek version) --i.e. "X+" and "X-" -- but rather the instruction mnemonics specifies the registers themselves, e.g. "2+", or "3-":

Action: Description:
a1. 1+ (Ia) [ r1 ] + 1 → r1 then go to instruction Ia. Increment (add 1 to) contents of register #1
b1. 1- (Ia, Ib) If [ r1 ] ≤ 0 THEN go to Ib else [ r1 ] -1 → r1 and go to Ia. Jump to instruction Ib if contents of register r1 is zero ELSE decrement (subtract 1 from) contents of register #1

1963: Shepherdson and Sturgis' model

On page 218 Shepherdson and Sturgis references Minsky (1961) as it appeared for them in the form of an M.I.T. Lincoln Laboratory Report:

In Section 10 we show that theorems (including Minsky's results [21, their reference]) on the computation of partial recursive functions by one or two tapes can be obtained rather easily from one of our intermediate forms (p. 218).

Their model is strongly influenced by the model and the spirit of Hao Wang (1957) and his Wang B-machine (also see Post-Turing machine). They "sum up by saying":

"...we have tried to carry a step further the 'rapprochement' between the practical and theoretical aspects of computation suggested and started by Wang."

Unlimited Register Machine URM: This, their "most flexible machine... consists of a denumerable sequence of registers numbered 1, 2, 3, ..., each of which can store any natural number...Each particular program, however involves only a finite number of these registers" (p. 219). In other words, the number of registers is potentially infinite, and each register's "size" is infinite.

They offer the following instruction set (p. 219), and the following "Notes":

URM model: Action: Description:
a. P(n) [ r ] + 1 → r Increment (add 1 to) contents of register r
b. D(n) [ r ] - 1 → r Decrement (subtract 1 from) contents of register r
c: O(n) 0 → r Zero (clear) register r
d. C(m,n) [ rj ] → rk, [ rj ] → rj, Copy contents of register rj to register rk
e. J[E1] Jump to "Exit 1" Unconditional jump to "Exit #1"
f: J(r) [E1] IF [ rj ] = 0 THEN jump to "Exit 1" ELSE next instruction IF contents of register r = 0 then jump to instruction "Exit 1" else next



"(1) This set of instructions is chosen for ease of progrmming the computation of partial recursive functions rather than economy; it is shown in Section 4 that this set is equivalent to a smaller set.
"(2) There are infinitely many instructions in this list since m, n [ contents of rj, etc] range over all positive integers.
(3) In instructions a, b, c, d the contents of all registers except n are supposed to be left unchanged; in instructions e, f, the contents of all registers are unchanged (p. 219).

Indeed, they show how to reduce this set further, to the following (for an infinite number of registers each of infinite size):

Reduced URM: Action: Description:
a1. P(r) [ r ] + 1 → r Increment (add 1 to) contents of register r
b1. D(n) [ r ] - 1 → r Decrement (subtract 1 from) contents of register r
~f1: J(r) [E1] IF [ r ] ≠ 0 THEN jump to "Exit 1" If contents of register m ≠ 0 THEN jump to instruction "Exit 1" ELSE continue

Limited Register Machine LRM: Here they restrict the machine to a finite number of registers N, but they also allow more registers to "be brought in" or removed if empty (cf p. 228). They show that the remove-register instruction need not require an empty register.

Single-Register Machine SRM: Here they are implementing the tag system of Emil Post and thereby allow only writing to the end of the string and erasing from the beginning. This is shown in their Figure 1 as a tape with a read head on the left and a write head on the right, and it can only move the tape right. "A" is their "word" (p. 229):

a. P(i)  ;add ai to the end of A
b. D  ;delete the first letter of A
f'. Ji[E1]  ;If A begins with ai jump to exit 1.

They also provide a model as "a stack of cards" with the symbols { 0, 1 } (p. 232 and Appendix C p. 248):

(1) add card at top printed 1
(2) add card at top printed 1
(3) remove bottom card; if printed 1 jump to instruction m, else next instruction.

1967: Minsky's "Simple Universal Base for a Program Computer"

Ultimately, in Problem 11.7-1 Minksy observes that many bases of computation can be formed from a tiny collection:

"Many other combinations of operation types [ 0 ], [ ' ], [ - ], [ O- ], [ → ] and [ RPT ] form universal basis. Find some of these basis. Which combinations of three operations are not universal basis? Invent some other operations..."(p. 214)

The following are definitions of the various instructions he treats:

Action: Description:
a. [ 0 ] 0 → r Zero (clear) register r
b. [ ' ] [ r ] + 1 → r Increment (add 1 to) contents of register r ( apostrophe ' signifies "successor" )
c. [ - ] IF [ r ] = 0 THEN jump to instruction z ELSE next instruction Test register r and jump to instruction z if contents is zero; if not, decrement (subtract 1 from) contents of register r
d. [ O- ] If [ r ] ≠ 0 THEN [ r ] -1 → r ELSE next instruction IF contents of register r not zero decrement contents of register r and jump to zth instruction, else if 0 then next instruction
e. [ → ] [ rj ] → rk , [ rj ] → rj Copy contents of register rj to register rk
f. [ RPT] RPT a:[m,n]. Repeat cannot operate within its own range. Do until contents of register [ r ] = 0: Repeat instructions m thru n. When [ r ] = 0, go to next instruction.
g. [ H ] HALT
h. goto(z) Jump to instruction z Unconditional jump to instruction z
i. [ ≠ ] If [ rj ] ≠ [ rk ] THEN jump to zth instruction ELSE next instruction Conditional jump: if contents of register rj not equal to contents of register rk THEN jump to instruction z ELSE next instruction
j. [ RPT]* RPT a:[m,n]. Repeat can operate within its own range. *Note: RPT must be in an infinite register

Minsky (1967) begins with a model that consists of the three operations plus HALT:

{ [ 0 ], [ ' ], [ - ], [ H ] }

He observes that we can dispense with [ 0 ] if we allow for a specific register e.g. w already "empty" (Minsky (1967) p. 206). Later (pages 255ff) he compresses the three { [ 0 ], [ ' ], [ - ] }, into two { [ ' ], [ - ] }.

But he admits the model is easier if he adds some [pseudo]-instructions [ O- ] (combined [ 0 ] and [ - ]) and "go(n)". He builds "go(n)" out of the register w pre-set to 0, so that [O-] (w, (n)) is an unconditional jump.

In his section 11.5 "The equivalence of Program Machines with General-recursive functions" he introduces two new subroutines:

f. [ → ]
j. [ ≠ ]
Jump unless equal": IF [ rj ] ≠ [ rk ] THEN jump to zth instruction ELSE next instruction

He proceeds to show how to replace the "successor-predecessor" set { [ 0 ], [ ' ], [ - ] } with the "successor-equality" set { [ 0 ], [ ' ], [ ≠ ] }. And then he defines his "REPEAT" [RPT] and shows that we can define any primitive recursive function by the "successor-repeat" set { [ 0 ], [ ' ], [RPT] } (where the range of the [ RPT ] cannot include itself. If it does, we get what is called the mu operator (see also mu recursive functions ) (p. 213)):

Any general recursive function can be computed by a program computer using only operations [ 0 ], [ ' ], [ RPT ] if we permit a RPT operation to lie in its own range ... [however] in general a RPT operation could not be an instruction in the finite-state part of the machine...[if it were] this might exhaust any particular amount of storage allowed in the finite part of the machine. RPT operations require infinite registers of their own, in general... [etc." (p. 214)

1980: Schönhage's 0-parameter model RAM0

Schönhage (1980) developed his computational model in context of a "new" model he called the Storage Machine Modification model (SMM), his variety of pointer machine. His development described a RAM (Random access machine) model with a remarkable instruction set requiring no operands at all, excepting, perhaps, the "conditional jump" (and even that could be achieved without an operand):

"...the RAM0 version deserves special attention for its extreme simplicity; its instruction set consists of only a few one-letter codes, without any (explicit) addressing" (p. 494)

The way Schönhage did this is of interest. He (i) atomizes the conventional register "address:datum" into its two parts: "address", and "datum", and (ii) generates the "address" in a specific register n to which the finite-state machine instructions (i.e. the "machine code") would have access, and (iii) provides an "accumulator" register z where all arithmetic operations are to occur.

In his particular RAM0 model has only two "arithmetic operations" -- "Z" for "set contents of register z to zero", and "A" for "add one to contents of register z". The only access to address-register n is via a copy-from-A-to-N instruction called "set address n". To store a "datum" in accumulator z in a given register, the machine uses the contents of n to specify the register's address and register z to supply the datum to be sent to the register.

Peculiarities: A first peculiarity of the Schönhage RAM0 is how it "loads" something into register z: register z first supplies the register-address and then secondly, receives the datum from the register -- a form of indirect "load". The second peculiarity is the specification of the COMPARE operation. This is a "jump if accumulator-register z=zero (not, for example, "compare the contents of z to the contents of the register pointed to by n). Apparently if the test fails the machine skips over the next instruction which always must be in the form of "goto λ" where "λ" is the jump-to address. The instruction -- "compare contents of z to zero" is unlike the Schonhage successor-RAM1 model (or any other known successor-models) with the more conventional "compare contents of register z to contents of register a for equality".

Primarily for reference -- this is a RAM model, not a counter-machine model -- the following is the Schönhage RAM0 instruction set:

Instruction Action: Description:
1 Z 0 → z Clear accumulator-register z
2 A [ z ] + 1 → z Increment the contents of accumulator-register z
3 N [ z ] → n, [ z ] → z "Set address n": copy contents of accumulator z into address-register n
4 L [ [ z ] ] → z Indirectly copy into accumulator z the contents of the register pointed to by accumulator z
5 S [ z ] → [ n ] Indirectly store the contents of accumulator z into the register pointed to by the contents of address-register n
6 C If [ z ] = 0 skip the next instruction (which must be a goto instruction Iλ) If contents of accumulator z = 0 THEN skip next instruction else continue
7 goto Iλ Unconditional goto (jump to) instruction Iλ Unconditional goto (jump to) instruction Iλ

Again, the above instruction set is for a random access machine, a RAM -- a counter machine with indirect addressing; instruction "N" allows for indirect storage of the accumulator, and instruction "L" allows for indirect load of the accumulator.

While peculiar, Schönhage's model shows how the conventional counter-machine's "register-to-register" or "read-modify-write" instruction set can be atomized to its simplest 0-parameter form.

Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Counter machine — A counter machine is an abstract machine used in formal logic and theoretical computer science to model computation. It is the most primitive of the four types of register machines. A counter machine comprises a set of one or more unbounded… …   Wikipedia

  • Counter machine reference model — The Counter machine s reference model is a set of choices and conventions to be used with the Counter machine and other model variants of the Register machine concept. It permits comparisons between models, and serves a didactic function with… …   Wikipedia

  • Register machine — In mathematical logic and theoretical computer science a register machine is a generic class of abstract machines used in a manner similar to a Turing machine. All the models are Turing equivalent. Contents 1 Overview 2 Formal definition 3 …   Wikipedia

  • Random access machine — In computer science, random access machine (RAM) is an abstract machine in the general class of register machines. The RAM is very similar to the counter machine but with the added capability of indirect addressing of its registers. Like the… …   Wikipedia

  • Counter-Strike: Condition Zero — Developer(s) Valve Corporation Gearbox Software Ritual Entertainment Turtle Rock Studios …   Wikipedia

  • Counter-insurgency — Police question a civilian during the Malayan Emergency. Counter insurgency involves action from both military and police authorities …   Wikipedia

  • Machine pistol — This article is about full auto or burst capable pistols. For semi automatic weapons, see semi automatic pistol. A fully automatic Steyr M1912, which was used as a side arm by the Austro Hungarian Army A machine pistol is a handgun style,[1]… …   Wikipedia

  • Turing machine equivalents — Turing machine(s) Machina Universal Turing machine Alternating Turing machine Quantum Turing machine Read only Turing machine Read only right moving Turing Machines Probabilistic Turing machine Multi track Turing machine Turing machine… …   Wikipedia

  • Turing machine — For the test of artificial intelligence, see Turing test. For the instrumental rock band, see Turing Machine (band). Turing machine(s) Machina Universal Turing machine Alternating Turing machine Quantum Turing machine Read only Turing machine… …   Wikipedia

  • Pointer machine — In theoretical computer science a pointer machine is an atomistic abstract computational machine model akin to the Random access machine.Depending on the type, a pointer machine may be called a linking automaton, a KU machine, an SMM, an… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”