- V. Register Machine
V. Register Machine Yuxi Fu BASICS, Shanghai Jiao Tong University - - PowerPoint PPT Presentation
V. Register Machine Yuxi Fu BASICS, Shanghai Jiao Tong University - - PowerPoint PPT Presentation
V. Register Machine Yuxi Fu BASICS, Shanghai Jiao Tong University Register Machines are more abstract than Turing Machines. Computability Theory, by Y. Fu V. Register Machine 1 / 35 Register Machine Models can be classified into three groups:
Register Machines are more abstract than Turing Machines.
Computability Theory, by Y. Fu
- V. Register Machine
1 / 35
Register Machine Models can be classified into three groups:
◮ CM (Counter Machine Model)
◮ Unlimited Register Machine Model
◮ RAM (Random Access Machine Model) ◮ RASP (Random Access Stored Program Machine Model)
Computability Theory, by Y. Fu
- V. Register Machine
2 / 35
Synopsis
- 1. Unlimited Register Machine
- 2. Definability in URM
- 3. Simulation of TM by URM
Computability Theory, by Y. Fu
- V. Register Machine
3 / 35
- 1. Unlimited Register Machine
Computability Theory, by Y. Fu
- V. Register Machine
4 / 35
Unlimited Register Machine Model
Unlimited Register Machines are introduced by Shepherdson and Sturgis in Computability and Recursive Functions. Journal of Symbolic Logic, 32:1-63, 1965.
Computability Theory, by Y. Fu
- V. Register Machine
5 / 35
Register
An Unlimited Register Machine (URM) has an infinite number of register labeled R1, R2, R3, . . .. r1 r2 r3 r4 r5 r6 r7 . . . R1 R2 R3 R4 R5 R6 R7 . . . Every register can hold a natural number at any moment. The registers can be equivalently written as for example [r1, r2, r3]3
1[r4]4 4[r5, r6, r7]7 5[0, 0, 0, . . .]∞ 8
- r simply
[r1, r2, r3]3
1[r4]4 4[r5, r6, r7]7 5.
Computability Theory, by Y. Fu
- V. Register Machine
6 / 35
Program
A URM also has a program, which is a finite list of instructions.
Computability Theory, by Y. Fu
- V. Register Machine
7 / 35
Instruction
type instruction response of URM Zero Z(n) Replace rn by 0. Successor S(n) Add 1 to rn. Transfer T(m, n) Copy rm to Rn. Jump J(m, n, q) If rm = rn, go to the q-th instruction;
- therwise go to the next instruction.
Computability Theory, by Y. Fu
- V. Register Machine
8 / 35
Computation
Registers: 9 7 . . . R1 R2 R3 R4 R5 R6 R7 Program: I1 : J(1, 2, 6) I2 : S(2) I3 : S(3) I4 : J(1, 2, 6) I5 : J(1, 1, 2) I6 : T(3, 1)
Computability Theory, by Y. Fu
- V. Register Machine
9 / 35
Configuration and Computation
Configuration: register contents + current instruction number. Initial configuration, computation, final configuration.
Computability Theory, by Y. Fu
- V. Register Machine
10 / 35
Some Notation
Suppose P is the program of a URM and a1, a2, a3, . . . are the numbers stored in the registers.
◮ P(a1, a2, a3, . . .) is the initial configuration. ◮ P(a1, a2, a3, . . .) ↓ means that the computation converges. ◮ P(a1, a2, a3, . . .) ↑ means that the computation diverges. ◮ P(a1, a2, . . . , am) is P(a1, a2, . . . , am, 0, 0, . . .).
Computability Theory, by Y. Fu
- V. Register Machine
11 / 35
Every URM uses only a fixed finite number of registers, no matter how large an input number is.
Computability Theory, by Y. Fu
- V. Register Machine
12 / 35
- 2. Definability in URM
Computability Theory, by Y. Fu
- V. Register Machine
13 / 35
URM-Computable Function
Let f ( x) be an n-ary partial function. What does it mean that a URM computes f ( x)?
Computability Theory, by Y. Fu
- V. Register Machine
14 / 35
URM-Computable Function
Suppose P is the program of a URM and a1, . . . , an, b ∈ ω. The computation P(a1, . . . , an) converges to b if P(a1, . . . , an) ↓ and r1 = b in the final configuration. In this case we write P(a1, . . . , an) ↓ b. P URM-computes f if, for all a1, . . . , an, b ∈ ω, P(a1, . . . , an) ↓ b iff f (a1, . . . , an) = b. The function f is URM-definable if there is a program that URM-computes f .
Computability Theory, by Y. Fu
- V. Register Machine
15 / 35
Example of URM
Construct a URM that computes x + y.
Computability Theory, by Y. Fu
- V. Register Machine
16 / 35
Example of URM
Construct a URM that computes x + y. I1 : J(3, 2, 5) I2 : S(1) I3 : S(3) I4 : J(1, 1, 1)
Computability Theory, by Y. Fu
- V. Register Machine
16 / 35
Example of URM
Construct a URM that computes x ˙ −1 = x − 1, if x > 0, 0, if x = 0.
Computability Theory, by Y. Fu
- V. Register Machine
17 / 35
Example of URM
Construct a URM that computes x ˙ −1 = x − 1, if x > 0, 0, if x = 0. I1 : J(1, 4, 8) I2 : S(3) I3 : J(1, 3, 7) I4 : S(2) I5 : S(3) I6 : J(1, 1, 3) I7 : T(2, 1)
Computability Theory, by Y. Fu
- V. Register Machine
17 / 35
Example of URM
Construct a URM that computes x ÷ 2 = x/2, if x is even, undefined, if x is odd.
Computability Theory, by Y. Fu
- V. Register Machine
18 / 35
Example of URM
Construct a URM that computes x ÷ 2 = x/2, if x is even, undefined, if x is odd. I1 : J(1, 2, 6) I2 : S(3) I3 : S(2) I4 : S(2) I5 : J(1, 1, 1) I6 : T(3, 1)
Computability Theory, by Y. Fu
- V. Register Machine
18 / 35
Function Defined by Program
f n
P (a1, . . . , an) =
b, if P(a1, . . . , an) ↓ b, undefined, if P(a1, . . . , an) ↑ .
Computability Theory, by Y. Fu
- V. Register Machine
19 / 35
Program in Standard Form
A program P = I1, . . . , Is is in standard form if, for every jump instruction J(m, n, q) we have q ≤ s + 1. For every program there is a program in standard form that computes the same function. We will focus exclusively on programs in standard form.
Computability Theory, by Y. Fu
- V. Register Machine
20 / 35
Program Composition
Given Programs P and Q, how do we construct the sequential composition P; Q? The jump instructions of P and Q must be modified.
Computability Theory, by Y. Fu
- V. Register Machine
21 / 35
Some Notations
Suppose the program P computes f . Let ρ(P) be the least number i such that the register Ri is not used by the program P.
Computability Theory, by Y. Fu
- V. Register Machine
22 / 35
Some Notations
The notation P[l1, . . . , ln → l] stands for the following program I1 : T(l1, 1) . . . In : T(ln, n) In+1 : Z(n + 1) . . . Iρ(P) : Z(ρ(P)) : P : T(1, l)
Computability Theory, by Y. Fu
- V. Register Machine
23 / 35
Definability of Initial Function
- Fact. The initial functions are URM-definable.
Computability Theory, by Y. Fu
- V. Register Machine
24 / 35
Definability of Composition
- Fact. If f (y1, . . . , yk) and g1(
x), . . . , gk( x) are URM-definable, then the composition function h( x) given by h( x) ≃ f (g1( x), . . . , gk( x)) is URM-definable.
Computability Theory, by Y. Fu
- V. Register Machine
25 / 35
Definability of Composition
Let F, G1, . . . , Gk be programs that compute f , g1, . . . , gk. Let m be max{n, k, ρ(F), ρ(G1), . . . , ρ(Gk)}. Registers: [. . .]m
1 [
x]m+n
m+1[g1(
x)]m+n+1
m+n+1 . . . [gk(
x)]m+n+k
m+n+k
Computability Theory, by Y. Fu
- V. Register Machine
26 / 35
Definability of Composition
The program for h: I1 : T(1, m + 1) . . . In : T(n, m + n) In+1 : G1[m + 1, m + 2, . . . , m + n → m + n + 1] . . . In+k : Gk[m + 1, m + 2, . . . , m + n → m + n + k] In+k+1 : F[m + n + 1 . . . , m + n + k → 1]
Computability Theory, by Y. Fu
- V. Register Machine
27 / 35
Definability of Recursion
- Fact. Suppose f (
x) and g( x, y, z) are URM-definable. The recursion function h( x, y) defined by the following recursion h( x, 0) ≃ f ( x), h( x, y + 1) ≃ g( x, y, h( x, y)) is URM-definable.
Computability Theory, by Y. Fu
- V. Register Machine
28 / 35
Definability of Recursion
Let F compute f and G compute g. Let m be max{n, ρ(F), ρ(G)}. Registers: [. . .]m
1 [
x]m+n
m+1[y]m+n+1 m+n+1[k]m+n+2 m+n+2[h(
x, k)]m+n+3
m+n+3.
Program: I1 : T(1, m + 1) . . . In+1 : T(n + 1, m + n + 1) In+2 : F[1, 2, . . . , n → m + n + 3] In+3 : J(m + n + 2, m + n + 1, n + 7) In+4 : G[m + 1, . . . , m + n, m + n + 2, m + n + 3 → m + n + 3] In+5 : S(m + n + 2) In+6 : J(1, 1, n + 3) In+7 : T(m + n + 3, 1)
Computability Theory, by Y. Fu
- V. Register Machine
29 / 35
Definability of Minimization
- Fact. If f (
x, y) is URM-definable, then the minimization function µy(f ( x, y) = 0) is URM-definable.
Computability Theory, by Y. Fu
- V. Register Machine
30 / 35
Definability of Minimization
Suppose F computes f ( x, y). Let m be max{n + 1, ρ(F)}. Registers: [. . .]m
1 [
x]m+n
m+1[k]m+n+1 m+n+1[0]m+n+2 m+n+2.
Program: I1 : T(1, m + 1) . . . In : T(n, m + n) In+1 : F[m + 1, m + 2, . . . , m + n + 1 → 1] In+2 : J(1, m + n + 2, n + 5) In+3 : S(m + n + 1) In+4 : J(1, 1, n + 1) In+5 : T(m + n + 1, 1)
Computability Theory, by Y. Fu
- V. Register Machine
31 / 35
Main Result
- Theorem. All recursive functions are URM-definable.
Computability Theory, by Y. Fu
- V. Register Machine
32 / 35
- 3. Simulation of TM by URM
Computability Theory, by Y. Fu
- V. Register Machine
33 / 35
Simulating TM by URM
Suppose M is a 3-tape TM with the alphabet {0, 1, , ⊲}. The URM that simulates M can be designed as follows:
◮ Suppose that Rm is the right most register that is used by a
program calculating x ˙ −1.
◮ The head positions are stored in Rm+1, Rm+2, Rm+3. ◮ The three binary strings in the tapes are stored respectively in
Rm+4, Rm+7, Rm+10, . . ., Rm+5, Rm+8, Rm+11, . . ., Rm+6, Rm+9, Rm+12, . . ..
◮ The states of M are encoded by the states of the URM. ◮ The transition function of M can be easily simulated by the
program of the URM.
Computability Theory, by Y. Fu
- V. Register Machine
34 / 35
- Exercise. Describe an algorithm that transforms a TM to a URM.
Computability Theory, by Y. Fu
- V. Register Machine
35 / 35