Urm program that computes the product of two numbers

Assignment Help Other Subject
Reference no: EM133001084

ASSIGNMENT - 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, C and Python. 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)

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 program.
In this task you are required to write and test a URM program that computes the product of two numbers.

Attachment:- Modelling Unlimited Register Machines.rar

Reference no: EM133001084

Questions Cloud

What kind of manufacturing and supply chain capacity : You are the Vice President, Operations for a battery. What kind of manufacturing and supply chain capacity strategy are you going to use and why?
Disadvantages of quantitative and qualitative research : Compare and contrast the advantages and disadvantages of quantitative and qualitative research.
What is the annual rate of interest : Cortezar purchases a property for $255,000 and puts 20% down. The monthly interest payments are $1,742.50. What is the annual rate of interest?
Solve the expected return and the volatility : Solve (a) the expected return and (b) the volatility (standard deviation) of a portfolio that is equally invested in Johnson & Johnson's and Walgreens' stock.
Urm program that computes the product of two numbers : Modelling Unlimited Register Machines - Write and test a URM program that computes the product of two numbers.
What amount of risk-free profit could ian make per contract : The current price of one share of JDV stock is 52. The stock does not pay dividends. The price of a one year put option on JDV with a strike price of 50 is 6.84
Real estate area problems : 1. A building's dimensions are 35' × 60' × 9'. How many square feet does it contain?
Which will increase the volatility of portfolio : Which will increase the volatility of portfolio: (i) selling a small amount of stock B and investing the proceeds in stock? A, or? (ii) selling a small amount
Compute the volatility of an equally weighted portfolio with : Compute the volatility of an equally weighted portfolio with. Suppose that the average stock has a volatility of 57%, and that the correlation between pairs.

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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