Register Machine
1. Register Machines
Register machines operate on natural numbers
- Add
to the contents of a register (increment). - Test whether the contents of a register is zero (test).
- Subtract
from the contents of a register, provided the register is not empty (decrement). - Jump to another instruction (goto).
- Conditional jump to another instruction (if_then_else_).
A register machine is specified by:
- Finitely many reigsters
, each capable of storing a natural number. - A program consisting of a finite list of instructions of the form
, where for , the -th instruction is labeled . The instruction body takes the form:
: Add to the contents of register and jump to instruction . : If the contents of is , subtract from and jump to ; otherwise, jump to . : Halt the machine.
For example:
1.1. Configurations
A register machine configuration has the form
means .
The initial configuration of a register machine is
Non-halting computations are computations which never halt. For example:
1.2 Graphical Representation
- One node in the graph for each instruction.
- Node labelled by the register of the instruction body.
denotes the register contents at label . - Arcs represent jumps between instructions.
- Initial instruction
.
1.3 Partial Functions
Register machine computation is deterministic: in any non halting configuration, the next configuration is uniquely determined by the program. So, the relation between an initial and final register contents defined by a register machine program is a partial function.
A partial function from set
to set is specified by any subset satisfying:
Notation:
means . means . means . denotes the set of all partial functions from to . denotes the set of all total functions from to .
A function is total if it satisfies
A partial function
The computation of
starting with halts with if and only if .
2. The Halting Problem
The Halting Problem is a decision problem with:
- The set
of all pairs , where is an algorithm and is some input datum on which the algorithm is designed to operate. - The property
holds for if the algorithm halts on input .
The halting problem is unsolvable. i.e., there is no algorithm
3. Numerical Coding of Pairs
For
gives a bijection between and . gives a bijection between and .
It is enough to observe that:
followed by number of s. followed by number of s.
4. Numerical Coding of Lists
Let
- Empty list:
. - List cons:
, if and .
Notation:
For
This gives a bijection from
Thus
For example,
5. Numerical Coding of Programs
If
Then its numerical code is
Any
- if
then - else
. Let in:- if
is even, then - else
is odd, then let in
- if
So any