Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

thank you!! 2. Deciding Simple Properties of Programs Suppose you are given a (magical) procedure Halt that works with programs in your favorite general purpose

image text in transcribed

image text in transcribed

thank you!!

2. Deciding Simple Properties of Programs Suppose you are given a (magical) procedure Halt that works with programs in your favorite general purpose language as follows. Halt takes as input a string representing an arbitrary program P (written in programming language L) which requires no input. . Halto(P) returns Yes if program P will halt without reading any input when executed. . Halto(P) returns No if program P will not halt when executed with no input You should not make any assumptions about the behavior of Haltg on arguments that do not consist of a syntactically correct program. As you can see Halt essentially solves the Halting Problem for programs that take no input (a) Show how to solve the (regular) Halting Problem for programs with a single integer input using Haltg. More specifically, write a procedure Halt that reads a program text P as input, reads a single integer n as input, and then decides whether or not P would halt if it ran and read n as its input. Such a Halt program would have the following form, P-readString; n-readInteger O; and it would print Yes if P halts when it runs and reads input n and No if P does not halt when it runs and reads input n You may assume that any program P you are given begins with a read statement that reads a single integer from standard input. Thus P has the form x = readInteger(); Q where Q is the rest of the program text, and Q does not perform any input Explain your solution by describing how a program solving the haltig problem would there is no need to write the program out fully. Hint: Remember the key is to start with a possible input P and n for the halting problem and to modify the program P to a program P (whose tert depends on both P and n) and show that using Halt P)nPwill determine whether the original program P will halt on n (b) On the basis of the previous part, explain why Haltg could not be written in Java (or again, any other Turing-complete language). Solution

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

What is the significance of the critical constants?

Answered: 1 week ago

Question

When should you avoid using exhaust brake select all that apply

Answered: 1 week ago