Discussion

Am open to constructive criticism: My Halting Problem solution

I may be wrong about this, feel free to offer constructive criticism:

Step 1: Load the program and initialize my Halting Problem program's variable n to 0.

Step 2: Save the register context (meaning all the values in all the registers in a CPU) to memory location A.

Step 3: Step variable n + 1 instructions.

Step 4: Save the register context (meaning all the values in all the registers in a CPU) to memory location B.

Step 5: Compare the contents of memory location A to memory location B. If they match exactly, then exit with a return code of "This program is in an infinite loop", if they don't match exactly, then goto Step 2.

The variable n is an unsigned fixed point arbitrary precision integer.

If this solves the Halting Problem as proposed by Alan Turing, then does this also solve P versus NP?

An example of this working:

ax is a 2 bit register initialized to 0.

100: add 1 ax

101: jmp 100

ax is 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3

0 is compared to 1, 1 is compared to 3, 3 is compared to 2, 2 is is compared to 2, wait, that's an infinite loop...

Well, my program basically detects if a infinite loop is of 1 iteration or two iterations or three iterations or ... iterations, but only infinite loops and not finite loops and in a finite amount of time. This means that finite loops don't trigger my program ever, only infinite ones after a finite amount of time.

TLDR: A turing machine can run my program and determine whether any other program halts or infinite loops in a finite amount of time, never infinite only if the variable n can be infinitely large.

3 points vitarnixofntrnt 2 years ago 12 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton