Implement unlimited register machines

Assignment Help Programming Languages
Reference no: EM133181748

ITECH 5403 Comparative Programming Languages - Federation University

Modelling Unlimited Register Machines

Introduction.

Unlimited Register Machines (or URMs) are mathematical abstractions of real-life computers. They are more user-friendly than Turing Machines and make an ideal introduction to machine models of computability. Any effectively computable function can be computed on a URM.
URMs were invented by J. C. Shepherdson and H.
E. Sturgis.
In this assignment you are required to implement Unlimited Register Machines (URMs) using three different languages - Java, Python and LISP. i.e., you are required to write programs in these languages that imitate the functionality of URMs (to develop Virtual URMs).

1. Description of the Unlimited Register Machines,
A URM has registers R0,R1,R2,..., which store natural numbers r0,r1,r2,...:

R0

R1

R2

R3

R4

R5

...

r0

r1

r2

r3

r4

r5

...

A URM program is a finite list of instructions, each having one of the four following basic types:

Instruction Type

Notation

Effect

Zero

Z(n)

rn = 0

Successor

S(n)

rn = rn+1

Transfer

T(m,n)

rn = rm

Jump

J(m,n,q)

If rn = rm go to instruction q, else go to the next instruction.

• Z(n) - sets value of register Rn to zero and moves to the next instruction in the program list.
• S(n) - increases the value of register Rn by one and moves to the next instruction in the program list.
• T(m,n) - copies the value of Rm to Rn and moves to the next instruction in the program list.
• J(m,n,q) - if rm = rn, the instruction at index q in the program list is executed. Else the next instruction in the program list is executed.
URM programs are zero-based indexed lists of instructions, i.e., instructions in a program can be accessed via indexes and the index of the first instruction is 0.

A URM program starts with the first instruction (at index 0) and executes instructions consecutively, one by one, unless it encounters the Jump instruction. The program halts after execution reaches the end of the program list or a Jump instruction J(m,n,q) is executed, where q is not a valid index in the program list.

URM is used to compute functions that take integer parameters and return an integer value.

Input and Output conventions: To compute a function f(n1, ... , nk), we start with n1, ... , nk in registers R0, ... , Rk-1, respectively, and with 0 in all the other registers. If computation halts, the output is the number in register R0.

Example 1. Addition function, m + n, can be computed by the following URM program:
0) J(1,2,4)
1) S(0)
2) S(2)
3) J(0,0,0)

Example 2. Product function, m*n, can be computed by the following URM program:
0) T(0,2)
1) Z(0)
2) Z(3)
3) Z(4)
4) J(2,4,13)
5) J(1,3,13)
6) S(0)
7) S(4)
8) J(2,4,10)
9) J(1,1,6)
10)S(3)
11)Z(4)
12)J(1,1,5)

Programming tasks.

You are required to implement Unlimited Register Machines (URMs) in three different languages - Java, C and Python.

Implementation Requirements:
• Set of URM's registers should be implemented as an array or list of integers.
• Instruction types should be coded by the integers
{0,1,2,3}: use 0 for Z, 1 for S, 2 for T and 3 for J.
• Instructions should be represented by arrays or lists of integers, for example, instruction J(1,2,4) in your Python program should be represented by the list [3,1,2,4].
• Programs should be implemented as arrays or lists of instructions. For example, the program from Example 1 should be represented by the following list of lists in your Python implementation:
program = [[3,1,2,4], [1,0], [1,2], [3,0,0,0]]

Also, you are required to write the following three functions/methods in each of the implementations:
(1) isValidCommand(command) - takes a list/array of integers and returns true if it is a valid URM command, otherwise returns false.
(2) isValidProgram(program) - takes a list of instructions and returns true if it is a valid URM program, otherwise returns false.
(3) run(program, registers) - runs the URM program on the list/array of registers.
(4) main() - this is a testing method/function where you test your implementation of URM by running the program from Example 1.

3. Write a URM power program.
In this task you are required to write and test, using one of your implementations, a URM program that computes the power function. I.e., power(m,n) should compute mn.
For example, power(2,3) should return 8.

Attachment:- Comparative Programming Languages.rar

Reference no: EM133181748

Questions Cloud

Dan price of gravity payments : Dan's philosophy on paying employees has changed over the years. What happened? Describe his journey in this area.
Create evaluation plan using the kirkpatrick model : Create an evaluation plan using the Kirkpatrick model to ensure that training is effective. Give a very brief example of each stage.
Determine the compensation and benefits : 1) One of the main functions of HRM is "Compensation and Benefits". Explain clearly what this function is and then discuss how this function can help specifical
Recruitment challenges unique to today organizations : Could you help me research a peer-reviewed article you regarding recruitment challenges unique to today's organizations. Also, could you explain each challenge
Implement unlimited register machines : Implement Unlimited Register Machines (URMs) using three different languages - Java, Python and LISP - write and test, using one of your implementations
Evaluation of financial statements : Internal users of financial statements use the information to make key business decisions. Some common users include managers, employees, internal accountants,
Flow of health information for newly hired hit : As the HIT Supervisor, you have been given the task of developing a new training program including the flow of health information for newly hired HIT.
Determining reasonable notice : Identify the factors that a court considers in determining reasonable notice when an employer dismisses an employee without just cause?
Define a push strategy : Give an example of a push strategy. Define a pull strategy. Under what situation would a "pull strategy" be used? Give an example of a pull strategy.

Reviews

Write a Review

Programming Languages Questions & Answers

  Program to keep track of a cd or dvd collection

Write a program to keep track of a CD or DVD collection. This can only work exclusively with either CDs or DVDs since some of the data is different.

  Create two objects p and q and generate 10 random numbers

Create Two objects P and Q. in object P the array a is type int and size 10, in Q array a is string type and size 12b. Generate 10 random numbers

  Write program which trace execution of RSA cryptosystem

You have to write a program (in the language of your choice) which will trace the execution of the RSA cryptosystem on a simple example

  Write sql to perform the following queries and updates

Retrieve all of your customers' names, account numbers, and addresses (street and zip code only), sorted by account number

  Design a program that asks the user to enter ten golf scores

Design a program that asks the user to enter 10 golf scores. The scores should be stored in an Integer array. Sort the array in ascending order and display its contents.

  Explain the process of migrating existing data to testing

CMGT 445-Develop a data conversion plan that describes the process of migrating existing data to the testing platform. Explain the methods and procedures that will be used to conduct the testing.

  Write script which declares and sets variable

Write the script which declares and sets a variable that's equal to total outstanding balance due. If that balance is greater than $10,000.00, the script must return the result set consisting of VendorName,

  Pseudocode for a program to solve mathematical problem

Pseudocode for a program to solve the following problem. A student borrows $3,000 at an interest rate 2% per month on the unpaid balance.

  Explain big o notation

What does "n" represent in relation to big O notation?

  Discuss the ui thread

I have a C# WPF app that needs to call an unmanaged C++ DLL and get a simple event notification from it. The DLL will wait for a keyboard event.

  Explain how and why you have designed your program

the program needs to read the radius of a circle from the user - You program should then display the circle on the screen in a random location

  Find out the total of balances

Display all the contents of the file in a tabular format with the first row being a header row and write to a file that is called account numbers.txt only the account numbers from the read file.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd