Please solve this question Dont copy answers from online Pri
Please solve this question. Don\'t copy answers from online.
Printing All x Where M(x) Halts Prove that it is possible to write a program P which: takes as input M, a java program runs forever, and prints out strings to the console for every x, if M(x) halts, then P(M) eventually prints out x for every x, if M(x) does NOT halt, then P(M) never prints out xSolution
The Halting Problem is:
INPUT: A string M and a string x. We will think of P as a program.
OUTPUT: P(M) print out x, if M(x) halts, and if M(x) does not halt then never prints out x.
Proof: Assume to reach a contradiction that there exists a program Halt(M, x) that solves the halting problem, Halt(M, x) returns True if and only M(x) halts. The given this program for the Halting Problem, we could construct the following code P:
