Created
October 22, 2019 16:28
-
-
Save agrif/b89c450a83196b3655b04fb07c9f9fb5 to your computer and use it in GitHub Desktop.
a crappy python proof that the halting problem is unsolvable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def halts(f, x): | |
# returns True if f(x) halts | |
# False if it runs forever | |
# notably, to solve the halting problem, it *must* return either True or False | |
# it can't just run forever... | |
return magic_turing_oracle(f, x) | |
def sneaky(f): | |
# see if f halts when passed itself as input... | |
if halts(f, f): | |
# f halts, so we shouldn't | |
while True: pass | |
else: | |
# f doesn't halt, so we should | |
return | |
# what on *earth* does this do? | |
print(halts(sneaky, sneaky)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment