V. Register Machine Yuxi Fu BASICS, Shanghai Jiao Tong University - - PowerPoint PPT Presentation

v register machine
SMART_READER_LITE
LIVE PREVIEW

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:


slide-1
SLIDE 1
  • V. Register Machine

Yuxi Fu

BASICS, Shanghai Jiao Tong University

slide-2
SLIDE 2

Register Machines are more abstract than Turing Machines.

Computability Theory, by Y. Fu

  • V. Register Machine

1 / 35

slide-3
SLIDE 3

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

slide-4
SLIDE 4

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

slide-5
SLIDE 5
  • 1. Unlimited Register Machine

Computability Theory, by Y. Fu

  • V. Register Machine

4 / 35

slide-6
SLIDE 6

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

slide-7
SLIDE 7

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

slide-8
SLIDE 8

Program

A URM also has a program, which is a finite list of instructions.

Computability Theory, by Y. Fu

  • V. Register Machine

7 / 35

slide-9
SLIDE 9

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

slide-10
SLIDE 10

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

slide-11
SLIDE 11

Configuration and Computation

Configuration: register contents + current instruction number. Initial configuration, computation, final configuration.

Computability Theory, by Y. Fu

  • V. Register Machine

10 / 35

slide-12
SLIDE 12

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

slide-13
SLIDE 13

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

slide-14
SLIDE 14
  • 2. Definability in URM

Computability Theory, by Y. Fu

  • V. Register Machine

13 / 35

slide-15
SLIDE 15

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

slide-16
SLIDE 16

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

slide-17
SLIDE 17

Example of URM

Construct a URM that computes x + y.

Computability Theory, by Y. Fu

  • V. Register Machine

16 / 35

slide-18
SLIDE 18

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

slide-19
SLIDE 19

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

slide-20
SLIDE 20

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

slide-21
SLIDE 21

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

slide-22
SLIDE 22

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

slide-23
SLIDE 23

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

slide-24
SLIDE 24

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

slide-25
SLIDE 25

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

slide-26
SLIDE 26

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

slide-27
SLIDE 27

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

slide-28
SLIDE 28

Definability of Initial Function

  • Fact. The initial functions are URM-definable.

Computability Theory, by Y. Fu

  • V. Register Machine

24 / 35

slide-29
SLIDE 29

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

slide-30
SLIDE 30

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

slide-31
SLIDE 31

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

slide-32
SLIDE 32

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

slide-33
SLIDE 33

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

slide-34
SLIDE 34

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

slide-35
SLIDE 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

slide-36
SLIDE 36

Main Result

  • Theorem. All recursive functions are URM-definable.

Computability Theory, by Y. Fu

  • V. Register Machine

32 / 35

slide-37
SLIDE 37
  • 3. Simulation of TM by URM

Computability Theory, by Y. Fu

  • V. Register Machine

33 / 35

slide-38
SLIDE 38

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

slide-39
SLIDE 39
  • Exercise. Describe an algorithm that transforms a TM to a URM.

Computability Theory, by Y. Fu

  • V. Register Machine

35 / 35